From 4f4a855d82a889cebcfca150a7a43909bcb6a346 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 18 Jan 2019 19:04:36 +0000 Subject: [PATCH] libgo: update to Go1.12beta2 Reviewed-on: https://go-review.googlesource.com/c/158019 gotools/: * Makefile.am (go_cmd_vet_files): Update for Go1.12beta2 release. (GOTOOLS_TEST_TIMEOUT): Increase to 600. (check-runtime): Export LD_LIBRARY_PATH before computing GOARCH and GOOS. (check-vet): Copy golang.org/x/tools into check-vet-dir. * Makefile.in: Regenerate. gcc/testsuite/: * go.go-torture/execute/names-1.go: Stop using debug/xcoff, which is no longer externally visible. From-SVN: r268084 --- gcc/go/gofrontend/MERGE | 2 +- gcc/testsuite/ChangeLog | 5 + .../go.go-torture/execute/names-1.go | 12 +- gotools/ChangeLog | 9 + gotools/Makefile.am | 31 +- gotools/Makefile.in | 31 +- libgo/MERGE | 2 +- libgo/Makefile.am | 56 +- libgo/Makefile.in | 64 +- libgo/VERSION | 2 +- libgo/check-packages.txt | 31 +- libgo/configure | 4 +- libgo/configure.ac | 4 +- libgo/go/archive/tar/format.go | 6 +- libgo/go/archive/tar/stat_actime1.go | 2 +- libgo/go/archive/zip/reader.go | 3 + libgo/go/archive/zip/reader_test.go | 6 + libgo/go/archive/zip/struct.go | 4 +- libgo/go/archive/zip/writer.go | 2 +- libgo/go/archive/zip/zip_test.go | 4 +- libgo/go/bufio/bufio.go | 27 +- libgo/go/bufio/bufio_test.go | 20 +- libgo/go/builtin/builtin.go | 6 + libgo/go/bytes/buffer.go | 23 +- libgo/go/bytes/buffer_test.go | 2 +- libgo/go/bytes/bytes.go | 62 +- libgo/go/bytes/bytes_decl.go | 24 - libgo/go/bytes/bytes_test.go | 6 + libgo/go/bytes/compare_test.go | 13 +- libgo/go/bytes/example_test.go | 14 + libgo/go/bytes/indexbyte.c | 73 - libgo/go/bytes/reader.go | 6 +- libgo/go/bytes/reader_test.go | 42 + libgo/go/cmd/cgo/ast.go | 21 + libgo/go/cmd/cgo/doc.go | 11 + libgo/go/cmd/cgo/gcc.go | 926 +- libgo/go/cmd/cgo/godefs.go | 6 + libgo/go/cmd/cgo/main.go | 18 +- libgo/go/cmd/cgo/out.go | 46 +- libgo/go/cmd/go/alldocs.go | 60 +- libgo/go/cmd/go/go_test.go | 163 +- libgo/go/cmd/go/help_test.go | 28 + libgo/go/cmd/go/internal/cache/cache.go | 8 +- libgo/go/cmd/go/internal/cache/default.go | 103 +- .../go/internal/cache/default_unix_test.go | 67 - libgo/go/cmd/go/internal/cache/hash.go | 2 +- libgo/go/cmd/go/internal/clean/clean.go | 50 +- libgo/go/cmd/go/internal/cmdflag/flag.go | 6 +- libgo/go/cmd/go/internal/doc/doc.go | 9 + libgo/go/cmd/go/internal/envcmd/env.go | 8 +- libgo/go/cmd/go/internal/fix/fix.go | 2 +- libgo/go/cmd/go/internal/generate/generate.go | 2 +- libgo/go/cmd/go/internal/get/get.go | 23 +- libgo/go/cmd/go/internal/get/path.go | 192 + libgo/go/cmd/go/internal/get/vcs.go | 39 +- libgo/go/cmd/go/internal/help/help.go | 20 +- libgo/go/cmd/go/internal/help/helpdoc.go | 10 +- libgo/go/cmd/go/internal/imports/build.go | 2 +- libgo/go/cmd/go/internal/imports/scan.go | 10 + libgo/go/cmd/go/internal/load/pkg.go | 45 +- libgo/go/cmd/go/internal/load/test.go | 6 + .../lockedfile/internal/filelock/filelock.go | 98 + .../internal/filelock/filelock_fcntl.go | 159 + .../internal/filelock/filelock_other.go | 36 + .../internal/filelock/filelock_plan9.go | 38 + .../internal/filelock/filelock_test.go | 209 + .../internal/filelock/filelock_unix.go | 44 + .../internal/filelock/filelock_windows.go | 66 + .../cmd/go/internal/lockedfile/lockedfile.go | 122 + .../lockedfile/lockedfile_filelock.go | 64 + .../internal/lockedfile/lockedfile_plan9.go | 93 + .../go/internal/lockedfile/lockedfile_test.go | 174 + libgo/go/cmd/go/internal/lockedfile/mutex.go | 60 + libgo/go/cmd/go/internal/modcmd/download.go | 12 +- libgo/go/cmd/go/internal/modcmd/edit.go | 45 +- libgo/go/cmd/go/internal/modcmd/init.go | 4 + libgo/go/cmd/go/internal/modcmd/tidy.go | 12 +- libgo/go/cmd/go/internal/modcmd/vendor.go | 18 +- .../cmd/go/internal/modconv/convert_test.go | 2 +- libgo/go/cmd/go/internal/modfetch/cache.go | 90 +- .../go/internal/modfetch/codehost/codehost.go | 50 +- .../cmd/go/internal/modfetch/codehost/git.go | 107 +- .../cmd/go/internal/modfetch/codehost/vcs.go | 105 +- libgo/go/cmd/go/internal/modfetch/coderepo.go | 72 +- .../cmd/go/internal/modfetch/coderepo_test.go | 32 +- libgo/go/cmd/go/internal/modfetch/fetch.go | 318 +- libgo/go/cmd/go/internal/modfetch/proxy.go | 32 +- libgo/go/cmd/go/internal/modfetch/repo.go | 19 +- libgo/go/cmd/go/internal/modfetch/unzip.go | 54 +- libgo/go/cmd/go/internal/modfile/rule.go | 20 +- libgo/go/cmd/go/internal/modget/get.go | 10 +- libgo/go/cmd/go/internal/modload/build.go | 102 +- libgo/go/cmd/go/internal/modload/help.go | 17 +- libgo/go/cmd/go/internal/modload/import.go | 59 +- .../go/cmd/go/internal/modload/import_test.go | 2 +- libgo/go/cmd/go/internal/modload/init.go | 271 +- libgo/go/cmd/go/internal/modload/init_test.go | 42 + libgo/go/cmd/go/internal/modload/list.go | 18 +- libgo/go/cmd/go/internal/modload/load.go | 54 +- libgo/go/cmd/go/internal/modload/query.go | 20 +- .../go/cmd/go/internal/modload/query_test.go | 2 +- libgo/go/cmd/go/internal/modload/search.go | 5 +- .../go/internal/modload/testgo.go} | 8 +- libgo/go/cmd/go/internal/module/module.go | 4 +- .../go/cmd/go/internal/module/module_test.go | 1 + libgo/go/cmd/go/internal/mvs/mvs.go | 1 + libgo/go/cmd/go/internal/renameio/renameio.go | 63 + libgo/go/cmd/go/internal/run/run.go | 3 + libgo/go/cmd/go/internal/search/search.go | 4 +- libgo/go/cmd/go/internal/semver/semver.go | 2 +- .../go/cmd/go/internal/semver/semver_test.go | 1 + libgo/go/cmd/go/internal/test/test.go | 61 +- libgo/go/cmd/go/internal/test/testflag.go | 4 +- libgo/go/cmd/go/internal/vet/vet.go | 13 +- libgo/go/cmd/go/internal/vet/vetflag.go | 163 +- libgo/go/cmd/go/internal/web2/web.go | 8 +- libgo/go/cmd/go/internal/work/action.go | 2 +- libgo/go/cmd/go/internal/work/build.go | 6 +- libgo/go/cmd/go/internal/work/build_test.go | 14 +- libgo/go/cmd/go/internal/work/buildid.go | 59 +- libgo/go/cmd/go/internal/work/exec.go | 172 +- libgo/go/cmd/go/internal/work/gc.go | 102 +- libgo/go/cmd/go/internal/work/gccgo.go | 43 +- libgo/go/cmd/go/internal/work/init.go | 11 +- libgo/go/cmd/go/internal/work/security.go | 3 + libgo/go/cmd/go/main.go | 32 +- libgo/go/cmd/go/proxy_test.go | 12 +- libgo/go/cmd/go/script_test.go | 288 +- libgo/go/cmd/go/testdata/addmod.go | 2 +- .../research.swtch.com_vgo-tour_v1.0.0.txt | 23 - libgo/go/cmd/go/testdata/script/README | 36 +- .../cmd/go/testdata/script/build_GOTMPDIR.txt | 5 +- libgo/go/cmd/go/testdata/script/help.txt | 18 + .../go/testdata/script/list_bad_import.txt | 2 +- libgo/go/cmd/go/testdata/script/list_std.txt | 2 +- .../cmd/go/testdata/script/mod_download.txt | 21 + libgo/go/cmd/go/testdata/script/mod_edit.txt | 55 +- .../go/cmd/go/testdata/script/mod_enabled.txt | 6 +- .../go/testdata/script/mod_fs_patterns.txt | 4 +- .../cmd/go/testdata/script/mod_go_version.txt | 16 +- .../cmd/go/testdata/script/mod_internal.txt | 13 - .../testdata/script/mod_list_bad_import.txt | 2 +- .../cmd/go/testdata/script/mod_list_dir.txt | 4 +- libgo/go/cmd/go/testdata/script/mod_nomod.txt | 2 +- .../cmd/go/testdata/script/mod_patterns.txt | 10 + .../cmd/go/testdata/script/mod_readonly.txt | 2 + .../go/cmd/go/testdata/script/mod_replace.txt | 29 +- libgo/go/cmd/go/testdata/script/mod_test.txt | 7 + libgo/go/cmd/go/testdata/script/mod_tidy.txt | 9 + .../go/cmd/go/testdata/script/mod_vendor.txt | 48 + .../testterminal18153/terminal_test.go | 2 +- libgo/go/cmd/go/vendor_test.go | 2 +- libgo/go/cmd/gofmt/gofmt.go | 5 +- libgo/go/cmd/gofmt/gofmt_test.go | 2 +- libgo/go/cmd/gofmt/long_test.go | 6 + libgo/go/cmd/internal/buildid/buildid.go | 2 +- libgo/go/cmd/internal/objabi/doc.go | 8 +- libgo/go/cmd/internal/objabi/flag.go | 13 +- libgo/go/cmd/internal/objabi/funcdata.go | 1 + libgo/go/cmd/internal/objabi/funcid.go | 68 +- libgo/go/cmd/internal/objabi/head.go | 5 + libgo/go/cmd/internal/objabi/reloctype.go | 2 +- libgo/go/cmd/internal/objabi/stack.go | 17 +- libgo/go/cmd/internal/objabi/symkind.go | 7 + .../go/cmd/internal/objabi/symkind_string.go | 4 +- libgo/go/cmd/internal/objabi/util.go | 6 +- libgo/go/cmd/internal/sys/arch.go | 187 + libgo/go/cmd/internal/sys/supported.go | 29 + libgo/go/cmd/vet/all/main.go | 94 +- libgo/go/cmd/vet/assign.go | 52 - libgo/go/cmd/vet/atomic.go | 71 - libgo/go/cmd/vet/buildtag.go | 126 - libgo/go/cmd/vet/cgo.go | 141 - libgo/go/cmd/vet/composite.go | 86 - libgo/go/cmd/vet/doc.go | 244 +- libgo/go/cmd/vet/httpresponse.go | 137 - libgo/go/cmd/vet/internal/cfg/cfg_test.go | 190 - libgo/go/cmd/vet/lostcancel.go | 322 - libgo/go/cmd/vet/main.go | 789 +- libgo/go/cmd/vet/nilfunc.go | 67 - libgo/go/cmd/vet/rangeloop.go | 105 - libgo/go/cmd/vet/shadow.go | 246 - libgo/go/cmd/vet/shift.go | 98 - libgo/go/cmd/vet/structtag.go | 226 - libgo/go/cmd/vet/testdata/asm/asm.go | 48 - libgo/go/cmd/vet/testdata/asm/asm1.s | 315 - libgo/go/cmd/vet/testdata/asm/asm2.s | 257 - libgo/go/cmd/vet/testdata/asm/asm3.s | 192 - libgo/go/cmd/vet/testdata/asm/asm4.s | 26 - libgo/go/cmd/vet/testdata/asm/asm5.s | 193 - libgo/go/cmd/vet/testdata/asm/asm6.s | 193 - libgo/go/cmd/vet/testdata/asm/asm7.s | 193 - libgo/go/cmd/vet/testdata/asm8.s | 165 - libgo/go/cmd/vet/testdata/atomic.go | 62 - libgo/go/cmd/vet/testdata/bool.go | 131 - .../cmd/vet/testdata/buildtag/buildtag_bad.go | 15 - libgo/go/cmd/vet/testdata/cgo/cgo.go | 59 - libgo/go/cmd/vet/testdata/cgo/cgo2.go | 12 - libgo/go/cmd/vet/testdata/cgo/cgo4.go | 15 - libgo/go/cmd/vet/testdata/composite.go | 120 - libgo/go/cmd/vet/testdata/copylock.go | 188 - libgo/go/cmd/vet/testdata/copylock_func.go | 136 - libgo/go/cmd/vet/testdata/copylock_range.go | 67 - libgo/go/cmd/vet/testdata/deadcode.go | 2134 ---- libgo/go/cmd/vet/testdata/divergent/buf.go | 17 - .../go/cmd/vet/testdata/divergent/buf_test.go | 35 - libgo/go/cmd/vet/testdata/httpresponse.go | 85 - .../vet/testdata/incomplete/examples_test.go | 33 - libgo/go/cmd/vet/testdata/lostcancel.go | 155 - libgo/go/cmd/vet/testdata/nilfunc.go | 35 - libgo/go/cmd/vet/testdata/rangeloop.go | 90 - libgo/go/cmd/vet/testdata/shadow.go | 59 - libgo/go/cmd/vet/testdata/shift.go | 162 - libgo/go/cmd/vet/testdata/src/asm/asm.go | 9 + libgo/go/cmd/vet/testdata/src/asm/asm1.s | 8 + .../vet/testdata/{ => src/assign}/assign.go | 2 +- .../go/cmd/vet/testdata/src/atomic/atomic.go | 14 + libgo/go/cmd/vet/testdata/src/bool/bool.go | 14 + .../testdata/{ => src}/buildtag/buildtag.go | 0 libgo/go/cmd/vet/testdata/src/cgo/cgo.go | 18 + .../vet/testdata/src/composite/composite.go | 24 + .../cmd/vet/testdata/src/copylock/copylock.go | 11 + .../cmd/vet/testdata/src/deadcode/deadcode.go | 14 + .../testdata/src/httpresponse/httpresponse.go | 22 + .../vet/testdata/src/lostcancel/lostcancel.go | 14 + .../vet/testdata/{ => src/method}/method.go | 14 +- .../cmd/vet/testdata/src/nilfunc/nilfunc.go | 13 + .../cmd/vet/testdata/{ => src/print}/print.go | 128 +- .../vet/testdata/src/rangeloop/rangeloop.go | 17 + libgo/go/cmd/vet/testdata/src/shift/shift.go | 13 + .../vet/testdata/src/structtag/structtag.go | 11 + .../vet/testdata/{ => src}/tagtest/file1.go | 3 + .../vet/testdata/{ => src}/tagtest/file2.go | 5 +- .../testdata/{ => src}/testingpkg/tests.go | 0 .../vet/testdata/src/testingpkg/tests_test.go | 3 + .../vet/testdata/src/unmarshal/unmarshal.go | 18 + .../vet/testdata/src/unsafeptr/unsafeptr.go | 14 + .../go/cmd/vet/testdata/src/unused/unused.go | 13 + libgo/go/cmd/vet/testdata/structtag.go | 102 - .../cmd/vet/testdata/testingpkg/tests_test.go | 74 - libgo/go/cmd/vet/testdata/unsafeptr.go | 63 - libgo/go/cmd/vet/testdata/unused.go | 29 - libgo/go/cmd/vet/tests.go | 187 - libgo/go/cmd/vet/types.go | 313 - libgo/go/cmd/vet/unsafeptr.go | 97 - libgo/go/cmd/vet/unused.go | 93 - libgo/go/cmd/vet/vet_test.go | 215 +- libgo/go/compress/bzip2/bzip2_test.go | 4 +- .../testdata/Isaac.Newton-Opticks.txt.bz2 | 0 libgo/go/compress/flate/deflate_test.go | 8 +- libgo/go/compress/flate/inflate.go | 4 +- libgo/go/compress/flate/reader_test.go | 4 +- .../flate/testdata/Isaac.Newton-Opticks.txt | 9286 +++++++++++++++++ .../testdata/Mark.Twain-Tom.Sawyer.txt | 8465 --------------- libgo/go/compress/zlib/reader.go | 2 +- libgo/go/compress/zlib/writer.go | 12 +- libgo/go/container/heap/heap.go | 21 +- libgo/go/container/list/list.go | 25 +- libgo/go/context/context.go | 5 +- libgo/go/crypto/aes/aes_test.go | 10 +- libgo/go/crypto/aes/block.go | 48 +- libgo/go/crypto/aes/ctr_s390x.go | 14 +- libgo/go/crypto/aes/gcm_s390x.go | 31 +- libgo/go/crypto/cipher/benchmark_test.go | 67 +- libgo/go/crypto/cipher/example_test.go | 43 +- libgo/go/crypto/cipher/export_test.go | 8 + libgo/go/crypto/cipher/gcm.go | 54 +- libgo/go/crypto/cipher/xor_amd64.go | 29 + .../crypto/cipher/{xor.go => xor_generic.go} | 62 +- libgo/go/crypto/cipher/xor_ppc64x.go | 30 + libgo/go/crypto/cipher/xor_test.go | 68 +- libgo/go/crypto/ecdsa/ecdsa.go | 2 +- libgo/go/crypto/elliptic/p256_s390x.go | 34 +- libgo/go/crypto/hmac/hmac.go | 4 +- libgo/go/crypto/md5/gen.go | 195 +- libgo/go/crypto/md5/md5.go | 100 +- libgo/go/crypto/md5/md5_test.go | 58 + libgo/go/crypto/md5/md5block.go | 347 +- libgo/go/crypto/md5/md5block_decl.go | 4 +- libgo/go/crypto/md5/md5block_generic.go | 4 +- libgo/go/crypto/rand/rand.go | 6 +- libgo/go/crypto/rand/rand_batched.go | 42 + ...and_linux_test.go => rand_batched_test.go} | 2 + libgo/go/crypto/rand/rand_freebsd.go | 9 + libgo/go/crypto/rand/rand_linux.go | 34 - libgo/go/crypto/rand/rand_unix.go | 18 +- libgo/go/crypto/rand/rand_windows.go | 9 + libgo/go/crypto/rc4/rc4.go | 9 +- libgo/go/crypto/rc4/rc4_asm.go | 28 - libgo/go/crypto/rc4/rc4_ref.go | 13 - libgo/go/crypto/rc4/rc4_test.go | 19 +- libgo/go/crypto/rsa/pss_test.go | 2 +- libgo/go/crypto/sha1/sha1.go | 2 +- libgo/go/crypto/sha1/sha1_test.go | 58 + libgo/go/crypto/sha1/sha1block_arm64.go | 4 +- libgo/go/crypto/sha256/sha256.go | 2 +- libgo/go/crypto/sha256/sha256_test.go | 63 + libgo/go/crypto/sha256/sha256block_arm64.go | 4 +- libgo/go/crypto/sha512/sha512.go | 2 +- libgo/go/crypto/sha512/sha512_test.go | 57 + libgo/go/crypto/tls/alert.go | 4 + libgo/go/crypto/tls/auth.go | 123 +- libgo/go/crypto/tls/cipher_suites.go | 164 +- libgo/go/crypto/tls/common.go | 375 +- libgo/go/crypto/tls/conn.go | 955 +- libgo/go/crypto/tls/conn_test.go | 26 +- libgo/go/crypto/tls/handshake_client.go | 572 +- libgo/go/crypto/tls/handshake_client_test.go | 689 +- libgo/go/crypto/tls/handshake_client_tls13.go | 673 ++ libgo/go/crypto/tls/handshake_messages.go | 2167 ++-- .../go/crypto/tls/handshake_messages_test.go | 225 +- libgo/go/crypto/tls/handshake_server.go | 276 +- libgo/go/crypto/tls/handshake_server_test.go | 488 +- libgo/go/crypto/tls/handshake_server_tls13.go | 854 ++ libgo/go/crypto/tls/handshake_test.go | 49 +- libgo/go/crypto/tls/key_agreement.go | 179 +- libgo/go/crypto/tls/key_schedule.go | 200 + libgo/go/crypto/tls/key_schedule_test.go | 175 + libgo/go/crypto/tls/prf.go | 20 +- libgo/go/crypto/tls/prf_test.go | 17 +- .../Client-TLSv10-ClientCert-ECDSA-ECDSA | 108 +- .../Client-TLSv10-ClientCert-ECDSA-RSA | 104 +- .../Client-TLSv10-ClientCert-RSA-ECDSA | 106 +- .../testdata/Client-TLSv10-ClientCert-RSA-RSA | 104 +- .../testdata/Client-TLSv10-ECDHE-ECDSA-AES | 90 +- .../tls/testdata/Client-TLSv10-ECDHE-RSA-AES | 86 +- .../Client-TLSv10-ExportKeyingMaterial | 86 +- .../crypto/tls/testdata/Client-TLSv10-RSA-RC4 | 54 +- .../testdata/Client-TLSv11-ECDHE-ECDSA-AES | 90 +- .../tls/testdata/Client-TLSv11-ECDHE-RSA-AES | 86 +- .../crypto/tls/testdata/Client-TLSv11-RSA-RC4 | 54 +- .../testdata/Client-TLSv12-AES128-GCM-SHA256 | 58 +- .../tls/testdata/Client-TLSv12-AES128-SHA256 | 72 +- .../testdata/Client-TLSv12-AES256-GCM-SHA384 | 58 +- .../go/crypto/tls/testdata/Client-TLSv12-ALPN | 80 +- .../Client-TLSv12-ClientCert-ECDSA-ECDSA | 119 +- .../Client-TLSv12-ClientCert-ECDSA-RSA | 109 +- ...nt-TLSv12-ClientCert-RSA-AES256-GCM-SHA384 | 107 +- .../Client-TLSv12-ClientCert-RSA-ECDSA | 115 +- .../testdata/Client-TLSv12-ClientCert-RSA-RSA | 107 +- .../Client-TLSv12-ClientCert-RSA-RSAPKCS1v15 | 134 + .../Client-TLSv12-ClientCert-RSA-RSAPSS | 135 + .../testdata/Client-TLSv12-ECDHE-ECDSA-AES | 90 +- .../Client-TLSv12-ECDHE-ECDSA-AES-GCM | 82 +- .../Client-TLSv12-ECDHE-ECDSA-AES128-SHA256 | 96 +- ...lient-TLSv12-ECDHE-ECDSA-AES256-GCM-SHA384 | 84 +- ...lient-TLSv12-ECDHE-ECDSA-CHACHA20-POLY1305 | 75 +- .../tls/testdata/Client-TLSv12-ECDHE-RSA-AES | 86 +- .../Client-TLSv12-ECDHE-RSA-AES128-SHA256 | 94 +- .../Client-TLSv12-ECDHE-RSA-CHACHA20-POLY1305 | 71 +- .../Client-TLSv12-ExportKeyingMaterial | 76 +- .../tls/testdata/Client-TLSv12-P256-ECDHE | 98 + .../crypto/tls/testdata/Client-TLSv12-RSA-RC4 | 54 +- .../testdata/Client-TLSv12-RenegotiateOnce | 313 +- .../testdata/Client-TLSv12-RenegotiateTwice | 497 +- .../Client-TLSv12-RenegotiateTwiceRejected | 319 +- .../Client-TLSv12-RenegotiationRejected | 82 +- .../go/crypto/tls/testdata/Client-TLSv12-SCT | 124 +- ...RSA-AES-GCM => Client-TLSv12-X25519-ECDHE} | 80 +- .../tls/testdata/Client-TLSv13-AES128-SHA256 | 90 + .../tls/testdata/Client-TLSv13-AES256-SHA384 | 92 + .../go/crypto/tls/testdata/Client-TLSv13-ALPN | 93 + .../testdata/Client-TLSv13-CHACHA20-SHA256 | 90 + .../Client-TLSv13-ClientCert-ECDSA-RSA | 139 + .../Client-TLSv13-ClientCert-RSA-ECDSA | 134 + .../Client-TLSv13-ClientCert-RSA-RSAPSS | 136 + .../crypto/tls/testdata/Client-TLSv13-ECDSA | 86 + .../Client-TLSv13-ExportKeyingMaterial | 90 + .../testdata/Client-TLSv13-HelloRetryRequest | 118 + .../tls/testdata/Client-TLSv13-KeyUpdate | 102 + .../tls/testdata/Client-TLSv13-P256-ECDHE | 94 + .../tls/testdata/Client-TLSv13-X25519-ECDHE | 90 + .../crypto/tls/testdata/Server-SSLv3-RSA-3DES | 60 +- .../crypto/tls/testdata/Server-SSLv3-RSA-AES | 62 +- .../crypto/tls/testdata/Server-SSLv3-RSA-RC4 | 52 +- .../testdata/Server-TLSv10-ECDHE-ECDSA-AES | 77 +- .../Server-TLSv10-ExportKeyingMaterial | 83 +- .../tls/testdata/Server-TLSv10-RSA-3DES | 57 +- .../crypto/tls/testdata/Server-TLSv10-RSA-AES | 63 +- .../crypto/tls/testdata/Server-TLSv10-RSA-RC4 | 51 +- .../tls/testdata/Server-TLSv11-FallbackSCSV | 13 +- .../crypto/tls/testdata/Server-TLSv11-RSA-RC4 | 51 +- .../go/crypto/tls/testdata/Server-TLSv12-ALPN | 82 +- .../tls/testdata/Server-TLSv12-ALPN-NoMatch | 82 +- ...rver-TLSv12-CipherSuiteCertPreferenceECDSA | 80 +- ...Server-TLSv12-CipherSuiteCertPreferenceRSA | 74 +- ...er-TLSv12-ClientAuthRequestedAndECDSAGiven | 90 +- .../Server-TLSv12-ClientAuthRequestedAndGiven | 89 +- ...TLSv12-ClientAuthRequestedAndPKCS1v15Given | 124 + .../Server-TLSv12-ClientAuthRequestedNotGiven | 74 +- .../testdata/Server-TLSv12-ECDHE-ECDSA-AES | 76 +- .../Server-TLSv12-ExportKeyingMaterial | 79 +- .../tls/testdata/Server-TLSv12-IssueTicket | 81 +- .../Server-TLSv12-IssueTicketPreDisable | 81 +- .../go/crypto/tls/testdata/Server-TLSv12-P256 | 85 + .../tls/testdata/Server-TLSv12-RSA-3DES | 63 +- .../crypto/tls/testdata/Server-TLSv12-RSA-AES | 67 +- .../tls/testdata/Server-TLSv12-RSA-AES-GCM | 64 +- .../Server-TLSv12-RSA-AES256-GCM-SHA384 | 64 +- .../crypto/tls/testdata/Server-TLSv12-RSA-RC4 | 57 +- .../testdata/Server-TLSv12-RSA-RSAPKCS1v15 | 81 + .../tls/testdata/Server-TLSv12-RSA-RSAPSS | 81 + .../crypto/tls/testdata/Server-TLSv12-Resume | 71 +- .../tls/testdata/Server-TLSv12-ResumeDisabled | 86 +- .../go/crypto/tls/testdata/Server-TLSv12-SNI | 68 +- .../testdata/Server-TLSv12-SNI-GetCertificate | 68 +- .../Server-TLSv12-SNI-GetCertificateNotFound | 68 +- ...ECDHE-RSA-AES-GCM => Server-TLSv12-X25519} | 64 +- .../tls/testdata/Server-TLSv13-AES128-SHA256 | 100 + .../tls/testdata/Server-TLSv13-AES256-SHA384 | 103 + .../go/crypto/tls/testdata/Server-TLSv13-ALPN | 104 + .../tls/testdata/Server-TLSv13-ALPN-NoMatch | 104 + .../testdata/Server-TLSv13-CHACHA20-SHA256 | 100 + ...er-TLSv13-ClientAuthRequestedAndECDSAGiven | 184 + .../Server-TLSv13-ClientAuthRequestedAndGiven | 180 + .../Server-TLSv13-ClientAuthRequestedNotGiven | 109 + .../testdata/Server-TLSv13-ECDHE-ECDSA-AES | 96 + .../Server-TLSv13-ExportKeyingMaterial | 103 + .../testdata/Server-TLSv13-HelloRetryRequest | 129 + .../tls/testdata/Server-TLSv13-IssueTicket | 103 + .../Server-TLSv13-IssueTicketPreDisable | 103 + .../go/crypto/tls/testdata/Server-TLSv13-P256 | 106 + .../tls/testdata/Server-TLSv13-RSA-RSAPSS | 101 + .../crypto/tls/testdata/Server-TLSv13-Resume | 66 + .../Server-TLSv13-Resume-HelloRetryRequest | 106 + .../tls/testdata/Server-TLSv13-ResumeDisabled | 104 + .../crypto/tls/testdata/Server-TLSv13-X25519 | 102 + libgo/go/crypto/tls/ticket.go | 88 +- libgo/go/crypto/tls/tls.go | 3 +- libgo/go/crypto/tls/tls_test.go | 217 +- libgo/go/crypto/x509/cert_pool.go | 32 +- libgo/go/crypto/x509/pem_decrypt.go | 2 +- libgo/go/crypto/x509/pkix/pkix.go | 4 +- libgo/go/crypto/x509/root_aix.go | 2 +- libgo/go/crypto/x509/root_cgo_darwin.go | 258 +- libgo/go/crypto/x509/root_darwin.go | 134 +- libgo/go/crypto/x509/root_darwin_arm_gen.go | 6 +- libgo/go/crypto/x509/verify.go | 110 +- libgo/go/crypto/x509/verify_test.go | 119 + libgo/go/crypto/x509/x509.go | 36 +- libgo/go/database/sql/convert.go | 45 +- libgo/go/database/sql/driver/driver.go | 7 +- libgo/go/database/sql/example_cli_test.go | 88 + libgo/go/database/sql/example_service_test.go | 160 + libgo/go/database/sql/fakedb_test.go | 20 +- libgo/go/database/sql/sql.go | 56 +- libgo/go/database/sql/sql_test.go | 102 +- libgo/go/debug/dwarf/line.go | 2 +- libgo/go/debug/elf/elf.go | 2 + libgo/go/debug/elf/file_test.go | 2 +- libgo/go/debug/gosym/pclntab_test.go | 38 +- libgo/go/debug/gosym/symtab.go | 5 - libgo/go/debug/gosym/testdata/main.go | 10 + libgo/go/debug/gosym/testdata/pclinetest.h | 9 + libgo/go/debug/gosym/testdata/pclinetest.s | 48 + libgo/go/debug/pe/file.go | 2 +- libgo/go/debug/pe/file_test.go | 87 +- libgo/go/debug/pe/pe.go | 1 + libgo/go/debug/plan9obj/file.go | 2 +- libgo/go/encoding/asn1/asn1.go | 2 +- libgo/go/encoding/base32/base32_test.go | 10 +- libgo/go/encoding/base64/base64.go | 68 +- libgo/go/encoding/base64/base64_test.go | 8 +- libgo/go/encoding/binary/binary.go | 40 +- libgo/go/encoding/gob/decoder.go | 11 +- libgo/go/encoding/gob/encoder.go | 3 +- libgo/go/encoding/gob/encoder_test.go | 22 - libgo/go/encoding/hex/hex.go | 13 +- libgo/go/encoding/hex/hex_test.go | 13 + libgo/go/encoding/json/bench_test.go | 28 + libgo/go/encoding/json/decode.go | 194 +- libgo/go/encoding/json/decode_test.go | 57 +- libgo/go/encoding/json/encode.go | 164 +- libgo/go/encoding/json/encode_test.go | 28 + .../json/example_text_marshaling_test.go | 69 + libgo/go/encoding/json/scanner.go | 2 +- libgo/go/encoding/json/stream.go | 24 +- libgo/go/encoding/json/stream_test.go | 34 +- libgo/go/encoding/pem/pem_test.go | 8 +- .../encoding/xml/example_marshaling_test.go | 86 + .../xml/example_text_marshaling_test.go | 81 + libgo/go/encoding/xml/marshal.go | 4 + libgo/go/encoding/xml/read.go | 5 + libgo/go/expvar/expvar.go | 15 +- libgo/go/expvar/expvar_test.go | 37 + libgo/go/flag/flag.go | 45 +- libgo/go/flag/flag_test.go | 53 + libgo/go/fmt/example_test.go | 362 +- libgo/go/fmt/fmt_test.go | 69 +- libgo/go/fmt/format.go | 33 +- libgo/go/fmt/gostringer_example_test.go | 61 + libgo/go/fmt/print.go | 31 +- libgo/go/fmt/stringer_example_test.go | 31 + libgo/go/go/build/build.go | 7 +- libgo/go/go/build/build_test.go | 30 +- libgo/go/go/build/deps_test.go | 61 +- libgo/go/go/build/doc.go | 3 + libgo/go/go/build/read_test.go | 7 +- libgo/go/go/build/syslist.go | 4 +- .../go/build/testdata/withvendor/src/a/b/b.go | 3 + .../build/testdata/withvendor/src/a/c/d/d.go | 1 + libgo/go/go/constant/value.go | 2 +- libgo/go/go/constant/value_test.go | 2 +- libgo/go/go/doc/comment.go | 102 +- libgo/go/go/doc/comment_test.go | 46 +- libgo/go/go/doc/doc.go | 13 +- libgo/go/go/doc/doc_test.go | 15 +- libgo/go/go/doc/example.go | 23 + libgo/go/go/doc/example_test.go | 97 + libgo/go/go/doc/lazyre.go | 51 + libgo/go/go/doc/reader.go | 83 +- libgo/go/go/doc/synopsis.go | 1 + libgo/go/go/doc/synopsis_test.go | 1 + libgo/go/go/doc/testdata/issue12839.0.golden | 18 + libgo/go/go/doc/testdata/issue12839.1.golden | 18 + libgo/go/go/doc/testdata/issue12839.2.golden | 18 + libgo/go/go/doc/testdata/issue12839.go | 31 + libgo/go/go/format/benchmark_test.go | 91 + libgo/go/go/importer/importer.go | 18 +- libgo/go/go/importer/importer_test.go | 26 +- libgo/go/go/internal/gccgoimporter/ar.go | 27 +- .../gccgoimporter/gccgoinstallation.go | 9 +- .../gccgoimporter/gccgoinstallation_test.go | 26 +- .../go/go/internal/gccgoimporter/importer.go | 5 +- .../internal/gccgoimporter/importer_test.go | 98 +- libgo/go/go/internal/gccgoimporter/parser.go | 334 +- .../go/internal/gccgoimporter/parser_test.go | 3 +- .../internal/gccgoimporter/testdata/alias.gox | 4 - .../gccgoimporter/testdata/aliases.go | 65 + .../gccgoimporter/testdata/aliases.gox | 33 + .../gccgoimporter/testdata/issue27856.go | 9 + .../gccgoimporter/testdata/issue27856.gox | 9 + .../gccgoimporter/testdata/issue29198.go | 37 + .../gccgoimporter/testdata/issue29198.gox | 86 + .../gccgoimporter/testdata/libimportsar.a | Bin 0 -> 9302 bytes .../gccgoimporter/testdata/nointerface.go | 12 + .../gccgoimporter/testdata/nointerface.gox | 8 + .../gccgoimporter/testdata/v1reflect.gox | Bin 0 -> 10872 bytes libgo/go/go/internal/gcimporter/gcimporter.go | 6 +- .../go/internal/gcimporter/gcimporter_test.go | 132 +- .../internal/srcimporter/srcimporter_test.go | 2 +- libgo/go/go/parser/parser.go | 2 +- libgo/go/go/printer/nodes.go | 6 +- libgo/go/go/printer/printer_test.go | 32 + libgo/go/go/printer/testdata/parser.go | 2 +- libgo/go/go/scanner/scanner.go | 18 +- libgo/go/go/scanner/scanner_test.go | 20 +- libgo/go/go/token/position.go | 17 +- libgo/go/go/token/position_test.go | 15 + libgo/go/go/types/api.go | 10 +- libgo/go/go/types/api_test.go | 13 + libgo/go/go/types/assignments.go | 2 +- libgo/go/go/types/builtins.go | 6 +- libgo/go/go/types/call.go | 23 +- libgo/go/go/types/check.go | 22 +- libgo/go/go/types/check_test.go | 3 + libgo/go/go/types/conversions.go | 11 +- libgo/go/go/types/decl.go | 142 +- libgo/go/go/types/errors.go | 3 +- libgo/go/go/types/example_test.go | 21 +- libgo/go/go/types/expr.go | 52 +- libgo/go/go/types/gotype.go | 2 +- libgo/go/go/types/interfaces.go | 10 +- libgo/go/go/types/issues_test.go | 192 +- libgo/go/go/types/lookup.go | 27 +- libgo/go/go/types/methodset.go | 18 +- libgo/go/go/types/object.go | 3 +- libgo/go/go/types/operand.go | 8 +- libgo/go/go/types/resolver.go | 118 +- libgo/go/go/types/scope.go | 15 +- libgo/go/go/types/sizes.go | 3 +- libgo/go/go/types/stdlib_test.go | 34 +- libgo/go/go/types/testdata/cycles.src | 6 +- libgo/go/go/types/testdata/cycles2.src | 14 +- libgo/go/go/types/testdata/decls0.src | 20 +- libgo/go/go/types/testdata/expr2.src | 13 + libgo/go/go/types/testdata/expr3.src | 2 +- libgo/go/go/types/testdata/issues.src | 44 + libgo/go/go/types/testdata/shifts.src | 12 + libgo/go/go/types/type.go | 15 +- libgo/go/go/types/typestring_test.go | 2 +- libgo/go/go/types/typexpr.go | 172 +- libgo/go/golang.org/x/tools/LICENSE | 27 + libgo/go/golang.org/x/tools/PATENTS | 22 + .../x/tools/go/analysis/analysis.go | 192 + .../go/golang.org/x/tools/go/analysis/doc.go | 336 + .../analysis/internal/analysisflags/flags.go | 343 + .../analysis/internal/analysisflags/help.go | 89 + .../analysis/internal/analysisflags/patch.go | 7 + .../tools/go/analysis/internal/facts/facts.go | 299 + .../go/analysis/internal/facts/imports.go | 88 + .../go/analysis/passes/asmdecl}/asmdecl.go | 98 +- .../tools/go/analysis/passes/assign/assign.go | 68 + .../tools/go/analysis/passes/atomic/atomic.go | 96 + .../tools/go/analysis/passes/bools/bools.go} | 91 +- .../go/analysis/passes/buildtag/buildtag.go | 159 + .../go/analysis/passes/cgocall/cgocall.go | 391 + .../go/analysis/passes/composite/composite.go | 108 + .../analysis/passes/composite}/whitelist.go | 13 +- .../go/analysis/passes/copylock}/copylock.go | 152 +- .../go/analysis/passes/ctrlflow/ctrlflow.go | 225 + .../passes/httpresponse/httpresponse.go | 177 + .../go/analysis/passes/inspect/inspect.go | 45 + .../passes/internal/analysisutil/util.go | 106 + .../passes/loopclosure/loopclosure.go | 130 + .../analysis/passes/lostcancel/lostcancel.go | 315 + .../go/analysis/passes/nilfunc/nilfunc.go | 74 + .../go/analysis/passes/pkgfact/pkgfact.go | 127 + .../go/analysis/passes/printf/printf.go} | 699 +- .../tools/go/analysis/passes/printf/types.go | 239 + .../x/tools/go/analysis/passes/shift}/dead.go | 63 +- .../x/tools/go/analysis/passes/shift/shift.go | 128 + .../analysis/passes/stdmethods/stdmethods.go} | 141 +- .../go/analysis/passes/structtag/structtag.go | 273 + .../x/tools/go/analysis/passes/tests/tests.go | 175 + .../go/analysis/passes/unmarshal/unmarshal.go | 92 + .../passes/unreachable/unreachable.go} | 94 +- .../go/analysis/passes/unsafeptr/unsafeptr.go | 130 + .../passes/unusedresult/unusedresult.go | 131 + .../x/tools/go/analysis/unitchecker/main.go | 64 + .../go/analysis/unitchecker/unitchecker.go | 387 + .../go/analysis/unitchecker/unitchecker112.go | 9 + .../x/tools/go/analysis/validate.go | 104 + .../x/tools/go/ast/astutil/enclosing.go | 627 ++ .../x/tools/go/ast/astutil/imports.go | 481 + .../x/tools/go/ast/astutil/rewrite.go | 477 + .../golang.org/x/tools/go/ast/astutil/util.go | 14 + .../x/tools/go/ast/inspector/inspector.go | 182 + .../x/tools/go/ast/inspector/typeof.go | 216 + .../x/tools/go}/cfg/builder.go | 94 +- .../x/tools/go}/cfg/cfg.go | 34 +- .../x/tools/go/types/objectpath/objectpath.go | 523 + .../x/tools/go/types/typeutil/callee.go | 46 + .../x/tools/go/types/typeutil/imports.go | 31 + .../x/tools/go/types/typeutil/map.go | 313 + .../tools/go/types/typeutil/methodsetcache.go | 72 + .../x/tools/go/types/typeutil/ui.go | 52 + .../internal/chacha20/chacha_generic.go | 199 - .../internal/chacha20/chacha_test.go | 33 - libgo/go/golang_org/x/net/idna/idna_test.go | 43 - .../golang_org/x/net/lex/httplex/httplex.go | 351 - .../x/net/lex/httplex/httplex_test.go | 119 - libgo/go/golang_org/x/net/lif/syscall.go | 22 - libgo/go/golang_org/x/net/proxy/direct.go | 18 - libgo/go/golang_org/x/net/proxy/per_host.go | 140 - .../golang_org/x/net/proxy/per_host_test.go | 55 - libgo/go/golang_org/x/net/proxy/proxy.go | 94 - libgo/go/golang_org/x/net/proxy/proxy_test.go | 142 - libgo/go/golang_org/x/net/proxy/socks5.go | 213 - .../go/golang_org/x/text/width/kind_string.go | 16 - libgo/go/golang_org/x/text/width/tables.go | 1284 --- libgo/go/golang_org/x/text/width/transform.go | 239 - libgo/go/golang_org/x/text/width/trieval.go | 30 - libgo/go/golang_org/x/text/width/width.go | 206 - libgo/go/hash/crc32/crc32_arm64.go | 14 +- libgo/go/hash/crc64/crc64.go | 17 +- libgo/go/hash/crc64/crc64_test.go | 6 +- libgo/go/hash/fnv/fnv.go | 33 +- libgo/go/html/template/context.go | 10 +- libgo/go/html/template/example_test.go | 22 + libgo/go/html/template/js.go | 5 +- libgo/go/html/template/js_test.go | 1 + libgo/go/html/template/url.go | 4 +- libgo/go/image/draw/draw.go | 126 +- libgo/go/image/format.go | 13 +- libgo/go/image/image.go | 149 +- libgo/go/image/image_test.go | 214 +- libgo/go/image/jpeg/fdct.go | 32 +- libgo/go/image/png/reader_test.go | 4 - libgo/go/image/png/writer.go | 90 +- libgo/go/image/png/writer_test.go | 112 +- libgo/go/internal/bytealg/bytealg.c | 6 +- libgo/go/internal/bytealg/bytealg.go | 11 +- libgo/go/internal/bytealg/compare_generic.go | 28 - libgo/go/internal/bytealg/compare_native.go | 9 + libgo/go/internal/bytealg/count_generic.go | 2 +- libgo/go/internal/bytealg/count_native.go | 2 +- libgo/go/internal/bytealg/equal_native.go | 12 + .../go/internal/bytealg/indexbyte_generic.go | 22 - libgo/go/internal/cpu/cpu.go | 150 +- libgo/go/internal/cpu/cpu_arm64.go | 96 +- libgo/go/internal/cpu/cpu_arm64_test.go | 26 - libgo/go/internal/cpu/cpu_no_init.go | 1 + libgo/go/internal/cpu/cpu_ppc64x.go | 46 +- libgo/go/internal/cpu/cpu_ppc64x_test.go | 33 - libgo/go/internal/cpu/cpu_s390x.go | 55 +- libgo/go/internal/cpu/cpu_test.go | 45 +- libgo/go/internal/cpu/cpu_x86.go | 39 +- libgo/go/internal/cpu/cpu_x86_test.go | 35 +- libgo/go/internal/fmtsort/export_test.go | 11 + libgo/go/internal/fmtsort/sort.go | 216 + libgo/go/internal/fmtsort/sort_test.go | 212 + libgo/go/internal/goroot/gc.go | 5 +- libgo/go/internal/goroot/gccgo.go | 2 +- libgo/go/internal/poll/fd_fsync_darwin.go | 38 + libgo/go/internal/poll/fd_fsync_posix.go | 33 + libgo/go/internal/poll/fd_fsync_windows.go | 16 + libgo/go/internal/poll/fd_opendir_ios.go | 35 + libgo/go/internal/poll/fd_plan9.go | 8 +- libgo/go/internal/poll/fd_poll_nacljs.go | 8 +- libgo/go/internal/poll/fd_poll_runtime.go | 27 +- libgo/go/internal/poll/fd_posix.go | 9 - libgo/go/internal/poll/fd_unix.go | 17 +- libgo/go/internal/poll/fd_windows.go | 158 +- libgo/go/internal/poll/fd_writev_darwin.go | 16 + libgo/go/internal/poll/fd_writev_unix.go | 20 + libgo/go/internal/poll/sendfile_bsd.go | 3 +- libgo/go/internal/poll/sendfile_linux.go | 3 +- libgo/go/internal/poll/sendfile_solaris.go | 3 +- libgo/go/internal/poll/sendfile_windows.go | 6 + libgo/go/internal/poll/sockopt_unix.go | 2 +- libgo/go/internal/poll/splice_linux.go | 21 +- libgo/go/internal/poll/writev.go | 19 +- libgo/go/internal/syscall/unix/at.go | 81 + libgo/go/internal/syscall/unix/at_aix.go | 10 + libgo/go/internal/syscall/unix/at_freebsd.go | 10 + libgo/go/internal/syscall/unix/at_solaris.go | 10 + .../internal/syscall/unix/at_sysnum_darwin.go | 8 + .../syscall/unix/at_sysnum_dragonfly.go | 8 + .../internal/syscall/unix/at_sysnum_linux.go | 8 + .../internal/syscall/unix/at_sysnum_netbsd.go | 8 + .../syscall/unix/at_sysnum_openbsd.go | 8 + .../syscall/unix/getrandom_freebsd.go | 48 + .../internal/syscall/unix/getrandom_linux.go | 3 - .../syscall/unix/getrandom_linux_generic.go | 2 +- libgo/go/internal/syscall/unix/ioctl_aix.go | 25 + libgo/go/internal/syscall/unix/nonblocking.go | 17 +- .../syscall/unix/nonblocking_darwin.go | 24 + .../go/internal/syscall/windows/mksyscall.go | 2 +- .../syscall/windows/symlink_windows.go | 25 + .../syscall/windows/syscall_windows.go | 12 + .../syscall/windows/zsyscall_windows.go | 83 +- libgo/go/internal/trace/gc.go | 825 ++ libgo/go/internal/trace/gc_test.go | 198 + libgo/go/internal/trace/goroutines.go | 2 +- libgo/go/internal/trace/mud.go | 223 + libgo/go/internal/trace/mud_test.go | 87 + .../go/internal/trace/testdata/http_1_10_good | Bin 0 -> 2201 bytes .../go/internal/trace/testdata/http_1_11_good | Bin 0 -> 2779 bytes .../go/internal/trace/testdata/http_1_9_good | Bin 0 -> 2187 bytes .../internal/trace/testdata/stress_1_10_good | Bin 0 -> 370999 bytes .../internal/trace/testdata/stress_1_11_good | Bin 0 -> 370129 bytes .../internal/trace/testdata/stress_1_9_good | Bin 0 -> 365129 bytes .../testdata/stress_start_stop_1_10_good | Bin 0 -> 6338 bytes .../testdata/stress_start_stop_1_11_good | Bin 0 -> 4882 bytes .../trace/testdata/stress_start_stop_1_9_good | Bin 0 -> 6271 bytes .../trace/testdata/user_task_span_1_11_good | Bin 0 -> 2000 bytes .../chacha20poly1305/chacha20poly1305.go | 2 +- .../chacha20poly1305_amd64.go | 0 .../chacha20poly1305_generic.go | 4 +- .../chacha20poly1305_noasm.go | 0 .../chacha20poly1305/chacha20poly1305_test.go | 0 .../chacha20poly1305_vectors_test.go | 0 .../x/crypto/cryptobyte/asn1.go | 2 +- .../x/crypto/cryptobyte/asn1/asn1.go | 2 +- .../x/crypto/cryptobyte/asn1_test.go | 2 +- .../x/crypto/cryptobyte/builder.go | 0 .../x/crypto/cryptobyte/cryptobyte_test.go | 0 .../x/crypto/cryptobyte/example_test.go | 4 +- .../x/crypto/cryptobyte/string.go | 2 +- .../x/crypto/curve25519/curve25519.go | 0 .../x/crypto/curve25519/curve25519_test.go | 0 .../x/crypto/curve25519/doc.go | 2 +- .../x/crypto/curve25519/mont25519_amd64.go | 0 .../go/internal/x/crypto/hkdf/example_test.go | 58 + libgo/go/internal/x/crypto/hkdf/hkdf.go | 93 + libgo/go/internal/x/crypto/hkdf/hkdf_test.go | 449 + .../internal/chacha20/chacha_generic.go | 0 .../crypto/internal/chacha20/chacha_noasm.go | 0 .../crypto/internal/chacha20/chacha_s390x.go | 0 .../x/crypto/internal/chacha20/chacha_test.go | 0 .../crypto/internal/chacha20/vectors_test.go | 0 .../x/crypto/internal/chacha20/xor.go | 0 .../x/crypto/poly1305/poly1305.go | 2 +- .../x/crypto/poly1305/poly1305_test.go | 0 .../x/crypto/poly1305/sum_amd64.go | 0 .../x/crypto/poly1305/sum_arm.go | 0 .../x/crypto/poly1305/sum_noasm.go | 0 .../x/crypto/poly1305/sum_ref.go | 0 .../x/crypto/poly1305/sum_s390x.go | 0 .../x/crypto/poly1305/vectors_test.go | 0 .../x/net/dns/dnsmessage/example_test.go | 4 +- .../x/net/dns/dnsmessage/message.go | 0 .../x/net/dns/dnsmessage/message_test.go | 0 .../x/net/http/httpguts/guts.go | 0 .../x/net/http/httpguts/httplex.go | 2 +- .../x/net/http/httpguts/httplex_test.go | 0 .../x/net/http/httpproxy/export_test.go | 0 .../x/net/http/httpproxy/proxy.go | 2 +- .../x/net/http/httpproxy/proxy_test.go | 2 +- .../x/net/http2/hpack/encode.go | 0 .../x/net/http2/hpack/encode_test.go | 0 .../x/net/http2/hpack/hpack.go | 10 +- .../x/net/http2/hpack/hpack_test.go | 14 +- .../x/net/http2/hpack/huffman.go | 0 .../x/net/http2/hpack/tables.go | 0 .../x/net/http2/hpack/tables_test.go | 0 .../x/net/idna/idna.go | 8 +- .../x/net/idna/punycode.go | 0 .../x/net/idna/punycode_test.go | 0 .../x/net/idna/tables.go | 2 +- .../x/net/idna/trie.go | 0 .../x/net/idna/trieval.go | 2 +- .../x/net/internal/nettest/helper_bsd.go | 0 .../x/net/internal/nettest/helper_nobsd.go | 0 .../x/net/internal/nettest/helper_posix.go | 0 .../x/net/internal/nettest/helper_stub.go | 2 +- .../x/net/internal/nettest/helper_unix.go | 0 .../x/net/internal/nettest/helper_windows.go | 0 .../x/net/internal/nettest/interface.go | 0 .../x/net/internal/nettest/rlimit.go | 0 .../x/net/internal/nettest/stack.go | 4 +- .../x/net/lif/address.go | 0 .../x/net/lif/address_test.go | 0 .../x/net/lif/binary.go | 0 .../x/net/lif/defs_solaris.go | 0 .../{golang_org => internal}/x/net/lif/lif.go | 0 .../x/net/lif/link.go | 8 +- .../x/net/lif/link_test.go | 0 .../{golang_org => internal}/x/net/lif/sys.go | 0 libgo/go/internal/x/net/lif/syscall.go | 28 + .../x/net/lif/zsys_solaris_amd64.go} | 13 +- .../x/net/nettest/conntest.go | 0 .../x/net/nettest/conntest_go16.go | 0 .../x/net/nettest/conntest_go17.go | 0 .../x/net/nettest/conntest_test.go | 2 +- .../x/net/route/address.go | 0 .../x/net/route/address_darwin_test.go | 0 .../x/net/route/address_test.go | 0 .../x/net/route/binary.go | 0 .../x/net/route/defs_darwin.go | 0 .../x/net/route/defs_dragonfly.go | 0 .../x/net/route/defs_freebsd.go | 0 .../x/net/route/defs_netbsd.go | 0 .../x/net/route/defs_openbsd.go | 0 .../x/net/route/interface.go | 2 +- .../x/net/route/interface_announce.go | 0 .../x/net/route/interface_classic.go | 0 .../x/net/route/interface_freebsd.go | 0 .../x/net/route/interface_multicast.go | 0 .../x/net/route/interface_openbsd.go | 0 .../x/net/route/message.go | 0 .../x/net/route/message_darwin_test.go | 0 .../x/net/route/message_freebsd_test.go | 8 +- .../x/net/route/message_test.go | 0 .../x/net/route/route.go | 0 .../x/net/route/route_classic.go | 0 .../x/net/route/route_openbsd.go | 0 .../x/net/route/route_test.go | 0 .../x/net/route/sys.go | 0 .../x/net/route/sys_darwin.go | 0 .../x/net/route/sys_dragonfly.go | 0 .../x/net/route/sys_freebsd.go | 22 +- .../x/net/route/sys_netbsd.go | 0 .../x/net/route/sys_openbsd.go | 0 .../x/net/route/syscall.go | 4 +- .../x/net/route/syscall_go1_11_darwin.go | 28 + .../x/net/route/syscall_go1_12_darwin.go | 12 + .../x/net/route/zsys_darwin.go | 0 .../x/net/route/zsys_dragonfly.go | 0 .../x/net/route/zsys_freebsd_386.go | 0 .../x/net/route/zsys_freebsd_amd64.go | 0 .../x/net/route/zsys_freebsd_arm.go | 0 .../x/net/route/zsys_netbsd.go | 0 .../x/net/route/zsys_openbsd.go | 0 .../x/text/secure/bidirule/bidirule.go | 4 +- .../x/text/secure/doc.go | 2 +- .../x/text/transform/examples_test.go | 4 +- .../x/text/transform/transform.go | 2 +- .../x/text/unicode/bidi/bidi.go | 2 +- .../x/text/unicode/bidi/bracket.go | 0 .../x/text/unicode/bidi/core.go | 0 .../x/text/unicode/bidi/example_test.go | 2 +- .../x/text/unicode/bidi/prop.go | 0 .../x/text/unicode/bidi/tables.go | 2 +- .../x/text/unicode/bidi/trieval.go | 2 +- .../x/text/unicode/doc.go | 2 +- .../x/text/unicode/norm/composition.go | 0 .../x/text/unicode/norm/example_iter_test.go | 2 +- .../x/text/unicode/norm/example_test.go | 2 +- .../x/text/unicode/norm/forminfo.go | 0 .../x/text/unicode/norm/input.go | 0 .../x/text/unicode/norm/iter.go | 0 .../x/text/unicode/norm/normalize.go | 4 +- .../x/text/unicode/norm/readwriter.go | 0 .../x/text/unicode/norm/tables.go | 2 +- .../x/text/unicode/norm/transform.go | 2 +- .../x/text/unicode/norm/trie.go | 0 .../x/text/unicode/norm/triegen.go | 0 libgo/go/internal/xcoff/ar.go | 228 + libgo/go/internal/xcoff/ar_test.go | 79 + libgo/go/internal/xcoff/file.go | 687 ++ libgo/go/internal/xcoff/file_test.go | 102 + libgo/go/internal/xcoff/testdata/bigar-empty | 2 + libgo/go/internal/xcoff/testdata/bigar-ppc64 | Bin 0 -> 2468 bytes .../xcoff/testdata/gcc-ppc32-aix-dwarf2-exec | Bin 0 -> 54694 bytes .../xcoff/testdata/gcc-ppc64-aix-dwarf2-exec | Bin 0 -> 57152 bytes libgo/go/internal/xcoff/testdata/hello.c | 7 + libgo/go/internal/xcoff/testdata/printbye.c | 5 + libgo/go/internal/xcoff/testdata/printhello.c | 5 + libgo/go/internal/xcoff/xcoff.go | 367 + libgo/go/io/io.go | 8 +- libgo/go/io/ioutil/example_test.go | 8 + libgo/go/io/multi.go | 4 +- libgo/go/log/log.go | 7 + libgo/go/math/all_test.go | 76 + libgo/go/math/big/arith.go | 2 +- libgo/go/math/big/float.go | 12 +- libgo/go/math/big/int.go | 7 + libgo/go/math/big/int_test.go | 26 + libgo/go/math/big/nat.go | 56 +- libgo/go/math/big/prime.go | 2 +- libgo/go/math/big/rat.go | 7 + libgo/go/math/big/sqrt.go | 20 +- libgo/go/math/bits/bits.go | 207 +- libgo/go/math/bits/bits_test.go | 380 + libgo/go/math/cmplx/isinf.go | 2 +- libgo/go/math/cmplx/isnan.go | 2 +- libgo/go/math/example_test.go | 22 + libgo/go/math/export_test.go | 3 + libgo/go/math/huge_test.go | 99 + libgo/go/math/log1p.go | 5 +- libgo/go/math/mod.go | 8 +- libgo/go/math/pow.go | 12 +- libgo/go/math/signbit.go | 2 +- libgo/go/math/sin.go | 64 +- libgo/go/math/sincos.go | 29 +- libgo/go/math/sincos_386.go | 15 - libgo/go/math/sinh.go | 2 +- libgo/go/math/tan.go | 28 +- libgo/go/math/trig_reduce.go | 94 + libgo/go/math/unsafe.go | 20 +- libgo/go/mime/mediatype.go | 5 +- libgo/go/mime/mediatype_test.go | 5 + libgo/go/mime/multipart/formdata_test.go | 8 +- libgo/go/mime/multipart/multipart.go | 3 +- libgo/go/mime/multipart/multipart_test.go | 16 +- libgo/go/mime/multipart/writer.go | 8 +- libgo/go/mime/multipart/writer_test.go | 13 + libgo/go/net/cgo_stub.go | 2 +- libgo/go/net/cgo_unix.go | 37 +- libgo/go/net/cgo_unix_test.go | 4 +- libgo/go/net/conf.go | 5 +- libgo/go/net/dial.go | 37 +- libgo/go/net/dial_test.go | 39 +- libgo/go/net/dnsclient.go | 17 +- libgo/go/net/dnsclient_unix.go | 3 +- libgo/go/net/dnsclient_unix_test.go | 2 +- libgo/go/net/dnsconfig_unix.go | 3 +- libgo/go/net/dnsname_test.go | 1 + libgo/go/net/error_test.go | 6 +- libgo/go/net/error_unix.go | 2 +- libgo/go/net/hook.go | 12 +- libgo/go/net/hosts.go | 3 +- libgo/go/net/http/cgi/child.go | 2 +- libgo/go/net/http/client.go | 18 +- libgo/go/net/http/client_test.go | 25 + libgo/go/net/http/clientserver_test.go | 97 +- libgo/go/net/http/cookie.go | 14 +- libgo/go/net/http/example_filesystem_test.go | 71 + libgo/go/net/http/example_handle_test.go | 29 + libgo/go/net/http/example_test.go | 32 + libgo/go/net/http/export_test.go | 8 +- libgo/go/net/http/h2_bundle.go | 530 +- libgo/go/net/http/header.go | 52 +- libgo/go/net/http/header_test.go | 3 +- libgo/go/net/http/http.go | 6 +- libgo/go/net/http/httptest/recorder.go | 2 +- libgo/go/net/http/httptest/server.go | 28 +- libgo/go/net/http/httputil/dump_test.go | 2 +- libgo/go/net/http/httputil/reverseproxy.go | 218 +- .../go/net/http/httputil/reverseproxy_test.go | 217 +- libgo/go/net/http/proxy_test.go | 2 +- libgo/go/net/http/readrequest_test.go | 2 +- libgo/go/net/http/request.go | 49 +- libgo/go/net/http/request_test.go | 6 +- libgo/go/net/http/requestwrite_test.go | 64 + libgo/go/net/http/response.go | 25 + libgo/go/net/http/response_test.go | 28 + libgo/go/net/http/roundtrip_js.go | 21 +- libgo/go/net/http/serve_test.go | 39 +- libgo/go/net/http/server.go | 113 +- libgo/go/net/http/server_test.go | 45 + libgo/go/net/http/socks_bundle.go | 1 + libgo/go/net/http/status.go | 2 + libgo/go/net/http/transfer.go | 42 +- libgo/go/net/http/transport.go | 135 +- libgo/go/net/http/transport_internal_test.go | 83 + libgo/go/net/http/transport_test.go | 241 +- libgo/go/net/interface.go | 44 +- libgo/go/net/interface_aix.go | 183 + libgo/go/net/interface_bsd.go | 2 +- libgo/go/net/interface_bsdvar.go | 2 +- libgo/go/net/interface_darwin.go | 2 +- libgo/go/net/interface_freebsd.go | 2 +- libgo/go/net/interface_solaris.go | 2 +- libgo/go/net/interface_test.go | 2 +- libgo/go/net/ip.go | 18 +- libgo/go/net/ipsock.go | 13 +- libgo/go/net/ipsock_plan9.go | 3 +- libgo/go/net/ipsock_posix.go | 2 +- libgo/go/net/listen_test.go | 2 +- libgo/go/net/lookup.go | 62 +- libgo/go/net/lookup_fake.go | 2 +- libgo/go/net/lookup_plan9.go | 11 +- libgo/go/net/lookup_test.go | 112 +- libgo/go/net/lookup_unix.go | 9 +- libgo/go/net/lookup_windows.go | 14 +- libgo/go/net/mail/message.go | 9 +- libgo/go/net/mail/message_test.go | 4 +- libgo/go/net/net.go | 11 +- libgo/go/net/nss.go | 9 +- libgo/go/net/parse.go | 26 +- libgo/go/net/pipe_test.go | 2 +- libgo/go/net/platform_test.go | 14 +- libgo/go/net/port_unix.go | 7 +- libgo/go/net/rawconn_unix_test.go | 2 +- libgo/go/net/sendfile_linux.go | 14 +- libgo/go/net/sendfile_test.go | 126 +- libgo/go/net/sendfile_unix_alt.go | 14 +- libgo/go/net/smtp/smtp_test.go | 60 +- libgo/go/net/sock_posix.go | 2 +- libgo/go/net/sockaddr_posix.go | 2 +- libgo/go/net/sockopt_aix.go | 10 +- libgo/go/net/sockopt_posix.go | 3 +- libgo/go/net/sockoptip_bsdvar.go | 2 +- libgo/go/net/splice_linux.go | 17 +- libgo/go/net/splice_test.go | 581 +- libgo/go/net/tcpsock_test.go | 31 + .../go/net/testdata/Mark.Twain-Tom.Sawyer.txt | 8465 --------------- libgo/go/net/textproto/reader.go | 11 +- libgo/go/net/textproto/reader_test.go | 44 +- libgo/go/net/timeout_test.go | 3 + libgo/go/net/udpsock_test.go | 15 +- libgo/go/net/unixsock.go | 7 +- libgo/go/net/unixsock_windows_test.go | 100 + libgo/go/net/url/url.go | 22 +- libgo/go/net/url/url_test.go | 109 +- libgo/go/os/dir_gccgo.go | 7 +- libgo/go/os/dir_ios.go | 87 + libgo/go/os/dir_libc64_gccgo.go | 3 - libgo/go/os/dir_libc_gccgo.go | 3 - libgo/go/os/dir_unix.go | 38 - libgo/go/os/env_unix_test.go | 2 +- libgo/go/os/error_posix.go | 2 +- libgo/go/os/error_unix_test.go | 2 +- libgo/go/os/example_test.go | 36 +- libgo/go/os/exec/exec.go | 9 + libgo/go/os/exec/exec_posix_test.go | 2 +- libgo/go/os/exec/exec_test.go | 62 +- libgo/go/os/exec/lp_unix_test.go | 2 +- libgo/go/os/exec_plan9.go | 10 + libgo/go/os/exec_posix.go | 19 +- libgo/go/os/exec_windows.go | 3 +- libgo/go/os/executable_test.go | 4 +- libgo/go/os/file.go | 36 +- libgo/go/os/file_plan9.go | 18 + libgo/go/os/file_posix.go | 3 +- libgo/go/os/file_unix.go | 84 +- libgo/go/os/os_test.go | 73 +- libgo/go/os/os_unix_test.go | 7 +- libgo/go/os/path.go | 102 +- libgo/go/os/path_test.go | 125 - libgo/go/os/path_unix.go | 28 +- libgo/go/os/path_windows_test.go | 6 +- libgo/go/os/pipe_test.go | 2 +- libgo/go/os/rawconn.go | 47 + libgo/go/os/rawconn_test.go | 65 + libgo/go/os/removeall_at.go | 138 + libgo/go/os/removeall_noat.go | 123 + libgo/go/os/removeall_test.go | 294 + libgo/go/os/signal/internal/pty/pty.go | 1 + libgo/go/os/signal/signal_cgo_test.go | 5 + libgo/go/os/stat_aix.go | 2 +- libgo/go/os/stat_test.go | 292 + libgo/go/os/sticky_bsd.go | 2 +- libgo/go/os/sticky_notbsd.go | 1 + libgo/go/os/sys_aix.go | 26 + libgo/go/os/types.go | 2 +- libgo/go/os/types_windows.go | 85 +- libgo/go/os/user/lookup.go | 4 + libgo/go/os/user/lookup_stubs.go | 15 +- libgo/go/os/user/lookup_unix.go | 2 +- libgo/go/os/user/lookup_unix_test.go | 2 +- libgo/go/os/user/user.go | 2 +- libgo/go/os/user/user_test.go | 18 +- libgo/go/os/wait_unimp.go | 2 +- libgo/go/os/wait_wait6.go | 2 +- libgo/go/os/wait_waitid.go | 2 +- libgo/go/path/filepath/example_unix_test.go | 15 + libgo/go/path/filepath/match_test.go | 2 +- libgo/go/path/filepath/path.go | 15 +- libgo/go/path/filepath/path_test.go | 56 +- libgo/go/path/filepath/path_windows.go | 37 +- libgo/go/path/filepath/symlink.go | 191 +- libgo/go/path/filepath/symlink_unix.go | 9 + libgo/go/path/filepath/symlink_windows.go | 10 +- libgo/go/plugin/plugin_dlopen.go | 10 - libgo/go/plugin/plugin_test.go | 18 + libgo/go/reflect/all_test.go | 146 +- libgo/go/reflect/example_test.go | 18 + libgo/go/reflect/type.go | 3 +- libgo/go/reflect/value.go | 110 +- libgo/go/regexp/all_test.go | 27 +- libgo/go/regexp/backtrack.go | 179 +- libgo/go/regexp/exec.go | 312 +- libgo/go/regexp/exec_test.go | 12 +- libgo/go/regexp/onepass.go | 24 +- libgo/go/regexp/onepass_test.go | 106 +- libgo/go/regexp/regexp.go | 163 +- libgo/go/regexp/syntax/prog.go | 32 +- libgo/go/regexp/syntax/regexp.go | 2 +- libgo/go/runtime/atomic_pointer.go | 13 - libgo/go/runtime/cgo_gccgo.go | 44 +- libgo/go/runtime/cgocall.go | 4 +- libgo/go/runtime/cgocheck.go | 9 +- libgo/go/runtime/chan.go | 28 +- libgo/go/runtime/crash_cgo_test.go | 60 +- libgo/go/runtime/crash_test.go | 3 + libgo/go/runtime/debug/mod.go | 112 + libgo/go/runtime/debug_test.go | 53 +- libgo/go/runtime/env_posix.go | 25 +- libgo/go/runtime/export_debug_test.go | 48 +- libgo/go/runtime/export_test.go | 41 + libgo/go/runtime/extern.go | 14 +- libgo/go/runtime/fastlog2table.go | 2 +- libgo/go/runtime/gc_test.go | 10 +- libgo/go/runtime/gcinfo_test.go | 48 +- libgo/go/runtime/hash_test.go | 6 +- libgo/go/runtime/heapdump.go | 12 +- libgo/go/runtime/internal/atomic/atomic.c | 40 +- libgo/go/runtime/internal/atomic/gccgo.go | 9 + libgo/go/runtime/internal/math/math.go | 19 + libgo/go/runtime/internal/math/math_test.go | 79 + libgo/go/runtime/lfstack_64bit.go | 10 +- libgo/go/runtime/lock_futex.go | 2 +- libgo/go/runtime/lock_js.go | 80 +- libgo/go/runtime/lock_sema.go | 2 +- libgo/go/runtime/malloc.go | 149 +- libgo/go/runtime/malloc_test.go | 16 + libgo/go/runtime/map.go | 96 +- libgo/go/runtime/map_benchmark_test.go | 113 + libgo/go/runtime/map_fast32.go | 59 +- libgo/go/runtime/map_fast64.go | 59 +- libgo/go/runtime/map_faststr.go | 65 +- libgo/go/runtime/map_test.go | 25 + libgo/go/runtime/mbarrier.go | 2 - libgo/go/runtime/mbitmap.go | 59 +- libgo/go/runtime/mcache.go | 58 +- libgo/go/runtime/mcentral.go | 74 +- libgo/go/runtime/mfinal.go | 1 + libgo/go/runtime/mfixalloc.go | 2 +- libgo/go/runtime/mgc.go | 760 +- libgo/go/runtime/mgc_gccgo.go | 5 +- libgo/go/runtime/mgclarge.go | 160 +- libgo/go/runtime/mgcmark.go | 252 +- libgo/go/runtime/mgcsweep.go | 112 +- libgo/go/runtime/mgcsweepbuf.go | 5 +- libgo/go/runtime/mgcwork.go | 180 +- libgo/go/runtime/mheap.go | 788 +- libgo/go/runtime/mkfastlog2table.go | 2 +- libgo/go/runtime/mprof.go | 2 +- libgo/go/runtime/mstats.go | 18 +- libgo/go/runtime/mwbbuf.go | 51 +- libgo/go/runtime/netpoll.go | 141 +- libgo/go/runtime/netpoll_aix.go | 127 +- libgo/go/runtime/netpoll_epoll.go | 12 +- libgo/go/runtime/netpoll_fake.go | 4 +- libgo/go/runtime/netpoll_kqueue.go | 12 +- libgo/go/runtime/netpoll_solaris.go | 12 +- libgo/go/runtime/netpoll_stub.go | 4 +- libgo/go/runtime/netpoll_windows.go | 22 +- libgo/go/runtime/os_aix.go | 23 +- libgo/go/runtime/os_freebsd.go | 39 + libgo/go/runtime/os_linux_arm64.go | 10 +- libgo/go/runtime/os_windows_arm.go | 22 + libgo/go/runtime/panic.go | 56 +- .../runtime/pprof/internal/profile/filter.go | 2 +- .../runtime/pprof/internal/profile/profile.go | 12 +- libgo/go/runtime/pprof/pprof.go | 3 +- libgo/go/runtime/pprof/pprof_test.go | 122 +- libgo/go/runtime/pprof/proto.go | 10 +- libgo/go/runtime/pprof/proto_test.go | 95 +- libgo/go/runtime/pprof/protomem.go | 4 +- libgo/go/runtime/pprof/protomem_test.go | 4 +- libgo/go/runtime/print.go | 7 +- libgo/go/runtime/proc.go | 540 +- libgo/go/runtime/proc_test.go | 15 +- libgo/go/runtime/runtime1.go | 25 +- libgo/go/runtime/runtime2.go | 41 +- libgo/go/runtime/select.go | 2 +- libgo/go/runtime/sema.go | 4 +- libgo/go/runtime/semasleep_test.go | 88 + libgo/go/runtime/signal_unix.go | 2 +- libgo/go/runtime/slice.go | 79 +- libgo/go/runtime/slice_test.go | 64 +- libgo/go/runtime/string.go | 9 +- libgo/go/runtime/string_test.go | 30 + libgo/go/runtime/stubs.go | 22 +- libgo/go/runtime/stubs2.go | 1 + libgo/go/runtime/stubs3.go | 1 + libgo/go/runtime/symtab.go | 10 +- libgo/go/runtime/sys_darwin.go | 57 +- libgo/go/runtime/sys_darwin_32.go | 32 + libgo/go/runtime/sys_darwin_64.go | 32 + libgo/go/runtime/testdata/testprog/gc.go | 88 +- libgo/go/runtime/testdata/testprog/gettid.go | 29 - .../runtime/testdata/testprog/lockosthread.go | 103 + .../testdata/testprog/syscalls.go} | 12 +- .../testdata/testprog/syscalls_linux.go | 59 + .../{gettid_none.go => syscalls_none.go} | 12 + .../testdata/testprog/traceback_ancestors.go | 56 +- libgo/go/runtime/testdata/testprogcgo/exec.go | 16 + .../go/runtime/testdata/testprogcgo/pprof.go | 8 +- .../testdata/testprogcgo/threadpprof.go | 6 +- libgo/go/runtime/time.go | 67 +- libgo/go/runtime/timeasm.go | 2 - libgo/go/runtime/timestub.go | 2 +- libgo/go/runtime/timestub2.go | 1 + libgo/go/runtime/trace.go | 14 +- libgo/go/runtime/trace/annotation.go | 2 +- libgo/go/runtime/traceback_gccgo.go | 122 +- libgo/go/strconv/atoi.go | 4 +- libgo/go/strconv/doc.go | 4 +- libgo/go/strconv/example_test.go | 56 +- libgo/go/strconv/itoa.go | 12 +- libgo/go/strconv/quote.go | 12 +- libgo/go/strings/builder.go | 5 + libgo/go/strings/builder_test.go | 16 + libgo/go/strings/compare_test.go | 13 +- libgo/go/strings/example_test.go | 6 + libgo/go/strings/export_test.go | 2 + libgo/go/strings/indexbyte.c | 29 - libgo/go/strings/reader.go | 6 +- libgo/go/strings/reader_test.go | 42 + libgo/go/strings/replace.go | 38 +- libgo/go/strings/strings.go | 172 +- libgo/go/strings/strings_decl.go | 8 - libgo/go/strings/strings_test.go | 48 +- libgo/go/sync/map.go | 12 +- libgo/go/sync/runtime.go | 2 +- libgo/go/syscall/bpf_bsd.go | 2 +- libgo/go/syscall/bpf_darwin.go | 185 + libgo/go/syscall/dirent_bsd_test.go | 76 + libgo/go/syscall/exec_aix_test.go | 37 + libgo/go/syscall/exec_darwin.go | 248 + libgo/go/syscall/exec_linux.go | 9 +- libgo/go/syscall/exec_linux_test.go | 6 + libgo/go/syscall/exec_unix.go | 24 +- libgo/go/syscall/export_freebsd_test.go | 12 + libgo/go/syscall/flock_aix.go | 18 + libgo/go/syscall/flock_darwin.go | 13 + libgo/go/syscall/forkpipe.go | 2 +- libgo/go/syscall/fs_js.go | 95 +- libgo/go/syscall/js/callback.go | 122 - libgo/go/syscall/js/func.go | 92 + libgo/go/syscall/js/js.go | 64 +- libgo/go/syscall/js/js_test.go | 120 +- libgo/go/syscall/js/typedarray.go | 2 + libgo/go/syscall/mkasm_darwin.go | 58 + libgo/go/syscall/net.go | 2 +- libgo/go/syscall/route_freebsd.go | 4 - libgo/go/syscall/route_freebsd_32bit.go | 2 +- libgo/go/syscall/sockcmsg_unix.go | 25 +- libgo/go/syscall/syscall_freebsd.go | 29 +- libgo/go/syscall/syscall_freebsd_test.go | 54 + libgo/go/syscall/syscall_js.go | 1 + libgo/go/syscall/syscall_linux_test.go | 7 +- libgo/go/syscall/syscall_unix_test.go | 18 +- libgo/go/testdata/Isaac.Newton-Opticks.txt | 9286 +++++++++++++++++ libgo/go/testing/benchmark.go | 77 +- libgo/go/testing/sub_test.go | 31 +- libgo/go/testing/testing.go | 53 +- libgo/go/text/scanner/scanner.go | 3 + libgo/go/text/scanner/scanner_test.go | 27 + libgo/go/text/template/doc.go | 4 +- libgo/go/text/template/exec.go | 45 +- libgo/go/text/template/exec_test.go | 60 + libgo/go/text/template/funcs.go | 25 +- libgo/go/text/template/parse/lex.go | 22 +- libgo/go/text/template/parse/parse.go | 69 +- libgo/go/text/template/parse/parse_test.go | 38 +- libgo/go/time/example_test.go | 15 +- libgo/go/time/format.go | 13 +- libgo/go/time/format_test.go | 21 +- libgo/go/time/sleep.go | 3 - libgo/go/time/sleep_test.go | 4 - libgo/go/time/time.go | 44 +- libgo/go/time/zoneinfo.go | 13 +- libgo/go/time/zoneinfo_android.go | 3 +- libgo/go/time/zoneinfo_js.go | 67 + libgo/go/time/zoneinfo_read.go | 15 +- libgo/go/time/zoneinfo_test.go | 11 + libgo/go/unicode/tables.go | 58 +- libgo/gotool-packages.txt | 40 +- libgo/libgo-packages.txt | 43 +- libgo/match.sh | 4 +- libgo/merge.sh | 8 +- libgo/misc/cgo/errors/errors_test.go | 9 +- libgo/misc/cgo/errors/ptr_test.go | 82 +- libgo/misc/cgo/errors/src/issue26745.go | 17 + libgo/misc/cgo/errors/src/issue28069.go | 26 + libgo/misc/cgo/errors/src/issue28721.go | 29 + libgo/misc/cgo/test/callback.go | 6 +- libgo/misc/cgo/test/cgo_test.go | 2 + libgo/misc/cgo/test/issue27054/egl.h | 7 + libgo/misc/cgo/test/issue27054/test27054.go | 17 + libgo/misc/cgo/test/issue27340.go | 12 + libgo/misc/cgo/test/issue27340/a.go | 42 + libgo/misc/cgo/test/issue28545.go | 26 + libgo/misc/cgo/test/issue28772.go | 12 + libgo/misc/cgo/test/issue28896.go | 83 + libgo/misc/cgo/test/issue29383.go | 19 + libgo/misc/cgo/test/issue4339.go | 3 +- libgo/misc/cgo/test/issue9026/issue9026.go | 2 +- libgo/misc/cgo/test/issue9400_linux.go | 2 +- libgo/misc/cgo/test/test27660.go | 61 + libgo/misc/cgo/test/twoargs.go | 22 + libgo/misc/cgo/testcshared/cshared_test.go | 52 + .../cgo/testcshared/src/go2c2go/go/shlib.go | 12 + libgo/misc/cgo/testcshared/src/go2c2go/m1/c.c | 9 + .../cgo/testcshared/src/go2c2go/m1/main.go | 22 + .../cgo/testcshared/src/go2c2go/m2/main.go | 22 + .../cgo/testplugin/src/checkdwarf/main.go | 106 + libgo/misc/cgo/testplugin/test.bash | 8 + libgo/misc/cgo/testplugin/unnamed1/main.go | 2 +- libgo/misc/cgo/testsanitizers/cc_test.go | 2 +- libgo/misc/cgo/testshared/shared_test.go | 10 +- libgo/misc/cgo/testshared/src/issue25065/a.go | 20 + libgo/runtime/runtime.h | 2 +- libgo/testsuite/gotest | 4 +- 1331 files changed, 71628 insertions(+), 44986 deletions(-) delete mode 100644 libgo/go/bytes/bytes_decl.go delete mode 100644 libgo/go/bytes/indexbyte.c create mode 100644 libgo/go/cmd/go/help_test.go delete mode 100644 libgo/go/cmd/go/internal/cache/default_unix_test.go create mode 100644 libgo/go/cmd/go/internal/get/path.go create mode 100644 libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock.go create mode 100644 libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_fcntl.go create mode 100644 libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_other.go create mode 100644 libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_plan9.go create mode 100644 libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_test.go create mode 100644 libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_unix.go create mode 100644 libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_windows.go create mode 100644 libgo/go/cmd/go/internal/lockedfile/lockedfile.go create mode 100644 libgo/go/cmd/go/internal/lockedfile/lockedfile_filelock.go create mode 100644 libgo/go/cmd/go/internal/lockedfile/lockedfile_plan9.go create mode 100644 libgo/go/cmd/go/internal/lockedfile/lockedfile_test.go create mode 100644 libgo/go/cmd/go/internal/lockedfile/mutex.go create mode 100644 libgo/go/cmd/go/internal/modload/init_test.go rename libgo/go/{net/http/race.go => cmd/go/internal/modload/testgo.go} (52%) create mode 100644 libgo/go/cmd/go/internal/renameio/renameio.go delete mode 100644 libgo/go/cmd/go/testdata/mod/research.swtch.com_vgo-tour_v1.0.0.txt create mode 100644 libgo/go/cmd/internal/sys/arch.go create mode 100644 libgo/go/cmd/internal/sys/supported.go delete mode 100644 libgo/go/cmd/vet/assign.go delete mode 100644 libgo/go/cmd/vet/atomic.go delete mode 100644 libgo/go/cmd/vet/buildtag.go delete mode 100644 libgo/go/cmd/vet/cgo.go delete mode 100644 libgo/go/cmd/vet/composite.go delete mode 100644 libgo/go/cmd/vet/httpresponse.go delete mode 100644 libgo/go/cmd/vet/internal/cfg/cfg_test.go delete mode 100644 libgo/go/cmd/vet/lostcancel.go delete mode 100644 libgo/go/cmd/vet/nilfunc.go delete mode 100644 libgo/go/cmd/vet/rangeloop.go delete mode 100644 libgo/go/cmd/vet/shadow.go delete mode 100644 libgo/go/cmd/vet/shift.go delete mode 100644 libgo/go/cmd/vet/structtag.go delete mode 100644 libgo/go/cmd/vet/testdata/asm/asm.go delete mode 100644 libgo/go/cmd/vet/testdata/asm/asm1.s delete mode 100644 libgo/go/cmd/vet/testdata/asm/asm2.s delete mode 100644 libgo/go/cmd/vet/testdata/asm/asm3.s delete mode 100644 libgo/go/cmd/vet/testdata/asm/asm4.s delete mode 100644 libgo/go/cmd/vet/testdata/asm/asm5.s delete mode 100644 libgo/go/cmd/vet/testdata/asm/asm6.s delete mode 100644 libgo/go/cmd/vet/testdata/asm/asm7.s delete mode 100644 libgo/go/cmd/vet/testdata/asm8.s delete mode 100644 libgo/go/cmd/vet/testdata/atomic.go delete mode 100644 libgo/go/cmd/vet/testdata/bool.go delete mode 100644 libgo/go/cmd/vet/testdata/buildtag/buildtag_bad.go delete mode 100644 libgo/go/cmd/vet/testdata/cgo/cgo.go delete mode 100644 libgo/go/cmd/vet/testdata/cgo/cgo2.go delete mode 100644 libgo/go/cmd/vet/testdata/cgo/cgo4.go delete mode 100644 libgo/go/cmd/vet/testdata/composite.go delete mode 100644 libgo/go/cmd/vet/testdata/copylock.go delete mode 100644 libgo/go/cmd/vet/testdata/copylock_func.go delete mode 100644 libgo/go/cmd/vet/testdata/copylock_range.go delete mode 100644 libgo/go/cmd/vet/testdata/deadcode.go delete mode 100644 libgo/go/cmd/vet/testdata/divergent/buf.go delete mode 100644 libgo/go/cmd/vet/testdata/divergent/buf_test.go delete mode 100644 libgo/go/cmd/vet/testdata/httpresponse.go delete mode 100644 libgo/go/cmd/vet/testdata/incomplete/examples_test.go delete mode 100644 libgo/go/cmd/vet/testdata/lostcancel.go delete mode 100644 libgo/go/cmd/vet/testdata/nilfunc.go delete mode 100644 libgo/go/cmd/vet/testdata/rangeloop.go delete mode 100644 libgo/go/cmd/vet/testdata/shadow.go delete mode 100644 libgo/go/cmd/vet/testdata/shift.go create mode 100644 libgo/go/cmd/vet/testdata/src/asm/asm.go create mode 100644 libgo/go/cmd/vet/testdata/src/asm/asm1.s rename libgo/go/cmd/vet/testdata/{ => src/assign}/assign.go (97%) create mode 100644 libgo/go/cmd/vet/testdata/src/atomic/atomic.go create mode 100644 libgo/go/cmd/vet/testdata/src/bool/bool.go rename libgo/go/cmd/vet/testdata/{ => src}/buildtag/buildtag.go (100%) create mode 100644 libgo/go/cmd/vet/testdata/src/cgo/cgo.go create mode 100644 libgo/go/cmd/vet/testdata/src/composite/composite.go create mode 100644 libgo/go/cmd/vet/testdata/src/copylock/copylock.go create mode 100644 libgo/go/cmd/vet/testdata/src/deadcode/deadcode.go create mode 100644 libgo/go/cmd/vet/testdata/src/httpresponse/httpresponse.go create mode 100644 libgo/go/cmd/vet/testdata/src/lostcancel/lostcancel.go rename libgo/go/cmd/vet/testdata/{ => src/method}/method.go (57%) create mode 100644 libgo/go/cmd/vet/testdata/src/nilfunc/nilfunc.go rename libgo/go/cmd/vet/testdata/{ => src/print}/print.go (88%) create mode 100644 libgo/go/cmd/vet/testdata/src/rangeloop/rangeloop.go create mode 100644 libgo/go/cmd/vet/testdata/src/shift/shift.go create mode 100644 libgo/go/cmd/vet/testdata/src/structtag/structtag.go rename libgo/go/cmd/vet/testdata/{ => src}/tagtest/file1.go (85%) rename libgo/go/cmd/vet/testdata/{ => src}/tagtest/file2.go (80%) rename libgo/go/cmd/vet/testdata/{ => src}/testingpkg/tests.go (100%) create mode 100644 libgo/go/cmd/vet/testdata/src/testingpkg/tests_test.go create mode 100644 libgo/go/cmd/vet/testdata/src/unmarshal/unmarshal.go create mode 100644 libgo/go/cmd/vet/testdata/src/unsafeptr/unsafeptr.go create mode 100644 libgo/go/cmd/vet/testdata/src/unused/unused.go delete mode 100644 libgo/go/cmd/vet/testdata/structtag.go delete mode 100644 libgo/go/cmd/vet/testdata/testingpkg/tests_test.go delete mode 100644 libgo/go/cmd/vet/testdata/unsafeptr.go delete mode 100644 libgo/go/cmd/vet/testdata/unused.go delete mode 100644 libgo/go/cmd/vet/tests.go delete mode 100644 libgo/go/cmd/vet/types.go delete mode 100644 libgo/go/cmd/vet/unsafeptr.go delete mode 100644 libgo/go/cmd/vet/unused.go create mode 100644 libgo/go/compress/bzip2/testdata/Isaac.Newton-Opticks.txt.bz2 create mode 100644 libgo/go/compress/flate/testdata/Isaac.Newton-Opticks.txt delete mode 100644 libgo/go/compress/testdata/Mark.Twain-Tom.Sawyer.txt create mode 100644 libgo/go/crypto/cipher/export_test.go create mode 100644 libgo/go/crypto/cipher/xor_amd64.go rename libgo/go/crypto/cipher/{xor.go => xor_generic.go} (74%) create mode 100644 libgo/go/crypto/cipher/xor_ppc64x.go create mode 100644 libgo/go/crypto/rand/rand_batched.go rename libgo/go/crypto/rand/{rand_linux_test.go => rand_batched_test.go} (97%) create mode 100644 libgo/go/crypto/rand/rand_freebsd.go delete mode 100644 libgo/go/crypto/rc4/rc4_asm.go delete mode 100644 libgo/go/crypto/rc4/rc4_ref.go create mode 100644 libgo/go/crypto/tls/handshake_client_tls13.go create mode 100644 libgo/go/crypto/tls/handshake_server_tls13.go create mode 100644 libgo/go/crypto/tls/key_schedule.go create mode 100644 libgo/go/crypto/tls/key_schedule_test.go create mode 100644 libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-RSAPKCS1v15 create mode 100644 libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-RSAPSS create mode 100644 libgo/go/crypto/tls/testdata/Client-TLSv12-P256-ECDHE rename libgo/go/crypto/tls/testdata/{Client-TLSv12-X25519-ECDHE-RSA-AES-GCM => Client-TLSv12-X25519-ECDHE} (53%) create mode 100644 libgo/go/crypto/tls/testdata/Client-TLSv13-AES128-SHA256 create mode 100644 libgo/go/crypto/tls/testdata/Client-TLSv13-AES256-SHA384 create mode 100644 libgo/go/crypto/tls/testdata/Client-TLSv13-ALPN create mode 100644 libgo/go/crypto/tls/testdata/Client-TLSv13-CHACHA20-SHA256 create mode 100644 libgo/go/crypto/tls/testdata/Client-TLSv13-ClientCert-ECDSA-RSA create mode 100644 libgo/go/crypto/tls/testdata/Client-TLSv13-ClientCert-RSA-ECDSA create mode 100644 libgo/go/crypto/tls/testdata/Client-TLSv13-ClientCert-RSA-RSAPSS create mode 100644 libgo/go/crypto/tls/testdata/Client-TLSv13-ECDSA create mode 100644 libgo/go/crypto/tls/testdata/Client-TLSv13-ExportKeyingMaterial create mode 100644 libgo/go/crypto/tls/testdata/Client-TLSv13-HelloRetryRequest create mode 100644 libgo/go/crypto/tls/testdata/Client-TLSv13-KeyUpdate create mode 100644 libgo/go/crypto/tls/testdata/Client-TLSv13-P256-ECDHE create mode 100644 libgo/go/crypto/tls/testdata/Client-TLSv13-X25519-ECDHE create mode 100644 libgo/go/crypto/tls/testdata/Server-TLSv12-ClientAuthRequestedAndPKCS1v15Given create mode 100644 libgo/go/crypto/tls/testdata/Server-TLSv12-P256 create mode 100644 libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-RSAPKCS1v15 create mode 100644 libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-RSAPSS rename libgo/go/crypto/tls/testdata/{Server-TLSv12-X25519-ECDHE-RSA-AES-GCM => Server-TLSv12-X25519} (58%) create mode 100644 libgo/go/crypto/tls/testdata/Server-TLSv13-AES128-SHA256 create mode 100644 libgo/go/crypto/tls/testdata/Server-TLSv13-AES256-SHA384 create mode 100644 libgo/go/crypto/tls/testdata/Server-TLSv13-ALPN create mode 100644 libgo/go/crypto/tls/testdata/Server-TLSv13-ALPN-NoMatch create mode 100644 libgo/go/crypto/tls/testdata/Server-TLSv13-CHACHA20-SHA256 create mode 100644 libgo/go/crypto/tls/testdata/Server-TLSv13-ClientAuthRequestedAndECDSAGiven create mode 100644 libgo/go/crypto/tls/testdata/Server-TLSv13-ClientAuthRequestedAndGiven create mode 100644 libgo/go/crypto/tls/testdata/Server-TLSv13-ClientAuthRequestedNotGiven create mode 100644 libgo/go/crypto/tls/testdata/Server-TLSv13-ECDHE-ECDSA-AES create mode 100644 libgo/go/crypto/tls/testdata/Server-TLSv13-ExportKeyingMaterial create mode 100644 libgo/go/crypto/tls/testdata/Server-TLSv13-HelloRetryRequest create mode 100644 libgo/go/crypto/tls/testdata/Server-TLSv13-IssueTicket create mode 100644 libgo/go/crypto/tls/testdata/Server-TLSv13-IssueTicketPreDisable create mode 100644 libgo/go/crypto/tls/testdata/Server-TLSv13-P256 create mode 100644 libgo/go/crypto/tls/testdata/Server-TLSv13-RSA-RSAPSS create mode 100644 libgo/go/crypto/tls/testdata/Server-TLSv13-Resume create mode 100644 libgo/go/crypto/tls/testdata/Server-TLSv13-Resume-HelloRetryRequest create mode 100644 libgo/go/crypto/tls/testdata/Server-TLSv13-ResumeDisabled create mode 100644 libgo/go/crypto/tls/testdata/Server-TLSv13-X25519 create mode 100644 libgo/go/database/sql/example_cli_test.go create mode 100644 libgo/go/database/sql/example_service_test.go create mode 100644 libgo/go/debug/gosym/testdata/main.go create mode 100644 libgo/go/debug/gosym/testdata/pclinetest.h create mode 100644 libgo/go/debug/gosym/testdata/pclinetest.s create mode 100644 libgo/go/encoding/json/example_text_marshaling_test.go create mode 100644 libgo/go/encoding/xml/example_marshaling_test.go create mode 100644 libgo/go/encoding/xml/example_text_marshaling_test.go create mode 100644 libgo/go/fmt/gostringer_example_test.go create mode 100644 libgo/go/fmt/stringer_example_test.go create mode 100644 libgo/go/go/build/testdata/withvendor/src/a/b/b.go create mode 100644 libgo/go/go/build/testdata/withvendor/src/a/c/d/d.go create mode 100644 libgo/go/go/doc/lazyre.go create mode 100644 libgo/go/go/format/benchmark_test.go delete mode 100644 libgo/go/go/internal/gccgoimporter/testdata/alias.gox create mode 100644 libgo/go/go/internal/gccgoimporter/testdata/aliases.go create mode 100644 libgo/go/go/internal/gccgoimporter/testdata/aliases.gox create mode 100644 libgo/go/go/internal/gccgoimporter/testdata/issue27856.go create mode 100644 libgo/go/go/internal/gccgoimporter/testdata/issue27856.gox create mode 100644 libgo/go/go/internal/gccgoimporter/testdata/issue29198.go create mode 100644 libgo/go/go/internal/gccgoimporter/testdata/issue29198.gox create mode 100644 libgo/go/go/internal/gccgoimporter/testdata/libimportsar.a create mode 100644 libgo/go/go/internal/gccgoimporter/testdata/nointerface.go create mode 100644 libgo/go/go/internal/gccgoimporter/testdata/nointerface.gox create mode 100644 libgo/go/go/internal/gccgoimporter/testdata/v1reflect.gox create mode 100644 libgo/go/golang.org/x/tools/LICENSE create mode 100644 libgo/go/golang.org/x/tools/PATENTS create mode 100644 libgo/go/golang.org/x/tools/go/analysis/analysis.go create mode 100644 libgo/go/golang.org/x/tools/go/analysis/doc.go create mode 100644 libgo/go/golang.org/x/tools/go/analysis/internal/analysisflags/flags.go create mode 100644 libgo/go/golang.org/x/tools/go/analysis/internal/analysisflags/help.go create mode 100644 libgo/go/golang.org/x/tools/go/analysis/internal/analysisflags/patch.go create mode 100644 libgo/go/golang.org/x/tools/go/analysis/internal/facts/facts.go create mode 100644 libgo/go/golang.org/x/tools/go/analysis/internal/facts/imports.go rename libgo/go/{cmd/vet => golang.org/x/tools/go/analysis/passes/asmdecl}/asmdecl.go (87%) create mode 100644 libgo/go/golang.org/x/tools/go/analysis/passes/assign/assign.go create mode 100644 libgo/go/golang.org/x/tools/go/analysis/passes/atomic/atomic.go rename libgo/go/{cmd/vet/bool.go => golang.org/x/tools/go/analysis/passes/bools/bools.go} (65%) create mode 100644 libgo/go/golang.org/x/tools/go/analysis/passes/buildtag/buildtag.go create mode 100644 libgo/go/golang.org/x/tools/go/analysis/passes/cgocall/cgocall.go create mode 100644 libgo/go/golang.org/x/tools/go/analysis/passes/composite/composite.go rename libgo/go/{cmd/vet/internal/whitelist => golang.org/x/tools/go/analysis/passes/composite}/whitelist.go (70%) rename libgo/go/{cmd/vet => golang.org/x/tools/go/analysis/passes/copylock}/copylock.go (50%) create mode 100644 libgo/go/golang.org/x/tools/go/analysis/passes/ctrlflow/ctrlflow.go create mode 100644 libgo/go/golang.org/x/tools/go/analysis/passes/httpresponse/httpresponse.go create mode 100644 libgo/go/golang.org/x/tools/go/analysis/passes/inspect/inspect.go create mode 100644 libgo/go/golang.org/x/tools/go/analysis/passes/internal/analysisutil/util.go create mode 100644 libgo/go/golang.org/x/tools/go/analysis/passes/loopclosure/loopclosure.go create mode 100644 libgo/go/golang.org/x/tools/go/analysis/passes/lostcancel/lostcancel.go create mode 100644 libgo/go/golang.org/x/tools/go/analysis/passes/nilfunc/nilfunc.go create mode 100644 libgo/go/golang.org/x/tools/go/analysis/passes/pkgfact/pkgfact.go rename libgo/go/{cmd/vet/print.go => golang.org/x/tools/go/analysis/passes/printf/printf.go} (57%) create mode 100644 libgo/go/golang.org/x/tools/go/analysis/passes/printf/types.go rename libgo/go/{cmd/vet => golang.org/x/tools/go/analysis/passes/shift}/dead.go (65%) create mode 100644 libgo/go/golang.org/x/tools/go/analysis/passes/shift/shift.go rename libgo/go/{cmd/vet/method.go => golang.org/x/tools/go/analysis/passes/stdmethods/stdmethods.go} (57%) create mode 100644 libgo/go/golang.org/x/tools/go/analysis/passes/structtag/structtag.go create mode 100644 libgo/go/golang.org/x/tools/go/analysis/passes/tests/tests.go create mode 100644 libgo/go/golang.org/x/tools/go/analysis/passes/unmarshal/unmarshal.go rename libgo/go/{cmd/vet/deadcode.go => golang.org/x/tools/go/analysis/passes/unreachable/unreachable.go} (79%) create mode 100644 libgo/go/golang.org/x/tools/go/analysis/passes/unsafeptr/unsafeptr.go create mode 100644 libgo/go/golang.org/x/tools/go/analysis/passes/unusedresult/unusedresult.go create mode 100644 libgo/go/golang.org/x/tools/go/analysis/unitchecker/main.go create mode 100644 libgo/go/golang.org/x/tools/go/analysis/unitchecker/unitchecker.go create mode 100644 libgo/go/golang.org/x/tools/go/analysis/unitchecker/unitchecker112.go create mode 100644 libgo/go/golang.org/x/tools/go/analysis/validate.go create mode 100644 libgo/go/golang.org/x/tools/go/ast/astutil/enclosing.go create mode 100644 libgo/go/golang.org/x/tools/go/ast/astutil/imports.go create mode 100644 libgo/go/golang.org/x/tools/go/ast/astutil/rewrite.go create mode 100644 libgo/go/golang.org/x/tools/go/ast/astutil/util.go create mode 100644 libgo/go/golang.org/x/tools/go/ast/inspector/inspector.go create mode 100644 libgo/go/golang.org/x/tools/go/ast/inspector/typeof.go rename libgo/go/{cmd/vet/internal => golang.org/x/tools/go}/cfg/builder.go (90%) rename libgo/go/{cmd/vet/internal => golang.org/x/tools/go}/cfg/cfg.go (83%) create mode 100644 libgo/go/golang.org/x/tools/go/types/objectpath/objectpath.go create mode 100644 libgo/go/golang.org/x/tools/go/types/typeutil/callee.go create mode 100644 libgo/go/golang.org/x/tools/go/types/typeutil/imports.go create mode 100644 libgo/go/golang.org/x/tools/go/types/typeutil/map.go create mode 100644 libgo/go/golang.org/x/tools/go/types/typeutil/methodsetcache.go create mode 100644 libgo/go/golang.org/x/tools/go/types/typeutil/ui.go delete mode 100644 libgo/go/golang_org/x/crypto/chacha20poly1305/internal/chacha20/chacha_generic.go delete mode 100644 libgo/go/golang_org/x/crypto/chacha20poly1305/internal/chacha20/chacha_test.go delete mode 100644 libgo/go/golang_org/x/net/idna/idna_test.go delete mode 100644 libgo/go/golang_org/x/net/lex/httplex/httplex.go delete mode 100644 libgo/go/golang_org/x/net/lex/httplex/httplex_test.go delete mode 100644 libgo/go/golang_org/x/net/lif/syscall.go delete mode 100644 libgo/go/golang_org/x/net/proxy/direct.go delete mode 100644 libgo/go/golang_org/x/net/proxy/per_host.go delete mode 100644 libgo/go/golang_org/x/net/proxy/per_host_test.go delete mode 100644 libgo/go/golang_org/x/net/proxy/proxy.go delete mode 100644 libgo/go/golang_org/x/net/proxy/proxy_test.go delete mode 100644 libgo/go/golang_org/x/net/proxy/socks5.go delete mode 100644 libgo/go/golang_org/x/text/width/kind_string.go delete mode 100644 libgo/go/golang_org/x/text/width/tables.go delete mode 100644 libgo/go/golang_org/x/text/width/transform.go delete mode 100644 libgo/go/golang_org/x/text/width/trieval.go delete mode 100644 libgo/go/golang_org/x/text/width/width.go delete mode 100644 libgo/go/internal/cpu/cpu_arm64_test.go delete mode 100644 libgo/go/internal/cpu/cpu_ppc64x_test.go create mode 100644 libgo/go/internal/fmtsort/export_test.go create mode 100644 libgo/go/internal/fmtsort/sort.go create mode 100644 libgo/go/internal/fmtsort/sort_test.go create mode 100644 libgo/go/internal/poll/fd_fsync_darwin.go create mode 100644 libgo/go/internal/poll/fd_fsync_posix.go create mode 100644 libgo/go/internal/poll/fd_fsync_windows.go create mode 100644 libgo/go/internal/poll/fd_opendir_ios.go create mode 100644 libgo/go/internal/poll/fd_writev_darwin.go create mode 100644 libgo/go/internal/poll/fd_writev_unix.go create mode 100644 libgo/go/internal/syscall/unix/at.go create mode 100644 libgo/go/internal/syscall/unix/at_aix.go create mode 100644 libgo/go/internal/syscall/unix/at_freebsd.go create mode 100644 libgo/go/internal/syscall/unix/at_solaris.go create mode 100644 libgo/go/internal/syscall/unix/at_sysnum_darwin.go create mode 100644 libgo/go/internal/syscall/unix/at_sysnum_dragonfly.go create mode 100644 libgo/go/internal/syscall/unix/at_sysnum_linux.go create mode 100644 libgo/go/internal/syscall/unix/at_sysnum_netbsd.go create mode 100644 libgo/go/internal/syscall/unix/at_sysnum_openbsd.go create mode 100644 libgo/go/internal/syscall/unix/getrandom_freebsd.go create mode 100644 libgo/go/internal/syscall/unix/ioctl_aix.go create mode 100644 libgo/go/internal/syscall/unix/nonblocking_darwin.go create mode 100644 libgo/go/internal/trace/gc.go create mode 100644 libgo/go/internal/trace/gc_test.go create mode 100644 libgo/go/internal/trace/mud.go create mode 100644 libgo/go/internal/trace/mud_test.go create mode 100644 libgo/go/internal/trace/testdata/http_1_10_good create mode 100644 libgo/go/internal/trace/testdata/http_1_11_good create mode 100644 libgo/go/internal/trace/testdata/http_1_9_good create mode 100644 libgo/go/internal/trace/testdata/stress_1_10_good create mode 100644 libgo/go/internal/trace/testdata/stress_1_11_good create mode 100644 libgo/go/internal/trace/testdata/stress_1_9_good create mode 100644 libgo/go/internal/trace/testdata/stress_start_stop_1_10_good create mode 100644 libgo/go/internal/trace/testdata/stress_start_stop_1_11_good create mode 100644 libgo/go/internal/trace/testdata/stress_start_stop_1_9_good create mode 100644 libgo/go/internal/trace/testdata/user_task_span_1_11_good rename libgo/go/{golang_org => internal}/x/crypto/chacha20poly1305/chacha20poly1305.go (97%) rename libgo/go/{golang_org => internal}/x/crypto/chacha20poly1305/chacha20poly1305_amd64.go (100%) rename libgo/go/{golang_org => internal}/x/crypto/chacha20poly1305/chacha20poly1305_generic.go (96%) rename libgo/go/{golang_org => internal}/x/crypto/chacha20poly1305/chacha20poly1305_noasm.go (100%) rename libgo/go/{golang_org => internal}/x/crypto/chacha20poly1305/chacha20poly1305_test.go (100%) rename libgo/go/{golang_org => internal}/x/crypto/chacha20poly1305/chacha20poly1305_vectors_test.go (100%) rename libgo/go/{golang_org => internal}/x/crypto/cryptobyte/asn1.go (99%) rename libgo/go/{golang_org => internal}/x/crypto/cryptobyte/asn1/asn1.go (96%) rename libgo/go/{golang_org => internal}/x/crypto/cryptobyte/asn1_test.go (99%) rename libgo/go/{golang_org => internal}/x/crypto/cryptobyte/builder.go (100%) rename libgo/go/{golang_org => internal}/x/crypto/cryptobyte/cryptobyte_test.go (100%) rename libgo/go/{golang_org => internal}/x/crypto/cryptobyte/example_test.go (98%) rename libgo/go/{golang_org => internal}/x/crypto/cryptobyte/string.go (98%) rename libgo/go/{golang_org => internal}/x/crypto/curve25519/curve25519.go (100%) rename libgo/go/{golang_org => internal}/x/crypto/curve25519/curve25519_test.go (100%) rename libgo/go/{golang_org => internal}/x/crypto/curve25519/doc.go (94%) rename libgo/go/{golang_org => internal}/x/crypto/curve25519/mont25519_amd64.go (100%) create mode 100644 libgo/go/internal/x/crypto/hkdf/example_test.go create mode 100644 libgo/go/internal/x/crypto/hkdf/hkdf.go create mode 100644 libgo/go/internal/x/crypto/hkdf/hkdf_test.go rename libgo/go/{golang_org => internal}/x/crypto/internal/chacha20/chacha_generic.go (100%) rename libgo/go/{golang_org => internal}/x/crypto/internal/chacha20/chacha_noasm.go (100%) rename libgo/go/{golang_org => internal}/x/crypto/internal/chacha20/chacha_s390x.go (100%) rename libgo/go/{golang_org => internal}/x/crypto/internal/chacha20/chacha_test.go (100%) rename libgo/go/{golang_org => internal}/x/crypto/internal/chacha20/vectors_test.go (100%) rename libgo/go/{golang_org => internal}/x/crypto/internal/chacha20/xor.go (100%) rename libgo/go/{golang_org => internal}/x/crypto/poly1305/poly1305.go (95%) rename libgo/go/{golang_org => internal}/x/crypto/poly1305/poly1305_test.go (100%) rename libgo/go/{golang_org => internal}/x/crypto/poly1305/sum_amd64.go (100%) rename libgo/go/{golang_org => internal}/x/crypto/poly1305/sum_arm.go (100%) rename libgo/go/{golang_org => internal}/x/crypto/poly1305/sum_noasm.go (100%) rename libgo/go/{golang_org => internal}/x/crypto/poly1305/sum_ref.go (100%) rename libgo/go/{golang_org => internal}/x/crypto/poly1305/sum_s390x.go (100%) rename libgo/go/{golang_org => internal}/x/crypto/poly1305/vectors_test.go (100%) rename libgo/go/{golang_org => internal}/x/net/dns/dnsmessage/example_test.go (97%) rename libgo/go/{golang_org => internal}/x/net/dns/dnsmessage/message.go (100%) rename libgo/go/{golang_org => internal}/x/net/dns/dnsmessage/message_test.go (100%) rename libgo/go/{golang_org => internal}/x/net/http/httpguts/guts.go (100%) rename libgo/go/{golang_org => internal}/x/net/http/httpguts/httplex.go (99%) rename libgo/go/{golang_org => internal}/x/net/http/httpguts/httplex_test.go (100%) rename libgo/go/{golang_org => internal}/x/net/http/httpproxy/export_test.go (100%) rename libgo/go/{golang_org => internal}/x/net/http/httpproxy/proxy.go (99%) rename libgo/go/{golang_org => internal}/x/net/http/httpproxy/proxy_test.go (99%) rename libgo/go/{golang_org => internal}/x/net/http2/hpack/encode.go (100%) rename libgo/go/{golang_org => internal}/x/net/http2/hpack/encode_test.go (100%) rename libgo/go/{golang_org => internal}/x/net/http2/hpack/hpack.go (97%) rename libgo/go/{golang_org => internal}/x/net/http2/hpack/hpack_test.go (98%) rename libgo/go/{golang_org => internal}/x/net/http2/hpack/huffman.go (100%) rename libgo/go/{golang_org => internal}/x/net/http2/hpack/tables.go (100%) rename libgo/go/{golang_org => internal}/x/net/http2/hpack/tables_test.go (100%) rename libgo/go/{golang_org => internal}/x/net/idna/idna.go (99%) rename libgo/go/{golang_org => internal}/x/net/idna/punycode.go (100%) rename libgo/go/{golang_org => internal}/x/net/idna/punycode_test.go (100%) rename libgo/go/{golang_org => internal}/x/net/idna/tables.go (99%) rename libgo/go/{golang_org => internal}/x/net/idna/trie.go (100%) rename libgo/go/{golang_org => internal}/x/net/idna/trieval.go (97%) rename libgo/go/{golang_org => internal}/x/net/internal/nettest/helper_bsd.go (100%) rename libgo/go/{golang_org => internal}/x/net/internal/nettest/helper_nobsd.go (100%) rename libgo/go/{golang_org => internal}/x/net/internal/nettest/helper_posix.go (100%) rename libgo/go/{golang_org => internal}/x/net/internal/nettest/helper_stub.go (95%) rename libgo/go/{golang_org => internal}/x/net/internal/nettest/helper_unix.go (100%) rename libgo/go/{golang_org => internal}/x/net/internal/nettest/helper_windows.go (100%) rename libgo/go/{golang_org => internal}/x/net/internal/nettest/interface.go (100%) rename libgo/go/{golang_org => internal}/x/net/internal/nettest/rlimit.go (100%) rename libgo/go/{golang_org => internal}/x/net/internal/nettest/stack.go (96%) rename libgo/go/{golang_org => internal}/x/net/lif/address.go (100%) rename libgo/go/{golang_org => internal}/x/net/lif/address_test.go (100%) rename libgo/go/{golang_org => internal}/x/net/lif/binary.go (100%) rename libgo/go/{golang_org => internal}/x/net/lif/defs_solaris.go (100%) rename libgo/go/{golang_org => internal}/x/net/lif/lif.go (100%) rename libgo/go/{golang_org => internal}/x/net/lif/link.go (91%) rename libgo/go/{golang_org => internal}/x/net/lif/link_test.go (100%) rename libgo/go/{golang_org => internal}/x/net/lif/sys.go (100%) create mode 100644 libgo/go/internal/x/net/lif/syscall.go rename libgo/go/{golang_org/x/net/lif/zsys_solaris.go => internal/x/net/lif/zsys_solaris_amd64.go} (89%) rename libgo/go/{golang_org => internal}/x/net/nettest/conntest.go (100%) rename libgo/go/{golang_org => internal}/x/net/nettest/conntest_go16.go (100%) rename libgo/go/{golang_org => internal}/x/net/nettest/conntest_go17.go (100%) rename libgo/go/{golang_org => internal}/x/net/nettest/conntest_test.go (97%) rename libgo/go/{golang_org => internal}/x/net/route/address.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/address_darwin_test.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/address_test.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/binary.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/defs_darwin.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/defs_dragonfly.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/defs_freebsd.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/defs_netbsd.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/defs_openbsd.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/interface.go (98%) rename libgo/go/{golang_org => internal}/x/net/route/interface_announce.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/interface_classic.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/interface_freebsd.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/interface_multicast.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/interface_openbsd.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/message.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/message_darwin_test.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/message_freebsd_test.go (95%) rename libgo/go/{golang_org => internal}/x/net/route/message_test.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/route.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/route_classic.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/route_openbsd.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/route_test.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/sys.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/sys_darwin.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/sys_dragonfly.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/sys_freebsd.go (90%) rename libgo/go/{golang_org => internal}/x/net/route/sys_netbsd.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/sys_openbsd.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/syscall.go (83%) create mode 100644 libgo/go/internal/x/net/route/syscall_go1_11_darwin.go create mode 100644 libgo/go/internal/x/net/route/syscall_go1_12_darwin.go rename libgo/go/{golang_org => internal}/x/net/route/zsys_darwin.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/zsys_dragonfly.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/zsys_freebsd_386.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/zsys_freebsd_amd64.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/zsys_freebsd_arm.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/zsys_netbsd.go (100%) rename libgo/go/{golang_org => internal}/x/net/route/zsys_openbsd.go (100%) rename libgo/go/{golang_org => internal}/x/text/secure/bidirule/bidirule.go (99%) rename libgo/go/{golang_org => internal}/x/text/secure/doc.go (85%) rename libgo/go/{golang_org => internal}/x/text/transform/examples_test.go (92%) rename libgo/go/{golang_org => internal}/x/text/transform/transform.go (99%) rename libgo/go/{golang_org => internal}/x/text/unicode/bidi/bidi.go (99%) rename libgo/go/{golang_org => internal}/x/text/unicode/bidi/bracket.go (100%) rename libgo/go/{golang_org => internal}/x/text/unicode/bidi/core.go (100%) rename libgo/go/{golang_org => internal}/x/text/unicode/bidi/example_test.go (99%) rename libgo/go/{golang_org => internal}/x/text/unicode/bidi/prop.go (100%) rename libgo/go/{golang_org => internal}/x/text/unicode/bidi/tables.go (99%) rename libgo/go/{golang_org => internal}/x/text/unicode/bidi/trieval.go (95%) rename libgo/go/{golang_org => internal}/x/text/unicode/doc.go (84%) rename libgo/go/{golang_org => internal}/x/text/unicode/norm/composition.go (100%) rename libgo/go/{golang_org => internal}/x/text/unicode/norm/example_iter_test.go (98%) rename libgo/go/{golang_org => internal}/x/text/unicode/norm/example_test.go (94%) rename libgo/go/{golang_org => internal}/x/text/unicode/norm/forminfo.go (100%) rename libgo/go/{golang_org => internal}/x/text/unicode/norm/input.go (100%) rename libgo/go/{golang_org => internal}/x/text/unicode/norm/iter.go (100%) rename libgo/go/{golang_org => internal}/x/text/unicode/norm/normalize.go (99%) rename libgo/go/{golang_org => internal}/x/text/unicode/norm/readwriter.go (100%) rename libgo/go/{golang_org => internal}/x/text/unicode/norm/tables.go (99%) rename libgo/go/{golang_org => internal}/x/text/unicode/norm/transform.go (98%) rename libgo/go/{golang_org => internal}/x/text/unicode/norm/trie.go (100%) rename libgo/go/{golang_org => internal}/x/text/unicode/norm/triegen.go (100%) create mode 100644 libgo/go/internal/xcoff/ar.go create mode 100644 libgo/go/internal/xcoff/ar_test.go create mode 100644 libgo/go/internal/xcoff/file.go create mode 100644 libgo/go/internal/xcoff/file_test.go create mode 100644 libgo/go/internal/xcoff/testdata/bigar-empty create mode 100644 libgo/go/internal/xcoff/testdata/bigar-ppc64 create mode 100644 libgo/go/internal/xcoff/testdata/gcc-ppc32-aix-dwarf2-exec create mode 100644 libgo/go/internal/xcoff/testdata/gcc-ppc64-aix-dwarf2-exec create mode 100644 libgo/go/internal/xcoff/testdata/hello.c create mode 100644 libgo/go/internal/xcoff/testdata/printbye.c create mode 100644 libgo/go/internal/xcoff/testdata/printhello.c create mode 100644 libgo/go/internal/xcoff/xcoff.go create mode 100644 libgo/go/math/huge_test.go delete mode 100644 libgo/go/math/sincos_386.go create mode 100644 libgo/go/math/trig_reduce.go create mode 100644 libgo/go/net/http/example_filesystem_test.go create mode 100644 libgo/go/net/http/example_handle_test.go create mode 100644 libgo/go/net/http/server_test.go create mode 100644 libgo/go/net/interface_aix.go delete mode 100644 libgo/go/net/testdata/Mark.Twain-Tom.Sawyer.txt create mode 100644 libgo/go/net/unixsock_windows_test.go create mode 100644 libgo/go/os/dir_ios.go delete mode 100644 libgo/go/os/dir_unix.go create mode 100644 libgo/go/os/rawconn.go create mode 100644 libgo/go/os/rawconn_test.go create mode 100644 libgo/go/os/removeall_at.go create mode 100644 libgo/go/os/removeall_noat.go create mode 100644 libgo/go/os/removeall_test.go create mode 100644 libgo/go/os/stat_test.go create mode 100644 libgo/go/os/sys_aix.go create mode 100644 libgo/go/plugin/plugin_test.go create mode 100644 libgo/go/runtime/debug/mod.go create mode 100644 libgo/go/runtime/internal/math/math.go create mode 100644 libgo/go/runtime/internal/math/math_test.go create mode 100644 libgo/go/runtime/os_windows_arm.go create mode 100644 libgo/go/runtime/semasleep_test.go create mode 100644 libgo/go/runtime/sys_darwin_32.go create mode 100644 libgo/go/runtime/sys_darwin_64.go delete mode 100644 libgo/go/runtime/testdata/testprog/gettid.go rename libgo/go/{cmd/vet/testdata/cgo/cgo3.go => runtime/testdata/testprog/syscalls.go} (55%) create mode 100644 libgo/go/runtime/testdata/testprog/syscalls_linux.go rename libgo/go/runtime/testdata/testprog/{gettid_none.go => syscalls_none.go} (68%) delete mode 100644 libgo/go/strings/indexbyte.c delete mode 100644 libgo/go/strings/strings_decl.go create mode 100644 libgo/go/syscall/bpf_darwin.go create mode 100644 libgo/go/syscall/dirent_bsd_test.go create mode 100644 libgo/go/syscall/exec_aix_test.go create mode 100644 libgo/go/syscall/exec_darwin.go create mode 100644 libgo/go/syscall/export_freebsd_test.go create mode 100644 libgo/go/syscall/flock_aix.go create mode 100644 libgo/go/syscall/flock_darwin.go delete mode 100644 libgo/go/syscall/js/callback.go create mode 100644 libgo/go/syscall/js/func.go create mode 100644 libgo/go/syscall/mkasm_darwin.go create mode 100644 libgo/go/syscall/syscall_freebsd_test.go create mode 100644 libgo/go/testdata/Isaac.Newton-Opticks.txt create mode 100644 libgo/go/time/zoneinfo_js.go create mode 100644 libgo/misc/cgo/errors/src/issue26745.go create mode 100644 libgo/misc/cgo/errors/src/issue28069.go create mode 100644 libgo/misc/cgo/errors/src/issue28721.go create mode 100644 libgo/misc/cgo/test/issue27054/egl.h create mode 100644 libgo/misc/cgo/test/issue27054/test27054.go create mode 100644 libgo/misc/cgo/test/issue27340.go create mode 100644 libgo/misc/cgo/test/issue27340/a.go create mode 100644 libgo/misc/cgo/test/issue28545.go create mode 100644 libgo/misc/cgo/test/issue28772.go create mode 100644 libgo/misc/cgo/test/issue28896.go create mode 100644 libgo/misc/cgo/test/issue29383.go create mode 100644 libgo/misc/cgo/test/test27660.go create mode 100644 libgo/misc/cgo/test/twoargs.go create mode 100644 libgo/misc/cgo/testcshared/src/go2c2go/go/shlib.go create mode 100644 libgo/misc/cgo/testcshared/src/go2c2go/m1/c.c create mode 100644 libgo/misc/cgo/testcshared/src/go2c2go/m1/main.go create mode 100644 libgo/misc/cgo/testcshared/src/go2c2go/m2/main.go create mode 100644 libgo/misc/cgo/testplugin/src/checkdwarf/main.go create mode 100644 libgo/misc/cgo/testshared/src/issue25065/a.go diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 99ec5ccfb6b..3c1d270cb5c 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -d16e9181a760796802c067730bb030b92b63fb2c +c76ba3014e42cc6adc3d43709bba28c5ad7a6ba2 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 28b74d507de..1c0de25df48 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-01-18 Ian Lance Taylor + + * go.go-torture/execute/names-1.go: Stop using debug/xcoff, which + is no longer externally visible. + 2019-01-18 Marek Polacek PR c++/86926 diff --git a/gcc/testsuite/go.go-torture/execute/names-1.go b/gcc/testsuite/go.go-torture/execute/names-1.go index bac91945bc7..88399f36cee 100644 --- a/gcc/testsuite/go.go-torture/execute/names-1.go +++ b/gcc/testsuite/go.go-torture/execute/names-1.go @@ -7,9 +7,9 @@ import ( "debug/elf" "debug/macho" "debug/pe" - "debug/xcoff" "fmt" "os" + "runtime" "strings" ) @@ -61,6 +61,12 @@ func Function3(out *bytes.Buffer) { } func main() { + if runtime.GOOS == "aix" { + // Not supported on AIX until there is an externally + // visible version of internal/xcoff. + return + } + var b bytes.Buffer Function1(&b) Function2(&b) @@ -95,10 +101,6 @@ func checkFile(f *os.File) { for _, psym := range pf.Symbols { syms = append(syms, psym.Name) } - } else if xf, err := xcoff.NewFile(f); err == nil { - for _, xsym := range xf.Symbols { - syms = append(syms, xsym.Name) - } } else { fmt.Println("checksyms: could not parse executable") fmt.Println("UNSUPPORTED: checksyms") diff --git a/gotools/ChangeLog b/gotools/ChangeLog index a9273eabcc9..ff5020ac2a1 100644 --- a/gotools/ChangeLog +++ b/gotools/ChangeLog @@ -1,3 +1,12 @@ +2019-01-18 Ian Lance Taylor + + * Makefile.am (go_cmd_vet_files): Update for Go1.12beta2 release. + (GOTOOLS_TEST_TIMEOUT): Increase to 600. + (check-runtime): Export LD_LIBRARY_PATH before computing GOARCH + and GOOS. + (check-vet): Copy golang.org/x/tools into check-vet-dir. + * Makefile.in: Regenerate. + 2018-10-31 Joseph Myers PR bootstrap/82856 diff --git a/gotools/Makefile.am b/gotools/Makefile.am index 55f83f20255..ad0ad24e206 100644 --- a/gotools/Makefile.am +++ b/gotools/Makefile.am @@ -70,31 +70,8 @@ go_cmd_cgo_files = \ $(cmdsrcdir)/cgo/util.go go_cmd_vet_files = \ - $(cmdsrcdir)/vet/asmdecl.go \ - $(cmdsrcdir)/vet/assign.go \ - $(cmdsrcdir)/vet/atomic.go \ - $(cmdsrcdir)/vet/bool.go \ - $(cmdsrcdir)/vet/buildtag.go \ - $(cmdsrcdir)/vet/cgo.go \ - $(cmdsrcdir)/vet/composite.go \ - $(cmdsrcdir)/vet/copylock.go \ - $(cmdsrcdir)/vet/deadcode.go \ - $(cmdsrcdir)/vet/dead.go \ $(cmdsrcdir)/vet/doc.go \ - $(cmdsrcdir)/vet/httpresponse.go \ - $(cmdsrcdir)/vet/lostcancel.go \ - $(cmdsrcdir)/vet/main.go \ - $(cmdsrcdir)/vet/method.go \ - $(cmdsrcdir)/vet/nilfunc.go \ - $(cmdsrcdir)/vet/print.go \ - $(cmdsrcdir)/vet/rangeloop.go \ - $(cmdsrcdir)/vet/shadow.go \ - $(cmdsrcdir)/vet/shift.go \ - $(cmdsrcdir)/vet/structtag.go \ - $(cmdsrcdir)/vet/tests.go \ - $(cmdsrcdir)/vet/types.go \ - $(cmdsrcdir)/vet/unsafeptr.go \ - $(cmdsrcdir)/vet/unused.go + $(cmdsrcdir)/vet/main.go go_cmd_buildid_files = \ $(cmdsrcdir)/buildid/buildid.go \ @@ -163,7 +140,7 @@ uninstall-local: GOTESTFLAGS = # Number of seconds before tests time out. -GOTOOLS_TEST_TIMEOUT = 480 +GOTOOLS_TEST_TIMEOUT = 600 # Run tests using the go tool, and frob the output to look like that # generated by DejaGNU. The main output of this is two files: @@ -256,6 +233,7 @@ check-runtime: go$(EXEEXT) $(noinst_PROGRAMS) check-head check-gccgo check-gcc $(MKDIR_P) check-runtime-dir @abs_libgodir=`cd $(libgodir) && $(PWD_COMMAND)`; \ LD_LIBRARY_PATH=`echo $${abs_libgodir}/.libs:$${LD_LIBRARY_PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; \ + export LD_LIBRARY_PATH; \ GOARCH=`$(abs_builddir)/go$(EXEEXT) env GOARCH`; \ GOOS=`$(abs_builddir)/go$(EXEEXT) env GOOS`; \ files=`$(SHELL) $(libgosrcdir)/../match.sh --goarch=$${GOARCH} --goos=$${GOOS} --srcdir=$(libgosrcdir)/runtime --extrafiles="$(libgodir)/runtime_sysinfo.go $(libgodir)/sigtab.go" --tag=libffi`; \ @@ -299,10 +277,11 @@ check-carchive-test: go$(EXEEXT) $(noinst_PROGRAMS) check-head check-gccgo check # check-vet runs `go test cmd/vet` in our environment. check-vet: go$(EXEEXT) $(noinst_PROGRAMS) check-head check-gccgo check-gcc rm -rf check-vet-dir cmd_vet-testlog - $(MKDIR_P) check-vet-dir/src/cmd/internal + $(MKDIR_P) check-vet-dir/src/cmd/internal check-vet-dir/src/cmd/vendor/golang.org/x cp -r $(cmdsrcdir)/vet check-vet-dir/src/cmd/ cp -r $(cmdsrcdir)/internal/objabi check-vet-dir/src/cmd/internal cp $(libgodir)/objabi.go check-vet-dir/src/cmd/internal/objabi/ + cp -r $(libgosrcdir)/golang.org/x/tools check-vet-dir/src/cmd/vendor/golang.org/x/ @abs_libgodir=`cd $(libgodir) && $(PWD_COMMAND)`; \ abs_checkdir=`cd check-vet-dir && $(PWD_COMMAND)`; \ echo "cd check-vet-dir/src/cmd/vet && $(ECHO_ENV) GOPATH=$${abs_checkdir} $(abs_builddir)/go$(EXEEXT) test -test.short -test.timeout=$(GOTOOLS_TEST_TIMEOUT)s -test.v" > cmd_vet-testlog diff --git a/gotools/Makefile.in b/gotools/Makefile.in index d1db6316c1d..47235df52ae 100644 --- a/gotools/Makefile.in +++ b/gotools/Makefile.in @@ -373,31 +373,8 @@ go_cmd_cgo_files = \ $(cmdsrcdir)/cgo/util.go go_cmd_vet_files = \ - $(cmdsrcdir)/vet/asmdecl.go \ - $(cmdsrcdir)/vet/assign.go \ - $(cmdsrcdir)/vet/atomic.go \ - $(cmdsrcdir)/vet/bool.go \ - $(cmdsrcdir)/vet/buildtag.go \ - $(cmdsrcdir)/vet/cgo.go \ - $(cmdsrcdir)/vet/composite.go \ - $(cmdsrcdir)/vet/copylock.go \ - $(cmdsrcdir)/vet/deadcode.go \ - $(cmdsrcdir)/vet/dead.go \ $(cmdsrcdir)/vet/doc.go \ - $(cmdsrcdir)/vet/httpresponse.go \ - $(cmdsrcdir)/vet/lostcancel.go \ - $(cmdsrcdir)/vet/main.go \ - $(cmdsrcdir)/vet/method.go \ - $(cmdsrcdir)/vet/nilfunc.go \ - $(cmdsrcdir)/vet/print.go \ - $(cmdsrcdir)/vet/rangeloop.go \ - $(cmdsrcdir)/vet/shadow.go \ - $(cmdsrcdir)/vet/shift.go \ - $(cmdsrcdir)/vet/structtag.go \ - $(cmdsrcdir)/vet/tests.go \ - $(cmdsrcdir)/vet/types.go \ - $(cmdsrcdir)/vet/unsafeptr.go \ - $(cmdsrcdir)/vet/unused.go + $(cmdsrcdir)/vet/main.go go_cmd_buildid_files = \ $(cmdsrcdir)/buildid/buildid.go \ @@ -726,8 +703,8 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -@NATIVE_FALSE@install-exec-local: @NATIVE_FALSE@uninstall-local: +@NATIVE_FALSE@install-exec-local: clean: clean-am clean-am: clean-binPROGRAMS clean-generic clean-noinstPROGRAMS \ @@ -927,6 +904,7 @@ mostlyclean-local: @NATIVE_TRUE@ $(MKDIR_P) check-runtime-dir @NATIVE_TRUE@ @abs_libgodir=`cd $(libgodir) && $(PWD_COMMAND)`; \ @NATIVE_TRUE@ LD_LIBRARY_PATH=`echo $${abs_libgodir}/.libs:$${LD_LIBRARY_PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; \ +@NATIVE_TRUE@ export LD_LIBRARY_PATH; \ @NATIVE_TRUE@ GOARCH=`$(abs_builddir)/go$(EXEEXT) env GOARCH`; \ @NATIVE_TRUE@ GOOS=`$(abs_builddir)/go$(EXEEXT) env GOOS`; \ @NATIVE_TRUE@ files=`$(SHELL) $(libgosrcdir)/../match.sh --goarch=$${GOARCH} --goos=$${GOOS} --srcdir=$(libgosrcdir)/runtime --extrafiles="$(libgodir)/runtime_sysinfo.go $(libgodir)/sigtab.go" --tag=libffi`; \ @@ -970,10 +948,11 @@ mostlyclean-local: # check-vet runs `go test cmd/vet` in our environment. @NATIVE_TRUE@check-vet: go$(EXEEXT) $(noinst_PROGRAMS) check-head check-gccgo check-gcc @NATIVE_TRUE@ rm -rf check-vet-dir cmd_vet-testlog -@NATIVE_TRUE@ $(MKDIR_P) check-vet-dir/src/cmd/internal +@NATIVE_TRUE@ $(MKDIR_P) check-vet-dir/src/cmd/internal check-vet-dir/src/cmd/vendor/golang.org/x @NATIVE_TRUE@ cp -r $(cmdsrcdir)/vet check-vet-dir/src/cmd/ @NATIVE_TRUE@ cp -r $(cmdsrcdir)/internal/objabi check-vet-dir/src/cmd/internal @NATIVE_TRUE@ cp $(libgodir)/objabi.go check-vet-dir/src/cmd/internal/objabi/ +@NATIVE_TRUE@ cp -r $(libgosrcdir)/golang.org/x/tools check-vet-dir/src/cmd/vendor/golang.org/x/ @NATIVE_TRUE@ @abs_libgodir=`cd $(libgodir) && $(PWD_COMMAND)`; \ @NATIVE_TRUE@ abs_checkdir=`cd check-vet-dir && $(PWD_COMMAND)`; \ @NATIVE_TRUE@ echo "cd check-vet-dir/src/cmd/vet && $(ECHO_ENV) GOPATH=$${abs_checkdir} $(abs_builddir)/go$(EXEEXT) test -test.short -test.timeout=$(GOTOOLS_TEST_TIMEOUT)s -test.v" > cmd_vet-testlog diff --git a/libgo/MERGE b/libgo/MERGE index b2803e871c5..4674467244f 100644 --- a/libgo/MERGE +++ b/libgo/MERGE @@ -1,4 +1,4 @@ -26957168c4c0cdcc7ca4f0b19d0eb19474d224ac +4b3f04c63b5b1a1bbc4dfd71c34341ea4e935115 The first line of this file holds the git revision number of the last merge done from the master library sources. diff --git a/libgo/Makefile.am b/libgo/Makefile.am index 461adcf867d..2ee4a28a53c 100644 --- a/libgo/Makefile.am +++ b/libgo/Makefile.am @@ -217,8 +217,7 @@ toolexeclibgodebug_DATA = \ debug/gosym.gox \ debug/macho.gox \ debug/pe.gox \ - debug/plan9obj.gox \ - debug/xcoff.gox + debug/plan9obj.gox toolexeclibgoencodingdir = $(toolexeclibgodir)/encoding @@ -394,8 +393,8 @@ toolexeclibgounicode_DATA = \ # internal packages nothing will explicitly depend on them. # Force them to be built. noinst_DATA = \ - golang_org/x/net/internal/nettest.gox \ - golang_org/x/net/nettest.gox \ + internal/x/net/internal/nettest.gox \ + internal/x/net/nettest.gox \ internal/testenv.gox \ internal/trace.gox \ net/internal/socktest.gox \ @@ -536,7 +535,7 @@ cpugen.go: s-cpu; @true s-cpu: Makefile rm -f cpugen.go.tmp echo "package cpu" > cpugen.go.tmp - echo "const CacheLineSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) cachelinesize`" >> cpugen.go.tmp + echo "const CacheLinePadSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) cachelinesize`" >> cpugen.go.tmp $(SHELL) $(srcdir)/mvifdiff.sh cpugen.go.tmp cpugen.go $(STAMP) $@ @@ -554,7 +553,7 @@ s-objabi: Makefile echo 'const defaultGOARCH = runtime.GOARCH' >> objabi.go.tmp echo 'const defaultGO_EXTLINK_ENABLED = ``' >> objabi.go.tmp echo 'const version = `'`cat $(srcdir)/VERSION | sed 1q`' '`$(GOC) --version | sed 1q`'`' >> objabi.go.tmp - echo 'const stackGuardMultiplier = 1' >> objabi.go.tmp + echo 'const stackGuardMultiplierDefault = 1' >> objabi.go.tmp echo 'const goexperiment = ``' >> objabi.go.tmp $(SHELL) $(srcdir)/mvifdiff.sh objabi.go.tmp objabi.go $(STAMP) $@ @@ -715,16 +714,14 @@ PACKAGES = $(shell cat $(srcdir)/libgo-packages.txt) libgo_go_objs = \ $(addsuffix .lo,$(PACKAGES)) \ - bytes/index.lo \ internal/bytealg/bytealg.lo \ reflect/makefunc_ffi_c.lo \ - strings/index.lo \ $(syscall_lib_clone_lo) \ syscall/errno.lo \ syscall/signame.lo \ syscall/wait.lo \ - $(golang_org_x_net_lif_lo) \ - $(golang_org_x_net_route_lo) \ + $(internal_x_net_lif_lo) \ + $(internal_x_net_route_lo) \ log/syslog/syslog_c.lo \ $(os_lib_inotify_lo) \ runtime/internal/atomic_c.lo \ @@ -807,7 +804,7 @@ BUILDDEPS = \ BUILDPACKAGE = \ $(MKDIR_P) $(@D); \ files=`echo $^ | sed -e 's/[^ ]*\.gox//g' -e 's/[^ ]*\.dep//'`; \ - $(LTGOCOMPILE) -I . -c -fgo-pkgpath=`echo $@ | sed -e 's/.lo$$//' -e 's|golang_org|vendor/golang_org|'` $($(subst -,_,$(subst .,_,$(subst /,_,$@)))_GOCFLAGS) -o $@ $$files + $(LTGOCOMPILE) -I . -c -fgo-pkgpath=`echo $@ | sed -e 's/.lo$$//'` $($(subst -,_,$(subst .,_,$(subst /,_,$@)))_GOCFLAGS) -o $@ $$files # How to build a .gox file from a .lo file. # Matching .o file can either be in the same directory as the .lo (non-PIC @@ -990,6 +987,7 @@ extra_check_libs_cmd_go_internal_cache = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_generate = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_get = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_load = $(abs_builddir)/libgotool.a +extra_check_libs_cmd_go_internal_lockedfile = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_imports = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_modconv = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_modfetch = $(abs_builddir)/libgotool.a @@ -1007,13 +1005,7 @@ extra_check_libs_cmd_vet_internal_cfg = $(abs_builddir)/libgotool.a # FIXME: The following C files may as well move to the runtime # directory and be treated like other C files. -# Use C code to speed up {bytes,strings}.IndexByte and friends. -bytes/index.lo: go/bytes/indexbyte.c runtime.inc - @$(MKDIR_P) bytes - $(LTCOMPILE) -c -o $@ $(srcdir)/go/bytes/indexbyte.c -strings/index.lo: go/strings/indexbyte.c runtime.inc - @$(MKDIR_P) strings - $(LTCOMPILE) -c -o $@ $(srcdir)/go/strings/indexbyte.c +# Use C code to speed up internal/bytealg.IndexByte and friends. internal/bytealg/bytealg.lo: go/internal/bytealg/bytealg.c runtime.inc @$(MKDIR_P) internal/bytealg $(LTCOMPILE) -c -o $@ $(srcdir)/go/internal/bytealg/bytealg.c @@ -1070,34 +1062,34 @@ endif if LIBGO_IS_BSD -# Build golang_org/x/net/route only on BSD systems. +# Build internal/x/net/route only on BSD systems. -$(eval $(call PACKAGE_template,golang_org/x/net/route)) +$(eval $(call PACKAGE_template,internal/x/net/route)) -golang_org_x_net_route_lo = \ - golang_org/x/net/route.lo -golang_org_x_net_route_check = \ - golang_org/x/net/route/check +internal_x_net_route_lo = \ + internal/x/net/route.lo +internal_x_net_route_check = \ + internal/x/net/route/check endif if LIBGO_IS_SOLARIS -# Build golang_org/x/net/lif only on Solaris systems. +# Build internal/x/net/lif only on Solaris systems. -$(eval $(call PACKAGE_template,golang_org/x/net/lif)) +$(eval $(call PACKAGE_template,internal/x/net/lif)) -golang_org_x_net_lif_lo = \ - golang_org/x/net/lif.lo -golang_org_x_net_lif_check = \ - golang_org/x/net/lif/check +internal_x_net_lif_lo = \ + internal/x/net/lif.lo +internal_x_net_lif_check = \ + internal_org/x/net/lif/check endif TPACKAGES = $(shell cat $(srcdir)/check-packages.txt) TEST_PACKAGES = $(addsuffix /check,$(TPACKAGES)) \ - $(golang_org_x_net_lif_check) \ - $(golang_org_x_net_route_check) + $(internal_x_net_lif_check) \ + $(internal_x_net_route_check) check: check-tail check-recursive: check-head diff --git a/libgo/Makefile.in b/libgo/Makefile.in index 51704945735..1695dd0faec 100644 --- a/libgo/Makefile.in +++ b/libgo/Makefile.in @@ -215,11 +215,11 @@ am_libgotool_a_OBJECTS = libgotool_a_OBJECTS = $(am_libgotool_a_OBJECTS) LTLIBRARIES = $(toolexeclib_LTLIBRARIES) @LIBGO_IS_LINUX_TRUE@am__DEPENDENCIES_1 = syscall/clone_linux.lo -am__DEPENDENCIES_2 = $(addsuffix .lo,$(PACKAGES)) bytes/index.lo \ +am__DEPENDENCIES_2 = $(addsuffix .lo,$(PACKAGES)) \ internal/bytealg/bytealg.lo reflect/makefunc_ffi_c.lo \ - strings/index.lo $(am__DEPENDENCIES_1) syscall/errno.lo \ - syscall/signame.lo syscall/wait.lo $(golang_org_x_net_lif_lo) \ - $(golang_org_x_net_route_lo) log/syslog/syslog_c.lo \ + $(am__DEPENDENCIES_1) syscall/errno.lo syscall/signame.lo \ + syscall/wait.lo $(internal_x_net_lif_lo) \ + $(internal_x_net_route_lo) log/syslog/syslog_c.lo \ runtime/internal/atomic_c.lo sync/atomic_c.lo \ internal/cpu/cpu_gccgo.lo am__DEPENDENCIES_3 = @@ -696,8 +696,7 @@ toolexeclibgodebug_DATA = \ debug/gosym.gox \ debug/macho.gox \ debug/pe.gox \ - debug/plan9obj.gox \ - debug/xcoff.gox + debug/plan9obj.gox toolexeclibgoencodingdir = $(toolexeclibgodir)/encoding toolexeclibgoencoding_DATA = \ @@ -849,8 +848,8 @@ toolexeclibgounicode_DATA = \ # Some packages are only needed for tests, so unlike the other # internal packages nothing will explicitly depend on them. # Force them to be built. -noinst_DATA = golang_org/x/net/internal/nettest.gox \ - golang_org/x/net/nettest.gox internal/testenv.gox \ +noinst_DATA = internal/x/net/internal/nettest.gox \ + internal/x/net/nettest.gox internal/testenv.gox \ internal/trace.gox net/internal/socktest.gox \ os/signal/internal/pty.gox runtime/pprof/internal/profile.gox \ zdefaultcc.go @@ -917,16 +916,14 @@ SYSINFO_FLAGS = \ PACKAGES = $(shell cat $(srcdir)/libgo-packages.txt) libgo_go_objs = \ $(addsuffix .lo,$(PACKAGES)) \ - bytes/index.lo \ internal/bytealg/bytealg.lo \ reflect/makefunc_ffi_c.lo \ - strings/index.lo \ $(syscall_lib_clone_lo) \ syscall/errno.lo \ syscall/signame.lo \ syscall/wait.lo \ - $(golang_org_x_net_lif_lo) \ - $(golang_org_x_net_route_lo) \ + $(internal_x_net_lif_lo) \ + $(internal_x_net_route_lo) \ log/syslog/syslog_c.lo \ $(os_lib_inotify_lo) \ runtime/internal/atomic_c.lo \ @@ -991,7 +988,7 @@ BUILDDEPS = \ BUILDPACKAGE = \ $(MKDIR_P) $(@D); \ files=`echo $^ | sed -e 's/[^ ]*\.gox//g' -e 's/[^ ]*\.dep//'`; \ - $(LTGOCOMPILE) -I . -c -fgo-pkgpath=`echo $@ | sed -e 's/.lo$$//' -e 's|golang_org|vendor/golang_org|'` $($(subst -,_,$(subst .,_,$(subst /,_,$@)))_GOCFLAGS) -o $@ $$files + $(LTGOCOMPILE) -I . -c -fgo-pkgpath=`echo $@ | sed -e 's/.lo$$//'` $($(subst -,_,$(subst .,_,$(subst /,_,$@)))_GOCFLAGS) -o $@ $$files # How to build a .gox file from a .lo file. @@ -1105,6 +1102,7 @@ extra_check_libs_cmd_go_internal_cache = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_generate = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_get = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_load = $(abs_builddir)/libgotool.a +extra_check_libs_cmd_go_internal_lockedfile = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_imports = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_modconv = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_modfetch = $(abs_builddir)/libgotool.a @@ -1123,22 +1121,22 @@ extra_check_libs_cmd_vet_internal_cfg = $(abs_builddir)/libgotool.a # Use a build tag, based on a configure check, to cope. @HAVE_STAT_TIMESPEC_TRUE@@LIBGO_IS_SOLARIS_TRUE@matchargs_os = --tag=solaristag @LIBGO_IS_SOLARIS_FALSE@matchargs_os = -@LIBGO_IS_BSD_TRUE@golang_org_x_net_route_lo = \ -@LIBGO_IS_BSD_TRUE@ golang_org/x/net/route.lo +@LIBGO_IS_BSD_TRUE@internal_x_net_route_lo = \ +@LIBGO_IS_BSD_TRUE@ internal/x/net/route.lo -@LIBGO_IS_BSD_TRUE@golang_org_x_net_route_check = \ -@LIBGO_IS_BSD_TRUE@ golang_org/x/net/route/check +@LIBGO_IS_BSD_TRUE@internal_x_net_route_check = \ +@LIBGO_IS_BSD_TRUE@ internal/x/net/route/check -@LIBGO_IS_SOLARIS_TRUE@golang_org_x_net_lif_lo = \ -@LIBGO_IS_SOLARIS_TRUE@ golang_org/x/net/lif.lo +@LIBGO_IS_SOLARIS_TRUE@internal_x_net_lif_lo = \ +@LIBGO_IS_SOLARIS_TRUE@ internal/x/net/lif.lo -@LIBGO_IS_SOLARIS_TRUE@golang_org_x_net_lif_check = \ -@LIBGO_IS_SOLARIS_TRUE@ golang_org/x/net/lif/check +@LIBGO_IS_SOLARIS_TRUE@internal_x_net_lif_check = \ +@LIBGO_IS_SOLARIS_TRUE@ internal_org/x/net/lif/check TPACKAGES = $(shell cat $(srcdir)/check-packages.txt) TEST_PACKAGES = $(addsuffix /check,$(TPACKAGES)) \ - $(golang_org_x_net_lif_check) \ - $(golang_org_x_net_route_check) + $(internal_x_net_lif_check) \ + $(internal_x_net_route_check) MOSTLYCLEANFILES = \ s-runtime_sysinfo s-sigtab s-runtime-inc s-zstdpkglist \ @@ -2635,7 +2633,7 @@ cpugen.go: s-cpu; @true s-cpu: Makefile rm -f cpugen.go.tmp echo "package cpu" > cpugen.go.tmp - echo "const CacheLineSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) cachelinesize`" >> cpugen.go.tmp + echo "const CacheLinePadSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) cachelinesize`" >> cpugen.go.tmp $(SHELL) $(srcdir)/mvifdiff.sh cpugen.go.tmp cpugen.go $(STAMP) $@ @@ -2653,7 +2651,7 @@ s-objabi: Makefile echo 'const defaultGOARCH = runtime.GOARCH' >> objabi.go.tmp echo 'const defaultGO_EXTLINK_ENABLED = ``' >> objabi.go.tmp echo 'const version = `'`cat $(srcdir)/VERSION | sed 1q`' '`$(GOC) --version | sed 1q`'`' >> objabi.go.tmp - echo 'const stackGuardMultiplier = 1' >> objabi.go.tmp + echo 'const stackGuardMultiplierDefault = 1' >> objabi.go.tmp echo 'const goexperiment = ``' >> objabi.go.tmp $(SHELL) $(srcdir)/mvifdiff.sh objabi.go.tmp objabi.go $(STAMP) $@ @@ -2846,13 +2844,7 @@ cmd/go/internal/cfg.lo.dep: $(extra_go_files_cmd_go_internal_cfg) # FIXME: The following C files may as well move to the runtime # directory and be treated like other C files. -# Use C code to speed up {bytes,strings}.IndexByte and friends. -bytes/index.lo: go/bytes/indexbyte.c runtime.inc - @$(MKDIR_P) bytes - $(LTCOMPILE) -c -o $@ $(srcdir)/go/bytes/indexbyte.c -strings/index.lo: go/strings/indexbyte.c runtime.inc - @$(MKDIR_P) strings - $(LTCOMPILE) -c -o $@ $(srcdir)/go/strings/indexbyte.c +# Use C code to speed up internal/bytealg.IndexByte and friends. internal/bytealg/bytealg.lo: go/internal/bytealg/bytealg.c runtime.inc @$(MKDIR_P) internal/bytealg $(LTCOMPILE) -c -o $@ $(srcdir)/go/internal/bytealg/bytealg.c @@ -2895,13 +2887,13 @@ internal/cpu/cpu_gccgo.lo: go/internal/cpu/cpu_gccgo.c runtime.inc @$(MKDIR_P) internal/cpu $(LTCOMPILE) -c -o $@ $(srcdir)/go/internal/cpu/cpu_gccgo.c -# Build golang_org/x/net/route only on BSD systems. +# Build internal/x/net/route only on BSD systems. -@LIBGO_IS_BSD_TRUE@$(eval $(call PACKAGE_template,golang_org/x/net/route)) +@LIBGO_IS_BSD_TRUE@$(eval $(call PACKAGE_template,internal/x/net/route)) -# Build golang_org/x/net/lif only on Solaris systems. +# Build internal/x/net/lif only on Solaris systems. -@LIBGO_IS_SOLARIS_TRUE@$(eval $(call PACKAGE_template,golang_org/x/net/lif)) +@LIBGO_IS_SOLARIS_TRUE@$(eval $(call PACKAGE_template,internal/x/net/lif)) check: check-tail check-recursive: check-head diff --git a/libgo/VERSION b/libgo/VERSION index 0ff4ff61d19..b23185da1d3 100644 --- a/libgo/VERSION +++ b/libgo/VERSION @@ -1 +1 @@ -go1.11.1 +go1.12beta2 diff --git a/libgo/check-packages.txt b/libgo/check-packages.txt index 6c307d30085..298f9e06261 100644 --- a/libgo/check-packages.txt +++ b/libgo/check-packages.txt @@ -8,6 +8,8 @@ cmd/go/internal/generate cmd/go/internal/get cmd/go/internal/imports cmd/go/internal/load +cmd/go/internal/lockedfile +cmd/go/internal/lockedfile/internal/filelock cmd/go/internal/modconv cmd/go/internal/modfetch cmd/go/internal/modfetch/codehost @@ -25,7 +27,6 @@ cmd/internal/buildid cmd/internal/edit cmd/internal/objabi cmd/internal/test2json -cmd/vet/internal/cfg compress/bzip2 compress/flate compress/gzip @@ -61,7 +62,6 @@ debug/elf debug/macho debug/pe debug/plan9obj -debug/xcoff encoding/ascii85 encoding/asn1 encoding/base32 @@ -91,19 +91,6 @@ go/printer go/scanner go/token go/types -golang_org/x/crypto/internal/chacha20 -golang_org/x/crypto/chacha20poly1305 -golang_org/x/crypto/chacha20poly1305/internal/chacha20 -golang_org/x/crypto/cryptobyte -golang_org/x/crypto/curve25519 -golang_org/x/crypto/poly1305 -golang_org/x/net/dns/dnsmessage -golang_org/x/net/http/httpguts -golang_org/x/net/http/httpproxy -golang_org/x/net/http2/hpack -golang_org/x/net/idna -golang_org/x/net/lex/httplex -golang_org/x/net/proxy hash hash/adler32 hash/crc32 @@ -118,9 +105,22 @@ image/jpeg image/png index/suffixarray internal/cpu +internal/fmtsort internal/poll internal/singleflight internal/trace +internal/x/crypto/chacha20poly1305 +internal/x/crypto/cryptobyte +internal/x/crypto/curve25519 +internal/x/crypto/hkdf +internal/x/crypto/internal/chacha20 +internal/x/crypto/poly1305 +internal/x/net/dns/dnsmessage +internal/x/net/http/httpguts +internal/x/net/http/httpproxy +internal/x/net/http2/hpack +internal/x/net/idna +internal/xcoff io io/ioutil log @@ -162,6 +162,7 @@ regexp/syntax runtime runtime/debug runtime/internal/atomic +runtime/internal/math runtime/internal/sys runtime/pprof runtime/pprof/internal/profile diff --git a/libgo/configure b/libgo/configure index 50de71759a4..4f6840099c4 100755 --- a/libgo/configure +++ b/libgo/configure @@ -2532,7 +2532,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers config.h" -libtool_VERSION=13:0:0 +libtool_VERSION=14:0:0 # Default to --enable-multilib @@ -13744,7 +13744,7 @@ go_include="-include" # All known GOOS values. This is the union of all operating systems # supported by the gofrontend and all operating systems supported by # the gc toolchain. -ALLGOOS="aix android darwin dragonfly freebsd irix linux netbsd openbsd plan9 rtems solaris windows" +ALLGOOS="aix android darwin dragonfly freebsd hurd irix js linux netbsd openbsd plan9 rtems solaris windows" is_darwin=no is_freebsd=no diff --git a/libgo/configure.ac b/libgo/configure.ac index 180b4f434e2..2b7e1910753 100644 --- a/libgo/configure.ac +++ b/libgo/configure.ac @@ -10,7 +10,7 @@ AC_INIT(package-unused, version-unused,, libgo) AC_CONFIG_SRCDIR(Makefile.am) AC_CONFIG_HEADER(config.h) -libtool_VERSION=13:0:0 +libtool_VERSION=14:0:0 AC_SUBST(libtool_VERSION) AM_ENABLE_MULTILIB(, ..) @@ -153,7 +153,7 @@ AC_SUBST(go_include) # All known GOOS values. This is the union of all operating systems # supported by the gofrontend and all operating systems supported by # the gc toolchain. -ALLGOOS="aix android darwin dragonfly freebsd irix linux netbsd openbsd plan9 rtems solaris windows" +ALLGOOS="aix android darwin dragonfly freebsd hurd irix js linux netbsd openbsd plan9 rtems solaris windows" is_darwin=no is_freebsd=no diff --git a/libgo/go/archive/tar/format.go b/libgo/go/archive/tar/format.go index 1f89d0c59a1..cfe24a5e1d3 100644 --- a/libgo/go/archive/tar/format.go +++ b/libgo/go/archive/tar/format.go @@ -160,7 +160,7 @@ func (b *block) V7() *headerV7 { return (*headerV7)(b) } func (b *block) GNU() *headerGNU { return (*headerGNU)(b) } func (b *block) STAR() *headerSTAR { return (*headerSTAR)(b) } func (b *block) USTAR() *headerUSTAR { return (*headerUSTAR)(b) } -func (b *block) Sparse() sparseArray { return (sparseArray)(b[:]) } +func (b *block) Sparse() sparseArray { return sparseArray(b[:]) } // GetFormat checks that the block is a valid tar header based on the checksum. // It then attempts to guess the specific format based on magic values. @@ -263,7 +263,7 @@ func (h *headerGNU) DevMajor() []byte { return h[329:][:8] } func (h *headerGNU) DevMinor() []byte { return h[337:][:8] } func (h *headerGNU) AccessTime() []byte { return h[345:][:12] } func (h *headerGNU) ChangeTime() []byte { return h[357:][:12] } -func (h *headerGNU) Sparse() sparseArray { return (sparseArray)(h[386:][:24*4+1]) } +func (h *headerGNU) Sparse() sparseArray { return sparseArray(h[386:][:24*4+1]) } func (h *headerGNU) RealSize() []byte { return h[483:][:12] } type headerSTAR [blockSize]byte @@ -293,7 +293,7 @@ func (h *headerUSTAR) Prefix() []byte { return h[345:][:155] } type sparseArray []byte -func (s sparseArray) Entry(i int) sparseElem { return (sparseElem)(s[i*24:]) } +func (s sparseArray) Entry(i int) sparseElem { return sparseElem(s[i*24:]) } func (s sparseArray) IsExtended() []byte { return s[24*s.MaxEntries():][:1] } func (s sparseArray) MaxEntries() int { return len(s) / 24 } diff --git a/libgo/go/archive/tar/stat_actime1.go b/libgo/go/archive/tar/stat_actime1.go index 1bdd1c9dcb2..cf9cc79c591 100644 --- a/libgo/go/archive/tar/stat_actime1.go +++ b/libgo/go/archive/tar/stat_actime1.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix linux dragonfly openbsd solaris +// +build linux dragonfly openbsd solaris package tar diff --git a/libgo/go/archive/zip/reader.go b/libgo/go/archive/zip/reader.go index 2444106ba69..2260b398c34 100644 --- a/libgo/go/archive/zip/reader.go +++ b/libgo/go/archive/zip/reader.go @@ -69,6 +69,9 @@ func OpenReader(name string) (*ReadCloser, error) { // NewReader returns a new Reader reading from r, which is assumed to // have the given size in bytes. func NewReader(r io.ReaderAt, size int64) (*Reader, error) { + if size < 0 { + return nil, errors.New("zip: size cannot be negative") + } zr := new(Reader) if err := zr.init(r, size); err != nil { return nil, err diff --git a/libgo/go/archive/zip/reader_test.go b/libgo/go/archive/zip/reader_test.go index 1e58b26b6e9..6b3f2f33bb4 100644 --- a/libgo/go/archive/zip/reader_test.go +++ b/libgo/go/archive/zip/reader_test.go @@ -658,6 +658,12 @@ func TestInvalidFiles(t *testing.T) { if err != ErrFormat { t.Errorf("sigs: error=%v, want %v", err, ErrFormat) } + + // negative size + _, err = NewReader(bytes.NewReader([]byte("foobar")), -1) + if err == nil { + t.Errorf("archive/zip.NewReader: expected error when negative size is passed") + } } func messWith(fileName string, corrupter func(b []byte)) (r io.ReaderAt, size int64) { diff --git a/libgo/go/archive/zip/struct.go b/libgo/go/archive/zip/struct.go index c90151d9d44..bd637d185b7 100644 --- a/libgo/go/archive/zip/struct.go +++ b/libgo/go/archive/zip/struct.go @@ -303,8 +303,8 @@ func (h *FileHeader) SetMode(mode os.FileMode) { } // isZip64 reports whether the file size exceeds the 32 bit limit -func (fh *FileHeader) isZip64() bool { - return fh.CompressedSize64 >= uint32max || fh.UncompressedSize64 >= uint32max +func (h *FileHeader) isZip64() bool { + return h.CompressedSize64 >= uint32max || h.UncompressedSize64 >= uint32max } func msdosModeToFileMode(m uint32) (mode os.FileMode) { diff --git a/libgo/go/archive/zip/writer.go b/libgo/go/archive/zip/writer.go index 5f0c0a1a555..cdc534eaf01 100644 --- a/libgo/go/archive/zip/writer.go +++ b/libgo/go/archive/zip/writer.go @@ -178,7 +178,7 @@ func (w *Writer) Close() error { return err } - // store max values in the regular end record to signal that + // store max values in the regular end record to signal // that the zip64 values should be used instead records = uint16max size = uint32max diff --git a/libgo/go/archive/zip/zip_test.go b/libgo/go/archive/zip/zip_test.go index 50218a2bbd7..3d5c759851a 100644 --- a/libgo/go/archive/zip/zip_test.go +++ b/libgo/go/archive/zip/zip_test.go @@ -159,7 +159,7 @@ func (r *rleBuffer) Write(p []byte) (n int, err error) { return len(p), nil } -func min(x, y int) int { +func min(x, y int64) int64 { if x < y { return x } @@ -190,7 +190,7 @@ func (r *rleBuffer) ReadAt(p []byte, off int64) (n int, err error) { if len(parts) > 0 { skipBytes := off - parts[0].off for _, part := range parts { - repeat := min(int(part.n-skipBytes), len(p)-n) + repeat := int(min(part.n-skipBytes, int64(len(p)-n))) memset(p[n:n+repeat], part.b) n += repeat if n == len(p) { diff --git a/libgo/go/bufio/bufio.go b/libgo/go/bufio/bufio.go index 72545a75095..0125d729d1b 100644 --- a/libgo/go/bufio/bufio.go +++ b/libgo/go/bufio/bufio.go @@ -33,8 +33,8 @@ type Reader struct { rd io.Reader // reader provided by the client r, w int // buf read and write positions err error - lastByte int - lastRuneSize int + lastByte int // last byte read for UnreadByte; -1 means invalid + lastRuneSize int // size of last rune read for UnreadRune; -1 means invalid } const minReadBufferSize = 16 @@ -63,7 +63,7 @@ func NewReader(rd io.Reader) *Reader { } // Size returns the size of the underlying buffer in bytes. -func (r *Reader) Size() int { return len(r.buf) } +func (b *Reader) Size() int { return len(b.buf) } // Reset discards any buffered data, resets all state, and switches // the buffered reader to read from r. @@ -123,11 +123,17 @@ func (b *Reader) readErr() error { // being valid at the next read call. If Peek returns fewer than n bytes, it // also returns an error explaining why the read is short. The error is // ErrBufferFull if n is larger than b's buffer size. +// +// Calling Peek prevents a UnreadByte or UnreadRune call from succeeding +// until the next read operation. func (b *Reader) Peek(n int) ([]byte, error) { if n < 0 { return nil, ErrNegativeCount } + b.lastByte = -1 + b.lastRuneSize = -1 + for b.w-b.r < n && b.w-b.r < len(b.buf) && b.err == nil { b.fill() // b.w-b.r < len(b.buf) => buffer is not full } @@ -186,6 +192,7 @@ func (b *Reader) Discard(n int) (discarded int, err error) { // It returns the number of bytes read into p. // The bytes are taken from at most one Read on the underlying Reader, // hence n may be less than len(p). +// To read exactly len(p) bytes, use io.ReadFull(b, p). // At EOF, the count will be zero and err will be io.EOF. func (b *Reader) Read(p []byte) (n int, err error) { n = len(p) @@ -248,6 +255,10 @@ func (b *Reader) ReadByte() (byte, error) { } // UnreadByte unreads the last byte. Only the most recently read byte can be unread. +// +// UnreadByte returns an error if the most recent method called on the +// Reader was not a read operation. Notably, Peek is not considered a +// read operation. func (b *Reader) UnreadByte() error { if b.lastByte < 0 || b.r == 0 && b.w > 0 { return ErrInvalidUnreadByte @@ -286,8 +297,8 @@ func (b *Reader) ReadRune() (r rune, size int, err error) { return r, size, nil } -// UnreadRune unreads the last rune. If the most recent read operation on -// the buffer was not a ReadRune, UnreadRune returns an error. (In this +// UnreadRune unreads the last rune. If the most recent method called on +// the Reader was not a ReadRune, UnreadRune returns an error. (In this // regard it is stricter than UnreadByte, which will unread the last byte // from any read operation.) func (b *Reader) UnreadRune() error { @@ -314,9 +325,11 @@ func (b *Reader) Buffered() int { return b.w - b.r } // ReadBytes or ReadString instead. // ReadSlice returns err != nil if and only if line does not end in delim. func (b *Reader) ReadSlice(delim byte) (line []byte, err error) { + s := 0 // search start index for { // Search buffer. - if i := bytes.IndexByte(b.buf[b.r:b.w], delim); i >= 0 { + if i := bytes.IndexByte(b.buf[b.r+s:b.w], delim); i >= 0 { + i += s line = b.buf[b.r : b.r+i+1] b.r += i + 1 break @@ -338,6 +351,8 @@ func (b *Reader) ReadSlice(delim byte) (line []byte, err error) { break } + s = b.w - b.r // do not rescan area we scanned before + b.fill() // buffer is not full } diff --git a/libgo/go/bufio/bufio_test.go b/libgo/go/bufio/bufio_test.go index c829d2b0648..f7a0682e703 100644 --- a/libgo/go/bufio/bufio_test.go +++ b/libgo/go/bufio/bufio_test.go @@ -285,6 +285,24 @@ func TestUnreadRune(t *testing.T) { } } +func TestNoUnreadRuneAfterPeek(t *testing.T) { + br := NewReader(strings.NewReader("example")) + br.ReadRune() + br.Peek(1) + if err := br.UnreadRune(); err == nil { + t.Error("UnreadRune didn't fail after Peek") + } +} + +func TestNoUnreadByteAfterPeek(t *testing.T) { + br := NewReader(strings.NewReader("example")) + br.ReadByte() + br.Peek(1) + if err := br.UnreadByte(); err == nil { + t.Error("UnreadByte didn't fail after Peek") + } +} + func TestUnreadByte(t *testing.T) { segments := []string{"Hello, ", "world"} r := NewReader(&StringReader{data: segments}) @@ -550,7 +568,7 @@ func TestWriter(t *testing.T) { t.Errorf("%s: %d bytes written", context, len(written)) } for l := 0; l < len(written); l++ { - if written[i] != data[i] { + if written[l] != data[l] { t.Errorf("wrong bytes written") t.Errorf("want=%q", data[0:len(written)]) t.Errorf("have=%q", written) diff --git a/libgo/go/builtin/builtin.go b/libgo/go/builtin/builtin.go index 4578c855a9e..c78fe09ea66 100644 --- a/libgo/go/builtin/builtin.go +++ b/libgo/go/builtin/builtin.go @@ -152,6 +152,9 @@ func delete(m map[Type]Type1, key Type) // String: the number of bytes in v. // Channel: the number of elements queued (unread) in the channel buffer; // if v is nil, len(v) is zero. +// For some arguments, such as a string literal or a simple array expression, the +// result can be a constant. See the Go language specification's "Length and +// capacity" section for details. func len(v Type) int // The cap built-in function returns the capacity of v, according to its type: @@ -161,6 +164,9 @@ func len(v Type) int // if v is nil, cap(v) is zero. // Channel: the channel buffer capacity, in units of elements; // if v is nil, cap(v) is zero. +// For some arguments, such as a simple array expression, the result can be a +// constant. See the Go language specification's "Length and capacity" section for +// details. func cap(v Type) int // The make built-in function allocates and initializes an object of type diff --git a/libgo/go/bytes/buffer.go b/libgo/go/bytes/buffer.go index a2eca2ed129..aff2db5084f 100644 --- a/libgo/go/bytes/buffer.go +++ b/libgo/go/bytes/buffer.go @@ -12,13 +12,15 @@ import ( "unicode/utf8" ) +// smallBufferSize is an initial allocation minimal capacity. +const smallBufferSize = 64 + // A Buffer is a variable-sized buffer of bytes with Read and Write methods. // The zero value for Buffer is an empty buffer ready to use. type Buffer struct { - buf []byte // contents are the bytes buf[off : len(buf)] - off int // read at &buf[off], write at &buf[len(buf)] - bootstrap [64]byte // memory to hold first slice; helps small buffers avoid allocation. - lastRead readOp // last read operation, so that Unread* can work correctly. + buf []byte // contents are the bytes buf[off : len(buf)] + off int // read at &buf[off], write at &buf[len(buf)] + lastRead readOp // last read operation, so that Unread* can work correctly. // FIXME: it would be advisable to align Buffer to cachelines to avoid false // sharing. @@ -66,7 +68,7 @@ func (b *Buffer) String() string { return string(b.buf[b.off:]) } -// empty returns whether the unread portion of the buffer is empty. +// empty reports whether the unread portion of the buffer is empty. func (b *Buffer) empty() bool { return len(b.buf) <= b.off } // Len returns the number of bytes of the unread portion of the buffer; @@ -125,9 +127,8 @@ func (b *Buffer) grow(n int) int { if i, ok := b.tryGrowByReslice(n); ok { return i } - // Check if we can make use of bootstrap array. - if b.buf == nil && n <= len(b.bootstrap) { - b.buf = b.bootstrap[:n] + if b.buf == nil && n <= smallBufferSize { + b.buf = make([]byte, n, smallBufferSize) return 0 } c := cap(b.buf) @@ -441,9 +442,9 @@ func (b *Buffer) ReadString(delim byte) (line string, err error) { // NewBuffer creates and initializes a new Buffer using buf as its // initial contents. The new Buffer takes ownership of buf, and the // caller should not use buf after this call. NewBuffer is intended to -// prepare a Buffer to read existing data. It can also be used to size -// the internal buffer for writing. To do that, buf should have the -// desired capacity but a length of zero. +// prepare a Buffer to read existing data. It can also be used to set +// the initial size of the internal buffer for writing. To do that, +// buf should have the desired capacity but a length of zero. // // In most cases, new(Buffer) (or just declaring a Buffer variable) is // sufficient to initialize a Buffer. diff --git a/libgo/go/bytes/buffer_test.go b/libgo/go/bytes/buffer_test.go index acbe5ca0c49..6e9d6952a51 100644 --- a/libgo/go/bytes/buffer_test.go +++ b/libgo/go/bytes/buffer_test.go @@ -293,7 +293,7 @@ func TestReadFromPanicReader(t *testing.T) { } check(t, "TestReadFromPanicReader (1)", &buf, "") - // Confirm that when Reader panics, the emtpy buffer remains empty + // Confirm that when Reader panics, the empty buffer remains empty var buf2 Buffer defer func() { recover() diff --git a/libgo/go/bytes/bytes.go b/libgo/go/bytes/bytes.go index 437a6e12df8..daf4a32f26f 100644 --- a/libgo/go/bytes/bytes.go +++ b/libgo/go/bytes/bytes.go @@ -12,6 +12,13 @@ import ( "unicode/utf8" ) +// Equal returns a boolean reporting whether a and b +// are the same length and contain the same bytes. +// A nil argument is equivalent to an empty slice. +func Equal(a, b []byte) bool { + return bytealg.Equal(a, b) +} + func equalPortable(a, b []byte) bool { if len(a) != len(b) { return false @@ -24,6 +31,13 @@ func equalPortable(a, b []byte) bool { return true } +// Compare returns an integer comparing two byte slices lexicographically. +// The result will be 0 if a==b, -1 if a < b, and +1 if a > b. +// A nil argument is equivalent to an empty slice. +func Compare(a, b []byte) int { + return bytealg.Compare(a, b) +} + // explode splits s into a slice of UTF-8 sequences, one per Unicode code point (still slices of bytes), // up to a maximum of n byte slices. Invalid UTF-8 sequences are chopped into individual bytes. func explode(s []byte, n int) [][]byte { @@ -83,6 +97,11 @@ func ContainsRune(b []byte, r rune) bool { return IndexRune(b, r) >= 0 } +// IndexByte returns the index of the first instance of c in b, or -1 if c is not present in b. +func IndexByte(b []byte, c byte) int { + return bytealg.IndexByte(b, c) +} + func indexBytePortable(s []byte, c byte) int { for i, b := range s { if b == c { @@ -489,19 +508,19 @@ func ToTitle(s []byte) []byte { return Map(unicode.ToTitle, s) } // ToUpperSpecial treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their // upper case, giving priority to the special casing rules. func ToUpperSpecial(c unicode.SpecialCase, s []byte) []byte { - return Map(func(r rune) rune { return c.ToUpper(r) }, s) + return Map(c.ToUpper, s) } // ToLowerSpecial treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their // lower case, giving priority to the special casing rules. func ToLowerSpecial(c unicode.SpecialCase, s []byte) []byte { - return Map(func(r rune) rune { return c.ToLower(r) }, s) + return Map(c.ToLower, s) } // ToTitleSpecial treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their // title case, giving priority to the special casing rules. func ToTitleSpecial(c unicode.SpecialCase, s []byte) []byte { - return Map(func(r rune) rune { return c.ToTitle(r) }, s) + return Map(c.ToTitle, s) } // isSeparator reports whether the rune could mark a word boundary. @@ -774,6 +793,15 @@ func Replace(s, old, new []byte, n int) []byte { return t[0:w] } +// ReplaceAll returns a copy of the slice s with all +// non-overlapping instances of old replaced by new. +// If old is empty, it matches at the beginning of the slice +// and after each UTF-8 sequence, yielding up to k+1 replacements +// for a k-rune slice. +func ReplaceAll(s, old, new []byte) []byte { + return Replace(s, old, new, -1) +} + // EqualFold reports whether s and t, interpreted as UTF-8 strings, // are equal under Unicode case-folding. func EqualFold(s, t []byte) bool { @@ -849,21 +877,22 @@ func Index(s, sep []byte) int { if len(s) <= bytealg.MaxBruteForce { return bytealg.Index(s, sep) } - c := sep[0] + c0 := sep[0] + c1 := sep[1] i := 0 - t := s[:len(s)-n+1] + t := len(s) - n + 1 fails := 0 - for i < len(t) { - if t[i] != c { + for i < t { + if s[i] != c0 { // IndexByte is faster than bytealg.Index, so use it as long as // we're not getting lots of false positives. - o := IndexByte(t[i:], c) + o := IndexByte(s[i:t], c0) if o < 0 { return -1 } i += o } - if Equal(s[i:i+n], sep) { + if s[i+1] == c1 && Equal(s[i:i+n], sep) { return i } fails++ @@ -879,24 +908,25 @@ func Index(s, sep []byte) int { } return -1 } - c := sep[0] + c0 := sep[0] + c1 := sep[1] i := 0 fails := 0 - t := s[:len(s)-n+1] - for i < len(t) { - if t[i] != c { - o := IndexByte(t[i:], c) + t := len(s) - n + 1 + for i < t { + if s[i] != c0 { + o := IndexByte(s[i:t], c0) if o < 0 { break } i += o } - if Equal(s[i:i+n], sep) { + if s[i+1] == c1 && Equal(s[i:i+n], sep) { return i } i++ fails++ - if fails >= 4+i>>4 && i < len(t) { + if fails >= 4+i>>4 && i < t { // Give up on IndexByte, it isn't skipping ahead // far enough to be better than Rabin-Karp. // Experiments (using IndexPeriodic) suggest diff --git a/libgo/go/bytes/bytes_decl.go b/libgo/go/bytes/bytes_decl.go deleted file mode 100644 index af0f8b179fd..00000000000 --- a/libgo/go/bytes/bytes_decl.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package bytes - -//go:noescape - -// IndexByte returns the index of the first instance of c in b, or -1 if c is not present in b. -func IndexByte(b []byte, c byte) int // in internal/bytealg - -//go:noescape - -// Equal returns a boolean reporting whether a and b -// are the same length and contain the same bytes. -// A nil argument is equivalent to an empty slice. -func Equal(a, b []byte) bool // in internal/bytealg - -//go:noescape - -// Compare returns an integer comparing two byte slices lexicographically. -// The result will be 0 if a==b, -1 if a < b, and +1 if a > b. -// A nil argument is equivalent to an empty slice. -func Compare(a, b []byte) int // in internal/bytealg diff --git a/libgo/go/bytes/bytes_test.go b/libgo/go/bytes/bytes_test.go index 11c5ef9ab80..ec4ecf31032 100644 --- a/libgo/go/bytes/bytes_test.go +++ b/libgo/go/bytes/bytes_test.go @@ -1367,6 +1367,12 @@ func TestReplace(t *testing.T) { if cap(in) == cap(out) && &in[:1][0] == &out[:1][0] { t.Errorf("Replace(%q, %q, %q, %d) didn't copy", tt.in, tt.old, tt.new, tt.n) } + if tt.n == -1 { + out := ReplaceAll(in, []byte(tt.old), []byte(tt.new)) + if s := string(out); s != tt.out { + t.Errorf("ReplaceAll(%q, %q, %q) = %q, want %q", tt.in, tt.old, tt.new, s, tt.out) + } + } } } diff --git a/libgo/go/bytes/compare_test.go b/libgo/go/bytes/compare_test.go index 3e33c27c9c9..a321f2e0861 100644 --- a/libgo/go/bytes/compare_test.go +++ b/libgo/go/bytes/compare_test.go @@ -41,9 +41,16 @@ var compareTests = []struct { func TestCompare(t *testing.T) { for _, tt := range compareTests { - cmp := Compare(tt.a, tt.b) - if cmp != tt.i { - t.Errorf(`Compare(%q, %q) = %v`, tt.a, tt.b, cmp) + numShifts := 16 + buffer := make([]byte, len(tt.b)+numShifts) + // vary the input alignment of tt.b + for offset := 0; offset <= numShifts; offset++ { + shiftedB := buffer[offset : len(tt.b)+offset] + copy(shiftedB, tt.b) + cmp := Compare(tt.a, shiftedB) + if cmp != tt.i { + t.Errorf(`Compare(%q, %q), offset %d = %v; want %v`, tt.a, tt.b, offset, cmp, tt.i) + } } } } diff --git a/libgo/go/bytes/example_test.go b/libgo/go/bytes/example_test.go index 5b7a46058f5..6d328378fab 100644 --- a/libgo/go/bytes/example_test.go +++ b/libgo/go/bytes/example_test.go @@ -39,6 +39,14 @@ func ExampleBuffer_Grow() { // Output: "64 bytes or fewer" } +func ExampleBuffer_Len() { + var b bytes.Buffer + b.Grow(64) + b.Write([]byte("abcde")) + fmt.Printf("%d", b.Len()) + // Output: 5 +} + func ExampleCompare() { // Interpret Compare's result by comparing it to zero. var a, b []byte @@ -290,6 +298,12 @@ func ExampleReplace() { // moo moo moo } +func ExampleReplaceAll() { + fmt.Printf("%s\n", bytes.ReplaceAll([]byte("oink oink oink"), []byte("oink"), []byte("moo"))) + // Output: + // moo moo moo +} + func ExampleRunes() { rs := bytes.Runes([]byte("go gopher")) for _, r := range rs { diff --git a/libgo/go/bytes/indexbyte.c b/libgo/go/bytes/indexbyte.c deleted file mode 100644 index b248108e404..00000000000 --- a/libgo/go/bytes/indexbyte.c +++ /dev/null @@ -1,73 +0,0 @@ -/* indexbyte.c -- implement bytes.IndexByte for Go. - - Copyright 2009 The Go Authors. All rights reserved. - Use of this source code is governed by a BSD-style - license that can be found in the LICENSE file. */ - -#include - -#include "runtime.h" -#include "array.h" - -/* This is in C so that the compiler can optimize it appropriately. - We deliberately don't split the stack in case it does call the - library function, which shouldn't need much stack space. */ - -intgo IndexByte (struct __go_open_array, char) - __asm__ (GOSYM_PREFIX "bytes.IndexByte") - __attribute__ ((no_split_stack)); - -intgo -IndexByte (struct __go_open_array s, char b) -{ - char *p; - - p = __builtin_memchr (s.__values, b, s.__count); - if (p == NULL) - return -1; - return p - (char *) s.__values; -} - -/* Comparison. */ - -_Bool Equal (struct __go_open_array a, struct __go_open_array b) - __asm__ (GOSYM_PREFIX "bytes.Equal") - __attribute__ ((no_split_stack)); - -_Bool -Equal (struct __go_open_array a, struct __go_open_array b) -{ - if (a.__count != b.__count) - return 0; - return __builtin_memcmp (a.__values, b.__values, a.__count) == 0; -} - -intgo Compare (struct __go_open_array a, struct __go_open_array b) - __asm__ (GOSYM_PREFIX "bytes.Compare") - __attribute__ ((no_split_stack)); - -intgo -Compare (struct __go_open_array a, struct __go_open_array b) -{ - intgo len; - - len = a.__count; - if (len > b.__count) - len = b.__count; - if (len > 0) - { - intgo ret; - - ret = __builtin_memcmp (a.__values, b.__values, len); - if (ret < 0) - return -1; - else if (ret > 0) - return 1; - } - if (a.__count < b.__count) - return -1; - else if (a.__count > b.__count) - return 1; - else - return 0; -} diff --git a/libgo/go/bytes/reader.go b/libgo/go/bytes/reader.go index 08464c2402d..5946cf9780b 100644 --- a/libgo/go/bytes/reader.go +++ b/libgo/go/bytes/reader.go @@ -14,6 +14,7 @@ import ( // io.ByteScanner, and io.RuneScanner interfaces by reading from // a byte slice. // Unlike a Buffer, a Reader is read-only and supports seeking. +// The zero value for Reader operates like a Reader of an empty slice. type Reader struct { s []byte i int64 // current reading index @@ -75,10 +76,10 @@ func (r *Reader) ReadByte() (byte, error) { // UnreadByte complements ReadByte in implementing the io.ByteScanner interface. func (r *Reader) UnreadByte() error { - r.prevRune = -1 if r.i <= 0 { return errors.New("bytes.Reader.UnreadByte: at beginning of slice") } + r.prevRune = -1 r.i-- return nil } @@ -101,6 +102,9 @@ func (r *Reader) ReadRune() (ch rune, size int, err error) { // UnreadRune complements ReadRune in implementing the io.RuneScanner interface. func (r *Reader) UnreadRune() error { + if r.i <= 0 { + return errors.New("bytes.Reader.UnreadRune: at beginning of slice") + } if r.prevRune < 0 { return errors.New("bytes.Reader.UnreadRune: previous operation was not ReadRune") } diff --git a/libgo/go/bytes/reader_test.go b/libgo/go/bytes/reader_test.go index 8806876ff13..d799e036f0c 100644 --- a/libgo/go/bytes/reader_test.go +++ b/libgo/go/bytes/reader_test.go @@ -276,3 +276,45 @@ func TestReaderReset(t *testing.T) { t.Errorf("ReadAll: got %q, want %q", got, want) } } + +func TestReaderZero(t *testing.T) { + if l := (&Reader{}).Len(); l != 0 { + t.Errorf("Len: got %d, want 0", l) + } + + if n, err := (&Reader{}).Read(nil); n != 0 || err != io.EOF { + t.Errorf("Read: got %d, %v; want 0, io.EOF", n, err) + } + + if n, err := (&Reader{}).ReadAt(nil, 11); n != 0 || err != io.EOF { + t.Errorf("ReadAt: got %d, %v; want 0, io.EOF", n, err) + } + + if b, err := (&Reader{}).ReadByte(); b != 0 || err != io.EOF { + t.Errorf("ReadByte: got %d, %v; want 0, io.EOF", b, err) + } + + if ch, size, err := (&Reader{}).ReadRune(); ch != 0 || size != 0 || err != io.EOF { + t.Errorf("ReadRune: got %d, %d, %v; want 0, 0, io.EOF", ch, size, err) + } + + if offset, err := (&Reader{}).Seek(11, io.SeekStart); offset != 11 || err != nil { + t.Errorf("Seek: got %d, %v; want 11, nil", offset, err) + } + + if s := (&Reader{}).Size(); s != 0 { + t.Errorf("Size: got %d, want 0", s) + } + + if (&Reader{}).UnreadByte() == nil { + t.Errorf("UnreadByte: got nil, want error") + } + + if (&Reader{}).UnreadRune() == nil { + t.Errorf("UnreadRune: got nil, want error") + } + + if n, err := (&Reader{}).WriteTo(ioutil.Discard); n != 0 || err != nil { + t.Errorf("WriteTo: got %d, %v; want 0, nil", n, err) + } +} diff --git a/libgo/go/cmd/cgo/ast.go b/libgo/go/cmd/cgo/ast.go index 4462136bf4b..83d727a8a5d 100644 --- a/libgo/go/cmd/cgo/ast.go +++ b/libgo/go/cmd/cgo/ast.go @@ -145,6 +145,7 @@ func (f *File) ParseGo(name string, src []byte) { if f.Ref == nil { f.Ref = make([]*Ref, 0, 8) } + f.walk(ast2, ctxProg, (*File).validateIdents) f.walk(ast2, ctxProg, (*File).saveExprs) // Accumulate exported functions. @@ -181,6 +182,14 @@ func commentText(g *ast.CommentGroup) string { return strings.Join(pieces, "") } +func (f *File) validateIdents(x interface{}, context astContext) { + if x, ok := x.(*ast.Ident); ok { + if f.isMangledName(x.Name) { + error_(x.Pos(), "identifier %q may conflict with identifiers generated by cgo", x.Name) + } + } +} + // Save various references we are going to need later. func (f *File) saveExprs(x interface{}, context astContext) { switch x := x.(type) { @@ -191,6 +200,18 @@ func (f *File) saveExprs(x interface{}, context astContext) { } case *ast.CallExpr: f.saveCall(x, context) + case *ast.GenDecl: + if x.Tok == token.CONST { + for _, spec := range x.Specs { + vs := spec.(*ast.ValueSpec) + if vs.Type == nil { + for _, name := range spec.(*ast.ValueSpec).Names { + consts[name.Name] = true + } + } + } + } + } } diff --git a/libgo/go/cmd/cgo/doc.go b/libgo/go/cmd/cgo/doc.go index 157cd94d653..cceb33edbdb 100644 --- a/libgo/go/cmd/cgo/doc.go +++ b/libgo/go/cmd/cgo/doc.go @@ -413,6 +413,8 @@ type in Go are instead represented by a uintptr. Those include: jobjectArray jweak +3. The EGLDisplay type from the EGL API. + These types are uintptr on the Go side because they would otherwise confuse the Go garbage collector; they are sometimes not really pointers but data structures encoded in a pointer type. All operations @@ -427,6 +429,11 @@ from Go 1.9 and earlier, use the cftype or jni rewrites in the Go fix tool: It will replace nil with 0 in the appropriate places. +The EGLDisplay case were introduced in Go 1.12. Use the egl rewrite +to auto-update code from Go 1.11 and earlier: + + go tool fix -r egl + Using cgo directly Usage: @@ -827,6 +834,10 @@ The directives are: possibly version in the dynamic library, and the optional "" names the specific library where the symbol should be found. + On AIX, the library pattern is slightly different. It must be + "lib.a/obj.o" with obj.o the member of this library exporting + this symbol. + In the , # or @ can be used to introduce a symbol version. Examples: diff --git a/libgo/go/cmd/cgo/gcc.go b/libgo/go/cmd/cgo/gcc.go index 2a2d0080d5e..a8429725209 100644 --- a/libgo/go/cmd/cgo/gcc.go +++ b/libgo/go/cmd/cgo/gcc.go @@ -13,7 +13,6 @@ import ( "debug/elf" "debug/macho" "debug/pe" - "debug/xcoff" "encoding/binary" "errors" "flag" @@ -21,6 +20,7 @@ import ( "go/ast" "go/parser" "go/token" + "internal/xcoff" "math" "os" "strconv" @@ -89,8 +89,14 @@ func (f *File) DiscardCgoDirectives() { // _cgo_flags file for the build system to use. func (p *Package) addToFlag(flag string, args []string) { if flag == "CFLAGS" { - // We'll need these when preprocessing for dwarf information. - p.GccOptions = append(p.GccOptions, args...) + // We'll also need these when preprocessing for dwarf information. + // However, discard any -g options: we need to be able + // to parse the debug info, so stick to what we expect. + for _, arg := range args { + if !strings.HasPrefix(arg, "-g") { + p.GccOptions = append(p.GccOptions, arg) + } + } } skip := false @@ -182,6 +188,10 @@ func (p *Package) Translate(f *File) { // Convert C.ulong to C.unsigned long, etc. cref.Name.C = cname(cref.Name.Go) } + + var conv typeConv + conv.Init(p.PtrSize, p.IntSize) + p.loadDefines(f) p.typedefs = map[string]bool{} p.typedefList = nil @@ -189,15 +199,17 @@ func (p *Package) Translate(f *File) { for len(p.typedefs) > numTypedefs { numTypedefs = len(p.typedefs) // Also ask about any typedefs we've seen so far. - for _, a := range p.typedefList { - f.Name[a] = &Name{ - Go: a, - C: a, + for _, info := range p.typedefList { + n := &Name{ + Go: info.typedef, + C: info.typedef, } + f.Name[info.typedef] = n + f.NamePos[n] = info.pos } needType := p.guessKinds(f) if len(needType) > 0 { - p.loadDWARF(f, needType) + p.loadDWARF(f, &conv, needType) } // In godefs mode we're OK with the typedefs, which @@ -207,6 +219,7 @@ func (p *Package) Translate(f *File) { break } } + p.prepareNames(f) if p.rewriteCalls(f) { // Add `import _cgo_unsafe "unsafe"` after the package statement. f.Edit.Insert(f.offset(f.AST.Name.End()), "; import _cgo_unsafe \"unsafe\"") @@ -491,7 +504,7 @@ func (p *Package) guessKinds(f *File) []*Name { // loadDWARF parses the DWARF debug information generated // by gcc to learn the details of the constants, variables, and types // being referred to as C.xxx. -func (p *Package) loadDWARF(f *File, names []*Name) { +func (p *Package) loadDWARF(f *File, conv *typeConv, names []*Name) { // Extract the types from the DWARF section of an object // from a well-formed C program. Gcc only generates DWARF info // for symbols in the object file, so it is not enough to print the @@ -590,7 +603,7 @@ func (p *Package) loadDWARF(f *File, names []*Name) { fatalf("malformed __cgo__ name: %s", name) } types[i] = t.Type - p.recordTypedefs(t.Type) + p.recordTypedefs(t.Type, f.NamePos[names[i]]) } if e.Tag != dwarf.TagCompileUnit { r.SkipChildren() @@ -598,8 +611,6 @@ func (p *Package) loadDWARF(f *File, names []*Name) { } // Record types and typedef information. - var conv typeConv - conv.Init(p.PtrSize, p.IntSize) for i, n := range names { if strings.HasSuffix(n.Go, "GetTypeID") && types[i].String() == "func() CFTypeID" { conv.getTypeIDs[n.Go[:len(n.Go)-9]] = true @@ -658,10 +669,11 @@ func (p *Package) loadDWARF(f *File, names []*Name) { } // recordTypedefs remembers in p.typedefs all the typedefs used in dtypes and its children. -func (p *Package) recordTypedefs(dtype dwarf.Type) { - p.recordTypedefs1(dtype, map[dwarf.Type]bool{}) +func (p *Package) recordTypedefs(dtype dwarf.Type, pos token.Pos) { + p.recordTypedefs1(dtype, pos, map[dwarf.Type]bool{}) } -func (p *Package) recordTypedefs1(dtype dwarf.Type, visited map[dwarf.Type]bool) { + +func (p *Package) recordTypedefs1(dtype dwarf.Type, pos token.Pos, visited map[dwarf.Type]bool) { if dtype == nil { return } @@ -677,24 +689,45 @@ func (p *Package) recordTypedefs1(dtype dwarf.Type, visited map[dwarf.Type]bool) } if !p.typedefs[dt.Name] { p.typedefs[dt.Name] = true - p.typedefList = append(p.typedefList, dt.Name) - p.recordTypedefs1(dt.Type, visited) + p.typedefList = append(p.typedefList, typedefInfo{dt.Name, pos}) + p.recordTypedefs1(dt.Type, pos, visited) } case *dwarf.PtrType: - p.recordTypedefs1(dt.Type, visited) + p.recordTypedefs1(dt.Type, pos, visited) case *dwarf.ArrayType: - p.recordTypedefs1(dt.Type, visited) + p.recordTypedefs1(dt.Type, pos, visited) case *dwarf.QualType: - p.recordTypedefs1(dt.Type, visited) + p.recordTypedefs1(dt.Type, pos, visited) case *dwarf.FuncType: - p.recordTypedefs1(dt.ReturnType, visited) + p.recordTypedefs1(dt.ReturnType, pos, visited) for _, a := range dt.ParamType { - p.recordTypedefs1(a, visited) + p.recordTypedefs1(a, pos, visited) } case *dwarf.StructType: for _, f := range dt.Field { - p.recordTypedefs1(f.Type, visited) + p.recordTypedefs1(f.Type, pos, visited) + } + } +} + +// prepareNames finalizes the Kind field of not-type names and sets +// the mangled name of all names. +func (p *Package) prepareNames(f *File) { + for _, n := range f.Name { + if n.Kind == "not-type" { + if n.Define == "" { + n.Kind = "var" + } else { + n.Kind = "macro" + n.FuncType = &FuncType{ + Result: n.Type, + Go: &ast.FuncType{ + Results: &ast.FieldList{List: []*ast.Field{{Type: n.Type.Go}}}, + }, + } + } } + p.mangleName(n) } } @@ -712,24 +745,37 @@ func (p *Package) mangleName(n *Name) { n.Mangle = prefix + n.Kind + "_" + n.Go } +func (f *File) isMangledName(s string) bool { + prefix := "_C" + if strings.HasPrefix(s, prefix) { + t := s[len(prefix):] + for _, k := range nameKinds { + if strings.HasPrefix(t, k+"_") { + return true + } + } + } + return false +} + // rewriteCalls rewrites all calls that pass pointers to check that // they follow the rules for passing pointers between Go and C. -// This returns whether the package needs to import unsafe as _cgo_unsafe. +// This reports whether the package needs to import unsafe as _cgo_unsafe. func (p *Package) rewriteCalls(f *File) bool { needsUnsafe := false + // Walk backward so that in C.f1(C.f2()) we rewrite C.f2 first. for _, call := range f.Calls { - // This is a call to C.xxx; set goname to "xxx". - goname := call.Call.Fun.(*ast.SelectorExpr).Sel.Name - if goname == "malloc" { - continue - } - name := f.Name[goname] - if name.Kind != "func" { - // Probably a type conversion. + if call.Done { continue } - if p.rewriteCall(f, call, name) { - needsUnsafe = true + start := f.offset(call.Call.Pos()) + end := f.offset(call.Call.End()) + str, nu := p.rewriteCall(f, call) + if str != "" { + f.Edit.Replace(start, end, str) + if nu { + needsUnsafe = true + } } } return needsUnsafe @@ -739,162 +785,206 @@ func (p *Package) rewriteCalls(f *File) bool { // If any pointer checks are required, we rewrite the call into a // function literal that calls _cgoCheckPointer for each pointer // argument and then calls the original function. -// This returns whether the package needs to import unsafe as _cgo_unsafe. -func (p *Package) rewriteCall(f *File, call *Call, name *Name) bool { +// This returns the rewritten call and whether the package needs to +// import unsafe as _cgo_unsafe. +// If it returns the empty string, the call did not need to be rewritten. +func (p *Package) rewriteCall(f *File, call *Call) (string, bool) { + // This is a call to C.xxx; set goname to "xxx". + // It may have already been mangled by rewriteName. + var goname string + switch fun := call.Call.Fun.(type) { + case *ast.SelectorExpr: + goname = fun.Sel.Name + case *ast.Ident: + goname = strings.TrimPrefix(fun.Name, "_C2func_") + goname = strings.TrimPrefix(goname, "_Cfunc_") + } + if goname == "" || goname == "malloc" { + return "", false + } + name := f.Name[goname] + if name == nil || name.Kind != "func" { + // Probably a type conversion. + return "", false + } + + params := name.FuncType.Params + args := call.Call.Args + // Avoid a crash if the number of arguments is // less than the number of parameters. // This will be caught when the generated file is compiled. - if len(call.Call.Args) < len(name.FuncType.Params) { - return false + if len(args) < len(params) { + return "", false } any := false - for i, param := range name.FuncType.Params { - if p.needsPointerCheck(f, param.Go, call.Call.Args[i]) { + for i, param := range params { + if p.needsPointerCheck(f, param.Go, args[i]) { any = true break } } if !any { - return false + return "", false } // We need to rewrite this call. // - // We are going to rewrite C.f(p) to - // func (_cgo0 ptype) { + // Rewrite C.f(p) to + // func() { + // _cgo0 := p // _cgoCheckPointer(_cgo0) // C.f(_cgo0) - // }(p) - // Using a function literal like this lets us do correct - // argument type checking, and works correctly if the call is - // deferred. + // }() + // Using a function literal like this lets us evaluate the + // function arguments only once while doing pointer checks. + // This is particularly useful when passing additional arguments + // to _cgoCheckPointer, as done in checkIndex and checkAddr. + // + // When the function argument is a conversion to unsafe.Pointer, + // we unwrap the conversion before checking the pointer, + // and then wrap again when calling C.f. This lets us check + // the real type of the pointer in some cases. See issue #25941. + // + // When the call to C.f is deferred, we use an additional function + // literal to evaluate the arguments at the right time. + // defer func() func() { + // _cgo0 := p + // return func() { + // _cgoCheckPointer(_cgo0) + // C.f(_cgo0) + // } + // }()() + // This works because the defer statement evaluates the first + // function literal in order to get the function to call. + + var sb bytes.Buffer + sb.WriteString("func() ") + if call.Deferred { + sb.WriteString("func() ") + } + needsUnsafe := false - params := make([]*ast.Field, len(name.FuncType.Params)) - nargs := make([]ast.Expr, len(name.FuncType.Params)) - var stmts []ast.Stmt - for i, param := range name.FuncType.Params { - // params is going to become the parameters of the - // function literal. - // nargs is going to become the list of arguments made - // by the call within the function literal. - // nparam is the parameter of the function literal that - // corresponds to param. - - origArg := call.Call.Args[i] - nparam := ast.NewIdent(fmt.Sprintf("_cgo%d", i)) - nargs[i] = nparam - - // The Go version of the C type might use unsafe.Pointer, - // but the file might not import unsafe. - // Rewrite the Go type if necessary to use _cgo_unsafe. - ptype := p.rewriteUnsafe(param.Go) - if ptype != param.Go { - needsUnsafe = true + result := false + twoResults := false + if !call.Deferred { + // Check whether this call expects two results. + for _, ref := range f.Ref { + if ref.Expr != &call.Call.Fun { + continue + } + if ref.Context == ctxCall2 { + sb.WriteString("(") + result = true + twoResults = true + } + break } - params[i] = &ast.Field{ - Names: []*ast.Ident{nparam}, - Type: ptype, + // Add the result type, if any. + if name.FuncType.Result != nil { + rtype := p.rewriteUnsafe(name.FuncType.Result.Go) + if rtype != name.FuncType.Result.Go { + needsUnsafe = true + } + sb.WriteString(gofmtLine(rtype)) + result = true } - if !p.needsPointerCheck(f, param.Go, origArg) { - continue + // Add the second result type, if any. + if twoResults { + if name.FuncType.Result == nil { + // An explicit void result looks odd but it + // seems to be how cgo has worked historically. + sb.WriteString("_Ctype_void") + } + sb.WriteString(", error)") } + } - // Run the cgo pointer checks on nparam. + sb.WriteString("{ ") - // Change the function literal to call the real function - // with the parameter passed through _cgoCheckPointer. - c := &ast.CallExpr{ - Fun: ast.NewIdent("_cgoCheckPointer"), - Args: []ast.Expr{ - nparam, - }, + // Define _cgoN for each argument value. + // Write _cgoCheckPointer calls to sbCheck. + var sbCheck bytes.Buffer + for i, param := range params { + origArg := args[i] + arg, nu := p.mangle(f, &args[i]) + if nu { + needsUnsafe = true } - // Add optional additional arguments for an address - // expression. - c.Args = p.checkAddrArgs(f, c.Args, origArg) + // Explicitly convert untyped constants to the + // parameter type, to avoid a type mismatch. + if p.isConst(f, arg) { + ptype := p.rewriteUnsafe(param.Go) + if ptype != param.Go { + needsUnsafe = true + } + arg = &ast.CallExpr{ + Fun: ptype, + Args: []ast.Expr{arg}, + } + } + + if !p.needsPointerCheck(f, param.Go, args[i]) { + fmt.Fprintf(&sb, "_cgo%d := %s; ", i, gofmtPos(arg, origArg.Pos())) + continue + } - stmt := &ast.ExprStmt{ - X: c, + // Check for &a[i]. + if p.checkIndex(&sb, &sbCheck, arg, i) { + continue + } + + // Check for &x. + if p.checkAddr(&sb, &sbCheck, arg, i) { + continue } - stmts = append(stmts, stmt) + + fmt.Fprintf(&sb, "_cgo%d := %s; ", i, gofmtPos(arg, origArg.Pos())) + fmt.Fprintf(&sbCheck, "_cgoCheckPointer(_cgo%d); ", i) } - const cgoMarker = "__cgo__###__marker__" - fcall := &ast.CallExpr{ - Fun: ast.NewIdent(cgoMarker), - Args: nargs, + if call.Deferred { + sb.WriteString("return func() { ") } - ftype := &ast.FuncType{ - Params: &ast.FieldList{ - List: params, - }, + + // Write out the calls to _cgoCheckPointer. + sb.WriteString(sbCheck.String()) + + if result { + sb.WriteString("return ") } - if name.FuncType.Result != nil { - rtype := p.rewriteUnsafe(name.FuncType.Result.Go) - if rtype != name.FuncType.Result.Go { - needsUnsafe = true - } - ftype.Results = &ast.FieldList{ - List: []*ast.Field{ - &ast.Field{ - Type: rtype, - }, - }, - } - } - - // If this call expects two results, we have to - // adjust the results of the function we generated. - for _, ref := range f.Ref { - if ref.Expr == &call.Call.Fun && ref.Context == ctxCall2 { - if ftype.Results == nil { - // An explicit void argument - // looks odd but it seems to - // be how cgo has worked historically. - ftype.Results = &ast.FieldList{ - List: []*ast.Field{ - &ast.Field{ - Type: ast.NewIdent("_Ctype_void"), - }, - }, - } - } - ftype.Results.List = append(ftype.Results.List, - &ast.Field{ - Type: ast.NewIdent("error"), - }) - } + + m, nu := p.mangle(f, &call.Call.Fun) + if nu { + needsUnsafe = true } + sb.WriteString(gofmtLine(m)) - var fbody ast.Stmt - if ftype.Results == nil { - fbody = &ast.ExprStmt{ - X: fcall, - } - } else { - fbody = &ast.ReturnStmt{ - Results: []ast.Expr{fcall}, + sb.WriteString("(") + for i := range params { + if i > 0 { + sb.WriteString(", ") } + fmt.Fprintf(&sb, "_cgo%d", i) } - lit := &ast.FuncLit{ - Type: ftype, - Body: &ast.BlockStmt{ - List: append(stmts, fbody), - }, + sb.WriteString("); ") + if call.Deferred { + sb.WriteString("}") } - text := strings.Replace(gofmt(lit), "\n", ";", -1) - repl := strings.Split(text, cgoMarker) - f.Edit.Insert(f.offset(call.Call.Fun.Pos()), repl[0]) - f.Edit.Insert(f.offset(call.Call.Fun.End()), repl[1]) + sb.WriteString("}") + if call.Deferred { + sb.WriteString("()") + } + sb.WriteString("()") - return needsUnsafe + return sb.String(), needsUnsafe } -// needsPointerCheck returns whether the type t needs a pointer check. +// needsPointerCheck reports whether the type t needs a pointer check. // This is true if t is a pointer and if the value to which it points // might contain a pointer. func (p *Package) needsPointerCheck(f *File, t ast.Expr, arg ast.Expr) bool { @@ -911,7 +1001,7 @@ func (p *Package) needsPointerCheck(f *File, t ast.Expr, arg ast.Expr) bool { // hasPointer is used by needsPointerCheck. If top is true it returns // whether t is or contains a pointer that might point to a pointer. -// If top is false it returns whether t is or contains a pointer. +// If top is false it reports whether t is or contains a pointer. // f may be nil. func (p *Package) hasPointer(f *File, t ast.Expr, top bool) bool { switch t := t.(type) { @@ -998,19 +1088,68 @@ func (p *Package) hasPointer(f *File, t ast.Expr, top bool) bool { } } -// checkAddrArgs tries to add arguments to the call of -// _cgoCheckPointer when the argument is an address expression. We -// pass true to mean that the argument is an address operation of -// something other than a slice index, which means that it's only -// necessary to check the specific element pointed to, not the entire -// object. This is for &s.f, where f is a field in a struct. We can -// pass a slice or array, meaning that we should check the entire -// slice or array but need not check any other part of the object. -// This is for &s.a[i], where we need to check all of a. However, we -// only pass the slice or array if we can refer to it without side -// effects. -func (p *Package) checkAddrArgs(f *File, args []ast.Expr, x ast.Expr) []ast.Expr { +// mangle replaces references to C names in arg with the mangled names, +// rewriting calls when it finds them. +// It removes the corresponding references in f.Ref and f.Calls, so that we +// don't try to do the replacement again in rewriteRef or rewriteCall. +func (p *Package) mangle(f *File, arg *ast.Expr) (ast.Expr, bool) { + needsUnsafe := false + f.walk(arg, ctxExpr, func(f *File, arg interface{}, context astContext) { + px, ok := arg.(*ast.Expr) + if !ok { + return + } + sel, ok := (*px).(*ast.SelectorExpr) + if ok { + if l, ok := sel.X.(*ast.Ident); !ok || l.Name != "C" { + return + } + + for _, r := range f.Ref { + if r.Expr == px { + *px = p.rewriteName(f, r) + r.Done = true + break + } + } + + return + } + + call, ok := (*px).(*ast.CallExpr) + if !ok { + return + } + + for _, c := range f.Calls { + if !c.Done && c.Call.Lparen == call.Lparen { + cstr, nu := p.rewriteCall(f, c) + if cstr != "" { + // Smuggle the rewritten call through an ident. + *px = ast.NewIdent(cstr) + if nu { + needsUnsafe = true + } + c.Done = true + } + } + } + }) + return *arg, needsUnsafe +} + +// checkIndex checks whether arg has the form &a[i], possibly inside +// type conversions. If so, it writes +// _cgoIndexNN := a +// _cgoNN := &cgoIndexNN[i] // with type conversions, if any +// to sb, and writes +// _cgoCheckPointer(_cgoNN, _cgoIndexNN) +// to sbCheck, and returns true. This tells _cgoCheckPointer to check +// the complete contents of the slice or array being indexed, but no +// other part of the memory allocation. +func (p *Package) checkIndex(sb, sbCheck *bytes.Buffer, arg ast.Expr, i int) bool { // Strip type conversions. + x := arg for { c, ok := x.(*ast.CallExpr) if !ok || len(c.Args) != 1 || !p.isType(c.Fun) { @@ -1020,40 +1159,63 @@ func (p *Package) checkAddrArgs(f *File, args []ast.Expr, x ast.Expr) []ast.Expr } u, ok := x.(*ast.UnaryExpr) if !ok || u.Op != token.AND { - return args + return false } index, ok := u.X.(*ast.IndexExpr) if !ok { - // This is the address of something that is not an - // index expression. We only need to examine the - // single value to which it points. - // TODO: what if true is shadowed? - return append(args, ast.NewIdent("true")) - } - if !p.hasSideEffects(f, index.X) { - // Examine the entire slice. - return append(args, index.X) - } - // Treat the pointer as unknown. - return args + return false + } + + fmt.Fprintf(sb, "_cgoIndex%d := %s; ", i, gofmtPos(index.X, index.X.Pos())) + origX := index.X + index.X = ast.NewIdent(fmt.Sprintf("_cgoIndex%d", i)) + fmt.Fprintf(sb, "_cgo%d := %s; ", i, gofmtPos(arg, arg.Pos())) + index.X = origX + + fmt.Fprintf(sbCheck, "_cgoCheckPointer(_cgo%d, _cgoIndex%d); ", i, i) + + return true } -// hasSideEffects returns whether the expression x has any side -// effects. x is an expression, not a statement, so the only side -// effect is a function call. -func (p *Package) hasSideEffects(f *File, x ast.Expr) bool { - found := false - f.walk(x, ctxExpr, - func(f *File, x interface{}, context astContext) { - switch x.(type) { - case *ast.CallExpr: - found = true - } - }) - return found +// checkAddr checks whether arg has the form &x, possibly inside type +// conversions. If so, it writes +// _cgoBaseNN := &x +// _cgoNN := _cgoBaseNN // with type conversions, if any +// to sb, and writes +// _cgoCheckPointer(_cgoBaseNN, true) +// to sbCheck, and returns true. This tells _cgoCheckPointer to check +// just the contents of the pointer being passed, not any other part +// of the memory allocation. This is run after checkIndex, which looks +// for the special case of &a[i], which requires different checks. +func (p *Package) checkAddr(sb, sbCheck *bytes.Buffer, arg ast.Expr, i int) bool { + // Strip type conversions. + px := &arg + for { + c, ok := (*px).(*ast.CallExpr) + if !ok || len(c.Args) != 1 || !p.isType(c.Fun) { + break + } + px = &c.Args[0] + } + if u, ok := (*px).(*ast.UnaryExpr); !ok || u.Op != token.AND { + return false + } + + fmt.Fprintf(sb, "_cgoBase%d := %s; ", i, gofmtPos(*px, (*px).Pos())) + + origX := *px + *px = ast.NewIdent(fmt.Sprintf("_cgoBase%d", i)) + fmt.Fprintf(sb, "_cgo%d := %s; ", i, gofmtPos(arg, arg.Pos())) + *px = origX + + // Use "0 == 0" to do the right thing in the unlikely event + // that "true" is shadowed. + fmt.Fprintf(sbCheck, "_cgoCheckPointer(_cgoBase%d, 0 == 0); ", i) + + return true } -// isType returns whether the expression is definitely a type. +// isType reports whether the expression is definitely a type. // This is conservative--it returns false for an unknown identifier. func (p *Package) isType(t ast.Expr) bool { switch t := t.(type) { @@ -1082,6 +1244,9 @@ func (p *Package) isType(t ast.Expr) bool { return true } + if strings.HasPrefix(t.Name, "_Ctype_") { + return true + } case *ast.StarExpr: return p.isType(t.X) case *ast.ArrayType, *ast.StructType, *ast.FuncType, *ast.InterfaceType, @@ -1092,6 +1257,47 @@ func (p *Package) isType(t ast.Expr) bool { return false } +// isConst reports whether x is an untyped constant expression. +func (p *Package) isConst(f *File, x ast.Expr) bool { + switch x := x.(type) { + case *ast.BasicLit: + return true + case *ast.SelectorExpr: + id, ok := x.X.(*ast.Ident) + if !ok || id.Name != "C" { + return false + } + name := f.Name[x.Sel.Name] + if name != nil { + return name.IsConst() + } + case *ast.Ident: + return x.Name == "nil" || + strings.HasPrefix(x.Name, "_Ciconst_") || + strings.HasPrefix(x.Name, "_Cfconst_") || + strings.HasPrefix(x.Name, "_Csconst_") || + consts[x.Name] + case *ast.UnaryExpr: + return p.isConst(f, x.X) + case *ast.BinaryExpr: + return p.isConst(f, x.X) && p.isConst(f, x.Y) + case *ast.ParenExpr: + return p.isConst(f, x.X) + case *ast.CallExpr: + // Calling the builtin function complex on two untyped + // constants returns an untyped constant. + // TODO: It's possible to construct a case that will + // erroneously succeed if there is a local function + // named "complex", shadowing the builtin, that returns + // a numeric type. I can't think of any cases that will + // erroneously fail. + if id, ok := x.Fun.(*ast.Ident); ok && id.Name == "complex" && len(x.Args) == 2 { + return p.isConst(f, x.Args[0]) && p.isConst(f, x.Args[1]) + } + } + return false +} + // rewriteUnsafe returns a version of t with references to unsafe.Pointer // rewritten to use _cgo_unsafe.Pointer instead. func (p *Package) rewriteUnsafe(t ast.Expr) ast.Expr { @@ -1150,24 +1356,7 @@ func (p *Package) rewriteRef(f *File) { // code for them. functions := make(map[string]bool) - // Assign mangled names. for _, n := range f.Name { - if n.Kind == "not-type" { - if n.Define == "" { - n.Kind = "var" - } else { - n.Kind = "macro" - n.FuncType = &FuncType{ - Result: n.Type, - Go: &ast.FuncType{ - Results: &ast.FieldList{List: []*ast.Field{{Type: n.Type.Go}}}, - }, - } - } - } - if n.Mangle == "" { - p.mangleName(n) - } if n.Kind == "func" { functions[n.Go] = false } @@ -1181,104 +1370,16 @@ func (p *Package) rewriteRef(f *File) { if r.Name.IsConst() && r.Name.Const == "" { error_(r.Pos(), "unable to find value of constant C.%s", fixGo(r.Name.Go)) } - var expr ast.Expr = ast.NewIdent(r.Name.Mangle) // default - switch r.Context { - case ctxCall, ctxCall2: - if r.Name.Kind != "func" { - if r.Name.Kind == "type" { - r.Context = ctxType - if r.Name.Type == nil { - error_(r.Pos(), "invalid conversion to C.%s: undefined C type '%s'", fixGo(r.Name.Go), r.Name.C) - break - } - expr = r.Name.Type.Go - break - } - error_(r.Pos(), "call of non-function C.%s", fixGo(r.Name.Go)) - break - } - functions[r.Name.Go] = true - if r.Context == ctxCall2 { - if r.Name.Go == "_CMalloc" { - error_(r.Pos(), "no two-result form for C.malloc") - break - } - // Invent new Name for the two-result function. - n := f.Name["2"+r.Name.Go] - if n == nil { - n = new(Name) - *n = *r.Name - n.AddError = true - n.Mangle = "_C2func_" + n.Go - f.Name["2"+r.Name.Go] = n - } - expr = ast.NewIdent(n.Mangle) - r.Name = n - break - } - case ctxExpr: - switch r.Name.Kind { - case "func": - if builtinDefs[r.Name.C] != "" { - error_(r.Pos(), "use of builtin '%s' not in function call", fixGo(r.Name.C)) - } - // Function is being used in an expression, to e.g. pass around a C function pointer. - // Create a new Name for this Ref which causes the variable to be declared in Go land. - fpName := "fp_" + r.Name.Go - name := f.Name[fpName] - if name == nil { - name = &Name{ - Go: fpName, - C: r.Name.C, - Kind: "fpvar", - Type: &Type{Size: p.PtrSize, Align: p.PtrSize, C: c("void*"), Go: ast.NewIdent("unsafe.Pointer")}, - } - p.mangleName(name) - f.Name[fpName] = name - } - r.Name = name - // Rewrite into call to _Cgo_ptr to prevent assignments. The _Cgo_ptr - // function is defined in out.go and simply returns its argument. See - // issue 7757. - expr = &ast.CallExpr{ - Fun: &ast.Ident{NamePos: (*r.Expr).Pos(), Name: "_Cgo_ptr"}, - Args: []ast.Expr{ast.NewIdent(name.Mangle)}, - } - case "type": - // Okay - might be new(T) - if r.Name.Type == nil { - error_(r.Pos(), "expression C.%s: undefined C type '%s'", fixGo(r.Name.Go), r.Name.C) - break - } - expr = r.Name.Type.Go - case "var": - expr = &ast.StarExpr{Star: (*r.Expr).Pos(), X: expr} - case "macro": - expr = &ast.CallExpr{Fun: expr} - } - case ctxSelector: - if r.Name.Kind == "var" { - expr = &ast.StarExpr{Star: (*r.Expr).Pos(), X: expr} - } else { - error_(r.Pos(), "only C variables allowed in selector expression %s", fixGo(r.Name.Go)) - } - case ctxType: - if r.Name.Kind != "type" { - error_(r.Pos(), "expression C.%s used as type", fixGo(r.Name.Go)) - } else if r.Name.Type == nil { - // Use of C.enum_x, C.struct_x or C.union_x without C definition. - // GCC won't raise an error when using pointers to such unknown types. - error_(r.Pos(), "type C.%s: undefined C type '%s'", fixGo(r.Name.Go), r.Name.C) - } else { - expr = r.Name.Type.Go - } - default: - if r.Name.Kind == "func" { - error_(r.Pos(), "must call C.%s", fixGo(r.Name.Go)) + if r.Name.Kind == "func" { + switch r.Context { + case ctxCall, ctxCall2: + functions[r.Name.Go] = true } } + expr := p.rewriteName(f, r) + if *godefs { // Substitute definition for mangled type name. if id, ok := expr.(*ast.Ident); ok { @@ -1295,8 +1396,7 @@ func (p *Package) rewriteRef(f *File) { // in case expression being replaced is first on line. // See golang.org/issue/6563. pos := (*r.Expr).Pos() - switch x := expr.(type) { - case *ast.Ident: + if x, ok := expr.(*ast.Ident); ok { expr = &ast.Ident{NamePos: pos, Name: x.Name} } @@ -1306,11 +1406,26 @@ func (p *Package) rewriteRef(f *File) { *r.Expr = expr // Record source-level edit for cgo output. - repl := gofmt(expr) - if r.Name.Kind != "type" { - repl = "(" + repl + ")" + if !r.Done { + // Prepend a space in case the earlier code ends + // with '/', which would give us a "//" comment. + repl := " " + gofmtPos(expr, old.Pos()) + end := fset.Position(old.End()) + // Subtract 1 from the column if we are going to + // append a close parenthesis. That will set the + // correct column for the following characters. + sub := 0 + if r.Name.Kind != "type" { + sub = 1 + } + if end.Column > sub { + repl = fmt.Sprintf("%s /*line :%d:%d*/", repl, end.Line, end.Column-sub) + } + if r.Name.Kind != "type" { + repl = "(" + repl + ")" + } + f.Edit.Replace(f.offset(old.Pos()), f.offset(old.End()), repl) } - f.Edit.Replace(f.offset(old.Pos()), f.offset(old.End()), repl) } // Remove functions only used as expressions, so their respective @@ -1322,6 +1437,118 @@ func (p *Package) rewriteRef(f *File) { } } +// rewriteName returns the expression used to rewrite a reference. +func (p *Package) rewriteName(f *File, r *Ref) ast.Expr { + var expr ast.Expr = ast.NewIdent(r.Name.Mangle) // default + switch r.Context { + case ctxCall, ctxCall2: + if r.Name.Kind != "func" { + if r.Name.Kind == "type" { + r.Context = ctxType + if r.Name.Type == nil { + error_(r.Pos(), "invalid conversion to C.%s: undefined C type '%s'", fixGo(r.Name.Go), r.Name.C) + break + } + expr = r.Name.Type.Go + break + } + error_(r.Pos(), "call of non-function C.%s", fixGo(r.Name.Go)) + break + } + if r.Context == ctxCall2 { + if r.Name.Go == "_CMalloc" { + error_(r.Pos(), "no two-result form for C.malloc") + break + } + // Invent new Name for the two-result function. + n := f.Name["2"+r.Name.Go] + if n == nil { + n = new(Name) + *n = *r.Name + n.AddError = true + n.Mangle = "_C2func_" + n.Go + f.Name["2"+r.Name.Go] = n + } + expr = ast.NewIdent(n.Mangle) + r.Name = n + break + } + case ctxExpr: + switch r.Name.Kind { + case "func": + if builtinDefs[r.Name.C] != "" { + error_(r.Pos(), "use of builtin '%s' not in function call", fixGo(r.Name.C)) + } + + // Function is being used in an expression, to e.g. pass around a C function pointer. + // Create a new Name for this Ref which causes the variable to be declared in Go land. + fpName := "fp_" + r.Name.Go + name := f.Name[fpName] + if name == nil { + name = &Name{ + Go: fpName, + C: r.Name.C, + Kind: "fpvar", + Type: &Type{Size: p.PtrSize, Align: p.PtrSize, C: c("void*"), Go: ast.NewIdent("unsafe.Pointer")}, + } + p.mangleName(name) + f.Name[fpName] = name + } + r.Name = name + // Rewrite into call to _Cgo_ptr to prevent assignments. The _Cgo_ptr + // function is defined in out.go and simply returns its argument. See + // issue 7757. + expr = &ast.CallExpr{ + Fun: &ast.Ident{NamePos: (*r.Expr).Pos(), Name: "_Cgo_ptr"}, + Args: []ast.Expr{ast.NewIdent(name.Mangle)}, + } + case "type": + // Okay - might be new(T) + if r.Name.Type == nil { + error_(r.Pos(), "expression C.%s: undefined C type '%s'", fixGo(r.Name.Go), r.Name.C) + break + } + expr = r.Name.Type.Go + case "var": + expr = &ast.StarExpr{Star: (*r.Expr).Pos(), X: expr} + case "macro": + expr = &ast.CallExpr{Fun: expr} + } + case ctxSelector: + if r.Name.Kind == "var" { + expr = &ast.StarExpr{Star: (*r.Expr).Pos(), X: expr} + } else { + error_(r.Pos(), "only C variables allowed in selector expression %s", fixGo(r.Name.Go)) + } + case ctxType: + if r.Name.Kind != "type" { + error_(r.Pos(), "expression C.%s used as type", fixGo(r.Name.Go)) + } else if r.Name.Type == nil { + // Use of C.enum_x, C.struct_x or C.union_x without C definition. + // GCC won't raise an error when using pointers to such unknown types. + error_(r.Pos(), "type C.%s: undefined C type '%s'", fixGo(r.Name.Go), r.Name.C) + } else { + expr = r.Name.Type.Go + } + default: + if r.Name.Kind == "func" { + error_(r.Pos(), "must call C.%s", fixGo(r.Name.Go)) + } + } + return expr +} + +// gofmtPos returns the gofmt-formatted string for an AST node, +// with a comment setting the position before the node. +func gofmtPos(n ast.Expr, pos token.Pos) string { + s := gofmtLine(n) + p := fset.Position(pos) + if p.Column == 0 { + return s + } + return fmt.Sprintf("/*line :%d:%d*/%s", p.Line, p.Column, s) +} + // gccBaseCmd returns the start of the compiler command line. // It uses $CC if set, or else $GCC, or else the compiler recorded // during the initial build as defaultCC. @@ -1400,6 +1627,9 @@ func (p *Package) gccCmd() []string { c = append(c, p.GccOptions...) c = append(c, p.gccMachine()...) + if goos == "aix" { + c = append(c, "-maix64") + } c = append(c, "-") //read input from standard input return c } @@ -1754,10 +1984,8 @@ func (p *Package) gccDebug(stdin []byte, nnames int) (d *dwarf.Data, ints []int6 } buildStrings() - return d, ints, floats, strs } - fatalf("cannot parse gcc output %s as ELF, Mach-O, PE, XCOFF object", gccTmp()) panic("not reached") } @@ -1788,6 +2016,11 @@ func (p *Package) gccErrors(stdin []byte) string { } } + // Force -O0 optimization but keep the trailing "-" at the end. + nargs = append(nargs, "-O0") + nl := len(nargs) + nargs[nl-2], nargs[nl-1] = nargs[nl-1], nargs[nl-2] + if *debugGcc { fmt.Fprintf(os.Stderr, "$ %s < 0 { dtype := c.ptrKeys[0] + dtypeKey := dtype.String() c.ptrKeys = c.ptrKeys[1:] - ptrs := c.ptrs[dtype] - delete(c.ptrs, dtype) + ptrs := c.ptrs[dtypeKey] + delete(c.ptrs, dtypeKey) - // Note Type might invalidate c.ptrs[dtype]. + // Note Type might invalidate c.ptrs[dtypeKey]. t := c.Type(dtype, pos) for _, ptr := range ptrs { ptr.Go.(*ast.StarExpr).X = t.Go @@ -1992,18 +2226,29 @@ func (c *typeConv) FinishType(pos token.Pos) { // Type returns a *Type with the same memory layout as // dtype when used as the type of a variable or a struct field. func (c *typeConv) Type(dtype dwarf.Type, pos token.Pos) *Type { - if t, ok := c.m[dtype]; ok { - if t.Go == nil { - fatalf("%s: type conversion loop at %s", lineno(pos), dtype) + // Always recompute bad pointer typedefs, as the set of such + // typedefs changes as we see more types. + checkCache := true + if dtt, ok := dtype.(*dwarf.TypedefType); ok && c.badPointerTypedef(dtt) { + checkCache = false + } + + key := dtype.String() + + if checkCache { + if t, ok := c.m[key]; ok { + if t.Go == nil { + fatalf("%s: type conversion loop at %s", lineno(pos), dtype) + } + return t } - return t } t := new(Type) t.Size = dtype.Size() // note: wrong for array of pointers, corrected below t.Align = -1 t.C = &TypeRepr{Repr: dtype.Common().Name} - c.m[dtype] = t + c.m[key] = t switch dt := dtype.(type) { default: @@ -2166,10 +2411,11 @@ func (c *typeConv) Type(dtype dwarf.Type, pos token.Pos) *Type { // Placeholder initialization; completed in FinishType. t.Go = &ast.StarExpr{} t.C.Set("*") - if _, ok := c.ptrs[dt.Type]; !ok { + key := dt.Type.String() + if _, ok := c.ptrs[key]; !ok { c.ptrKeys = append(c.ptrKeys, dt.Type) } - c.ptrs[dt.Type] = append(c.ptrs[dt.Type], t) + c.ptrs[key] = append(c.ptrs[key], t) case *dwarf.QualType: t1 := c.Type(dt.Type, pos) @@ -2557,11 +2803,6 @@ func (c *typeConv) Struct(dt *dwarf.StructType, pos token.Pos) (expr *ast.Struct anon := 0 for _, f := range dt.Field { - if f.ByteOffset > off { - fld, sizes = c.pad(fld, sizes, f.ByteOffset-off) - off = f.ByteOffset - } - name := f.Name ft := f.Type @@ -2610,6 +2851,19 @@ func (c *typeConv) Struct(dt *dwarf.StructType, pos token.Pos) (expr *ast.Struct // structs are in system headers that cannot be corrected. continue } + + // Round off up to talign, assumed to be a power of 2. + off = (off + talign - 1) &^ (talign - 1) + + if f.ByteOffset > off { + fld, sizes = c.pad(fld, sizes, f.ByteOffset-off) + off = f.ByteOffset + } + if f.ByteOffset < off { + // Drop a packed field that we can't represent. + continue + } + n := len(fld) fld = fld[0 : n+1] if name == "" { @@ -2659,7 +2913,7 @@ func (c *typeConv) Struct(dt *dwarf.StructType, pos token.Pos) (expr *ast.Struct return } -// dwarfHasPointer returns whether the DWARF type dt contains a pointer. +// dwarfHasPointer reports whether the DWARF type dt contains a pointer. func (c *typeConv) dwarfHasPointer(dt dwarf.Type, pos token.Pos) bool { switch dt := dt.(type) { default: @@ -2776,6 +3030,9 @@ func (c *typeConv) badPointerTypedef(dt *dwarf.TypedefType) bool { if c.badJNI(dt) { return true } + if c.badEGLDisplay(dt) { + return true + } return false } @@ -2912,6 +3169,19 @@ func (c *typeConv) badJNI(dt *dwarf.TypedefType) bool { return false } +func (c *typeConv) badEGLDisplay(dt *dwarf.TypedefType) bool { + if dt.Name != "EGLDisplay" { + return false + } + // Check that the typedef is "typedef void *EGLDisplay". + if ptr, ok := dt.Type.(*dwarf.PtrType); ok { + if _, ok := ptr.Type.(*dwarf.VoidType); ok { + return true + } + } + return false +} + // jniTypes maps from JNI types that we want to be uintptrs, to the underlying type to which // they are mapped. The base "jobject" maps to the empty string. var jniTypes = map[string]string{ diff --git a/libgo/go/cmd/cgo/godefs.go b/libgo/go/cmd/cgo/godefs.go index 6720945cddd..9c763a22fb0 100644 --- a/libgo/go/cmd/cgo/godefs.go +++ b/libgo/go/cmd/cgo/godefs.go @@ -126,3 +126,9 @@ func gofmt(n interface{}) string { } return gofmtBuf.String() } + +// gofmtLine returns the gofmt-formatted string for an AST node, +// ensuring that it is on a single line. +func gofmtLine(n interface{}) string { + return strings.Replace(gofmt(n), "\n", ";", -1) +} diff --git a/libgo/go/cmd/cgo/main.go b/libgo/go/cmd/cgo/main.go index 8e7567b5b0e..4a5c0ca2bab 100644 --- a/libgo/go/cmd/cgo/main.go +++ b/libgo/go/cmd/cgo/main.go @@ -47,7 +47,14 @@ type Package struct { GccFiles []string // list of gcc output files Preamble string // collected preamble for _cgo_export.h typedefs map[string]bool // type names that appear in the types of the objects we're interested in - typedefList []string + typedefList []typedefInfo +} + +// A typedefInfo is an element on Package.typedefList: a typedef name +// and the position where it was required. +type typedefInfo struct { + typedef string + pos token.Pos } // A File collects information about a single Go input file. @@ -64,6 +71,9 @@ type File struct { Edit *edit.Buffer } +// Untyped constants in the current package. +var consts = make(map[string]bool) + func (f *File) offset(p token.Pos) int { return fset.Position(p).Offset } @@ -81,6 +91,7 @@ func nameKeys(m map[string]*Name) []string { type Call struct { Call *ast.CallExpr Deferred bool + Done bool } // A Ref refers to an expression of the form C.xxx in the AST. @@ -88,19 +99,22 @@ type Ref struct { Name *Name Expr *ast.Expr Context astContext + Done bool } func (r *Ref) Pos() token.Pos { return (*r.Expr).Pos() } +var nameKinds = []string{"iconst", "fconst", "sconst", "type", "var", "fpvar", "func", "macro", "not-type"} + // A Name collects information about C.xxx. type Name struct { Go string // name used in Go referring to package C Mangle string // name used in generated Go C string // name used in C Define string // #define expansion - Kind string // "iconst", "fconst", "sconst", "type", "var", "fpvar", "func", "macro", "not-type" + Kind string // one of the nameKinds Type *Type // the type of xxx FuncType *FuncType AddError bool diff --git a/libgo/go/cmd/cgo/out.go b/libgo/go/cmd/cgo/out.go index 50e57157793..f44da9c8b12 100644 --- a/libgo/go/cmd/cgo/out.go +++ b/libgo/go/cmd/cgo/out.go @@ -9,11 +9,11 @@ import ( "debug/elf" "debug/macho" "debug/pe" - "debug/xcoff" "fmt" "go/ast" "go/printer" "go/token" + "internal/xcoff" "io" "io/ioutil" "os" @@ -251,7 +251,22 @@ func (p *Package) writeDefs() { init := gccgoInit.String() if init != "" { - fmt.Fprintln(fc, "static void init(void) __attribute__ ((constructor));") + // The init function does nothing but simple + // assignments, so it won't use much stack space, so + // it's OK to not split the stack. Splitting the stack + // can run into a bug in clang (as of 2018-11-09): + // this is a leaf function, and when clang sees a leaf + // function it won't emit the split stack prologue for + // the function. However, if this function refers to a + // non-split-stack function, which will happen if the + // cgo code refers to a C function not compiled with + // -fsplit-stack, then the linker will think that it + // needs to adjust the split stack prologue, but there + // won't be one. Marking the function explicitly + // no_split_stack works around this problem by telling + // the linker that it's OK if there is no split stack + // prologue. + fmt.Fprintln(fc, "static void init(void) __attribute__ ((constructor, no_split_stack));") fmt.Fprintln(fc, "static void init(void) {") fmt.Fprint(fc, init) fmt.Fprintln(fc, "}") @@ -1193,7 +1208,7 @@ func (p *Package) writeExportHeader(fgcch io.Writer) { fmt.Fprintf(fgcch, "%s\n", p.gccExportHeaderProlog()) } -// gccgoUsesNewMangling returns whether gccgo uses the new collision-free +// gccgoUsesNewMangling reports whether gccgo uses the new collision-free // packagepath mangling scheme (see determineGccgoManglingScheme for more // info). func gccgoUsesNewMangling() bool { @@ -1545,6 +1560,7 @@ const builtinProlog = ` /* Define intgo when compiling with GCC. */ typedef ptrdiff_t intgo; +#define GO_CGO_GOSTRING_TYPEDEF typedef struct { const char *p; intgo n; } _GoString_; typedef struct { char *p; intgo n; intgo c; } _GoBytes_; _GoString_ GoString(char *p); @@ -1555,7 +1571,7 @@ void *CBytes(_GoBytes_); void *_CMalloc(size_t); __attribute__ ((unused)) -static size_t _GoStringLen(_GoString_ s) { return s.n; } +static size_t _GoStringLen(_GoString_ s) { return (size_t)s.n; } __attribute__ ((unused)) static const char *_GoStringPtr(_GoString_ s) { return s.p; } @@ -1796,15 +1812,20 @@ void localCgoCheckResult(Eface val) { // because _cgo_export.h defines GoString as a struct while builtinProlog // defines it as a function. We don't change this to avoid unnecessarily // breaking existing code. +// The test of GO_CGO_GOSTRING_TYPEDEF avoids a duplicate definition +// error if a Go file with a cgo comment #include's the export header +// generated by a different package. const builtinExportProlog = ` -#line 1 "cgo-builtin-prolog" +#line 1 "cgo-builtin-export-prolog" #include /* for ptrdiff_t below */ #ifndef GO_CGO_EXPORT_PROLOGUE_H #define GO_CGO_EXPORT_PROLOGUE_H +#ifndef GO_CGO_GOSTRING_TYPEDEF typedef struct { const char *p; ptrdiff_t n; } _GoString_; +#endif #endif ` @@ -1813,6 +1834,19 @@ func (p *Package) gccExportHeaderProlog() string { return strings.Replace(gccExportHeaderProlog, "GOINTBITS", fmt.Sprint(8*p.IntSize), -1) } +// gccExportHeaderProlog is written to the exported header, after the +// import "C" comment preamble but before the generated declarations +// of exported functions. This permits the generated declarations to +// use the type names that appear in goTypes, above. +// +// The test of GO_CGO_GOSTRING_TYPEDEF avoids a duplicate definition +// error if a Go file with a cgo comment #include's the export header +// generated by a different package. Unfortunately GoString means two +// different things: in this prolog it means a C name for the Go type, +// while in the prolog written into the start of the C code generated +// from a cgo-using Go file it means the C.GoString function. There is +// no way to resolve this conflict, but it also doesn't make much +// difference, as Go code never wants to refer to the latter meaning. const gccExportHeaderProlog = ` /* Start of boilerplate cgo prologue. */ #line 1 "cgo-gcc-export-header-prolog" @@ -1842,7 +1876,9 @@ typedef double _Complex GoComplex128; */ typedef char _check_for_GOINTBITS_bit_pointer_matching_GoInt[sizeof(void*)==GOINTBITS/8 ? 1:-1]; +#ifndef GO_CGO_GOSTRING_TYPEDEF typedef _GoString_ GoString; +#endif typedef void *GoMap; typedef void *GoChan; typedef struct { void *t; void *v; } GoInterface; diff --git a/libgo/go/cmd/go/alldocs.go b/libgo/go/cmd/go/alldocs.go index 1060e779c1b..9d9304a3b64 100644 --- a/libgo/go/cmd/go/alldocs.go +++ b/libgo/go/cmd/go/alldocs.go @@ -144,7 +144,7 @@ // link against shared libraries previously created with // -buildmode=shared. // -mod mode -// module download mode to use: readonly, release, or vendor. +// module download mode to use: readonly or vendor. // See 'go help modules' for more. // -pkgdir dir // install and load all packages from dir instead of the usual locations. @@ -342,12 +342,21 @@ // cd go/src/encoding/json; go doc decode // // Flags: +// -all +// Show all the documentation for the package. // -c // Respect case when matching symbols. // -cmd // Treat a command (package main) like a regular package. // Otherwise package main's exported symbols are hidden // when showing the package's top-level documentation. +// -src +// Show the full source code for the symbol. This will +// display the full Go source of its declaration and +// definition, such as a function definition (including +// the body), type declaration or enclosing const +// block. The output may therefore include unexported +// details. // -u // Show documentation for unexported as well as exported // symbols, methods, and fields. @@ -889,7 +898,7 @@ // // Usage: // -// go mod download [-dir] [-json] [modules] +// go mod download [-json] [modules] // // Download downloads the named modules, which can be module patterns selecting // dependencies of the main module or module queries of the form path@version. @@ -963,6 +972,8 @@ // and -dropreplace editing flags may be repeated, and the changes // are applied in the order given. // +// The -go=version flag sets the expected Go language version. +// // The -print flag prints the final go.mod in its text format instead of // writing it back to go.mod. // @@ -975,7 +986,8 @@ // } // // type GoMod struct { -// Module Module +// Module Module +// Go string // Require []Require // Exclude []Module // Replace []Replace @@ -1287,16 +1299,25 @@ // // Usage: // -// go vet [-n] [-x] [build flags] [vet flags] [packages] +// go vet [-n] [-x] [-vettool prog] [build flags] [vet flags] [packages] // // Vet runs the Go vet command on the packages named by the import paths. // // For more about vet and its flags, see 'go doc cmd/vet'. // For more about specifying packages, see 'go help packages'. +// For a list of checkers and their flags, see 'go tool vet help'. +// For details of a specific checker such as 'printf', see 'go tool vet help printf'. // // The -n flag prints commands that would be executed. // The -x flag prints commands as they are executed. // +// The -vettool=prog flag selects a different analysis tool with alternative +// or additional checks. +// For example, the 'shadow' analyzer can be built and run using these commands: +// +// go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow +// go vet -vettool=$(which shadow) +// // The build flags supported by go vet are those that control package resolution // and execution, such as -n, -x, -v, -tags, and -toolexec. // For more about these flags, see 'go help build'. @@ -1451,9 +1472,7 @@ // // Each entry in the GOFLAGS list must be a standalone flag. // Because the entries are space-separated, flag values must -// not contain spaces. In some cases, you can provide multiple flag -// values instead: for example, to set '-ldflags=-s -w' -// you can use 'GOFLAGS=-ldflags=-s -ldflags=-w'. +// not contain spaces. // // Environment variables for use with cgo: // @@ -1488,6 +1507,10 @@ // The command to use to compile C++ code. // PKG_CONFIG // Path to pkg-config tool. +// AR +// The command to use to manipulate library archives when +// building with the gccgo compiler. +// The default is 'ar'. // // Architecture-specific environment variables: // @@ -1595,17 +1618,20 @@ // verb followed by arguments. For example: // // module my/thing +// go 1.12 // require other/thing v1.0.2 -// require new/thing v2.3.4 +// require new/thing/v2 v2.3.4 // exclude old/thing v1.2.3 // replace bad/thing v1.4.5 => good/thing v1.4.5 // -// The verbs are module, to define the module path; require, to require -// a particular module at a given version or later; exclude, to exclude -// a particular module version from use; and replace, to replace a module -// version with a different module version. Exclude and replace apply only -// in the main module's go.mod and are ignored in dependencies. -// See https://research.swtch.com/vgo-mvs for details. +// The verbs are +// module, to define the module path; +// go, to set the expected language version; +// require, to require a particular module at a given version or later; +// exclude, to exclude a particular module version from use; and +// replace, to replace a module version with a different module version. +// Exclude and replace apply only in the main module's go.mod and are ignored +// in dependencies. See https://research.swtch.com/vgo-mvs for details. // // The leading verb can be factored out of adjacent lines to create a block, // like in Go imports: @@ -2028,7 +2054,7 @@ // (See 'go help gopath-get' and 'go help gopath'.) // // When using modules, downloaded packages are stored in the module cache. -// (See 'go help modules-get' and 'go help goproxy'.) +// (See 'go help module-get' and 'go help goproxy'.) // // When using modules, an additional variant of the go-import meta tag is // recognized and is preferred over those listing version control systems. @@ -2490,7 +2516,7 @@ // In general, adding a new dependency may require upgrading // existing dependencies to keep a working build, and 'go get' does // this automatically. Similarly, downgrading one dependency may -// require downgrading other dependenceis, and 'go get' does +// require downgrading other dependencies, and 'go get' does // this automatically as well. // // The -m flag instructs get to stop here, after resolving, upgrading, @@ -2652,6 +2678,8 @@ // Run enough iterations of each benchmark to take t, specified // as a time.Duration (for example, -benchtime 1h30s). // The default is 1 second (1s). +// The special syntax Nx means to run the benchmark N times +// (for example, -benchtime 100x). // // -count n // Run each test and benchmark n times (default 1). diff --git a/libgo/go/cmd/go/go_test.go b/libgo/go/cmd/go/go_test.go index e88338815c3..63549cfded6 100644 --- a/libgo/go/cmd/go/go_test.go +++ b/libgo/go/cmd/go/go_test.go @@ -6,6 +6,8 @@ package main_test import ( "bytes" + "cmd/internal/sys" + "context" "debug/elf" "debug/macho" "flag" @@ -107,6 +109,12 @@ var testGo string var testTmpDir string var testBin string +// testCtx is canceled when the test binary is about to time out. +// +// If https://golang.org/issue/28135 is accepted, uses of this variable in test +// functions should be replaced by t.Context(). +var testCtx = context.Background() + // The TestMain function creates a go command for testing purposes and // deletes it after the tests have been run. func TestMain(m *testing.M) { @@ -119,6 +127,20 @@ func TestMain(m *testing.M) { os.Unsetenv("GOROOT_FINAL") flag.Parse() + + timeoutFlag := flag.Lookup("test.timeout") + if timeoutFlag != nil { + // TODO(golang.org/issue/28147): The go command does not pass the + // test.timeout flag unless either -timeout or -test.timeout is explicitly + // set on the command line. + if d := timeoutFlag.Value.(flag.Getter).Get().(time.Duration); d != 0 { + aBitShorter := d * 95 / 100 + var cancel context.CancelFunc + testCtx, cancel = context.WithTimeout(testCtx, aBitShorter) + defer cancel() + } + } + if *proxyAddr != "" { StartProxy() select {} @@ -209,15 +231,13 @@ func TestMain(m *testing.M) { } testGOCACHE = strings.TrimSpace(string(out)) - // As of Sept 2017, MSan is only supported on linux/amd64. - // https://github.com/google/sanitizers/wiki/MemorySanitizer#getting-memorysanitizer - canMSan = canCgo && runtime.GOOS == "linux" && runtime.GOARCH == "amd64" - - switch runtime.GOOS { - case "linux", "darwin", "freebsd", "windows": - // The race detector doesn't work on Alpine Linux: - // golang.org/issue/14481 - canRace = canCgo && runtime.GOARCH == "amd64" && !isAlpineLinux() && runtime.Compiler != "gccgo" + canMSan = canCgo && sys.MSanSupported(runtime.GOOS, runtime.GOARCH) + canRace = canCgo && sys.RaceDetectorSupported(runtime.GOOS, runtime.GOARCH) + // The race detector doesn't work on Alpine Linux: + // golang.org/issue/14481 + // gccgo does not support the race detector. + if isAlpineLinux() || runtime.Compiler == "gccgo" { + canRace = false } } // Don't let these environment variables confuse the test. @@ -1075,6 +1095,8 @@ func testMove(t *testing.T, vcs, url, base, config string) { defer tg.cleanup() tg.parallel() tg.tempDir("src") + tg.must(os.Mkdir(tg.path(".hg"), 0700)) + tg.must(ioutil.WriteFile(filepath.Join(tg.path(".hg"), "hgrc"), nil, 0600)) tg.setenv("GOPATH", tg.path(".")) tg.run("get", "-d", url) tg.run("get", "-d", "-u", url) @@ -1089,7 +1111,7 @@ func testMove(t *testing.T, vcs, url, base, config string) { path := tg.path(filepath.Join("src", config)) data, err := ioutil.ReadFile(path) tg.must(err) - data = bytes.Replace(data, []byte(base), []byte(base+"XXX"), -1) + data = bytes.ReplaceAll(data, []byte(base), []byte(base+"XXX")) tg.must(ioutil.WriteFile(path, data, 0644)) } if vcs == "git" { @@ -1185,22 +1207,6 @@ func TestImportCycle(t *testing.T) { tg.run("list", "-e", "-json", "selfimport") } -func TestListImportMap(t *testing.T) { - skipIfGccgo(t, "gccgo does not have standard packages") - tg := testgo(t) - defer tg.cleanup() - tg.parallel() - tg.run("list", "-f", "{{.ImportPath}}: {{.ImportMap}}", "net", "fmt") - tg.grepStdout(`^net: map\[(.* )?golang_org/x/net/dns/dnsmessage:vendor/golang_org/x/net/dns/dnsmessage.*\]`, "net/http should have rewritten dnsmessage import") - tg.grepStdout(`^fmt: map\[\]`, "fmt should have no rewritten imports") - tg.run("list", "-deps", "-test", "-f", "{{.ImportPath}} MAP: {{.ImportMap}}\n{{.ImportPath}} IMPORT: {{.Imports}}", "fmt") - tg.grepStdout(`^flag \[fmt\.test\] MAP: map\[fmt:fmt \[fmt\.test\]\]`, "flag [fmt.test] should import fmt [fmt.test] as fmt") - tg.grepStdout(`^fmt\.test MAP: map\[(.* )?testing:testing \[fmt\.test\]`, "fmt.test should import testing [fmt.test] as testing") - tg.grepStdout(`^fmt\.test MAP: map\[(.* )?testing:testing \[fmt\.test\]`, "fmt.test should import testing [fmt.test] as testing") - tg.grepStdoutNot(`^fmt\.test MAP: map\[(.* )?os:`, "fmt.test should not import a modified os") - tg.grepStdout(`^fmt\.test IMPORT: \[fmt \[fmt\.test\] fmt_test \[fmt\.test\] os testing \[fmt\.test\] testing/internal/testdeps \[fmt\.test\]\]`, "wrong imports for fmt.test") -} - // cmd/go: custom import path checking should not apply to Go packages without import comment. func TestIssue10952(t *testing.T) { testenv.MustHaveExternalNetwork(t) @@ -1421,6 +1427,7 @@ func TestRelativeGOBINFail(t *testing.T) { tg.tempFile("triv.go", `package main; func main() {}`) tg.cd(tg.path(".")) tg.setenv("GOBIN", ".") + tg.cd(tg.path(".")) tg.runFail("install") tg.grepStderr("cannot install, GOBIN must be an absolute path", "go install must fail if $GOBIN is a relative path") } @@ -1440,8 +1447,38 @@ func TestInstallIntoGOPATH(t *testing.T) { func TestBuildOutputToDevNull(t *testing.T) { tg := testgo(t) defer tg.cleanup() + fi1, err1 := os.Lstat(os.DevNull) tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata")) tg.run("build", "-o", os.DevNull, "go-cmd-test") + fi2, err2 := os.Lstat(os.DevNull) + if err1 == nil { + if err2 != nil { + t.Errorf("second stat of /dev/null failed: %v", err2) + } else if !os.SameFile(fi1, fi2) { + t.Errorf("/dev/null changed: now %v was %v", fi1, fi2) + } + } +} + +// Issue 28549. +func TestTestOutputToDevNull(t *testing.T) { + tg := testgo(t) + defer tg.cleanup() + fi1, err1 := os.Lstat(os.DevNull) + tg.makeTempdir() + tg.setenv("GOPATH", tg.path(".")) + tg.tempFile("src/p/p.go", "package p\n") + tg.tempFile("src/p/p_test.go", "package p\nimport \"testing\"\nfunc TestX(t *testing.T) {}\n") + tg.run("test", "-o", os.DevNull, "-c", "p") + tg.mustNotExist("p.test") + fi2, err2 := os.Lstat(os.DevNull) + if err1 == nil { + if err2 != nil { + t.Errorf("second stat of /dev/null failed: %v", err2) + } else if !os.SameFile(fi1, fi2) { + t.Errorf("/dev/null changed: now %v was %v", fi1, fi2) + } + } } func TestPackageMainTestImportsArchiveNotBinary(t *testing.T) { @@ -1735,11 +1772,11 @@ func TestGoListDeps(t *testing.T) { if runtime.Compiler != "gccgo" { // Check the list is in dependency order. tg.run("list", "-deps", "math") - want := "internal/cpu\nunsafe\nmath\n" + want := "internal/cpu\nunsafe\nmath/bits\nmath\n" out := tg.stdout.String() if !strings.Contains(out, "internal/cpu") { // Some systems don't use internal/cpu. - want = "unsafe\nmath\n" + want = "unsafe\nmath/bits\nmath\n" } if tg.stdout.String() != want { t.Fatalf("list -deps math: wrong order\nhave %q\nwant %q", tg.stdout.String(), want) @@ -2359,14 +2396,14 @@ func TestShadowingLogic(t *testing.T) { // The math in root1 is not "math" because the standard math is. tg.run("list", "-f", "({{.ImportPath}}) ({{.ConflictDir}})", "./testdata/shadow/root1/src/math") - pwdForwardSlash := strings.Replace(pwd, string(os.PathSeparator), "/", -1) + pwdForwardSlash := strings.ReplaceAll(pwd, string(os.PathSeparator), "/") if !strings.HasPrefix(pwdForwardSlash, "/") { pwdForwardSlash = "/" + pwdForwardSlash } // The output will have makeImportValid applies, but we only // bother to deal with characters we might reasonably see. for _, r := range " :" { - pwdForwardSlash = strings.Replace(pwdForwardSlash, string(r), "_", -1) + pwdForwardSlash = strings.ReplaceAll(pwdForwardSlash, string(r), "_") } want := "(_" + pwdForwardSlash + "/testdata/shadow/root1/src/math) (" + filepath.Join(runtime.GOROOT(), "src", "math") + ")" if strings.TrimSpace(tg.getStdout()) != want { @@ -2556,7 +2593,7 @@ func TestCoverageErrorLine(t *testing.T) { // It's OK that stderr2 drops the character position in the error, // because of the //line directive (see golang.org/issue/22662). - stderr = strings.Replace(stderr, "p.go:4:2:", "p.go:4:", -1) + stderr = strings.ReplaceAll(stderr, "p.go:4:2:", "p.go:4:") if stderr != stderr2 { t.Logf("test -cover changed error messages:\nbefore:\n%s\n\nafter:\n%s", stderr, stderr2) t.Skip("golang.org/issue/22660") @@ -4027,8 +4064,6 @@ func TestCgoConsistentResults(t *testing.T) { t.Skip("skipping because cgo not enabled") } switch runtime.GOOS { - case "freebsd": - testenv.SkipFlaky(t, 15405) case "solaris": testenv.SkipFlaky(t, 13247) } @@ -4977,7 +5012,8 @@ func TestExecBuildX(t *testing.T) { tg := testgo(t) defer tg.cleanup() - tg.setenv("GOCACHE", "off") + tg.tempDir("cache") + tg.setenv("GOCACHE", tg.path("cache")) tg.tempFile("main.go", `package main; import "C"; func main() { print("hello") }`) src := tg.path("main.go") @@ -5508,30 +5544,6 @@ func TestTestCacheInputs(t *testing.T) { } } -func TestNoCache(t *testing.T) { - switch runtime.GOOS { - case "windows": - t.Skipf("no unwritable directories on %s", runtime.GOOS) - } - if os.Getuid() == 0 { - t.Skip("skipping test because running as root") - } - - tg := testgo(t) - defer tg.cleanup() - tg.parallel() - tg.tempFile("triv.go", `package main; func main() {}`) - tg.must(os.MkdirAll(tg.path("unwritable"), 0555)) - home := "HOME" - if runtime.GOOS == "plan9" { - home = "home" - } - tg.setenv(home, tg.path(filepath.Join("unwritable", "home"))) - tg.unsetenv("GOCACHE") - tg.run("build", "-o", tg.path("triv"), tg.path("triv.go")) - tg.grepStderr("disabling cache", "did not disable cache") -} - func TestTestVet(t *testing.T) { tooSlow(t) tg := testgo(t) @@ -5681,17 +5693,6 @@ func TestFmtLoadErrors(t *testing.T) { tg.run("fmt", "-n", "exclude") } -func TestRelativePkgdir(t *testing.T) { - tooSlow(t) - tg := testgo(t) - defer tg.cleanup() - tg.makeTempdir() - tg.setenv("GOCACHE", "off") - tg.cd(tg.tempdir) - - tg.run("build", "-i", "-pkgdir=.", "runtime") -} - func TestGoTestMinusN(t *testing.T) { // Intent here is to verify that 'go test -n' works without crashing. // This reuses flag_test.go, but really any test would do. @@ -6073,28 +6074,6 @@ func TestDontReportRemoveOfEmptyDir(t *testing.T) { } } -// Issue 23264. -func TestNoRelativeTmpdir(t *testing.T) { - tg := testgo(t) - defer tg.cleanup() - - tg.tempFile("src/a/a.go", `package a`) - tg.cd(tg.path(".")) - tg.must(os.Mkdir("tmp", 0777)) - - tg.setenv("GOCACHE", "off") - tg.setenv("GOPATH", tg.path(".")) - tg.setenv("GOTMPDIR", "tmp") - tg.run("build", "-work", "a") - tg.grepStderr("WORK=[^t]", "work should be absolute path") - - tg.unsetenv("GOTMPDIR") - tg.setenv("TMP", "tmp") // windows - tg.setenv("TMPDIR", "tmp") // unix - tg.run("build", "-work", "a") - tg.grepStderr("WORK=[^t]", "work should be absolute path") -} - // Issue 24704. func TestLinkerTmpDirIsDeleted(t *testing.T) { skipIfGccgo(t, "gccgo does not use cmd/link") @@ -6172,7 +6151,7 @@ func TestCDAndGOPATHAreDifferent(t *testing.T) { testCDAndGOPATHAreDifferent(tg, cd, gopath) if runtime.GOOS == "windows" { - testCDAndGOPATHAreDifferent(tg, cd, strings.Replace(gopath, `\`, `/`, -1)) + testCDAndGOPATHAreDifferent(tg, cd, strings.ReplaceAll(gopath, `\`, `/`)) testCDAndGOPATHAreDifferent(tg, cd, strings.ToUpper(gopath)) testCDAndGOPATHAreDifferent(tg, cd, strings.ToLower(gopath)) } diff --git a/libgo/go/cmd/go/help_test.go b/libgo/go/cmd/go/help_test.go new file mode 100644 index 00000000000..ec6a9d11cbe --- /dev/null +++ b/libgo/go/cmd/go/help_test.go @@ -0,0 +1,28 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !nacl + +package main_test + +import ( + "bytes" + "io/ioutil" + "testing" + + "cmd/go/internal/help" +) + +func TestDocsUpToDate(t *testing.T) { + buf := new(bytes.Buffer) + // Match the command in mkalldocs.sh that generates alldocs.go. + help.Help(buf, []string{"documentation"}) + data, err := ioutil.ReadFile("alldocs.go") + if err != nil { + t.Fatalf("error reading alldocs.go: %v", err) + } + if !bytes.Equal(data, buf.Bytes()) { + t.Errorf("alldocs.go is not up to date; run mkalldocs.sh to regenerate it") + } +} diff --git a/libgo/go/cmd/go/internal/cache/cache.go b/libgo/go/cmd/go/internal/cache/cache.go index 0cf01550ff9..ab84cf6302c 100644 --- a/libgo/go/cmd/go/internal/cache/cache.go +++ b/libgo/go/cmd/go/internal/cache/cache.go @@ -18,6 +18,8 @@ import ( "strconv" "strings" "time" + + "cmd/go/internal/renameio" ) // An ActionID is a cache action key, the hash of a complete description of a @@ -283,7 +285,9 @@ func (c *Cache) Trim() { c.trimSubdir(subdir, cutoff) } - ioutil.WriteFile(filepath.Join(c.dir, "trim.txt"), []byte(fmt.Sprintf("%d", now.Unix())), 0666) + // Ignore errors from here: if we don't write the complete timestamp, the + // cache will appear older than it is, and we'll trim it again next time. + renameio.WriteFile(filepath.Join(c.dir, "trim.txt"), []byte(fmt.Sprintf("%d", now.Unix()))) } // trimSubdir trims a single cache subdirectory. @@ -338,6 +342,8 @@ func (c *Cache) putIndexEntry(id ActionID, out OutputID, size int64, allowVerify } file := c.fileName(id, "a") if err := ioutil.WriteFile(file, entry, 0666); err != nil { + // TODO(bcmills): This Remove potentially races with another go command writing to file. + // Can we eliminate it? os.Remove(file) return err } diff --git a/libgo/go/cmd/go/internal/cache/default.go b/libgo/go/cmd/go/internal/cache/default.go index 02fc1e896f7..f545c147009 100644 --- a/libgo/go/cmd/go/internal/cache/default.go +++ b/libgo/go/cmd/go/internal/cache/default.go @@ -9,8 +9,9 @@ import ( "io/ioutil" "os" "path/filepath" - "runtime" "sync" + + "cmd/go/internal/base" ) // Default returns the default cache to use, or nil if no cache should be used. @@ -35,15 +36,15 @@ See golang.org to learn more about Go. // initDefaultCache does the work of finding the default cache // the first time Default is called. func initDefaultCache() { - dir, showWarnings := defaultDir() - if dir == "off" { - return + dir := DefaultDir() + if dir == "off" || dir == "" { + if defaultDirErr != nil { + base.Fatalf("build cache is required, but could not be located: %v", defaultDirErr) + } + base.Fatalf("build cache is disabled by GOCACHE=off, but required as of Go 1.12") } if err := os.MkdirAll(dir, 0777); err != nil { - if showWarnings { - fmt.Fprintf(os.Stderr, "go: disabling cache (%s) due to initialization failure: %s\n", dir, err) - } - return + base.Fatalf("failed to initialize build cache at %s: %s\n", dir, err) } if _, err := os.Stat(filepath.Join(dir, "README")); err != nil { // Best effort. @@ -52,78 +53,40 @@ func initDefaultCache() { c, err := Open(dir) if err != nil { - if showWarnings { - fmt.Fprintf(os.Stderr, "go: disabling cache (%s) due to initialization failure: %s\n", dir, err) - } - return + base.Fatalf("failed to initialize build cache at %s: %s\n", dir, err) } defaultCache = c } +var ( + defaultDirOnce sync.Once + defaultDir string + defaultDirErr error +) + // DefaultDir returns the effective GOCACHE setting. // It returns "off" if the cache is disabled. func DefaultDir() string { - dir, _ := defaultDir() - return dir -} + // Save the result of the first call to DefaultDir for later use in + // initDefaultCache. cmd/go/main.go explicitly sets GOCACHE so that + // subprocesses will inherit it, but that means initDefaultCache can't + // otherwise distinguish between an explicit "off" and a UserCacheDir error. -// defaultDir returns the effective GOCACHE setting. -// It returns "off" if the cache is disabled. -// The second return value reports whether warnings should -// be shown if the cache fails to initialize. -func defaultDir() (string, bool) { - dir := os.Getenv("GOCACHE") - if dir != "" { - return dir, true - } - - // Compute default location. - // TODO(rsc): This code belongs somewhere else, - // like maybe ioutil.CacheDir or os.CacheDir. - showWarnings := true - switch runtime.GOOS { - case "windows": - dir = os.Getenv("LocalAppData") - if dir == "" { - // Fall back to %AppData%, the old name of - // %LocalAppData% on Windows XP. - dir = os.Getenv("AppData") - } - if dir == "" { - return "off", true + defaultDirOnce.Do(func() { + defaultDir = os.Getenv("GOCACHE") + if defaultDir != "" { + return } - case "darwin": - dir = os.Getenv("HOME") - if dir == "" { - return "off", true + // Compute default location. + dir, err := os.UserCacheDir() + if err != nil { + defaultDir = "off" + defaultDirErr = fmt.Errorf("GOCACHE is not defined and %v", err) + return } - dir += "/Library/Caches" + defaultDir = filepath.Join(dir, "go-build") + }) - case "plan9": - dir = os.Getenv("home") - if dir == "" { - return "off", true - } - // Plan 9 has no established per-user cache directory, - // but $home/lib/xyz is the usual equivalent of $HOME/.xyz on Unix. - dir += "/lib/cache" - - default: // Unix - // https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html - dir = os.Getenv("XDG_CACHE_HOME") - if dir == "" { - dir = os.Getenv("HOME") - if dir == "" { - return "off", true - } - if dir == "/" { - // probably docker run with -u flag - // https://golang.org/issue/26280 - showWarnings = false - } - dir += "/.cache" - } - } - return filepath.Join(dir, "go-build"), showWarnings + return defaultDir } diff --git a/libgo/go/cmd/go/internal/cache/default_unix_test.go b/libgo/go/cmd/go/internal/cache/default_unix_test.go deleted file mode 100644 index a207497a42c..00000000000 --- a/libgo/go/cmd/go/internal/cache/default_unix_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !windows,!darwin,!plan9 - -package cache - -import ( - "os" - "strings" - "testing" -) - -func TestDefaultDir(t *testing.T) { - goCacheDir := "/tmp/test-go-cache" - xdgCacheDir := "/tmp/test-xdg-cache" - homeDir := "/tmp/test-home" - - // undo env changes when finished - defer func(GOCACHE, XDG_CACHE_HOME, HOME string) { - os.Setenv("GOCACHE", GOCACHE) - os.Setenv("XDG_CACHE_HOME", XDG_CACHE_HOME) - os.Setenv("HOME", HOME) - }(os.Getenv("GOCACHE"), os.Getenv("XDG_CACHE_HOME"), os.Getenv("HOME")) - - os.Setenv("GOCACHE", goCacheDir) - os.Setenv("XDG_CACHE_HOME", xdgCacheDir) - os.Setenv("HOME", homeDir) - - dir, showWarnings := defaultDir() - if dir != goCacheDir { - t.Errorf("Cache DefaultDir %q should be $GOCACHE %q", dir, goCacheDir) - } - if !showWarnings { - t.Error("Warnings should be shown when $GOCACHE is set") - } - - os.Unsetenv("GOCACHE") - dir, showWarnings = defaultDir() - if !strings.HasPrefix(dir, xdgCacheDir+"/") { - t.Errorf("Cache DefaultDir %q should be under $XDG_CACHE_HOME %q when $GOCACHE is unset", dir, xdgCacheDir) - } - if !showWarnings { - t.Error("Warnings should be shown when $XDG_CACHE_HOME is set") - } - - os.Unsetenv("XDG_CACHE_HOME") - dir, showWarnings = defaultDir() - if !strings.HasPrefix(dir, homeDir+"/.cache/") { - t.Errorf("Cache DefaultDir %q should be under $HOME/.cache %q when $GOCACHE and $XDG_CACHE_HOME are unset", dir, homeDir+"/.cache") - } - if !showWarnings { - t.Error("Warnings should be shown when $HOME is not /") - } - - os.Unsetenv("HOME") - if dir, _ := defaultDir(); dir != "off" { - t.Error("Cache not disabled when $GOCACHE, $XDG_CACHE_HOME, and $HOME are unset") - } - - os.Setenv("HOME", "/") - if _, showWarnings := defaultDir(); showWarnings { - // https://golang.org/issue/26280 - t.Error("Cache initalization warnings should be squelched when $GOCACHE and $XDG_CACHE_HOME are unset and $HOME is /") - } -} diff --git a/libgo/go/cmd/go/internal/cache/hash.go b/libgo/go/cmd/go/internal/cache/hash.go index 0e45e7db547..e4bb2a34bb4 100644 --- a/libgo/go/cmd/go/internal/cache/hash.go +++ b/libgo/go/cmd/go/internal/cache/hash.go @@ -123,7 +123,7 @@ var hashFileCache struct { m map[string][HashSize]byte } -// HashFile returns the hash of the named file. +// FileHash returns the hash of the named file. // It caches repeated lookups for a given file, // and the cache entry for a file can be initialized // using SetFileHash. diff --git a/libgo/go/cmd/go/internal/clean/clean.go b/libgo/go/cmd/go/internal/clean/clean.go index d023592eedc..32cc80736df 100644 --- a/libgo/go/cmd/go/internal/clean/clean.go +++ b/libgo/go/cmd/go/internal/clean/clean.go @@ -10,6 +10,7 @@ import ( "io/ioutil" "os" "path/filepath" + "strconv" "strings" "time" @@ -17,6 +18,7 @@ import ( "cmd/go/internal/cache" "cmd/go/internal/cfg" "cmd/go/internal/load" + "cmd/go/internal/lockedfile" "cmd/go/internal/modfetch" "cmd/go/internal/modload" "cmd/go/internal/work" @@ -103,18 +105,16 @@ func init() { } func runClean(cmd *base.Command, args []string) { - if len(args) == 0 && modload.Failed() { - // Don't try to clean current directory, - // which will cause modload to base.Fatalf. - } else { + if len(args) > 0 || !modload.Enabled() || modload.HasModRoot() { for _, pkg := range load.PackagesAndErrors(args) { clean(pkg) } } + var b work.Builder + b.Print = fmt.Print + if cleanCache { - var b work.Builder - b.Print = fmt.Print dir := cache.DefaultDir() if dir != "off" { // Remove the cache subdirectories but not the top cache directory. @@ -145,7 +145,20 @@ func runClean(cmd *base.Command, args []string) { // right now are to be ignored. dir := cache.DefaultDir() if dir != "off" { - err := ioutil.WriteFile(filepath.Join(dir, "testexpire.txt"), []byte(fmt.Sprintf("%d\n", time.Now().UnixNano())), 0666) + f, err := lockedfile.Edit(filepath.Join(dir, "testexpire.txt")) + if err == nil { + now := time.Now().UnixNano() + buf, _ := ioutil.ReadAll(f) + prev, _ := strconv.ParseInt(strings.TrimSpace(string(buf)), 10, 64) + if now > prev { + if err = f.Truncate(0); err == nil { + _, err = fmt.Fprintf(f, "%d\n", now) + } + } + if closeErr := f.Close(); err == nil { + err = closeErr + } + } if err != nil { base.Errorf("go clean -testcache: %v", err) } @@ -156,24 +169,15 @@ func runClean(cmd *base.Command, args []string) { if modfetch.PkgMod == "" { base.Fatalf("go clean -modcache: no module cache") } - if err := removeAll(modfetch.PkgMod); err != nil { - base.Errorf("go clean -modcache: %v", err) - } - } -} - -func removeAll(dir string) error { - // Module cache has 0555 directories; make them writable in order to remove content. - filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { - if err != nil { - return nil // ignore errors walking in file system + if cfg.BuildN || cfg.BuildX { + b.Showcmd("", "rm -rf %s", modfetch.PkgMod) } - if info.IsDir() { - os.Chmod(path, 0777) + if !cfg.BuildN { + if err := modfetch.RemoveAll(modfetch.PkgMod); err != nil { + base.Errorf("go clean -modcache: %v", err) + } } - return nil - }) - return os.RemoveAll(dir) + } } var cleaned = map[*load.Package]bool{} diff --git a/libgo/go/cmd/go/internal/cmdflag/flag.go b/libgo/go/cmd/go/internal/cmdflag/flag.go index b2a67e6f74a..7f2c53def8f 100644 --- a/libgo/go/cmd/go/internal/cmdflag/flag.go +++ b/libgo/go/cmd/go/internal/cmdflag/flag.go @@ -79,15 +79,15 @@ func AddKnownFlags(cmd string, defns []*Defn) { // Parse sees if argument i is present in the definitions and if so, // returns its definition, value, and whether it consumed an extra word. -// If the flag begins (cmd+".") it is ignored for the purpose of this function. -func Parse(cmd string, defns []*Defn, args []string, i int) (f *Defn, value string, extra bool) { +// If the flag begins (cmd.Name()+".") it is ignored for the purpose of this function. +func Parse(cmd string, usage func(), defns []*Defn, args []string, i int) (f *Defn, value string, extra bool) { arg := args[i] if strings.HasPrefix(arg, "--") { // reduce two minuses to one arg = arg[1:] } switch arg { case "-?", "-h", "-help": - base.Usage() + usage() } if arg == "" || arg[0] != '-' { return diff --git a/libgo/go/cmd/go/internal/doc/doc.go b/libgo/go/cmd/go/internal/doc/doc.go index 4e7dca082d7..bad05ff9128 100644 --- a/libgo/go/cmd/go/internal/doc/doc.go +++ b/libgo/go/cmd/go/internal/doc/doc.go @@ -106,12 +106,21 @@ Examples: cd go/src/encoding/json; go doc decode Flags: + -all + Show all the documentation for the package. -c Respect case when matching symbols. -cmd Treat a command (package main) like a regular package. Otherwise package main's exported symbols are hidden when showing the package's top-level documentation. + -src + Show the full source code for the symbol. This will + display the full Go source of its declaration and + definition, such as a function definition (including + the body), type declaration or enclosing const + block. The output may therefore include unexported + details. -u Show documentation for unexported as well as exported symbols, methods, and fields. diff --git a/libgo/go/cmd/go/internal/envcmd/env.go b/libgo/go/cmd/go/internal/envcmd/env.go index afadbade38e..ae98d3999a1 100644 --- a/libgo/go/cmd/go/internal/envcmd/env.go +++ b/libgo/go/cmd/go/internal/envcmd/env.go @@ -115,8 +115,10 @@ func findEnv(env []cfg.EnvVar, name string) string { // ExtraEnvVars returns environment variables that should not leak into child processes. func ExtraEnvVars() []cfg.EnvVar { gomod := "" - if modload.Init(); modload.ModRoot != "" { - gomod = filepath.Join(modload.ModRoot, "go.mod") + if modload.HasModRoot() { + gomod = filepath.Join(modload.ModRoot(), "go.mod") + } else if modload.Enabled() { + gomod = os.DevNull } return []cfg.EnvVar{ {Name: "GOMOD", Value: gomod}, @@ -203,7 +205,7 @@ func runEnv(cmd *base.Command, args []string) { fmt.Printf("%s=\"%s\"\n", e.Name, e.Value) case "plan9": if strings.IndexByte(e.Value, '\x00') < 0 { - fmt.Printf("%s='%s'\n", e.Name, strings.Replace(e.Value, "'", "''", -1)) + fmt.Printf("%s='%s'\n", e.Name, strings.ReplaceAll(e.Value, "'", "''")) } else { v := strings.Split(e.Value, "\x00") fmt.Printf("%s=(", e.Name) diff --git a/libgo/go/cmd/go/internal/fix/fix.go b/libgo/go/cmd/go/internal/fix/fix.go index aab164148ff..4d741df2b4f 100644 --- a/libgo/go/cmd/go/internal/fix/fix.go +++ b/libgo/go/cmd/go/internal/fix/fix.go @@ -34,7 +34,7 @@ See also: go fmt, go vet. func runFix(cmd *base.Command, args []string) { printed := false for _, pkg := range load.Packages(args) { - if modload.Enabled() && !pkg.Module.Main { + if modload.Enabled() && pkg.Module != nil && !pkg.Module.Main { if !printed { fmt.Fprintf(os.Stderr, "go: not fixing packages in dependency modules\n") printed = true diff --git a/libgo/go/cmd/go/internal/generate/generate.go b/libgo/go/cmd/go/internal/generate/generate.go index 9482be98aef..7cbc448e6dd 100644 --- a/libgo/go/cmd/go/internal/generate/generate.go +++ b/libgo/go/cmd/go/internal/generate/generate.go @@ -161,7 +161,7 @@ func runGenerate(cmd *base.Command, args []string) { // Even if the arguments are .go files, this loop suffices. printed := false for _, pkg := range load.Packages(args) { - if modload.Enabled() && !pkg.Module.Main { + if modload.Enabled() && pkg.Module != nil && !pkg.Module.Main { if !printed { fmt.Fprintf(os.Stderr, "go: not generating in packages in dependency modules\n") printed = true diff --git a/libgo/go/cmd/go/internal/get/get.go b/libgo/go/cmd/go/internal/get/get.go index e4148bceb04..a314c57160b 100644 --- a/libgo/go/cmd/go/internal/get/get.go +++ b/libgo/go/cmd/go/internal/get/get.go @@ -232,7 +232,7 @@ var downloadCache = map[string]bool{} var downloadRootCache = map[string]bool{} // download runs the download half of the get command -// for the package named by the argument. +// for the package or pattern named by the argument. func download(arg string, parent *load.Package, stk *load.ImportStack, mode int) { if mode&load.ResolveImport != 0 { // Caller is responsible for expanding vendor paths. @@ -402,6 +402,23 @@ func downloadPackage(p *load.Package) error { security = web.Insecure } + // p can be either a real package, or a pseudo-package whose “import path” is + // actually a wildcard pattern. + // Trim the path at the element containing the first wildcard, + // and hope that it applies to the wildcarded parts too. + // This makes 'go get rsc.io/pdf/...' work in a fresh GOPATH. + importPrefix := p.ImportPath + if i := strings.Index(importPrefix, "..."); i >= 0 { + slash := strings.LastIndexByte(importPrefix[:i], '/') + if slash < 0 { + return fmt.Errorf("cannot expand ... in %q", p.ImportPath) + } + importPrefix = importPrefix[:slash] + } + if err := CheckImportPath(importPrefix); err != nil { + return fmt.Errorf("%s: invalid import path: %v", p.ImportPath, err) + } + if p.Internal.Build.SrcRoot != "" { // Directory exists. Look for checkout along path to src. vcs, rootPath, err = vcsFromDir(p.Dir, p.Internal.Build.SrcRoot) @@ -421,7 +438,7 @@ func downloadPackage(p *load.Package) error { } repo = remote if !*getF && err == nil { - if rr, err := RepoRootForImportPath(p.ImportPath, IgnoreMod, security); err == nil { + if rr, err := RepoRootForImportPath(importPrefix, IgnoreMod, security); err == nil { repo := rr.Repo if rr.vcs.resolveRepo != nil { resolved, err := rr.vcs.resolveRepo(rr.vcs, dir, repo) @@ -438,7 +455,7 @@ func downloadPackage(p *load.Package) error { } else { // Analyze the import path to determine the version control system, // repository, and the import path for the root of the repository. - rr, err := RepoRootForImportPath(p.ImportPath, IgnoreMod, security) + rr, err := RepoRootForImportPath(importPrefix, IgnoreMod, security) if err != nil { return err } diff --git a/libgo/go/cmd/go/internal/get/path.go b/libgo/go/cmd/go/internal/get/path.go new file mode 100644 index 00000000000..d443bd28a96 --- /dev/null +++ b/libgo/go/cmd/go/internal/get/path.go @@ -0,0 +1,192 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package get + +import ( + "fmt" + "strings" + "unicode" + "unicode/utf8" +) + +// The following functions are copied verbatim from cmd/go/internal/module/module.go, +// with a change to additionally reject Windows short-names, +// and one to accept arbitrary letters (golang.org/issue/29101). +// +// TODO(bcmills): After the call site for this function is backported, +// consolidate this back down to a single copy. +// +// NOTE: DO NOT MERGE THESE UNTIL WE DECIDE ABOUT ARBITRARY LETTERS IN MODULE MODE. + +// CheckImportPath checks that an import path is valid. +func CheckImportPath(path string) error { + if err := checkPath(path, false); err != nil { + return fmt.Errorf("malformed import path %q: %v", path, err) + } + return nil +} + +// checkPath checks that a general path is valid. +// It returns an error describing why but not mentioning path. +// Because these checks apply to both module paths and import paths, +// the caller is expected to add the "malformed ___ path %q: " prefix. +// fileName indicates whether the final element of the path is a file name +// (as opposed to a directory name). +func checkPath(path string, fileName bool) error { + if !utf8.ValidString(path) { + return fmt.Errorf("invalid UTF-8") + } + if path == "" { + return fmt.Errorf("empty string") + } + if strings.Contains(path, "..") { + return fmt.Errorf("double dot") + } + if strings.Contains(path, "//") { + return fmt.Errorf("double slash") + } + if path[len(path)-1] == '/' { + return fmt.Errorf("trailing slash") + } + elemStart := 0 + for i, r := range path { + if r == '/' { + if err := checkElem(path[elemStart:i], fileName); err != nil { + return err + } + elemStart = i + 1 + } + } + if err := checkElem(path[elemStart:], fileName); err != nil { + return err + } + return nil +} + +// checkElem checks whether an individual path element is valid. +// fileName indicates whether the element is a file name (not a directory name). +func checkElem(elem string, fileName bool) error { + if elem == "" { + return fmt.Errorf("empty path element") + } + if strings.Count(elem, ".") == len(elem) { + return fmt.Errorf("invalid path element %q", elem) + } + if elem[0] == '.' && !fileName { + return fmt.Errorf("leading dot in path element") + } + if elem[len(elem)-1] == '.' { + return fmt.Errorf("trailing dot in path element") + } + + charOK := pathOK + if fileName { + charOK = fileNameOK + } + for _, r := range elem { + if !charOK(r) { + return fmt.Errorf("invalid char %q", r) + } + } + + // Windows disallows a bunch of path elements, sadly. + // See https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file + short := elem + if i := strings.Index(short, "."); i >= 0 { + short = short[:i] + } + for _, bad := range badWindowsNames { + if strings.EqualFold(bad, short) { + return fmt.Errorf("disallowed path element %q", elem) + } + } + + // Reject path components that look like Windows short-names. + // Those usually end in a tilde followed by one or more ASCII digits. + if tilde := strings.LastIndexByte(short, '~'); tilde >= 0 && tilde < len(short)-1 { + suffix := short[tilde+1:] + suffixIsDigits := true + for _, r := range suffix { + if r < '0' || r > '9' { + suffixIsDigits = false + break + } + } + if suffixIsDigits { + return fmt.Errorf("trailing tilde and digits in path element") + } + } + + return nil +} + +// pathOK reports whether r can appear in an import path element. +// +// NOTE: This function DIVERGES from module mode pathOK by accepting Unicode letters. +func pathOK(r rune) bool { + if r < utf8.RuneSelf { + return r == '+' || r == '-' || r == '.' || r == '_' || r == '~' || + '0' <= r && r <= '9' || + 'A' <= r && r <= 'Z' || + 'a' <= r && r <= 'z' + } + return unicode.IsLetter(r) +} + +// fileNameOK reports whether r can appear in a file name. +// For now we allow all Unicode letters but otherwise limit to pathOK plus a few more punctuation characters. +// If we expand the set of allowed characters here, we have to +// work harder at detecting potential case-folding and normalization collisions. +// See note about "safe encoding" below. +func fileNameOK(r rune) bool { + if r < utf8.RuneSelf { + // Entire set of ASCII punctuation, from which we remove characters: + // ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~ + // We disallow some shell special characters: " ' * < > ? ` | + // (Note that some of those are disallowed by the Windows file system as well.) + // We also disallow path separators / : and \ (fileNameOK is only called on path element characters). + // We allow spaces (U+0020) in file names. + const allowed = "!#$%&()+,-.=@[]^_{}~ " + if '0' <= r && r <= '9' || 'A' <= r && r <= 'Z' || 'a' <= r && r <= 'z' { + return true + } + for i := 0; i < len(allowed); i++ { + if rune(allowed[i]) == r { + return true + } + } + return false + } + // It may be OK to add more ASCII punctuation here, but only carefully. + // For example Windows disallows < > \, and macOS disallows :, so we must not allow those. + return unicode.IsLetter(r) +} + +// badWindowsNames are the reserved file path elements on Windows. +// See https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file +var badWindowsNames = []string{ + "CON", + "PRN", + "AUX", + "NUL", + "COM1", + "COM2", + "COM3", + "COM4", + "COM5", + "COM6", + "COM7", + "COM8", + "COM9", + "LPT1", + "LPT2", + "LPT3", + "LPT4", + "LPT5", + "LPT6", + "LPT7", + "LPT8", + "LPT9", +} diff --git a/libgo/go/cmd/go/internal/get/vcs.go b/libgo/go/cmd/go/internal/get/vcs.go index 5cd164f2ff3..a7a2ba32cc3 100644 --- a/libgo/go/cmd/go/internal/get/vcs.go +++ b/libgo/go/cmd/go/internal/get/vcs.go @@ -647,14 +647,7 @@ const ( func RepoRootForImportPath(importPath string, mod ModuleMode, security web.SecurityMode) (*RepoRoot, error) { rr, err := repoRootFromVCSPaths(importPath, "", security, vcsPaths) if err == errUnknownSite { - // If there are wildcards, look up the thing before the wildcard, - // hoping it applies to the wildcarded parts too. - // This makes 'go get rsc.io/pdf/...' work in a fresh GOPATH. - lookup := strings.TrimSuffix(importPath, "/...") - if i := strings.Index(lookup, "/.../"); i >= 0 { - lookup = lookup[:i] - } - rr, err = repoRootForImportDynamic(lookup, mod, security) + rr, err = repoRootForImportDynamic(importPath, mod, security) if err != nil { err = fmt.Errorf("unrecognized import path %q (%v)", importPath, err) } @@ -667,6 +660,7 @@ func RepoRootForImportPath(importPath string, mod ModuleMode, security web.Secur } } + // Should have been taken care of above, but make sure. if err == nil && strings.Contains(importPath, "...") && strings.Contains(rr.Root, "...") { // Do not allow wildcards in the repo root. rr = nil @@ -903,16 +897,16 @@ type metaImport struct { Prefix, VCS, RepoRoot string } -func splitPathHasPrefix(path, prefix []string) bool { - if len(path) < len(prefix) { +// pathPrefix reports whether sub is a prefix of s, +// only considering entire path components. +func pathPrefix(s, sub string) bool { + // strings.HasPrefix is necessary but not sufficient. + if !strings.HasPrefix(s, sub) { return false } - for i, p := range prefix { - if path[i] != p { - return false - } - } - return true + // The remainder after the prefix must either be empty or start with a slash. + rem := s[len(sub):] + return rem == "" || rem[0] == '/' } // A ImportMismatchError is returned where metaImport/s are present @@ -935,13 +929,10 @@ func (m ImportMismatchError) Error() string { // errNoMatch is returned if none match. func matchGoImport(imports []metaImport, importPath string) (metaImport, error) { match := -1 - imp := strings.Split(importPath, "/") errImportMismatch := ImportMismatchError{importPath: importPath} for i, im := range imports { - pre := strings.Split(im.Prefix, "/") - - if !splitPathHasPrefix(imp, pre) { + if !pathPrefix(importPath, im.Prefix) { errImportMismatch.mismatches = append(errImportMismatch.mismatches, im.Prefix) continue } @@ -966,10 +957,14 @@ func matchGoImport(imports []metaImport, importPath string) (metaImport, error) // expand rewrites s to replace {k} with match[k] for each key k in match. func expand(match map[string]string, s string) string { + // We want to replace each match exactly once, and the result of expansion + // must not depend on the iteration order through the map. + // A strings.Replacer has exactly the properties we're looking for. + oldNew := make([]string, 0, 2*len(match)) for k, v := range match { - s = strings.Replace(s, "{"+k+"}", v, -1) + oldNew = append(oldNew, "{"+k+"}", v) } - return s + return strings.NewReplacer(oldNew...).Replace(s) } // vcsPaths defines the meaning of import paths referring to diff --git a/libgo/go/cmd/go/internal/help/help.go b/libgo/go/cmd/go/internal/help/help.go index a80afe36c41..312a29590f4 100644 --- a/libgo/go/cmd/go/internal/help/help.go +++ b/libgo/go/cmd/go/internal/help/help.go @@ -20,16 +20,16 @@ import ( ) // Help implements the 'help' command. -func Help(args []string) { +func Help(w io.Writer, args []string) { // 'go help documentation' generates doc.go. if len(args) == 1 && args[0] == "documentation" { - fmt.Println("// Copyright 2011 The Go Authors. All rights reserved.") - fmt.Println("// Use of this source code is governed by a BSD-style") - fmt.Println("// license that can be found in the LICENSE file.") - fmt.Println() - fmt.Println("// Code generated by mkalldocs.sh; DO NOT EDIT.") - fmt.Println("// Edit the documentation in other files and rerun mkalldocs.sh to generate this one.") - fmt.Println() + fmt.Fprintln(w, "// Copyright 2011 The Go Authors. All rights reserved.") + fmt.Fprintln(w, "// Use of this source code is governed by a BSD-style") + fmt.Fprintln(w, "// license that can be found in the LICENSE file.") + fmt.Fprintln(w) + fmt.Fprintln(w, "// Code generated by mkalldocs.sh; DO NOT EDIT.") + fmt.Fprintln(w, "// Edit the documentation in other files and rerun mkalldocs.sh to generate this one.") + fmt.Fprintln(w) buf := new(bytes.Buffer) PrintUsage(buf, base.Go) usage := &base.Command{Long: buf.String()} @@ -42,8 +42,8 @@ func Help(args []string) { cmds = append(cmds, cmd) cmds = append(cmds, cmd.Commands...) } - tmpl(&commentWriter{W: os.Stdout}, documentationTemplate, cmds) - fmt.Println("package main") + tmpl(&commentWriter{W: w}, documentationTemplate, cmds) + fmt.Fprintln(w, "package main") return } diff --git a/libgo/go/cmd/go/internal/help/helpdoc.go b/libgo/go/cmd/go/internal/help/helpdoc.go index e2c4e61615b..973bfbc611d 100644 --- a/libgo/go/cmd/go/internal/help/helpdoc.go +++ b/libgo/go/cmd/go/internal/help/helpdoc.go @@ -266,7 +266,7 @@ listed in the GOPATH environment variable. (See 'go help gopath-get' and 'go help gopath'.) When using modules, downloaded packages are stored in the module cache. -(See 'go help modules-get' and 'go help goproxy'.) +(See 'go help module-get' and 'go help goproxy'.) When using modules, an additional variant of the go-import meta tag is recognized and is preferred over those listing version control systems. @@ -509,9 +509,7 @@ General-purpose environment variables: Each entry in the GOFLAGS list must be a standalone flag. Because the entries are space-separated, flag values must -not contain spaces. In some cases, you can provide multiple flag -values instead: for example, to set '-ldflags=-s -w' -you can use 'GOFLAGS=-ldflags=-s -ldflags=-w'. +not contain spaces. Environment variables for use with cgo: @@ -546,6 +544,10 @@ Environment variables for use with cgo: The command to use to compile C++ code. PKG_CONFIG Path to pkg-config tool. + AR + The command to use to manipulate library archives when + building with the gccgo compiler. + The default is 'ar'. Architecture-specific environment variables: diff --git a/libgo/go/cmd/go/internal/imports/build.go b/libgo/go/cmd/go/internal/imports/build.go index d1adf9440cb..ddf425b0204 100644 --- a/libgo/go/cmd/go/internal/imports/build.go +++ b/libgo/go/cmd/go/internal/imports/build.go @@ -207,5 +207,5 @@ func init() { } } -const goosList = "android darwin dragonfly freebsd js linux nacl netbsd openbsd plan9 solaris windows zos " +const goosList = "aix android darwin dragonfly freebsd hurd js linux nacl netbsd openbsd plan9 solaris windows zos " const goarchList = "386 amd64 amd64p32 arm armbe arm64 arm64be ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32le ppc riscv riscv64 s390 s390x sparc sparc64 wasm " diff --git a/libgo/go/cmd/go/internal/imports/scan.go b/libgo/go/cmd/go/internal/imports/scan.go index d944e95724e..966a38cfef3 100644 --- a/libgo/go/cmd/go/internal/imports/scan.go +++ b/libgo/go/cmd/go/internal/imports/scan.go @@ -22,6 +22,16 @@ func ScanDir(dir string, tags map[string]bool) ([]string, []string, error) { var files []string for _, info := range infos { name := info.Name() + + // If the directory entry is a symlink, stat it to obtain the info for the + // link target instead of the link itself. + if info.Mode()&os.ModeSymlink != 0 { + info, err = os.Stat(name) + if err != nil { + continue // Ignore broken symlinks. + } + } + if info.Mode().IsRegular() && !strings.HasPrefix(name, "_") && strings.HasSuffix(name, ".go") && MatchFile(name, tags) { files = append(files, filepath.Join(dir, name)) } diff --git a/libgo/go/cmd/go/internal/load/pkg.go b/libgo/go/cmd/go/internal/load/pkg.go index b6c90378881..543250e86c1 100644 --- a/libgo/go/cmd/go/internal/load/pkg.go +++ b/libgo/go/cmd/go/internal/load/pkg.go @@ -440,6 +440,10 @@ const ( // this package, as part of a bigger load operation, and by GOPATH-based "go get". // TODO(rsc): When GOPATH-based "go get" is removed, unexport this function. func LoadImport(path, srcDir string, parent *Package, stk *ImportStack, importPos []token.Position, mode int) *Package { + if path == "" { + panic("LoadImport called with empty package path") + } + stk.Push(path) defer stk.Pop() @@ -999,10 +1003,12 @@ func disallowInternal(srcDir string, importer *Package, importerPath string, p * } else { // p is in a module, so make it available based on the importer's import path instead // of the file path (https://golang.org/issue/23970). - if importerPath == "." { + if importer.Internal.CmdlineFiles { // The importer is a list of command-line files. // Pretend that the import path is the import path of the // directory containing them. + // If the directory is outside the main module, this will resolve to ".", + // which is not a prefix of any valid module. importerPath = ModDirImportPath(importer.Dir) } parentOfInternal := p.ImportPath[:i] @@ -1053,20 +1059,6 @@ func disallowVendor(srcDir string, importer *Package, importerPath, path string, return p } - // Modules must not import vendor packages in the standard library, - // but the usual vendor visibility check will not catch them - // because the module loader presents them with an ImportPath starting - // with "golang_org/" instead of "vendor/". - if p.Standard && !importer.Standard && strings.HasPrefix(p.ImportPath, "golang_org") { - perr := *p - perr.Error = &PackageError{ - ImportStack: stk.Copy(), - Err: "use of vendored package " + path + " not allowed", - } - perr.Incomplete = true - return &perr - } - if perr := disallowVendorVisibility(srcDir, p, stk); perr != p { return perr } @@ -1345,6 +1337,7 @@ func (p *Package) load(stk *ImportStack, bp *build.Package, err error) { // SWIG adds imports of some standard packages. if p.UsesSwig() { + addImport("unsafe", true) if cfg.BuildContext.Compiler != "gccgo" { addImport("runtime/cgo", true) } @@ -1530,9 +1523,13 @@ func (p *Package) load(stk *ImportStack, bp *build.Package, err error) { } if cfg.ModulesEnabled { - p.Module = ModPackageModuleInfo(p.ImportPath) + mainPath := p.ImportPath + if p.Internal.CmdlineFiles { + mainPath = "command-line-arguments" + } + p.Module = ModPackageModuleInfo(mainPath) if p.Name == "main" { - p.Internal.BuildInfo = ModPackageBuildInfo(p.ImportPath, p.Deps) + p.Internal.BuildInfo = ModPackageBuildInfo(mainPath, p.Deps) } } } @@ -1756,6 +1753,9 @@ func LoadPackageNoFlags(arg string, stk *ImportStack) *Package { // loadPackage accepts pseudo-paths beginning with cmd/ to denote commands // in the Go command directory, as well as paths to those directories. func loadPackage(arg string, stk *ImportStack) *Package { + if arg == "" { + panic("loadPackage called with empty package path") + } if build.IsLocalImport(arg) { dir := arg if !filepath.IsAbs(dir) { @@ -1779,9 +1779,6 @@ func loadPackage(arg string, stk *ImportStack) *Package { bp.ImportPath = arg bp.Goroot = true bp.BinDir = cfg.GOROOTbin - if cfg.GOROOTbin != "" { - bp.BinDir = cfg.GOROOTbin - } bp.Root = cfg.GOROOT bp.SrcRoot = cfg.GOROOTsrc p := new(Package) @@ -1854,6 +1851,9 @@ func PackagesAndErrors(patterns []string) []*Package { for _, m := range matches { for _, pkg := range m.Pkgs { + if pkg == "" { + panic(fmt.Sprintf("ImportPaths returned empty package for pattern %s", m.Pattern)) + } p := loadPackage(pkg, &stk) p.Match = append(p.Match, m.Pattern) p.Internal.CmdlinePkg = true @@ -1996,11 +1996,6 @@ func GoFilesPackage(gofiles []string) *Package { } bp, err := ctxt.ImportDir(dir, 0) - if ModDirImportPath != nil { - // Use the effective import path of the directory - // for deciding visibility during pkg.load. - bp.ImportPath = ModDirImportPath(dir) - } pkg := new(Package) pkg.Internal.Local = true pkg.Internal.CmdlineFiles = true diff --git a/libgo/go/cmd/go/internal/load/test.go b/libgo/go/cmd/go/internal/load/test.go index 0eab21b1761..5f9daa49578 100644 --- a/libgo/go/cmd/go/internal/load/test.go +++ b/libgo/go/cmd/go/internal/load/test.go @@ -227,6 +227,12 @@ func GetTestPackagesFor(p *Package, cover *TestCover) (pmain, ptest, pxtest *Pac } } + allTestImports := make([]*Package, 0, len(pmain.Internal.Imports)+len(imports)+len(ximports)) + allTestImports = append(allTestImports, pmain.Internal.Imports...) + allTestImports = append(allTestImports, imports...) + allTestImports = append(allTestImports, ximports...) + setToolFlags(allTestImports...) + // Do initial scan for metadata needed for writing _testmain.go // Use that metadata to update the list of imports for package main. // The list of imports is used by recompileForTest and by the loop diff --git a/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock.go b/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock.go new file mode 100644 index 00000000000..aba3eed7767 --- /dev/null +++ b/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock.go @@ -0,0 +1,98 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package filelock provides a platform-independent API for advisory file +// locking. Calls to functions in this package on platforms that do not support +// advisory locks will return errors for which IsNotSupported returns true. +package filelock + +import ( + "errors" + "os" +) + +// A File provides the minimal set of methods required to lock an open file. +// File implementations must be usable as map keys. +// The usual implementation is *os.File. +type File interface { + // Name returns the name of the file. + Name() string + + // Fd returns a valid file descriptor. + // (If the File is an *os.File, it must not be closed.) + Fd() uintptr + + // Stat returns the FileInfo structure describing file. + Stat() (os.FileInfo, error) +} + +// Lock places an advisory write lock on the file, blocking until it can be +// locked. +// +// If Lock returns nil, no other process will be able to place a read or write +// lock on the file until this process exits, closes f, or calls Unlock on it. +// +// If f's descriptor is already read- or write-locked, the behavior of Lock is +// unspecified. +// +// Closing the file may or may not release the lock promptly. Callers should +// ensure that Unlock is always called when Lock succeeds. +func Lock(f File) error { + return lock(f, writeLock) +} + +// RLock places an advisory read lock on the file, blocking until it can be locked. +// +// If RLock returns nil, no other process will be able to place a write lock on +// the file until this process exits, closes f, or calls Unlock on it. +// +// If f is already read- or write-locked, the behavior of RLock is unspecified. +// +// Closing the file may or may not release the lock promptly. Callers should +// ensure that Unlock is always called if RLock succeeds. +func RLock(f File) error { + return lock(f, readLock) +} + +// Unlock removes an advisory lock placed on f by this process. +// +// The caller must not attempt to unlock a file that is not locked. +func Unlock(f File) error { + return unlock(f) +} + +// String returns the name of the function corresponding to lt +// (Lock, RLock, or Unlock). +func (lt lockType) String() string { + switch lt { + case readLock: + return "RLock" + case writeLock: + return "Lock" + default: + return "Unlock" + } +} + +// IsNotSupported returns a boolean indicating whether the error is known to +// report that a function is not supported (possibly for a specific input). +// It is satisfied by ErrNotSupported as well as some syscall errors. +func IsNotSupported(err error) bool { + return isNotSupported(underlyingError(err)) +} + +var ErrNotSupported = errors.New("operation not supported") + +// underlyingError returns the underlying error for known os error types. +func underlyingError(err error) error { + switch err := err.(type) { + case *os.PathError: + return err.Err + case *os.LinkError: + return err.Err + case *os.SyscallError: + return err.Err + } + return err +} diff --git a/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_fcntl.go b/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_fcntl.go new file mode 100644 index 00000000000..2831975c0c6 --- /dev/null +++ b/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_fcntl.go @@ -0,0 +1,159 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build aix solaris + +// This code implements the filelock API using POSIX 'fcntl' locks, which attach +// to an (inode, process) pair rather than a file descriptor. To avoid unlocking +// files prematurely when the same file is opened through different descriptors, +// we allow only one read-lock at a time. +// +// Most platforms provide some alternative API, such as an 'flock' system call +// or an F_OFD_SETLK command for 'fcntl', that allows for better concurrency and +// does not require per-inode bookkeeping in the application. +// +// TODO(bcmills): If we add a build tag for Illumos (see golang.org/issue/20603) +// then Illumos should use F_OFD_SETLK, and the resulting code would be as +// simple as filelock_unix.go. We will still need the code in this file for AIX +// or as long as Oracle Solaris provides only F_SETLK. + +package filelock + +import ( + "errors" + "io" + "os" + "sync" + "syscall" +) + +type lockType int16 + +const ( + readLock lockType = syscall.F_RDLCK + writeLock lockType = syscall.F_WRLCK +) + +type inode = uint64 // type of syscall.Stat_t.Ino + +type inodeLock struct { + owner File + queue []<-chan File +} + +type token struct{} + +var ( + mu sync.Mutex + inodes = map[File]inode{} + locks = map[inode]inodeLock{} +) + +func lock(f File, lt lockType) (err error) { + // POSIX locks apply per inode and process, and the lock for an inode is + // released when *any* descriptor for that inode is closed. So we need to + // synchronize access to each inode internally, and must serialize lock and + // unlock calls that refer to the same inode through different descriptors. + fi, err := f.Stat() + if err != nil { + return err + } + ino := fi.Sys().(*syscall.Stat_t).Ino + + mu.Lock() + if i, dup := inodes[f]; dup && i != ino { + mu.Unlock() + return &os.PathError{ + Op: lt.String(), + Path: f.Name(), + Err: errors.New("inode for file changed since last Lock or RLock"), + } + } + inodes[f] = ino + + var wait chan File + l := locks[ino] + if l.owner == f { + // This file already owns the lock, but the call may change its lock type. + } else if l.owner == nil { + // No owner: it's ours now. + l.owner = f + } else { + // Already owned: add a channel to wait on. + wait = make(chan File) + l.queue = append(l.queue, wait) + } + locks[ino] = l + mu.Unlock() + + if wait != nil { + wait <- f + } + + err = setlkw(f.Fd(), lt) + + if err != nil { + unlock(f) + return &os.PathError{ + Op: lt.String(), + Path: f.Name(), + Err: err, + } + } + + return nil +} + +func unlock(f File) error { + var owner File + + mu.Lock() + ino, ok := inodes[f] + if ok { + owner = locks[ino].owner + } + mu.Unlock() + + if owner != f { + panic("unlock called on a file that is not locked") + } + + err := setlkw(f.Fd(), syscall.F_UNLCK) + + mu.Lock() + l := locks[ino] + if len(l.queue) == 0 { + // No waiters: remove the map entry. + delete(locks, ino) + } else { + // The first waiter is sending us their file now. + // Receive it and update the queue. + l.owner = <-l.queue[0] + l.queue = l.queue[1:] + locks[ino] = l + } + delete(inodes, f) + mu.Unlock() + + return err +} + +// setlkw calls FcntlFlock with F_SETLKW for the entire file indicated by fd. +func setlkw(fd uintptr, lt lockType) error { + for { + err := syscall.FcntlFlock(fd, syscall.F_SETLKW, &syscall.Flock_t{ + Type: int16(lt), + Whence: io.SeekStart, + Start: 0, + Len: 0, // All bytes. + }) + if err != syscall.EINTR { + return err + } + } +} + +func isNotSupported(err error) bool { + return err == syscall.ENOSYS || err == syscall.ENOTSUP || err == syscall.EOPNOTSUPP || err == ErrNotSupported +} diff --git a/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_other.go b/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_other.go new file mode 100644 index 00000000000..107611e1ce8 --- /dev/null +++ b/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_other.go @@ -0,0 +1,36 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!plan9,!solaris,!windows + +package filelock + +import "os" + +type lockType int8 + +const ( + readLock = iota + 1 + writeLock +) + +func lock(f File, lt lockType) error { + return &os.PathError{ + Op: lt.String(), + Path: f.Name(), + Err: ErrNotSupported, + } +} + +func unlock(f File) error { + return &os.PathError{ + Op: "Unlock", + Path: f.Name(), + Err: ErrNotSupported, + } +} + +func isNotSupported(err error) bool { + return err == ErrNotSupported +} diff --git a/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_plan9.go b/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_plan9.go new file mode 100644 index 00000000000..afdffe323fc --- /dev/null +++ b/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_plan9.go @@ -0,0 +1,38 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build plan9 + +package filelock + +import ( + "os" +) + +type lockType int8 + +const ( + readLock = iota + 1 + writeLock +) + +func lock(f File, lt lockType) error { + return &os.PathError{ + Op: lt.String(), + Path: f.Name(), + Err: ErrNotSupported, + } +} + +func unlock(f File) error { + return &os.PathError{ + Op: "Unlock", + Path: f.Name(), + Err: ErrNotSupported, + } +} + +func isNotSupported(err error) bool { + return err == ErrNotSupported +} diff --git a/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_test.go b/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_test.go new file mode 100644 index 00000000000..aa67093a48a --- /dev/null +++ b/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_test.go @@ -0,0 +1,209 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !js,!nacl,!plan9 + +package filelock_test + +import ( + "fmt" + "internal/testenv" + "io/ioutil" + "os" + "os/exec" + "path/filepath" + "runtime" + "testing" + "time" + + "cmd/go/internal/lockedfile/internal/filelock" +) + +func lock(t *testing.T, f *os.File) { + t.Helper() + err := filelock.Lock(f) + t.Logf("Lock(fd %d) = %v", f.Fd(), err) + if err != nil { + t.Fail() + } +} + +func rLock(t *testing.T, f *os.File) { + t.Helper() + err := filelock.RLock(f) + t.Logf("RLock(fd %d) = %v", f.Fd(), err) + if err != nil { + t.Fail() + } +} + +func unlock(t *testing.T, f *os.File) { + t.Helper() + err := filelock.Unlock(f) + t.Logf("Unlock(fd %d) = %v", f.Fd(), err) + if err != nil { + t.Fail() + } +} + +func mustTempFile(t *testing.T) (f *os.File, remove func()) { + t.Helper() + + base := filepath.Base(t.Name()) + f, err := ioutil.TempFile("", base) + if err != nil { + t.Fatalf(`ioutil.TempFile("", %q) = %v`, base, err) + } + t.Logf("fd %d = %s", f.Fd(), f.Name()) + + return f, func() { + f.Close() + os.Remove(f.Name()) + } +} + +func mustOpen(t *testing.T, name string) *os.File { + t.Helper() + + f, err := os.OpenFile(name, os.O_RDWR, 0) + if err != nil { + t.Fatalf("os.Open(%q) = %v", name, err) + } + + t.Logf("fd %d = os.Open(%q)", f.Fd(), name) + return f +} + +const ( + quiescent = 10 * time.Millisecond + probablyStillBlocked = 10 * time.Second +) + +func mustBlock(t *testing.T, op string, f *os.File) (wait func(*testing.T)) { + t.Helper() + + desc := fmt.Sprintf("%s(fd %d)", op, f.Fd()) + + done := make(chan struct{}) + go func() { + t.Helper() + switch op { + case "Lock": + lock(t, f) + case "RLock": + rLock(t, f) + default: + panic("invalid op: " + op) + } + close(done) + }() + + select { + case <-done: + t.Fatalf("%s unexpectedly did not block", desc) + return nil + + case <-time.After(quiescent): + t.Logf("%s is blocked (as expected)", desc) + return func(t *testing.T) { + t.Helper() + select { + case <-time.After(probablyStillBlocked): + t.Fatalf("%s is unexpectedly still blocked", desc) + case <-done: + } + } + } +} + +func TestLockExcludesLock(t *testing.T) { + t.Parallel() + + f, remove := mustTempFile(t) + defer remove() + + other := mustOpen(t, f.Name()) + defer other.Close() + + lock(t, f) + lockOther := mustBlock(t, "Lock", other) + unlock(t, f) + lockOther(t) + unlock(t, other) +} + +func TestLockExcludesRLock(t *testing.T) { + t.Parallel() + + f, remove := mustTempFile(t) + defer remove() + + other := mustOpen(t, f.Name()) + defer other.Close() + + lock(t, f) + rLockOther := mustBlock(t, "RLock", other) + unlock(t, f) + rLockOther(t) + unlock(t, other) +} + +func TestRLockExcludesOnlyLock(t *testing.T) { + t.Parallel() + + f, remove := mustTempFile(t) + defer remove() + rLock(t, f) + + f2 := mustOpen(t, f.Name()) + defer f2.Close() + + if runtime.GOOS == "solaris" || runtime.GOOS == "aix" { + // When using POSIX locks (as on Solaris), we can't safely read-lock the + // same inode through two different descriptors at the same time: when the + // first descriptor is closed, the second descriptor would still be open but + // silently unlocked. So a second RLock must block instead of proceeding. + lockF2 := mustBlock(t, "RLock", f2) + unlock(t, f) + lockF2(t) + } else { + rLock(t, f2) + } + + other := mustOpen(t, f.Name()) + defer other.Close() + lockOther := mustBlock(t, "Lock", other) + + unlock(t, f2) + if runtime.GOOS != "solaris" && runtime.GOOS != "aix" { + unlock(t, f) + } + lockOther(t) + unlock(t, other) +} + +func TestLockNotDroppedByExecCommand(t *testing.T) { + testenv.MustHaveExec(t) + + f, remove := mustTempFile(t) + defer remove() + + lock(t, f) + + other := mustOpen(t, f.Name()) + defer other.Close() + + // Some kinds of file locks are dropped when a duplicated or forked file + // descriptor is unlocked. Double-check that the approach used by os/exec does + // not accidentally drop locks. + cmd := exec.Command(os.Args[0], "-test.run=^$") + if err := cmd.Run(); err != nil { + t.Fatalf("exec failed: %v", err) + } + + lockOther := mustBlock(t, "Lock", other) + unlock(t, f) + lockOther(t) + unlock(t, other) +} diff --git a/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_unix.go b/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_unix.go new file mode 100644 index 00000000000..00c42628322 --- /dev/null +++ b/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_unix.go @@ -0,0 +1,44 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build darwin dragonfly freebsd linux netbsd openbsd + +package filelock + +import ( + "os" + "syscall" +) + +type lockType int16 + +const ( + readLock lockType = syscall.LOCK_SH + writeLock lockType = syscall.LOCK_EX +) + +func lock(f File, lt lockType) (err error) { + for { + err = syscall.Flock(int(f.Fd()), int(lt)) + if err != syscall.EINTR { + break + } + } + if err != nil { + return &os.PathError{ + Op: lt.String(), + Path: f.Name(), + Err: err, + } + } + return nil +} + +func unlock(f File) error { + return lock(f, syscall.LOCK_UN) +} + +func isNotSupported(err error) bool { + return err == syscall.ENOSYS || err == syscall.ENOTSUP || err == syscall.EOPNOTSUPP || err == ErrNotSupported +} diff --git a/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_windows.go b/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_windows.go new file mode 100644 index 00000000000..43e85e450ec --- /dev/null +++ b/libgo/go/cmd/go/internal/lockedfile/internal/filelock/filelock_windows.go @@ -0,0 +1,66 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows + +package filelock + +import ( + "internal/syscall/windows" + "os" + "syscall" +) + +type lockType uint32 + +const ( + readLock lockType = 0 + writeLock lockType = windows.LOCKFILE_EXCLUSIVE_LOCK +) + +const ( + reserved = 0 + allBytes = ^uint32(0) +) + +func lock(f File, lt lockType) error { + // Per https://golang.org/issue/19098, “Programs currently expect the Fd + // method to return a handle that uses ordinary synchronous I/O.” + // However, LockFileEx still requires an OVERLAPPED structure, + // which contains the file offset of the beginning of the lock range. + // We want to lock the entire file, so we leave the offset as zero. + ol := new(syscall.Overlapped) + + err := windows.LockFileEx(syscall.Handle(f.Fd()), uint32(lt), reserved, allBytes, allBytes, ol) + if err != nil { + return &os.PathError{ + Op: lt.String(), + Path: f.Name(), + Err: err, + } + } + return nil +} + +func unlock(f File) error { + ol := new(syscall.Overlapped) + err := windows.UnlockFileEx(syscall.Handle(f.Fd()), reserved, allBytes, allBytes, ol) + if err != nil { + return &os.PathError{ + Op: "Unlock", + Path: f.Name(), + Err: err, + } + } + return nil +} + +func isNotSupported(err error) bool { + switch err { + case windows.ERROR_NOT_SUPPORTED, windows.ERROR_CALL_NOT_IMPLEMENTED, ErrNotSupported: + return true + default: + return false + } +} diff --git a/libgo/go/cmd/go/internal/lockedfile/lockedfile.go b/libgo/go/cmd/go/internal/lockedfile/lockedfile.go new file mode 100644 index 00000000000..bb184b1085e --- /dev/null +++ b/libgo/go/cmd/go/internal/lockedfile/lockedfile.go @@ -0,0 +1,122 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package lockedfile creates and manipulates files whose contents should only +// change atomically. +package lockedfile + +import ( + "fmt" + "io" + "io/ioutil" + "os" + "runtime" +) + +// A File is a locked *os.File. +// +// Closing the file releases the lock. +// +// If the program exits while a file is locked, the operating system releases +// the lock but may not do so promptly: callers must ensure that all locked +// files are closed before exiting. +type File struct { + osFile + closed bool +} + +// osFile embeds a *os.File while keeping the pointer itself unexported. +// (When we close a File, it must be the same file descriptor that we opened!) +type osFile struct { + *os.File +} + +// OpenFile is like os.OpenFile, but returns a locked file. +// If flag includes os.O_WRONLY or os.O_RDWR, the file is write-locked; +// otherwise, it is read-locked. +func OpenFile(name string, flag int, perm os.FileMode) (*File, error) { + var ( + f = new(File) + err error + ) + f.osFile.File, err = openFile(name, flag, perm) + if err != nil { + return nil, err + } + + // Although the operating system will drop locks for open files when the go + // command exits, we want to hold locks for as little time as possible, and we + // especially don't want to leave a file locked after we're done with it. Our + // Close method is what releases the locks, so use a finalizer to report + // missing Close calls on a best-effort basis. + runtime.SetFinalizer(f, func(f *File) { + panic(fmt.Sprintf("lockedfile.File %s became unreachable without a call to Close", f.Name())) + }) + + return f, nil +} + +// Open is like os.Open, but returns a read-locked file. +func Open(name string) (*File, error) { + return OpenFile(name, os.O_RDONLY, 0) +} + +// Create is like os.Create, but returns a write-locked file. +func Create(name string) (*File, error) { + return OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666) +} + +// Edit creates the named file with mode 0666 (before umask), +// but does not truncate existing contents. +// +// If Edit succeeds, methods on the returned File can be used for I/O. +// The associated file descriptor has mode O_RDWR and the file is write-locked. +func Edit(name string) (*File, error) { + return OpenFile(name, os.O_RDWR|os.O_CREATE, 0666) +} + +// Close unlocks and closes the underlying file. +// +// Close may be called multiple times; all calls after the first will return a +// non-nil error. +func (f *File) Close() error { + if f.closed { + return &os.PathError{ + Op: "close", + Path: f.Name(), + Err: os.ErrClosed, + } + } + f.closed = true + + err := closeFile(f.osFile.File) + runtime.SetFinalizer(f, nil) + return err +} + +// Read opens the named file with a read-lock and returns its contents. +func Read(name string) ([]byte, error) { + f, err := Open(name) + if err != nil { + return nil, err + } + defer f.Close() + + return ioutil.ReadAll(f) +} + +// Write opens the named file (creating it with the given permissions if needed), +// then write-locks it and overwrites it with the given content. +func Write(name string, content io.Reader, perm os.FileMode) (err error) { + f, err := OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, perm) + if err != nil { + return err + } + + _, err = io.Copy(f, content) + if closeErr := f.Close(); err == nil { + err = closeErr + } + return err +} diff --git a/libgo/go/cmd/go/internal/lockedfile/lockedfile_filelock.go b/libgo/go/cmd/go/internal/lockedfile/lockedfile_filelock.go new file mode 100644 index 00000000000..f63dd8664b0 --- /dev/null +++ b/libgo/go/cmd/go/internal/lockedfile/lockedfile_filelock.go @@ -0,0 +1,64 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !plan9 + +package lockedfile + +import ( + "os" + + "cmd/go/internal/lockedfile/internal/filelock" +) + +func openFile(name string, flag int, perm os.FileMode) (*os.File, error) { + // On BSD systems, we could add the O_SHLOCK or O_EXLOCK flag to the OpenFile + // call instead of locking separately, but we have to support separate locking + // calls for Linux and Windows anyway, so it's simpler to use that approach + // consistently. + + f, err := os.OpenFile(name, flag&^os.O_TRUNC, perm) + if err != nil { + return nil, err + } + + switch flag & (os.O_RDONLY | os.O_WRONLY | os.O_RDWR) { + case os.O_WRONLY, os.O_RDWR: + err = filelock.Lock(f) + default: + err = filelock.RLock(f) + } + if err != nil { + f.Close() + return nil, err + } + + if flag&os.O_TRUNC == os.O_TRUNC { + if err := f.Truncate(0); err != nil { + // The documentation for os.O_TRUNC says “if possible, truncate file when + // opened”, but doesn't define “possible” (golang.org/issue/28699). + // We'll treat regular files (and symlinks to regular files) as “possible” + // and ignore errors for the rest. + if fi, statErr := f.Stat(); statErr != nil || fi.Mode().IsRegular() { + filelock.Unlock(f) + f.Close() + return nil, err + } + } + } + + return f, nil +} + +func closeFile(f *os.File) error { + // Since locking syscalls operate on file descriptors, we must unlock the file + // while the descriptor is still valid — that is, before the file is closed — + // and avoid unlocking files that are already closed. + err := filelock.Unlock(f) + + if closeErr := f.Close(); err == nil { + err = closeErr + } + return err +} diff --git a/libgo/go/cmd/go/internal/lockedfile/lockedfile_plan9.go b/libgo/go/cmd/go/internal/lockedfile/lockedfile_plan9.go new file mode 100644 index 00000000000..4a52c949763 --- /dev/null +++ b/libgo/go/cmd/go/internal/lockedfile/lockedfile_plan9.go @@ -0,0 +1,93 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build plan9 + +package lockedfile + +import ( + "math/rand" + "os" + "strings" + "time" +) + +// Opening an exclusive-use file returns an error. +// The expected error strings are: +// +// - "open/create -- file is locked" (cwfs, kfs) +// - "exclusive lock" (fossil) +// - "exclusive use file already open" (ramfs) +var lockedErrStrings = [...]string{ + "file is locked", + "exclusive lock", + "exclusive use file already open", +} + +// Even though plan9 doesn't support the Lock/RLock/Unlock functions to +// manipulate already-open files, IsLocked is still meaningful: os.OpenFile +// itself may return errors that indicate that a file with the ModeExclusive bit +// set is already open. +func isLocked(err error) bool { + s := err.Error() + + for _, frag := range lockedErrStrings { + if strings.Contains(s, frag) { + return true + } + } + + return false +} + +func openFile(name string, flag int, perm os.FileMode) (*os.File, error) { + // Plan 9 uses a mode bit instead of explicit lock/unlock syscalls. + // + // Per http://man.cat-v.org/plan_9/5/stat: “Exclusive use files may be open + // for I/O by only one fid at a time across all clients of the server. If a + // second open is attempted, it draws an error.” + // + // So we can try to open a locked file, but if it fails we're on our own to + // figure out when it becomes available. We'll use exponential backoff with + // some jitter and an arbitrary limit of 500ms. + + // If the file was unpacked or created by some other program, it might not + // have the ModeExclusive bit set. Set it before we call OpenFile, so that we + // can be confident that a successful OpenFile implies exclusive use. + if fi, err := os.Stat(name); err == nil { + if fi.Mode()&os.ModeExclusive == 0 { + if err := os.Chmod(name, fi.Mode()|os.ModeExclusive); err != nil { + return nil, err + } + } + } else if !os.IsNotExist(err) { + return nil, err + } + + nextSleep := 1 * time.Millisecond + const maxSleep = 500 * time.Millisecond + for { + f, err := os.OpenFile(name, flag, perm|os.ModeExclusive) + if err == nil { + return f, nil + } + + if !isLocked(err) { + return nil, err + } + + time.Sleep(nextSleep) + + nextSleep += nextSleep + if nextSleep > maxSleep { + nextSleep = maxSleep + } + // Apply 10% jitter to avoid synchronizing collisions. + nextSleep += time.Duration((0.1*rand.Float64() - 0.05) * float64(nextSleep)) + } +} + +func closeFile(f *os.File) error { + return f.Close() +} diff --git a/libgo/go/cmd/go/internal/lockedfile/lockedfile_test.go b/libgo/go/cmd/go/internal/lockedfile/lockedfile_test.go new file mode 100644 index 00000000000..6d5819efdb0 --- /dev/null +++ b/libgo/go/cmd/go/internal/lockedfile/lockedfile_test.go @@ -0,0 +1,174 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// js and nacl do not support inter-process file locking. +// +build !js,!nacl + +package lockedfile_test + +import ( + "io/ioutil" + "os" + "path/filepath" + "testing" + "time" + + "cmd/go/internal/lockedfile" +) + +func mustTempDir(t *testing.T) (dir string, remove func()) { + t.Helper() + + dir, err := ioutil.TempDir("", filepath.Base(t.Name())) + if err != nil { + t.Fatal(err) + } + return dir, func() { os.RemoveAll(dir) } +} + +const ( + quiescent = 10 * time.Millisecond + probablyStillBlocked = 10 * time.Second +) + +func mustBlock(t *testing.T, desc string, f func()) (wait func(*testing.T)) { + t.Helper() + + done := make(chan struct{}) + go func() { + f() + close(done) + }() + + select { + case <-done: + t.Fatalf("%s unexpectedly did not block", desc) + return nil + + case <-time.After(quiescent): + return func(t *testing.T) { + t.Helper() + select { + case <-time.After(probablyStillBlocked): + t.Fatalf("%s is unexpectedly still blocked after %v", desc, probablyStillBlocked) + case <-done: + } + } + } +} + +func TestMutexExcludes(t *testing.T) { + t.Parallel() + + dir, remove := mustTempDir(t) + defer remove() + + path := filepath.Join(dir, "lock") + + mu := lockedfile.MutexAt(path) + t.Logf("mu := MutexAt(_)") + + unlock, err := mu.Lock() + if err != nil { + t.Fatalf("mu.Lock: %v", err) + } + t.Logf("unlock, _ := mu.Lock()") + + mu2 := lockedfile.MutexAt(mu.Path) + t.Logf("mu2 := MutexAt(mu.Path)") + + wait := mustBlock(t, "mu2.Lock()", func() { + unlock2, err := mu2.Lock() + if err != nil { + t.Errorf("mu2.Lock: %v", err) + return + } + t.Logf("unlock2, _ := mu2.Lock()") + t.Logf("unlock2()") + unlock2() + }) + + t.Logf("unlock()") + unlock() + wait(t) +} + +func TestReadWaitsForLock(t *testing.T) { + t.Parallel() + + dir, remove := mustTempDir(t) + defer remove() + + path := filepath.Join(dir, "timestamp.txt") + + f, err := lockedfile.Create(path) + if err != nil { + t.Fatalf("Create: %v", err) + } + defer f.Close() + + const ( + part1 = "part 1\n" + part2 = "part 2\n" + ) + _, err = f.WriteString(part1) + if err != nil { + t.Fatalf("WriteString: %v", err) + } + t.Logf("WriteString(%q) = ", part1) + + wait := mustBlock(t, "Read", func() { + b, err := lockedfile.Read(path) + if err != nil { + t.Errorf("Read: %v", err) + return + } + + const want = part1 + part2 + got := string(b) + if got == want { + t.Logf("Read(_) = %q", got) + } else { + t.Errorf("Read(_) = %q, _; want %q", got, want) + } + }) + + _, err = f.WriteString(part2) + if err != nil { + t.Errorf("WriteString: %v", err) + } else { + t.Logf("WriteString(%q) = ", part2) + } + f.Close() + + wait(t) +} + +func TestCanLockExistingFile(t *testing.T) { + t.Parallel() + + dir, remove := mustTempDir(t) + defer remove() + path := filepath.Join(dir, "existing.txt") + + if err := ioutil.WriteFile(path, []byte("ok"), 0777); err != nil { + t.Fatalf("ioutil.WriteFile: %v", err) + } + + f, err := lockedfile.Edit(path) + if err != nil { + t.Fatalf("first Edit: %v", err) + } + + wait := mustBlock(t, "Edit", func() { + other, err := lockedfile.Edit(path) + if err != nil { + t.Errorf("second Edit: %v", err) + } + other.Close() + }) + + f.Close() + wait(t) +} diff --git a/libgo/go/cmd/go/internal/lockedfile/mutex.go b/libgo/go/cmd/go/internal/lockedfile/mutex.go new file mode 100644 index 00000000000..17f3751c371 --- /dev/null +++ b/libgo/go/cmd/go/internal/lockedfile/mutex.go @@ -0,0 +1,60 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package lockedfile + +import ( + "fmt" + "os" +) + +// A Mutex provides mutual exclusion within and across processes by locking a +// well-known file. Such a file generally guards some other part of the +// filesystem: for example, a Mutex file in a directory might guard access to +// the entire tree rooted in that directory. +// +// Mutex does not implement sync.Locker: unlike a sync.Mutex, a lockedfile.Mutex +// can fail to lock (e.g. if there is a permission error in the filesystem). +// +// Like a sync.Mutex, a Mutex may be included as a field of a larger struct but +// must not be copied after first use. The Path field must be set before first +// use and must not be change thereafter. +type Mutex struct { + Path string // The path to the well-known lock file. Must be non-empty. +} + +// MutexAt returns a new Mutex with Path set to the given non-empty path. +func MutexAt(path string) *Mutex { + if path == "" { + panic("lockedfile.MutexAt: path must be non-empty") + } + return &Mutex{Path: path} +} + +func (mu *Mutex) String() string { + return fmt.Sprintf("lockedfile.Mutex(%s)", mu.Path) +} + +// Lock attempts to lock the Mutex. +// +// If successful, Lock returns a non-nil unlock function: it is provided as a +// return-value instead of a separate method to remind the caller to check the +// accompanying error. (See https://golang.org/issue/20803.) +func (mu *Mutex) Lock() (unlock func(), err error) { + if mu.Path == "" { + panic("lockedfile.Mutex: missing Path during Lock") + } + + // We could use either O_RDWR or O_WRONLY here. If we choose O_RDWR and the + // file at mu.Path is write-only, the call to OpenFile will fail with a + // permission error. That's actually what we want: if we add an RLock method + // in the future, it should call OpenFile with O_RDONLY and will require the + // files must be readable, so we should not let the caller make any + // assumptions about Mutex working with write-only files. + f, err := OpenFile(mu.Path, os.O_RDWR|os.O_CREATE, 0666) + if err != nil { + return nil, err + } + return func() { f.Close() }, nil +} diff --git a/libgo/go/cmd/go/internal/modcmd/download.go b/libgo/go/cmd/go/internal/modcmd/download.go index cf42eff58a1..bbaba444f50 100644 --- a/libgo/go/cmd/go/internal/modcmd/download.go +++ b/libgo/go/cmd/go/internal/modcmd/download.go @@ -15,7 +15,7 @@ import ( ) var cmdDownload = &base.Command{ - UsageLine: "go mod download [-dir] [-json] [modules]", + UsageLine: "go mod download [-json] [modules]", Short: "download modules to local cache", Long: ` Download downloads the named modules, which can be module patterns selecting @@ -128,6 +128,16 @@ func runDownload(cmd *base.Command, args []string) { base.Fatalf("%v", err) } os.Stdout.Write(append(b, '\n')) + if m.Error != "" { + base.SetExitStatus(1) + } + } + } else { + for _, m := range mods { + if m.Error != "" { + base.Errorf("%s@%s: %s\n", m.Path, m.Version, m.Error) + } } + base.ExitIfErrors() } } diff --git a/libgo/go/cmd/go/internal/modcmd/edit.go b/libgo/go/cmd/go/internal/modcmd/edit.go index 5fea3e48e08..5066e4ddf75 100644 --- a/libgo/go/cmd/go/internal/modcmd/edit.go +++ b/libgo/go/cmd/go/internal/modcmd/edit.go @@ -7,6 +7,7 @@ package modcmd import ( + "bytes" "encoding/json" "fmt" "io/ioutil" @@ -15,6 +16,7 @@ import ( "strings" "cmd/go/internal/base" + "cmd/go/internal/modfetch" "cmd/go/internal/modfile" "cmd/go/internal/modload" "cmd/go/internal/module" @@ -62,6 +64,8 @@ The -require, -droprequire, -exclude, -dropexclude, -replace, and -dropreplace editing flags may be repeated, and the changes are applied in the order given. +The -go=version flag sets the expected Go language version. + The -print flag prints the final go.mod in its text format instead of writing it back to go.mod. @@ -74,7 +78,8 @@ writing it back to go.mod. The JSON output corresponds to these Go types: } type GoMod struct { - Module Module + Module Module + Go string Require []Require Exclude []Module Replace []Replace @@ -102,8 +107,8 @@ by invoking 'go mod edit' with -require, -exclude, and so on. } var ( - editFmt = cmdEdit.Flag.Bool("fmt", false, "") - // editGo = cmdEdit.Flag.String("go", "", "") + editFmt = cmdEdit.Flag.Bool("fmt", false, "") + editGo = cmdEdit.Flag.String("go", "", "") editJSON = cmdEdit.Flag.Bool("json", false, "") editPrint = cmdEdit.Flag.Bool("print", false, "") editModule = cmdEdit.Flag.String("module", "", "") @@ -131,6 +136,7 @@ func init() { func runEdit(cmd *base.Command, args []string) { anyFlags := *editModule != "" || + *editGo != "" || *editJSON || *editPrint || *editFmt || @@ -151,8 +157,7 @@ func runEdit(cmd *base.Command, args []string) { if len(args) == 1 { gomod = args[0] } else { - modload.MustInit() - gomod = filepath.Join(modload.ModRoot, "go.mod") + gomod = filepath.Join(modload.ModRoot(), "go.mod") } if *editModule != "" { @@ -161,7 +166,11 @@ func runEdit(cmd *base.Command, args []string) { } } - // TODO(rsc): Implement -go= once we start advertising it. + if *editGo != "" { + if !modfile.GoVersionRE.MatchString(*editGo) { + base.Fatalf(`go mod: invalid -go option; expecting something like "-go 1.12"`) + } + } data, err := ioutil.ReadFile(gomod) if err != nil { @@ -174,7 +183,13 @@ func runEdit(cmd *base.Command, args []string) { } if *editModule != "" { - modFile.AddModuleStmt(modload.CmdModModule) + modFile.AddModuleStmt(*editModule) + } + + if *editGo != "" { + if err := modFile.AddGoStmt(*editGo); err != nil { + base.Fatalf("go: internal error: %v", err) + } } if len(edits) > 0 { @@ -190,17 +205,23 @@ func runEdit(cmd *base.Command, args []string) { return } - data, err = modFile.Format() + out, err := modFile.Format() if err != nil { base.Fatalf("go: %v", err) } if *editPrint { - os.Stdout.Write(data) + os.Stdout.Write(out) return } - if err := ioutil.WriteFile(gomod, data, 0666); err != nil { + unlock := modfetch.SideLock() + defer unlock() + lockedData, err := ioutil.ReadFile(gomod) + if err == nil && !bytes.Equal(lockedData, data) { + base.Fatalf("go: go.mod changed during editing; not overwriting") + } + if err := ioutil.WriteFile(gomod, out, 0666); err != nil { base.Fatalf("go: %v", err) } } @@ -344,6 +365,7 @@ func flagDropReplace(arg string) { // fileJSON is the -json output data structure. type fileJSON struct { Module module.Version + Go string `json:",omitempty"` Require []requireJSON Exclude []module.Version Replace []replaceJSON @@ -364,6 +386,9 @@ type replaceJSON struct { func editPrintJSON(modFile *modfile.File) { var f fileJSON f.Module = modFile.Module.Mod + if modFile.Go != nil { + f.Go = modFile.Go.Version + } for _, r := range modFile.Require { f.Require = append(f.Require, requireJSON{Path: r.Mod.Path, Version: r.Mod.Version, Indirect: r.Indirect}) } diff --git a/libgo/go/cmd/go/internal/modcmd/init.go b/libgo/go/cmd/go/internal/modcmd/init.go index f510a46262b..0f7421e5849 100644 --- a/libgo/go/cmd/go/internal/modcmd/init.go +++ b/libgo/go/cmd/go/internal/modcmd/init.go @@ -10,6 +10,7 @@ import ( "cmd/go/internal/base" "cmd/go/internal/modload" "os" + "strings" ) var cmdInit = &base.Command{ @@ -37,5 +38,8 @@ func runInit(cmd *base.Command, args []string) { if _, err := os.Stat("go.mod"); err == nil { base.Fatalf("go mod init: go.mod already exists") } + if strings.Contains(modload.CmdModModule, "@") { + base.Fatalf("go mod init: module path must not contain '@'") + } modload.InitMod() // does all the hard work } diff --git a/libgo/go/cmd/go/internal/modcmd/tidy.go b/libgo/go/cmd/go/internal/modcmd/tidy.go index f2063a9ea60..839c92a0a02 100644 --- a/libgo/go/cmd/go/internal/modcmd/tidy.go +++ b/libgo/go/cmd/go/internal/modcmd/tidy.go @@ -77,7 +77,17 @@ func modTidyGoSum() { keep := make(map[module.Version]bool) var walk func(module.Version) walk = func(m module.Version) { - keep[m] = true + // If we build using a replacement module, keep the sum for the replacement, + // since that's the code we'll actually use during a build. + // + // TODO(golang.org/issue/29182): Perhaps we should keep both sums, and the + // sums for both sets of transitive requirements. + r := modload.Replacement(m) + if r.Path == "" { + keep[m] = true + } else { + keep[r] = true + } list, _ := reqs.Required(m) for _, r := range list { if !keep[r] { diff --git a/libgo/go/cmd/go/internal/modcmd/vendor.go b/libgo/go/cmd/go/internal/modcmd/vendor.go index 62e74585359..b70f25cec39 100644 --- a/libgo/go/cmd/go/internal/modcmd/vendor.go +++ b/libgo/go/cmd/go/internal/modcmd/vendor.go @@ -43,9 +43,9 @@ func runVendor(cmd *base.Command, args []string) { } pkgs := modload.LoadVendor() - vdir := filepath.Join(modload.ModRoot, "vendor") + vdir := filepath.Join(modload.ModRoot(), "vendor") if err := os.RemoveAll(vdir); err != nil { - base.Fatalf("go vendor: %v", err) + base.Fatalf("go mod vendor: %v", err) } modpkgs := make(map[module.Version][]string) @@ -85,7 +85,7 @@ func runVendor(cmd *base.Command, args []string) { return } if err := ioutil.WriteFile(filepath.Join(vdir, "modules.txt"), buf.Bytes(), 0666); err != nil { - base.Fatalf("go vendor: %v", err) + base.Fatalf("go mod vendor: %v", err) } } @@ -172,10 +172,10 @@ func matchNonTest(info os.FileInfo) bool { func copyDir(dst, src string, match func(os.FileInfo) bool) { files, err := ioutil.ReadDir(src) if err != nil { - base.Fatalf("go vendor: %v", err) + base.Fatalf("go mod vendor: %v", err) } if err := os.MkdirAll(dst, 0777); err != nil { - base.Fatalf("go vendor: %v", err) + base.Fatalf("go mod vendor: %v", err) } for _, file := range files { if file.IsDir() || !file.Mode().IsRegular() || !match(file) { @@ -183,18 +183,18 @@ func copyDir(dst, src string, match func(os.FileInfo) bool) { } r, err := os.Open(filepath.Join(src, file.Name())) if err != nil { - base.Fatalf("go vendor: %v", err) + base.Fatalf("go mod vendor: %v", err) } w, err := os.Create(filepath.Join(dst, file.Name())) if err != nil { - base.Fatalf("go vendor: %v", err) + base.Fatalf("go mod vendor: %v", err) } if _, err := io.Copy(w, r); err != nil { - base.Fatalf("go vendor: %v", err) + base.Fatalf("go mod vendor: %v", err) } r.Close() if err := w.Close(); err != nil { - base.Fatalf("go vendor: %v", err) + base.Fatalf("go mod vendor: %v", err) } } } diff --git a/libgo/go/cmd/go/internal/modconv/convert_test.go b/libgo/go/cmd/go/internal/modconv/convert_test.go index ad27abb8ef7..4d55d73f214 100644 --- a/libgo/go/cmd/go/internal/modconv/convert_test.go +++ b/libgo/go/cmd/go/internal/modconv/convert_test.go @@ -146,7 +146,7 @@ func TestConvertLegacyConfig(t *testing.T) { } for _, tt := range tests { - t.Run(strings.Replace(tt.path, "/", "_", -1)+"_"+tt.vers, func(t *testing.T) { + t.Run(strings.ReplaceAll(tt.path, "/", "_")+"_"+tt.vers, func(t *testing.T) { f, err := modfile.Parse("golden", []byte(tt.gomod), nil) if err != nil { t.Fatal(err) diff --git a/libgo/go/cmd/go/internal/modfetch/cache.go b/libgo/go/cmd/go/internal/modfetch/cache.go index 1f9cc96c3ec..1ccd43dc2ae 100644 --- a/libgo/go/cmd/go/internal/modfetch/cache.go +++ b/libgo/go/cmd/go/internal/modfetch/cache.go @@ -8,15 +8,18 @@ import ( "bytes" "encoding/json" "fmt" + "io" "io/ioutil" "os" "path/filepath" "strings" "cmd/go/internal/base" + "cmd/go/internal/lockedfile" "cmd/go/internal/modfetch/codehost" "cmd/go/internal/module" "cmd/go/internal/par" + "cmd/go/internal/renameio" "cmd/go/internal/semver" ) @@ -53,6 +56,8 @@ func CachePath(m module.Version, suffix string) (string, error) { return filepath.Join(dir, encVer+"."+suffix), nil } +// DownloadDir returns the directory to which m should be downloaded. +// Note that the directory may not yet exist. func DownloadDir(m module.Version) (string, error) { if PkgMod == "" { return "", fmt.Errorf("internal error: modfetch.PkgMod not set") @@ -74,6 +79,37 @@ func DownloadDir(m module.Version) (string, error) { return filepath.Join(PkgMod, enc+"@"+encVer), nil } +// lockVersion locks a file within the module cache that guards the downloading +// and extraction of the zipfile for the given module version. +func lockVersion(mod module.Version) (unlock func(), err error) { + path, err := CachePath(mod, "lock") + if err != nil { + return nil, err + } + if err := os.MkdirAll(filepath.Dir(path), 0777); err != nil { + return nil, err + } + return lockedfile.MutexAt(path).Lock() +} + +// SideLock locks a file within the module cache that that guards edits to files +// outside the cache, such as go.sum and go.mod files in the user's working +// directory. It returns a function that must be called to unlock the file. +func SideLock() (unlock func()) { + if PkgMod == "" { + base.Fatalf("go: internal error: modfetch.PkgMod not set") + } + path := filepath.Join(PkgMod, "cache", "lock") + if err := os.MkdirAll(filepath.Dir(path), 0777); err != nil { + base.Fatalf("go: failed to create cache directory %s: %v", filepath.Dir(path), err) + } + unlock, err := lockedfile.MutexAt(path).Lock() + if err != nil { + base.Fatalf("go: failed to lock file at %v", path) + } + return unlock +} + // A cachingRepo is a cache around an underlying Repo, // avoiding redundant calls to ModulePath, Versions, Stat, Latest, and GoMod (but not Zip). // It is also safe for simultaneous use by multiple goroutines @@ -129,16 +165,18 @@ func (r *cachingRepo) Stat(rev string) (*RevInfo, error) { } info, err = r.r.Stat(rev) if err == nil { - if err := writeDiskStat(file, info); err != nil { - fmt.Fprintf(os.Stderr, "go: writing stat cache: %v\n", err) - } // If we resolved, say, 1234abcde to v0.0.0-20180604122334-1234abcdef78, // then save the information under the proper version, for future use. if info.Version != rev { + file, _ = CachePath(module.Version{Path: r.path, Version: info.Version}, "info") r.cache.Do("stat:"+info.Version, func() interface{} { return cachedInfo{info, err} }) } + + if err := writeDiskStat(file, info); err != nil { + fmt.Fprintf(os.Stderr, "go: writing stat cache: %v\n", err) + } } return cachedInfo{info, err} }).(cachedInfo) @@ -213,8 +251,8 @@ func (r *cachingRepo) GoMod(rev string) ([]byte, error) { return append([]byte(nil), c.text...), nil } -func (r *cachingRepo) Zip(version, tmpdir string) (string, error) { - return r.r.Zip(version, tmpdir) +func (r *cachingRepo) Zip(dst io.Writer, version string) error { + return r.r.Zip(dst, version) } // Stat is like Lookup(path).Stat(rev) but avoids the @@ -383,7 +421,7 @@ func readDiskStatByHash(path, rev string) (file string, info *RevInfo, err error // and should ignore it. var oldVgoPrefix = []byte("//vgo 0.0.") -// readDiskGoMod reads a cached stat result from disk, +// readDiskGoMod reads a cached go.mod file from disk, // returning the name of the cache file and the result. // If the read fails, the caller can use // writeDiskGoMod(file, data) to write a new cache entry. @@ -449,22 +487,8 @@ func writeDiskCache(file string, data []byte) error { if err := os.MkdirAll(filepath.Dir(file), 0777); err != nil { return err } - // Write data to temp file next to target file. - f, err := ioutil.TempFile(filepath.Dir(file), filepath.Base(file)+".tmp-") - if err != nil { - return err - } - defer os.Remove(f.Name()) - defer f.Close() - if _, err := f.Write(data); err != nil { - return err - } - if err := f.Close(); err != nil { - return err - } - // Rename temp file onto cache file, - // so that the cache file is always a complete file. - if err := os.Rename(f.Name(), file); err != nil { + + if err := renameio.WriteFile(file, data); err != nil { return err } @@ -481,8 +505,18 @@ func rewriteVersionList(dir string) { base.Fatalf("go: internal error: misuse of rewriteVersionList") } - // TODO(rsc): We should do some kind of directory locking here, - // to avoid lost updates. + listFile := filepath.Join(dir, "list") + + // We use a separate lockfile here instead of locking listFile itself because + // we want to use Rename to write the file atomically. The list may be read by + // a GOPROXY HTTP server, and if we crash midway through a rewrite (or if the + // HTTP server ignores our locking and serves the file midway through a + // rewrite) it's better to serve a stale list than a truncated one. + unlock, err := lockedfile.MutexAt(listFile + ".lock").Lock() + if err != nil { + base.Fatalf("go: can't lock version list lockfile: %v", err) + } + defer unlock() infos, err := ioutil.ReadDir(dir) if err != nil { @@ -511,12 +545,12 @@ func rewriteVersionList(dir string) { buf.WriteString(v) buf.WriteString("\n") } - listFile := filepath.Join(dir, "list") old, _ := ioutil.ReadFile(listFile) if bytes.Equal(buf.Bytes(), old) { return } - // TODO: Use rename to install file, - // so that readers never see an incomplete file. - ioutil.WriteFile(listFile, buf.Bytes(), 0666) + + if err := renameio.WriteFile(listFile, buf.Bytes()); err != nil { + base.Fatalf("go: failed to write version list: %v", err) + } } diff --git a/libgo/go/cmd/go/internal/modfetch/codehost/codehost.go b/libgo/go/cmd/go/internal/modfetch/codehost/codehost.go index 4103ddc717f..6c17f7886f1 100644 --- a/libgo/go/cmd/go/internal/modfetch/codehost/codehost.go +++ b/libgo/go/cmd/go/internal/modfetch/codehost/codehost.go @@ -20,6 +20,7 @@ import ( "time" "cmd/go/internal/cfg" + "cmd/go/internal/lockedfile" "cmd/go/internal/str" ) @@ -131,9 +132,9 @@ var WorkRoot string // WorkDir returns the name of the cached work directory to use for the // given repository type and name. -func WorkDir(typ, name string) (string, error) { +func WorkDir(typ, name string) (dir, lockfile string, err error) { if WorkRoot == "" { - return "", fmt.Errorf("codehost.WorkRoot not set") + return "", "", fmt.Errorf("codehost.WorkRoot not set") } // We name the work directory for the SHA256 hash of the type and name. @@ -142,22 +143,41 @@ func WorkDir(typ, name string) (string, error) { // that one checkout is never nested inside another. That nesting has // led to security problems in the past. if strings.Contains(typ, ":") { - return "", fmt.Errorf("codehost.WorkDir: type cannot contain colon") + return "", "", fmt.Errorf("codehost.WorkDir: type cannot contain colon") } key := typ + ":" + name - dir := filepath.Join(WorkRoot, fmt.Sprintf("%x", sha256.Sum256([]byte(key)))) + dir = filepath.Join(WorkRoot, fmt.Sprintf("%x", sha256.Sum256([]byte(key)))) + + if cfg.BuildX { + fmt.Fprintf(os.Stderr, "mkdir -p %s # %s %s\n", filepath.Dir(dir), typ, name) + } + if err := os.MkdirAll(filepath.Dir(dir), 0777); err != nil { + return "", "", err + } + + lockfile = dir + ".lock" + if cfg.BuildX { + fmt.Fprintf(os.Stderr, "# lock %s", lockfile) + } + + unlock, err := lockedfile.MutexAt(lockfile).Lock() + if err != nil { + return "", "", fmt.Errorf("codehost.WorkDir: can't find or create lock file: %v", err) + } + defer unlock() + data, err := ioutil.ReadFile(dir + ".info") info, err2 := os.Stat(dir) if err == nil && err2 == nil && info.IsDir() { // Info file and directory both already exist: reuse. have := strings.TrimSuffix(string(data), "\n") if have != key { - return "", fmt.Errorf("%s exists with wrong content (have %q want %q)", dir+".info", have, key) + return "", "", fmt.Errorf("%s exists with wrong content (have %q want %q)", dir+".info", have, key) } if cfg.BuildX { fmt.Fprintf(os.Stderr, "# %s for %s %s\n", dir, typ, name) } - return dir, nil + return dir, lockfile, nil } // Info file or directory missing. Start from scratch. @@ -166,26 +186,30 @@ func WorkDir(typ, name string) (string, error) { } os.RemoveAll(dir) if err := os.MkdirAll(dir, 0777); err != nil { - return "", err + return "", "", err } if err := ioutil.WriteFile(dir+".info", []byte(key), 0666); err != nil { os.RemoveAll(dir) - return "", err + return "", "", err } - return dir, nil + return dir, lockfile, nil } type RunError struct { - Cmd string - Err error - Stderr []byte + Cmd string + Err error + Stderr []byte + HelpText string } func (e *RunError) Error() string { text := e.Cmd + ": " + e.Err.Error() stderr := bytes.TrimRight(e.Stderr, "\n") if len(stderr) > 0 { - text += ":\n\t" + strings.Replace(string(stderr), "\n", "\n\t", -1) + text += ":\n\t" + strings.ReplaceAll(string(stderr), "\n", "\n\t") + } + if len(e.HelpText) > 0 { + text += "\n" + e.HelpText } return text } diff --git a/libgo/go/cmd/go/internal/modfetch/codehost/git.go b/libgo/go/cmd/go/internal/modfetch/codehost/git.go index 87940a8f02c..588e7496cc5 100644 --- a/libgo/go/cmd/go/internal/modfetch/codehost/git.go +++ b/libgo/go/cmd/go/internal/modfetch/codehost/git.go @@ -17,6 +17,7 @@ import ( "sync" "time" + "cmd/go/internal/lockedfile" "cmd/go/internal/par" ) @@ -57,22 +58,29 @@ func newGitRepo(remote string, localOK bool) (Repo, error) { r := &gitRepo{remote: remote} if strings.Contains(remote, "://") { // This is a remote path. - dir, err := WorkDir(gitWorkDirType, r.remote) + var err error + r.dir, r.mu.Path, err = WorkDir(gitWorkDirType, r.remote) if err != nil { return nil, err } - r.dir = dir - if _, err := os.Stat(filepath.Join(dir, "objects")); err != nil { - if _, err := Run(dir, "git", "init", "--bare"); err != nil { - os.RemoveAll(dir) + + unlock, err := r.mu.Lock() + if err != nil { + return nil, err + } + defer unlock() + + if _, err := os.Stat(filepath.Join(r.dir, "objects")); err != nil { + if _, err := Run(r.dir, "git", "init", "--bare"); err != nil { + os.RemoveAll(r.dir) return nil, err } // We could just say git fetch https://whatever later, // but this lets us say git fetch origin instead, which // is a little nicer. More importantly, using a named remote // avoids a problem with Git LFS. See golang.org/issue/25605. - if _, err := Run(dir, "git", "remote", "add", "origin", r.remote); err != nil { - os.RemoveAll(dir) + if _, err := Run(r.dir, "git", "remote", "add", "origin", r.remote); err != nil { + os.RemoveAll(r.dir) return nil, err } r.remote = "origin" @@ -97,6 +105,7 @@ func newGitRepo(remote string, localOK bool) (Repo, error) { return nil, fmt.Errorf("%s exists but is not a directory", remote) } r.dir = remote + r.mu.Path = r.dir + ".lock" } return r, nil } @@ -106,7 +115,8 @@ type gitRepo struct { local bool dir string - mu sync.Mutex // protects fetchLevel, some git repo state + mu lockedfile.Mutex // protects fetchLevel and git repo state + fetchLevel int statCache par.Cache @@ -154,6 +164,11 @@ func (r *gitRepo) loadRefs() { // Most of the time we only care about tags but sometimes we care about heads too. out, err := Run(r.dir, "git", "ls-remote", "-q", r.remote) if err != nil { + if rerr, ok := err.(*RunError); ok { + if bytes.Contains(rerr.Stderr, []byte("fatal: could not read Username")) { + rerr.HelpText = "If this is a private repository, see https://golang.org/doc/faq#git_https for additional information." + } + } r.refsErr = err return } @@ -304,11 +319,11 @@ func (r *gitRepo) stat(rev string) (*RevInfo, error) { } // Protect r.fetchLevel and the "fetch more and more" sequence. - // TODO(rsc): Add LockDir and use it for protecting that - // sequence, so that multiple processes don't collide in their - // git commands. - r.mu.Lock() - defer r.mu.Unlock() + unlock, err := r.mu.Lock() + if err != nil { + return nil, err + } + defer unlock() // Perhaps r.localTags did not have the ref when we loaded local tags, // but we've since done fetches that pulled down the hash we need @@ -495,8 +510,11 @@ func (r *gitRepo) ReadFileRevs(revs []string, file string, maxSize int64) (map[s // Protect r.fetchLevel and the "fetch more and more" sequence. // See stat method above. - r.mu.Lock() - defer r.mu.Unlock() + unlock, err := r.mu.Lock() + if err != nil { + return nil, err + } + defer unlock() var refs []string var protoFlag []string @@ -658,8 +676,11 @@ func (r *gitRepo) RecentTag(rev, prefix string) (tag string, err error) { // There are plausible tags, but we don't know if rev is a descendent of any of them. // Fetch the history to find out. - r.mu.Lock() - defer r.mu.Unlock() + unlock, err := r.mu.Lock() + if err != nil { + return "", err + } + defer unlock() if r.fetchLevel < fetchAll { // Fetch all heads and tags and see if that gives us enough history. @@ -678,7 +699,7 @@ func (r *gitRepo) RecentTag(rev, prefix string) (tag string, err error) { // unreachable for a reason). // // Try one last time in case some other goroutine fetched rev while we were - // waiting on r.mu. + // waiting on the lock. describe() return tag, err } @@ -694,6 +715,16 @@ func (r *gitRepo) ReadZip(rev, subdir string, maxSize int64) (zip io.ReadCloser, return nil, "", err } + unlock, err := r.mu.Lock() + if err != nil { + return nil, "", err + } + defer unlock() + + if err := ensureGitAttributes(r.dir); err != nil { + return nil, "", err + } + // Incredibly, git produces different archives depending on whether // it is running on a Windows system or not, in an attempt to normalize // text file line endings. Setting -c core.autocrlf=input means only @@ -709,3 +740,43 @@ func (r *gitRepo) ReadZip(rev, subdir string, maxSize int64) (zip io.ReadCloser, return ioutil.NopCloser(bytes.NewReader(archive)), "", nil } + +// ensureGitAttributes makes sure export-subst and export-ignore features are +// disabled for this repo. This is intended to be run prior to running git +// archive so that zip files are generated that produce consistent ziphashes +// for a given revision, independent of variables such as git version and the +// size of the repo. +// +// See: https://github.com/golang/go/issues/27153 +func ensureGitAttributes(repoDir string) (err error) { + const attr = "\n* -export-subst -export-ignore\n" + + d := repoDir + "/info" + p := d + "/attributes" + + if err := os.MkdirAll(d, 0755); err != nil { + return err + } + + f, err := os.OpenFile(p, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0666) + if err != nil { + return err + } + defer func() { + closeErr := f.Close() + if closeErr != nil { + err = closeErr + } + }() + + b, err := ioutil.ReadAll(f) + if err != nil { + return err + } + if !bytes.HasSuffix(b, []byte(attr)) { + _, err := f.WriteString(attr) + return err + } + + return nil +} diff --git a/libgo/go/cmd/go/internal/modfetch/codehost/vcs.go b/libgo/go/cmd/go/internal/modfetch/codehost/vcs.go index 9e862a0ef8c..59c2b15d19a 100644 --- a/libgo/go/cmd/go/internal/modfetch/codehost/vcs.go +++ b/libgo/go/cmd/go/internal/modfetch/codehost/vcs.go @@ -18,6 +18,7 @@ import ( "sync" "time" + "cmd/go/internal/lockedfile" "cmd/go/internal/par" "cmd/go/internal/str" ) @@ -27,12 +28,19 @@ import ( // to get the code, but we can't access it due to the error. // The caller should report this error instead of continuing to probe // other possible module paths. +// +// TODO(bcmills): See if we can invert this. (Return a distinguished error for +// “repo not found” and treat everything else as terminal.) type VCSError struct { Err error } func (e *VCSError) Error() string { return e.Err.Error() } +func vcsErrorf(format string, a ...interface{}) error { + return &VCSError{Err: fmt.Errorf(format, a...)} +} + func NewRepo(vcs, remote string) (Repo, error) { type key struct { vcs string @@ -56,6 +64,8 @@ func NewRepo(vcs, remote string) (Repo, error) { var vcsRepoCache par.Cache type vcsRepo struct { + mu lockedfile.Mutex // protects all commands, so we don't have to decide which are safe on a per-VCS basis + remote string cmd *vcsCmd dir string @@ -81,18 +91,27 @@ func newVCSRepo(vcs, remote string) (Repo, error) { if !strings.Contains(remote, "://") { return nil, fmt.Errorf("invalid vcs remote: %s %s", vcs, remote) } + r := &vcsRepo{remote: remote, cmd: cmd} + var err error + r.dir, r.mu.Path, err = WorkDir(vcsWorkDirType+vcs, r.remote) + if err != nil { + return nil, err + } + if cmd.init == nil { return r, nil } - dir, err := WorkDir(vcsWorkDirType+vcs, r.remote) + + unlock, err := r.mu.Lock() if err != nil { return nil, err } - r.dir = dir - if _, err := os.Stat(filepath.Join(dir, "."+vcs)); err != nil { - if _, err := Run(dir, cmd.init(r.remote)); err != nil { - os.RemoveAll(dir) + defer unlock() + + if _, err := os.Stat(filepath.Join(r.dir, "."+vcs)); err != nil { + if _, err := Run(r.dir, cmd.init(r.remote)); err != nil { + os.RemoveAll(r.dir) return nil, err } } @@ -270,6 +289,12 @@ func (r *vcsRepo) loadBranches() { } func (r *vcsRepo) Tags(prefix string) ([]string, error) { + unlock, err := r.mu.Lock() + if err != nil { + return nil, err + } + defer unlock() + r.tagsOnce.Do(r.loadTags) tags := []string{} @@ -283,6 +308,12 @@ func (r *vcsRepo) Tags(prefix string) ([]string, error) { } func (r *vcsRepo) Stat(rev string) (*RevInfo, error) { + unlock, err := r.mu.Lock() + if err != nil { + return nil, err + } + defer unlock() + if rev == "latest" { rev = r.cmd.latest } @@ -315,7 +346,7 @@ func (r *vcsRepo) fetch() { func (r *vcsRepo) statLocal(rev string) (*RevInfo, error) { out, err := Run(r.dir, r.cmd.statLocal(rev, r.remote)) if err != nil { - return nil, fmt.Errorf("unknown revision %s", rev) + return nil, vcsErrorf("unknown revision %s", rev) } return r.cmd.parseStat(rev, string(out)) } @@ -332,6 +363,14 @@ func (r *vcsRepo) ReadFile(rev, file string, maxSize int64) ([]byte, error) { if err != nil { return nil, err } + + // r.Stat acquires r.mu, so lock after that. + unlock, err := r.mu.Lock() + if err != nil { + return nil, err + } + defer unlock() + out, err := Run(r.dir, r.cmd.readFile(rev, file, r.remote)) if err != nil { return nil, os.ErrNotExist @@ -340,14 +379,42 @@ func (r *vcsRepo) ReadFile(rev, file string, maxSize int64) ([]byte, error) { } func (r *vcsRepo) ReadFileRevs(revs []string, file string, maxSize int64) (map[string]*FileRev, error) { - return nil, fmt.Errorf("ReadFileRevs not implemented") + // We don't technically need to lock here since we're returning an error + // uncondititonally, but doing so anyway will help to avoid baking in + // lock-inversion bugs. + unlock, err := r.mu.Lock() + if err != nil { + return nil, err + } + defer unlock() + + return nil, vcsErrorf("ReadFileRevs not implemented") } func (r *vcsRepo) RecentTag(rev, prefix string) (tag string, err error) { - return "", fmt.Errorf("RecentTags not implemented") + // We don't technically need to lock here since we're returning an error + // uncondititonally, but doing so anyway will help to avoid baking in + // lock-inversion bugs. + unlock, err := r.mu.Lock() + if err != nil { + return "", err + } + defer unlock() + + return "", vcsErrorf("RecentTag not implemented") } func (r *vcsRepo) ReadZip(rev, subdir string, maxSize int64) (zip io.ReadCloser, actualSubdir string, err error) { + if r.cmd.readZip == nil { + return nil, "", vcsErrorf("ReadZip not implemented for %s", r.cmd.vcs) + } + + unlock, err := r.mu.Lock() + if err != nil { + return nil, "", err + } + defer unlock() + if rev == "latest" { rev = r.cmd.latest } @@ -392,7 +459,7 @@ func (d *deleteCloser) Close() error { func hgParseStat(rev, out string) (*RevInfo, error) { f := strings.Fields(string(out)) if len(f) < 3 { - return nil, fmt.Errorf("unexpected response from hg log: %q", out) + return nil, vcsErrorf("unexpected response from hg log: %q", out) } hash := f[0] version := rev @@ -401,7 +468,7 @@ func hgParseStat(rev, out string) (*RevInfo, error) { } t, err := strconv.ParseInt(f[1], 10, 64) if err != nil { - return nil, fmt.Errorf("invalid time from hg log: %q", out) + return nil, vcsErrorf("invalid time from hg log: %q", out) } var tags []string @@ -430,12 +497,12 @@ func svnParseStat(rev, out string) (*RevInfo, error) { } `xml:"logentry"` } if err := xml.Unmarshal([]byte(out), &log); err != nil { - return nil, fmt.Errorf("unexpected response from svn log --xml: %v\n%s", err, out) + return nil, vcsErrorf("unexpected response from svn log --xml: %v\n%s", err, out) } t, err := time.Parse(time.RFC3339, log.Logentry.Date) if err != nil { - return nil, fmt.Errorf("unexpected response from svn log --xml: %v\n%s", err, out) + return nil, vcsErrorf("unexpected response from svn log --xml: %v\n%s", err, out) } info := &RevInfo{ @@ -471,23 +538,23 @@ func bzrParseStat(rev, out string) (*RevInfo, error) { } i, err := strconv.ParseInt(val, 10, 64) if err != nil { - return nil, fmt.Errorf("unexpected revno from bzr log: %q", line) + return nil, vcsErrorf("unexpected revno from bzr log: %q", line) } revno = i case "timestamp": j := strings.Index(val, " ") if j < 0 { - return nil, fmt.Errorf("unexpected timestamp from bzr log: %q", line) + return nil, vcsErrorf("unexpected timestamp from bzr log: %q", line) } t, err := time.Parse("2006-01-02 15:04:05 -0700", val[j+1:]) if err != nil { - return nil, fmt.Errorf("unexpected timestamp from bzr log: %q", line) + return nil, vcsErrorf("unexpected timestamp from bzr log: %q", line) } tm = t.UTC() } } if revno == 0 || tm.IsZero() { - return nil, fmt.Errorf("unexpected response from bzr log: %q", out) + return nil, vcsErrorf("unexpected response from bzr log: %q", out) } info := &RevInfo{ @@ -504,11 +571,11 @@ func fossilParseStat(rev, out string) (*RevInfo, error) { if strings.HasPrefix(line, "uuid:") { f := strings.Fields(line) if len(f) != 5 || len(f[1]) != 40 || f[4] != "UTC" { - return nil, fmt.Errorf("unexpected response from fossil info: %q", line) + return nil, vcsErrorf("unexpected response from fossil info: %q", line) } t, err := time.Parse("2006-01-02 15:04:05", f[2]+" "+f[3]) if err != nil { - return nil, fmt.Errorf("unexpected response from fossil info: %q", line) + return nil, vcsErrorf("unexpected response from fossil info: %q", line) } hash := f[1] version := rev @@ -524,5 +591,5 @@ func fossilParseStat(rev, out string) (*RevInfo, error) { return info, nil } } - return nil, fmt.Errorf("unexpected response from fossil info: %q", out) + return nil, vcsErrorf("unexpected response from fossil info: %q", out) } diff --git a/libgo/go/cmd/go/internal/modfetch/coderepo.go b/libgo/go/cmd/go/internal/modfetch/coderepo.go index 9cf0e911508..5018b6d8af7 100644 --- a/libgo/go/cmd/go/internal/modfetch/coderepo.go +++ b/libgo/go/cmd/go/internal/modfetch/coderepo.go @@ -407,25 +407,26 @@ func (r *codeRepo) modPrefix(rev string) string { return r.modPath + "@" + rev } -func (r *codeRepo) Zip(version string, tmpdir string) (tmpfile string, err error) { +func (r *codeRepo) Zip(dst io.Writer, version string) error { rev, dir, _, err := r.findDir(version) if err != nil { - return "", err + return err } dl, actualDir, err := r.code.ReadZip(rev, dir, codehost.MaxZipFile) if err != nil { - return "", err + return err } + defer dl.Close() if actualDir != "" && !hasPathPrefix(dir, actualDir) { - return "", fmt.Errorf("internal error: downloading %v %v: dir=%q but actualDir=%q", r.path, rev, dir, actualDir) + return fmt.Errorf("internal error: downloading %v %v: dir=%q but actualDir=%q", r.path, rev, dir, actualDir) } subdir := strings.Trim(strings.TrimPrefix(dir, actualDir), "/") // Spool to local file. - f, err := ioutil.TempFile(tmpdir, "go-codehost-") + f, err := ioutil.TempFile("", "go-codehost-") if err != nil { dl.Close() - return "", err + return err } defer os.Remove(f.Name()) defer f.Close() @@ -433,35 +434,24 @@ func (r *codeRepo) Zip(version string, tmpdir string) (tmpfile string, err error lr := &io.LimitedReader{R: dl, N: maxSize + 1} if _, err := io.Copy(f, lr); err != nil { dl.Close() - return "", err + return err } dl.Close() if lr.N <= 0 { - return "", fmt.Errorf("downloaded zip file too large") + return fmt.Errorf("downloaded zip file too large") } size := (maxSize + 1) - lr.N if _, err := f.Seek(0, 0); err != nil { - return "", err + return err } // Translate from zip file we have to zip file we want. zr, err := zip.NewReader(f, size) if err != nil { - return "", err - } - f2, err := ioutil.TempFile(tmpdir, "go-codezip-") - if err != nil { - return "", err + return err } - zw := zip.NewWriter(f2) - newName := f2.Name() - defer func() { - f2.Close() - if err != nil { - os.Remove(newName) - } - }() + zw := zip.NewWriter(dst) if subdir != "" { subdir += "/" } @@ -472,12 +462,12 @@ func (r *codeRepo) Zip(version string, tmpdir string) (tmpfile string, err error if topPrefix == "" { i := strings.Index(zf.Name, "/") if i < 0 { - return "", fmt.Errorf("missing top-level directory prefix") + return fmt.Errorf("missing top-level directory prefix") } topPrefix = zf.Name[:i+1] } if !strings.HasPrefix(zf.Name, topPrefix) { - return "", fmt.Errorf("zip file contains more than one top-level directory") + return fmt.Errorf("zip file contains more than one top-level directory") } dir, file := path.Split(zf.Name) if file == "go.mod" { @@ -497,11 +487,17 @@ func (r *codeRepo) Zip(version string, tmpdir string) (tmpfile string, err error name = dir[:len(dir)-1] } } + for _, zf := range zr.File { + if !zf.FileInfo().Mode().IsRegular() { + // Skip symlinks (golang.org/issue/27093). + continue + } + if topPrefix == "" { i := strings.Index(zf.Name, "/") if i < 0 { - return "", fmt.Errorf("missing top-level directory prefix") + return fmt.Errorf("missing top-level directory prefix") } topPrefix = zf.Name[:i+1] } @@ -509,7 +505,7 @@ func (r *codeRepo) Zip(version string, tmpdir string) (tmpfile string, err error continue } if !strings.HasPrefix(zf.Name, topPrefix) { - return "", fmt.Errorf("zip file contains more than one top-level directory") + return fmt.Errorf("zip file contains more than one top-level directory") } name := strings.TrimPrefix(zf.Name, topPrefix) if !strings.HasPrefix(name, subdir) { @@ -529,28 +525,28 @@ func (r *codeRepo) Zip(version string, tmpdir string) (tmpfile string, err error } base := path.Base(name) if strings.ToLower(base) == "go.mod" && base != "go.mod" { - return "", fmt.Errorf("zip file contains %s, want all lower-case go.mod", zf.Name) + return fmt.Errorf("zip file contains %s, want all lower-case go.mod", zf.Name) } if name == "LICENSE" { haveLICENSE = true } - size := int64(zf.UncompressedSize) + size := int64(zf.UncompressedSize64) if size < 0 || maxSize < size { - return "", fmt.Errorf("module source tree too big") + return fmt.Errorf("module source tree too big") } maxSize -= size rc, err := zf.Open() if err != nil { - return "", err + return err } w, err := zw.Create(r.modPrefix(version) + "/" + name) lr := &io.LimitedReader{R: rc, N: size + 1} if _, err := io.Copy(w, lr); err != nil { - return "", err + return err } if lr.N <= 0 { - return "", fmt.Errorf("individual file too large") + return fmt.Errorf("individual file too large") } } @@ -559,21 +555,15 @@ func (r *codeRepo) Zip(version string, tmpdir string) (tmpfile string, err error if err == nil { w, err := zw.Create(r.modPrefix(version) + "/LICENSE") if err != nil { - return "", err + return err } if _, err := w.Write(data); err != nil { - return "", err + return err } } } - if err := zw.Close(); err != nil { - return "", err - } - if err := f2.Close(); err != nil { - return "", err - } - return f2.Name(), nil + return zw.Close() } // hasPathPrefix reports whether the path s begins with the diff --git a/libgo/go/cmd/go/internal/modfetch/coderepo_test.go b/libgo/go/cmd/go/internal/modfetch/coderepo_test.go index 79b82786cb9..c93d8dbe442 100644 --- a/libgo/go/cmd/go/internal/modfetch/coderepo_test.go +++ b/libgo/go/cmd/go/internal/modfetch/coderepo_test.go @@ -284,10 +284,10 @@ var codeRepoTests = []struct { { path: "gopkg.in/yaml.v2", rev: "v2", - version: "v2.2.1", - name: "5420a8b6744d3b0345ab293f6fcba19c978f1183", - short: "5420a8b6744d", - time: time.Date(2018, 3, 28, 19, 50, 20, 0, time.UTC), + version: "v2.2.2", + name: "51d6538a90f86fe93ac480b35f37b2be17fef232", + short: "51d6538a90f8", + time: time.Date(2018, 11, 15, 11, 05, 04, 0, time.UTC), gomod: "module \"gopkg.in/yaml.v2\"\n\nrequire (\n\t\"gopkg.in/check.v1\" v0.0.0-20161208181325-20d25e280405\n)\n", }, { @@ -391,7 +391,13 @@ func TestCodeRepo(t *testing.T) { } } if tt.zip != nil || tt.ziperr != "" { - zipfile, err := repo.Zip(tt.version, tmpdir) + f, err := ioutil.TempFile(tmpdir, tt.version+".zip.") + if err != nil { + t.Fatalf("ioutil.TempFile: %v", err) + } + zipfile := f.Name() + err = repo.Zip(f, tt.version) + f.Close() if err != nil { if tt.ziperr != "" { if err.Error() == tt.ziperr { @@ -423,7 +429,7 @@ func TestCodeRepo(t *testing.T) { } } } - t.Run(strings.Replace(tt.path, "/", "_", -1)+"/"+tt.rev, f) + t.Run(strings.ReplaceAll(tt.path, "/", "_")+"/"+tt.rev, f) if strings.HasPrefix(tt.path, vgotest1git) { for _, alt := range altVgotests { // Note: Communicating with f through tt; should be cleaned up. @@ -442,7 +448,7 @@ func TestCodeRepo(t *testing.T) { tt.rev = remap(tt.rev, m) tt.gomoderr = remap(tt.gomoderr, m) tt.ziperr = remap(tt.ziperr, m) - t.Run(strings.Replace(tt.path, "/", "_", -1)+"/"+tt.rev, f) + t.Run(strings.ReplaceAll(tt.path, "/", "_")+"/"+tt.rev, f) tt = old } } @@ -473,9 +479,9 @@ func remap(name string, m map[string]string) string { } } for k, v := range m { - name = strings.Replace(name, k, v, -1) + name = strings.ReplaceAll(name, k, v) if codehost.AllHex(k) { - name = strings.Replace(name, k[:12], v[:12], -1) + name = strings.ReplaceAll(name, k[:12], v[:12]) } } return name @@ -505,11 +511,11 @@ var codeRepoVersionsTests = []struct { }, { path: "gopkg.in/russross/blackfriday.v2", - versions: []string{"v2.0.0"}, + versions: []string{"v2.0.0", "v2.0.1"}, }, { path: "gopkg.in/natefinch/lumberjack.v2", - versions: nil, + versions: []string{"v2.0.0"}, }, } @@ -522,7 +528,7 @@ func TestCodeRepoVersions(t *testing.T) { } defer os.RemoveAll(tmpdir) for _, tt := range codeRepoVersionsTests { - t.Run(strings.Replace(tt.path, "/", "_", -1), func(t *testing.T) { + t.Run(strings.ReplaceAll(tt.path, "/", "_"), func(t *testing.T) { repo, err := Lookup(tt.path) if err != nil { t.Fatalf("Lookup(%q): %v", tt.path, err) @@ -570,7 +576,7 @@ func TestLatest(t *testing.T) { } defer os.RemoveAll(tmpdir) for _, tt := range latestTests { - name := strings.Replace(tt.path, "/", "_", -1) + name := strings.ReplaceAll(tt.path, "/", "_") t.Run(name, func(t *testing.T) { repo, err := Lookup(tt.path) if err != nil { diff --git a/libgo/go/cmd/go/internal/modfetch/fetch.go b/libgo/go/cmd/go/internal/modfetch/fetch.go index 2e26bac434d..81a6c843abc 100644 --- a/libgo/go/cmd/go/internal/modfetch/fetch.go +++ b/libgo/go/cmd/go/internal/modfetch/fetch.go @@ -21,6 +21,7 @@ import ( "cmd/go/internal/dirhash" "cmd/go/internal/module" "cmd/go/internal/par" + "cmd/go/internal/renameio" ) var downloadCache par.Cache @@ -34,9 +35,7 @@ func Download(mod module.Version) (dir string, err error) { return "", fmt.Errorf("missing modfetch.PkgMod") } - // The par.Cache here avoids duplicate work but also - // avoids conflicts from simultaneous calls by multiple goroutines - // for the same version. + // The par.Cache here avoids duplicate work. type cached struct { dir string err error @@ -46,16 +45,8 @@ func Download(mod module.Version) (dir string, err error) { if err != nil { return cached{"", err} } - if files, _ := ioutil.ReadDir(dir); len(files) == 0 { - zipfile, err := DownloadZip(mod) - if err != nil { - return cached{"", err} - } - modpath := mod.Path + "@" + mod.Version - if err := Unzip(dir, zipfile, modpath, 0); err != nil { - fmt.Fprintf(os.Stderr, "-> %s\n", err) - return cached{"", err} - } + if err := download(mod, dir); err != nil { + return cached{"", err} } checkSum(mod) return cached{dir, nil} @@ -63,14 +54,88 @@ func Download(mod module.Version) (dir string, err error) { return c.dir, c.err } +func download(mod module.Version, dir string) (err error) { + // If the directory exists, the module has already been extracted. + fi, err := os.Stat(dir) + if err == nil && fi.IsDir() { + return nil + } + + // To avoid cluttering the cache with extraneous files, + // DownloadZip uses the same lockfile as Download. + // Invoke DownloadZip before locking the file. + zipfile, err := DownloadZip(mod) + if err != nil { + return err + } + + if cfg.CmdName != "mod download" { + fmt.Fprintf(os.Stderr, "go: extracting %s %s\n", mod.Path, mod.Version) + } + + unlock, err := lockVersion(mod) + if err != nil { + return err + } + defer unlock() + + // Check whether the directory was populated while we were waiting on the lock. + fi, err = os.Stat(dir) + if err == nil && fi.IsDir() { + return nil + } + + // Clean up any remaining temporary directories from previous runs. + // This is only safe to do because the lock file ensures that their writers + // are no longer active. + parentDir := filepath.Dir(dir) + tmpPrefix := filepath.Base(dir) + ".tmp-" + if old, err := filepath.Glob(filepath.Join(parentDir, tmpPrefix+"*")); err == nil { + for _, path := range old { + RemoveAll(path) // best effort + } + } + + // Extract the zip file to a temporary directory, then rename it to the + // final path. That way, we can use the existence of the source directory to + // signal that it has been extracted successfully, and if someone deletes + // the entire directory (e.g. as an attempt to prune out file corruption) + // the module cache will still be left in a recoverable state. + if err := os.MkdirAll(parentDir, 0777); err != nil { + return err + } + tmpDir, err := ioutil.TempDir(parentDir, tmpPrefix) + if err != nil { + return err + } + defer func() { + if err != nil { + RemoveAll(tmpDir) + } + }() + + modpath := mod.Path + "@" + mod.Version + if err := Unzip(tmpDir, zipfile, modpath, 0); err != nil { + fmt.Fprintf(os.Stderr, "-> %s\n", err) + return err + } + + if err := os.Rename(tmpDir, dir); err != nil { + return err + } + + // Make dir read-only only *after* renaming it. + // os.Rename was observed to fail for read-only directories on macOS. + makeDirsReadOnly(dir) + return nil +} + var downloadZipCache par.Cache // DownloadZip downloads the specific module version to the // local zip cache and returns the name of the zip file. func DownloadZip(mod module.Version) (zipfile string, err error) { - // The par.Cache here avoids duplicate work but also - // avoids conflicts from simultaneous calls by multiple goroutines - // for the same version. + // The par.Cache here avoids duplicate work. type cached struct { zipfile string err error @@ -80,83 +145,134 @@ func DownloadZip(mod module.Version) (zipfile string, err error) { if err != nil { return cached{"", err} } + + // Skip locking if the zipfile already exists. if _, err := os.Stat(zipfile); err == nil { - // Use it. - // This should only happen if the mod/cache directory is preinitialized - // or if pkg/mod/path was removed but not pkg/mod/cache/download. - if cfg.CmdName != "mod download" { - fmt.Fprintf(os.Stderr, "go: extracting %s %s\n", mod.Path, mod.Version) - } - } else { - if err := os.MkdirAll(filepath.Dir(zipfile), 0777); err != nil { - return cached{"", err} - } - if cfg.CmdName != "mod download" { - fmt.Fprintf(os.Stderr, "go: downloading %s %s\n", mod.Path, mod.Version) - } - if err := downloadZip(mod, zipfile); err != nil { - return cached{"", err} - } + return cached{zipfile, nil} + } + + // The zip file does not exist. Acquire the lock and create it. + if cfg.CmdName != "mod download" { + fmt.Fprintf(os.Stderr, "go: downloading %s %s\n", mod.Path, mod.Version) + } + unlock, err := lockVersion(mod) + if err != nil { + return cached{"", err} + } + defer unlock() + + // Double-check that the zipfile was not created while we were waiting for + // the lock. + if _, err := os.Stat(zipfile); err == nil { + return cached{zipfile, nil} + } + if err := os.MkdirAll(filepath.Dir(zipfile), 0777); err != nil { + return cached{"", err} + } + if err := downloadZip(mod, zipfile); err != nil { + return cached{"", err} } return cached{zipfile, nil} }).(cached) return c.zipfile, c.err } -func downloadZip(mod module.Version, target string) error { - repo, err := Lookup(mod.Path) +func downloadZip(mod module.Version, zipfile string) (err error) { + // Clean up any remaining tempfiles from previous runs. + // This is only safe to do because the lock file ensures that their + // writers are no longer active. + for _, base := range []string{zipfile, zipfile + "hash"} { + if old, err := filepath.Glob(renameio.Pattern(base)); err == nil { + for _, path := range old { + os.Remove(path) // best effort + } + } + } + + // From here to the os.Rename call below is functionally almost equivalent to + // renameio.WriteToFile, with one key difference: we want to validate the + // contents of the file (by hashing it) before we commit it. Because the file + // is zip-compressed, we need an actual file — or at least an io.ReaderAt — to + // validate it: we can't just tee the stream as we write it. + f, err := ioutil.TempFile(filepath.Dir(zipfile), filepath.Base(renameio.Pattern(zipfile))) if err != nil { return err } - tmpfile, err := repo.Zip(mod.Version, os.TempDir()) + defer func() { + if err != nil { + f.Close() + os.Remove(f.Name()) + } + }() + + repo, err := Lookup(mod.Path) if err != nil { return err } - defer os.Remove(tmpfile) + if err := repo.Zip(f, mod.Version); err != nil { + return err + } - // Double-check zip file looks OK. - z, err := zip.OpenReader(tmpfile) + // Double-check that the paths within the zip file are well-formed. + // + // TODO(bcmills): There is a similar check within the Unzip function. Can we eliminate one? + fi, err := f.Stat() if err != nil { return err } - prefix := mod.Path + "@" + mod.Version + z, err := zip.NewReader(f, fi.Size()) + if err != nil { + return err + } + prefix := mod.Path + "@" + mod.Version + "/" for _, f := range z.File { if !strings.HasPrefix(f.Name, prefix) { - z.Close() return fmt.Errorf("zip for %s has unexpected file %s", prefix[:len(prefix)-1], f.Name) } } - z.Close() - hash, err := dirhash.HashZip(tmpfile, dirhash.DefaultHash) - if err != nil { + // Sync the file before renaming it: otherwise, after a crash the reader may + // observe a 0-length file instead of the actual contents. + // See https://golang.org/issue/22397#issuecomment-380831736. + if err := f.Sync(); err != nil { return err } - checkOneSum(mod, hash) // check before installing the zip file - r, err := os.Open(tmpfile) - if err != nil { + if err := f.Close(); err != nil { return err } - defer r.Close() - w, err := os.Create(target) + + // Hash the zip file and check the sum before renaming to the final location. + hash, err := dirhash.HashZip(f.Name(), dirhash.DefaultHash) if err != nil { return err } - if _, err := io.Copy(w, r); err != nil { - w.Close() - return fmt.Errorf("copying: %v", err) + checkOneSum(mod, hash) + + if err := renameio.WriteFile(zipfile+"hash", []byte(hash)); err != nil { + return err } - if err := w.Close(); err != nil { + if err := os.Rename(f.Name(), zipfile); err != nil { return err } - return ioutil.WriteFile(target+"hash", []byte(hash), 0666) + + // TODO(bcmills): Should we make the .zip and .ziphash files read-only to discourage tampering? + + return nil } var GoSumFile string // path to go.sum; set by package modload +type modSum struct { + mod module.Version + sum string +} + var goSum struct { mu sync.Mutex m map[module.Version][]string // content of go.sum file (+ go.modverify if present) + checked map[modSum]bool // sums actually checked during execution + dirty bool // whether we added any new sums to m + overwrite bool // if true, overwrite go.sum without incorporating its contents enabled bool // whether to use go.sum at all modverify string // path to go.modverify, to be deleted } @@ -173,18 +289,25 @@ func initGoSum() bool { } goSum.m = make(map[module.Version][]string) + goSum.checked = make(map[modSum]bool) data, err := ioutil.ReadFile(GoSumFile) if err != nil && !os.IsNotExist(err) { base.Fatalf("go: %v", err) } goSum.enabled = true - readGoSum(GoSumFile, data) + readGoSum(goSum.m, GoSumFile, data) // Add old go.modverify file. // We'll delete go.modverify in WriteGoSum. alt := strings.TrimSuffix(GoSumFile, ".sum") + ".modverify" if data, err := ioutil.ReadFile(alt); err == nil { - readGoSum(alt, data) + migrate := make(map[module.Version][]string) + readGoSum(migrate, alt, data) + for mod, sums := range migrate { + for _, sum := range sums { + checkOneSumLocked(mod, sum) + } + } goSum.modverify = alt } return true @@ -197,7 +320,7 @@ const emptyGoModHash = "h1:G7mAYYxgmS0lVkHyy2hEOLQCFB0DlQFTMLWggykrydY=" // readGoSum parses data, which is the content of file, // and adds it to goSum.m. The goSum lock must be held. -func readGoSum(file string, data []byte) { +func readGoSum(dst map[module.Version][]string, file string, data []byte) { lineno := 0 for len(data) > 0 { var line []byte @@ -221,7 +344,7 @@ func readGoSum(file string, data []byte) { continue } mod := module.Version{Path: f[0], Version: f[1]} - goSum.m[mod] = append(goSum.m[mod], f[2]) + dst[mod] = append(dst[mod], f[2]) } } @@ -235,7 +358,7 @@ func checkSum(mod module.Version) { // Do the file I/O before acquiring the go.sum lock. ziphash, err := CachePath(mod, "ziphash") if err != nil { - base.Fatalf("go: verifying %s@%s: %v", mod.Path, mod.Version, err) + base.Fatalf("verifying %s@%s: %v", mod.Path, mod.Version, err) } data, err := ioutil.ReadFile(ziphash) if err != nil { @@ -243,11 +366,11 @@ func checkSum(mod module.Version) { // This can happen if someone does rm -rf GOPATH/src/cache/download. So it goes. return } - base.Fatalf("go: verifying %s@%s: %v", mod.Path, mod.Version, err) + base.Fatalf("verifying %s@%s: %v", mod.Path, mod.Version, err) } h := strings.TrimSpace(string(data)) if !strings.HasPrefix(h, "h1:") { - base.Fatalf("go: verifying %s@%s: unexpected ziphash: %q", mod.Path, mod.Version, h) + base.Fatalf("verifying %s@%s: unexpected ziphash: %q", mod.Path, mod.Version, h) } checkOneSum(mod, h) @@ -265,7 +388,7 @@ func goModSum(data []byte) (string, error) { func checkGoMod(path, version string, data []byte) { h, err := goModSum(data) if err != nil { - base.Fatalf("go: verifying %s %s go.mod: %v", path, version, err) + base.Fatalf("verifying %s %s go.mod: %v", path, version, err) } checkOneSum(module.Version{Path: path, Version: version + "/go.mod"}, h) @@ -275,22 +398,27 @@ func checkGoMod(path, version string, data []byte) { func checkOneSum(mod module.Version, h string) { goSum.mu.Lock() defer goSum.mu.Unlock() - if !initGoSum() { - return + if initGoSum() { + checkOneSumLocked(mod, h) } +} + +func checkOneSumLocked(mod module.Version, h string) { + goSum.checked[modSum{mod, h}] = true for _, vh := range goSum.m[mod] { if h == vh { return } if strings.HasPrefix(vh, "h1:") { - base.Fatalf("go: verifying %s@%s: checksum mismatch\n\tdownloaded: %v\n\tgo.sum: %v", mod.Path, mod.Version, h, vh) + base.Fatalf("verifying %s@%s: checksum mismatch\n\tdownloaded: %v\n\tgo.sum: %v", mod.Path, mod.Version, h, vh) } } if len(goSum.m[mod]) > 0 { fmt.Fprintf(os.Stderr, "warning: verifying %s@%s: unknown hashes in go.sum: %v; adding %v", mod.Path, mod.Version, strings.Join(goSum.m[mod], ", "), h) } goSum.m[mod] = append(goSum.m[mod], h) + goSum.dirty = true } // Sum returns the checksum for the downloaded copy of the given module, @@ -316,10 +444,55 @@ func Sum(mod module.Version) string { func WriteGoSum() { goSum.mu.Lock() defer goSum.mu.Unlock() - if !initGoSum() { + + if !goSum.enabled { + // If we haven't read the go.sum file yet, don't bother writing it: at best, + // we could rename the go.modverify file if it isn't empty, but we haven't + // needed to touch it so far — how important could it be? + return + } + if !goSum.dirty { + // Don't bother opening the go.sum file if we don't have anything to add. return } + // We want to avoid races between creating the lockfile and deleting it, but + // we also don't want to leave a permanent lockfile in the user's repository. + // + // On top of that, if we crash while writing go.sum, we don't want to lose the + // sums that were already present in the file, so it's important that we write + // the file by renaming rather than truncating — which means that we can't + // lock the go.sum file itself. + // + // Instead, we'll lock a distinguished file in the cache directory: that will + // only race if the user runs `go clean -modcache` concurrently with a command + // that updates go.sum, and that's already racy to begin with. + // + // We'll end up slightly over-synchronizing go.sum writes if the user runs a + // bunch of go commands that update sums in separate modules simultaneously, + // but that's unlikely to matter in practice. + + unlock := SideLock() + defer unlock() + + if !goSum.overwrite { + // Re-read the go.sum file to incorporate any sums added by other processes + // in the meantime. + data, err := ioutil.ReadFile(GoSumFile) + if err != nil && !os.IsNotExist(err) { + base.Fatalf("go: re-reading go.sum: %v", err) + } + + // Add only the sums that we actually checked: the user may have edited or + // truncated the file to remove erroneous hashes, and we shouldn't restore + // them without good reason. + goSum.m = make(map[module.Version][]string, len(goSum.m)) + readGoSum(goSum.m, GoSumFile, data) + for ms := range goSum.checked { + checkOneSumLocked(ms.mod, ms.sum) + } + } + var mods []module.Version for m := range goSum.m { mods = append(mods, m) @@ -334,15 +507,16 @@ func WriteGoSum() { } } - data, _ := ioutil.ReadFile(GoSumFile) - if !bytes.Equal(data, buf.Bytes()) { - if err := ioutil.WriteFile(GoSumFile, buf.Bytes(), 0666); err != nil { - base.Fatalf("go: writing go.sum: %v", err) - } + if err := renameio.WriteFile(GoSumFile, buf.Bytes()); err != nil { + base.Fatalf("go: writing go.sum: %v", err) } + goSum.checked = make(map[modSum]bool) + goSum.dirty = false + goSum.overwrite = false + if goSum.modverify != "" { - os.Remove(goSum.modverify) + os.Remove(goSum.modverify) // best effort } } @@ -360,6 +534,8 @@ func TrimGoSum(keep map[module.Version]bool) { noGoMod := module.Version{Path: m.Path, Version: strings.TrimSuffix(m.Version, "/go.mod")} if !keep[m] && !keep[noGoMod] { delete(goSum.m, m) + goSum.dirty = true + goSum.overwrite = true } } } diff --git a/libgo/go/cmd/go/internal/modfetch/proxy.go b/libgo/go/cmd/go/internal/modfetch/proxy.go index 5f856b80d2e..60ed2a37966 100644 --- a/libgo/go/cmd/go/internal/modfetch/proxy.go +++ b/libgo/go/cmd/go/internal/modfetch/proxy.go @@ -8,7 +8,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/url" "os" "strings" @@ -209,44 +208,31 @@ func (p *proxyRepo) GoMod(version string) ([]byte, error) { return data, nil } -func (p *proxyRepo) Zip(version string, tmpdir string) (tmpfile string, err error) { +func (p *proxyRepo) Zip(dst io.Writer, version string) error { var body io.ReadCloser encVer, err := module.EncodeVersion(version) if err != nil { - return "", err + return err } err = webGetBody(p.url+"/@v/"+pathEscape(encVer)+".zip", &body) if err != nil { - return "", err + return err } defer body.Close() - // Spool to local file. - f, err := ioutil.TempFile(tmpdir, "go-proxy-download-") - if err != nil { - return "", err - } - defer f.Close() - maxSize := int64(codehost.MaxZipFile) - lr := &io.LimitedReader{R: body, N: maxSize + 1} - if _, err := io.Copy(f, lr); err != nil { - os.Remove(f.Name()) - return "", err + lr := &io.LimitedReader{R: body, N: codehost.MaxZipFile + 1} + if _, err := io.Copy(dst, lr); err != nil { + return err } if lr.N <= 0 { - os.Remove(f.Name()) - return "", fmt.Errorf("downloaded zip file too large") - } - if err := f.Close(); err != nil { - os.Remove(f.Name()) - return "", err + return fmt.Errorf("downloaded zip file too large") } - return f.Name(), nil + return nil } // pathEscape escapes s so it can be used in a path. // That is, it escapes things like ? and # (which really shouldn't appear anyway). // It does not escape / to %2F: our REST API is designed so that / can be left as is. func pathEscape(s string) string { - return strings.Replace(url.PathEscape(s), "%2F", "/", -1) + return strings.ReplaceAll(url.PathEscape(s), "%2F", "/") } diff --git a/libgo/go/cmd/go/internal/modfetch/repo.go b/libgo/go/cmd/go/internal/modfetch/repo.go index 0ea8c1f0e35..c63f6b04221 100644 --- a/libgo/go/cmd/go/internal/modfetch/repo.go +++ b/libgo/go/cmd/go/internal/modfetch/repo.go @@ -6,8 +6,10 @@ package modfetch import ( "fmt" + "io" "os" "sort" + "strconv" "time" "cmd/go/internal/cfg" @@ -45,11 +47,8 @@ type Repo interface { // GoMod returns the go.mod file for the given version. GoMod(version string) (data []byte, err error) - // Zip downloads a zip file for the given version - // to a new file in a given temporary directory. - // It returns the name of the new file. - // The caller should remove the file when finished with it. - Zip(version, tmpdir string) (tmpfile string, err error) + // Zip writes a zip file for the given version to dst. + Zip(dst io.Writer, version string) error } // A Rev describes a single revision in a module repository. @@ -357,7 +356,11 @@ func (l *loggingRepo) GoMod(version string) ([]byte, error) { return l.r.GoMod(version) } -func (l *loggingRepo) Zip(version, tmpdir string) (string, error) { - defer logCall("Repo[%s]: Zip(%q, %q)", l.r.ModulePath(), version, tmpdir)() - return l.r.Zip(version, tmpdir) +func (l *loggingRepo) Zip(dst io.Writer, version string) error { + dstName := "_" + if dst, ok := dst.(interface{ Name() string }); ok { + dstName = strconv.Quote(dst.Name()) + } + defer logCall("Repo[%s]: Zip(%s, %q)", l.r.ModulePath(), dstName, version)() + return l.r.Zip(dst, version) } diff --git a/libgo/go/cmd/go/internal/modfetch/unzip.go b/libgo/go/cmd/go/internal/modfetch/unzip.go index a50431fd862..ac13ede257b 100644 --- a/libgo/go/cmd/go/internal/modfetch/unzip.go +++ b/libgo/go/cmd/go/internal/modfetch/unzip.go @@ -12,7 +12,6 @@ import ( "os" "path" "path/filepath" - "sort" "strings" "cmd/go/internal/modfetch/codehost" @@ -21,12 +20,12 @@ import ( ) func Unzip(dir, zipfile, prefix string, maxSize int64) error { + // TODO(bcmills): The maxSize parameter is invariantly 0. Remove it. if maxSize == 0 { maxSize = codehost.MaxZipFile } // Directory can exist, but must be empty. - // except maybe files, _ := ioutil.ReadDir(dir) if len(files) > 0 { return fmt.Errorf("target directory %v exists and is not empty", dir) @@ -98,22 +97,16 @@ func Unzip(dir, zipfile, prefix string, maxSize int64) error { } // Unzip, enforcing sizes checked earlier. - dirs := map[string]bool{dir: true} for _, zf := range z.File { if zf.Name == prefix || strings.HasSuffix(zf.Name, "/") { continue } name := zf.Name[len(prefix):] dst := filepath.Join(dir, name) - parent := filepath.Dir(dst) - for parent != dir { - dirs[parent] = true - parent = filepath.Dir(parent) - } if err := os.MkdirAll(filepath.Dir(dst), 0777); err != nil { return err } - w, err := os.OpenFile(dst, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0444) + w, err := os.OpenFile(dst, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0444) if err != nil { return fmt.Errorf("unzip %v: %v", zipfile, err) } @@ -137,17 +130,44 @@ func Unzip(dir, zipfile, prefix string, maxSize int64) error { } } - // Mark directories unwritable, best effort. - var dirlist []string - for dir := range dirs { - dirlist = append(dirlist, dir) + return nil +} + +// makeDirsReadOnly makes a best-effort attempt to remove write permissions for dir +// and its transitive contents. +func makeDirsReadOnly(dir string) { + type pathMode struct { + path string + mode os.FileMode } - sort.Strings(dirlist) + var dirs []pathMode // in lexical order + filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { + if err == nil && info.Mode()&0222 != 0 { + if info.IsDir() { + dirs = append(dirs, pathMode{path, info.Mode()}) + } + } + return nil + }) // Run over list backward to chmod children before parents. - for i := len(dirlist) - 1; i >= 0; i-- { - os.Chmod(dirlist[i], 0555) + for i := len(dirs) - 1; i >= 0; i-- { + os.Chmod(dirs[i].path, dirs[i].mode&^0222) } +} - return nil +// RemoveAll removes a directory written by Download or Unzip, first applying +// any permission changes needed to do so. +func RemoveAll(dir string) error { + // Module cache has 0555 directories; make them writable in order to remove content. + filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { + if err != nil { + return nil // ignore errors walking in file system + } + if info.IsDir() { + os.Chmod(path, 0777) + } + return nil + }) + return os.RemoveAll(dir) } diff --git a/libgo/go/cmd/go/internal/modfile/rule.go b/libgo/go/cmd/go/internal/modfile/rule.go index e11f0a6e31e..7f9a18c6c2a 100644 --- a/libgo/go/cmd/go/internal/modfile/rule.go +++ b/libgo/go/cmd/go/internal/modfile/rule.go @@ -154,7 +154,7 @@ func parseToFile(file string, data []byte, fix VersionFixer, strict bool) (*File return f, nil } -var goVersionRE = regexp.MustCompile(`([1-9][0-9]*)\.(0|[1-9][0-9]*)`) +var GoVersionRE = regexp.MustCompile(`([1-9][0-9]*)\.(0|[1-9][0-9]*)`) func (f *File) add(errs *bytes.Buffer, line *Line, verb string, args []string, fix VersionFixer, strict bool) { // If strict is false, this module is a dependency. @@ -181,7 +181,7 @@ func (f *File) add(errs *bytes.Buffer, line *Line, verb string, args []string, f fmt.Fprintf(errs, "%s:%d: repeated go statement\n", f.Syntax.Name, line.Start.Line) return } - if len(args) != 1 || !goVersionRE.MatchString(args[0]) { + if len(args) != 1 || !GoVersionRE.MatchString(args[0]) { fmt.Fprintf(errs, "%s:%d: usage: go 1.23\n", f.Syntax.Name, line.Start.Line) return } @@ -477,6 +477,22 @@ func (f *File) Cleanup() { f.Syntax.Cleanup() } +func (f *File) AddGoStmt(version string) error { + if !GoVersionRE.MatchString(version) { + return fmt.Errorf("invalid language version string %q", version) + } + if f.Go == nil { + f.Go = &Go{ + Version: version, + Syntax: f.Syntax.addLine(nil, "go", version), + } + } else { + f.Go.Version = version + f.Syntax.updateLine(f.Go.Syntax, "go", version) + } + return nil +} + func (f *File) AddRequire(path, vers string) error { need := true for _, r := range f.Require { diff --git a/libgo/go/cmd/go/internal/modget/get.go b/libgo/go/cmd/go/internal/modget/get.go index 90a5bd81302..2bfe6d3bb23 100644 --- a/libgo/go/cmd/go/internal/modget/get.go +++ b/libgo/go/cmd/go/internal/modget/get.go @@ -78,7 +78,7 @@ to use newer patch releases when available. Continuing the previous example, In general, adding a new dependency may require upgrading existing dependencies to keep a working build, and 'go get' does this automatically. Similarly, downgrading one dependency may -require downgrading other dependenceis, and 'go get' does +require downgrading other dependencies, and 'go get' does this automatically as well. The -m flag instructs get to stop here, after resolving, upgrading, @@ -247,7 +247,7 @@ func runGet(cmd *base.Command, args []string) { // Deciding which module to upgrade/downgrade for a particular argument is difficult. // Patterns only make it more difficult. // We impose restrictions to avoid needing to interlace pattern expansion, - // like in in modload.ImportPaths. + // like in modload.ImportPaths. // Specifically, these patterns are supported: // // - Relative paths like ../../foo or ../../foo... are restricted to matching directories @@ -281,8 +281,8 @@ func runGet(cmd *base.Command, args []string) { base.Errorf("go get %s: %v", arg, err) continue } - if !str.HasFilePathPrefix(abs, modload.ModRoot) { - base.Errorf("go get %s: directory %s is outside module root %s", arg, abs, modload.ModRoot) + if !str.HasFilePathPrefix(abs, modload.ModRoot()) { + base.Errorf("go get %s: directory %s is outside module root %s", arg, abs, modload.ModRoot()) continue } // TODO: Check if abs is inside a nested module. @@ -534,9 +534,11 @@ func runGet(cmd *base.Command, args []string) { // module root. continue } + base.Errorf("%s", p.Error) } todo = append(todo, p) } + base.ExitIfErrors() // If -d was specified, we're done after the download: no build. // (The load.PackagesAndErrors is what did the download diff --git a/libgo/go/cmd/go/internal/modload/build.go b/libgo/go/cmd/go/internal/modload/build.go index 558401d01f6..af89b192fe4 100644 --- a/libgo/go/cmd/go/internal/modload/build.go +++ b/libgo/go/cmd/go/internal/modload/build.go @@ -17,6 +17,7 @@ import ( "internal/goroot" "os" "path/filepath" + "runtime/debug" "strings" ) @@ -30,6 +31,9 @@ func isStandardImportPath(path string) bool { } func findStandardImportPath(path string) string { + if path == "" { + panic("findStandardImportPath called with empty path") + } if search.IsStandardImportPath(path) { if goroot.IsStandardPackage(cfg.GOROOT, cfg.BuildContext.Compiler, path) { return filepath.Join(cfg.GOROOT, "src", path) @@ -95,11 +99,13 @@ func moduleInfo(m module.Version, fromBuildList bool) *modinfo.ModulePublic { Path: m.Path, Version: m.Version, Main: true, - Dir: ModRoot, - GoMod: filepath.Join(ModRoot, "go.mod"), } - if modFile.Go != nil { - info.GoVersion = modFile.Go.Version + if HasModRoot() { + info.Dir = ModRoot() + info.GoMod = filepath.Join(info.Dir, "go.mod") + if modFile.Go != nil { + info.GoVersion = modFile.Go.Version + } } return info } @@ -114,7 +120,7 @@ func moduleInfo(m module.Version, fromBuildList bool) *modinfo.ModulePublic { } if cfg.BuildMod == "vendor" { - info.Dir = filepath.Join(ModRoot, "vendor", m.Path) + info.Dir = filepath.Join(ModRoot(), "vendor", m.Path) return info } @@ -142,34 +148,38 @@ func moduleInfo(m module.Version, fromBuildList bool) *modinfo.ModulePublic { } } } - if cfg.BuildMod == "vendor" { - m.Dir = filepath.Join(ModRoot, "vendor", m.Path) - } } - complete(info) + if !fromBuildList { + complete(info) + return info + } - if fromBuildList { - if r := Replacement(m); r.Path != "" { - info.Replace = &modinfo.ModulePublic{ - Path: r.Path, - Version: r.Version, - GoVersion: info.GoVersion, - } - if r.Version == "" { - if filepath.IsAbs(r.Path) { - info.Replace.Dir = r.Path - } else { - info.Replace.Dir = filepath.Join(ModRoot, r.Path) - } - } - complete(info.Replace) - info.Dir = info.Replace.Dir - info.GoMod = filepath.Join(info.Dir, "go.mod") - info.Error = nil // ignore error loading original module version (it has been replaced) - } + r := Replacement(m) + if r.Path == "" { + complete(info) + return info } + // Don't hit the network to fill in extra data for replaced modules. + // The original resolved Version and Time don't matter enough to be + // worth the cost, and we're going to overwrite the GoMod and Dir from the + // replacement anyway. See https://golang.org/issue/27859. + info.Replace = &modinfo.ModulePublic{ + Path: r.Path, + Version: r.Version, + GoVersion: info.GoVersion, + } + if r.Version == "" { + if filepath.IsAbs(r.Path) { + info.Replace.Dir = r.Path + } else { + info.Replace.Dir = filepath.Join(ModRoot(), r.Path) + } + } + complete(info.Replace) + info.Dir = info.Replace.Dir + info.GoMod = filepath.Join(info.Dir, "go.mod") return info } @@ -177,6 +187,7 @@ func PackageBuildInfo(path string, deps []string) string { if isStandardImportPath(path) || !Enabled() { return "" } + target := findModule(path, path) mdeps := make(map[module.Version]bool) for _, dep := range deps { @@ -216,28 +227,33 @@ func PackageBuildInfo(path string, deps []string) string { return buf.String() } +// findModule returns the module containing the package at path, +// needed to build the package at target. func findModule(target, path string) module.Version { - // TODO: This should use loaded. - if path == "." { - return buildList[0] - } - for _, mod := range buildList { - if maybeInModule(path, mod.Path) { - return mod + pkg, ok := loaded.pkgCache.Get(path).(*loadPkg) + if ok { + if pkg.err != nil { + base.Fatalf("build %v: cannot load %v: %v", target, path, pkg.err) } + return pkg.mod + } + + if path == "command-line-arguments" { + return Target + } + + if printStackInDie { + debug.PrintStack() } base.Fatalf("build %v: cannot find module for path %v", target, path) panic("unreachable") } func ModInfoProg(info string) []byte { - return []byte(fmt.Sprintf(` - package main - import _ "unsafe" - //go:linkname __debug_modinfo__ runtime/debug.modinfo - var __debug_modinfo__ string - func init() { - __debug_modinfo__ = %q - } + return []byte(fmt.Sprintf(`package main +import _ "unsafe" +//go:linkname __set_debug_modinfo__ runtime..z2fdebug.setmodinfo +func __set_debug_modinfo__(string) +func init() { __set_debug_modinfo__(%q) } `, string(infoStart)+info+string(infoEnd))) } diff --git a/libgo/go/cmd/go/internal/modload/help.go b/libgo/go/cmd/go/internal/modload/help.go index f2f34197244..d9c8ae40d88 100644 --- a/libgo/go/cmd/go/internal/modload/help.go +++ b/libgo/go/cmd/go/internal/modload/help.go @@ -393,17 +393,20 @@ no /* */ comments. Each line holds a single directive, made up of a verb followed by arguments. For example: module my/thing + go 1.12 require other/thing v1.0.2 - require new/thing v2.3.4 + require new/thing/v2 v2.3.4 exclude old/thing v1.2.3 replace bad/thing v1.4.5 => good/thing v1.4.5 -The verbs are module, to define the module path; require, to require -a particular module at a given version or later; exclude, to exclude -a particular module version from use; and replace, to replace a module -version with a different module version. Exclude and replace apply only -in the main module's go.mod and are ignored in dependencies. -See https://research.swtch.com/vgo-mvs for details. +The verbs are + module, to define the module path; + go, to set the expected language version; + require, to require a particular module at a given version or later; + exclude, to exclude a particular module version from use; and + replace, to replace a module version with a different module version. +Exclude and replace apply only in the main module's go.mod and are ignored +in dependencies. See https://research.swtch.com/vgo-mvs for details. The leading verb can be factored out of adjacent lines to create a block, like in Go imports: diff --git a/libgo/go/cmd/go/internal/modload/import.go b/libgo/go/cmd/go/internal/modload/import.go index 44c2a237267..3210e16c25b 100644 --- a/libgo/go/cmd/go/internal/modload/import.go +++ b/libgo/go/cmd/go/internal/modload/import.go @@ -12,13 +12,17 @@ import ( "internal/goroot" "os" "path/filepath" + "sort" "strings" + "time" "cmd/go/internal/cfg" + "cmd/go/internal/modfetch" "cmd/go/internal/modfetch/codehost" "cmd/go/internal/module" "cmd/go/internal/par" "cmd/go/internal/search" + "cmd/go/internal/semver" ) type ImportMissingError struct { @@ -58,9 +62,6 @@ func Import(path string) (m module.Version, dir string, err error) { // Is the package in the standard library? if search.IsStandardImportPath(path) { - if strings.HasPrefix(path, "golang_org/") { - return module.Version{}, filepath.Join(cfg.GOROOT, "src/vendor", path), nil - } if goroot.IsStandardPackage(cfg.GOROOT, cfg.BuildContext.Compiler, path) { dir := filepath.Join(cfg.GOROOT, "src", path) return module.Version{}, dir, nil @@ -70,8 +71,8 @@ func Import(path string) (m module.Version, dir string, err error) { // -mod=vendor is special. // Everything must be in the main module or the main module's vendor directory. if cfg.BuildMod == "vendor" { - mainDir, mainOK := dirInModule(path, Target.Path, ModRoot, true) - vendorDir, vendorOK := dirInModule(path, "", filepath.Join(ModRoot, "vendor"), false) + mainDir, mainOK := dirInModule(path, Target.Path, ModRoot(), true) + vendorDir, vendorOK := dirInModule(path, "", filepath.Join(ModRoot(), "vendor"), false) if mainOK && vendorOK { return module.Version{}, "", fmt.Errorf("ambiguous import: found %s in multiple directories:\n\t%s\n\t%s", path, mainDir, vendorDir) } @@ -125,14 +126,58 @@ func Import(path string) (m module.Version, dir string, err error) { return module.Version{}, "", errors.New(buf.String()) } - // Not on build list. - // Look up module containing the package, for addition to the build list. // Goal is to determine the module, download it to dir, and return m, dir, ErrMissing. if cfg.BuildMod == "readonly" { return module.Version{}, "", fmt.Errorf("import lookup disabled by -mod=%s", cfg.BuildMod) } + // Not on build list. + // To avoid spurious remote fetches, next try the latest replacement for each module. + // (golang.org/issue/26241) + if modFile != nil { + latest := map[string]string{} // path -> version + for _, r := range modFile.Replace { + if maybeInModule(path, r.Old.Path) { + latest[r.Old.Path] = semver.Max(r.Old.Version, latest[r.Old.Path]) + } + } + + mods = make([]module.Version, 0, len(latest)) + for p, v := range latest { + // If the replacement didn't specify a version, synthesize a + // pseudo-version with an appropriate major version and a timestamp below + // any real timestamp. That way, if the main module is used from within + // some other module, the user will be able to upgrade the requirement to + // any real version they choose. + if v == "" { + if _, pathMajor, ok := module.SplitPathVersion(p); ok && len(pathMajor) > 0 { + v = modfetch.PseudoVersion(pathMajor[1:], "", time.Time{}, "000000000000") + } else { + v = modfetch.PseudoVersion("v0", "", time.Time{}, "000000000000") + } + } + mods = append(mods, module.Version{Path: p, Version: v}) + } + + // Every module path in mods is a prefix of the import path. + // As in QueryPackage, prefer the longest prefix that satisfies the import. + sort.Slice(mods, func(i, j int) bool { + return len(mods[i].Path) > len(mods[j].Path) + }) + for _, m := range mods { + root, isLocal, err := fetch(m) + if err != nil { + // Report fetch error as above. + return module.Version{}, "", err + } + _, ok := dirInModule(path, m.Path, root, isLocal) + if ok { + return m, "", &ImportMissingError{ImportPath: path, Module: m} + } + } + } + m, _, err = QueryPackage(path, "latest", Allowed) if err != nil { if _, ok := err.(*codehost.VCSError); ok { diff --git a/libgo/go/cmd/go/internal/modload/import_test.go b/libgo/go/cmd/go/internal/modload/import_test.go index 3f4ddab436c..9422a3d960c 100644 --- a/libgo/go/cmd/go/internal/modload/import_test.go +++ b/libgo/go/cmd/go/internal/modload/import_test.go @@ -45,7 +45,7 @@ func TestImport(t *testing.T) { testenv.MustHaveExternalNetwork(t) for _, tt := range importTests { - t.Run(strings.Replace(tt.path, "/", "_", -1), func(t *testing.T) { + t.Run(strings.ReplaceAll(tt.path, "/", "_"), func(t *testing.T) { // Note that there is no build list, so Import should always fail. m, dir, err := Import(tt.path) if err == nil { diff --git a/libgo/go/cmd/go/internal/modload/init.go b/libgo/go/cmd/go/internal/modload/init.go index f995bad13b5..22d14ccce78 100644 --- a/libgo/go/cmd/go/internal/modload/init.go +++ b/libgo/go/cmd/go/internal/modload/init.go @@ -16,27 +16,31 @@ import ( "cmd/go/internal/modfile" "cmd/go/internal/module" "cmd/go/internal/mvs" + "cmd/go/internal/renameio" "cmd/go/internal/search" "encoding/json" "fmt" + "go/build" "io/ioutil" "os" "path" "path/filepath" "regexp" + "runtime/debug" "strconv" "strings" ) var ( - cwd string + cwd string // TODO(bcmills): Is this redundant with base.Cwd? MustUseModules = mustUseModules() initialized bool - ModRoot string - modFile *modfile.File - excluded map[module.Version]bool - Target module.Version + modRoot string + modFile *modfile.File + modFileData []byte + excluded map[module.Version]bool + Target module.Version gopath string @@ -53,11 +57,15 @@ var ( // To make permanent changes to the require statements // in go.mod, edit it before calling ImportPaths or LoadBuildList. func ModFile() *modfile.File { + Init() + if modFile == nil { + die() + } return modFile } func BinDir() string { - MustInit() + Init() return filepath.Join(gopath, "bin") } @@ -73,6 +81,10 @@ func mustUseModules() bool { var inGOPATH bool // running in GOPATH/src +// Init determines whether module mode is enabled, locates the root of the +// current module (if any), sets environment variables for Git subprocesses, and +// configures the cfg, codehost, load, modfetch, and search packages for use +// with modules. func Init() { if initialized { return @@ -138,6 +150,9 @@ func Init() { } if inGOPATH && !MustUseModules { + if CmdModInit { + die() // Don't init a module that we're just going to ignore. + } // No automatic enabling in GOPATH. if root, _ := FindModuleRoot(cwd, "", false); root != "" { cfg.GoModInGOPATH = filepath.Join(root, "go.mod") @@ -147,26 +162,54 @@ func Init() { if CmdModInit { // Running 'go mod init': go.mod will be created in current directory. - ModRoot = cwd + modRoot = cwd } else { - ModRoot, _ = FindModuleRoot(cwd, "", MustUseModules) - if !MustUseModules { - if ModRoot == "" { - return - } - if search.InDir(ModRoot, os.TempDir()) == "." { - // If you create /tmp/go.mod for experimenting, - // then any tests that create work directories under /tmp - // will find it and get modules when they're not expecting them. - // It's a bit of a peculiar thing to disallow but quite mysterious - // when it happens. See golang.org/issue/26708. - ModRoot = "" - fmt.Fprintf(os.Stderr, "go: warning: ignoring go.mod in system temp root %v\n", os.TempDir()) + modRoot, _ = FindModuleRoot(cwd, "", MustUseModules) + if modRoot == "" { + if !MustUseModules { + // GO111MODULE is 'auto' (or unset), and we can't find a module root. + // Stay in GOPATH mode. return } + } else if search.InDir(modRoot, os.TempDir()) == "." { + // If you create /tmp/go.mod for experimenting, + // then any tests that create work directories under /tmp + // will find it and get modules when they're not expecting them. + // It's a bit of a peculiar thing to disallow but quite mysterious + // when it happens. See golang.org/issue/26708. + modRoot = "" + fmt.Fprintf(os.Stderr, "go: warning: ignoring go.mod in system temp root %v\n", os.TempDir()) } } + // We're in module mode. Install the hooks to make it work. + + if c := cache.Default(); c == nil { + // With modules, there are no install locations for packages + // other than the build cache. + base.Fatalf("go: cannot use modules with build cache disabled") + } + + list := filepath.SplitList(cfg.BuildContext.GOPATH) + if len(list) == 0 || list[0] == "" { + base.Fatalf("missing $GOPATH") + } + gopath = list[0] + if _, err := os.Stat(filepath.Join(gopath, "go.mod")); err == nil { + base.Fatalf("$GOPATH/go.mod exists but should not") + } + + oldSrcMod := filepath.Join(list[0], "src/mod") + pkgMod := filepath.Join(list[0], "pkg/mod") + infoOld, errOld := os.Stat(oldSrcMod) + _, errMod := os.Stat(pkgMod) + if errOld == nil && infoOld.IsDir() && errMod != nil && os.IsNotExist(errMod) { + os.Rename(oldSrcMod, pkgMod) + } + + modfetch.PkgMod = pkgMod + codehost.WorkRoot = filepath.Join(pkgMod, "cache/vcs") + cfg.ModulesEnabled = true load.ModBinDir = BinDir load.ModLookup = Lookup @@ -177,7 +220,35 @@ func Init() { load.ModImportFromFiles = ImportFromFiles load.ModDirImportPath = DirImportPath - search.SetModRoot(ModRoot) + if modRoot == "" { + // We're in module mode, but not inside a module. + // + // If the command is 'go get' or 'go list' and all of the args are in the + // same existing module, we could use that module's download directory in + // the module cache as the module root, applying any replacements and/or + // exclusions specified by that module. However, that would leave us in a + // strange state: we want 'go get' to be consistent with 'go list', and 'go + // list' should be able to operate on multiple modules. Moreover, the 'get' + // target might specify relative file paths (e.g. in the same repository) as + // replacements, and we would not be able to apply those anyway: we would + // need to either error out or ignore just those replacements, when a build + // from an empty module could proceed without error. + // + // Instead, we'll operate as though we're in some ephemeral external module, + // ignoring all replacements and exclusions uniformly. + + // Normally we check sums using the go.sum file from the main module, but + // without a main module we do not have an authoritative go.sum file. + // + // TODO(bcmills): In Go 1.13, check sums when outside the main module. + // + // One possible approach is to merge the go.sum files from all of the + // modules we download: that doesn't protect us against bad top-level + // modules, but it at least ensures consistency for transitive dependencies. + } else { + modfetch.GoSumFile = filepath.Join(modRoot, "go.sum") + search.SetModRoot(modRoot) + } } func init() { @@ -190,38 +261,41 @@ func init() { } // Enabled reports whether modules are (or must be) enabled. -// If modules must be enabled but are not, Enabled returns true +// If modules are enabled but there is no main module, Enabled returns true // and then the first use of module information will call die -// (usually through InitMod and MustInit). +// (usually through MustModRoot). func Enabled() bool { - if !initialized { - panic("go: Enabled called before Init") - } - return ModRoot != "" || MustUseModules + Init() + return modRoot != "" || MustUseModules } -// MustInit calls Init if needed and checks that -// modules are enabled and the main module has been found. -// If not, MustInit calls base.Fatalf with an appropriate message. -func MustInit() { - if Init(); ModRoot == "" { +// ModRoot returns the root of the main module. +// It calls base.Fatalf if there is no main module. +func ModRoot() string { + if !HasModRoot() { die() } - if c := cache.Default(); c == nil { - // With modules, there are no install locations for packages - // other than the build cache. - base.Fatalf("go: cannot use modules with build cache disabled") - } + return modRoot } -// Failed reports whether module loading failed. -// If Failed returns true, then any use of module information will call die. -func Failed() bool { +// HasModRoot reports whether a main module is present. +// HasModRoot may return false even if Enabled returns true: for example, 'get' +// does not require a main module. +func HasModRoot() bool { Init() - return cfg.ModulesEnabled && ModRoot == "" + return modRoot != "" } +// printStackInDie causes die to print a stack trace. +// +// It is enabled by the testgo tag, and helps to diagnose paths that +// unexpectedly require a main module. +var printStackInDie = false + func die() { + if printStackInDie { + debug.PrintStack() + } if os.Getenv("GO111MODULE") == "off" { base.Fatalf("go: modules disabled by GO111MODULE=off; see 'go help modules'") } @@ -231,33 +305,20 @@ func die() { base.Fatalf("go: cannot find main module; see 'go help modules'") } +// InitMod sets Target and, if there is a main module, parses the initial build +// list from its go.mod file, creating and populating that file if needed. func InitMod() { - MustInit() - if modFile != nil { + if len(buildList) > 0 { return } - list := filepath.SplitList(cfg.BuildContext.GOPATH) - if len(list) == 0 || list[0] == "" { - base.Fatalf("missing $GOPATH") - } - gopath = list[0] - if _, err := os.Stat(filepath.Join(gopath, "go.mod")); err == nil { - base.Fatalf("$GOPATH/go.mod exists but should not") - } - - oldSrcMod := filepath.Join(list[0], "src/mod") - pkgMod := filepath.Join(list[0], "pkg/mod") - infoOld, errOld := os.Stat(oldSrcMod) - _, errMod := os.Stat(pkgMod) - if errOld == nil && infoOld.IsDir() && errMod != nil && os.IsNotExist(errMod) { - os.Rename(oldSrcMod, pkgMod) + Init() + if modRoot == "" { + Target = module.Version{Path: "command-line-arguments"} + buildList = []module.Version{Target} + return } - modfetch.PkgMod = pkgMod - modfetch.GoSumFile = filepath.Join(ModRoot, "go.sum") - codehost.WorkRoot = filepath.Join(pkgMod, "cache/vcs") - if CmdModInit { // Running go mod init: do legacy module conversion legacyModInit() @@ -266,7 +327,7 @@ func InitMod() { return } - gomod := filepath.Join(ModRoot, "go.mod") + gomod := filepath.Join(modRoot, "go.mod") data, err := ioutil.ReadFile(gomod) if err != nil { if os.IsNotExist(err) { @@ -284,10 +345,11 @@ func InitMod() { base.Fatalf("go: errors parsing go.mod:\n%s\n", err) } modFile = f + modFileData = data if len(f.Syntax.Stmt) == 0 || f.Module == nil { // Empty mod file. Must add module path. - path, err := FindModulePath(ModRoot) + path, err := FindModulePath(modRoot) if err != nil { base.Fatalf("go: %v", err) } @@ -325,7 +387,7 @@ func Allowed(m module.Version) bool { func legacyModInit() { if modFile == nil { - path, err := FindModulePath(ModRoot) + path, err := FindModulePath(modRoot) if err != nil { base.Fatalf("go: %v", err) } @@ -334,8 +396,10 @@ func legacyModInit() { modFile.AddModuleStmt(path) } + addGoStmt() + for _, name := range altConfigs { - cfg := filepath.Join(ModRoot, name) + cfg := filepath.Join(modRoot, name) data, err := ioutil.ReadFile(cfg) if err == nil { convert := modconv.Converters[name] @@ -356,6 +420,25 @@ func legacyModInit() { } } +// InitGoStmt adds a go statement, unless there already is one. +func InitGoStmt() { + if modFile.Go == nil { + addGoStmt() + } +} + +// addGoStmt adds a go statement referring to the current version. +func addGoStmt() { + tags := build.Default.ReleaseTags + version := tags[len(tags)-1] + if !strings.HasPrefix(version, "go") || !modfile.GoVersionRE.MatchString(version[2:]) { + base.Fatalf("go: unrecognized default version %q", version) + } + if err := modFile.AddGoStmt(version[2:]); err != nil { + base.Fatalf("go: internal error: %v", err) + } +} + var altConfigs = []string{ "Gopkg.lock", @@ -379,7 +462,7 @@ func FindModuleRoot(dir, limit string, legacyConfigOK bool) (root, file string) // Look for enclosing go.mod. for { - if _, err := os.Stat(filepath.Join(dir, "go.mod")); err == nil { + if fi, err := os.Stat(filepath.Join(dir, "go.mod")); err == nil && !fi.IsDir() { return dir, "go.mod" } if dir == limit { @@ -397,7 +480,7 @@ func FindModuleRoot(dir, limit string, legacyConfigOK bool) (root, file string) dir = dir1 for { for _, name := range altConfigs { - if _, err := os.Stat(filepath.Join(dir, name)); err == nil { + if fi, err := os.Stat(filepath.Join(dir, name)); err == nil && !fi.IsDir() { return dir, name } } @@ -541,6 +624,11 @@ func WriteGoMod() { return } + // If we aren't in a module, we don't have anywhere to write a go.mod file. + if modRoot == "" { + return + } + if loaded != nil { reqs := MinReqs() min, err := reqs.Required(Target) @@ -557,22 +645,53 @@ func WriteGoMod() { modFile.SetRequire(list) } - file := filepath.Join(ModRoot, "go.mod") - old, _ := ioutil.ReadFile(file) modFile.Cleanup() // clean file after edits new, err := modFile.Format() if err != nil { base.Fatalf("go: %v", err) } - if !bytes.Equal(old, new) { - if cfg.BuildMod == "readonly" { - base.Fatalf("go: updates to go.mod needed, disabled by -mod=readonly") + + // Always update go.sum, even if we didn't change go.mod: we may have + // downloaded modules that we didn't have before. + modfetch.WriteGoSum() + + if bytes.Equal(new, modFileData) { + // We don't need to modify go.mod from what we read previously. + // Ignore any intervening edits. + return + } + if cfg.BuildMod == "readonly" { + base.Fatalf("go: updates to go.mod needed, disabled by -mod=readonly") + } + + unlock := modfetch.SideLock() + defer unlock() + + file := filepath.Join(modRoot, "go.mod") + old, err := ioutil.ReadFile(file) + if !bytes.Equal(old, modFileData) { + if bytes.Equal(old, new) { + // Some other process wrote the same go.mod file that we were about to write. + modFileData = new + return } - if err := ioutil.WriteFile(file, new, 0666); err != nil { - base.Fatalf("go: %v", err) + if err != nil { + base.Fatalf("go: can't determine whether go.mod has changed: %v", err) } + // The contents of the go.mod file have changed. In theory we could add all + // of the new modules to the build list, recompute, and check whether any + // module in *our* build list got bumped to a different version, but that's + // a lot of work for marginal benefit. Instead, fail the command: if users + // want to run concurrent commands, they need to start with a complete, + // consistent module definition. + base.Fatalf("go: updates to go.mod needed, but contents have changed") + } - modfetch.WriteGoSum() + + if err := renameio.WriteFile(file, new); err != nil { + base.Fatalf("error writing go.mod: %v", err) + } + modFileData = new } func fixVersion(path, vers string) (string, error) { diff --git a/libgo/go/cmd/go/internal/modload/init_test.go b/libgo/go/cmd/go/internal/modload/init_test.go new file mode 100644 index 00000000000..2df9d8af7df --- /dev/null +++ b/libgo/go/cmd/go/internal/modload/init_test.go @@ -0,0 +1,42 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modload + +import ( + "io/ioutil" + "os" + "path/filepath" + "testing" +) + +func TestFindModuleRootIgnoreDir(t *testing.T) { + // In Plan 9, directories are automatically created in /n. + // For example, /n/go.mod always exist, but it's a directory. + // Test that we ignore directories when trying to find go.mod and other config files. + + dir, err := ioutil.TempDir("", "gotest") + if err != nil { + t.Fatalf("failed to create temporary directory: %v", err) + } + defer os.RemoveAll(dir) + if err := os.Mkdir(filepath.Join(dir, "go.mod"), os.ModeDir|0755); err != nil { + t.Fatalf("Mkdir failed: %v", err) + } + for _, name := range altConfigs { + if err := os.MkdirAll(filepath.Join(dir, name), os.ModeDir|0755); err != nil { + t.Fatalf("MkdirAll failed: %v", err) + } + } + p := filepath.Join(dir, "example") + if err := os.Mkdir(p, os.ModeDir|0755); err != nil { + t.Fatalf("Mkdir failed: %v", err) + } + if root, _ := FindModuleRoot(p, "", false); root != "" { + t.Errorf("FindModuleRoot(%q, \"\", false): %q, want empty string", p, root) + } + if root, _ := FindModuleRoot(p, "", true); root != "" { + t.Errorf("FindModuleRoot(%q, \"\", true): %q, want empty string", p, root) + } +} diff --git a/libgo/go/cmd/go/internal/modload/list.go b/libgo/go/cmd/go/internal/modload/list.go index 69a832de1df..2f1a3c24d22 100644 --- a/libgo/go/cmd/go/internal/modload/list.go +++ b/libgo/go/cmd/go/internal/modload/list.go @@ -17,7 +17,7 @@ import ( ) func ListModules(args []string, listU, listVersions bool) []*modinfo.ModulePublic { - mods := listModules(args) + mods := listModules(args, listVersions) if listU || listVersions { var work par.Work for _, m := range mods { @@ -39,7 +39,7 @@ func ListModules(args []string, listU, listVersions bool) []*modinfo.ModulePubli return mods } -func listModules(args []string) []*modinfo.ModulePublic { +func listModules(args []string, listVersions bool) []*modinfo.ModulePublic { LoadBuildList() if len(args) == 0 { return []*modinfo.ModulePublic{moduleInfo(buildList[0], true)} @@ -83,6 +83,10 @@ func listModules(args []string) []*modinfo.ModulePublic { } matched := false for i, m := range buildList { + if i == 0 && !HasModRoot() { + // The root module doesn't actually exist: omit it. + continue + } if match(m.Path) { matched = true if !matchedBuildList[i] { @@ -93,6 +97,16 @@ func listModules(args []string) []*modinfo.ModulePublic { } if !matched { if literal { + if listVersions { + // Don't make the user provide an explicit '@latest' when they're + // explicitly asking what the available versions are. + // Instead, resolve the module, even if it isn't an existing dependency. + info, err := Query(arg, "latest", nil) + if err == nil { + mods = append(mods, moduleInfo(module.Version{Path: arg, Version: info.Version}, false)) + continue + } + } mods = append(mods, &modinfo.ModulePublic{ Path: arg, Error: &modinfo.ModuleError{ diff --git a/libgo/go/cmd/go/internal/modload/load.go b/libgo/go/cmd/go/internal/modload/load.go index 5bf6c9b1cf9..9a1fb76bb95 100644 --- a/libgo/go/cmd/go/internal/modload/load.go +++ b/libgo/go/cmd/go/internal/modload/load.go @@ -90,7 +90,7 @@ func ImportPaths(patterns []string) []*search.Match { // the exact version of a particular module increases during // the loader iterations. m.Pkgs = str.StringList(fsDirs[i]) - for i, pkg := range m.Pkgs { + for j, pkg := range m.Pkgs { dir := pkg if !filepath.IsAbs(dir) { dir = filepath.Join(cwd, pkg) @@ -101,10 +101,10 @@ func ImportPaths(patterns []string) []*search.Match { // Note: The checks for @ here are just to avoid misinterpreting // the module cache directories (formerly GOPATH/src/mod/foo@v1.5.2/bar). // It's not strictly necessary but helpful to keep the checks. - if dir == ModRoot { + if modRoot != "" && dir == modRoot { pkg = Target.Path - } else if strings.HasPrefix(dir, ModRoot+string(filepath.Separator)) && !strings.Contains(dir[len(ModRoot):], "@") { - suffix := filepath.ToSlash(dir[len(ModRoot):]) + } else if modRoot != "" && strings.HasPrefix(dir, modRoot+string(filepath.Separator)) && !strings.Contains(dir[len(modRoot):], "@") { + suffix := filepath.ToSlash(dir[len(modRoot):]) if strings.HasPrefix(suffix, "/vendor/") { // TODO getmode vendor check pkg = strings.TrimPrefix(suffix, "/vendor/") @@ -118,24 +118,21 @@ func ImportPaths(patterns []string) []*search.Match { } else { pkg = "" if !iterating { + ModRoot() base.Errorf("go: directory %s outside available modules", base.ShortPath(dir)) } } info, err := os.Stat(dir) if err != nil || !info.IsDir() { - // If the directory does not exist, - // don't turn it into an import path - // that will trigger a lookup. - pkg = "" - if !iterating { - if err != nil { - base.Errorf("go: no such directory %v", m.Pattern) - } else { - base.Errorf("go: %s is not a directory", m.Pattern) - } + // If the directory is local but does not exist, don't return it + // while loader is iterating, since this would trigger a fetch. + // After loader is done iterating, we still need to return the + // path, so that "go list -e" produces valid output. + if iterating { + pkg = "" } } - m.Pkgs[i] = pkg + m.Pkgs[j] = pkg } case strings.Contains(m.Pattern, "..."): @@ -251,17 +248,21 @@ func ImportFromFiles(gofiles []string) { // DirImportPath returns the effective import path for dir, // provided it is within the main module, or else returns ".". func DirImportPath(dir string) string { + if modRoot == "" { + return "." + } + if !filepath.IsAbs(dir) { dir = filepath.Join(cwd, dir) } else { dir = filepath.Clean(dir) } - if dir == ModRoot { + if dir == modRoot { return Target.Path } - if strings.HasPrefix(dir, ModRoot+string(filepath.Separator)) { - suffix := filepath.ToSlash(dir[len(ModRoot):]) + if strings.HasPrefix(dir, modRoot+string(filepath.Separator)) { + suffix := filepath.ToSlash(dir[len(modRoot):]) if strings.HasPrefix(suffix, "/vendor/") { return strings.TrimPrefix(suffix, "/vendor/") } @@ -397,6 +398,9 @@ func ModuleUsedDirectly(path string) bool { // Lookup requires that one of the Load functions in this package has already // been called. func Lookup(path string) (dir, realPath string, err error) { + if path == "" { + panic("Lookup called with empty package path") + } pkg, ok := loaded.pkgCache.Get(path).(*loadPkg) if !ok { // The loader should have found all the relevant paths. @@ -762,7 +766,7 @@ func (pkg *loadPkg) stackText() string { } // why returns the text to use in "go mod why" output about the given package. -// It is less ornate than the stackText but conatins the same information. +// It is less ornate than the stackText but contains the same information. func (pkg *loadPkg) why() string { var buf strings.Builder var stack []*loadPkg @@ -811,7 +815,7 @@ func WhyDepth(path string) int { // a module.Version with Path == "". func Replacement(mod module.Version) module.Version { if modFile == nil { - // Happens during testing. + // Happens during testing and if invoking 'go get' or 'go list' outside a module. return module.Version{} } @@ -888,7 +892,7 @@ func readVendorList() { vendorOnce.Do(func() { vendorList = nil vendorMap = make(map[string]module.Version) - data, _ := ioutil.ReadFile(filepath.Join(ModRoot, "vendor/modules.txt")) + data, _ := ioutil.ReadFile(filepath.Join(ModRoot(), "vendor/modules.txt")) var m module.Version for _, line := range strings.Split(string(data), "\n") { if strings.HasPrefix(line, "# ") { @@ -918,7 +922,7 @@ func (r *mvsReqs) modFileToList(f *modfile.File) []module.Version { func (r *mvsReqs) required(mod module.Version) ([]module.Version, error) { if mod == Target { - if modFile.Go != nil { + if modFile != nil && modFile.Go != nil { r.versions.LoadOrStore(mod, modFile.Go.Version) } var list []module.Version @@ -938,7 +942,7 @@ func (r *mvsReqs) required(mod module.Version) ([]module.Version, error) { // TODO: need to slip the new version into the tags list etc. dir := repl.Path if !filepath.IsAbs(dir) { - dir = filepath.Join(ModRoot, dir) + dir = filepath.Join(ModRoot(), dir) } gomod := filepath.Join(dir, "go.mod") data, err := ioutil.ReadFile(gomod) @@ -1053,13 +1057,13 @@ func (*mvsReqs) next(m module.Version) (module.Version, error) { func fetch(mod module.Version) (dir string, isLocal bool, err error) { if mod == Target { - return ModRoot, true, nil + return ModRoot(), true, nil } if r := Replacement(mod); r.Path != "" { if r.Version == "" { dir = r.Path if !filepath.IsAbs(dir) { - dir = filepath.Join(ModRoot, dir) + dir = filepath.Join(ModRoot(), dir) } return dir, true, nil } diff --git a/libgo/go/cmd/go/internal/modload/query.go b/libgo/go/cmd/go/internal/modload/query.go index 3b550f1db7f..0856486c212 100644 --- a/libgo/go/cmd/go/internal/modload/query.go +++ b/libgo/go/cmd/go/internal/modload/query.go @@ -207,21 +207,23 @@ func matchSemverPrefix(p, v string) bool { // If multiple modules with revisions matching the query provide the requested // package, QueryPackage picks the one with the longest module path. // -// If the path is in the the main module and the query is "latest", +// If the path is in the main module and the query is "latest", // QueryPackage returns Target as the version. func QueryPackage(path, query string, allowed func(module.Version) bool) (module.Version, *modfetch.RevInfo, error) { - if _, ok := dirInModule(path, Target.Path, ModRoot, true); ok { - if query != "latest" { - return module.Version{}, nil, fmt.Errorf("can't query specific version (%q) for package %s in the main module (%s)", query, path, Target.Path) - } - if !allowed(Target) { - return module.Version{}, nil, fmt.Errorf("internal error: package %s is in the main module (%s), but version is not allowed", path, Target.Path) + if HasModRoot() { + if _, ok := dirInModule(path, Target.Path, modRoot, true); ok { + if query != "latest" { + return module.Version{}, nil, fmt.Errorf("can't query specific version (%q) for package %s in the main module (%s)", query, path, Target.Path) + } + if !allowed(Target) { + return module.Version{}, nil, fmt.Errorf("internal error: package %s is in the main module (%s), but version is not allowed", path, Target.Path) + } + return Target, &modfetch.RevInfo{Version: Target.Version}, nil } - return Target, &modfetch.RevInfo{Version: Target.Version}, nil } finalErr := errMissing - for p := path; p != "."; p = pathpkg.Dir(p) { + for p := path; p != "." && p != "/"; p = pathpkg.Dir(p) { info, err := Query(p, query, allowed) if err != nil { if _, ok := err.(*codehost.VCSError); ok { diff --git a/libgo/go/cmd/go/internal/modload/query_test.go b/libgo/go/cmd/go/internal/modload/query_test.go index 7f3ffabef74..9b073832171 100644 --- a/libgo/go/cmd/go/internal/modload/query_test.go +++ b/libgo/go/cmd/go/internal/modload/query_test.go @@ -132,7 +132,7 @@ func TestQuery(t *testing.T) { ok, _ := path.Match(allow, m.Version) return ok } - t.Run(strings.Replace(tt.path, "/", "_", -1)+"/"+tt.query+"/"+allow, func(t *testing.T) { + t.Run(strings.ReplaceAll(tt.path, "/", "_")+"/"+tt.query+"/"+allow, func(t *testing.T) { info, err := Query(tt.path, tt.query, allowed) if tt.err != "" { if err != nil && err.Error() == tt.err { diff --git a/libgo/go/cmd/go/internal/modload/search.go b/libgo/go/cmd/go/internal/modload/search.go index 24825cc35d8..7d8852d01d7 100644 --- a/libgo/go/cmd/go/internal/modload/search.go +++ b/libgo/go/cmd/go/internal/modload/search.go @@ -118,7 +118,10 @@ func matchPackages(pattern string, tags map[string]bool, useStd bool, modules [] } var root string if mod.Version == "" { - root = ModRoot + if !HasModRoot() { + continue // If there is no main module, we can't search in it. + } + root = ModRoot() } else { var err error root, _, err = fetch(mod) diff --git a/libgo/go/net/http/race.go b/libgo/go/cmd/go/internal/modload/testgo.go similarity index 52% rename from libgo/go/net/http/race.go rename to libgo/go/cmd/go/internal/modload/testgo.go index 766503967c3..663b24a68d7 100644 --- a/libgo/go/net/http/race.go +++ b/libgo/go/cmd/go/internal/modload/testgo.go @@ -1,11 +1,11 @@ -// Copyright 2014 The Go Authors. All rights reserved. +// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build race +//+build testgo -package http +package modload func init() { - raceEnabled = true + printStackInDie = true } diff --git a/libgo/go/cmd/go/internal/module/module.go b/libgo/go/cmd/go/internal/module/module.go index 1dbb0f5cb79..481a90b1c46 100644 --- a/libgo/go/cmd/go/internal/module/module.go +++ b/libgo/go/cmd/go/internal/module/module.go @@ -226,7 +226,7 @@ func checkElem(elem string, fileName bool) error { } for _, bad := range badWindowsNames { if strings.EqualFold(bad, short) { - return fmt.Errorf("disallowed path element %q", elem) + return fmt.Errorf("%q disallowed as path element component on Windows", short) } } return nil @@ -284,7 +284,7 @@ func SplitPathVersion(path string) (prefix, pathMajor string, ok bool) { } i-- } - if i <= 1 || path[i-1] != 'v' || path[i-2] != '/' { + if i <= 1 || i == len(path) || path[i-1] != 'v' || path[i-2] != '/' { return path, "", true } prefix, pathMajor = path[:i-2], path[i-2:] diff --git a/libgo/go/cmd/go/internal/module/module_test.go b/libgo/go/cmd/go/internal/module/module_test.go index f21d620d328..b40bd03dfa6 100644 --- a/libgo/go/cmd/go/internal/module/module_test.go +++ b/libgo/go/cmd/go/internal/module/module_test.go @@ -214,6 +214,7 @@ var splitPathVersionTests = []struct { {"x.y/z", ""}, {"x.y/z", "/v2"}, {"x.y/z", "/v3"}, + {"x.y/v", ""}, {"gopkg.in/yaml", ".v0"}, {"gopkg.in/yaml", ".v1"}, {"gopkg.in/yaml", ".v2"}, diff --git a/libgo/go/cmd/go/internal/mvs/mvs.go b/libgo/go/cmd/go/internal/mvs/mvs.go index 8ec9162dabc..aa109693f30 100644 --- a/libgo/go/cmd/go/internal/mvs/mvs.go +++ b/libgo/go/cmd/go/internal/mvs/mvs.go @@ -68,6 +68,7 @@ func (e *MissingModuleError) Error() string { } // BuildList returns the build list for the target module. +// The first element is the target itself, with the remainder of the list sorted by path. func BuildList(target module.Version, reqs Reqs) ([]module.Version, error) { return buildList(target, reqs, nil) } diff --git a/libgo/go/cmd/go/internal/renameio/renameio.go b/libgo/go/cmd/go/internal/renameio/renameio.go new file mode 100644 index 00000000000..8f59e1a5773 --- /dev/null +++ b/libgo/go/cmd/go/internal/renameio/renameio.go @@ -0,0 +1,63 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package renameio writes files atomically by renaming temporary files. +package renameio + +import ( + "bytes" + "io" + "io/ioutil" + "os" + "path/filepath" +) + +const patternSuffix = "*.tmp" + +// Pattern returns a glob pattern that matches the unrenamed temporary files +// created when writing to filename. +func Pattern(filename string) string { + return filepath.Join(filepath.Dir(filename), filepath.Base(filename)+patternSuffix) +} + +// WriteFile is like ioutil.WriteFile, but first writes data to an arbitrary +// file in the same directory as filename, then renames it atomically to the +// final name. +// +// That ensures that the final location, if it exists, is always a complete file. +func WriteFile(filename string, data []byte) (err error) { + return WriteToFile(filename, bytes.NewReader(data)) +} + +// WriteToFile is a variant of WriteFile that accepts the data as an io.Reader +// instead of a slice. +func WriteToFile(filename string, data io.Reader) (err error) { + f, err := ioutil.TempFile(filepath.Dir(filename), filepath.Base(filename)+patternSuffix) + if err != nil { + return err + } + defer func() { + // Only call os.Remove on f.Name() if we failed to rename it: otherwise, + // some other process may have created a new file with the same name after + // that. + if err != nil { + f.Close() + os.Remove(f.Name()) + } + }() + + if _, err := io.Copy(f, data); err != nil { + return err + } + // Sync the file before renaming it: otherwise, after a crash the reader may + // observe a 0-length file instead of the actual contents. + // See https://golang.org/issue/22397#issuecomment-380831736. + if err := f.Sync(); err != nil { + return err + } + if err := f.Close(); err != nil { + return err + } + return os.Rename(f.Name(), filename) +} diff --git a/libgo/go/cmd/go/internal/run/run.go b/libgo/go/cmd/go/internal/run/run.go index 303e6842e7b..feccf23b278 100644 --- a/libgo/go/cmd/go/internal/run/run.go +++ b/libgo/go/cmd/go/internal/run/run.go @@ -78,6 +78,9 @@ func runRun(cmd *base.Command, args []string) { p = load.GoFilesPackage(files) } else if len(args) > 0 && !strings.HasPrefix(args[0], "-") { pkgs := load.PackagesAndErrors(args[:1]) + if len(pkgs) == 0 { + base.Fatalf("go run: no packages loaded from %s", args[0]) + } if len(pkgs) > 1 { var names []string for _, p := range pkgs { diff --git a/libgo/go/cmd/go/internal/search/search.go b/libgo/go/cmd/go/internal/search/search.go index 60ae73696bb..0ca60e73497 100644 --- a/libgo/go/cmd/go/internal/search/search.go +++ b/libgo/go/cmd/go/internal/search/search.go @@ -275,7 +275,7 @@ func MatchPattern(pattern string) func(name string) bool { case strings.HasSuffix(re, `/\.\.\.`): re = strings.TrimSuffix(re, `/\.\.\.`) + `(/\.\.\.)?` } - re = strings.Replace(re, `\.\.\.`, `[^`+vendorChar+`]*`, -1) + re = strings.ReplaceAll(re, `\.\.\.`, `[^`+vendorChar+`]*`) reg := regexp.MustCompile(`^` + re + `$`) @@ -353,7 +353,7 @@ func CleanPatterns(patterns []string) []string { // as a courtesy to Windows developers, rewrite \ to / // in command-line arguments. Handles .\... and so on. if filepath.Separator == '\\' { - a = strings.Replace(a, `\`, `/`, -1) + a = strings.ReplaceAll(a, `\`, `/`) } // Put argument in canonical form, but preserve leading ./. diff --git a/libgo/go/cmd/go/internal/semver/semver.go b/libgo/go/cmd/go/internal/semver/semver.go index 4af7118e55d..122e612dd4b 100644 --- a/libgo/go/cmd/go/internal/semver/semver.go +++ b/libgo/go/cmd/go/internal/semver/semver.go @@ -263,7 +263,7 @@ func parseBuild(v string) (t, rest string, ok bool) { i := 1 start := 1 for i < len(v) { - if !isIdentChar(v[i]) { + if !isIdentChar(v[i]) && v[i] != '.' { return } if v[i] == '.' { diff --git a/libgo/go/cmd/go/internal/semver/semver_test.go b/libgo/go/cmd/go/internal/semver/semver_test.go index 96b64a58075..77025a44abd 100644 --- a/libgo/go/cmd/go/internal/semver/semver_test.go +++ b/libgo/go/cmd/go/internal/semver/semver_test.go @@ -44,6 +44,7 @@ var tests = []struct { {"v1.2.3", "v1.2.3"}, {"v1.2.3+meta", "v1.2.3"}, {"v1.2.3+meta-pre", "v1.2.3"}, + {"v1.2.3+meta-pre.sha.256a", "v1.2.3"}, } func TestIsValid(t *testing.T) { diff --git a/libgo/go/cmd/go/internal/test/test.go b/libgo/go/cmd/go/internal/test/test.go index a089f1b134a..332f3124415 100644 --- a/libgo/go/cmd/go/internal/test/test.go +++ b/libgo/go/cmd/go/internal/test/test.go @@ -27,6 +27,7 @@ import ( "cmd/go/internal/cache" "cmd/go/internal/cfg" "cmd/go/internal/load" + "cmd/go/internal/lockedfile" "cmd/go/internal/modload" "cmd/go/internal/str" "cmd/go/internal/work" @@ -124,16 +125,6 @@ A cached test result is treated as executing in no time at all, so a successful package test result will be cached and reused regardless of -timeout setting. -` + strings.TrimSpace(testFlag1) + ` See 'go help testflag' for details. - -For more about build flags, see 'go help build'. -For more about specifying packages, see 'go help packages'. - -See also: go build, go vet. -`, -} - -const testFlag1 = ` In addition to the build flags, the flags handled by 'go test' itself are: -args @@ -164,15 +155,13 @@ In addition to the build flags, the flags handled by 'go test' itself are: The test still runs (unless -c or -i is specified). The test binary also accepts flags that control execution of the test; these -flags are also accessible by 'go test'. -` - -// Usage prints the usage message for 'go test -h' and exits. -func Usage() { - os.Stderr.WriteString("usage: " + testUsage + "\n\n" + - strings.TrimSpace(testFlag1) + "\n\n\t" + - strings.TrimSpace(testFlag2) + "\n") - os.Exit(2) +flags are also accessible by 'go test'. See 'go help testflag' for details. + +For more about build flags, see 'go help build'. +For more about specifying packages, see 'go help packages'. + +See also: go build, go vet. +`, } var HelpTestflag = &base.Command{ @@ -190,11 +179,6 @@ options of pprof control how the information is presented. The following flags are recognized by the 'go test' command and control the execution of any test: - ` + strings.TrimSpace(testFlag2) + ` -`, -} - -const testFlag2 = ` -bench regexp Run only those benchmarks matching a regular expression. By default, no benchmarks are run. @@ -212,6 +196,8 @@ const testFlag2 = ` Run enough iterations of each benchmark to take t, specified as a time.Duration (for example, -benchtime 1h30s). The default is 1 second (1s). + The special syntax Nx means to run the benchmark N times + (for example, -benchtime 100x). -count n Run each test and benchmark n times (default 1). @@ -412,7 +398,8 @@ In the first example, the -x and the second -v are passed through to the test binary unchanged and with no effect on the go command itself. In the second example, the argument math is passed through to the test binary, instead of being interpreted as the package list. -` +`, +} var HelpTestfunc = &base.Command{ UsageLine: "testfunc", @@ -530,7 +517,7 @@ var testVetFlags = []string{ func runTest(cmd *base.Command, args []string) { modload.LoadTests = true - pkgArgs, testArgs = testFlags(args) + pkgArgs, testArgs = testFlags(cmd.Usage, args) work.FindExecCmd() // initialize cached result @@ -580,7 +567,7 @@ func runTest(cmd *base.Command, args []string) { // (We implement go clean -testcache by writing an expiration date // instead of searching out and deleting test result cache entries.) if dir := cache.DefaultDir(); dir != "off" { - if data, _ := ioutil.ReadFile(filepath.Join(dir, "testexpire.txt")); len(data) > 0 && data[len(data)-1] == '\n' { + if data, _ := lockedfile.Read(filepath.Join(dir, "testexpire.txt")); len(data) > 0 && data[len(data)-1] == '\n' { if t, err := strconv.ParseInt(string(data[:len(data)-1]), 10, 64); err == nil { testCacheExpire = time.Unix(0, t) } @@ -885,15 +872,19 @@ func builderTest(b *work.Builder, p *load.Package) (buildAction, runAction, prin target = filepath.Join(base.Cwd, target) } } - pmain.Target = target - installAction = &work.Action{ - Mode: "test build", - Func: work.BuildInstallFunc, - Deps: []*work.Action{buildAction}, - Package: pmain, - Target: target, + if target == os.DevNull { + runAction = buildAction + } else { + pmain.Target = target + installAction = &work.Action{ + Mode: "test build", + Func: work.BuildInstallFunc, + Deps: []*work.Action{buildAction}, + Package: pmain, + Target: target, + } + runAction = installAction // make sure runAction != nil even if not running test } - runAction = installAction // make sure runAction != nil even if not running test } var vetRunAction *work.Action if testC { diff --git a/libgo/go/cmd/go/internal/test/testflag.go b/libgo/go/cmd/go/internal/test/testflag.go index 73f8c69d9e1..ebcf49a4e9c 100644 --- a/libgo/go/cmd/go/internal/test/testflag.go +++ b/libgo/go/cmd/go/internal/test/testflag.go @@ -87,7 +87,7 @@ func init() { // to allow both // go test fmt -custom-flag-for-fmt-test // go test -x math -func testFlags(args []string) (packageNames, passToTest []string) { +func testFlags(usage func(), args []string) (packageNames, passToTest []string) { args = str.StringList(cmdflag.FindGOFLAGS(testFlagDefn), args) inPkg := false var explicitArgs []string @@ -108,7 +108,7 @@ func testFlags(args []string) (packageNames, passToTest []string) { inPkg = false } - f, value, extraWord := cmdflag.Parse(cmd, testFlagDefn, args, i) + f, value, extraWord := cmdflag.Parse(cmd, usage, testFlagDefn, args, i) if f == nil { // This is a flag we do not know; we must assume // that any args we see after this might be flag diff --git a/libgo/go/cmd/go/internal/vet/vet.go b/libgo/go/cmd/go/internal/vet/vet.go index ea85fb8d5c9..3d828a2a4a4 100644 --- a/libgo/go/cmd/go/internal/vet/vet.go +++ b/libgo/go/cmd/go/internal/vet/vet.go @@ -16,17 +16,26 @@ import ( var CmdVet = &base.Command{ Run: runVet, CustomFlags: true, - UsageLine: "go vet [-n] [-x] [build flags] [vet flags] [packages]", + UsageLine: "go vet [-n] [-x] [-vettool prog] [build flags] [vet flags] [packages]", Short: "report likely mistakes in packages", Long: ` Vet runs the Go vet command on the packages named by the import paths. For more about vet and its flags, see 'go doc cmd/vet'. For more about specifying packages, see 'go help packages'. +For a list of checkers and their flags, see 'go tool vet help'. +For details of a specific checker such as 'printf', see 'go tool vet help printf'. The -n flag prints commands that would be executed. The -x flag prints commands as they are executed. +The -vettool=prog flag selects a different analysis tool with alternative +or additional checks. +For example, the 'shadow' analyzer can be built and run using these commands: + + go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow + go vet -vettool=$(which shadow) + The build flags supported by go vet are those that control package resolution and execution, such as -n, -x, -v, -tags, and -toolexec. For more about these flags, see 'go help build'. @@ -38,7 +47,7 @@ See also: go fmt, go fix. func runVet(cmd *base.Command, args []string) { modload.LoadTests = true - vetFlags, pkgArgs := vetFlags(args) + vetFlags, pkgArgs := vetFlags(vetUsage, args) work.BuildInit() work.VetFlags = vetFlags diff --git a/libgo/go/cmd/go/internal/vet/vetflag.go b/libgo/go/cmd/go/internal/vet/vetflag.go index 50eac425ec3..37342f41633 100644 --- a/libgo/go/cmd/go/internal/vet/vetflag.go +++ b/libgo/go/cmd/go/internal/vet/vetflag.go @@ -5,9 +5,14 @@ package vet import ( + "bytes" + "encoding/json" "flag" "fmt" + "log" "os" + "os/exec" + "path/filepath" "strings" "cmd/go/internal/base" @@ -16,72 +21,116 @@ import ( "cmd/go/internal/work" ) -const cmd = "vet" - -// vetFlagDefn is the set of flags we process. -var vetFlagDefn = []*cmdflag.Defn{ - // Note: Some flags, in particular -tags and -v, are known to - // vet but also defined as build flags. This works fine, so we - // don't define them here but use AddBuildFlags to init them. - // However some, like -x, are known to the build but not - // to vet. We handle them in vetFlags. - - // local. - {Name: "all", BoolVar: new(bool), PassToTest: true}, - {Name: "asmdecl", BoolVar: new(bool), PassToTest: true}, - {Name: "assign", BoolVar: new(bool), PassToTest: true}, - {Name: "atomic", BoolVar: new(bool), PassToTest: true}, - {Name: "bool", BoolVar: new(bool), PassToTest: true}, - {Name: "buildtags", BoolVar: new(bool), PassToTest: true}, - {Name: "cgocall", BoolVar: new(bool), PassToTest: true}, - {Name: "composites", BoolVar: new(bool), PassToTest: true}, - {Name: "copylocks", BoolVar: new(bool), PassToTest: true}, - {Name: "httpresponse", BoolVar: new(bool), PassToTest: true}, - {Name: "lostcancel", BoolVar: new(bool), PassToTest: true}, - {Name: "methods", BoolVar: new(bool), PassToTest: true}, - {Name: "nilfunc", BoolVar: new(bool), PassToTest: true}, - {Name: "printf", BoolVar: new(bool), PassToTest: true}, - {Name: "printfuncs", PassToTest: true}, - {Name: "rangeloops", BoolVar: new(bool), PassToTest: true}, - {Name: "shadow", BoolVar: new(bool), PassToTest: true}, - {Name: "shadowstrict", BoolVar: new(bool), PassToTest: true}, - {Name: "shift", BoolVar: new(bool), PassToTest: true}, - {Name: "source", BoolVar: new(bool), PassToTest: true}, - {Name: "structtags", BoolVar: new(bool), PassToTest: true}, - {Name: "tests", BoolVar: new(bool), PassToTest: true}, - {Name: "unreachable", BoolVar: new(bool), PassToTest: true}, - {Name: "unsafeptr", BoolVar: new(bool), PassToTest: true}, - {Name: "unusedfuncs", PassToTest: true}, - {Name: "unusedresult", BoolVar: new(bool), PassToTest: true}, - {Name: "unusedstringmethods", PassToTest: true}, -} +// go vet flag processing +// +// We query the flags of the tool specified by -vettool and accept any +// of those flags plus any flag valid for 'go build'. The tool must +// support -flags, which prints a description of its flags in JSON to +// stdout. -var vetTool string +// vetTool specifies the vet command to run. +// Any tool that supports the (still unpublished) vet +// command-line protocol may be supplied; see +// golang.org/x/tools/go/analysis/unitchecker for one +// implementation. It is also used by tests. +// +// The default behavior (vetTool=="") runs 'go tool vet'. +// +var vetTool string // -vettool -// add build flags to vetFlagDefn. func init() { - cmdflag.AddKnownFlags("vet", vetFlagDefn) + // Extract -vettool by ad hoc flag processing: + // its value is needed even before we can declare + // the flags available during main flag processing. + for i, arg := range os.Args { + if arg == "-vettool" || arg == "--vettool" { + if i+1 >= len(os.Args) { + log.Fatalf("%s requires a filename", arg) + } + vetTool = os.Args[i+1] + break + } else if strings.HasPrefix(arg, "-vettool=") || + strings.HasPrefix(arg, "--vettool=") { + vetTool = arg[strings.IndexByte(arg, '=')+1:] + break + } + } +} + +// vetFlags processes the command line, splitting it at the first non-flag +// into the list of flags and list of packages. +func vetFlags(usage func(), args []string) (passToVet, packageNames []string) { + // Query the vet command for its flags. + tool := vetTool + if tool != "" { + var err error + tool, err = filepath.Abs(tool) + if err != nil { + log.Fatal(err) + } + } else { + tool = base.Tool("vet") + } + out := new(bytes.Buffer) + vetcmd := exec.Command(tool, "-flags") + vetcmd.Stdout = out + if err := vetcmd.Run(); err != nil { + fmt.Fprintf(os.Stderr, "go vet: can't execute %s -flags: %v\n", tool, err) + os.Exit(2) + } + var analysisFlags []struct { + Name string + Bool bool + Usage string + } + if err := json.Unmarshal(out.Bytes(), &analysisFlags); err != nil { + fmt.Fprintf(os.Stderr, "go vet: can't unmarshal JSON from %s -flags: %v", tool, err) + os.Exit(2) + } + + // Add vet's flags to vetflagDefn. + // + // Some flags, in particular -tags and -v, are known to vet but + // also defined as build flags. This works fine, so we don't + // define them here but use AddBuildFlags to init them. + // However some, like -x, are known to the build but not to vet. + var vetFlagDefn []*cmdflag.Defn + for _, f := range analysisFlags { + switch f.Name { + case "tags", "v": + continue + } + defn := &cmdflag.Defn{ + Name: f.Name, + PassToTest: true, + } + if f.Bool { + defn.BoolVar = new(bool) + } + vetFlagDefn = append(vetFlagDefn, defn) + } + + // Add build flags to vetFlagDefn. var cmd base.Command work.AddBuildFlags(&cmd) - cmd.Flag.StringVar(&vetTool, "vettool", "", "path to vet tool binary") // for cmd/vet tests; undocumented for now + // This flag declaration is a placeholder: + // -vettool is actually parsed by the init function above. + cmd.Flag.StringVar(new(string), "vettool", "", "path to vet tool binary") cmd.Flag.VisitAll(func(f *flag.Flag) { vetFlagDefn = append(vetFlagDefn, &cmdflag.Defn{ Name: f.Name, Value: f.Value, }) }) -} -// vetFlags processes the command line, splitting it at the first non-flag -// into the list of flags and list of packages. -func vetFlags(args []string) (passToVet, packageNames []string) { + // Process args. args = str.StringList(cmdflag.FindGOFLAGS(vetFlagDefn), args) for i := 0; i < len(args); i++ { if !strings.HasPrefix(args[i], "-") { return args[:i], args[i:] } - f, value, extraWord := cmdflag.Parse(cmd, vetFlagDefn, args, i) + f, value, extraWord := cmdflag.Parse("vet", usage, vetFlagDefn, args, i) if f == nil { fmt.Fprintf(os.Stderr, "vet: flag %q not defined\n", args[i]) fmt.Fprintf(os.Stderr, "Run \"go help vet\" for more information\n") @@ -117,3 +166,21 @@ func vetFlags(args []string) (passToVet, packageNames []string) { } return args, nil } + +var vetUsage func() + +func init() { vetUsage = usage } // break initialization cycle + +func usage() { + fmt.Fprintf(os.Stderr, "usage: %s\n", CmdVet.UsageLine) + fmt.Fprintf(os.Stderr, "Run 'go help %s' for details.\n", CmdVet.LongName()) + + // This part is additional to what (*Command).Usage does: + cmd := "go tool vet" + if vetTool != "" { + cmd = vetTool + } + fmt.Fprintf(os.Stderr, "Run '%s -help' for the vet tool's flags.\n", cmd) + + os.Exit(2) +} diff --git a/libgo/go/cmd/go/internal/web2/web.go b/libgo/go/cmd/go/internal/web2/web.go index f3900379e17..64934f1d506 100644 --- a/libgo/go/cmd/go/internal/web2/web.go +++ b/libgo/go/cmd/go/internal/web2/web.go @@ -7,11 +7,13 @@ package web2 import ( "bytes" "cmd/go/internal/base" + "cmd/go/internal/cfg" "encoding/json" "flag" "fmt" "io" "io/ioutil" + "log" "net/http" "os" "path/filepath" @@ -187,10 +189,10 @@ func SetHTTPDoForTesting(do func(*http.Request) (*http.Response, error)) { } func Get(url string, options ...Option) error { - if TraceGET || webstack { - println("GET", url) + if TraceGET || webstack || cfg.BuildV { + log.Printf("Fetching %s", url) if webstack { - println(string(debug.Stack())) + log.Println(string(debug.Stack())) } } diff --git a/libgo/go/cmd/go/internal/work/action.go b/libgo/go/cmd/go/internal/work/action.go index 82cf228fa44..d0d02117a73 100644 --- a/libgo/go/cmd/go/internal/work/action.go +++ b/libgo/go/cmd/go/internal/work/action.go @@ -11,9 +11,9 @@ import ( "bytes" "container/heap" "debug/elf" - "debug/xcoff" "encoding/json" "fmt" + "internal/xcoff" "io/ioutil" "os" "path/filepath" diff --git a/libgo/go/cmd/go/internal/work/build.go b/libgo/go/cmd/go/internal/work/build.go index ed41ce5d073..145b87513a9 100644 --- a/libgo/go/cmd/go/internal/work/build.go +++ b/libgo/go/cmd/go/internal/work/build.go @@ -99,7 +99,7 @@ and test commands: link against shared libraries previously created with -buildmode=shared. -mod mode - module download mode to use: readonly, release, or vendor. + module download mode to use: readonly or vendor. See 'go help modules' for more. -pkgdir dir install and load all packages from dir instead of the usual locations. @@ -398,10 +398,10 @@ func libname(args []string, pkgs []*load.Package) (string, error) { arg = bp.ImportPath } } - appendName(strings.Replace(arg, "/", "-", -1)) + appendName(strings.ReplaceAll(arg, "/", "-")) } else { for _, pkg := range pkgs { - appendName(strings.Replace(pkg.ImportPath, "/", "-", -1)) + appendName(strings.ReplaceAll(pkg.ImportPath, "/", "-")) } } } else if haveNonMeta { // have both meta package and a non-meta one diff --git a/libgo/go/cmd/go/internal/work/build_test.go b/libgo/go/cmd/go/internal/work/build_test.go index 010e17ee480..ef95a408ca3 100644 --- a/libgo/go/cmd/go/internal/work/build_test.go +++ b/libgo/go/cmd/go/internal/work/build_test.go @@ -227,6 +227,8 @@ func TestRespectSetgidDir(t *testing.T) { if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" { t.Skip("can't set SetGID bit with chmod on iOS") } + case "windows", "plan9", "js": + t.Skip("chown/chmod setgid are not supported on Windows, Plan 9, or JS") } var b Builder @@ -245,11 +247,13 @@ func TestRespectSetgidDir(t *testing.T) { } defer os.RemoveAll(setgiddir) - if runtime.GOOS == "freebsd" { - err = os.Chown(setgiddir, os.Getuid(), os.Getgid()) - if err != nil { - t.Fatal(err) - } + // BSD mkdir(2) inherits the parent directory group, and other platforms + // can inherit the parent directory group via setgid. The test setup (chmod + // setgid) will fail if the process does not have the group permission to + // the new temporary directory. + err = os.Chown(setgiddir, os.Getuid(), os.Getgid()) + if err != nil { + t.Fatal(err) } // Change setgiddir's permissions to include the SetGID bit. diff --git a/libgo/go/cmd/go/internal/work/buildid.go b/libgo/go/cmd/go/internal/work/buildid.go index fb57e912802..750bc3c6cdb 100644 --- a/libgo/go/cmd/go/internal/work/buildid.go +++ b/libgo/go/cmd/go/internal/work/buildid.go @@ -18,7 +18,6 @@ import ( "cmd/go/internal/load" "cmd/go/internal/str" "cmd/internal/buildid" - "cmd/internal/objabi" ) // Build IDs @@ -178,7 +177,8 @@ func (b *Builder) toolID(name string) string { path := base.Tool(name) desc := "go tool " + name - // Special case: undocumented -vettool overrides usual vet, for testing vet. + // Special case: undocumented -vettool overrides usual vet, + // for testing vet or supplying an alternative analysis tool. if name == "vet" && VetTool != "" { path = VetTool desc = VetTool @@ -207,11 +207,6 @@ func (b *Builder) toolID(name string) string { id = f[2] } - // For the compiler, add any experiments. - if name == "compile" { - id += " " + objabi.Expstring() - } - b.id.Lock() b.toolIDCache[name] = id b.id.Unlock() @@ -322,13 +317,16 @@ func assemblerIsGas() bool { } } -// gccgoBuildIDELFFile creates an assembler file that records the -// action's build ID in an SHF_EXCLUDE section. -func (b *Builder) gccgoBuildIDELFFile(a *Action) (string, error) { +// gccgoBuildIDFile creates an assembler file that records the +// action's build ID in an SHF_EXCLUDE section for ELF files or +// in a CSECT in XCOFF files. +func (b *Builder) gccgoBuildIDFile(a *Action) (string, error) { sfile := a.Objdir + "_buildid.s" var buf bytes.Buffer - if cfg.Goos != "solaris" || assemblerIsGas() { + if cfg.Goos == "aix" { + fmt.Fprintf(&buf, "\t.csect .go.buildid[XO]\n") + } else if cfg.Goos != "solaris" || assemblerIsGas() { fmt.Fprintf(&buf, "\t"+`.section .go.buildid,"e"`+"\n") } else if cfg.Goarch == "sparc" || cfg.Goarch == "sparc64" { fmt.Fprintf(&buf, "\t"+`.section ".go.buildid",#exclude`+"\n") @@ -347,7 +345,7 @@ func (b *Builder) gccgoBuildIDELFFile(a *Action) (string, error) { fmt.Fprintf(&buf, "%#02x", a.buildID[i]) } fmt.Fprintf(&buf, "\n") - if cfg.Goos != "solaris" { + if cfg.Goos != "solaris" && cfg.Goos != "aix" { secType := "@progbits" if cfg.Goarch == "arm" { secType = "%progbits" @@ -372,43 +370,6 @@ func (b *Builder) gccgoBuildIDELFFile(a *Action) (string, error) { return sfile, nil } -// gccgoBuildIDXCOFFFile creates an assembler file that records the -// action's build ID in a CSECT (AIX linker deletes CSECTs that are -// not referenced in the output file). -func (b *Builder) gccgoBuildIDXCOFFFile(a *Action) (string, error) { - sfile := a.Objdir + "_buildid.s" - - var buf bytes.Buffer - fmt.Fprintf(&buf, "\t.csect .go.buildid[XO]\n") - fmt.Fprintf(&buf, "\t.byte ") - for i := 0; i < len(a.buildID); i++ { - if i > 0 { - if i%8 == 0 { - fmt.Fprintf(&buf, "\n\t.byte ") - } else { - fmt.Fprintf(&buf, ",") - } - } - fmt.Fprintf(&buf, "%#02x", a.buildID[i]) - } - fmt.Fprintf(&buf, "\n") - - if cfg.BuildN || cfg.BuildX { - for _, line := range bytes.Split(buf.Bytes(), []byte("\n")) { - b.Showcmd("", "echo '%s' >> %s", line, sfile) - } - if cfg.BuildN { - return sfile, nil - } - } - - if err := ioutil.WriteFile(sfile, buf.Bytes(), 0666); err != nil { - return "", err - } - - return sfile, nil -} - // buildID returns the build ID found in the given file. // If no build ID is found, buildID returns the content hash of the file. func (b *Builder) buildID(file string) string { diff --git a/libgo/go/cmd/go/internal/work/exec.go b/libgo/go/cmd/go/internal/work/exec.go index 8aba293dd34..a4feb1d0058 100644 --- a/libgo/go/cmd/go/internal/work/exec.go +++ b/libgo/go/cmd/go/internal/work/exec.go @@ -377,7 +377,7 @@ func (b *Builder) build(a *Action) (err error) { if b.NeedExport { p.Export = a.built } - if need&needCompiledGoFiles != 0 && b.loadCachedGoFiles(a) { + if need&needCompiledGoFiles != 0 && b.loadCachedSrcFiles(a) { need &^= needCompiledGoFiles } // Otherwise, we need to write files to a.Objdir (needVet, needCgoHdr). @@ -386,6 +386,13 @@ func (b *Builder) build(a *Action) (err error) { cached = true a.output = []byte{} // start saving output in case we miss any cache results } + + // Source files might be cached, even if the full action is not + // (e.g., go list -compiled -find). + if !cached && need&needCompiledGoFiles != 0 && b.loadCachedSrcFiles(a) { + need &^= needCompiledGoFiles + } + if need == 0 { return nil } @@ -434,10 +441,6 @@ func (b *Builder) build(a *Action) (err error) { return fmt.Errorf("missing or invalid binary-only package; expected file %q", a.Package.Target) } - if p.Module != nil && !allowedVersion(p.Module.GoVersion) { - return fmt.Errorf("module requires Go %s", p.Module.GoVersion) - } - if err := b.Mkdir(a.Objdir); err != nil { return err } @@ -579,7 +582,13 @@ func (b *Builder) build(a *Action) (err error) { b.cacheCgoHdr(a) } } - b.cacheGofiles(a, gofiles) + + var srcfiles []string // .go and non-.go + srcfiles = append(srcfiles, gofiles...) + srcfiles = append(srcfiles, sfiles...) + srcfiles = append(srcfiles, cfiles...) + srcfiles = append(srcfiles, cxxfiles...) + b.cacheSrcFiles(a, srcfiles) // Running cgo generated the cgo header. need &^= needCgoHdr @@ -591,11 +600,11 @@ func (b *Builder) build(a *Action) (err error) { // Prepare Go vet config if needed. if need&needVet != 0 { - buildVetConfig(a, gofiles) + buildVetConfig(a, srcfiles) need &^= needVet } if need&needCompiledGoFiles != 0 { - if !b.loadCachedGoFiles(a) { + if !b.loadCachedSrcFiles(a) { return fmt.Errorf("failed to cache compiled Go files") } need &^= needCompiledGoFiles @@ -605,6 +614,12 @@ func (b *Builder) build(a *Action) (err error) { return nil } + // Collect symbol ABI requirements from assembly. + symabis, err := BuildToolchain.symabis(b, a, sfiles) + if err != nil { + return err + } + // Prepare Go import config. // We start it off with a comment so it can't be empty, so icfg.Bytes() below is never nil. // It should never be empty anyway, but there have been bugs in the past that resulted @@ -638,14 +653,21 @@ func (b *Builder) build(a *Action) (err error) { // Compile Go. objpkg := objdir + "_pkg_.a" - ofile, out, err := BuildToolchain.gc(b, a, objpkg, icfg.Bytes(), len(sfiles) > 0, gofiles) + ofile, out, err := BuildToolchain.gc(b, a, objpkg, icfg.Bytes(), symabis, len(sfiles) > 0, gofiles) if len(out) > 0 { - b.showOutput(a, a.Package.Dir, a.Package.Desc(), b.processOutput(out)) + output := b.processOutput(out) + if p.Module != nil && !allowedVersion(p.Module.GoVersion) { + output += "note: module requires Go " + p.Module.GoVersion + } + b.showOutput(a, a.Package.Dir, a.Package.Desc(), output) if err != nil { return errPrintedOutput } } if err != nil { + if p.Module != nil && !allowedVersion(p.Module.GoVersion) { + b.showOutput(a, a.Package.Dir, a.Package.Desc(), "note: module requires Go "+p.Module.GoVersion) + } return err } if ofile != objpkg { @@ -701,18 +723,8 @@ func (b *Builder) build(a *Action) (err error) { // This is read by readGccgoArchive in cmd/internal/buildid/buildid.go. if a.buildID != "" && cfg.BuildToolchainName == "gccgo" { switch cfg.Goos { - case "android", "dragonfly", "freebsd", "linux", "netbsd", "openbsd", "solaris": - asmfile, err := b.gccgoBuildIDELFFile(a) - if err != nil { - return err - } - ofiles, err := BuildToolchain.asm(b, a, []string{asmfile}) - if err != nil { - return err - } - objects = append(objects, ofiles...) - case "aix": - asmfile, err := b.gccgoBuildIDXCOFFFile(a) + case "aix", "android", "dragonfly", "freebsd", "linux", "netbsd", "openbsd", "solaris": + asmfile, err := b.gccgoBuildIDFile(a) if err != nil { return err } @@ -797,13 +809,13 @@ func (b *Builder) loadCachedCgoHdr(a *Action) bool { return err == nil } -func (b *Builder) cacheGofiles(a *Action, gofiles []string) { +func (b *Builder) cacheSrcFiles(a *Action, srcfiles []string) { c := cache.Default() if c == nil { return } var buf bytes.Buffer - for _, file := range gofiles { + for _, file := range srcfiles { if !strings.HasPrefix(file, a.Objdir) { // not generated buf.WriteString("./") @@ -818,7 +830,7 @@ func (b *Builder) cacheGofiles(a *Action, gofiles []string) { return } } - c.PutBytes(cache.Subkey(a.actionID, "gofiles"), buf.Bytes()) + c.PutBytes(cache.Subkey(a.actionID, "srcfiles"), buf.Bytes()) } func (b *Builder) loadCachedVet(a *Action) bool { @@ -826,34 +838,34 @@ func (b *Builder) loadCachedVet(a *Action) bool { if c == nil { return false } - list, _, err := c.GetBytes(cache.Subkey(a.actionID, "gofiles")) + list, _, err := c.GetBytes(cache.Subkey(a.actionID, "srcfiles")) if err != nil { return false } - var gofiles []string + var srcfiles []string for _, name := range strings.Split(string(list), "\n") { if name == "" { // end of list continue } if strings.HasPrefix(name, "./") { - gofiles = append(gofiles, name[2:]) + srcfiles = append(srcfiles, name[2:]) continue } if err := b.loadCachedObjdirFile(a, c, name); err != nil { return false } - gofiles = append(gofiles, a.Objdir+name) + srcfiles = append(srcfiles, a.Objdir+name) } - buildVetConfig(a, gofiles) + buildVetConfig(a, srcfiles) return true } -func (b *Builder) loadCachedGoFiles(a *Action) bool { +func (b *Builder) loadCachedSrcFiles(a *Action) bool { c := cache.Default() if c == nil { return false } - list, _, err := c.GetBytes(cache.Subkey(a.actionID, "gofiles")) + list, _, err := c.GetBytes(cache.Subkey(a.actionID, "srcfiles")) if err != nil { return false } @@ -878,10 +890,12 @@ func (b *Builder) loadCachedGoFiles(a *Action) bool { // vetConfig is the configuration passed to vet describing a single package. type vetConfig struct { + ID string // package ID (example: "fmt [fmt.test]") Compiler string // compiler name (gc, gccgo) Dir string // directory containing package ImportPath string // canonical import path ("package path") GoFiles []string // absolute paths to package source files + NonGoFiles []string // absolute paths to package non-Go files ImportMap map[string]string // map import path in source code to package path PackageFile map[string]string // map package path to .a file with export data @@ -893,15 +907,28 @@ type vetConfig struct { SucceedOnTypecheckFailure bool // awful hack; see #18395 and below } -func buildVetConfig(a *Action, gofiles []string) { +func buildVetConfig(a *Action, srcfiles []string) { + // Classify files based on .go extension. + // srcfiles does not include raw cgo files. + var gofiles, nongofiles []string + for _, name := range srcfiles { + if strings.HasSuffix(name, ".go") { + gofiles = append(gofiles, name) + } else { + nongofiles = append(nongofiles, name) + } + } + // Pass list of absolute paths to vet, // so that vet's error messages will use absolute paths, // so that we can reformat them relative to the directory // in which the go command is invoked. vcfg := &vetConfig{ + ID: a.Package.ImportPath, Compiler: cfg.BuildToolchainName, Dir: a.Package.Dir, GoFiles: mkAbsFiles(a.Package.Dir, gofiles), + NonGoFiles: mkAbsFiles(a.Package.Dir, nongofiles), ImportPath: a.Package.ImportPath, ImportMap: make(map[string]string), PackageFile: make(map[string]string), @@ -998,6 +1025,8 @@ func (b *Builder) vet(a *Action) error { } } + // TODO(adonovan): delete this when we use the new vet printf checker. + // https://github.com/golang/go/issues/28756 if vcfg.ImportMap["fmt"] == "" { a1 := a.Deps[1] vcfg.ImportMap["fmt"] = "fmt" @@ -1621,6 +1650,25 @@ func (b *Builder) writeFile(file string, text []byte) error { return ioutil.WriteFile(file, text, 0666) } +// appendFile appends the text to file. +func (b *Builder) appendFile(file string, text []byte) error { + if cfg.BuildN || cfg.BuildX { + b.Showcmd("", "cat >>%s << 'EOF' # internal\n%sEOF", file, text) + } + if cfg.BuildN { + return nil + } + f, err := os.OpenFile(file, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0666) + if err != nil { + return err + } + defer f.Close() + if _, err = f.Write(text); err != nil { + return err + } + return f.Close() +} + // Install the cgo export header file, if there is one. func (b *Builder) installHeader(a *Action) error { src := a.Objdir + "_cgo_install.h" @@ -1671,8 +1719,8 @@ var objectMagic = [][]byte{ {0x00, 0x00, 0x8a, 0x97}, // Plan 9 amd64 {0x00, 0x00, 0x06, 0x47}, // Plan 9 arm {0x00, 0x61, 0x73, 0x6D}, // WASM - {0x01, 0xDF}, // XCOFF32 - {0x01, 0xF7}, // XCOFF64 + {0x01, 0xDF}, // XCOFF 32bit + {0x01, 0xF7}, // XCOFF 64bit } func isObject(s string) bool { @@ -1720,14 +1768,14 @@ func (b *Builder) fmtcmd(dir string, format string, args ...interface{}) string if dir[len(dir)-1] == filepath.Separator { dot += string(filepath.Separator) } - cmd = strings.Replace(" "+cmd, " "+dir, dot, -1)[1:] + cmd = strings.ReplaceAll(" "+cmd, " "+dir, dot)[1:] if b.scriptDir != dir { b.scriptDir = dir cmd = "cd " + dir + "\n" + cmd } } if b.WorkDir != "" { - cmd = strings.Replace(cmd, b.WorkDir, "$WORK", -1) + cmd = strings.ReplaceAll(cmd, b.WorkDir, "$WORK") } return cmd } @@ -1769,10 +1817,10 @@ func (b *Builder) showOutput(a *Action, dir, desc, out string) { prefix := "# " + desc suffix := "\n" + out if reldir := base.ShortPath(dir); reldir != dir { - suffix = strings.Replace(suffix, " "+dir, " "+reldir, -1) - suffix = strings.Replace(suffix, "\n"+dir, "\n"+reldir, -1) + suffix = strings.ReplaceAll(suffix, " "+dir, " "+reldir) + suffix = strings.ReplaceAll(suffix, "\n"+dir, "\n"+reldir) } - suffix = strings.Replace(suffix, " "+b.WorkDir, " $WORK", -1) + suffix = strings.ReplaceAll(suffix, " "+b.WorkDir, " $WORK") if a != nil && a.output != nil { a.output = append(a.output, prefix...) @@ -1976,13 +2024,18 @@ func mkAbs(dir, f string) string { type toolchain interface { // gc runs the compiler in a specific directory on a set of files // and returns the name of the generated output file. - gc(b *Builder, a *Action, archive string, importcfg []byte, asmhdr bool, gofiles []string) (ofile string, out []byte, err error) + // + // TODO: This argument list is long. Consider putting it in a struct. + gc(b *Builder, a *Action, archive string, importcfg []byte, symabis string, asmhdr bool, gofiles []string) (ofile string, out []byte, err error) // cc runs the toolchain's C compiler in a directory on a C file // to produce an output file. cc(b *Builder, a *Action, ofile, cfile string) error // asm runs the assembler in a specific directory on specific files // and returns a list of named output files. asm(b *Builder, a *Action, sfiles []string) ([]string, error) + // symabis scans the symbol ABIs from sfiles and returns the + // path to the output symbol ABIs file, or "" if none. + symabis(b *Builder, a *Action, sfiles []string) (string, error) // pack runs the archive packer in a specific directory to create // an archive from a set of object files. // typically it is run in the object directory. @@ -2013,7 +2066,7 @@ func (noToolchain) linker() string { return "" } -func (noToolchain) gc(b *Builder, a *Action, archive string, importcfg []byte, asmhdr bool, gofiles []string) (ofile string, out []byte, err error) { +func (noToolchain) gc(b *Builder, a *Action, archive string, importcfg []byte, symabis string, asmhdr bool, gofiles []string) (ofile string, out []byte, err error) { return "", nil, noCompiler() } @@ -2021,6 +2074,10 @@ func (noToolchain) asm(b *Builder, a *Action, sfiles []string) ([]string, error) return nil, noCompiler() } +func (noToolchain) symabis(b *Builder, a *Action, sfiles []string) (string, error) { + return "", noCompiler() +} + func (noToolchain) pack(b *Builder, a *Action, afile string, ofiles []string) error { return noCompiler() } @@ -2092,14 +2149,37 @@ func (b *Builder) ccompile(a *Action, p *load.Package, outfile string, flags []s } // gccld runs the gcc linker to create an executable from a set of object files. -func (b *Builder) gccld(p *load.Package, objdir, out string, flags []string, objs []string) error { +func (b *Builder) gccld(p *load.Package, objdir, outfile string, flags []string, objs []string) error { var cmd []string if len(p.CXXFiles) > 0 || len(p.SwigCXXFiles) > 0 { cmd = b.GxxCmd(p.Dir, objdir) } else { cmd = b.GccCmd(p.Dir, objdir) } - return b.run(nil, p.Dir, p.ImportPath, b.cCompilerEnv(), cmd, "-o", out, objs, flags) + + cmdargs := []interface{}{cmd, "-o", outfile, objs, flags} + dir := p.Dir + out, err := b.runOut(dir, b.cCompilerEnv(), cmdargs...) + if len(out) > 0 { + // Filter out useless linker warnings caused by bugs outside Go. + // See also cmd/link/internal/ld's hostlink method. + var save [][]byte + for _, line := range bytes.SplitAfter(out, []byte("\n")) { + // golang.org/issue/26073 - Apple Xcode bug + if bytes.Contains(line, []byte("ld: warning: text-based stub file")) { + continue + } + save = append(save, line) + } + out = bytes.Join(save, nil) + if len(out) > 0 { + b.showOutput(nil, dir, p.ImportPath, b.processOutput(out)) + if err != nil { + err = errPrintedOutput + } + } + } + return err } // Grab these before main helpfully overwrites them. @@ -2686,7 +2766,7 @@ func (b *Builder) swigDoIntSize(objdir string) (intsize string, err error) { p := load.GoFilesPackage(srcs) - if _, _, e := BuildToolchain.gc(b, &Action{Mode: "swigDoIntSize", Package: p, Objdir: objdir}, "", nil, false, srcs); e != nil { + if _, _, e := BuildToolchain.gc(b, &Action{Mode: "swigDoIntSize", Package: p, Objdir: objdir}, "", nil, "", false, srcs); e != nil { return "32", nil } return "64", nil @@ -2884,7 +2964,7 @@ func useResponseFile(path string, argLen int) bool { } // On the Go build system, use response files about 10% of the - // time, just to excercise this codepath. + // time, just to exercise this codepath. isBuilder := os.Getenv("GO_BUILDER_NAME") != "" if isBuilder && rand.Intn(10) == 0 { return true diff --git a/libgo/go/cmd/go/internal/work/gc.go b/libgo/go/cmd/go/internal/work/gc.go index 6e5333ccbc4..3d09f69fcc3 100644 --- a/libgo/go/cmd/go/internal/work/gc.go +++ b/libgo/go/cmd/go/internal/work/gc.go @@ -36,7 +36,7 @@ func (gcToolchain) linker() string { return base.Tool("link") } -func (gcToolchain) gc(b *Builder, a *Action, archive string, importcfg []byte, asmhdr bool, gofiles []string) (ofile string, output []byte, err error) { +func (gcToolchain) gc(b *Builder, a *Action, archive string, importcfg []byte, symabis string, asmhdr bool, gofiles []string) (ofile string, output []byte, err error) { p := a.Package objdir := a.Objdir if archive != "" { @@ -53,6 +53,9 @@ func (gcToolchain) gc(b *Builder, a *Action, archive string, importcfg []byte, a pkgpath = "main" } gcargs := []string{"-p", pkgpath} + if p.Module != nil && p.Module.GoVersion != "" && allowedVersion(p.Module.GoVersion) { + gcargs = append(gcargs, "-lang=go"+p.Module.GoVersion) + } if p.Standard { gcargs = append(gcargs, "-std") } @@ -95,6 +98,9 @@ func (gcToolchain) gc(b *Builder, a *Action, archive string, importcfg []byte, a if strings.HasPrefix(runtimeVersion, "go1") && !strings.Contains(os.Args[0], "go_bootstrap") { gcargs = append(gcargs, "-goversion", runtimeVersion) } + if symabis != "" { + gcargs = append(gcargs, "-symabis", symabis) + } gcflags := str.StringList(forcedGcflags, p.Internal.Gcflags) if compilingRuntime { @@ -168,7 +174,7 @@ CheckFlags: } // TODO: Test and delete these conditions. - if objabi.Fieldtrack_enabled != 0 || objabi.Preemptibleloops_enabled != 0 || objabi.Clobberdead_enabled != 0 { + if objabi.Fieldtrack_enabled != 0 || objabi.Preemptibleloops_enabled != 0 { canDashC = false } @@ -215,8 +221,7 @@ func trimDir(dir string) string { return dir } -func (gcToolchain) asm(b *Builder, a *Action, sfiles []string) ([]string, error) { - p := a.Package +func asmArgs(a *Action, p *load.Package) []interface{} { // Add -I pkg/GOOS_GOARCH so #include "textflag.h" works in .s files. inc := filepath.Join(cfg.GOROOT, "pkg", "include") args := []interface{}{cfg.BuildToolexec, base.Tool("asm"), "-trimpath", trimDir(a.Objdir), "-I", a.Objdir, "-I", inc, "-D", "GOOS_" + cfg.Goos, "-D", "GOARCH_" + cfg.Goarch, forcedAsmflags, p.Internal.Asmflags} @@ -238,6 +243,13 @@ func (gcToolchain) asm(b *Builder, a *Action, sfiles []string) ([]string, error) args = append(args, "-D", "GOMIPS64_"+cfg.GOMIPS64) } + return args +} + +func (gcToolchain) asm(b *Builder, a *Action, sfiles []string) ([]string, error) { + p := a.Package + args := asmArgs(a, p) + var ofiles []string for _, sfile := range sfiles { ofile := a.Objdir + sfile[:len(sfile)-len(".s")] + ".o" @@ -250,6 +262,88 @@ func (gcToolchain) asm(b *Builder, a *Action, sfiles []string) ([]string, error) return ofiles, nil } +func (gcToolchain) symabis(b *Builder, a *Action, sfiles []string) (string, error) { + mkSymabis := func(p *load.Package, sfiles []string, path string) error { + args := asmArgs(a, p) + args = append(args, "-gensymabis", "-o", path) + for _, sfile := range sfiles { + if p.ImportPath == "runtime/cgo" && strings.HasPrefix(sfile, "gcc_") { + continue + } + args = append(args, mkAbs(p.Dir, sfile)) + } + + // Supply an empty go_asm.h as if the compiler had been run. + // -gensymabis parsing is lax enough that we don't need the + // actual definitions that would appear in go_asm.h. + if err := b.writeFile(a.Objdir+"go_asm.h", nil); err != nil { + return err + } + + return b.run(a, p.Dir, p.ImportPath, nil, args...) + } + + var symabis string // Only set if we actually create the file + p := a.Package + if len(sfiles) != 0 { + symabis = a.Objdir + "symabis" + if err := mkSymabis(p, sfiles, symabis); err != nil { + return "", err + } + } + + // Gather known cross-package references from assembly code. + var otherPkgs []string + if p.ImportPath == "runtime" { + // Assembly in the following packages references + // symbols in runtime. + otherPkgs = []string{"syscall", "internal/syscall/unix", "runtime/cgo"} + } else if p.ImportPath == "runtime/internal/atomic" { + // sync/atomic is an assembly wrapper around + // runtime/internal/atomic. + otherPkgs = []string{"sync/atomic"} + } + for _, p2name := range otherPkgs { + p2 := load.LoadPackage(p2name, &load.ImportStack{}) + if len(p2.SFiles) == 0 { + continue + } + + symabis2 := a.Objdir + "symabis2" + if err := mkSymabis(p2, p2.SFiles, symabis2); err != nil { + return "", err + } + + // Filter out just the symbol refs and append them to + // the symabis file. + if cfg.BuildN { + // -x will print the lines from symabis2 that are actually appended + // to symabis. With -n, we don't know what those lines will be. + b.Showcmd("", `grep '^ref' <%s | grep -v '^ref\s*""\.' >>%s`, symabis2, a.Objdir+"symabis") + continue + } + abis2, err := ioutil.ReadFile(symabis2) + if err != nil { + return "", err + } + var refs bytes.Buffer + for _, line := range strings.Split(string(abis2), "\n") { + fs := strings.Fields(line) + if len(fs) >= 2 && fs[0] == "ref" && !strings.HasPrefix(fs[1], `"".`) { + fmt.Fprintf(&refs, "%s\n", line) + } + } + if refs.Len() != 0 { + symabis = a.Objdir + "symabis" + if err := b.appendFile(symabis, refs.Bytes()); err != nil { + return "", err + } + } + } + + return symabis, nil +} + // toolVerify checks that the command line args writes the same output file // if run using newTool instead. // Unused now but kept around for future use. diff --git a/libgo/go/cmd/go/internal/work/gccgo.go b/libgo/go/cmd/go/internal/work/gccgo.go index 7255748b5c3..82da5912b2d 100644 --- a/libgo/go/cmd/go/internal/work/gccgo.go +++ b/libgo/go/cmd/go/internal/work/gccgo.go @@ -43,6 +43,14 @@ func (gccgoToolchain) linker() string { return GccgoBin } +func (gccgoToolchain) ar() string { + ar := os.Getenv("AR") + if ar == "" { + ar = "ar" + } + return ar +} + func checkGccgoBin() { if gccgoErr == nil { return @@ -51,7 +59,7 @@ func checkGccgoBin() { os.Exit(2) } -func (tools gccgoToolchain) gc(b *Builder, a *Action, archive string, importcfg []byte, asmhdr bool, gofiles []string) (ofile string, output []byte, err error) { +func (tools gccgoToolchain) gc(b *Builder, a *Action, archive string, importcfg []byte, symabis string, asmhdr bool, gofiles []string) (ofile string, output []byte, err error) { p := a.Package objdir := a.Objdir out := "_go_.o" @@ -174,6 +182,10 @@ func (tools gccgoToolchain) asm(b *Builder, a *Action, sfiles []string) ([]strin return ofiles, nil } +func (gccgoToolchain) symabis(b *Builder, a *Action, sfiles []string) (string, error) { + return "", nil +} + func gccgoArchive(basedir, imp string) string { end := filepath.FromSlash(imp + ".a") afile := filepath.Join(basedir, end) @@ -181,26 +193,22 @@ func gccgoArchive(basedir, imp string) string { return filepath.Join(filepath.Dir(afile), "lib"+filepath.Base(afile)) } -func (gccgoToolchain) pack(b *Builder, a *Action, afile string, ofiles []string) error { +func (tools gccgoToolchain) pack(b *Builder, a *Action, afile string, ofiles []string) error { p := a.Package objdir := a.Objdir var absOfiles []string for _, f := range ofiles { absOfiles = append(absOfiles, mkAbs(objdir, f)) } - absAfile := mkAbs(objdir, afile) - // Try with D modifier first, then without if that fails. - if cfg.Goos == "aix" || b.run(a, p.Dir, p.ImportPath, nil, "ar", "rcD", absAfile, absOfiles) != nil { - var arArgs []string - if cfg.Goos == "aix" && cfg.Goarch == "ppc64" { - // AIX puts both 32-bit and 64-bit objects in the same archive. - // Tell the AIX "ar" command to only care about 64-bit objects. - // AIX "ar" command does not know D option. - arArgs = append(arArgs, "-X64") - } - return b.run(a, p.Dir, p.ImportPath, nil, "ar", arArgs, "rc", absAfile, absOfiles) + var arArgs []string + if cfg.Goos == "aix" && cfg.Goarch == "ppc64" { + // AIX puts both 32-bit and 64-bit objects in the same archive. + // Tell the AIX "ar" command to only care about 64-bit objects. + // AIX "ar" command does not know D option. + arArgs = []string{"-X64"} } - return nil + + return b.run(a, p.Dir, p.ImportPath, nil, tools.ar(), arArgs, "rc", mkAbs(objdir, afile), absOfiles) } func (tools gccgoToolchain) link(b *Builder, root *Action, out, importcfg string, allactions []*Action, buildmode, desc string) error { @@ -281,11 +289,11 @@ func (tools gccgoToolchain) link(b *Builder, root *Action, out, importcfg string b.Showcmd("", "ar d %s _cgo_flags", newArchive) return "", nil } - err := b.run(root, root.Objdir, desc, nil, "ar", "x", newArchive, "_cgo_flags") + err := b.run(root, root.Objdir, desc, nil, tools.ar(), "x", newArchive, "_cgo_flags") if err != nil { return "", err } - err = b.run(root, ".", desc, nil, "ar", "d", newArchive, "_cgo_flags") + err = b.run(root, ".", desc, nil, tools.ar(), "d", newArchive, "_cgo_flags") if err != nil { return "", err } @@ -393,7 +401,6 @@ func (tools gccgoToolchain) link(b *Builder, root *Action, out, importcfg string if root.Package != nil { ldflags = append(ldflags, root.Package.CgoLDFLAGS...) } - if cfg.Goos != "aix" { ldflags = str.StringList("-Wl,-(", ldflags, "-Wl,-)") } @@ -505,7 +512,7 @@ func (tools gccgoToolchain) link(b *Builder, root *Action, out, importcfg string switch buildmode { case "c-archive": - if err := b.run(root, ".", desc, nil, "ar", "rc", realOut, out); err != nil { + if err := b.run(root, ".", desc, nil, tools.ar(), "rc", realOut, out); err != nil { return err } } diff --git a/libgo/go/cmd/go/internal/work/init.go b/libgo/go/cmd/go/internal/work/init.go index 56f1ff229cb..693a53e9ab7 100644 --- a/libgo/go/cmd/go/internal/work/init.go +++ b/libgo/go/cmd/go/internal/work/init.go @@ -10,6 +10,7 @@ import ( "cmd/go/internal/base" "cmd/go/internal/cfg" "cmd/go/internal/load" + "cmd/internal/sys" "flag" "fmt" "os" @@ -42,18 +43,14 @@ func instrumentInit() { fmt.Fprintf(os.Stderr, "go %s: may not use -race and -msan simultaneously\n", flag.Args()[0]) os.Exit(2) } - if cfg.BuildMSan && (cfg.Goos != "linux" || cfg.Goarch != "amd64" && cfg.Goarch != "arm64") { + if cfg.BuildMSan && !sys.MSanSupported(cfg.Goos, cfg.Goarch) { fmt.Fprintf(os.Stderr, "-msan is not supported on %s/%s\n", cfg.Goos, cfg.Goarch) os.Exit(2) } if cfg.BuildRace { - platform := cfg.Goos + "/" + cfg.Goarch - switch platform { - default: - fmt.Fprintf(os.Stderr, "go %s: -race is only supported on linux/amd64, linux/ppc64le, freebsd/amd64, netbsd/amd64, darwin/amd64 and windows/amd64\n", flag.Args()[0]) + if !sys.RaceDetectorSupported(cfg.Goos, cfg.Goarch) { + fmt.Fprintf(os.Stderr, "go %s: -race is only supported on linux/amd64, linux/ppc64le, linux/arm64, freebsd/amd64, netbsd/amd64, darwin/amd64 and windows/amd64\n", flag.Args()[0]) os.Exit(2) - case "linux/amd64", "linux/ppc64le", "freebsd/amd64", "netbsd/amd64", "darwin/amd64", "windows/amd64": - // race supported on these platforms } } mode := "race" diff --git a/libgo/go/cmd/go/internal/work/security.go b/libgo/go/cmd/go/internal/work/security.go index 2132c5f3e15..1a401b8981e 100644 --- a/libgo/go/cmd/go/internal/work/security.go +++ b/libgo/go/cmd/go/internal/work/security.go @@ -89,7 +89,9 @@ var validCompilerFlags = []*regexp.Regexp{ re(`-m32`), re(`-m64`), re(`-m(abi|arch|cpu|fpu|tune)=([^@\-].*)`), + re(`-m(no-)?v?aes`), re(`-marm`), + re(`-m(no-)?avx[0-9a-z]*`), re(`-mfloat-abi=([^@\-].*)`), re(`-mfpmath=[0-9a-z,+]*`), re(`-m(no-)?avx[0-9a-z.]*`), @@ -100,6 +102,7 @@ var validCompilerFlags = []*regexp.Regexp{ re(`-miphoneos-version-min=(.+)`), re(`-mnop-fun-dllimport`), re(`-m(no-)?sse[0-9.]*`), + re(`-m(no-)?ssse3`), re(`-mthumb(-interwork)?`), re(`-mthreads`), re(`-mwindows`), diff --git a/libgo/go/cmd/go/main.go b/libgo/go/cmd/go/main.go index 14b435295ec..d986f5508d9 100644 --- a/libgo/go/cmd/go/main.go +++ b/libgo/go/cmd/go/main.go @@ -93,9 +93,18 @@ func main() { *get.CmdGet = *modget.CmdGet } + if args[0] == "get" || args[0] == "help" { + // Replace get with module-aware get if appropriate. + // Note that if MustUseModules is true, this happened already above, + // but no harm in doing it again. + if modload.Init(); modload.Enabled() { + *get.CmdGet = *modget.CmdGet + } + } + cfg.CmdName = args[0] // for error messages if args[0] == "help" { - help.Help(args[1:]) + help.Help(os.Stdout, args[1:]) return } @@ -145,10 +154,10 @@ func main() { flag = flag[:i] } switch flag { - case "-sync": - fmt.Fprintf(os.Stderr, "go: go mod -sync is now go mod tidy\n") + case "-sync", "-fix": + fmt.Fprintf(os.Stderr, "go: go mod %s is now go mod tidy\n", flag) os.Exit(2) - case "-init", "-fix", "-graph", "-vendor", "-verify": + case "-init", "-graph", "-vendor", "-verify": fmt.Fprintf(os.Stderr, "go: go mod %s is now go mod %s\n", flag, flag[1:]) os.Exit(2) case "-fmt", "-json", "-module", "-require", "-droprequire", "-replace", "-dropreplace", "-exclude", "-dropexclude": @@ -164,15 +173,6 @@ func main() { os.Exit(2) } - if args[0] == "get" { - // Replace get with module-aware get if appropriate. - // Note that if MustUseModules is true, this happened already above, - // but no harm in doing it again. - if modload.Init(); modload.Enabled() { - *get.CmdGet = *modget.CmdGet - } - } - // Set environment (GOOS, GOARCH, etc) explicitly. // In theory all the commands we invoke should have // the same default computation of these as we do, @@ -202,7 +202,7 @@ BigCmdLoop: } if args[0] == "help" { // Accept 'go mod help' and 'go mod help foo' for 'go help mod' and 'go help mod foo'. - help.Help(append(strings.Split(cfg.CmdName, " "), args[1:]...)) + help.Help(os.Stdout, append(strings.Split(cfg.CmdName, " "), args[1:]...)) return } cfg.CmdName += " " + args[0] @@ -238,10 +238,6 @@ func init() { } func mainUsage() { - // special case "go test -h" - if len(os.Args) > 1 && os.Args[1] == "test" { - test.Usage() - } help.PrintUsage(os.Stderr, base.Go) os.Exit(2) } diff --git a/libgo/go/cmd/go/proxy_test.go b/libgo/go/cmd/go/proxy_test.go index 212e5aa08f7..830cea029b7 100644 --- a/libgo/go/cmd/go/proxy_test.go +++ b/libgo/go/cmd/go/proxy_test.go @@ -78,7 +78,7 @@ func readModList() { if i < 0 { continue } - encPath := strings.Replace(name[:i], "_", "/", -1) + encPath := strings.ReplaceAll(name[:i], "_", "/") path, err := module.DecodePath(encPath) if err != nil { fmt.Fprintf(os.Stderr, "go proxy_test: %v\n", err) @@ -197,7 +197,13 @@ func proxyHandler(w http.ResponseWriter, r *http.Request) { if strings.HasPrefix(f.Name, ".") { continue } - zf, err := z.Create(path + "@" + vers + "/" + f.Name) + var zipName string + if strings.HasPrefix(f.Name, "/") { + zipName = f.Name[1:] + } else { + zipName = path + "@" + vers + "/" + f.Name + } + zf, err := z.Create(zipName) if err != nil { return cached{nil, err} } @@ -256,7 +262,7 @@ func readArchive(path, vers string) *txtar.Archive { return nil } - prefix := strings.Replace(enc, "/", "_", -1) + prefix := strings.ReplaceAll(enc, "/", "_") name := filepath.Join(cmdGoDir, "testdata/mod", prefix+"_"+encVers+".txt") a := archiveCache.Do(name, func() interface{} { a, err := txtar.ParseFile(name) diff --git a/libgo/go/cmd/go/script_test.go b/libgo/go/cmd/go/script_test.go index 6399faac0f4..f6facfd944f 100644 --- a/libgo/go/cmd/go/script_test.go +++ b/libgo/go/cmd/go/script_test.go @@ -9,7 +9,9 @@ package main_test import ( "bytes" + "context" "fmt" + "go/build" "internal/testenv" "io/ioutil" "os" @@ -25,6 +27,7 @@ import ( "cmd/go/internal/imports" "cmd/go/internal/par" "cmd/go/internal/txtar" + "cmd/go/internal/work" ) // TestScript runs the tests in testdata/script/*.txt. @@ -55,21 +58,28 @@ func TestScript(t *testing.T) { // A testScript holds execution state for a single test script. type testScript struct { - t *testing.T - workdir string // temporary work dir ($WORK) - log bytes.Buffer // test execution log (printed at end of test) - mark int // offset of next log truncation - cd string // current directory during test execution; initially $WORK/gopath/src - name string // short name of test ("foo") - file string // full file name ("testdata/script/foo.txt") - lineno int // line number currently executing - line string // line currently executing - env []string // environment list (for os/exec) - envMap map[string]string // environment mapping (matches env) - stdout string // standard output from last 'go' command; for 'stdout' command - stderr string // standard error from last 'go' command; for 'stderr' command - stopped bool // test wants to stop early - start time.Time // time phase started + t *testing.T + workdir string // temporary work dir ($WORK) + log bytes.Buffer // test execution log (printed at end of test) + mark int // offset of next log truncation + cd string // current directory during test execution; initially $WORK/gopath/src + name string // short name of test ("foo") + file string // full file name ("testdata/script/foo.txt") + lineno int // line number currently executing + line string // line currently executing + env []string // environment list (for os/exec) + envMap map[string]string // environment mapping (matches env) + stdout string // standard output from last 'go' command; for 'stdout' command + stderr string // standard error from last 'go' command; for 'stderr' command + stopped bool // test wants to stop early + start time.Time // time phase started + background []backgroundCmd // backgrounded 'exec' and 'go' commands +} + +type backgroundCmd struct { + cmd *exec.Cmd + wait <-chan struct{} + neg bool // if true, cmd should fail } var extraEnvKeys = []string{ @@ -102,6 +112,7 @@ func (ts *testScript) setup() { "GOROOT=" + testGOROOT, tempEnvName() + "=" + filepath.Join(ts.workdir, "tmp"), "devnull=" + os.DevNull, + "goversion=" + goVersion(ts), ":=" + string(os.PathListSeparator), } @@ -128,6 +139,16 @@ func (ts *testScript) setup() { } } +// goVersion returns the current Go version. +func goVersion(ts *testScript) string { + tags := build.Default.ReleaseTags + version := tags[len(tags)-1] + if !regexp.MustCompile(`^go([1-9][0-9]*)\.(0|[1-9][0-9]*)$`).MatchString(version) { + ts.fatalf("invalid go version %q", version) + } + return version[2:] +} + var execCache par.Cache // run runs the test script. @@ -152,6 +173,17 @@ func (ts *testScript) run() { } defer func() { + // On a normal exit from the test loop, background processes are cleaned up + // before we print PASS. If we return early (e.g., due to a test failure), + // don't print anything about the processes that were still running. + for _, bg := range ts.background { + interruptProcess(bg.cmd.Process) + } + for _, bg := range ts.background { + <-bg.wait + } + ts.background = nil + markTime() // Flush testScript log to testing.T log. ts.t.Log("\n" + ts.abbrev(ts.log.String())) @@ -249,12 +281,19 @@ Script: ok = testenv.HasExternalNetwork() case "link": ok = testenv.HasLink() + case "root": + ok = os.Geteuid() == 0 case "symlink": ok = testenv.HasSymlink() default: if strings.HasPrefix(cond, "exec:") { prog := cond[len("exec:"):] ok = execCache.Do(prog, func() interface{} { + if runtime.GOOS == "plan9" && prog == "git" { + // The Git command is usually not the real Git on Plan 9. + // See https://golang.org/issues/29640. + return false + } _, err := exec.LookPath(prog) return err == nil }).(bool) @@ -290,14 +329,23 @@ Script: // Command can ask script to stop early. if ts.stopped { - return + // Break instead of returning, so that we check the status of any + // background processes and print PASS. + break } } + for _, bg := range ts.background { + interruptProcess(bg.cmd.Process) + } + ts.cmdWait(false, nil) + // Final phase ended. rewind() markTime() - fmt.Fprintf(&ts.log, "PASS\n") + if !ts.stopped { + fmt.Fprintf(&ts.log, "PASS\n") + } } // scriptCmds are the script command implementations. @@ -307,8 +355,11 @@ Script: // var scriptCmds = map[string]func(*testScript, bool, []string){ "addcrlf": (*testScript).cmdAddcrlf, + "cc": (*testScript).cmdCc, "cd": (*testScript).cmdCd, + "chmod": (*testScript).cmdChmod, "cmp": (*testScript).cmdCmp, + "cmpenv": (*testScript).cmdCmpenv, "cp": (*testScript).cmdCp, "env": (*testScript).cmdEnv, "exec": (*testScript).cmdExec, @@ -323,6 +374,7 @@ var scriptCmds = map[string]func(*testScript, bool, []string){ "stdout": (*testScript).cmdStdout, "stop": (*testScript).cmdStop, "symlink": (*testScript).cmdSymlink, + "wait": (*testScript).cmdWait, } // addcrlf adds CRLF line endings to the named files. @@ -335,10 +387,21 @@ func (ts *testScript) cmdAddcrlf(neg bool, args []string) { file = ts.mkabs(file) data, err := ioutil.ReadFile(file) ts.check(err) - ts.check(ioutil.WriteFile(file, bytes.Replace(data, []byte("\n"), []byte("\r\n"), -1), 0666)) + ts.check(ioutil.WriteFile(file, bytes.ReplaceAll(data, []byte("\n"), []byte("\r\n")), 0666)) } } +// cc runs the C compiler along with platform specific options. +func (ts *testScript) cmdCc(neg bool, args []string) { + if len(args) < 1 || (len(args) == 1 && args[0] == "&") { + ts.fatalf("usage: cc args... [&]") + } + + var b work.Builder + b.Init() + ts.cmdExec(neg, append(b.GccCmd(".", ""), args...)) +} + // cd changes to a different directory. func (ts *testScript) cmdCd(neg bool, args []string) { if neg { @@ -364,6 +427,24 @@ func (ts *testScript) cmdCd(neg bool, args []string) { fmt.Fprintf(&ts.log, "%s\n", ts.cd) } +// chmod changes permissions for a file or directory. +func (ts *testScript) cmdChmod(neg bool, args []string) { + if neg { + ts.fatalf("unsupported: ! chmod") + } + if len(args) < 2 { + ts.fatalf("usage: chmod perm paths...") + } + perm, err := strconv.ParseUint(args[0], 0, 32) + if err != nil || perm&uint64(os.ModePerm) != perm { + ts.fatalf("invalid mode: %s", args[0]) + } + for _, path := range args[1:] { + err := os.Chmod(path, os.FileMode(perm)) + ts.check(err) + } +} + // cmp compares two files. func (ts *testScript) cmdCmp(neg bool, args []string) { if neg { @@ -373,7 +454,21 @@ func (ts *testScript) cmdCmp(neg bool, args []string) { if len(args) != 2 { ts.fatalf("usage: cmp file1 file2") } + ts.doCmdCmp(args, false) +} +// cmpenv compares two files with environment variable substitution. +func (ts *testScript) cmdCmpenv(neg bool, args []string) { + if neg { + ts.fatalf("unsupported: ! cmpenv") + } + if len(args) != 2 { + ts.fatalf("usage: cmpenv file1 file2") + } + ts.doCmdCmp(args, true) +} + +func (ts *testScript) doCmdCmp(args []string, env bool) { name1, name2 := args[0], args[1] var text1, text2 string if name1 == "stdout" { @@ -390,6 +485,11 @@ func (ts *testScript) cmdCmp(neg bool, args []string) { ts.check(err) text2 = string(data) + if env { + text1 = ts.expand(text1) + text2 = ts.expand(text2) + } + if text1 == text2 { return } @@ -457,26 +557,43 @@ func (ts *testScript) cmdEnv(neg bool, args []string) { // exec runs the given command. func (ts *testScript) cmdExec(neg bool, args []string) { - if len(args) < 1 { - ts.fatalf("usage: exec program [args...]") + if len(args) < 1 || (len(args) == 1 && args[0] == "&") { + ts.fatalf("usage: exec program [args...] [&]") } + var err error - ts.stdout, ts.stderr, err = ts.exec(args[0], args[1:]...) - if ts.stdout != "" { - fmt.Fprintf(&ts.log, "[stdout]\n%s", ts.stdout) - } - if ts.stderr != "" { - fmt.Fprintf(&ts.log, "[stderr]\n%s", ts.stderr) + if len(args) > 0 && args[len(args)-1] == "&" { + var cmd *exec.Cmd + cmd, err = ts.execBackground(args[0], args[1:len(args)-1]...) + if err == nil { + wait := make(chan struct{}) + go func() { + ctxWait(testCtx, cmd) + close(wait) + }() + ts.background = append(ts.background, backgroundCmd{cmd, wait, neg}) + } + ts.stdout, ts.stderr = "", "" + } else { + ts.stdout, ts.stderr, err = ts.exec(args[0], args[1:]...) + if ts.stdout != "" { + fmt.Fprintf(&ts.log, "[stdout]\n%s", ts.stdout) + } + if ts.stderr != "" { + fmt.Fprintf(&ts.log, "[stderr]\n%s", ts.stderr) + } + if err == nil && neg { + ts.fatalf("unexpected command success") + } } + if err != nil { fmt.Fprintf(&ts.log, "[%v]\n", err) - if !neg { + if testCtx.Err() != nil { + ts.fatalf("test timed out while running command") + } else if !neg { ts.fatalf("unexpected command failure") } - } else { - if neg { - ts.fatalf("unexpected command success") - } } } @@ -551,6 +668,14 @@ func (ts *testScript) cmdSkip(neg bool, args []string) { if neg { ts.fatalf("unsupported: ! skip") } + + // Before we mark the test as skipped, shut down any background processes and + // make sure they have returned the correct status. + for _, bg := range ts.background { + interruptProcess(bg.cmd.Process) + } + ts.cmdWait(false, nil) + if len(args) == 1 { ts.t.Skip(args[0]) } @@ -620,7 +745,7 @@ func scriptMatch(ts *testScript, neg bool, args []string, text, name string) { want = 2 } if len(args) != want { - ts.fatalf("usage: %s [-count=N] 'pattern' file%s", name, extraUsage) + ts.fatalf("usage: %s [-count=N] 'pattern'%s", name, extraUsage) } pattern := args[0] @@ -636,7 +761,7 @@ func scriptMatch(ts *testScript, neg bool, args []string, text, name string) { } // Matching against workdir would be misleading. - text = strings.Replace(text, ts.workdir, "$WORK", -1) + text = strings.ReplaceAll(text, ts.workdir, "$WORK") if neg { if re.MatchString(text) { @@ -693,11 +818,57 @@ func (ts *testScript) cmdSymlink(neg bool, args []string) { ts.check(os.Symlink(args[2], ts.mkabs(args[0]))) } +// wait waits for background commands to exit, setting stderr and stdout to their result. +func (ts *testScript) cmdWait(neg bool, args []string) { + if neg { + ts.fatalf("unsupported: ! wait") + } + if len(args) > 0 { + ts.fatalf("usage: wait") + } + + var stdouts, stderrs []string + for _, bg := range ts.background { + <-bg.wait + + args := append([]string{filepath.Base(bg.cmd.Args[0])}, bg.cmd.Args[1:]...) + fmt.Fprintf(&ts.log, "[background] %s: %v\n", strings.Join(args, " "), bg.cmd.ProcessState) + + cmdStdout := bg.cmd.Stdout.(*strings.Builder).String() + if cmdStdout != "" { + fmt.Fprintf(&ts.log, "[stdout]\n%s", cmdStdout) + stdouts = append(stdouts, cmdStdout) + } + + cmdStderr := bg.cmd.Stderr.(*strings.Builder).String() + if cmdStderr != "" { + fmt.Fprintf(&ts.log, "[stderr]\n%s", cmdStderr) + stderrs = append(stderrs, cmdStderr) + } + + if bg.cmd.ProcessState.Success() { + if bg.neg { + ts.fatalf("unexpected command success") + } + } else { + if testCtx.Err() != nil { + ts.fatalf("test timed out while running command") + } else if !bg.neg { + ts.fatalf("unexpected command failure") + } + } + } + + ts.stdout = strings.Join(stdouts, "") + ts.stderr = strings.Join(stderrs, "") + ts.background = nil +} + // Helpers for command implementations. // abbrev abbreviates the actual work directory in the string s to the literal string "$WORK". func (ts *testScript) abbrev(s string) string { - s = strings.Replace(s, ts.workdir, "$WORK", -1) + s = strings.ReplaceAll(s, ts.workdir, "$WORK") if *testWork { // Expose actual $WORK value in environment dump on first line of work script, // so that the user can find out what directory -testwork left behind. @@ -722,10 +893,51 @@ func (ts *testScript) exec(command string, args ...string) (stdout, stderr strin var stdoutBuf, stderrBuf strings.Builder cmd.Stdout = &stdoutBuf cmd.Stderr = &stderrBuf - err = cmd.Run() + if err = cmd.Start(); err == nil { + err = ctxWait(testCtx, cmd) + } return stdoutBuf.String(), stderrBuf.String(), err } +// execBackground starts the given command line (an actual subprocess, not simulated) +// in ts.cd with environment ts.env. +func (ts *testScript) execBackground(command string, args ...string) (*exec.Cmd, error) { + cmd := exec.Command(command, args...) + cmd.Dir = ts.cd + cmd.Env = append(ts.env, "PWD="+ts.cd) + var stdoutBuf, stderrBuf strings.Builder + cmd.Stdout = &stdoutBuf + cmd.Stderr = &stderrBuf + return cmd, cmd.Start() +} + +// ctxWait is like cmd.Wait, but terminates cmd with os.Interrupt if ctx becomes done. +// +// This differs from exec.CommandContext in that it prefers os.Interrupt over os.Kill. +// (See https://golang.org/issue/21135.) +func ctxWait(ctx context.Context, cmd *exec.Cmd) error { + errc := make(chan error, 1) + go func() { errc <- cmd.Wait() }() + + select { + case err := <-errc: + return err + case <-ctx.Done(): + interruptProcess(cmd.Process) + return <-errc + } +} + +// interruptProcess sends os.Interrupt to p if supported, or os.Kill otherwise. +func interruptProcess(p *os.Process) { + if err := p.Signal(os.Interrupt); err != nil { + // Per https://golang.org/pkg/os/#Signal, “Interrupt is not implemented on + // Windows; using it with os.Process.Signal will return an error.” + // Fall back to Kill instead. + p.Kill() + } +} + // expand applies environment variable expansion to the string s. func (ts *testScript) expand(s string) string { return os.Expand(s, func(key string) string { return ts.envMap[key] }) @@ -891,17 +1103,17 @@ var diffTests = []struct { func TestDiff(t *testing.T) { for _, tt := range diffTests { // Turn spaces into \n. - text1 := strings.Replace(tt.text1, " ", "\n", -1) + text1 := strings.ReplaceAll(tt.text1, " ", "\n") if text1 != "" { text1 += "\n" } - text2 := strings.Replace(tt.text2, " ", "\n", -1) + text2 := strings.ReplaceAll(tt.text2, " ", "\n") if text2 != "" { text2 += "\n" } out := diff(text1, text2) // Cut final \n, cut spaces, turn remaining \n into spaces. - out = strings.Replace(strings.Replace(strings.TrimSuffix(out, "\n"), " ", "", -1), "\n", " ", -1) + out = strings.ReplaceAll(strings.ReplaceAll(strings.TrimSuffix(out, "\n"), " ", ""), "\n", " ") if out != tt.diff { t.Errorf("diff(%q, %q) = %q, want %q", text1, text2, out, tt.diff) } diff --git a/libgo/go/cmd/go/testdata/addmod.go b/libgo/go/cmd/go/testdata/addmod.go index 19850af0f37..8bb6056a540 100644 --- a/libgo/go/cmd/go/testdata/addmod.go +++ b/libgo/go/cmd/go/testdata/addmod.go @@ -142,7 +142,7 @@ func main() { } data := txtar.Format(a) - target := filepath.Join("mod", strings.Replace(path, "/", "_", -1)+"_"+vers+".txt") + target := filepath.Join("mod", strings.ReplaceAll(path, "/", "_")+"_"+vers+".txt") if err := ioutil.WriteFile(target, data, 0666); err != nil { log.Printf("%s: %v", arg, err) exitCode = 1 diff --git a/libgo/go/cmd/go/testdata/mod/research.swtch.com_vgo-tour_v1.0.0.txt b/libgo/go/cmd/go/testdata/mod/research.swtch.com_vgo-tour_v1.0.0.txt deleted file mode 100644 index 0f060dc8e32..00000000000 --- a/libgo/go/cmd/go/testdata/mod/research.swtch.com_vgo-tour_v1.0.0.txt +++ /dev/null @@ -1,23 +0,0 @@ -research.swtch.com/vgo-tour@v1.0.0 - --- .mod -- -module "research.swtch.com/vgo-tour" --- .info -- -{"Version":"v1.0.0","Name":"84de74b35823c1e49634f2262f1a58cfc951ebae","Short":"84de74b35823","Time":"2018-02-20T00:04:00Z"} --- go.mod -- -module "research.swtch.com/vgo-tour" --- hello.go -- -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -import ( - "fmt" - "rsc.io/quote" -) - -func main() { - fmt.Println(quote.Hello()) -} diff --git a/libgo/go/cmd/go/testdata/script/README b/libgo/go/cmd/go/testdata/script/README index a80233b8c38..a7b50fff164 100644 --- a/libgo/go/cmd/go/testdata/script/README +++ b/libgo/go/cmd/go/testdata/script/README @@ -36,6 +36,7 @@ Scripts also have access to these other environment variables: PATH= TMPDIR=$WORK/tmp devnull= + goversion= The environment variable $exe (lowercase) is an empty string on most systems, ".exe" on Windows. @@ -74,6 +75,7 @@ should only run when the condition is satisfied. The available conditions are: - [cgo], [msan], [race] for whether cgo, msan, and the race detector can be used - [net] for whether the external network can be used - [link] for testenv.HasLink() + - [root] for os.Geteuid() == 0 - [symlink] for testenv.HasSymlink() - [exec:prog] for whether prog is available for execution (found by exec.LookPath) @@ -82,9 +84,17 @@ when testing.Short() is false. The commands are: +- [!] cc args... [&] + Run the C compiler, the platform specific flags (i.e. `go env GOGCCFLAGS`) will be + added automatically before args. + - cd dir Change to the given directory for future commands. +- chmod perm path... + Change the permissions of the files or directories named by the path arguments + to be equal to perm. Only numerical permissions are supported. + - cmp file1 file2 Check that the named files have the same content. By convention, file1 is the actual data and file2 the expected data. @@ -92,6 +102,10 @@ The commands are: from the most recent exec or go command. (If the files have differing content, the failure prints a diff.) +- cmpenv file1 file2 + Like cmp, but environment variables are substituted in the file contents + before the comparison. For example, $GOOS is replaced by the target GOOS. + - cp src... dst Copy the listed files to the target file or existing directory. @@ -99,16 +113,23 @@ The commands are: With no arguments, print the environment (useful for debugging). Otherwise add the listed key=value pairs to the environment. -- [!] exec program [args...] +- [!] exec program [args...] [&] Run the given executable program with the arguments. It must (or must not) succeed. Note that 'exec' does not terminate the script (unlike in Unix shells). + If the last token is '&', the program executes in the background. The standard + output and standard error of the previous command is cleared, but the output + of the background process is buffered — and checking of its exit status is + delayed — until the next call to 'wait', 'skip', or 'stop' or the end of the + test. At the end of the test, any remaining background processes are + terminated using os.Interrupt (if supported) or os.Kill. + - [!] exists [-readonly] file... Each of the listed files or directories must (or must not) exist. If -readonly is given, the files or directories must be unwritable. -- [!] go args... +- [!] go args... [&] Run the (test copy of the) go command with the given arguments. It must (or must not) succeed. @@ -131,11 +152,11 @@ The commands are: - [!] stderr [-count=N] pattern Apply the grep command (see above) to the standard error - from the most recent exec or go command. + from the most recent exec, go, or wait command. - [!] stdout [-count=N] pattern Apply the grep command (see above) to the standard output - from the most recent exec or go command. + from the most recent exec, go, or wait command. - stop [message] Stop the test early (marking it as passing), including the message if given. @@ -143,6 +164,13 @@ The commands are: - symlink file -> target Create file as a symlink to target. The -> (like in ls -l output) is required. +- wait + Wait for all 'exec' and 'go' commands started in the background (with the '&' + token) to exit, and display success or failure status for them. + After a call to wait, the 'stderr' and 'stdout' commands will apply to the + concatenation of the corresponding streams of the background commands, + in the order in which those commands were started. + When TestScript runs a script and the script fails, by default TestScript shows the execution of the most recent phase of the script (since the last # comment) and only shows the # comments for earlier phases. For example, here is a diff --git a/libgo/go/cmd/go/testdata/script/build_GOTMPDIR.txt b/libgo/go/cmd/go/testdata/script/build_GOTMPDIR.txt index 4c387afbbab..ea06dcc472d 100644 --- a/libgo/go/cmd/go/testdata/script/build_GOTMPDIR.txt +++ b/libgo/go/cmd/go/testdata/script/build_GOTMPDIR.txt @@ -1,6 +1,8 @@ +# Set GOCACHE to a clean directory to ensure that 'go build' has work to report. +env GOCACHE=$WORK/gocache + # Build should use GOTMPDIR if set. env GOTMPDIR=$WORK/my-favorite-tmpdir -env GOCACHE=off mkdir $GOTMPDIR go build -work hello.go stderr ^WORK=.*my-favorite-tmpdir @@ -8,4 +10,3 @@ stderr ^WORK=.*my-favorite-tmpdir -- hello.go -- package main func main() { println("hello") } - diff --git a/libgo/go/cmd/go/testdata/script/help.txt b/libgo/go/cmd/go/testdata/script/help.txt index cbbd15404b5..9f455256f72 100644 --- a/libgo/go/cmd/go/testdata/script/help.txt +++ b/libgo/go/cmd/go/testdata/script/help.txt @@ -28,3 +28,21 @@ stdout 'usage: go mod tidy' # go mod --help doesn't print help but at least suggests it. ! go mod --help stderr 'Run ''go help mod'' for usage.' + +# Earlier versions of Go printed the same as 'go -h' here. +# Also make sure we print the short help line. +! go vet -h +stderr 'usage: go vet' +stderr 'Run ''go help vet'' for details' +stderr 'Run ''go tool vet -help'' for the vet tool''s flags' + +# Earlier versions of Go printed a large document here, instead of these two +# lines. +! go test -h +stderr 'usage: go test' +stderr 'Run ''go help test'' for details' + +# go help get shows usage for get +go help get +stdout 'usage: go get' +stdout 'get when using GOPATH' diff --git a/libgo/go/cmd/go/testdata/script/list_bad_import.txt b/libgo/go/cmd/go/testdata/script/list_bad_import.txt index ba66b0937f8..3d9cac0d5f5 100644 --- a/libgo/go/cmd/go/testdata/script/list_bad_import.txt +++ b/libgo/go/cmd/go/testdata/script/list_bad_import.txt @@ -47,7 +47,7 @@ stdout error stdout incomplete -# The pattern "all" should match only packages that acutally exist, +# The pattern "all" should match only packages that actually exist, # ignoring those whose existence is merely implied by imports. go list -e -f '{{.ImportPath}}' all stdout example.com/direct diff --git a/libgo/go/cmd/go/testdata/script/list_std.txt b/libgo/go/cmd/go/testdata/script/list_std.txt index a63d74db120..046bec6ac54 100644 --- a/libgo/go/cmd/go/testdata/script/list_std.txt +++ b/libgo/go/cmd/go/testdata/script/list_std.txt @@ -8,5 +8,5 @@ go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' ./... # our vendored packages should be reported as standard go list std cmd -stdout golang_org/x/net/http2/hpack +stdout internal/x/net/http2/hpack stdout cmd/vendor/golang\.org/x/arch/x86/x86asm diff --git a/libgo/go/cmd/go/testdata/script/mod_download.txt b/libgo/go/cmd/go/testdata/script/mod_download.txt index 6be6acb360c..22f07c33c75 100644 --- a/libgo/go/cmd/go/testdata/script/mod_download.txt +++ b/libgo/go/cmd/go/testdata/script/mod_download.txt @@ -8,6 +8,12 @@ exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.info exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.mod exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.zip +# download of an invalid path should report the error +! go mod download this.domain.is.invalid/somemodule@v1.0.0 +stderr 'this.domain.is.invalid' +! go mod download -json this.domain.is.invalid/somemodule@v1.0.0 +stdout '"Error": ".*this.domain.is.invalid.*"' + # download -json with version should print JSON go mod download -json 'rsc.io/quote@<=v1.5.0' stdout '^\t"Path": "rsc.io/quote"' @@ -42,6 +48,21 @@ exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.mod exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip exists $GOPATH/pkg/mod/rsc.io/quote@v1.5.2 +# download repopulates deleted files and directories independently. +rm $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.info +go mod download +exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.info +rm $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.mod +go mod download +exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.mod +rm $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip +go mod download +exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.zip +rm -r $GOPATH/pkg/mod/rsc.io/quote@v1.5.2 +go mod download +exists $GOPATH/pkg/mod/rsc.io/quote@v1.5.2 + +# download reports the locations of downloaded files go mod download -json stdout '^\t"Path": "rsc.io/quote"' stdout '^\t"Version": "v1.5.2"' diff --git a/libgo/go/cmd/go/testdata/script/mod_edit.txt b/libgo/go/cmd/go/testdata/script/mod_edit.txt index 60a6f745361..aa714e8b3cd 100644 --- a/libgo/go/cmd/go/testdata/script/mod_edit.txt +++ b/libgo/go/cmd/go/testdata/script/mod_edit.txt @@ -10,37 +10,43 @@ stderr 'cannot determine module path' go mod init x.x/y/z stderr 'creating new go.mod: module x.x/y/z' -cmp go.mod $WORK/go.mod.init +cmpenv go.mod $WORK/go.mod.init ! go mod init -cmp go.mod $WORK/go.mod.init +cmpenv go.mod $WORK/go.mod.init # go mod edits go mod edit -droprequire=x.1 -require=x.1@v1.0.0 -require=x.2@v1.1.0 -droprequire=x.2 -exclude='x.1 @ v1.2.0' -exclude=x.1@v1.2.1 -replace=x.1@v1.3.0=y.1@v1.4.0 -replace='x.1@v1.4.0 = ../z' -cmp go.mod $WORK/go.mod.edit1 +cmpenv go.mod $WORK/go.mod.edit1 go mod edit -droprequire=x.1 -dropexclude=x.1@v1.2.1 -dropreplace=x.1@v1.3.0 -require=x.3@v1.99.0 -cmp go.mod $WORK/go.mod.edit2 +cmpenv go.mod $WORK/go.mod.edit2 # go mod edit -json go mod edit -json -cmp stdout $WORK/go.mod.json +cmpenv stdout $WORK/go.mod.json # go mod edit -replace go mod edit -replace=x.1@v1.3.0=y.1/v2@v2.3.5 -replace=x.1@v1.4.0=y.1/v2@v2.3.5 -cmp go.mod $WORK/go.mod.edit3 +cmpenv go.mod $WORK/go.mod.edit3 go mod edit -replace=x.1=y.1/v2@v2.3.6 -cmp go.mod $WORK/go.mod.edit4 +cmpenv go.mod $WORK/go.mod.edit4 go mod edit -dropreplace=x.1 -cmp go.mod $WORK/go.mod.edit5 +cmpenv go.mod $WORK/go.mod.edit5 # go mod edit -fmt cp $WORK/go.mod.badfmt go.mod go mod edit -fmt -print # -print should avoid writing file -cmp stdout $WORK/go.mod.edit4 +cmpenv stdout $WORK/go.mod.edit6 cmp go.mod $WORK/go.mod.badfmt go mod edit -fmt # without -print, should write file (and nothing to stdout) ! stdout . -cmp go.mod $WORK/go.mod.edit4 +cmpenv go.mod $WORK/go.mod.edit6 + +# go mod edit -module +cd $WORK/m +go mod init a.a/b/c +go mod edit -module x.x/y/z +cmpenv go.mod go.mod.edit -- x.go -- package x @@ -50,9 +56,13 @@ package w -- $WORK/go.mod.init -- module x.x/y/z + +go $goversion -- $WORK/go.mod.edit1 -- module x.x/y/z +go $goversion + require x.1 v1.0.0 exclude ( @@ -67,6 +77,8 @@ replace ( -- $WORK/go.mod.edit2 -- module x.x/y/z +go $goversion + exclude x.1 v1.2.0 replace x.1 v1.4.0 => ../z @@ -77,6 +89,7 @@ require x.3 v1.99.0 "Module": { "Path": "x.x/y/z" }, + "Go": "$goversion", "Require": [ { "Path": "x.3", @@ -104,6 +117,8 @@ require x.3 v1.99.0 -- $WORK/go.mod.edit3 -- module x.x/y/z +go $goversion + exclude x.1 v1.2.0 replace ( @@ -115,6 +130,8 @@ require x.3 v1.99.0 -- $WORK/go.mod.edit4 -- module x.x/y/z +go $goversion + exclude x.1 v1.2.0 replace x.1 => y.1/v2 v2.3.6 @@ -123,14 +140,32 @@ require x.3 v1.99.0 -- $WORK/go.mod.edit5 -- module x.x/y/z +go $goversion + +exclude x.1 v1.2.0 + +require x.3 v1.99.0 +-- $WORK/go.mod.edit6 -- +module x.x/y/z + +go 1.10 + exclude x.1 v1.2.0 +replace x.1 => y.1/v2 v2.3.6 + require x.3 v1.99.0 -- $WORK/go.mod.badfmt -- module x.x/y/z +go 1.10 + exclude x.1 v1.2.0 replace x.1 => y.1/v2 v2.3.6 require x.3 v1.99.0 +-- $WORK/m/go.mod.edit -- +module x.x/y/z + +go $goversion \ No newline at end of file diff --git a/libgo/go/cmd/go/testdata/script/mod_enabled.txt b/libgo/go/cmd/go/testdata/script/mod_enabled.txt index 8eef870b02b..ab5ee3d6dfa 100644 --- a/libgo/go/cmd/go/testdata/script/mod_enabled.txt +++ b/libgo/go/cmd/go/testdata/script/mod_enabled.txt @@ -38,9 +38,9 @@ stdout z[/\\]go.mod cd $GOPATH/src/x/y go env GOMOD -! stdout . -! go list -m -stderr 'cannot find main module' +stdout 'NUL|/dev/null' +go list -m +stdout '^command-line-arguments$' cd $GOPATH/foo go env GOMOD diff --git a/libgo/go/cmd/go/testdata/script/mod_fs_patterns.txt b/libgo/go/cmd/go/testdata/script/mod_fs_patterns.txt index d7d3e0321b5..9341a1d0830 100644 --- a/libgo/go/cmd/go/testdata/script/mod_fs_patterns.txt +++ b/libgo/go/cmd/go/testdata/script/mod_fs_patterns.txt @@ -34,11 +34,11 @@ stderr 'import lookup disabled' ! go build -mod=readonly ./nonexist ! stderr 'import lookup disabled' -stderr '^go: no such directory ./nonexist' +stderr 'unknown import path "m/nonexist": cannot find package' ! go build -mod=readonly ./go.mod ! stderr 'import lookup disabled' -stderr '^go: ./go.mod is not a directory' +stderr 'unknown import path "m/go.mod": cannot find package' -- x/go.mod -- module m diff --git a/libgo/go/cmd/go/testdata/script/mod_go_version.txt b/libgo/go/cmd/go/testdata/script/mod_go_version.txt index f2de74cee87..37f173531b6 100644 --- a/libgo/go/cmd/go/testdata/script/mod_go_version.txt +++ b/libgo/go/cmd/go/testdata/script/mod_go_version.txt @@ -3,9 +3,10 @@ env GO111MODULE=on go list -! go build -stderr 'module requires Go 1.999' +go build go build sub.1 +go build subver.1 +! stderr 'module requires' ! go build badsub.1 stderr 'module requires Go 1.11111' @@ -19,11 +20,13 @@ module m go 1.999 require ( sub.1 v1.0.0 + subver.1 v1.0.0 badsub.1 v1.0.0 versioned.1 v1.0.0 ) replace ( sub.1 => ./sub + subver.1 => ./subver badsub.1 => ./badsub versioned.1 v1.0.0 => ./versioned1 versioned.1 v1.1.0 => ./versioned2 @@ -39,12 +42,20 @@ go 1.11 -- sub/x.go -- package x +-- subver/go.mod -- +module m +go 1.11111 + +-- subver/x.go -- +package x + -- badsub/go.mod -- module m go 1.11111 -- badsub/x.go -- package x +invalid syntax -- versioned1/go.mod -- module versioned @@ -59,3 +70,4 @@ go 1.99999 -- versioned2/x.go -- package x +invalid syntax diff --git a/libgo/go/cmd/go/testdata/script/mod_internal.txt b/libgo/go/cmd/go/testdata/script/mod_internal.txt index 72706fdc7b4..5a47c3fa44a 100644 --- a/libgo/go/cmd/go/testdata/script/mod_internal.txt +++ b/libgo/go/cmd/go/testdata/script/mod_internal.txt @@ -18,15 +18,6 @@ stderr 'use of internal package golang.org/x/.* not allowed' ! go build ./fromstd stderr 'use of internal package internal/testenv not allowed' -# Packages found via standard-library vendoring should not leak. -! go build ./fromstdvendor -stderr 'use of vendored package golang_org/x/net/http/httpguts not allowed' - -env GO111MODULE=off -! go build ./fromstdvendor -[!gccgo] stderr 'cannot find package "golang_org/x/net/http/httpguts" in any of:' -env GO111MODULE=on - # Dependencies should be able to use their own internal modules... rm go.mod go mod init golang.org/notx @@ -83,10 +74,6 @@ import _ "golang.org/notx/useinternal" package fromstd import _ "internal/testenv" --- fromstdvendor/useinternal.go -- -package fromstdvendor -import _ "golang_org/x/net/http/httpguts" - -- replace/golang.org/notx/internal/go.mod -- module golang.org/x/internal diff --git a/libgo/go/cmd/go/testdata/script/mod_list_bad_import.txt b/libgo/go/cmd/go/testdata/script/mod_list_bad_import.txt index 258eb6a5671..8a66e0b72a0 100644 --- a/libgo/go/cmd/go/testdata/script/mod_list_bad_import.txt +++ b/libgo/go/cmd/go/testdata/script/mod_list_bad_import.txt @@ -47,7 +47,7 @@ stdout error stdout incomplete -# The pattern "all" should match only packages that acutally exist, +# The pattern "all" should match only packages that actually exist, # ignoring those whose existence is merely implied by imports. go list -e -f '{{.ImportPath}} {{.Error}}' all stdout example.com/direct diff --git a/libgo/go/cmd/go/testdata/script/mod_list_dir.txt b/libgo/go/cmd/go/testdata/script/mod_list_dir.txt index 6d9414794e5..31cd27d7561 100644 --- a/libgo/go/cmd/go/testdata/script/mod_list_dir.txt +++ b/libgo/go/cmd/go/testdata/script/mod_list_dir.txt @@ -12,7 +12,9 @@ stdout ^math$ go list -f '{{.ImportPath}}' . stdout ^x$ ! go list -f '{{.ImportPath}}' $GOPATH/pkg/mod/rsc.io/quote@v1.5.2 -stderr '^go: no such directory.*quote@v1.5.2' +stderr 'unknown import path "rsc.io/quote": cannot find package' +go list -e -f '{{with .Error}}{{.}}{{end}}' $GOPATH/pkg/mod/rsc.io/quote@v1.5.2 +stdout 'unknown import path "rsc.io/quote": cannot find package' go mod download rsc.io/quote@v1.5.2 go list -f '{{.ImportPath}}' $GOPATH/pkg/mod/rsc.io/quote@v1.5.2 stdout '^rsc.io/quote$' diff --git a/libgo/go/cmd/go/testdata/script/mod_nomod.txt b/libgo/go/cmd/go/testdata/script/mod_nomod.txt index c6fb791c514..b347deea7ff 100644 --- a/libgo/go/cmd/go/testdata/script/mod_nomod.txt +++ b/libgo/go/cmd/go/testdata/script/mod_nomod.txt @@ -16,7 +16,7 @@ go mod edit -json x.mod ! go get ! go install ! go list -! go run x.go +! go run ! go test ! go vet diff --git a/libgo/go/cmd/go/testdata/script/mod_patterns.txt b/libgo/go/cmd/go/testdata/script/mod_patterns.txt index 9b2ebdf02b9..539b64a2461 100644 --- a/libgo/go/cmd/go/testdata/script/mod_patterns.txt +++ b/libgo/go/cmd/go/testdata/script/mod_patterns.txt @@ -34,6 +34,13 @@ env CGO_ENABLED=0 go list -f '{{.ImportPath}}: {{.Match}}' all ... example.com/m/... ./... ./xyz... ! stdout example.com/m/useC +# 'go list ./...' should not try to resolve the main module. +cd ../empty +go list -deps ./... +! stdout . +! stderr 'finding' +stderr -count=1 '^go: warning: "./..." matched no packages' + -- m/go.mod -- module example.com/m @@ -64,3 +71,6 @@ module example.com/m/nested -- nested/useencoding/useencoding.go -- package useencoding import _ "encoding" + +-- empty/go.mod -- +module example.com/empty diff --git a/libgo/go/cmd/go/testdata/script/mod_readonly.txt b/libgo/go/cmd/go/testdata/script/mod_readonly.txt index 1b5932e441e..188a66d0e15 100644 --- a/libgo/go/cmd/go/testdata/script/mod_readonly.txt +++ b/libgo/go/cmd/go/testdata/script/mod_readonly.txt @@ -37,6 +37,8 @@ cmp go.mod go.mod.inconsistent -- go.mod -- module m +go 1.20 + -- x.go -- package x import _ "rsc.io/quote" diff --git a/libgo/go/cmd/go/testdata/script/mod_replace.txt b/libgo/go/cmd/go/testdata/script/mod_replace.txt index 5894ed69f34..78d6729fce3 100644 --- a/libgo/go/cmd/go/testdata/script/mod_replace.txt +++ b/libgo/go/cmd/go/testdata/script/mod_replace.txt @@ -1,10 +1,14 @@ env GO111MODULE=on +cp go.mod go.mod.orig + +# Make sure the test builds without replacement. go build -o a1.exe . exec ./a1.exe stdout 'Don''t communicate by sharing memory' # Modules can be replaced by local packages. +cp go.mod.orig go.mod go mod edit -replace=rsc.io/quote/v3=./local/rsc.io/quote/v3 go build -o a2.exe . exec ./a2.exe @@ -12,16 +16,27 @@ stdout 'Concurrency is not parallelism.' # The module path of the replacement doesn't need to match. # (For example, it could be a long-running fork with its own import path.) +cp go.mod.orig go.mod go mod edit -replace=rsc.io/quote/v3=./local/not-rsc.io/quote/v3 go build -o a3.exe . exec ./a3.exe stdout 'Clear is better than clever.' # However, the same module can't be used as two different paths. -go mod edit -dropreplace=rsc.io/quote/v3 -replace=not-rsc.io/quote/v3@v3.0.0=rsc.io/quote/v3@v3.0.0 -require=not-rsc.io/quote/v3@v3.0.0 +cp go.mod.orig go.mod +go mod edit -replace=not-rsc.io/quote/v3@v3.0.0=rsc.io/quote/v3@v3.0.0 -require=not-rsc.io/quote/v3@v3.0.0 ! go build -o a4.exe . stderr 'rsc.io/quote/v3@v3.0.0 used for two different module paths \(not-rsc.io/quote/v3 and rsc.io/quote/v3\)' +# Modules that do not (yet) exist upstream can be replaced too. +cp go.mod.orig go.mod +go mod edit -replace=not-rsc.io/quote/v3@v3.1.0=./local/rsc.io/quote/v3 +go build -o a5.exe ./usenewmodule +! stderr 'finding not-rsc.io/quote/v3' +grep 'not-rsc.io/quote/v3 v3.1.0' go.mod +exec ./a5.exe +stdout 'Concurrency is not parallelism.' + -- go.mod -- module quoter @@ -39,6 +54,18 @@ func main() { fmt.Println(quote.GoV3()) } +-- usenewmodule/main.go -- +package main + +import ( + "fmt" + "not-rsc.io/quote/v3" +) + +func main() { + fmt.Println(quote.GoV3()) +} + -- local/rsc.io/quote/v3/go.mod -- module rsc.io/quote/v3 diff --git a/libgo/go/cmd/go/testdata/script/mod_test.txt b/libgo/go/cmd/go/testdata/script/mod_test.txt index caeb25ada84..af4fd76d706 100644 --- a/libgo/go/cmd/go/testdata/script/mod_test.txt +++ b/libgo/go/cmd/go/testdata/script/mod_test.txt @@ -1,5 +1,8 @@ env GO111MODULE=on +# TODO(bcmills): Convert the 'go test' calls below to 'go list -test' once 'go +# list' is more sensitive to package loading errors. + # A test in the module's root package should work. cd a/ cp go.mod.empty go.mod @@ -48,6 +51,10 @@ cd ../d_test go test stdout PASS +cd ../e +go test +stdout PASS + -- a/go.mod.empty -- module example.com/user/a diff --git a/libgo/go/cmd/go/testdata/script/mod_tidy.txt b/libgo/go/cmd/go/testdata/script/mod_tidy.txt index 449aa073a78..de3b52e2c02 100644 --- a/libgo/go/cmd/go/testdata/script/mod_tidy.txt +++ b/libgo/go/cmd/go/testdata/script/mod_tidy.txt @@ -5,6 +5,9 @@ go mod tidy -v stderr '^unused y.1' ! stderr '^unused [^y]' +# tidy should not touch existing go line +grep 'go 1.10' go.mod + go list -m all ! stdout '^y' stdout '^w.1 v1.2.0' @@ -12,11 +15,17 @@ stdout '^z.1 v1.2.0' # empty tidy should not crash cd triv +! grep 'go ' go.mod go mod tidy +# tidy should add missing go line +grep 'go ' go.mod + -- go.mod -- module m +go 1.10 + require ( x.1 v1.0.0 y.1 v1.0.0 diff --git a/libgo/go/cmd/go/testdata/script/mod_vendor.txt b/libgo/go/cmd/go/testdata/script/mod_vendor.txt index b3769a85041..203183be881 100644 --- a/libgo/go/cmd/go/testdata/script/mod_vendor.txt +++ b/libgo/go/cmd/go/testdata/script/mod_vendor.txt @@ -67,6 +67,7 @@ module m require ( a v1.0.0 + diamondroot v0.0.0 mysite/myname/mypkg v1.0.0 w v1.0.0 // indirect x v1.0.0 @@ -76,6 +77,10 @@ require ( replace ( a v1.0.0 => ./a + diamondleft => ./diamondleft + diamondpoint => ./diamondpoint + diamondright => ./diamondright + diamondroot => ./diamondroot mysite/myname/mypkg v1.0.0 => ./mypkg w v1.0.0 => ./w x v1.0.0 => ./x @@ -200,6 +205,10 @@ import _ "z" package m import _ "x/x1" +-- importdiamond.go -- +package m + +import _ "diamondroot" -- w/go.mod -- module w -- w/w.go -- @@ -228,3 +237,42 @@ package y module z -- z/z.go -- package z + +-- diamondroot/go.mod -- +module diamondroot + +require ( + diamondleft v0.0.0 + diamondright v0.0.0 +) +-- diamondroot/x.go -- +package diamondroot + +import ( + _ "diamondleft" + _ "diamondright" +) +-- diamondleft/go.mod -- +module diamondleft + +require ( + diamondpoint v0.0.0 +) +-- diamondleft/x.go -- +package diamondleft + +import _ "diamondpoint" +-- diamondright/go.mod -- +module diamondright + +require ( + diamondpoint v0.0.0 +) +-- diamondright/x.go -- +package diamondright + +import _ "diamondpoint" +-- diamondpoint/go.mod -- +module diamondpoint +-- diamondpoint/x.go -- +package diamondpoint diff --git a/libgo/go/cmd/go/testdata/testterminal18153/terminal_test.go b/libgo/go/cmd/go/testdata/testterminal18153/terminal_test.go index d662e55ee55..71493efe983 100644 --- a/libgo/go/cmd/go/testdata/testterminal18153/terminal_test.go +++ b/libgo/go/cmd/go/testdata/testterminal18153/terminal_test.go @@ -5,7 +5,7 @@ // +build linux // This test is run by src/cmd/dist/test.go (cmd_go_test_terminal), -// and not by cmd/go's tests. This is because this test requires that +// and not by cmd/go's tests. This is because this test requires // that it be called with its stdout and stderr being a terminal. // dist doesn't run `cmd/go test` against this test directory if // dist's stdout/stderr aren't terminals. diff --git a/libgo/go/cmd/go/vendor_test.go b/libgo/go/cmd/go/vendor_test.go index 22aa643b003..c302d7e9b58 100644 --- a/libgo/go/cmd/go/vendor_test.go +++ b/libgo/go/cmd/go/vendor_test.go @@ -37,7 +37,7 @@ func TestVendorImports(t *testing.T) { vend/x/vendor/p/p [notfound] vend/x/vendor/r [] ` - want = strings.Replace(want+"\t", "\n\t\t", "\n", -1) + want = strings.ReplaceAll(want+"\t", "\n\t\t", "\n") want = strings.TrimPrefix(want, "\n") have := tg.stdout.String() diff --git a/libgo/go/cmd/gofmt/gofmt.go b/libgo/go/cmd/gofmt/gofmt.go index d5b7be327a5..ac6852f2e4e 100644 --- a/libgo/go/cmd/gofmt/gofmt.go +++ b/libgo/go/cmd/gofmt/gofmt.go @@ -319,10 +319,7 @@ func backupFile(filename string, data []byte, perm os.FileMode) (string, error) } // write data to backup file - n, err := f.Write(data) - if err == nil && n < len(data) { - err = io.ErrShortWrite - } + _, err = f.Write(data) if err1 := f.Close(); err == nil { err = err1 } diff --git a/libgo/go/cmd/gofmt/gofmt_test.go b/libgo/go/cmd/gofmt/gofmt_test.go index 16b653b6460..3008365cd23 100644 --- a/libgo/go/cmd/gofmt/gofmt_test.go +++ b/libgo/go/cmd/gofmt/gofmt_test.go @@ -200,7 +200,7 @@ func TestDiff(t *testing.T) { } if runtime.GOOS == "windows" { - b = bytes.Replace(b, []byte{'\r', '\n'}, []byte{'\n'}, -1) + b = bytes.ReplaceAll(b, []byte{'\r', '\n'}, []byte{'\n'}) } bs := bytes.SplitN(b, []byte{'\n'}, 3) diff --git a/libgo/go/cmd/gofmt/long_test.go b/libgo/go/cmd/gofmt/long_test.go index 237b86021bf..e2a6208f871 100644 --- a/libgo/go/cmd/gofmt/long_test.go +++ b/libgo/go/cmd/gofmt/long_test.go @@ -85,6 +85,12 @@ func testFile(t *testing.T, b1, b2 *bytes.Buffer, filename string) { // the first and 2nd result should be identical if !bytes.Equal(b1.Bytes(), b2.Bytes()) { + // A known instance of gofmt not being idempotent + // (see Issue #24472) + if strings.HasSuffix(filename, "issue22662.go") { + t.Log("known gofmt idempotency bug (Issue #24472)") + return + } t.Errorf("gofmt %s not idempotent", filename) } } diff --git a/libgo/go/cmd/internal/buildid/buildid.go b/libgo/go/cmd/internal/buildid/buildid.go index 41e6c773e1b..ac238d70ea0 100644 --- a/libgo/go/cmd/internal/buildid/buildid.go +++ b/libgo/go/cmd/internal/buildid/buildid.go @@ -7,8 +7,8 @@ package buildid import ( "bytes" "debug/elf" - "debug/xcoff" "fmt" + "internal/xcoff" "io" "os" "strconv" diff --git a/libgo/go/cmd/internal/objabi/doc.go b/libgo/go/cmd/internal/objabi/doc.go index 7bd5ff63e56..03dc9fb88bc 100644 --- a/libgo/go/cmd/internal/objabi/doc.go +++ b/libgo/go/cmd/internal/objabi/doc.go @@ -22,7 +22,7 @@ // // The file format is: // -// - magic header: "\x00\x00go19ld" +// - magic header: "\x00go112ld" // - byte 1 - version number // - sequence of strings giving dependencies (imported packages) // - empty string (marks end of sequence) @@ -38,7 +38,7 @@ // - data, the content of the defined symbols // - sequence of defined symbols // - byte 0xff (marks end of sequence) -// - magic footer: "\xff\xffgo19ld" +// - magic footer: "\xffgo112ld" // // All integers are stored in a zigzag varint format. // See golang.org/s/go12symtab for a definition. @@ -46,7 +46,7 @@ // Data blocks and strings are both stored as an integer // followed by that many bytes. // -// A symbol reference is a string name followed by a version. +// A symbol reference is a string name followed by an ABI or -1 for static. // // A symbol points to other symbols using an index into the symbol // reference sequence. Index 0 corresponds to a nil symbol pointer. @@ -57,7 +57,7 @@ // // - byte 0xfe (sanity check for synchronization) // - type [byte] -// - name & version [symref index] +// - name & ABI [symref index] // - flags [int] // 1<<0 dupok // 1<<1 local diff --git a/libgo/go/cmd/internal/objabi/flag.go b/libgo/go/cmd/internal/objabi/flag.go index 30cd7dccac2..90e944656bb 100644 --- a/libgo/go/cmd/internal/objabi/flag.go +++ b/libgo/go/cmd/internal/objabi/flag.go @@ -100,9 +100,18 @@ func (versionFlag) Set(s string) error { // for releases, but during development we include the full // build ID of the binary, so that if the compiler is changed and // rebuilt, we notice and rebuild all packages. - if s == "full" && strings.HasPrefix(Version, "devel") { - p += " buildID=" + buildID + if s == "full" { + // If there's an active experiment, include that, + // to distinguish go1.10.2 with an experiment + // from go1.10.2 without an experiment. + if x := Expstring(); x != "" { + p += " " + x + } + if strings.HasPrefix(Version, "devel") { + p += " buildID=" + buildID + } } + fmt.Printf("%s version %s%s%s\n", name, Version, sep, p) os.Exit(0) return nil diff --git a/libgo/go/cmd/internal/objabi/funcdata.go b/libgo/go/cmd/internal/objabi/funcdata.go index a7827125bf6..231d11b1857 100644 --- a/libgo/go/cmd/internal/objabi/funcdata.go +++ b/libgo/go/cmd/internal/objabi/funcdata.go @@ -18,6 +18,7 @@ const ( FUNCDATA_LocalsPointerMaps = 1 FUNCDATA_InlTree = 2 FUNCDATA_RegPointerMaps = 3 + FUNCDATA_StackObjects = 4 // ArgsSizeUnknown is set in Func.argsize to mark all functions // whose argument size is unknown (C vararg functions, and diff --git a/libgo/go/cmd/internal/objabi/funcid.go b/libgo/go/cmd/internal/objabi/funcid.go index 15a63ab8b34..1792df7cc1d 100644 --- a/libgo/go/cmd/internal/objabi/funcid.go +++ b/libgo/go/cmd/internal/objabi/funcid.go @@ -4,12 +4,17 @@ package objabi +import ( + "strconv" + "strings" +) + // A FuncID identifies particular functions that need to be treated // specially by the runtime. // Note that in some situations involving plugins, there may be multiple // copies of a particular special runtime function. // Note: this list must match the list in runtime/symtab.go. -type FuncID uint32 +type FuncID uint8 const ( FuncID_normal FuncID = iota // not a special function @@ -30,4 +35,65 @@ const ( FuncID_gogo FuncID_externalthreadhandler FuncID_debugCallV1 + FuncID_gopanic + FuncID_panicwrap + FuncID_wrapper // any autogenerated code (hash/eq algorithms, method wrappers, etc.) ) + +// Get the function ID for the named function in the named file. +// The function should be package-qualified. +func GetFuncID(name, file string) FuncID { + switch name { + case "runtime.main": + return FuncID_runtime_main + case "runtime.goexit": + return FuncID_goexit + case "runtime.jmpdefer": + return FuncID_jmpdefer + case "runtime.mcall": + return FuncID_mcall + case "runtime.morestack": + return FuncID_morestack + case "runtime.mstart": + return FuncID_mstart + case "runtime.rt0_go": + return FuncID_rt0_go + case "runtime.asmcgocall": + return FuncID_asmcgocall + case "runtime.sigpanic": + return FuncID_sigpanic + case "runtime.runfinq": + return FuncID_runfinq + case "runtime.gcBgMarkWorker": + return FuncID_gcBgMarkWorker + case "runtime.systemstack_switch": + return FuncID_systemstack_switch + case "runtime.systemstack": + return FuncID_systemstack + case "runtime.cgocallback_gofunc": + return FuncID_cgocallback_gofunc + case "runtime.gogo": + return FuncID_gogo + case "runtime.externalthreadhandler": + return FuncID_externalthreadhandler + case "runtime.debugCallV1": + return FuncID_debugCallV1 + case "runtime.gopanic": + return FuncID_gopanic + case "runtime.panicwrap": + return FuncID_panicwrap + } + if file == "" && !strings.HasSuffix(name, ".init") { + return FuncID_wrapper + } + if strings.HasPrefix(name, "runtime.call") { + if _, err := strconv.Atoi(name[12:]); err == nil { + // runtime.callXX reflect call wrappers. + return FuncID_wrapper + } + } + if strings.HasSuffix(name, "-fm") { + return FuncID_wrapper + } + return FuncID_normal +} diff --git a/libgo/go/cmd/internal/objabi/head.go b/libgo/go/cmd/internal/objabi/head.go index 23c7b62daf6..db2221d6b14 100644 --- a/libgo/go/cmd/internal/objabi/head.go +++ b/libgo/go/cmd/internal/objabi/head.go @@ -48,10 +48,13 @@ const ( Hplan9 Hsolaris Hwindows + Haix ) func (h *HeadType) Set(s string) error { switch s { + case "aix": + *h = Haix case "darwin": *h = Hdarwin case "dragonfly": @@ -82,6 +85,8 @@ func (h *HeadType) Set(s string) error { func (h *HeadType) String() string { switch *h { + case Haix: + return "aix" case Hdarwin: return "darwin" case Hdragonfly: diff --git a/libgo/go/cmd/internal/objabi/reloctype.go b/libgo/go/cmd/internal/objabi/reloctype.go index a3e2868a1bc..355882c6388 100644 --- a/libgo/go/cmd/internal/objabi/reloctype.go +++ b/libgo/go/cmd/internal/objabi/reloctype.go @@ -198,7 +198,7 @@ const ( R_WASMIMPORT ) -// IsDirectJump returns whether r is a relocation for a direct jump. +// IsDirectJump reports whether r is a relocation for a direct jump. // A direct jump is a CALL or JMP instruction that takes the target address // as immediate. The address is embedded into the instruction, possibly // with limited width. diff --git a/libgo/go/cmd/internal/objabi/stack.go b/libgo/go/cmd/internal/objabi/stack.go index 11433932e2d..62ab0398a66 100644 --- a/libgo/go/cmd/internal/objabi/stack.go +++ b/libgo/go/cmd/internal/objabi/stack.go @@ -10,11 +10,24 @@ const ( STACKSYSTEM = 0 StackSystem = STACKSYSTEM StackBig = 4096 - StackGuard = 880*stackGuardMultiplier + StackSystem StackSmall = 128 - StackLimit = StackGuard - StackSystem - StackSmall ) const ( StackPreempt = -1314 // 0xfff...fade ) + +// Initialize StackGuard and StackLimit according to target system. +var StackGuard = 880*stackGuardMultiplier() + StackSystem +var StackLimit = StackGuard - StackSystem - StackSmall + +// stackGuardMultiplier returns a multiplier to apply to the default +// stack guard size. Larger multipliers are used for non-optimized +// builds that have larger stack frames or for specific targets. +func stackGuardMultiplier() int { + // On AIX, a larger stack is needed for syscalls. + if GOOS == "aix" { + return 2 + } + return stackGuardMultiplierDefault +} diff --git a/libgo/go/cmd/internal/objabi/symkind.go b/libgo/go/cmd/internal/objabi/symkind.go index b95a0d3c701..16b4c535ed8 100644 --- a/libgo/go/cmd/internal/objabi/symkind.go +++ b/libgo/go/cmd/internal/objabi/symkind.go @@ -60,6 +60,13 @@ const ( SDWARFRANGE SDWARFLOC SDWARFMISC + // ABI alias. An ABI alias symbol is an empty symbol with a + // single relocation with 0 size that references the native + // function implementation symbol. + // + // TODO(austin): Remove this and all uses once the compiler + // generates real ABI wrappers rather than symbol aliases. + SABIALIAS // Update cmd/link/internal/sym/AbiSymKindToSymKind for new SymKind values. ) diff --git a/libgo/go/cmd/internal/objabi/symkind_string.go b/libgo/go/cmd/internal/objabi/symkind_string.go index 7152d6c0069..2b9a9080e8c 100644 --- a/libgo/go/cmd/internal/objabi/symkind_string.go +++ b/libgo/go/cmd/internal/objabi/symkind_string.go @@ -4,9 +4,9 @@ package objabi import "strconv" -const _SymKind_name = "SxxxSTEXTSRODATASNOPTRDATASDATASBSSSNOPTRBSSSTLSBSSSDWARFINFOSDWARFRANGESDWARFLOCSDWARFMISC" +const _SymKind_name = "SxxxSTEXTSRODATASNOPTRDATASDATASBSSSNOPTRBSSSTLSBSSSDWARFINFOSDWARFRANGESDWARFLOCSDWARFMISCSABIALIAS" -var _SymKind_index = [...]uint8{0, 4, 9, 16, 26, 31, 35, 44, 51, 61, 72, 81, 91} +var _SymKind_index = [...]uint8{0, 4, 9, 16, 26, 31, 35, 44, 51, 61, 72, 81, 91, 100} func (i SymKind) String() string { if i >= SymKind(len(_SymKind_index)-1) { diff --git a/libgo/go/cmd/internal/objabi/util.go b/libgo/go/cmd/internal/objabi/util.go index a47e2f93a10..da49f706f60 100644 --- a/libgo/go/cmd/internal/objabi/util.go +++ b/libgo/go/cmd/internal/objabi/util.go @@ -76,7 +76,7 @@ func init() { } func Framepointer_enabled(goos, goarch string) bool { - return framepointer_enabled != 0 && goarch == "amd64" && goos != "nacl" + return framepointer_enabled != 0 && (goarch == "amd64" && goos != "nacl" || goarch == "arm64" && goos == "linux") } func addexp(s string) { @@ -104,8 +104,6 @@ var ( framepointer_enabled int = 1 Fieldtrack_enabled int Preemptibleloops_enabled int - Clobberdead_enabled int - DebugCPU_enabled int ) // Toolchain experiments. @@ -119,8 +117,6 @@ var exper = []struct { {"fieldtrack", &Fieldtrack_enabled}, {"framepointer", &framepointer_enabled}, {"preemptibleloops", &Preemptibleloops_enabled}, - {"clobberdead", &Clobberdead_enabled}, - {"debugcpu", &DebugCPU_enabled}, } var defaultExpstring = Expstring() diff --git a/libgo/go/cmd/internal/sys/arch.go b/libgo/go/cmd/internal/sys/arch.go new file mode 100644 index 00000000000..487c9260e85 --- /dev/null +++ b/libgo/go/cmd/internal/sys/arch.go @@ -0,0 +1,187 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package sys + +import "encoding/binary" + +// ArchFamily represents a family of one or more related architectures. +// For example, amd64 and amd64p32 are both members of the AMD64 family, +// and ppc64 and ppc64le are both members of the PPC64 family. +type ArchFamily byte + +const ( + NoArch ArchFamily = iota + AMD64 + ARM + ARM64 + I386 + MIPS + MIPS64 + PPC64 + S390X + Wasm +) + +// Arch represents an individual architecture. +type Arch struct { + Name string + Family ArchFamily + + ByteOrder binary.ByteOrder + + // PtrSize is the size in bytes of pointers and the + // predeclared "int", "uint", and "uintptr" types. + PtrSize int + + // RegSize is the size in bytes of general purpose registers. + RegSize int + + // MinLC is the minimum length of an instruction code. + MinLC int +} + +// InFamily reports whether a is a member of any of the specified +// architecture families. +func (a *Arch) InFamily(xs ...ArchFamily) bool { + for _, x := range xs { + if a.Family == x { + return true + } + } + return false +} + +var Arch386 = &Arch{ + Name: "386", + Family: I386, + ByteOrder: binary.LittleEndian, + PtrSize: 4, + RegSize: 4, + MinLC: 1, +} + +var ArchAMD64 = &Arch{ + Name: "amd64", + Family: AMD64, + ByteOrder: binary.LittleEndian, + PtrSize: 8, + RegSize: 8, + MinLC: 1, +} + +var ArchAMD64P32 = &Arch{ + Name: "amd64p32", + Family: AMD64, + ByteOrder: binary.LittleEndian, + PtrSize: 4, + RegSize: 8, + MinLC: 1, +} + +var ArchARM = &Arch{ + Name: "arm", + Family: ARM, + ByteOrder: binary.LittleEndian, + PtrSize: 4, + RegSize: 4, + MinLC: 4, +} + +var ArchARM64 = &Arch{ + Name: "arm64", + Family: ARM64, + ByteOrder: binary.LittleEndian, + PtrSize: 8, + RegSize: 8, + MinLC: 4, +} + +var ArchMIPS = &Arch{ + Name: "mips", + Family: MIPS, + ByteOrder: binary.BigEndian, + PtrSize: 4, + RegSize: 4, + MinLC: 4, +} + +var ArchMIPSLE = &Arch{ + Name: "mipsle", + Family: MIPS, + ByteOrder: binary.LittleEndian, + PtrSize: 4, + RegSize: 4, + MinLC: 4, +} + +var ArchMIPS64 = &Arch{ + Name: "mips64", + Family: MIPS64, + ByteOrder: binary.BigEndian, + PtrSize: 8, + RegSize: 8, + MinLC: 4, +} + +var ArchMIPS64LE = &Arch{ + Name: "mips64le", + Family: MIPS64, + ByteOrder: binary.LittleEndian, + PtrSize: 8, + RegSize: 8, + MinLC: 4, +} + +var ArchPPC64 = &Arch{ + Name: "ppc64", + Family: PPC64, + ByteOrder: binary.BigEndian, + PtrSize: 8, + RegSize: 8, + MinLC: 4, +} + +var ArchPPC64LE = &Arch{ + Name: "ppc64le", + Family: PPC64, + ByteOrder: binary.LittleEndian, + PtrSize: 8, + RegSize: 8, + MinLC: 4, +} + +var ArchS390X = &Arch{ + Name: "s390x", + Family: S390X, + ByteOrder: binary.BigEndian, + PtrSize: 8, + RegSize: 8, + MinLC: 2, +} + +var ArchWasm = &Arch{ + Name: "wasm", + Family: Wasm, + ByteOrder: binary.LittleEndian, + PtrSize: 8, + RegSize: 8, + MinLC: 1, +} + +var Archs = [...]*Arch{ + Arch386, + ArchAMD64, + ArchAMD64P32, + ArchARM, + ArchARM64, + ArchMIPS, + ArchMIPSLE, + ArchMIPS64, + ArchMIPS64LE, + ArchPPC64, + ArchPPC64LE, + ArchS390X, + ArchWasm, +} diff --git a/libgo/go/cmd/internal/sys/supported.go b/libgo/go/cmd/internal/sys/supported.go new file mode 100644 index 00000000000..a53da6ed2cb --- /dev/null +++ b/libgo/go/cmd/internal/sys/supported.go @@ -0,0 +1,29 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package sys + +// RaceDetectorSupported reports whether goos/goarch supports the race +// detector. There is a copy of this function in cmd/dist/test.go. +func RaceDetectorSupported(goos, goarch string) bool { + switch goos { + case "linux": + return goarch == "amd64" || goarch == "ppc64le" || goarch == "arm64" + case "darwin", "freebsd", "netbsd", "windows": + return goarch == "amd64" + default: + return false + } +} + +// MSanSupported reports whether goos/goarch supports the memory +// sanitizer option. There is a copy of this function in cmd/dist/test.go. +func MSanSupported(goos, goarch string) bool { + switch goos { + case "linux": + return goarch == "amd64" || goarch == "arm64" + default: + return false + } +} diff --git a/libgo/go/cmd/vet/all/main.go b/libgo/go/cmd/vet/all/main.go index 09181f96895..2500c690bfd 100644 --- a/libgo/go/cmd/vet/all/main.go +++ b/libgo/go/cmd/vet/all/main.go @@ -7,6 +7,9 @@ // The vet/all command runs go vet on the standard library and commands. // It compares the output against a set of whitelists // maintained in the whitelist directory. +// +// This program attempts to build packages from golang.org/x/tools, +// which must be in your GOPATH. package main import ( @@ -18,6 +21,7 @@ import ( "go/types" "internal/testenv" "io" + "io/ioutil" "log" "os" "os/exec" @@ -192,9 +196,21 @@ func vetPlatforms(pp []platform) { } func (p platform) vet() { - if p.os == "linux" && p.arch == "riscv64" { - // TODO(tklauser): enable as soon as the riscv64 port has fully landed - fmt.Println("skipping linux/riscv64") + if p.os == "linux" && (p.arch == "riscv64" || p.arch == "sparc64") { + // TODO(tklauser): enable as soon as these ports have fully landed + fmt.Printf("skipping %s/%s\n", p.os, p.arch) + return + } + + if p.os == "windows" && p.arch == "arm" { + // TODO(jordanrh1): enable as soon as the windows/arm port has fully landed + fmt.Println("skipping windows/arm") + return + } + + if p.os == "aix" && p.arch == "ppc64" { + // TODO(aix): enable as soon as the aix/ppc64 port has fully landed + fmt.Println("skipping aix/ppc64") return } @@ -205,13 +221,36 @@ func (p platform) vet() { w := make(whitelist) w.load(p.os, p.arch) - // 'go tool vet .' is considerably faster than 'go vet ./...' + tmpdir, err := ioutil.TempDir("", "cmd-vet-all") + if err != nil { + log.Fatal(err) + } + defer os.RemoveAll(tmpdir) + + // Build the go/packages-based vet command from the x/tools + // repo. It is considerably faster than "go vet", which rebuilds + // the standard library. + vetTool := filepath.Join(tmpdir, "vet") + cmd := exec.Command(cmdGoPath, "build", "-o", vetTool, "golang.org/x/tools/go/analysis/cmd/vet") + cmd.Dir = filepath.Join(runtime.GOROOT(), "src") + cmd.Stderr = os.Stderr + cmd.Stdout = os.Stderr + if err := cmd.Run(); err != nil { + log.Fatal(err) + } + // TODO: The unsafeptr checks are disabled for now, // because there are so many false positives, // and no clear way to improve vet to eliminate large chunks of them. // And having them in the whitelists will just cause annoyance // and churn when working on the runtime. - cmd := exec.Command(cmdGoPath, "tool", "vet", "-unsafeptr=false", "-source", ".") + cmd = exec.Command(vetTool, + "-unsafeptr=0", + "-nilness=0", // expensive, uses SSA + "std", + "cmd/...", + "cmd/compile/internal/gc/testdata", + ) cmd.Dir = filepath.Join(runtime.GOROOT(), "src") cmd.Env = append(os.Environ(), "GOOS="+p.os, "GOARCH="+p.arch, "CGO_ENABLED=0") stderr, err := cmd.StderrPipe() @@ -231,6 +270,9 @@ NextLine: if strings.HasPrefix(line, "vet: ") { // Typecheck failure: Malformed syntax or multiple packages or the like. // This will yield nicer error messages elsewhere, so ignore them here. + + // This includes warnings from asmdecl of the form: + // "vet: foo.s:16: [amd64] cannot check cross-package assembly function" continue } @@ -242,22 +284,48 @@ NextLine: io.Copy(os.Stderr, stderr) break } + if strings.HasPrefix(line, "# ") { + // 'go vet' prefixes the output of each vet invocation by a comment: + // # [package] + continue + } - fields := strings.SplitN(line, ":", 3) + // Parse line. + // Assume the part before the first ": " + // is the "file:line:col: " information. + // TODO(adonovan): parse vet -json output. var file, lineno, msg string - switch len(fields) { - case 2: - // vet message with no line number - file, msg = fields[0], fields[1] - case 3: - file, lineno, msg = fields[0], fields[1], fields[2] - default: + if i := strings.Index(line, ": "); i >= 0 { + msg = line[i+len(": "):] + + words := strings.Split(line[:i], ":") + switch len(words) { + case 3: + _ = words[2] // ignore column + fallthrough + case 2: + lineno = words[1] + fallthrough + case 1: + file = words[0] + + // Make the file name relative to GOROOT/src. + if rel, err := filepath.Rel(cmd.Dir, file); err == nil { + file = rel + } + default: + // error: too many columns + } + } + if file == "" { if !parseFailed { parseFailed = true fmt.Fprintf(os.Stderr, "failed to parse %s vet output:\n", p) } fmt.Fprintln(os.Stderr, line) + continue } + msg = strings.TrimSpace(msg) for _, ignore := range ignorePathPrefixes { diff --git a/libgo/go/cmd/vet/assign.go b/libgo/go/cmd/vet/assign.go deleted file mode 100644 index 223e80d4007..00000000000 --- a/libgo/go/cmd/vet/assign.go +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -/* -This file contains the code to check for useless assignments. -*/ - -package main - -import ( - "go/ast" - "go/token" - "reflect" -) - -func init() { - register("assign", - "check for useless assignments", - checkAssignStmt, - assignStmt) -} - -// TODO: should also check for assignments to struct fields inside methods -// that are on T instead of *T. - -// checkAssignStmt checks for assignments of the form " = ". -// These are almost always useless, and even when they aren't they are usually a mistake. -func checkAssignStmt(f *File, node ast.Node) { - stmt := node.(*ast.AssignStmt) - if stmt.Tok != token.ASSIGN { - return // ignore := - } - if len(stmt.Lhs) != len(stmt.Rhs) { - // If LHS and RHS have different cardinality, they can't be the same. - return - } - for i, lhs := range stmt.Lhs { - rhs := stmt.Rhs[i] - if hasSideEffects(f, lhs) || hasSideEffects(f, rhs) { - continue // expressions may not be equal - } - if reflect.TypeOf(lhs) != reflect.TypeOf(rhs) { - continue // short-circuit the heavy-weight gofmt check - } - le := f.gofmt(lhs) - re := f.gofmt(rhs) - if le == re { - f.Badf(stmt.Pos(), "self-assignment of %s to %s", re, le) - } - } -} diff --git a/libgo/go/cmd/vet/atomic.go b/libgo/go/cmd/vet/atomic.go deleted file mode 100644 index b425669e1ae..00000000000 --- a/libgo/go/cmd/vet/atomic.go +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -import ( - "go/ast" - "go/token" - "go/types" -) - -func init() { - register("atomic", - "check for common mistaken usages of the sync/atomic package", - checkAtomicAssignment, - assignStmt) -} - -// checkAtomicAssignment walks the assignment statement checking for common -// mistaken usage of atomic package, such as: x = atomic.AddUint64(&x, 1) -func checkAtomicAssignment(f *File, node ast.Node) { - n := node.(*ast.AssignStmt) - if len(n.Lhs) != len(n.Rhs) { - return - } - if len(n.Lhs) == 1 && n.Tok == token.DEFINE { - return - } - - for i, right := range n.Rhs { - call, ok := right.(*ast.CallExpr) - if !ok { - continue - } - sel, ok := call.Fun.(*ast.SelectorExpr) - if !ok { - continue - } - pkgIdent, _ := sel.X.(*ast.Ident) - pkgName, ok := f.pkg.uses[pkgIdent].(*types.PkgName) - if !ok || pkgName.Imported().Path() != "sync/atomic" { - continue - } - - switch sel.Sel.Name { - case "AddInt32", "AddInt64", "AddUint32", "AddUint64", "AddUintptr": - f.checkAtomicAddAssignment(n.Lhs[i], call) - } - } -} - -// checkAtomicAddAssignment walks the atomic.Add* method calls checking for assigning the return value -// to the same variable being used in the operation -func (f *File) checkAtomicAddAssignment(left ast.Expr, call *ast.CallExpr) { - if len(call.Args) != 2 { - return - } - arg := call.Args[0] - broken := false - - if uarg, ok := arg.(*ast.UnaryExpr); ok && uarg.Op == token.AND { - broken = f.gofmt(left) == f.gofmt(uarg.X) - } else if star, ok := left.(*ast.StarExpr); ok { - broken = f.gofmt(star.X) == f.gofmt(arg) - } - - if broken { - f.Bad(left.Pos(), "direct assignment to atomic value") - } -} diff --git a/libgo/go/cmd/vet/buildtag.go b/libgo/go/cmd/vet/buildtag.go deleted file mode 100644 index ba3a361b911..00000000000 --- a/libgo/go/cmd/vet/buildtag.go +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -import ( - "bytes" - "fmt" - "os" - "strings" - "unicode" -) - -var ( - nl = []byte("\n") - slashSlash = []byte("//") - plusBuild = []byte("+build") -) - -func badfLine(f *File, line int, format string, args ...interface{}) { - msg := fmt.Sprintf(format, args...) - fmt.Fprintf(os.Stderr, "%s:%d: %s\n", f.name, line, msg) - setExit(1) -} - -// checkBuildTag checks that build tags are in the correct location and well-formed. -func checkBuildTag(f *File) { - if !vet("buildtags") { - return - } - - // we must look at the raw lines, as build tags may appear in non-Go - // files such as assembly files. - lines := bytes.SplitAfter(f.content, nl) - - // lineWithComment reports whether a line corresponds to a comment in - // the source file. If the source file wasn't Go, the function always - // returns true. - lineWithComment := func(line int) bool { - if f.file == nil { - // Current source file is not Go, so be conservative. - return true - } - for _, group := range f.file.Comments { - startLine := f.fset.Position(group.Pos()).Line - endLine := f.fset.Position(group.End()).Line - if startLine <= line && line <= endLine { - return true - } - } - return false - } - - // Determine cutpoint where +build comments are no longer valid. - // They are valid in leading // comments in the file followed by - // a blank line. - var cutoff int - for i, line := range lines { - line = bytes.TrimSpace(line) - if len(line) == 0 { - cutoff = i - continue - } - if bytes.HasPrefix(line, slashSlash) { - continue - } - break - } - - for i, line := range lines { - line = bytes.TrimSpace(line) - if !bytes.HasPrefix(line, slashSlash) { - continue - } - if !bytes.Contains(line, plusBuild) { - // Check that the comment contains "+build" early, to - // avoid unnecessary lineWithComment calls that may - // incur linear searches. - continue - } - if !lineWithComment(i + 1) { - // This is a line in a Go source file that looks like a - // comment, but actually isn't - such as part of a raw - // string. - continue - } - - text := bytes.TrimSpace(line[2:]) - if bytes.HasPrefix(text, plusBuild) { - fields := bytes.Fields(text) - if !bytes.Equal(fields[0], plusBuild) { - // Comment is something like +buildasdf not +build. - badfLine(f, i+1, "possible malformed +build comment") - continue - } - if i >= cutoff { - badfLine(f, i+1, "+build comment must appear before package clause and be followed by a blank line") - continue - } - // Check arguments. - Args: - for _, arg := range fields[1:] { - for _, elem := range strings.Split(string(arg), ",") { - if strings.HasPrefix(elem, "!!") { - badfLine(f, i+1, "invalid double negative in build constraint: %s", arg) - break Args - } - elem = strings.TrimPrefix(elem, "!") - for _, c := range elem { - if !unicode.IsLetter(c) && !unicode.IsDigit(c) && c != '_' && c != '.' { - badfLine(f, i+1, "invalid non-alphanumeric build constraint: %s", arg) - break Args - } - } - } - } - continue - } - // Comment with +build but not at beginning. - if i < cutoff { - badfLine(f, i+1, "possible malformed +build comment") - continue - } - } -} diff --git a/libgo/go/cmd/vet/cgo.go b/libgo/go/cmd/vet/cgo.go deleted file mode 100644 index 76364ff6ed8..00000000000 --- a/libgo/go/cmd/vet/cgo.go +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Check for invalid cgo pointer passing. -// This looks for code that uses cgo to call C code passing values -// whose types are almost always invalid according to the cgo pointer -// sharing rules. -// Specifically, it warns about attempts to pass a Go chan, map, func, -// or slice to C, either directly, or via a pointer, array, or struct. - -package main - -import ( - "go/ast" - "go/token" - "go/types" -) - -func init() { - register("cgocall", - "check for types that may not be passed to cgo calls", - checkCgoCall, - callExpr) -} - -func checkCgoCall(f *File, node ast.Node) { - x := node.(*ast.CallExpr) - - // We are only looking for calls to functions imported from - // the "C" package. - sel, ok := x.Fun.(*ast.SelectorExpr) - if !ok { - return - } - id, ok := sel.X.(*ast.Ident) - if !ok { - return - } - - pkgname, ok := f.pkg.uses[id].(*types.PkgName) - if !ok || pkgname.Imported().Path() != "C" { - return - } - - // A call to C.CBytes passes a pointer but is always safe. - if sel.Sel.Name == "CBytes" { - return - } - - for _, arg := range x.Args { - if !typeOKForCgoCall(cgoBaseType(f, arg), make(map[types.Type]bool)) { - f.Badf(arg.Pos(), "possibly passing Go type with embedded pointer to C") - } - - // Check for passing the address of a bad type. - if conv, ok := arg.(*ast.CallExpr); ok && len(conv.Args) == 1 && f.hasBasicType(conv.Fun, types.UnsafePointer) { - arg = conv.Args[0] - } - if u, ok := arg.(*ast.UnaryExpr); ok && u.Op == token.AND { - if !typeOKForCgoCall(cgoBaseType(f, u.X), make(map[types.Type]bool)) { - f.Badf(arg.Pos(), "possibly passing Go type with embedded pointer to C") - } - } - } -} - -// cgoBaseType tries to look through type conversions involving -// unsafe.Pointer to find the real type. It converts: -// unsafe.Pointer(x) => x -// *(*unsafe.Pointer)(unsafe.Pointer(&x)) => x -func cgoBaseType(f *File, arg ast.Expr) types.Type { - switch arg := arg.(type) { - case *ast.CallExpr: - if len(arg.Args) == 1 && f.hasBasicType(arg.Fun, types.UnsafePointer) { - return cgoBaseType(f, arg.Args[0]) - } - case *ast.StarExpr: - call, ok := arg.X.(*ast.CallExpr) - if !ok || len(call.Args) != 1 { - break - } - // Here arg is *f(v). - t := f.pkg.types[call.Fun].Type - if t == nil { - break - } - ptr, ok := t.Underlying().(*types.Pointer) - if !ok { - break - } - // Here arg is *(*p)(v) - elem, ok := ptr.Elem().Underlying().(*types.Basic) - if !ok || elem.Kind() != types.UnsafePointer { - break - } - // Here arg is *(*unsafe.Pointer)(v) - call, ok = call.Args[0].(*ast.CallExpr) - if !ok || len(call.Args) != 1 { - break - } - // Here arg is *(*unsafe.Pointer)(f(v)) - if !f.hasBasicType(call.Fun, types.UnsafePointer) { - break - } - // Here arg is *(*unsafe.Pointer)(unsafe.Pointer(v)) - u, ok := call.Args[0].(*ast.UnaryExpr) - if !ok || u.Op != token.AND { - break - } - // Here arg is *(*unsafe.Pointer)(unsafe.Pointer(&v)) - return cgoBaseType(f, u.X) - } - - return f.pkg.types[arg].Type -} - -// typeOKForCgoCall reports whether the type of arg is OK to pass to a -// C function using cgo. This is not true for Go types with embedded -// pointers. m is used to avoid infinite recursion on recursive types. -func typeOKForCgoCall(t types.Type, m map[types.Type]bool) bool { - if t == nil || m[t] { - return true - } - m[t] = true - switch t := t.Underlying().(type) { - case *types.Chan, *types.Map, *types.Signature, *types.Slice: - return false - case *types.Pointer: - return typeOKForCgoCall(t.Elem(), m) - case *types.Array: - return typeOKForCgoCall(t.Elem(), m) - case *types.Struct: - for i := 0; i < t.NumFields(); i++ { - if !typeOKForCgoCall(t.Field(i).Type(), m) { - return false - } - } - } - return true -} diff --git a/libgo/go/cmd/vet/composite.go b/libgo/go/cmd/vet/composite.go deleted file mode 100644 index 861e040aac4..00000000000 --- a/libgo/go/cmd/vet/composite.go +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This file contains the test for unkeyed struct literals. - -package main - -import ( - "cmd/vet/internal/whitelist" - "flag" - "go/ast" - "go/types" - "strings" -) - -var compositeWhiteList = flag.Bool("compositewhitelist", true, "use composite white list; for testing only") - -func init() { - register("composites", - "check that composite literals of types from imported packages use field-keyed elements", - checkUnkeyedLiteral, - compositeLit) -} - -// checkUnkeyedLiteral checks if a composite literal is a struct literal with -// unkeyed fields. -func checkUnkeyedLiteral(f *File, node ast.Node) { - cl := node.(*ast.CompositeLit) - - typ := f.pkg.types[cl].Type - if typ == nil { - // cannot determine composite literals' type, skip it - return - } - typeName := typ.String() - if *compositeWhiteList && whitelist.UnkeyedLiteral[typeName] { - // skip whitelisted types - return - } - under := typ.Underlying() - for { - ptr, ok := under.(*types.Pointer) - if !ok { - break - } - under = ptr.Elem().Underlying() - } - if _, ok := under.(*types.Struct); !ok { - // skip non-struct composite literals - return - } - if isLocalType(f, typ) { - // allow unkeyed locally defined composite literal - return - } - - // check if the CompositeLit contains an unkeyed field - allKeyValue := true - for _, e := range cl.Elts { - if _, ok := e.(*ast.KeyValueExpr); !ok { - allKeyValue = false - break - } - } - if allKeyValue { - // all the composite literal fields are keyed - return - } - - f.Badf(cl.Pos(), "%s composite literal uses unkeyed fields", typeName) -} - -func isLocalType(f *File, typ types.Type) bool { - switch x := typ.(type) { - case *types.Struct: - // struct literals are local types - return true - case *types.Pointer: - return isLocalType(f, x.Elem()) - case *types.Named: - // names in package foo are local to foo_test too - return strings.TrimSuffix(x.Obj().Pkg().Path(), "_test") == strings.TrimSuffix(f.pkg.path, "_test") - } - return false -} diff --git a/libgo/go/cmd/vet/doc.go b/libgo/go/cmd/vet/doc.go index d9af0a88759..279d081be39 100644 --- a/libgo/go/cmd/vet/doc.go +++ b/libgo/go/cmd/vet/doc.go @@ -1,4 +1,4 @@ -// Copyright 2010 The Go Authors. All rights reserved. +// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. @@ -9,211 +9,63 @@ calls whose arguments do not align with the format string. Vet uses heuristics that do not guarantee all reports are genuine problems, but it can find errors not caught by the compilers. -Vet is normally invoked using the go command by running "go vet": +Vet is normally invoked through the go command. +This command vets the package in the current directory: go vet -vets the package in the current directory. - go vet package/path/name -vets the package whose path is provided. +whereas this one vets the packages whose path is provided: + + go vet my/project/... Use "go help packages" to see other ways of specifying which packages to vet. -Vet's exit code is 2 for erroneous invocation of the tool, 1 if a +Vet's exit code is non-zero for erroneous invocation of the tool or if a problem was reported, and 0 otherwise. Note that the tool does not -check every possible problem and depends on unreliable heuristics +check every possible problem and depends on unreliable heuristics, so it should be used as guidance only, not as a firm indicator of program correctness. -By default the -all flag is set so all checks are performed. -If any flags are explicitly set to true, only those tests are run. Conversely, if -any flag is explicitly set to false, only those tests are disabled. Thus -printf=true -runs the printf check, -printf=false runs all checks except the printf check. - -By default vet uses the object files generated by 'go install some/pkg' to typecheck the code. -If the -source flag is provided, vet uses only source code. - -Available checks: - -Assembly declarations - -Flag: -asmdecl - -Mismatches between assembly files and Go function declarations. - -Useless assignments - -Flag: -assign - -Check for useless assignments. - -Atomic mistakes - -Flag: -atomic - -Common mistaken usages of the sync/atomic package. - -Boolean conditions - -Flag: -bool - -Mistakes involving boolean operators. - -Build tags - -Flag: -buildtags - -Badly formed or misplaced +build tags. - -Invalid uses of cgo - -Flag: -cgocall - -Detect some violations of the cgo pointer passing rules. - -Unkeyed composite literals - -Flag: -composites - -Composite struct literals that do not use the field-keyed syntax. - -Copying locks - -Flag: -copylocks - -Locks that are erroneously passed by value. - -HTTP responses used incorrectly - -Flag: -httpresponse - -Mistakes deferring a function call on an HTTP response before -checking whether the error returned with the response was nil. - -Failure to call the cancelation function returned by WithCancel - -Flag: -lostcancel - -The cancelation function returned by context.WithCancel, WithTimeout, -and WithDeadline must be called or the new context will remain live -until its parent context is cancelled. -(The background context is never cancelled.) - -Methods - -Flag: -methods - -Non-standard signatures for methods with familiar names, including: - Format GobEncode GobDecode MarshalJSON MarshalXML - Peek ReadByte ReadFrom ReadRune Scan Seek - UnmarshalJSON UnreadByte UnreadRune WriteByte - WriteTo - -Nil function comparison - -Flag: -nilfunc - -Comparisons between functions and nil. - -Printf family - -Flag: -printf - -Suspicious calls to fmt.Print, fmt.Printf, and related functions. -The check applies to known functions (for example, those in package fmt) -as well as any detected wrappers of known functions. - -The -printfuncs flag specifies a comma-separated list of names of -additional known formatting functions. Each name can be of the form -pkg.Name or pkg.Type.Name, where pkg is a complete import path, -or else can be a case-insensitive unqualified identifier like "errorf". -If a listed name ends in f, the function is assumed to be Printf-like, -taking a format string before the argument list. Otherwise it is -assumed to be Print-like, taking a list of arguments with no format string. - -Range loop variables - -Flag: -rangeloops - -Incorrect uses of range loop variables in closures. - -Shadowed variables - -Flag: -shadow=false (experimental; must be set explicitly) - -Variables that may have been unintentionally shadowed. - -Shifts - -Flag: -shift - -Shifts equal to or longer than the variable's length. - -Struct tags - -Flag: -structtags - -Struct tags that do not follow the format understood by reflect.StructTag.Get. -Well-known encoding struct tags (json, xml) used with unexported fields. - -Tests and documentation examples - -Flag: -tests - -Mistakes involving tests including functions with incorrect names or signatures -and example tests that document identifiers not in the package. - -Unreachable code - -Flag: -unreachable - -Unreachable code. - -Misuse of unsafe Pointers - -Flag: -unsafeptr - -Likely incorrect uses of unsafe.Pointer to convert integers to pointers. -A conversion from uintptr to unsafe.Pointer is invalid if it implies that -there is a uintptr-typed word in memory that holds a pointer value, -because that word will be invisible to stack copying and to the garbage -collector. - -Unused result of certain function calls - -Flag: -unusedresult - -Calls to well-known functions and methods that return a value that is -discarded. By default, this includes functions like fmt.Errorf and -fmt.Sprintf and methods like String and Error. The flags -unusedfuncs -and -unusedstringmethods control the set. - -Other flags - -These flags configure the behavior of vet: - - -all (default true) - Enable all non-experimental checks. - -v - Verbose mode - -printfuncs - A comma-separated list of print-like function names - to supplement the standard list. - For more information, see the discussion of the -printf flag. - -shadowstrict - Whether to be strict about shadowing; can be noisy. - -Using vet directly - -For testing and debugging vet can be run directly by invoking -"go tool vet" or just running the binary. Run this way, vet might not -have up to date information for imported packages. - - go tool vet source/directory/*.go -vets the files named, all of which must be in the same package. - - go tool vet source/directory -recursively descends the directory, vetting each package it finds. +To list the available checks, run "go tool vet help": + + asmdecl report mismatches between assembly files and Go declarations + assign check for useless assignments + atomic check for common mistakes using the sync/atomic package + bools check for common mistakes involving boolean operators + buildtag check that +build tags are well-formed and correctly located + cgocall detect some violations of the cgo pointer passing rules + composites check for unkeyed composite literals + copylocks check for locks erroneously passed by value + httpresponse check for mistakes using HTTP responses + loopclosure check references to loop variables from within nested functions + lostcancel check cancel func returned by context.WithCancel is called + nilfunc check for useless comparisons between functions and nil + printf check consistency of Printf format strings and arguments + shift check for shifts that equal or exceed the width of the integer + stdmethods check signature of methods of well-known interfaces + structtag check that struct field tags conform to reflect.StructTag.Get + tests check for common mistaken usages of tests and examples + unmarshal report passing non-pointer or non-interface values to unmarshal + unreachable check for unreachable code + unsafeptr check for invalid conversions of uintptr to unsafe.Pointer + unusedresult check for unused results of calls to some functions + +For details and flags of a particular check, such as printf, run "go tool vet help printf". + +By default, all checks are performed. +If any flags are explicitly set to true, only those tests are run. +Conversely, if any flag is explicitly set to false, only those tests are disabled. +Thus -printf=true runs the printf check, +and -printf=false runs all checks except the printf check. + +For information on writing a new check, see golang.org/x/tools/go/analysis. + +Core flags: + + -c=N + display offending line plus N lines of surrounding context + -json + emit analysis diagnostics (and errors) in JSON format */ package main diff --git a/libgo/go/cmd/vet/httpresponse.go b/libgo/go/cmd/vet/httpresponse.go deleted file mode 100644 index 791d11d5bde..00000000000 --- a/libgo/go/cmd/vet/httpresponse.go +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This file contains the check for http.Response values being used before -// checking for errors. - -package main - -import ( - "go/ast" - "go/types" -) - -func init() { - register("httpresponse", - "check errors are checked before using an http Response", - checkHTTPResponse, callExpr) -} - -func checkHTTPResponse(f *File, node ast.Node) { - call := node.(*ast.CallExpr) - if !isHTTPFuncOrMethodOnClient(f, call) { - return // the function call is not related to this check. - } - - finder := &blockStmtFinder{node: call} - ast.Walk(finder, f.file) - stmts := finder.stmts() - if len(stmts) < 2 { - return // the call to the http function is the last statement of the block. - } - - asg, ok := stmts[0].(*ast.AssignStmt) - if !ok { - return // the first statement is not assignment. - } - resp := rootIdent(asg.Lhs[0]) - if resp == nil { - return // could not find the http.Response in the assignment. - } - - def, ok := stmts[1].(*ast.DeferStmt) - if !ok { - return // the following statement is not a defer. - } - root := rootIdent(def.Call.Fun) - if root == nil { - return // could not find the receiver of the defer call. - } - - if resp.Obj == root.Obj { - f.Badf(root.Pos(), "using %s before checking for errors", resp.Name) - } -} - -// isHTTPFuncOrMethodOnClient checks whether the given call expression is on -// either a function of the net/http package or a method of http.Client that -// returns (*http.Response, error). -func isHTTPFuncOrMethodOnClient(f *File, expr *ast.CallExpr) bool { - fun, _ := expr.Fun.(*ast.SelectorExpr) - sig, _ := f.pkg.types[fun].Type.(*types.Signature) - if sig == nil { - return false // the call is not on of the form x.f() - } - - res := sig.Results() - if res.Len() != 2 { - return false // the function called does not return two values. - } - if ptr, ok := res.At(0).Type().(*types.Pointer); !ok || !isNamedType(ptr.Elem(), "net/http", "Response") { - return false // the first return type is not *http.Response. - } - if !types.Identical(res.At(1).Type().Underlying(), errorType) { - return false // the second return type is not error - } - - typ := f.pkg.types[fun.X].Type - if typ == nil { - id, ok := fun.X.(*ast.Ident) - return ok && id.Name == "http" // function in net/http package. - } - - if isNamedType(typ, "net/http", "Client") { - return true // method on http.Client. - } - ptr, ok := typ.(*types.Pointer) - return ok && isNamedType(ptr.Elem(), "net/http", "Client") // method on *http.Client. -} - -// blockStmtFinder is an ast.Visitor that given any ast node can find the -// statement containing it and its succeeding statements in the same block. -type blockStmtFinder struct { - node ast.Node // target of search - stmt ast.Stmt // innermost statement enclosing argument to Visit - block *ast.BlockStmt // innermost block enclosing argument to Visit. -} - -// Visit finds f.node performing a search down the ast tree. -// It keeps the last block statement and statement seen for later use. -func (f *blockStmtFinder) Visit(node ast.Node) ast.Visitor { - if node == nil || f.node.Pos() < node.Pos() || f.node.End() > node.End() { - return nil // not here - } - switch n := node.(type) { - case *ast.BlockStmt: - f.block = n - case ast.Stmt: - f.stmt = n - } - if f.node.Pos() == node.Pos() && f.node.End() == node.End() { - return nil // found - } - return f // keep looking -} - -// stmts returns the statements of f.block starting from the one including f.node. -func (f *blockStmtFinder) stmts() []ast.Stmt { - for i, v := range f.block.List { - if f.stmt == v { - return f.block.List[i:] - } - } - return nil -} - -// rootIdent finds the root identifier x in a chain of selections x.y.z, or nil if not found. -func rootIdent(n ast.Node) *ast.Ident { - switch n := n.(type) { - case *ast.SelectorExpr: - return rootIdent(n.X) - case *ast.Ident: - return n - default: - return nil - } -} diff --git a/libgo/go/cmd/vet/internal/cfg/cfg_test.go b/libgo/go/cmd/vet/internal/cfg/cfg_test.go deleted file mode 100644 index 2400fed6f4b..00000000000 --- a/libgo/go/cmd/vet/internal/cfg/cfg_test.go +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package cfg - -import ( - "bytes" - "fmt" - "go/ast" - "go/parser" - "go/token" - "testing" -) - -const src = `package main - -import "log" - -func f1() { - live() - return - dead() -} - -func f2() { - for { - live() - } - dead() -} - -func f3() { - if true { // even known values are ignored - return - } - for true { // even known values are ignored - live() - } - for { - live() - } - dead() -} - -func f4(x int) { - switch x { - case 1: - live() - fallthrough - case 2: - live() - log.Fatal() - default: - panic("oops") - } - dead() -} - -func f4(ch chan int) { - select { - case <-ch: - live() - return - default: - live() - panic("oops") - } - dead() -} - -func f5(unknown bool) { - for { - if unknown { - break - } - continue - dead() - } - live() -} - -func f6(unknown bool) { -outer: - for { - for { - break outer - dead() - } - dead() - } - live() -} - -func f7() { - for { - break nosuchlabel - dead() - } - dead() -} - -func f8() { - select{} - dead() -} - -func f9(ch chan int) { - select { - case <-ch: - return - } - dead() -} - -func f10(ch chan int) { - select { - case <-ch: - return - dead() - default: - } - live() -} - -func f11() { - goto; // mustn't crash - dead() -} - -` - -func TestDeadCode(t *testing.T) { - // We'll use dead code detection to verify the CFG. - - fset := token.NewFileSet() - f, err := parser.ParseFile(fset, "dummy.go", src, parser.Mode(0)) - if err != nil { - t.Fatal(err) - } - for _, decl := range f.Decls { - if decl, ok := decl.(*ast.FuncDecl); ok { - g := New(decl.Body, mayReturn) - - // Mark blocks reachable from entry. - live := make(map[*Block]bool) - var visit func(*Block) - visit = func(b *Block) { - if !live[b] { - live[b] = true - for _, succ := range b.Succs { - visit(succ) - } - } - } - visit(g.Blocks[0]) - - // Print statements in unreachable blocks - // (in order determined by builder). - var buf bytes.Buffer - for _, b := range g.Blocks { - if !live[b] { - for _, n := range b.Nodes { - fmt.Fprintf(&buf, "\t%s\n", formatNode(fset, n)) - } - } - } - - // Check that the result contains "dead" at least once but not "live". - if !bytes.Contains(buf.Bytes(), []byte("dead")) || - bytes.Contains(buf.Bytes(), []byte("live")) { - t.Errorf("unexpected dead statements in function %s:\n%s", - decl.Name.Name, - &buf) - t.Logf("control flow graph:\n%s", g.Format(fset)) - } - } - } -} - -// A trivial mayReturn predicate that looks only at syntax, not types. -func mayReturn(call *ast.CallExpr) bool { - switch fun := call.Fun.(type) { - case *ast.Ident: - return fun.Name != "panic" - case *ast.SelectorExpr: - return fun.Sel.Name != "Fatal" - } - return true -} diff --git a/libgo/go/cmd/vet/lostcancel.go b/libgo/go/cmd/vet/lostcancel.go deleted file mode 100644 index ee0342035fe..00000000000 --- a/libgo/go/cmd/vet/lostcancel.go +++ /dev/null @@ -1,322 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -import ( - "cmd/vet/internal/cfg" - "fmt" - "go/ast" - "go/types" - "strconv" -) - -func init() { - register("lostcancel", - "check for failure to call cancelation function returned by context.WithCancel", - checkLostCancel, - funcDecl, funcLit) -} - -const debugLostCancel = false - -var contextPackage = "context" - -// checkLostCancel reports a failure to the call the cancel function -// returned by context.WithCancel, either because the variable was -// assigned to the blank identifier, or because there exists a -// control-flow path from the call to a return statement and that path -// does not "use" the cancel function. Any reference to the variable -// counts as a use, even within a nested function literal. -// -// checkLostCancel analyzes a single named or literal function. -func checkLostCancel(f *File, node ast.Node) { - // Fast path: bypass check if file doesn't use context.WithCancel. - if !hasImport(f.file, contextPackage) { - return - } - - // Maps each cancel variable to its defining ValueSpec/AssignStmt. - cancelvars := make(map[*types.Var]ast.Node) - - // Find the set of cancel vars to analyze. - stack := make([]ast.Node, 0, 32) - ast.Inspect(node, func(n ast.Node) bool { - switch n.(type) { - case *ast.FuncLit: - if len(stack) > 0 { - return false // don't stray into nested functions - } - case nil: - stack = stack[:len(stack)-1] // pop - return true - } - stack = append(stack, n) // push - - // Look for [{AssignStmt,ValueSpec} CallExpr SelectorExpr]: - // - // ctx, cancel := context.WithCancel(...) - // ctx, cancel = context.WithCancel(...) - // var ctx, cancel = context.WithCancel(...) - // - if isContextWithCancel(f, n) && isCall(stack[len(stack)-2]) { - var id *ast.Ident // id of cancel var - stmt := stack[len(stack)-3] - switch stmt := stmt.(type) { - case *ast.ValueSpec: - if len(stmt.Names) > 1 { - id = stmt.Names[1] - } - case *ast.AssignStmt: - if len(stmt.Lhs) > 1 { - id, _ = stmt.Lhs[1].(*ast.Ident) - } - } - if id != nil { - if id.Name == "_" { - f.Badf(id.Pos(), "the cancel function returned by context.%s should be called, not discarded, to avoid a context leak", - n.(*ast.SelectorExpr).Sel.Name) - } else if v, ok := f.pkg.uses[id].(*types.Var); ok { - cancelvars[v] = stmt - } else if v, ok := f.pkg.defs[id].(*types.Var); ok { - cancelvars[v] = stmt - } - } - } - - return true - }) - - if len(cancelvars) == 0 { - return // no need to build CFG - } - - // Tell the CFG builder which functions never return. - info := &types.Info{Uses: f.pkg.uses, Selections: f.pkg.selectors} - mayReturn := func(call *ast.CallExpr) bool { - name := callName(info, call) - return !noReturnFuncs[name] - } - - // Build the CFG. - var g *cfg.CFG - var sig *types.Signature - switch node := node.(type) { - case *ast.FuncDecl: - obj := f.pkg.defs[node.Name] - if obj == nil { - return // type error (e.g. duplicate function declaration) - } - sig, _ = obj.Type().(*types.Signature) - g = cfg.New(node.Body, mayReturn) - case *ast.FuncLit: - sig, _ = f.pkg.types[node.Type].Type.(*types.Signature) - g = cfg.New(node.Body, mayReturn) - } - - // Print CFG. - if debugLostCancel { - fmt.Println(g.Format(f.fset)) - } - - // Examine the CFG for each variable in turn. - // (It would be more efficient to analyze all cancelvars in a - // single pass over the AST, but seldom is there more than one.) - for v, stmt := range cancelvars { - if ret := lostCancelPath(f, g, v, stmt, sig); ret != nil { - lineno := f.fset.Position(stmt.Pos()).Line - f.Badf(stmt.Pos(), "the %s function is not used on all paths (possible context leak)", v.Name()) - f.Badf(ret.Pos(), "this return statement may be reached without using the %s var defined on line %d", v.Name(), lineno) - } - } -} - -func isCall(n ast.Node) bool { _, ok := n.(*ast.CallExpr); return ok } - -func hasImport(f *ast.File, path string) bool { - for _, imp := range f.Imports { - v, _ := strconv.Unquote(imp.Path.Value) - if v == path { - return true - } - } - return false -} - -// isContextWithCancel reports whether n is one of the qualified identifiers -// context.With{Cancel,Timeout,Deadline}. -func isContextWithCancel(f *File, n ast.Node) bool { - if sel, ok := n.(*ast.SelectorExpr); ok { - switch sel.Sel.Name { - case "WithCancel", "WithTimeout", "WithDeadline": - if x, ok := sel.X.(*ast.Ident); ok { - if pkgname, ok := f.pkg.uses[x].(*types.PkgName); ok { - return pkgname.Imported().Path() == contextPackage - } - // Import failed, so we can't check package path. - // Just check the local package name (heuristic). - return x.Name == "context" - } - } - } - return false -} - -// lostCancelPath finds a path through the CFG, from stmt (which defines -// the 'cancel' variable v) to a return statement, that doesn't "use" v. -// If it finds one, it returns the return statement (which may be synthetic). -// sig is the function's type, if known. -func lostCancelPath(f *File, g *cfg.CFG, v *types.Var, stmt ast.Node, sig *types.Signature) *ast.ReturnStmt { - vIsNamedResult := sig != nil && tupleContains(sig.Results(), v) - - // uses reports whether stmts contain a "use" of variable v. - uses := func(f *File, v *types.Var, stmts []ast.Node) bool { - found := false - for _, stmt := range stmts { - ast.Inspect(stmt, func(n ast.Node) bool { - switch n := n.(type) { - case *ast.Ident: - if f.pkg.uses[n] == v { - found = true - } - case *ast.ReturnStmt: - // A naked return statement counts as a use - // of the named result variables. - if n.Results == nil && vIsNamedResult { - found = true - } - } - return !found - }) - } - return found - } - - // blockUses computes "uses" for each block, caching the result. - memo := make(map[*cfg.Block]bool) - blockUses := func(f *File, v *types.Var, b *cfg.Block) bool { - res, ok := memo[b] - if !ok { - res = uses(f, v, b.Nodes) - memo[b] = res - } - return res - } - - // Find the var's defining block in the CFG, - // plus the rest of the statements of that block. - var defblock *cfg.Block - var rest []ast.Node -outer: - for _, b := range g.Blocks { - for i, n := range b.Nodes { - if n == stmt { - defblock = b - rest = b.Nodes[i+1:] - break outer - } - } - } - if defblock == nil { - panic("internal error: can't find defining block for cancel var") - } - - // Is v "used" in the remainder of its defining block? - if uses(f, v, rest) { - return nil - } - - // Does the defining block return without using v? - if ret := defblock.Return(); ret != nil { - return ret - } - - // Search the CFG depth-first for a path, from defblock to a - // return block, in which v is never "used". - seen := make(map[*cfg.Block]bool) - var search func(blocks []*cfg.Block) *ast.ReturnStmt - search = func(blocks []*cfg.Block) *ast.ReturnStmt { - for _, b := range blocks { - if !seen[b] { - seen[b] = true - - // Prune the search if the block uses v. - if blockUses(f, v, b) { - continue - } - - // Found path to return statement? - if ret := b.Return(); ret != nil { - if debugLostCancel { - fmt.Printf("found path to return in block %s\n", b) - } - return ret // found - } - - // Recur - if ret := search(b.Succs); ret != nil { - if debugLostCancel { - fmt.Printf(" from block %s\n", b) - } - return ret - } - } - } - return nil - } - return search(defblock.Succs) -} - -func tupleContains(tuple *types.Tuple, v *types.Var) bool { - for i := 0; i < tuple.Len(); i++ { - if tuple.At(i) == v { - return true - } - } - return false -} - -var noReturnFuncs = map[string]bool{ - "(*testing.common).FailNow": true, - "(*testing.common).Fatal": true, - "(*testing.common).Fatalf": true, - "(*testing.common).Skip": true, - "(*testing.common).SkipNow": true, - "(*testing.common).Skipf": true, - "log.Fatal": true, - "log.Fatalf": true, - "log.Fatalln": true, - "os.Exit": true, - "panic": true, - "runtime.Goexit": true, -} - -// callName returns the canonical name of the builtin, method, or -// function called by call, if known. -func callName(info *types.Info, call *ast.CallExpr) string { - switch fun := call.Fun.(type) { - case *ast.Ident: - // builtin, e.g. "panic" - if obj, ok := info.Uses[fun].(*types.Builtin); ok { - return obj.Name() - } - case *ast.SelectorExpr: - if sel, ok := info.Selections[fun]; ok && sel.Kind() == types.MethodVal { - // method call, e.g. "(*testing.common).Fatal" - meth := sel.Obj() - return fmt.Sprintf("(%s).%s", - meth.Type().(*types.Signature).Recv().Type(), - meth.Name()) - } - if obj, ok := info.Uses[fun.Sel]; ok { - // qualified identifier, e.g. "os.Exit" - return fmt.Sprintf("%s.%s", - obj.Pkg().Path(), - obj.Name()) - } - } - - // function with no name, or defined in missing imported package - return "" -} diff --git a/libgo/go/cmd/vet/main.go b/libgo/go/cmd/vet/main.go index c50d4885a07..4ec174b3cd1 100644 --- a/libgo/go/cmd/vet/main.go +++ b/libgo/go/cmd/vet/main.go @@ -1,750 +1,53 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Vet is a simple checker for static errors in Go source code. -// See doc.go for more information. - package main import ( - "bytes" - "encoding/gob" - "encoding/json" - "flag" - "fmt" - "go/ast" - "go/build" - "go/importer" - "go/parser" - "go/printer" - "go/token" - "go/types" - "io" - "io/ioutil" - "os" - "path/filepath" - "sort" - "strconv" - "strings" - - "cmd/internal/objabi" -) - -// Important! If you add flags here, make sure to update cmd/go/internal/vet/vetflag.go. - -var ( - verbose = flag.Bool("v", false, "verbose") - source = flag.Bool("source", false, "import from source instead of compiled object files") - tags = flag.String("tags", "", "space-separated list of build tags to apply when parsing") - tagList = []string{} // exploded version of tags flag; set in main - - vcfg vetConfig - mustTypecheck bool -) - -var exitCode = 0 - -// "-all" flag enables all non-experimental checks -var all = triStateFlag("all", unset, "enable all non-experimental checks") - -// Flags to control which individual checks to perform. -var report = map[string]*triState{ - // Only unusual checks are written here. - // Most checks that operate during the AST walk are added by register. - "asmdecl": triStateFlag("asmdecl", unset, "check assembly against Go declarations"), - "buildtags": triStateFlag("buildtags", unset, "check that +build tags are valid"), -} - -// experimental records the flags enabling experimental features. These must be -// requested explicitly; they are not enabled by -all. -var experimental = map[string]bool{} - -// setTrueCount record how many flags are explicitly set to true. -var setTrueCount int - -// dirsRun and filesRun indicate whether the vet is applied to directory or -// file targets. The distinction affects which checks are run. -var dirsRun, filesRun bool - -// includesNonTest indicates whether the vet is applied to non-test targets. -// Certain checks are relevant only if they touch both test and non-test files. -var includesNonTest bool - -// A triState is a boolean that knows whether it has been set to either true or false. -// It is used to identify if a flag appears; the standard boolean flag cannot -// distinguish missing from unset. It also satisfies flag.Value. -type triState int - -const ( - unset triState = iota - setTrue - setFalse -) - -func triStateFlag(name string, value triState, usage string) *triState { - flag.Var(&value, name, usage) - return &value -} - -// triState implements flag.Value, flag.Getter, and flag.boolFlag. -// They work like boolean flags: we can say vet -printf as well as vet -printf=true -func (ts *triState) Get() interface{} { - return *ts == setTrue -} - -func (ts triState) isTrue() bool { - return ts == setTrue -} - -func (ts *triState) Set(value string) error { - b, err := strconv.ParseBool(value) - if err != nil { - return err - } - if b { - *ts = setTrue - setTrueCount++ - } else { - *ts = setFalse - } - return nil -} - -func (ts *triState) String() string { - switch *ts { - case unset: - return "true" // An unset flag will be set by -all, so defaults to true. - case setTrue: - return "true" - case setFalse: - return "false" - } - panic("not reached") -} - -func (ts triState) IsBoolFlag() bool { - return true -} - -// vet tells whether to report errors for the named check, a flag name. -func vet(name string) bool { - return report[name].isTrue() -} - -// setExit sets the value for os.Exit when it is called, later. It -// remembers the highest value. -func setExit(err int) { - if err > exitCode { - exitCode = err - } -} - -var ( - // Each of these vars has a corresponding case in (*File).Visit. - assignStmt *ast.AssignStmt - binaryExpr *ast.BinaryExpr - callExpr *ast.CallExpr - compositeLit *ast.CompositeLit - exprStmt *ast.ExprStmt - forStmt *ast.ForStmt - funcDecl *ast.FuncDecl - funcLit *ast.FuncLit - genDecl *ast.GenDecl - interfaceType *ast.InterfaceType - rangeStmt *ast.RangeStmt - returnStmt *ast.ReturnStmt - structType *ast.StructType - - // checkers is a two-level map. - // The outer level is keyed by a nil pointer, one of the AST vars above. - // The inner level is keyed by checker name. - checkers = make(map[ast.Node]map[string]func(*File, ast.Node)) - pkgCheckers = make(map[string]func(*Package)) - exporters = make(map[string]func() interface{}) + "golang.org/x/tools/go/analysis/unitchecker" + + "golang.org/x/tools/go/analysis/passes/asmdecl" + "golang.org/x/tools/go/analysis/passes/assign" + "golang.org/x/tools/go/analysis/passes/atomic" + "golang.org/x/tools/go/analysis/passes/bools" + "golang.org/x/tools/go/analysis/passes/buildtag" + "golang.org/x/tools/go/analysis/passes/cgocall" + "golang.org/x/tools/go/analysis/passes/composite" + "golang.org/x/tools/go/analysis/passes/copylock" + "golang.org/x/tools/go/analysis/passes/httpresponse" + "golang.org/x/tools/go/analysis/passes/loopclosure" + "golang.org/x/tools/go/analysis/passes/lostcancel" + "golang.org/x/tools/go/analysis/passes/nilfunc" + "golang.org/x/tools/go/analysis/passes/printf" + "golang.org/x/tools/go/analysis/passes/shift" + "golang.org/x/tools/go/analysis/passes/stdmethods" + "golang.org/x/tools/go/analysis/passes/structtag" + "golang.org/x/tools/go/analysis/passes/tests" + "golang.org/x/tools/go/analysis/passes/unmarshal" + "golang.org/x/tools/go/analysis/passes/unreachable" + "golang.org/x/tools/go/analysis/passes/unsafeptr" + "golang.org/x/tools/go/analysis/passes/unusedresult" ) -// The exporters data as written to the vetx output file. -type vetxExport struct { - Name string - Data interface{} -} - -// Vet can provide its own "export information" -// about package A to future invocations of vet -// on packages importing A. If B imports A, -// then running "go vet B" actually invokes vet twice: -// first, it runs vet on A, in "vetx-only" mode, which -// skips most checks and only computes export data -// describing A. Then it runs vet on B, making A's vetx -// data available for consultation. The vet of B -// computes vetx data for B in addition to its -// usual vet checks. - -// register registers the named check function, -// to be called with AST nodes of the given types. -// The registered functions are not called in vetx-only mode. -func register(name, usage string, fn func(*File, ast.Node), types ...ast.Node) { - report[name] = triStateFlag(name, unset, usage) - for _, typ := range types { - m := checkers[typ] - if m == nil { - m = make(map[string]func(*File, ast.Node)) - checkers[typ] = m - } - m[name] = fn - } -} - -// registerPkgCheck registers a package-level checking function, -// to be invoked with the whole package being vetted -// before any of the per-node handlers. -// The registered function fn is called even in vetx-only mode -// (see comment above), so fn must take care not to report -// errors when vcfg.VetxOnly is true. -func registerPkgCheck(name string, fn func(*Package)) { - pkgCheckers[name] = fn -} - -// registerExport registers a function to return vetx export data -// that should be saved and provided to future invocations of vet -// when checking packages importing this one. -// The value returned by fn should be nil or else valid to encode using gob. -// Typically a registerExport call is paired with a call to gob.Register. -func registerExport(name string, fn func() interface{}) { - exporters[name] = fn -} - -// Usage is a replacement usage function for the flags package. -func Usage() { - fmt.Fprintf(os.Stderr, "Usage of vet:\n") - fmt.Fprintf(os.Stderr, "\tvet [flags] directory...\n") - fmt.Fprintf(os.Stderr, "\tvet [flags] files... # Must be a single package\n") - fmt.Fprintf(os.Stderr, "By default, -all is set and all non-experimental checks are run.\n") - fmt.Fprintf(os.Stderr, "For more information run\n") - fmt.Fprintf(os.Stderr, "\tgo doc cmd/vet\n\n") - fmt.Fprintf(os.Stderr, "Flags:\n") - flag.PrintDefaults() - os.Exit(2) -} - -// File is a wrapper for the state of a file used in the parser. -// The parse tree walkers are all methods of this type. -type File struct { - pkg *Package - fset *token.FileSet - name string - content []byte - file *ast.File - b bytes.Buffer // for use by methods - - // Parsed package "foo" when checking package "foo_test" - basePkg *Package - - // The keys are the objects that are receivers of a "String() - // string" method. The value reports whether the method has a - // pointer receiver. - // This is used by the recursiveStringer method in print.go. - stringerPtrs map[*ast.Object]bool - - // Registered checkers to run. - checkers map[ast.Node][]func(*File, ast.Node) - - // Unreachable nodes; can be ignored in shift check. - dead map[ast.Node]bool -} - func main() { - objabi.AddVersionFlag() - flag.Usage = Usage - flag.Parse() - - // If any flag is set, we run only those checks requested. - // If all flag is set true or if no flags are set true, set all the non-experimental ones - // not explicitly set (in effect, set the "-all" flag). - if setTrueCount == 0 || *all == setTrue { - for name, setting := range report { - if *setting == unset && !experimental[name] { - *setting = setTrue - } - } - } - - // Accept space-separated tags because that matches - // the go command's other subcommands. - // Accept commas because go tool vet traditionally has. - tagList = strings.Fields(strings.Replace(*tags, ",", " ", -1)) - - initPrintFlags() - initUnusedFlags() - - if flag.NArg() == 0 { - Usage() - } - - // Special case for "go vet" passing an explicit configuration: - // single argument ending in vet.cfg. - // Once we have a more general mechanism for obtaining this - // information from build tools like the go command, - // vet should be changed to use it. This vet.cfg hack is an - // experiment to learn about what form that information should take. - if flag.NArg() == 1 && strings.HasSuffix(flag.Arg(0), "vet.cfg") { - doPackageCfg(flag.Arg(0)) - os.Exit(exitCode) - } - - for _, name := range flag.Args() { - // Is it a directory? - fi, err := os.Stat(name) - if err != nil { - warnf("error walking tree: %s", err) - continue - } - if fi.IsDir() { - dirsRun = true - } else { - filesRun = true - if !strings.HasSuffix(name, "_test.go") { - includesNonTest = true - } - } - } - if dirsRun && filesRun { - Usage() - } - if dirsRun { - for _, name := range flag.Args() { - walkDir(name) - } - os.Exit(exitCode) - } - if doPackage(flag.Args(), nil) == nil { - warnf("no files checked") - } - os.Exit(exitCode) -} - -// prefixDirectory places the directory name on the beginning of each name in the list. -func prefixDirectory(directory string, names []string) { - if directory != "." { - for i, name := range names { - names[i] = filepath.Join(directory, name) - } - } -} - -// vetConfig is the JSON config struct prepared by the Go command. -type vetConfig struct { - Compiler string - Dir string - ImportPath string - GoFiles []string - ImportMap map[string]string - PackageFile map[string]string - Standard map[string]bool - PackageVetx map[string]string // map from import path to vetx data file - VetxOnly bool // only compute vetx output; don't run ordinary checks - VetxOutput string // file where vetx output should be written - - SucceedOnTypecheckFailure bool - - imp types.Importer -} - -func (v *vetConfig) Import(path string) (*types.Package, error) { - if v.imp == nil { - v.imp = importer.For(v.Compiler, v.openPackageFile) - } - if path == "unsafe" { - return v.imp.Import("unsafe") - } - p := v.ImportMap[path] - if p == "" { - return nil, fmt.Errorf("unknown import path %q", path) - } - if v.PackageFile[p] == "" { - if v.Compiler == "gccgo" && v.Standard[path] { - // gccgo doesn't have sources for standard library packages, - // but the importer will do the right thing. - return v.imp.Import(path) - } - return nil, fmt.Errorf("unknown package file for import %q", path) - } - return v.imp.Import(p) -} - -func (v *vetConfig) openPackageFile(path string) (io.ReadCloser, error) { - file := v.PackageFile[path] - if file == "" { - if v.Compiler == "gccgo" && v.Standard[path] { - // The importer knows how to handle this. - return nil, nil - } - // Note that path here has been translated via v.ImportMap, - // unlike in the error in Import above. We prefer the error in - // Import, but it's worth diagnosing this one too, just in case. - return nil, fmt.Errorf("unknown package file for %q", path) - } - f, err := os.Open(file) - if err != nil { - return nil, err - } - return f, nil -} - -// doPackageCfg analyzes a single package described in a config file. -func doPackageCfg(cfgFile string) { - js, err := ioutil.ReadFile(cfgFile) - if err != nil { - errorf("%v", err) - } - if err := json.Unmarshal(js, &vcfg); err != nil { - errorf("parsing vet config %s: %v", cfgFile, err) - } - stdImporter = &vcfg - inittypes() - mustTypecheck = true - doPackage(vcfg.GoFiles, nil) - if vcfg.VetxOutput != "" { - out := make([]vetxExport, 0, len(exporters)) - for name, fn := range exporters { - out = append(out, vetxExport{ - Name: name, - Data: fn(), - }) - } - // Sort the data so that it is consistent across builds. - sort.Slice(out, func(i, j int) bool { - return out[i].Name < out[j].Name - }) - var buf bytes.Buffer - if err := gob.NewEncoder(&buf).Encode(out); err != nil { - errorf("encoding vet output: %v", err) - return - } - if err := ioutil.WriteFile(vcfg.VetxOutput, buf.Bytes(), 0666); err != nil { - errorf("saving vet output: %v", err) - return - } - } -} - -// doPackageDir analyzes the single package found in the directory, if there is one, -// plus a test package, if there is one. -func doPackageDir(directory string) { - context := build.Default - if len(context.BuildTags) != 0 { - warnf("build tags %s previously set", context.BuildTags) - } - context.BuildTags = append(tagList, context.BuildTags...) - - pkg, err := context.ImportDir(directory, 0) - if err != nil { - // If it's just that there are no go source files, that's fine. - if _, nogo := err.(*build.NoGoError); nogo { - return - } - // Non-fatal: we are doing a recursive walk and there may be other directories. - warnf("cannot process directory %s: %s", directory, err) - return - } - var names []string - names = append(names, pkg.GoFiles...) - names = append(names, pkg.CgoFiles...) - names = append(names, pkg.TestGoFiles...) // These are also in the "foo" package. - names = append(names, pkg.SFiles...) - prefixDirectory(directory, names) - basePkg := doPackage(names, nil) - // Is there also a "foo_test" package? If so, do that one as well. - if len(pkg.XTestGoFiles) > 0 { - names = pkg.XTestGoFiles - prefixDirectory(directory, names) - doPackage(names, basePkg) - } -} - -type Package struct { - path string - defs map[*ast.Ident]types.Object - uses map[*ast.Ident]types.Object - selectors map[*ast.SelectorExpr]*types.Selection - types map[ast.Expr]types.TypeAndValue - spans map[types.Object]Span - files []*File - typesPkg *types.Package -} - -// doPackage analyzes the single package constructed from the named files. -// It returns the parsed Package or nil if none of the files have been checked. -func doPackage(names []string, basePkg *Package) *Package { - var files []*File - var astFiles []*ast.File - fs := token.NewFileSet() - for _, name := range names { - data, err := ioutil.ReadFile(name) - if err != nil { - // Warn but continue to next package. - warnf("%s: %s", name, err) - return nil - } - var parsedFile *ast.File - if strings.HasSuffix(name, ".go") { - parsedFile, err = parser.ParseFile(fs, name, data, parser.ParseComments) - if err != nil { - warnf("%s: %s", name, err) - return nil - } - astFiles = append(astFiles, parsedFile) - } - file := &File{ - fset: fs, - content: data, - name: name, - file: parsedFile, - dead: make(map[ast.Node]bool), - } - files = append(files, file) - } - if len(astFiles) == 0 { - return nil - } - pkg := new(Package) - pkg.path = astFiles[0].Name.Name - pkg.files = files - // Type check the package. - errs := pkg.check(fs, astFiles) - if errs != nil { - if vcfg.SucceedOnTypecheckFailure { - os.Exit(0) - } - if *verbose || mustTypecheck { - for _, err := range errs { - fmt.Fprintf(os.Stderr, "%v\n", err) - } - if mustTypecheck { - // This message could be silenced, and we could just exit, - // but it might be helpful at least at first to make clear that the - // above errors are coming from vet and not the compiler - // (they often look like compiler errors, such as "declared but not used"). - errorf("typecheck failures") - } - } - } - - // Check. - for _, file := range files { - file.pkg = pkg - file.basePkg = basePkg - } - for name, fn := range pkgCheckers { - if vet(name) { - fn(pkg) - } - } - if vcfg.VetxOnly { - return pkg - } - - chk := make(map[ast.Node][]func(*File, ast.Node)) - for typ, set := range checkers { - for name, fn := range set { - if vet(name) { - chk[typ] = append(chk[typ], fn) - } - } - } - for _, file := range files { - checkBuildTag(file) - file.checkers = chk - if file.file != nil { - file.walkFile(file.name, file.file) - } - } - return pkg -} - -func visit(path string, f os.FileInfo, err error) error { - if err != nil { - warnf("walk error: %s", err) - return err - } - // One package per directory. Ignore the files themselves. - if !f.IsDir() { - return nil - } - doPackageDir(path) - return nil -} - -func (pkg *Package) hasFileWithSuffix(suffix string) bool { - for _, f := range pkg.files { - if strings.HasSuffix(f.name, suffix) { - return true - } - } - return false -} - -// walkDir recursively walks the tree looking for Go packages. -func walkDir(root string) { - filepath.Walk(root, visit) -} - -// errorf formats the error to standard error, adding program -// identification and a newline, and exits. -func errorf(format string, args ...interface{}) { - fmt.Fprintf(os.Stderr, "vet: "+format+"\n", args...) - os.Exit(2) -} - -// warnf formats the error to standard error, adding program -// identification and a newline, but does not exit. -func warnf(format string, args ...interface{}) { - fmt.Fprintf(os.Stderr, "vet: "+format+"\n", args...) - setExit(1) -} - -// Println is fmt.Println guarded by -v. -func Println(args ...interface{}) { - if !*verbose { - return - } - fmt.Println(args...) -} - -// Printf is fmt.Printf guarded by -v. -func Printf(format string, args ...interface{}) { - if !*verbose { - return - } - fmt.Printf(format+"\n", args...) -} - -// Bad reports an error and sets the exit code.. -func (f *File) Bad(pos token.Pos, args ...interface{}) { - f.Warn(pos, args...) - setExit(1) -} - -// Badf reports a formatted error and sets the exit code. -func (f *File) Badf(pos token.Pos, format string, args ...interface{}) { - f.Warnf(pos, format, args...) - setExit(1) -} - -// loc returns a formatted representation of the position. -func (f *File) loc(pos token.Pos) string { - if pos == token.NoPos { - return "" - } - // Do not print columns. Because the pos often points to the start of an - // expression instead of the inner part with the actual error, the - // precision can mislead. - posn := f.fset.Position(pos) - return fmt.Sprintf("%s:%d", posn.Filename, posn.Line) -} - -// locPrefix returns a formatted representation of the position for use as a line prefix. -func (f *File) locPrefix(pos token.Pos) string { - if pos == token.NoPos { - return "" - } - return fmt.Sprintf("%s: ", f.loc(pos)) -} - -// Warn reports an error but does not set the exit code. -func (f *File) Warn(pos token.Pos, args ...interface{}) { - fmt.Fprintf(os.Stderr, "%s%s", f.locPrefix(pos), fmt.Sprintln(args...)) -} - -// Warnf reports a formatted error but does not set the exit code. -func (f *File) Warnf(pos token.Pos, format string, args ...interface{}) { - fmt.Fprintf(os.Stderr, "%s%s\n", f.locPrefix(pos), fmt.Sprintf(format, args...)) -} - -// walkFile walks the file's tree. -func (f *File) walkFile(name string, file *ast.File) { - Println("Checking file", name) - ast.Walk(f, file) -} - -// Visit implements the ast.Visitor interface. -func (f *File) Visit(node ast.Node) ast.Visitor { - f.updateDead(node) - var key ast.Node - switch node.(type) { - case *ast.AssignStmt: - key = assignStmt - case *ast.BinaryExpr: - key = binaryExpr - case *ast.CallExpr: - key = callExpr - case *ast.CompositeLit: - key = compositeLit - case *ast.ExprStmt: - key = exprStmt - case *ast.ForStmt: - key = forStmt - case *ast.FuncDecl: - key = funcDecl - case *ast.FuncLit: - key = funcLit - case *ast.GenDecl: - key = genDecl - case *ast.InterfaceType: - key = interfaceType - case *ast.RangeStmt: - key = rangeStmt - case *ast.ReturnStmt: - key = returnStmt - case *ast.StructType: - key = structType - } - for _, fn := range f.checkers[key] { - fn(f, node) - } - return f -} - -// gofmt returns a string representation of the expression. -func (f *File) gofmt(x ast.Expr) string { - f.b.Reset() - printer.Fprint(&f.b, f.fset, x) - return f.b.String() -} - -// imported[path][key] is previously written export data. -var imported = make(map[string]map[string]interface{}) - -// readVetx reads export data written by a previous -// invocation of vet on an imported package (path). -// The key is the name passed to registerExport -// when the data was originally generated. -// readVetx returns nil if the data is unavailable. -func readVetx(path, key string) interface{} { - if path == "unsafe" || vcfg.ImportPath == "" { - return nil - } - m := imported[path] - if m == nil { - file := vcfg.PackageVetx[path] - if file == "" { - return nil - } - data, err := ioutil.ReadFile(file) - if err != nil { - return nil - } - var out []vetxExport - err = gob.NewDecoder(bytes.NewReader(data)).Decode(&out) - if err != nil { - return nil - } - m = make(map[string]interface{}) - for _, x := range out { - m[x.Name] = x.Data - } - imported[path] = m - } - return m[key] + unitchecker.Main( + asmdecl.Analyzer, + assign.Analyzer, + atomic.Analyzer, + bools.Analyzer, + buildtag.Analyzer, + cgocall.Analyzer, + composite.Analyzer, + copylock.Analyzer, + httpresponse.Analyzer, + loopclosure.Analyzer, + lostcancel.Analyzer, + nilfunc.Analyzer, + printf.Analyzer, + shift.Analyzer, + stdmethods.Analyzer, + structtag.Analyzer, + tests.Analyzer, + unmarshal.Analyzer, + unreachable.Analyzer, + unsafeptr.Analyzer, + unusedresult.Analyzer, + ) } diff --git a/libgo/go/cmd/vet/nilfunc.go b/libgo/go/cmd/vet/nilfunc.go deleted file mode 100644 index bfe05e3353d..00000000000 --- a/libgo/go/cmd/vet/nilfunc.go +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -/* -This file contains the code to check for useless function comparisons. -A useless comparison is one like f == nil as opposed to f() == nil. -*/ - -package main - -import ( - "go/ast" - "go/token" - "go/types" -) - -func init() { - register("nilfunc", - "check for comparisons between functions and nil", - checkNilFuncComparison, - binaryExpr) -} - -func checkNilFuncComparison(f *File, node ast.Node) { - e := node.(*ast.BinaryExpr) - - // Only want == or != comparisons. - if e.Op != token.EQL && e.Op != token.NEQ { - return - } - - // Only want comparisons with a nil identifier on one side. - var e2 ast.Expr - switch { - case f.isNil(e.X): - e2 = e.Y - case f.isNil(e.Y): - e2 = e.X - default: - return - } - - // Only want identifiers or selector expressions. - var obj types.Object - switch v := e2.(type) { - case *ast.Ident: - obj = f.pkg.uses[v] - case *ast.SelectorExpr: - obj = f.pkg.uses[v.Sel] - default: - return - } - - // Only want functions. - if _, ok := obj.(*types.Func); !ok { - return - } - - f.Badf(e.Pos(), "comparison of function %v %v nil is always %v", obj.Name(), e.Op, e.Op == token.NEQ) -} - -// isNil reports whether the provided expression is the built-in nil -// identifier. -func (f *File) isNil(e ast.Expr) bool { - return f.pkg.types[e].Type == types.Typ[types.UntypedNil] -} diff --git a/libgo/go/cmd/vet/rangeloop.go b/libgo/go/cmd/vet/rangeloop.go deleted file mode 100644 index 53a41364dfe..00000000000 --- a/libgo/go/cmd/vet/rangeloop.go +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -/* -This file contains the code to check range loop variables bound inside function -literals that are deferred or launched in new goroutines. We only check -instances where the defer or go statement is the last statement in the loop -body, as otherwise we would need whole program analysis. - -For example: - - for i, v := range s { - go func() { - println(i, v) // not what you might expect - }() - } - -See: https://golang.org/doc/go_faq.html#closures_and_goroutines -*/ - -package main - -import "go/ast" - -func init() { - register("rangeloops", - "check that loop variables are used correctly", - checkLoop, - rangeStmt, forStmt) -} - -// checkLoop walks the body of the provided loop statement, checking whether -// its index or value variables are used unsafely inside goroutines or deferred -// function literals. -func checkLoop(f *File, node ast.Node) { - // Find the variables updated by the loop statement. - var vars []*ast.Ident - addVar := func(expr ast.Expr) { - if id, ok := expr.(*ast.Ident); ok { - vars = append(vars, id) - } - } - var body *ast.BlockStmt - switch n := node.(type) { - case *ast.RangeStmt: - body = n.Body - addVar(n.Key) - addVar(n.Value) - case *ast.ForStmt: - body = n.Body - switch post := n.Post.(type) { - case *ast.AssignStmt: - // e.g. for p = head; p != nil; p = p.next - for _, lhs := range post.Lhs { - addVar(lhs) - } - case *ast.IncDecStmt: - // e.g. for i := 0; i < n; i++ - addVar(post.X) - } - } - if vars == nil { - return - } - - // Inspect a go or defer statement - // if it's the last one in the loop body. - // (We give up if there are following statements, - // because it's hard to prove go isn't followed by wait, - // or defer by return.) - if len(body.List) == 0 { - return - } - var last *ast.CallExpr - switch s := body.List[len(body.List)-1].(type) { - case *ast.GoStmt: - last = s.Call - case *ast.DeferStmt: - last = s.Call - default: - return - } - lit, ok := last.Fun.(*ast.FuncLit) - if !ok { - return - } - ast.Inspect(lit.Body, func(n ast.Node) bool { - id, ok := n.(*ast.Ident) - if !ok || id.Obj == nil { - return true - } - if f.pkg.types[id].Type == nil { - // Not referring to a variable (e.g. struct field name) - return true - } - for _, v := range vars { - if v.Obj == id.Obj { - f.Badf(id.Pos(), "loop variable %s captured by func literal", - id.Name) - } - } - return true - }) -} diff --git a/libgo/go/cmd/vet/shadow.go b/libgo/go/cmd/vet/shadow.go deleted file mode 100644 index 29c952fd885..00000000000 --- a/libgo/go/cmd/vet/shadow.go +++ /dev/null @@ -1,246 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -/* -This file contains the code to check for shadowed variables. -A shadowed variable is a variable declared in an inner scope -with the same name and type as a variable in an outer scope, -and where the outer variable is mentioned after the inner one -is declared. - -(This definition can be refined; the module generates too many -false positives and is not yet enabled by default.) - -For example: - - func BadRead(f *os.File, buf []byte) error { - var err error - for { - n, err := f.Read(buf) // shadows the function variable 'err' - if err != nil { - break // causes return of wrong value - } - foo(buf) - } - return err - } - -*/ - -package main - -import ( - "flag" - "go/ast" - "go/token" - "go/types" -) - -var strictShadowing = flag.Bool("shadowstrict", false, "whether to be strict about shadowing; can be noisy") - -func init() { - register("shadow", - "check for shadowed variables (experimental; must be set explicitly)", - checkShadow, - assignStmt, genDecl) - experimental["shadow"] = true -} - -func checkShadow(f *File, node ast.Node) { - switch n := node.(type) { - case *ast.AssignStmt: - checkShadowAssignment(f, n) - case *ast.GenDecl: - checkShadowDecl(f, n) - } -} - -// Span stores the minimum range of byte positions in the file in which a -// given variable (types.Object) is mentioned. It is lexically defined: it spans -// from the beginning of its first mention to the end of its last mention. -// A variable is considered shadowed (if *strictShadowing is off) only if the -// shadowing variable is declared within the span of the shadowed variable. -// In other words, if a variable is shadowed but not used after the shadowed -// variable is declared, it is inconsequential and not worth complaining about. -// This simple check dramatically reduces the nuisance rate for the shadowing -// check, at least until something cleverer comes along. -// -// One wrinkle: A "naked return" is a silent use of a variable that the Span -// will not capture, but the compilers catch naked returns of shadowed -// variables so we don't need to. -// -// Cases this gets wrong (TODO): -// - If a for loop's continuation statement mentions a variable redeclared in -// the block, we should complain about it but don't. -// - A variable declared inside a function literal can falsely be identified -// as shadowing a variable in the outer function. -// -type Span struct { - min token.Pos - max token.Pos -} - -// contains reports whether the position is inside the span. -func (s Span) contains(pos token.Pos) bool { - return s.min <= pos && pos < s.max -} - -// growSpan expands the span for the object to contain the instance represented -// by the identifier. -func (pkg *Package) growSpan(ident *ast.Ident, obj types.Object) { - if *strictShadowing { - return // No need - } - pos := ident.Pos() - end := ident.End() - span, ok := pkg.spans[obj] - if ok { - if span.min > pos { - span.min = pos - } - if span.max < end { - span.max = end - } - } else { - span = Span{pos, end} - } - pkg.spans[obj] = span -} - -// checkShadowAssignment checks for shadowing in a short variable declaration. -func checkShadowAssignment(f *File, a *ast.AssignStmt) { - if a.Tok != token.DEFINE { - return - } - if f.idiomaticShortRedecl(a) { - return - } - for _, expr := range a.Lhs { - ident, ok := expr.(*ast.Ident) - if !ok { - f.Badf(expr.Pos(), "invalid AST: short variable declaration of non-identifier") - return - } - checkShadowing(f, ident) - } -} - -// idiomaticShortRedecl reports whether this short declaration can be ignored for -// the purposes of shadowing, that is, that any redeclarations it contains are deliberate. -func (f *File) idiomaticShortRedecl(a *ast.AssignStmt) bool { - // Don't complain about deliberate redeclarations of the form - // i := i - // Such constructs are idiomatic in range loops to create a new variable - // for each iteration. Another example is - // switch n := n.(type) - if len(a.Rhs) != len(a.Lhs) { - return false - } - // We know it's an assignment, so the LHS must be all identifiers. (We check anyway.) - for i, expr := range a.Lhs { - lhs, ok := expr.(*ast.Ident) - if !ok { - f.Badf(expr.Pos(), "invalid AST: short variable declaration of non-identifier") - return true // Don't do any more processing. - } - switch rhs := a.Rhs[i].(type) { - case *ast.Ident: - if lhs.Name != rhs.Name { - return false - } - case *ast.TypeAssertExpr: - if id, ok := rhs.X.(*ast.Ident); ok { - if lhs.Name != id.Name { - return false - } - } - default: - return false - } - } - return true -} - -// idiomaticRedecl reports whether this declaration spec can be ignored for -// the purposes of shadowing, that is, that any redeclarations it contains are deliberate. -func (f *File) idiomaticRedecl(d *ast.ValueSpec) bool { - // Don't complain about deliberate redeclarations of the form - // var i, j = i, j - if len(d.Names) != len(d.Values) { - return false - } - for i, lhs := range d.Names { - if rhs, ok := d.Values[i].(*ast.Ident); ok { - if lhs.Name != rhs.Name { - return false - } - } - } - return true -} - -// checkShadowDecl checks for shadowing in a general variable declaration. -func checkShadowDecl(f *File, d *ast.GenDecl) { - if d.Tok != token.VAR { - return - } - for _, spec := range d.Specs { - valueSpec, ok := spec.(*ast.ValueSpec) - if !ok { - f.Badf(spec.Pos(), "invalid AST: var GenDecl not ValueSpec") - return - } - // Don't complain about deliberate redeclarations of the form - // var i = i - if f.idiomaticRedecl(valueSpec) { - return - } - for _, ident := range valueSpec.Names { - checkShadowing(f, ident) - } - } -} - -// checkShadowing checks whether the identifier shadows an identifier in an outer scope. -func checkShadowing(f *File, ident *ast.Ident) { - if ident.Name == "_" { - // Can't shadow the blank identifier. - return - } - obj := f.pkg.defs[ident] - if obj == nil { - return - } - // obj.Parent.Parent is the surrounding scope. If we can find another declaration - // starting from there, we have a shadowed identifier. - _, shadowed := obj.Parent().Parent().LookupParent(obj.Name(), obj.Pos()) - if shadowed == nil { - return - } - // Don't complain if it's shadowing a universe-declared identifier; that's fine. - if shadowed.Parent() == types.Universe { - return - } - if *strictShadowing { - // The shadowed identifier must appear before this one to be an instance of shadowing. - if shadowed.Pos() > ident.Pos() { - return - } - } else { - // Don't complain if the span of validity of the shadowed identifier doesn't include - // the shadowing identifier. - span, ok := f.pkg.spans[shadowed] - if !ok { - f.Badf(ident.Pos(), "internal error: no range for %q", ident.Name) - return - } - if !span.contains(ident.Pos()) { - return - } - } - // Don't complain if the types differ: that implies the programmer really wants two different things. - if types.Identical(obj.Type(), shadowed.Type()) { - f.Badf(ident.Pos(), "declaration of %q shadows declaration at %s", obj.Name(), f.loc(shadowed.Pos())) - } -} diff --git a/libgo/go/cmd/vet/shift.go b/libgo/go/cmd/vet/shift.go deleted file mode 100644 index 1e48d325242..00000000000 --- a/libgo/go/cmd/vet/shift.go +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -/* -This file contains the code to check for suspicious shifts. -*/ - -package main - -import ( - "go/ast" - "go/constant" - "go/token" - "go/types" -) - -func init() { - register("shift", - "check for useless shifts", - checkShift, - binaryExpr, assignStmt) -} - -func checkShift(f *File, node ast.Node) { - if f.dead[node] { - // Skip shift checks on unreachable nodes. - return - } - - switch node := node.(type) { - case *ast.BinaryExpr: - if node.Op == token.SHL || node.Op == token.SHR { - checkLongShift(f, node, node.X, node.Y) - } - case *ast.AssignStmt: - if len(node.Lhs) != 1 || len(node.Rhs) != 1 { - return - } - if node.Tok == token.SHL_ASSIGN || node.Tok == token.SHR_ASSIGN { - checkLongShift(f, node, node.Lhs[0], node.Rhs[0]) - } - } -} - -// checkLongShift checks if shift or shift-assign operations shift by more than -// the length of the underlying variable. -func checkLongShift(f *File, node ast.Node, x, y ast.Expr) { - if f.pkg.types[x].Value != nil { - // Ignore shifts of constants. - // These are frequently used for bit-twiddling tricks - // like ^uint(0) >> 63 for 32/64 bit detection and compatibility. - return - } - - v := f.pkg.types[y].Value - if v == nil { - return - } - amt, ok := constant.Int64Val(v) - if !ok { - return - } - t := f.pkg.types[x].Type - if t == nil { - return - } - b, ok := t.Underlying().(*types.Basic) - if !ok { - return - } - var size int64 - switch b.Kind() { - case types.Uint8, types.Int8: - size = 8 - case types.Uint16, types.Int16: - size = 16 - case types.Uint32, types.Int32: - size = 32 - case types.Uint64, types.Int64: - size = 64 - case types.Int, types.Uint: - size = uintBitSize - case types.Uintptr: - size = uintptrBitSize - default: - return - } - if amt >= size { - ident := f.gofmt(x) - f.Badf(node.Pos(), "%s (%d bits) too small for shift of %d", ident, size, amt) - } -} - -var ( - uintBitSize = 8 * archSizes.Sizeof(types.Typ[types.Uint]) - uintptrBitSize = 8 * archSizes.Sizeof(types.Typ[types.Uintptr]) -) diff --git a/libgo/go/cmd/vet/structtag.go b/libgo/go/cmd/vet/structtag.go deleted file mode 100644 index 3bc30c47405..00000000000 --- a/libgo/go/cmd/vet/structtag.go +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This file contains the test for canonical struct tags. - -package main - -import ( - "errors" - "go/ast" - "go/token" - "reflect" - "strconv" - "strings" -) - -func init() { - register("structtags", - "check that struct field tags have canonical format and apply to exported fields as needed", - checkStructFieldTags, - structType) -} - -// checkStructFieldTags checks all the field tags of a struct, including checking for duplicates. -func checkStructFieldTags(f *File, node ast.Node) { - var seen map[[2]string]token.Pos - for _, field := range node.(*ast.StructType).Fields.List { - checkCanonicalFieldTag(f, field, &seen) - } -} - -var checkTagDups = []string{"json", "xml"} -var checkTagSpaces = map[string]bool{"json": true, "xml": true, "asn1": true} - -// checkCanonicalFieldTag checks a single struct field tag. -func checkCanonicalFieldTag(f *File, field *ast.Field, seen *map[[2]string]token.Pos) { - if field.Tag == nil { - return - } - - tag, err := strconv.Unquote(field.Tag.Value) - if err != nil { - f.Badf(field.Pos(), "unable to read struct tag %s", field.Tag.Value) - return - } - - if err := validateStructTag(tag); err != nil { - raw, _ := strconv.Unquote(field.Tag.Value) // field.Tag.Value is known to be a quoted string - f.Badf(field.Pos(), "struct field tag %#q not compatible with reflect.StructTag.Get: %s", raw, err) - } - - for _, key := range checkTagDups { - val := reflect.StructTag(tag).Get(key) - if val == "" || val == "-" || val[0] == ',' { - continue - } - if key == "xml" && len(field.Names) > 0 && field.Names[0].Name == "XMLName" { - // XMLName defines the XML element name of the struct being - // checked. That name cannot collide with element or attribute - // names defined on other fields of the struct. Vet does not have a - // check for untagged fields of type struct defining their own name - // by containing a field named XMLName; see issue 18256. - continue - } - if i := strings.Index(val, ","); i >= 0 { - if key == "xml" { - // Use a separate namespace for XML attributes. - for _, opt := range strings.Split(val[i:], ",") { - if opt == "attr" { - key += " attribute" // Key is part of the error message. - break - } - } - } - val = val[:i] - } - if *seen == nil { - *seen = map[[2]string]token.Pos{} - } - if pos, ok := (*seen)[[2]string{key, val}]; ok { - var name string - if len(field.Names) > 0 { - name = field.Names[0].Name - } else { - name = field.Type.(*ast.Ident).Name - } - f.Badf(field.Pos(), "struct field %s repeats %s tag %q also at %s", name, key, val, f.loc(pos)) - } else { - (*seen)[[2]string{key, val}] = field.Pos() - } - } - - // Check for use of json or xml tags with unexported fields. - - // Embedded struct. Nothing to do for now, but that - // may change, depending on what happens with issue 7363. - if len(field.Names) == 0 { - return - } - - if field.Names[0].IsExported() { - return - } - - for _, enc := range [...]string{"json", "xml"} { - if reflect.StructTag(tag).Get(enc) != "" { - f.Badf(field.Pos(), "struct field %s has %s tag but is not exported", field.Names[0].Name, enc) - return - } - } -} - -var ( - errTagSyntax = errors.New("bad syntax for struct tag pair") - errTagKeySyntax = errors.New("bad syntax for struct tag key") - errTagValueSyntax = errors.New("bad syntax for struct tag value") - errTagValueSpace = errors.New("suspicious space in struct tag value") - errTagSpace = errors.New("key:\"value\" pairs not separated by spaces") -) - -// validateStructTag parses the struct tag and returns an error if it is not -// in the canonical format, which is a space-separated list of key:"value" -// settings. The value may contain spaces. -func validateStructTag(tag string) error { - // This code is based on the StructTag.Get code in package reflect. - - n := 0 - for ; tag != ""; n++ { - if n > 0 && tag != "" && tag[0] != ' ' { - // More restrictive than reflect, but catches likely mistakes - // like `x:"foo",y:"bar"`, which parses as `x:"foo" ,y:"bar"` with second key ",y". - return errTagSpace - } - // Skip leading space. - i := 0 - for i < len(tag) && tag[i] == ' ' { - i++ - } - tag = tag[i:] - if tag == "" { - break - } - - // Scan to colon. A space, a quote or a control character is a syntax error. - // Strictly speaking, control chars include the range [0x7f, 0x9f], not just - // [0x00, 0x1f], but in practice, we ignore the multi-byte control characters - // as it is simpler to inspect the tag's bytes than the tag's runes. - i = 0 - for i < len(tag) && tag[i] > ' ' && tag[i] != ':' && tag[i] != '"' && tag[i] != 0x7f { - i++ - } - if i == 0 { - return errTagKeySyntax - } - if i+1 >= len(tag) || tag[i] != ':' { - return errTagSyntax - } - if tag[i+1] != '"' { - return errTagValueSyntax - } - key := tag[:i] - tag = tag[i+1:] - - // Scan quoted string to find value. - i = 1 - for i < len(tag) && tag[i] != '"' { - if tag[i] == '\\' { - i++ - } - i++ - } - if i >= len(tag) { - return errTagValueSyntax - } - qvalue := tag[:i+1] - tag = tag[i+1:] - - value, err := strconv.Unquote(qvalue) - if err != nil { - return errTagValueSyntax - } - - if !checkTagSpaces[key] { - continue - } - - switch key { - case "xml": - // If the first or last character in the XML tag is a space, it is - // suspicious. - if strings.Trim(value, " ") != value { - return errTagValueSpace - } - - // If there are multiple spaces, they are suspicious. - if strings.Count(value, " ") > 1 { - return errTagValueSpace - } - - // If there is no comma, skip the rest of the checks. - comma := strings.IndexRune(value, ',') - if comma < 0 { - continue - } - - // If the character before a comma is a space, this is suspicious. - if comma > 0 && value[comma-1] == ' ' { - return errTagValueSpace - } - value = value[comma+1:] - case "json": - // JSON allows using spaces in the name, so skip it. - comma := strings.IndexRune(value, ',') - if comma < 0 { - continue - } - value = value[comma+1:] - } - - if strings.IndexByte(value, ' ') >= 0 { - return errTagValueSpace - } - } - return nil -} diff --git a/libgo/go/cmd/vet/testdata/asm/asm.go b/libgo/go/cmd/vet/testdata/asm/asm.go deleted file mode 100644 index 2237ddc3b05..00000000000 --- a/libgo/go/cmd/vet/testdata/asm/asm.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// This file contains declarations to test the assembly in test_asm.s. - -package testdata - -type S struct { - i int32 - b bool - s string -} - -func arg1(x int8, y uint8) -func arg2(x int16, y uint16) -func arg4(x int32, y uint32) -func arg8(x int64, y uint64) -func argint(x int, y uint) -func argptr(x *byte, y *byte, c chan int, m map[int]int, f func()) -func argstring(x, y string) -func argslice(x, y []string) -func argiface(x interface{}, y interface { - m() -}) -func argcomplex(x complex64, y complex128) -func argstruct(x S, y struct{}) -func argarray(x [2]S) -func returnint() int -func returnbyte(x int) byte -func returnnamed(x byte) (r1 int, r2 int16, r3 string, r4 byte) -func returnintmissing() int -func leaf(x, y int) int - -func noprof(x int) -func dupok(x int) -func nosplit(x int) -func rodata(x int) -func noptr(x int) -func wrapper(x int) - -func f15271() (x uint32) -func f17584(x float32, y complex64) - -func noframe1(x int32) -func noframe2(x int32) diff --git a/libgo/go/cmd/vet/testdata/asm/asm1.s b/libgo/go/cmd/vet/testdata/asm/asm1.s deleted file mode 100644 index cac6ed22cd0..00000000000 --- a/libgo/go/cmd/vet/testdata/asm/asm1.s +++ /dev/null @@ -1,315 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build amd64 -// +build vet_test - -TEXT ·arg1(SB),0,$0-2 - MOVB x+0(FP), AX - // MOVB x+0(FP), AX // commented out instructions used to panic - MOVB y+1(FP), BX - MOVW x+0(FP), AX // ERROR "\[amd64\] arg1: invalid MOVW of x\+0\(FP\); int8 is 1-byte value" - MOVW y+1(FP), AX // ERROR "invalid MOVW of y\+1\(FP\); uint8 is 1-byte value" - MOVL x+0(FP), AX // ERROR "invalid MOVL of x\+0\(FP\); int8 is 1-byte value" - MOVL y+1(FP), AX // ERROR "invalid MOVL of y\+1\(FP\); uint8 is 1-byte value" - MOVQ x+0(FP), AX // ERROR "invalid MOVQ of x\+0\(FP\); int8 is 1-byte value" - MOVQ y+1(FP), AX // ERROR "invalid MOVQ of y\+1\(FP\); uint8 is 1-byte value" - MOVB x+1(FP), AX // ERROR "invalid offset x\+1\(FP\); expected x\+0\(FP\)" - MOVB y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+1\(FP\)" - TESTB x+0(FP), AX - TESTB y+1(FP), BX - TESTW x+0(FP), AX // ERROR "invalid TESTW of x\+0\(FP\); int8 is 1-byte value" - TESTW y+1(FP), AX // ERROR "invalid TESTW of y\+1\(FP\); uint8 is 1-byte value" - TESTL x+0(FP), AX // ERROR "invalid TESTL of x\+0\(FP\); int8 is 1-byte value" - TESTL y+1(FP), AX // ERROR "invalid TESTL of y\+1\(FP\); uint8 is 1-byte value" - TESTQ x+0(FP), AX // ERROR "invalid TESTQ of x\+0\(FP\); int8 is 1-byte value" - TESTQ y+1(FP), AX // ERROR "invalid TESTQ of y\+1\(FP\); uint8 is 1-byte value" - TESTB x+1(FP), AX // ERROR "invalid offset x\+1\(FP\); expected x\+0\(FP\)" - TESTB y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+1\(FP\)" - MOVB 8(SP), AX // ERROR "8\(SP\) should be x\+0\(FP\)" - MOVB 9(SP), AX // ERROR "9\(SP\) should be y\+1\(FP\)" - MOVB 10(SP), AX // ERROR "use of 10\(SP\) points beyond argument frame" - RET - -TEXT ·arg2(SB),0,$0-4 - MOVB x+0(FP), AX // ERROR "arg2: invalid MOVB of x\+0\(FP\); int16 is 2-byte value" - MOVB y+2(FP), AX // ERROR "invalid MOVB of y\+2\(FP\); uint16 is 2-byte value" - MOVW x+0(FP), AX - MOVW y+2(FP), BX - MOVL x+0(FP), AX // ERROR "invalid MOVL of x\+0\(FP\); int16 is 2-byte value" - MOVL y+2(FP), AX // ERROR "invalid MOVL of y\+2\(FP\); uint16 is 2-byte value" - MOVQ x+0(FP), AX // ERROR "invalid MOVQ of x\+0\(FP\); int16 is 2-byte value" - MOVQ y+2(FP), AX // ERROR "invalid MOVQ of y\+2\(FP\); uint16 is 2-byte value" - MOVW x+2(FP), AX // ERROR "invalid offset x\+2\(FP\); expected x\+0\(FP\)" - MOVW y+0(FP), AX // ERROR "invalid offset y\+0\(FP\); expected y\+2\(FP\)" - TESTB x+0(FP), AX // ERROR "invalid TESTB of x\+0\(FP\); int16 is 2-byte value" - TESTB y+2(FP), AX // ERROR "invalid TESTB of y\+2\(FP\); uint16 is 2-byte value" - TESTW x+0(FP), AX - TESTW y+2(FP), BX - TESTL x+0(FP), AX // ERROR "invalid TESTL of x\+0\(FP\); int16 is 2-byte value" - TESTL y+2(FP), AX // ERROR "invalid TESTL of y\+2\(FP\); uint16 is 2-byte value" - TESTQ x+0(FP), AX // ERROR "invalid TESTQ of x\+0\(FP\); int16 is 2-byte value" - TESTQ y+2(FP), AX // ERROR "invalid TESTQ of y\+2\(FP\); uint16 is 2-byte value" - TESTW x+2(FP), AX // ERROR "invalid offset x\+2\(FP\); expected x\+0\(FP\)" - TESTW y+0(FP), AX // ERROR "invalid offset y\+0\(FP\); expected y\+2\(FP\)" - RET - -TEXT ·arg4(SB),0,$0-2 // ERROR "arg4: wrong argument size 2; expected \$\.\.\.-8" - MOVB x+0(FP), AX // ERROR "invalid MOVB of x\+0\(FP\); int32 is 4-byte value" - MOVB y+4(FP), BX // ERROR "invalid MOVB of y\+4\(FP\); uint32 is 4-byte value" - MOVW x+0(FP), AX // ERROR "invalid MOVW of x\+0\(FP\); int32 is 4-byte value" - MOVW y+4(FP), AX // ERROR "invalid MOVW of y\+4\(FP\); uint32 is 4-byte value" - MOVL x+0(FP), AX - MOVL y+4(FP), AX - MOVQ x+0(FP), AX // ERROR "invalid MOVQ of x\+0\(FP\); int32 is 4-byte value" - MOVQ y+4(FP), AX // ERROR "invalid MOVQ of y\+4\(FP\); uint32 is 4-byte value" - MOVL x+4(FP), AX // ERROR "invalid offset x\+4\(FP\); expected x\+0\(FP\)" - MOVL y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+4\(FP\)" - TESTB x+0(FP), AX // ERROR "invalid TESTB of x\+0\(FP\); int32 is 4-byte value" - TESTB y+4(FP), BX // ERROR "invalid TESTB of y\+4\(FP\); uint32 is 4-byte value" - TESTW x+0(FP), AX // ERROR "invalid TESTW of x\+0\(FP\); int32 is 4-byte value" - TESTW y+4(FP), AX // ERROR "invalid TESTW of y\+4\(FP\); uint32 is 4-byte value" - TESTL x+0(FP), AX - TESTL y+4(FP), AX - TESTQ x+0(FP), AX // ERROR "invalid TESTQ of x\+0\(FP\); int32 is 4-byte value" - TESTQ y+4(FP), AX // ERROR "invalid TESTQ of y\+4\(FP\); uint32 is 4-byte value" - TESTL x+4(FP), AX // ERROR "invalid offset x\+4\(FP\); expected x\+0\(FP\)" - TESTL y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+4\(FP\)" - RET - -TEXT ·arg8(SB),7,$0-2 // ERROR "wrong argument size 2; expected \$\.\.\.-16" - MOVB x+0(FP), AX // ERROR "invalid MOVB of x\+0\(FP\); int64 is 8-byte value" - MOVB y+8(FP), BX // ERROR "invalid MOVB of y\+8\(FP\); uint64 is 8-byte value" - MOVW x+0(FP), AX // ERROR "invalid MOVW of x\+0\(FP\); int64 is 8-byte value" - MOVW y+8(FP), AX // ERROR "invalid MOVW of y\+8\(FP\); uint64 is 8-byte value" - MOVL x+0(FP), AX // ERROR "invalid MOVL of x\+0\(FP\); int64 is 8-byte value" - MOVL y+8(FP), AX // ERROR "invalid MOVL of y\+8\(FP\); uint64 is 8-byte value" - MOVQ x+0(FP), AX - MOVQ y+8(FP), AX - MOVQ x+8(FP), AX // ERROR "invalid offset x\+8\(FP\); expected x\+0\(FP\)" - MOVQ y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+8\(FP\)" - TESTB x+0(FP), AX // ERROR "invalid TESTB of x\+0\(FP\); int64 is 8-byte value" - TESTB y+8(FP), BX // ERROR "invalid TESTB of y\+8\(FP\); uint64 is 8-byte value" - TESTW x+0(FP), AX // ERROR "invalid TESTW of x\+0\(FP\); int64 is 8-byte value" - TESTW y+8(FP), AX // ERROR "invalid TESTW of y\+8\(FP\); uint64 is 8-byte value" - TESTL x+0(FP), AX // ERROR "invalid TESTL of x\+0\(FP\); int64 is 8-byte value" - TESTL y+8(FP), AX // ERROR "invalid TESTL of y\+8\(FP\); uint64 is 8-byte value" - TESTQ x+0(FP), AX - TESTQ y+8(FP), AX - TESTQ x+8(FP), AX // ERROR "invalid offset x\+8\(FP\); expected x\+0\(FP\)" - TESTQ y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+8\(FP\)" - RET - -TEXT ·argint(SB),0,$0-2 // ERROR "wrong argument size 2; expected \$\.\.\.-16" - MOVB x+0(FP), AX // ERROR "invalid MOVB of x\+0\(FP\); int is 8-byte value" - MOVB y+8(FP), BX // ERROR "invalid MOVB of y\+8\(FP\); uint is 8-byte value" - MOVW x+0(FP), AX // ERROR "invalid MOVW of x\+0\(FP\); int is 8-byte value" - MOVW y+8(FP), AX // ERROR "invalid MOVW of y\+8\(FP\); uint is 8-byte value" - MOVL x+0(FP), AX // ERROR "invalid MOVL of x\+0\(FP\); int is 8-byte value" - MOVL y+8(FP), AX // ERROR "invalid MOVL of y\+8\(FP\); uint is 8-byte value" - MOVQ x+0(FP), AX - MOVQ y+8(FP), AX - MOVQ x+8(FP), AX // ERROR "invalid offset x\+8\(FP\); expected x\+0\(FP\)" - MOVQ y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+8\(FP\)" - TESTB x+0(FP), AX // ERROR "invalid TESTB of x\+0\(FP\); int is 8-byte value" - TESTB y+8(FP), BX // ERROR "invalid TESTB of y\+8\(FP\); uint is 8-byte value" - TESTW x+0(FP), AX // ERROR "invalid TESTW of x\+0\(FP\); int is 8-byte value" - TESTW y+8(FP), AX // ERROR "invalid TESTW of y\+8\(FP\); uint is 8-byte value" - TESTL x+0(FP), AX // ERROR "invalid TESTL of x\+0\(FP\); int is 8-byte value" - TESTL y+8(FP), AX // ERROR "invalid TESTL of y\+8\(FP\); uint is 8-byte value" - TESTQ x+0(FP), AX - TESTQ y+8(FP), AX - TESTQ x+8(FP), AX // ERROR "invalid offset x\+8\(FP\); expected x\+0\(FP\)" - TESTQ y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+8\(FP\)" - RET - -TEXT ·argptr(SB),7,$0-2 // ERROR "wrong argument size 2; expected \$\.\.\.-40" - MOVB x+0(FP), AX // ERROR "invalid MOVB of x\+0\(FP\); \*byte is 8-byte value" - MOVB y+8(FP), BX // ERROR "invalid MOVB of y\+8\(FP\); \*byte is 8-byte value" - MOVW x+0(FP), AX // ERROR "invalid MOVW of x\+0\(FP\); \*byte is 8-byte value" - MOVW y+8(FP), AX // ERROR "invalid MOVW of y\+8\(FP\); \*byte is 8-byte value" - MOVL x+0(FP), AX // ERROR "invalid MOVL of x\+0\(FP\); \*byte is 8-byte value" - MOVL y+8(FP), AX // ERROR "invalid MOVL of y\+8\(FP\); \*byte is 8-byte value" - MOVQ x+0(FP), AX - MOVQ y+8(FP), AX - MOVQ x+8(FP), AX // ERROR "invalid offset x\+8\(FP\); expected x\+0\(FP\)" - MOVQ y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+8\(FP\)" - TESTB x+0(FP), AX // ERROR "invalid TESTB of x\+0\(FP\); \*byte is 8-byte value" - TESTB y+8(FP), BX // ERROR "invalid TESTB of y\+8\(FP\); \*byte is 8-byte value" - TESTW x+0(FP), AX // ERROR "invalid TESTW of x\+0\(FP\); \*byte is 8-byte value" - TESTW y+8(FP), AX // ERROR "invalid TESTW of y\+8\(FP\); \*byte is 8-byte value" - TESTL x+0(FP), AX // ERROR "invalid TESTL of x\+0\(FP\); \*byte is 8-byte value" - TESTL y+8(FP), AX // ERROR "invalid TESTL of y\+8\(FP\); \*byte is 8-byte value" - TESTQ x+0(FP), AX - TESTQ y+8(FP), AX - TESTQ x+8(FP), AX // ERROR "invalid offset x\+8\(FP\); expected x\+0\(FP\)" - TESTQ y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+8\(FP\)" - MOVL c+16(FP), AX // ERROR "invalid MOVL of c\+16\(FP\); chan int is 8-byte value" - MOVL m+24(FP), AX // ERROR "invalid MOVL of m\+24\(FP\); map\[int\]int is 8-byte value" - MOVL f+32(FP), AX // ERROR "invalid MOVL of f\+32\(FP\); func\(\) is 8-byte value" - RET - -TEXT ·argstring(SB),0,$32 // ERROR "wrong argument size 0; expected \$\.\.\.-32" - MOVW x+0(FP), AX // ERROR "invalid MOVW of x\+0\(FP\); string base is 8-byte value" - MOVL x+0(FP), AX // ERROR "invalid MOVL of x\+0\(FP\); string base is 8-byte value" - MOVQ x+0(FP), AX - MOVW x_base+0(FP), AX // ERROR "invalid MOVW of x_base\+0\(FP\); string base is 8-byte value" - MOVL x_base+0(FP), AX // ERROR "invalid MOVL of x_base\+0\(FP\); string base is 8-byte value" - MOVQ x_base+0(FP), AX - MOVW x_len+0(FP), AX // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+8\(FP\)" - MOVL x_len+0(FP), AX // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+8\(FP\)" - MOVQ x_len+0(FP), AX // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+8\(FP\)" - MOVW x_len+8(FP), AX // ERROR "invalid MOVW of x_len\+8\(FP\); string len is 8-byte value" - MOVL x_len+8(FP), AX // ERROR "invalid MOVL of x_len\+8\(FP\); string len is 8-byte value" - MOVQ x_len+8(FP), AX - MOVQ y+0(FP), AX // ERROR "invalid offset y\+0\(FP\); expected y\+16\(FP\)" - MOVQ y_len+8(FP), AX // ERROR "invalid offset y_len\+8\(FP\); expected y_len\+24\(FP\)" - RET - -TEXT ·argslice(SB),0,$48 // ERROR "wrong argument size 0; expected \$\.\.\.-48" - MOVW x+0(FP), AX // ERROR "invalid MOVW of x\+0\(FP\); slice base is 8-byte value" - MOVL x+0(FP), AX // ERROR "invalid MOVL of x\+0\(FP\); slice base is 8-byte value" - MOVQ x+0(FP), AX - MOVW x_base+0(FP), AX // ERROR "invalid MOVW of x_base\+0\(FP\); slice base is 8-byte value" - MOVL x_base+0(FP), AX // ERROR "invalid MOVL of x_base\+0\(FP\); slice base is 8-byte value" - MOVQ x_base+0(FP), AX - MOVW x_len+0(FP), AX // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+8\(FP\)" - MOVL x_len+0(FP), AX // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+8\(FP\)" - MOVQ x_len+0(FP), AX // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+8\(FP\)" - MOVW x_len+8(FP), AX // ERROR "invalid MOVW of x_len\+8\(FP\); slice len is 8-byte value" - MOVL x_len+8(FP), AX // ERROR "invalid MOVL of x_len\+8\(FP\); slice len is 8-byte value" - MOVQ x_len+8(FP), AX - MOVW x_cap+0(FP), AX // ERROR "invalid offset x_cap\+0\(FP\); expected x_cap\+16\(FP\)" - MOVL x_cap+0(FP), AX // ERROR "invalid offset x_cap\+0\(FP\); expected x_cap\+16\(FP\)" - MOVQ x_cap+0(FP), AX // ERROR "invalid offset x_cap\+0\(FP\); expected x_cap\+16\(FP\)" - MOVW x_cap+16(FP), AX // ERROR "invalid MOVW of x_cap\+16\(FP\); slice cap is 8-byte value" - MOVL x_cap+16(FP), AX // ERROR "invalid MOVL of x_cap\+16\(FP\); slice cap is 8-byte value" - MOVQ x_cap+16(FP), AX - MOVQ y+0(FP), AX // ERROR "invalid offset y\+0\(FP\); expected y\+24\(FP\)" - MOVQ y_len+8(FP), AX // ERROR "invalid offset y_len\+8\(FP\); expected y_len\+32\(FP\)" - MOVQ y_cap+16(FP), AX // ERROR "invalid offset y_cap\+16\(FP\); expected y_cap\+40\(FP\)" - RET - -TEXT ·argiface(SB),0,$0-32 - MOVW x+0(FP), AX // ERROR "invalid MOVW of x\+0\(FP\); interface type is 8-byte value" - MOVL x+0(FP), AX // ERROR "invalid MOVL of x\+0\(FP\); interface type is 8-byte value" - MOVQ x+0(FP), AX - MOVW x_type+0(FP), AX // ERROR "invalid MOVW of x_type\+0\(FP\); interface type is 8-byte value" - MOVL x_type+0(FP), AX // ERROR "invalid MOVL of x_type\+0\(FP\); interface type is 8-byte value" - MOVQ x_type+0(FP), AX - MOVQ x_itable+0(FP), AX // ERROR "unknown variable x_itable; offset 0 is x_type\+0\(FP\)" - MOVQ x_itable+1(FP), AX // ERROR "unknown variable x_itable; offset 1 is x_type\+0\(FP\)" - MOVW x_data+0(FP), AX // ERROR "invalid offset x_data\+0\(FP\); expected x_data\+8\(FP\)" - MOVL x_data+0(FP), AX // ERROR "invalid offset x_data\+0\(FP\); expected x_data\+8\(FP\)" - MOVQ x_data+0(FP), AX // ERROR "invalid offset x_data\+0\(FP\); expected x_data\+8\(FP\)" - MOVW x_data+8(FP), AX // ERROR "invalid MOVW of x_data\+8\(FP\); interface data is 8-byte value" - MOVL x_data+8(FP), AX // ERROR "invalid MOVL of x_data\+8\(FP\); interface data is 8-byte value" - MOVQ x_data+8(FP), AX - MOVW y+16(FP), AX // ERROR "invalid MOVW of y\+16\(FP\); interface itable is 8-byte value" - MOVL y+16(FP), AX // ERROR "invalid MOVL of y\+16\(FP\); interface itable is 8-byte value" - MOVQ y+16(FP), AX - MOVW y_itable+16(FP), AX // ERROR "invalid MOVW of y_itable\+16\(FP\); interface itable is 8-byte value" - MOVL y_itable+16(FP), AX // ERROR "invalid MOVL of y_itable\+16\(FP\); interface itable is 8-byte value" - MOVQ y_itable+16(FP), AX - MOVQ y_type+16(FP), AX // ERROR "unknown variable y_type; offset 16 is y_itable\+16\(FP\)" - MOVW y_data+16(FP), AX // ERROR "invalid offset y_data\+16\(FP\); expected y_data\+24\(FP\)" - MOVL y_data+16(FP), AX // ERROR "invalid offset y_data\+16\(FP\); expected y_data\+24\(FP\)" - MOVQ y_data+16(FP), AX // ERROR "invalid offset y_data\+16\(FP\); expected y_data\+24\(FP\)" - MOVW y_data+24(FP), AX // ERROR "invalid MOVW of y_data\+24\(FP\); interface data is 8-byte value" - MOVL y_data+24(FP), AX // ERROR "invalid MOVL of y_data\+24\(FP\); interface data is 8-byte value" - MOVQ y_data+24(FP), AX - RET - -TEXT ·argcomplex(SB),0,$24 // ERROR "wrong argument size 0; expected \$\.\.\.-24" - MOVSS x+0(FP), X0 // ERROR "invalid MOVSS of x\+0\(FP\); complex64 is 8-byte value containing x_real\+0\(FP\) and x_imag\+4\(FP\)" - MOVSD x+0(FP), X0 // ERROR "invalid MOVSD of x\+0\(FP\); complex64 is 8-byte value containing x_real\+0\(FP\) and x_imag\+4\(FP\)" - MOVSS x_real+0(FP), X0 - MOVSD x_real+0(FP), X0 // ERROR "invalid MOVSD of x_real\+0\(FP\); real\(complex64\) is 4-byte value" - MOVSS x_real+4(FP), X0 // ERROR "invalid offset x_real\+4\(FP\); expected x_real\+0\(FP\)" - MOVSS x_imag+4(FP), X0 - MOVSD x_imag+4(FP), X0 // ERROR "invalid MOVSD of x_imag\+4\(FP\); imag\(complex64\) is 4-byte value" - MOVSS x_imag+8(FP), X0 // ERROR "invalid offset x_imag\+8\(FP\); expected x_imag\+4\(FP\)" - MOVSD y+8(FP), X0 // ERROR "invalid MOVSD of y\+8\(FP\); complex128 is 16-byte value containing y_real\+8\(FP\) and y_imag\+16\(FP\)" - MOVSS y_real+8(FP), X0 // ERROR "invalid MOVSS of y_real\+8\(FP\); real\(complex128\) is 8-byte value" - MOVSD y_real+8(FP), X0 - MOVSS y_real+16(FP), X0 // ERROR "invalid offset y_real\+16\(FP\); expected y_real\+8\(FP\)" - MOVSS y_imag+16(FP), X0 // ERROR "invalid MOVSS of y_imag\+16\(FP\); imag\(complex128\) is 8-byte value" - MOVSD y_imag+16(FP), X0 - MOVSS y_imag+24(FP), X0 // ERROR "invalid offset y_imag\+24\(FP\); expected y_imag\+16\(FP\)" - RET - -TEXT ·argstruct(SB),0,$64 // ERROR "wrong argument size 0; expected \$\.\.\.-24" - MOVQ x+0(FP), AX // ERROR "invalid MOVQ of x\+0\(FP\); testdata.S is 24-byte value" - MOVQ x_i+0(FP), AX // ERROR "invalid MOVQ of x_i\+0\(FP\); int32 is 4-byte value" - MOVQ x_b+0(FP), AX // ERROR "invalid offset x_b\+0\(FP\); expected x_b\+4\(FP\)" - MOVQ x_s+8(FP), AX - MOVQ x_s_base+8(FP), AX - MOVQ x_s+16(FP), AX // ERROR "invalid offset x_s\+16\(FP\); expected x_s\+8\(FP\), x_s_base\+8\(FP\), or x_s_len\+16\(FP\)" - MOVQ x_s_len+16(FP), AX - RET - -TEXT ·argarray(SB),0,$64 // ERROR "wrong argument size 0; expected \$\.\.\.-48" - MOVQ x+0(FP), AX // ERROR "invalid MOVQ of x\+0\(FP\); \[2\]testdata.S is 48-byte value" - MOVQ x_0_i+0(FP), AX // ERROR "invalid MOVQ of x_0_i\+0\(FP\); int32 is 4-byte value" - MOVQ x_0_b+0(FP), AX // ERROR "invalid offset x_0_b\+0\(FP\); expected x_0_b\+4\(FP\)" - MOVQ x_0_s+8(FP), AX - MOVQ x_0_s_base+8(FP), AX - MOVQ x_0_s+16(FP), AX // ERROR "invalid offset x_0_s\+16\(FP\); expected x_0_s\+8\(FP\), x_0_s_base\+8\(FP\), or x_0_s_len\+16\(FP\)" - MOVQ x_0_s_len+16(FP), AX - MOVB foo+25(FP), AX // ERROR "unknown variable foo; offset 25 is x_1_i\+24\(FP\)" - MOVQ x_1_s+32(FP), AX - MOVQ x_1_s_base+32(FP), AX - MOVQ x_1_s+40(FP), AX // ERROR "invalid offset x_1_s\+40\(FP\); expected x_1_s\+32\(FP\), x_1_s_base\+32\(FP\), or x_1_s_len\+40\(FP\)" - MOVQ x_1_s_len+40(FP), AX - RET - -TEXT ·returnint(SB),0,$0-8 - MOVB AX, ret+0(FP) // ERROR "invalid MOVB of ret\+0\(FP\); int is 8-byte value" - MOVW AX, ret+0(FP) // ERROR "invalid MOVW of ret\+0\(FP\); int is 8-byte value" - MOVL AX, ret+0(FP) // ERROR "invalid MOVL of ret\+0\(FP\); int is 8-byte value" - MOVQ AX, ret+0(FP) - MOVQ AX, ret+1(FP) // ERROR "invalid offset ret\+1\(FP\); expected ret\+0\(FP\)" - MOVQ AX, r+0(FP) // ERROR "unknown variable r; offset 0 is ret\+0\(FP\)" - RET - -TEXT ·returnbyte(SB),0,$0-9 - MOVQ x+0(FP), AX - MOVB AX, ret+8(FP) - MOVW AX, ret+8(FP) // ERROR "invalid MOVW of ret\+8\(FP\); byte is 1-byte value" - MOVL AX, ret+8(FP) // ERROR "invalid MOVL of ret\+8\(FP\); byte is 1-byte value" - MOVQ AX, ret+8(FP) // ERROR "invalid MOVQ of ret\+8\(FP\); byte is 1-byte value" - MOVB AX, ret+7(FP) // ERROR "invalid offset ret\+7\(FP\); expected ret\+8\(FP\)" - RET - -TEXT ·returnnamed(SB),0,$0-41 - MOVB x+0(FP), AX - MOVQ AX, r1+8(FP) - MOVW AX, r2+16(FP) - MOVQ AX, r3+24(FP) - MOVQ AX, r3_base+24(FP) - MOVQ AX, r3_len+32(FP) - MOVB AX, r4+40(FP) - MOVL AX, r1+8(FP) // ERROR "invalid MOVL of r1\+8\(FP\); int is 8-byte value" - RET - -TEXT ·returnintmissing(SB),0,$0-8 - RET // ERROR "RET without writing to 8-byte ret\+0\(FP\)" - - -// issue 15271 -TEXT ·f15271(SB), NOSPLIT, $0-4 - // Stick 123 into the low 32 bits of X0. - MOVQ $123, AX - PINSRD $0, AX, X0 - - // Return them. - PEXTRD $0, X0, x+0(FP) - RET - -// issue 17584 -TEXT ·f17584(SB), NOSPLIT, $12 - MOVSS x+0(FP), X0 - MOVSS y_real+4(FP), X0 - MOVSS y_imag+8(FP), X0 - RET diff --git a/libgo/go/cmd/vet/testdata/asm/asm2.s b/libgo/go/cmd/vet/testdata/asm/asm2.s deleted file mode 100644 index c33c02a70b2..00000000000 --- a/libgo/go/cmd/vet/testdata/asm/asm2.s +++ /dev/null @@ -1,257 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build 386 -// +build vet_test - -TEXT ·arg1(SB),0,$0-2 - MOVB x+0(FP), AX - MOVB y+1(FP), BX - MOVW x+0(FP), AX // ERROR "\[386\] arg1: invalid MOVW of x\+0\(FP\); int8 is 1-byte value" - MOVW y+1(FP), AX // ERROR "invalid MOVW of y\+1\(FP\); uint8 is 1-byte value" - MOVL x+0(FP), AX // ERROR "invalid MOVL of x\+0\(FP\); int8 is 1-byte value" - MOVL y+1(FP), AX // ERROR "invalid MOVL of y\+1\(FP\); uint8 is 1-byte value" - MOVQ x+0(FP), AX // ERROR "invalid MOVQ of x\+0\(FP\); int8 is 1-byte value" - MOVQ y+1(FP), AX // ERROR "invalid MOVQ of y\+1\(FP\); uint8 is 1-byte value" - MOVB x+1(FP), AX // ERROR "invalid offset x\+1\(FP\); expected x\+0\(FP\)" - MOVB y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+1\(FP\)" - TESTB x+0(FP), AX - TESTB y+1(FP), BX - TESTW x+0(FP), AX // ERROR "invalid TESTW of x\+0\(FP\); int8 is 1-byte value" - TESTW y+1(FP), AX // ERROR "invalid TESTW of y\+1\(FP\); uint8 is 1-byte value" - TESTL x+0(FP), AX // ERROR "invalid TESTL of x\+0\(FP\); int8 is 1-byte value" - TESTL y+1(FP), AX // ERROR "invalid TESTL of y\+1\(FP\); uint8 is 1-byte value" - TESTQ x+0(FP), AX // ERROR "invalid TESTQ of x\+0\(FP\); int8 is 1-byte value" - TESTQ y+1(FP), AX // ERROR "invalid TESTQ of y\+1\(FP\); uint8 is 1-byte value" - TESTB x+1(FP), AX // ERROR "invalid offset x\+1\(FP\); expected x\+0\(FP\)" - TESTB y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+1\(FP\)" - MOVB 4(SP), AX // ERROR "4\(SP\) should be x\+0\(FP\)" - MOVB 5(SP), AX // ERROR "5\(SP\) should be y\+1\(FP\)" - MOVB 6(SP), AX // ERROR "use of 6\(SP\) points beyond argument frame" - RET - -TEXT ·arg2(SB),0,$0-4 - MOVB x+0(FP), AX // ERROR "arg2: invalid MOVB of x\+0\(FP\); int16 is 2-byte value" - MOVB y+2(FP), AX // ERROR "invalid MOVB of y\+2\(FP\); uint16 is 2-byte value" - MOVW x+0(FP), AX - MOVW y+2(FP), BX - MOVL x+0(FP), AX // ERROR "invalid MOVL of x\+0\(FP\); int16 is 2-byte value" - MOVL y+2(FP), AX // ERROR "invalid MOVL of y\+2\(FP\); uint16 is 2-byte value" - MOVQ x+0(FP), AX // ERROR "invalid MOVQ of x\+0\(FP\); int16 is 2-byte value" - MOVQ y+2(FP), AX // ERROR "invalid MOVQ of y\+2\(FP\); uint16 is 2-byte value" - MOVW x+2(FP), AX // ERROR "invalid offset x\+2\(FP\); expected x\+0\(FP\)" - MOVW y+0(FP), AX // ERROR "invalid offset y\+0\(FP\); expected y\+2\(FP\)" - TESTB x+0(FP), AX // ERROR "invalid TESTB of x\+0\(FP\); int16 is 2-byte value" - TESTB y+2(FP), AX // ERROR "invalid TESTB of y\+2\(FP\); uint16 is 2-byte value" - TESTW x+0(FP), AX - TESTW y+2(FP), BX - TESTL x+0(FP), AX // ERROR "invalid TESTL of x\+0\(FP\); int16 is 2-byte value" - TESTL y+2(FP), AX // ERROR "invalid TESTL of y\+2\(FP\); uint16 is 2-byte value" - TESTQ x+0(FP), AX // ERROR "invalid TESTQ of x\+0\(FP\); int16 is 2-byte value" - TESTQ y+2(FP), AX // ERROR "invalid TESTQ of y\+2\(FP\); uint16 is 2-byte value" - TESTW x+2(FP), AX // ERROR "invalid offset x\+2\(FP\); expected x\+0\(FP\)" - TESTW y+0(FP), AX // ERROR "invalid offset y\+0\(FP\); expected y\+2\(FP\)" - RET - -TEXT ·arg4(SB),0,$0-2 // ERROR "arg4: wrong argument size 2; expected \$\.\.\.-8" - MOVB x+0(FP), AX // ERROR "invalid MOVB of x\+0\(FP\); int32 is 4-byte value" - MOVB y+4(FP), BX // ERROR "invalid MOVB of y\+4\(FP\); uint32 is 4-byte value" - MOVW x+0(FP), AX // ERROR "invalid MOVW of x\+0\(FP\); int32 is 4-byte value" - MOVW y+4(FP), AX // ERROR "invalid MOVW of y\+4\(FP\); uint32 is 4-byte value" - MOVL x+0(FP), AX - MOVL y+4(FP), AX - MOVQ x+0(FP), AX // ERROR "invalid MOVQ of x\+0\(FP\); int32 is 4-byte value" - MOVQ y+4(FP), AX // ERROR "invalid MOVQ of y\+4\(FP\); uint32 is 4-byte value" - MOVL x+4(FP), AX // ERROR "invalid offset x\+4\(FP\); expected x\+0\(FP\)" - MOVL y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+4\(FP\)" - TESTB x+0(FP), AX // ERROR "invalid TESTB of x\+0\(FP\); int32 is 4-byte value" - TESTB y+4(FP), BX // ERROR "invalid TESTB of y\+4\(FP\); uint32 is 4-byte value" - TESTW x+0(FP), AX // ERROR "invalid TESTW of x\+0\(FP\); int32 is 4-byte value" - TESTW y+4(FP), AX // ERROR "invalid TESTW of y\+4\(FP\); uint32 is 4-byte value" - TESTL x+0(FP), AX - TESTL y+4(FP), AX - TESTQ x+0(FP), AX // ERROR "invalid TESTQ of x\+0\(FP\); int32 is 4-byte value" - TESTQ y+4(FP), AX // ERROR "invalid TESTQ of y\+4\(FP\); uint32 is 4-byte value" - TESTL x+4(FP), AX // ERROR "invalid offset x\+4\(FP\); expected x\+0\(FP\)" - TESTL y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+4\(FP\)" - RET - -TEXT ·arg8(SB),7,$0-2 // ERROR "wrong argument size 2; expected \$\.\.\.-16" - MOVB x+0(FP), AX // ERROR "invalid MOVB of x\+0\(FP\); int64 is 8-byte value" - MOVB y+8(FP), BX // ERROR "invalid MOVB of y\+8\(FP\); uint64 is 8-byte value" - MOVW x+0(FP), AX // ERROR "invalid MOVW of x\+0\(FP\); int64 is 8-byte value" - MOVW y+8(FP), AX // ERROR "invalid MOVW of y\+8\(FP\); uint64 is 8-byte value" - MOVL x+0(FP), AX // ERROR "invalid MOVL of x\+0\(FP\); int64 is 8-byte value containing x_lo\+0\(FP\) and x_hi\+4\(FP\)" - MOVL x_lo+0(FP), AX - MOVL x_hi+4(FP), AX - MOVL y+8(FP), AX // ERROR "invalid MOVL of y\+8\(FP\); uint64 is 8-byte value containing y_lo\+8\(FP\) and y_hi\+12\(FP\)" - MOVL y_lo+8(FP), AX - MOVL y_hi+12(FP), AX - MOVQ x+0(FP), AX - MOVQ y+8(FP), AX - MOVQ x+8(FP), AX // ERROR "invalid offset x\+8\(FP\); expected x\+0\(FP\)" - MOVQ y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+8\(FP\)" - TESTB x+0(FP), AX // ERROR "invalid TESTB of x\+0\(FP\); int64 is 8-byte value" - TESTB y+8(FP), BX // ERROR "invalid TESTB of y\+8\(FP\); uint64 is 8-byte value" - TESTW x+0(FP), AX // ERROR "invalid TESTW of x\+0\(FP\); int64 is 8-byte value" - TESTW y+8(FP), AX // ERROR "invalid TESTW of y\+8\(FP\); uint64 is 8-byte value" - TESTL x+0(FP), AX // ERROR "invalid TESTL of x\+0\(FP\); int64 is 8-byte value containing x_lo\+0\(FP\) and x_hi\+4\(FP\)" - TESTL y+8(FP), AX // ERROR "invalid TESTL of y\+8\(FP\); uint64 is 8-byte value containing y_lo\+8\(FP\) and y_hi\+12\(FP\)" - TESTQ x+0(FP), AX - TESTQ y+8(FP), AX - TESTQ x+8(FP), AX // ERROR "invalid offset x\+8\(FP\); expected x\+0\(FP\)" - TESTQ y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+8\(FP\)" - RET - -TEXT ·argint(SB),0,$0-2 // ERROR "wrong argument size 2; expected \$\.\.\.-8" - MOVB x+0(FP), AX // ERROR "invalid MOVB of x\+0\(FP\); int is 4-byte value" - MOVB y+4(FP), BX // ERROR "invalid MOVB of y\+4\(FP\); uint is 4-byte value" - MOVW x+0(FP), AX // ERROR "invalid MOVW of x\+0\(FP\); int is 4-byte value" - MOVW y+4(FP), AX // ERROR "invalid MOVW of y\+4\(FP\); uint is 4-byte value" - MOVL x+0(FP), AX - MOVL y+4(FP), AX - MOVQ x+0(FP), AX // ERROR "invalid MOVQ of x\+0\(FP\); int is 4-byte value" - MOVQ y+4(FP), AX // ERROR "invalid MOVQ of y\+4\(FP\); uint is 4-byte value" - MOVQ x+4(FP), AX // ERROR "invalid offset x\+4\(FP\); expected x\+0\(FP\)" - MOVQ y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+4\(FP\)" - TESTB x+0(FP), AX // ERROR "invalid TESTB of x\+0\(FP\); int is 4-byte value" - TESTB y+4(FP), BX // ERROR "invalid TESTB of y\+4\(FP\); uint is 4-byte value" - TESTW x+0(FP), AX // ERROR "invalid TESTW of x\+0\(FP\); int is 4-byte value" - TESTW y+4(FP), AX // ERROR "invalid TESTW of y\+4\(FP\); uint is 4-byte value" - TESTL x+0(FP), AX - TESTL y+4(FP), AX - TESTQ x+0(FP), AX // ERROR "invalid TESTQ of x\+0\(FP\); int is 4-byte value" - TESTQ y+4(FP), AX // ERROR "invalid TESTQ of y\+4\(FP\); uint is 4-byte value" - TESTQ x+4(FP), AX // ERROR "invalid offset x\+4\(FP\); expected x\+0\(FP\)" - TESTQ y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+4\(FP\)" - RET - -TEXT ·argptr(SB),7,$0-2 // ERROR "wrong argument size 2; expected \$\.\.\.-20" - MOVB x+0(FP), AX // ERROR "invalid MOVB of x\+0\(FP\); \*byte is 4-byte value" - MOVB y+4(FP), BX // ERROR "invalid MOVB of y\+4\(FP\); \*byte is 4-byte value" - MOVW x+0(FP), AX // ERROR "invalid MOVW of x\+0\(FP\); \*byte is 4-byte value" - MOVW y+4(FP), AX // ERROR "invalid MOVW of y\+4\(FP\); \*byte is 4-byte value" - MOVL x+0(FP), AX - MOVL y+4(FP), AX - MOVQ x+0(FP), AX // ERROR "invalid MOVQ of x\+0\(FP\); \*byte is 4-byte value" - MOVQ y+4(FP), AX // ERROR "invalid MOVQ of y\+4\(FP\); \*byte is 4-byte value" - MOVQ x+4(FP), AX // ERROR "invalid offset x\+4\(FP\); expected x\+0\(FP\)" - MOVQ y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+4\(FP\)" - TESTB x+0(FP), AX // ERROR "invalid TESTB of x\+0\(FP\); \*byte is 4-byte value" - TESTB y+4(FP), BX // ERROR "invalid TESTB of y\+4\(FP\); \*byte is 4-byte value" - TESTW x+0(FP), AX // ERROR "invalid TESTW of x\+0\(FP\); \*byte is 4-byte value" - TESTW y+4(FP), AX // ERROR "invalid TESTW of y\+4\(FP\); \*byte is 4-byte value" - TESTL x+0(FP), AX - TESTL y+4(FP), AX - TESTQ x+0(FP), AX // ERROR "invalid TESTQ of x\+0\(FP\); \*byte is 4-byte value" - TESTQ y+4(FP), AX // ERROR "invalid TESTQ of y\+4\(FP\); \*byte is 4-byte value" - TESTQ x+4(FP), AX // ERROR "invalid offset x\+4\(FP\); expected x\+0\(FP\)" - TESTQ y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+4\(FP\)" - MOVW c+8(FP), AX // ERROR "invalid MOVW of c\+8\(FP\); chan int is 4-byte value" - MOVW m+12(FP), AX // ERROR "invalid MOVW of m\+12\(FP\); map\[int\]int is 4-byte value" - MOVW f+16(FP), AX // ERROR "invalid MOVW of f\+16\(FP\); func\(\) is 4-byte value" - RET - -TEXT ·argstring(SB),0,$16 // ERROR "wrong argument size 0; expected \$\.\.\.-16" - MOVW x+0(FP), AX // ERROR "invalid MOVW of x\+0\(FP\); string base is 4-byte value" - MOVL x+0(FP), AX - MOVQ x+0(FP), AX // ERROR "invalid MOVQ of x\+0\(FP\); string base is 4-byte value" - MOVW x_base+0(FP), AX // ERROR "invalid MOVW of x_base\+0\(FP\); string base is 4-byte value" - MOVL x_base+0(FP), AX - MOVQ x_base+0(FP), AX // ERROR "invalid MOVQ of x_base\+0\(FP\); string base is 4-byte value" - MOVW x_len+0(FP), AX // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+4\(FP\)" - MOVL x_len+0(FP), AX // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+4\(FP\)" - MOVQ x_len+0(FP), AX // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+4\(FP\)" - MOVW x_len+4(FP), AX // ERROR "invalid MOVW of x_len\+4\(FP\); string len is 4-byte value" - MOVL x_len+4(FP), AX - MOVQ x_len+4(FP), AX // ERROR "invalid MOVQ of x_len\+4\(FP\); string len is 4-byte value" - MOVQ y+0(FP), AX // ERROR "invalid offset y\+0\(FP\); expected y\+8\(FP\)" - MOVQ y_len+4(FP), AX // ERROR "invalid offset y_len\+4\(FP\); expected y_len\+12\(FP\)" - RET - -TEXT ·argslice(SB),0,$24 // ERROR "wrong argument size 0; expected \$\.\.\.-24" - MOVW x+0(FP), AX // ERROR "invalid MOVW of x\+0\(FP\); slice base is 4-byte value" - MOVL x+0(FP), AX - MOVQ x+0(FP), AX // ERROR "invalid MOVQ of x\+0\(FP\); slice base is 4-byte value" - MOVW x_base+0(FP), AX // ERROR "invalid MOVW of x_base\+0\(FP\); slice base is 4-byte value" - MOVL x_base+0(FP), AX - MOVQ x_base+0(FP), AX // ERROR "invalid MOVQ of x_base\+0\(FP\); slice base is 4-byte value" - MOVW x_len+0(FP), AX // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+4\(FP\)" - MOVL x_len+0(FP), AX // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+4\(FP\)" - MOVQ x_len+0(FP), AX // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+4\(FP\)" - MOVW x_len+4(FP), AX // ERROR "invalid MOVW of x_len\+4\(FP\); slice len is 4-byte value" - MOVL x_len+4(FP), AX - MOVQ x_len+4(FP), AX // ERROR "invalid MOVQ of x_len\+4\(FP\); slice len is 4-byte value" - MOVW x_cap+0(FP), AX // ERROR "invalid offset x_cap\+0\(FP\); expected x_cap\+8\(FP\)" - MOVL x_cap+0(FP), AX // ERROR "invalid offset x_cap\+0\(FP\); expected x_cap\+8\(FP\)" - MOVQ x_cap+0(FP), AX // ERROR "invalid offset x_cap\+0\(FP\); expected x_cap\+8\(FP\)" - MOVW x_cap+8(FP), AX // ERROR "invalid MOVW of x_cap\+8\(FP\); slice cap is 4-byte value" - MOVL x_cap+8(FP), AX - MOVQ x_cap+8(FP), AX // ERROR "invalid MOVQ of x_cap\+8\(FP\); slice cap is 4-byte value" - MOVQ y+0(FP), AX // ERROR "invalid offset y\+0\(FP\); expected y\+12\(FP\)" - MOVQ y_len+4(FP), AX // ERROR "invalid offset y_len\+4\(FP\); expected y_len\+16\(FP\)" - MOVQ y_cap+8(FP), AX // ERROR "invalid offset y_cap\+8\(FP\); expected y_cap\+20\(FP\)" - RET - -TEXT ·argiface(SB),0,$0-16 - MOVW x+0(FP), AX // ERROR "invalid MOVW of x\+0\(FP\); interface type is 4-byte value" - MOVL x+0(FP), AX - MOVQ x+0(FP), AX // ERROR "invalid MOVQ of x\+0\(FP\); interface type is 4-byte value" - MOVW x_type+0(FP), AX // ERROR "invalid MOVW of x_type\+0\(FP\); interface type is 4-byte value" - MOVL x_type+0(FP), AX - MOVQ x_type+0(FP), AX // ERROR "invalid MOVQ of x_type\+0\(FP\); interface type is 4-byte value" - MOVQ x_itable+0(FP), AX // ERROR "unknown variable x_itable; offset 0 is x_type\+0\(FP\)" - MOVQ x_itable+1(FP), AX // ERROR "unknown variable x_itable; offset 1 is x_type\+0\(FP\)" - MOVW x_data+0(FP), AX // ERROR "invalid offset x_data\+0\(FP\); expected x_data\+4\(FP\)" - MOVL x_data+0(FP), AX // ERROR "invalid offset x_data\+0\(FP\); expected x_data\+4\(FP\)" - MOVQ x_data+0(FP), AX // ERROR "invalid offset x_data\+0\(FP\); expected x_data\+4\(FP\)" - MOVW x_data+4(FP), AX // ERROR "invalid MOVW of x_data\+4\(FP\); interface data is 4-byte value" - MOVL x_data+4(FP), AX - MOVQ x_data+4(FP), AX // ERROR "invalid MOVQ of x_data\+4\(FP\); interface data is 4-byte value" - MOVW y+8(FP), AX // ERROR "invalid MOVW of y\+8\(FP\); interface itable is 4-byte value" - MOVL y+8(FP), AX - MOVQ y+8(FP), AX // ERROR "invalid MOVQ of y\+8\(FP\); interface itable is 4-byte value" - MOVW y_itable+8(FP), AX // ERROR "invalid MOVW of y_itable\+8\(FP\); interface itable is 4-byte value" - MOVL y_itable+8(FP), AX - MOVQ y_itable+8(FP), AX // ERROR "invalid MOVQ of y_itable\+8\(FP\); interface itable is 4-byte value" - MOVQ y_type+8(FP), AX // ERROR "unknown variable y_type; offset 8 is y_itable\+8\(FP\)" - MOVW y_data+8(FP), AX // ERROR "invalid offset y_data\+8\(FP\); expected y_data\+12\(FP\)" - MOVL y_data+8(FP), AX // ERROR "invalid offset y_data\+8\(FP\); expected y_data\+12\(FP\)" - MOVQ y_data+8(FP), AX // ERROR "invalid offset y_data\+8\(FP\); expected y_data\+12\(FP\)" - MOVW y_data+12(FP), AX // ERROR "invalid MOVW of y_data\+12\(FP\); interface data is 4-byte value" - MOVL y_data+12(FP), AX - MOVQ y_data+12(FP), AX // ERROR "invalid MOVQ of y_data\+12\(FP\); interface data is 4-byte value" - RET - -TEXT ·returnint(SB),0,$0-4 - MOVB AX, ret+0(FP) // ERROR "invalid MOVB of ret\+0\(FP\); int is 4-byte value" - MOVW AX, ret+0(FP) // ERROR "invalid MOVW of ret\+0\(FP\); int is 4-byte value" - MOVL AX, ret+0(FP) - MOVQ AX, ret+0(FP) // ERROR "invalid MOVQ of ret\+0\(FP\); int is 4-byte value" - MOVQ AX, ret+1(FP) // ERROR "invalid offset ret\+1\(FP\); expected ret\+0\(FP\)" - MOVQ AX, r+0(FP) // ERROR "unknown variable r; offset 0 is ret\+0\(FP\)" - RET - -TEXT ·returnbyte(SB),0,$0-5 - MOVL x+0(FP), AX - MOVB AX, ret+4(FP) - MOVW AX, ret+4(FP) // ERROR "invalid MOVW of ret\+4\(FP\); byte is 1-byte value" - MOVL AX, ret+4(FP) // ERROR "invalid MOVL of ret\+4\(FP\); byte is 1-byte value" - MOVQ AX, ret+4(FP) // ERROR "invalid MOVQ of ret\+4\(FP\); byte is 1-byte value" - MOVB AX, ret+3(FP) // ERROR "invalid offset ret\+3\(FP\); expected ret\+4\(FP\)" - RET - -TEXT ·returnnamed(SB),0,$0-21 - MOVB x+0(FP), AX - MOVL AX, r1+4(FP) - MOVW AX, r2+8(FP) - MOVL AX, r3+12(FP) - MOVL AX, r3_base+12(FP) - MOVL AX, r3_len+16(FP) - MOVB AX, r4+20(FP) - MOVQ AX, r1+4(FP) // ERROR "invalid MOVQ of r1\+4\(FP\); int is 4-byte value" - RET - -TEXT ·returnintmissing(SB),0,$0-4 - RET // ERROR "RET without writing to 4-byte ret\+0\(FP\)" diff --git a/libgo/go/cmd/vet/testdata/asm/asm3.s b/libgo/go/cmd/vet/testdata/asm/asm3.s deleted file mode 100644 index 83e53862d7d..00000000000 --- a/libgo/go/cmd/vet/testdata/asm/asm3.s +++ /dev/null @@ -1,192 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build arm -// +build vet_test - -TEXT ·arg1(SB),0,$0-2 - MOVB x+0(FP), AX - MOVB y+1(FP), BX - MOVH x+0(FP), AX // ERROR "\[arm\] arg1: invalid MOVH of x\+0\(FP\); int8 is 1-byte value" - MOVH y+1(FP), AX // ERROR "invalid MOVH of y\+1\(FP\); uint8 is 1-byte value" - MOVW x+0(FP), AX // ERROR "invalid MOVW of x\+0\(FP\); int8 is 1-byte value" - MOVW y+1(FP), AX // ERROR "invalid MOVW of y\+1\(FP\); uint8 is 1-byte value" - MOVB x+1(FP), AX // ERROR "invalid offset x\+1\(FP\); expected x\+0\(FP\)" - MOVB y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+1\(FP\)" - MOVB 8(R13), AX // ERROR "8\(R13\) should be x\+0\(FP\)" - MOVB 9(R13), AX // ERROR "9\(R13\) should be y\+1\(FP\)" - MOVB 10(R13), AX // ERROR "use of 10\(R13\) points beyond argument frame" - RET - -TEXT ·arg2(SB),0,$0-4 - MOVB x+0(FP), AX // ERROR "arg2: invalid MOVB of x\+0\(FP\); int16 is 2-byte value" - MOVB y+2(FP), AX // ERROR "invalid MOVB of y\+2\(FP\); uint16 is 2-byte value" - MOVH x+0(FP), AX - MOVH y+2(FP), BX - MOVW x+0(FP), AX // ERROR "invalid MOVW of x\+0\(FP\); int16 is 2-byte value" - MOVW y+2(FP), AX // ERROR "invalid MOVW of y\+2\(FP\); uint16 is 2-byte value" - MOVH x+2(FP), AX // ERROR "invalid offset x\+2\(FP\); expected x\+0\(FP\)" - MOVH y+0(FP), AX // ERROR "invalid offset y\+0\(FP\); expected y\+2\(FP\)" - RET - -TEXT ·arg4(SB),0,$0-2 // ERROR "arg4: wrong argument size 2; expected \$\.\.\.-8" - MOVB x+0(FP), AX // ERROR "invalid MOVB of x\+0\(FP\); int32 is 4-byte value" - MOVB y+4(FP), BX // ERROR "invalid MOVB of y\+4\(FP\); uint32 is 4-byte value" - MOVH x+0(FP), AX // ERROR "invalid MOVH of x\+0\(FP\); int32 is 4-byte value" - MOVH y+4(FP), AX // ERROR "invalid MOVH of y\+4\(FP\); uint32 is 4-byte value" - MOVW x+0(FP), AX - MOVW y+4(FP), AX - MOVW x+4(FP), AX // ERROR "invalid offset x\+4\(FP\); expected x\+0\(FP\)" - MOVW y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+4\(FP\)" - RET - -TEXT ·arg8(SB),7,$0-2 // ERROR "wrong argument size 2; expected \$\.\.\.-16" - MOVB x+0(FP), AX // ERROR "invalid MOVB of x\+0\(FP\); int64 is 8-byte value" - MOVB y+8(FP), BX // ERROR "invalid MOVB of y\+8\(FP\); uint64 is 8-byte value" - MOVH x+0(FP), AX // ERROR "invalid MOVH of x\+0\(FP\); int64 is 8-byte value" - MOVH y+8(FP), AX // ERROR "invalid MOVH of y\+8\(FP\); uint64 is 8-byte value" - MOVW x+0(FP), AX // ERROR "invalid MOVW of x\+0\(FP\); int64 is 8-byte value containing x_lo\+0\(FP\) and x_hi\+4\(FP\)" - MOVW x_lo+0(FP), AX - MOVW x_hi+4(FP), AX - MOVW y+8(FP), AX // ERROR "invalid MOVW of y\+8\(FP\); uint64 is 8-byte value containing y_lo\+8\(FP\) and y_hi\+12\(FP\)" - MOVW y_lo+8(FP), AX - MOVW y_hi+12(FP), AX - MOVQ x+0(FP), AX - MOVQ y+8(FP), AX - MOVQ x+8(FP), AX // ERROR "invalid offset x\+8\(FP\); expected x\+0\(FP\)" - MOVQ y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+8\(FP\)" - RET - -TEXT ·argint(SB),0,$0-2 // ERROR "wrong argument size 2; expected \$\.\.\.-8" - MOVB x+0(FP), AX // ERROR "invalid MOVB of x\+0\(FP\); int is 4-byte value" - MOVB y+4(FP), BX // ERROR "invalid MOVB of y\+4\(FP\); uint is 4-byte value" - MOVH x+0(FP), AX // ERROR "invalid MOVH of x\+0\(FP\); int is 4-byte value" - MOVH y+4(FP), AX // ERROR "invalid MOVH of y\+4\(FP\); uint is 4-byte value" - MOVW x+0(FP), AX - MOVW y+4(FP), AX - MOVQ x+4(FP), AX // ERROR "invalid offset x\+4\(FP\); expected x\+0\(FP\)" - MOVQ y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+4\(FP\)" - RET - -TEXT ·argptr(SB),7,$0-2 // ERROR "wrong argument size 2; expected \$\.\.\.-20" - MOVB x+0(FP), AX // ERROR "invalid MOVB of x\+0\(FP\); \*byte is 4-byte value" - MOVB y+4(FP), BX // ERROR "invalid MOVB of y\+4\(FP\); \*byte is 4-byte value" - MOVH x+0(FP), AX // ERROR "invalid MOVH of x\+0\(FP\); \*byte is 4-byte value" - MOVH y+4(FP), AX // ERROR "invalid MOVH of y\+4\(FP\); \*byte is 4-byte value" - MOVW x+0(FP), AX - MOVW y+4(FP), AX - MOVQ x+4(FP), AX // ERROR "invalid offset x\+4\(FP\); expected x\+0\(FP\)" - MOVQ y+2(FP), AX // ERROR "invalid offset y\+2\(FP\); expected y\+4\(FP\)" - MOVH c+8(FP), AX // ERROR "invalid MOVH of c\+8\(FP\); chan int is 4-byte value" - MOVH m+12(FP), AX // ERROR "invalid MOVH of m\+12\(FP\); map\[int\]int is 4-byte value" - MOVH f+16(FP), AX // ERROR "invalid MOVH of f\+16\(FP\); func\(\) is 4-byte value" - RET - -TEXT ·argstring(SB),0,$16 // ERROR "wrong argument size 0; expected \$\.\.\.-16" - MOVH x+0(FP), AX // ERROR "invalid MOVH of x\+0\(FP\); string base is 4-byte value" - MOVW x+0(FP), AX - MOVH x_base+0(FP), AX // ERROR "invalid MOVH of x_base\+0\(FP\); string base is 4-byte value" - MOVW x_base+0(FP), AX - MOVH x_len+0(FP), AX // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+4\(FP\)" - MOVW x_len+0(FP), AX // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+4\(FP\)" - MOVQ x_len+0(FP), AX // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+4\(FP\)" - MOVH x_len+4(FP), AX // ERROR "invalid MOVH of x_len\+4\(FP\); string len is 4-byte value" - MOVW x_len+4(FP), AX - MOVQ y+0(FP), AX // ERROR "invalid offset y\+0\(FP\); expected y\+8\(FP\)" - MOVQ y_len+4(FP), AX // ERROR "invalid offset y_len\+4\(FP\); expected y_len\+12\(FP\)" - RET - -TEXT ·argslice(SB),0,$24 // ERROR "wrong argument size 0; expected \$\.\.\.-24" - MOVH x+0(FP), AX // ERROR "invalid MOVH of x\+0\(FP\); slice base is 4-byte value" - MOVW x+0(FP), AX - MOVH x_base+0(FP), AX // ERROR "invalid MOVH of x_base\+0\(FP\); slice base is 4-byte value" - MOVW x_base+0(FP), AX - MOVH x_len+0(FP), AX // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+4\(FP\)" - MOVW x_len+0(FP), AX // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+4\(FP\)" - MOVQ x_len+0(FP), AX // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+4\(FP\)" - MOVH x_len+4(FP), AX // ERROR "invalid MOVH of x_len\+4\(FP\); slice len is 4-byte value" - MOVW x_len+4(FP), AX - MOVH x_cap+0(FP), AX // ERROR "invalid offset x_cap\+0\(FP\); expected x_cap\+8\(FP\)" - MOVW x_cap+0(FP), AX // ERROR "invalid offset x_cap\+0\(FP\); expected x_cap\+8\(FP\)" - MOVQ x_cap+0(FP), AX // ERROR "invalid offset x_cap\+0\(FP\); expected x_cap\+8\(FP\)" - MOVH x_cap+8(FP), AX // ERROR "invalid MOVH of x_cap\+8\(FP\); slice cap is 4-byte value" - MOVW x_cap+8(FP), AX - MOVQ y+0(FP), AX // ERROR "invalid offset y\+0\(FP\); expected y\+12\(FP\)" - MOVQ y_len+4(FP), AX // ERROR "invalid offset y_len\+4\(FP\); expected y_len\+16\(FP\)" - MOVQ y_cap+8(FP), AX // ERROR "invalid offset y_cap\+8\(FP\); expected y_cap\+20\(FP\)" - RET - -TEXT ·argiface(SB),0,$0-16 - MOVH x+0(FP), AX // ERROR "invalid MOVH of x\+0\(FP\); interface type is 4-byte value" - MOVW x+0(FP), AX - MOVH x_type+0(FP), AX // ERROR "invalid MOVH of x_type\+0\(FP\); interface type is 4-byte value" - MOVW x_type+0(FP), AX - MOVQ x_itable+0(FP), AX // ERROR "unknown variable x_itable; offset 0 is x_type\+0\(FP\)" - MOVQ x_itable+1(FP), AX // ERROR "unknown variable x_itable; offset 1 is x_type\+0\(FP\)" - MOVH x_data+0(FP), AX // ERROR "invalid offset x_data\+0\(FP\); expected x_data\+4\(FP\)" - MOVW x_data+0(FP), AX // ERROR "invalid offset x_data\+0\(FP\); expected x_data\+4\(FP\)" - MOVQ x_data+0(FP), AX // ERROR "invalid offset x_data\+0\(FP\); expected x_data\+4\(FP\)" - MOVH x_data+4(FP), AX // ERROR "invalid MOVH of x_data\+4\(FP\); interface data is 4-byte value" - MOVW x_data+4(FP), AX - MOVH y+8(FP), AX // ERROR "invalid MOVH of y\+8\(FP\); interface itable is 4-byte value" - MOVW y+8(FP), AX - MOVH y_itable+8(FP), AX // ERROR "invalid MOVH of y_itable\+8\(FP\); interface itable is 4-byte value" - MOVW y_itable+8(FP), AX - MOVQ y_type+8(FP), AX // ERROR "unknown variable y_type; offset 8 is y_itable\+8\(FP\)" - MOVH y_data+8(FP), AX // ERROR "invalid offset y_data\+8\(FP\); expected y_data\+12\(FP\)" - MOVW y_data+8(FP), AX // ERROR "invalid offset y_data\+8\(FP\); expected y_data\+12\(FP\)" - MOVQ y_data+8(FP), AX // ERROR "invalid offset y_data\+8\(FP\); expected y_data\+12\(FP\)" - MOVH y_data+12(FP), AX // ERROR "invalid MOVH of y_data\+12\(FP\); interface data is 4-byte value" - MOVW y_data+12(FP), AX - RET - -TEXT ·returnint(SB),0,$0-4 - MOVB AX, ret+0(FP) // ERROR "invalid MOVB of ret\+0\(FP\); int is 4-byte value" - MOVH AX, ret+0(FP) // ERROR "invalid MOVH of ret\+0\(FP\); int is 4-byte value" - MOVW AX, ret+0(FP) - MOVQ AX, ret+1(FP) // ERROR "invalid offset ret\+1\(FP\); expected ret\+0\(FP\)" - MOVQ AX, r+0(FP) // ERROR "unknown variable r; offset 0 is ret\+0\(FP\)" - RET - -TEXT ·returnbyte(SB),0,$0-5 - MOVW x+0(FP), AX - MOVB AX, ret+4(FP) - MOVH AX, ret+4(FP) // ERROR "invalid MOVH of ret\+4\(FP\); byte is 1-byte value" - MOVW AX, ret+4(FP) // ERROR "invalid MOVW of ret\+4\(FP\); byte is 1-byte value" - MOVB AX, ret+3(FP) // ERROR "invalid offset ret\+3\(FP\); expected ret\+4\(FP\)" - RET - -TEXT ·returnnamed(SB),0,$0-21 - MOVB x+0(FP), AX - MOVW AX, r1+4(FP) - MOVH AX, r2+8(FP) - MOVW AX, r3+12(FP) - MOVW AX, r3_base+12(FP) - MOVW AX, r3_len+16(FP) - MOVB AX, r4+20(FP) - MOVB AX, r1+4(FP) // ERROR "invalid MOVB of r1\+4\(FP\); int is 4-byte value" - RET - -TEXT ·returnintmissing(SB),0,$0-4 - RET // ERROR "RET without writing to 4-byte ret\+0\(FP\)" - -TEXT ·leaf(SB),0,$-4-12 - MOVW x+0(FP), AX - MOVW y+4(FP), AX - MOVW AX, ret+8(FP) - RET - -TEXT ·noframe1(SB),0,$0-4 - MOVW 0(R13), AX // Okay; our saved LR - MOVW 4(R13), AX // Okay; caller's saved LR - MOVW x+8(R13), AX // Okay; x argument - MOVW 12(R13), AX // ERROR "use of 12\(R13\) points beyond argument frame" - RET - -TEXT ·noframe2(SB),NOFRAME,$0-4 - MOVW 0(R13), AX // Okay; caller's saved LR - MOVW x+4(R13), AX // Okay; x argument - MOVW 8(R13), AX // ERROR "use of 8\(R13\) points beyond argument frame" - MOVW 12(R13), AX // ERROR "use of 12\(R13\) points beyond argument frame" - RET diff --git a/libgo/go/cmd/vet/testdata/asm/asm4.s b/libgo/go/cmd/vet/testdata/asm/asm4.s deleted file mode 100644 index 044b050b6b9..00000000000 --- a/libgo/go/cmd/vet/testdata/asm/asm4.s +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build amd64 -// +build vet_test - -// Test cases for symbolic NOSPLIT etc. on TEXT symbols. - -TEXT ·noprof(SB),NOPROF,$0-8 - RET - -TEXT ·dupok(SB),DUPOK,$0-8 - RET - -TEXT ·nosplit(SB),NOSPLIT,$0 - RET - -TEXT ·rodata(SB),RODATA,$0-8 - RET - -TEXT ·noptr(SB),NOPTR|NOSPLIT,$0 - RET - -TEXT ·wrapper(SB),WRAPPER,$0-8 - RET diff --git a/libgo/go/cmd/vet/testdata/asm/asm5.s b/libgo/go/cmd/vet/testdata/asm/asm5.s deleted file mode 100644 index c6176e9669f..00000000000 --- a/libgo/go/cmd/vet/testdata/asm/asm5.s +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build mips64 -// +build vet_test - -TEXT ·arg1(SB),0,$0-2 - MOVB x+0(FP), R1 - MOVBU y+1(FP), R2 - MOVH x+0(FP), R1 // ERROR "\[mips64\] arg1: invalid MOVH of x\+0\(FP\); int8 is 1-byte value" - MOVHU y+1(FP), R1 // ERROR "invalid MOVHU of y\+1\(FP\); uint8 is 1-byte value" - MOVW x+0(FP), R1 // ERROR "invalid MOVW of x\+0\(FP\); int8 is 1-byte value" - MOVWU y+1(FP), R1 // ERROR "invalid MOVWU of y\+1\(FP\); uint8 is 1-byte value" - MOVV x+0(FP), R1 // ERROR "invalid MOVV of x\+0\(FP\); int8 is 1-byte value" - MOVV y+1(FP), R1 // ERROR "invalid MOVV of y\+1\(FP\); uint8 is 1-byte value" - MOVB x+1(FP), R1 // ERROR "invalid offset x\+1\(FP\); expected x\+0\(FP\)" - MOVBU y+2(FP), R1 // ERROR "invalid offset y\+2\(FP\); expected y\+1\(FP\)" - MOVB 16(R29), R1 // ERROR "16\(R29\) should be x\+0\(FP\)" - MOVB 17(R29), R1 // ERROR "17\(R29\) should be y\+1\(FP\)" - MOVB 18(R29), R1 // ERROR "use of 18\(R29\) points beyond argument frame" - RET - -TEXT ·arg2(SB),0,$0-4 - MOVBU x+0(FP), R1 // ERROR "arg2: invalid MOVBU of x\+0\(FP\); int16 is 2-byte value" - MOVB y+2(FP), R1 // ERROR "invalid MOVB of y\+2\(FP\); uint16 is 2-byte value" - MOVHU x+0(FP), R1 - MOVH y+2(FP), R2 - MOVWU x+0(FP), R1 // ERROR "invalid MOVWU of x\+0\(FP\); int16 is 2-byte value" - MOVW y+2(FP), R1 // ERROR "invalid MOVW of y\+2\(FP\); uint16 is 2-byte value" - MOVV x+0(FP), R1 // ERROR "invalid MOVV of x\+0\(FP\); int16 is 2-byte value" - MOVV y+2(FP), R1 // ERROR "invalid MOVV of y\+2\(FP\); uint16 is 2-byte value" - MOVHU x+2(FP), R1 // ERROR "invalid offset x\+2\(FP\); expected x\+0\(FP\)" - MOVH y+0(FP), R1 // ERROR "invalid offset y\+0\(FP\); expected y\+2\(FP\)" - RET - -TEXT ·arg4(SB),0,$0-2 // ERROR "arg4: wrong argument size 2; expected \$\.\.\.-8" - MOVB x+0(FP), R1 // ERROR "invalid MOVB of x\+0\(FP\); int32 is 4-byte value" - MOVB y+4(FP), R2 // ERROR "invalid MOVB of y\+4\(FP\); uint32 is 4-byte value" - MOVH x+0(FP), R1 // ERROR "invalid MOVH of x\+0\(FP\); int32 is 4-byte value" - MOVH y+4(FP), R1 // ERROR "invalid MOVH of y\+4\(FP\); uint32 is 4-byte value" - MOVW x+0(FP), R1 - MOVW y+4(FP), R1 - MOVV x+0(FP), R1 // ERROR "invalid MOVV of x\+0\(FP\); int32 is 4-byte value" - MOVV y+4(FP), R1 // ERROR "invalid MOVV of y\+4\(FP\); uint32 is 4-byte value" - MOVW x+4(FP), R1 // ERROR "invalid offset x\+4\(FP\); expected x\+0\(FP\)" - MOVW y+2(FP), R1 // ERROR "invalid offset y\+2\(FP\); expected y\+4\(FP\)" - RET - -TEXT ·arg8(SB),7,$0-2 // ERROR "wrong argument size 2; expected \$\.\.\.-16" - MOVB x+0(FP), R1 // ERROR "invalid MOVB of x\+0\(FP\); int64 is 8-byte value" - MOVB y+8(FP), R2 // ERROR "invalid MOVB of y\+8\(FP\); uint64 is 8-byte value" - MOVH x+0(FP), R1 // ERROR "invalid MOVH of x\+0\(FP\); int64 is 8-byte value" - MOVH y+8(FP), R1 // ERROR "invalid MOVH of y\+8\(FP\); uint64 is 8-byte value" - MOVW x+0(FP), R1 // ERROR "invalid MOVW of x\+0\(FP\); int64 is 8-byte value" - MOVW y+8(FP), R1 // ERROR "invalid MOVW of y\+8\(FP\); uint64 is 8-byte value" - MOVV x+0(FP), R1 - MOVV y+8(FP), R1 - MOVV x+8(FP), R1 // ERROR "invalid offset x\+8\(FP\); expected x\+0\(FP\)" - MOVV y+2(FP), R1 // ERROR "invalid offset y\+2\(FP\); expected y\+8\(FP\)" - RET - -TEXT ·argint(SB),0,$0-2 // ERROR "wrong argument size 2; expected \$\.\.\.-16" - MOVB x+0(FP), R1 // ERROR "invalid MOVB of x\+0\(FP\); int is 8-byte value" - MOVB y+8(FP), R2 // ERROR "invalid MOVB of y\+8\(FP\); uint is 8-byte value" - MOVH x+0(FP), R1 // ERROR "invalid MOVH of x\+0\(FP\); int is 8-byte value" - MOVH y+8(FP), R1 // ERROR "invalid MOVH of y\+8\(FP\); uint is 8-byte value" - MOVW x+0(FP), R1 // ERROR "invalid MOVW of x\+0\(FP\); int is 8-byte value" - MOVW y+8(FP), R1 // ERROR "invalid MOVW of y\+8\(FP\); uint is 8-byte value" - MOVV x+0(FP), R1 - MOVV y+8(FP), R1 - MOVV x+8(FP), R1 // ERROR "invalid offset x\+8\(FP\); expected x\+0\(FP\)" - MOVV y+2(FP), R1 // ERROR "invalid offset y\+2\(FP\); expected y\+8\(FP\)" - RET - -TEXT ·argptr(SB),7,$0-2 // ERROR "wrong argument size 2; expected \$\.\.\.-40" - MOVB x+0(FP), R1 // ERROR "invalid MOVB of x\+0\(FP\); \*byte is 8-byte value" - MOVB y+8(FP), R2 // ERROR "invalid MOVB of y\+8\(FP\); \*byte is 8-byte value" - MOVH x+0(FP), R1 // ERROR "invalid MOVH of x\+0\(FP\); \*byte is 8-byte value" - MOVH y+8(FP), R1 // ERROR "invalid MOVH of y\+8\(FP\); \*byte is 8-byte value" - MOVW x+0(FP), R1 // ERROR "invalid MOVW of x\+0\(FP\); \*byte is 8-byte value" - MOVW y+8(FP), R1 // ERROR "invalid MOVW of y\+8\(FP\); \*byte is 8-byte value" - MOVV x+0(FP), R1 - MOVV y+8(FP), R1 - MOVV x+8(FP), R1 // ERROR "invalid offset x\+8\(FP\); expected x\+0\(FP\)" - MOVV y+2(FP), R1 // ERROR "invalid offset y\+2\(FP\); expected y\+8\(FP\)" - MOVW c+16(FP), R1 // ERROR "invalid MOVW of c\+16\(FP\); chan int is 8-byte value" - MOVW m+24(FP), R1 // ERROR "invalid MOVW of m\+24\(FP\); map\[int\]int is 8-byte value" - MOVW f+32(FP), R1 // ERROR "invalid MOVW of f\+32\(FP\); func\(\) is 8-byte value" - RET - -TEXT ·argstring(SB),0,$32 // ERROR "wrong argument size 0; expected \$\.\.\.-32" - MOVH x+0(FP), R1 // ERROR "invalid MOVH of x\+0\(FP\); string base is 8-byte value" - MOVW x+0(FP), R1 // ERROR "invalid MOVW of x\+0\(FP\); string base is 8-byte value" - MOVV x+0(FP), R1 - MOVH x_base+0(FP), R1 // ERROR "invalid MOVH of x_base\+0\(FP\); string base is 8-byte value" - MOVW x_base+0(FP), R1 // ERROR "invalid MOVW of x_base\+0\(FP\); string base is 8-byte value" - MOVV x_base+0(FP), R1 - MOVH x_len+0(FP), R1 // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+8\(FP\)" - MOVW x_len+0(FP), R1 // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+8\(FP\)" - MOVV x_len+0(FP), R1 // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+8\(FP\)" - MOVH x_len+8(FP), R1 // ERROR "invalid MOVH of x_len\+8\(FP\); string len is 8-byte value" - MOVW x_len+8(FP), R1 // ERROR "invalid MOVW of x_len\+8\(FP\); string len is 8-byte value" - MOVV x_len+8(FP), R1 - MOVV y+0(FP), R1 // ERROR "invalid offset y\+0\(FP\); expected y\+16\(FP\)" - MOVV y_len+8(FP), R1 // ERROR "invalid offset y_len\+8\(FP\); expected y_len\+24\(FP\)" - RET - -TEXT ·argslice(SB),0,$48 // ERROR "wrong argument size 0; expected \$\.\.\.-48" - MOVH x+0(FP), R1 // ERROR "invalid MOVH of x\+0\(FP\); slice base is 8-byte value" - MOVW x+0(FP), R1 // ERROR "invalid MOVW of x\+0\(FP\); slice base is 8-byte value" - MOVV x+0(FP), R1 - MOVH x_base+0(FP), R1 // ERROR "invalid MOVH of x_base\+0\(FP\); slice base is 8-byte value" - MOVW x_base+0(FP), R1 // ERROR "invalid MOVW of x_base\+0\(FP\); slice base is 8-byte value" - MOVV x_base+0(FP), R1 - MOVH x_len+0(FP), R1 // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+8\(FP\)" - MOVW x_len+0(FP), R1 // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+8\(FP\)" - MOVV x_len+0(FP), R1 // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+8\(FP\)" - MOVH x_len+8(FP), R1 // ERROR "invalid MOVH of x_len\+8\(FP\); slice len is 8-byte value" - MOVW x_len+8(FP), R1 // ERROR "invalid MOVW of x_len\+8\(FP\); slice len is 8-byte value" - MOVV x_len+8(FP), R1 - MOVH x_cap+0(FP), R1 // ERROR "invalid offset x_cap\+0\(FP\); expected x_cap\+16\(FP\)" - MOVW x_cap+0(FP), R1 // ERROR "invalid offset x_cap\+0\(FP\); expected x_cap\+16\(FP\)" - MOVV x_cap+0(FP), R1 // ERROR "invalid offset x_cap\+0\(FP\); expected x_cap\+16\(FP\)" - MOVH x_cap+16(FP), R1 // ERROR "invalid MOVH of x_cap\+16\(FP\); slice cap is 8-byte value" - MOVW x_cap+16(FP), R1 // ERROR "invalid MOVW of x_cap\+16\(FP\); slice cap is 8-byte value" - MOVV x_cap+16(FP), R1 - MOVV y+0(FP), R1 // ERROR "invalid offset y\+0\(FP\); expected y\+24\(FP\)" - MOVV y_len+8(FP), R1 // ERROR "invalid offset y_len\+8\(FP\); expected y_len\+32\(FP\)" - MOVV y_cap+16(FP), R1 // ERROR "invalid offset y_cap\+16\(FP\); expected y_cap\+40\(FP\)" - RET - -TEXT ·argiface(SB),0,$0-32 - MOVH x+0(FP), R1 // ERROR "invalid MOVH of x\+0\(FP\); interface type is 8-byte value" - MOVW x+0(FP), R1 // ERROR "invalid MOVW of x\+0\(FP\); interface type is 8-byte value" - MOVV x+0(FP), R1 - MOVH x_type+0(FP), R1 // ERROR "invalid MOVH of x_type\+0\(FP\); interface type is 8-byte value" - MOVW x_type+0(FP), R1 // ERROR "invalid MOVW of x_type\+0\(FP\); interface type is 8-byte value" - MOVV x_type+0(FP), R1 - MOVV x_itable+0(FP), R1 // ERROR "unknown variable x_itable; offset 0 is x_type\+0\(FP\)" - MOVV x_itable+1(FP), R1 // ERROR "unknown variable x_itable; offset 1 is x_type\+0\(FP\)" - MOVH x_data+0(FP), R1 // ERROR "invalid offset x_data\+0\(FP\); expected x_data\+8\(FP\)" - MOVW x_data+0(FP), R1 // ERROR "invalid offset x_data\+0\(FP\); expected x_data\+8\(FP\)" - MOVV x_data+0(FP), R1 // ERROR "invalid offset x_data\+0\(FP\); expected x_data\+8\(FP\)" - MOVH x_data+8(FP), R1 // ERROR "invalid MOVH of x_data\+8\(FP\); interface data is 8-byte value" - MOVW x_data+8(FP), R1 // ERROR "invalid MOVW of x_data\+8\(FP\); interface data is 8-byte value" - MOVV x_data+8(FP), R1 - MOVH y+16(FP), R1 // ERROR "invalid MOVH of y\+16\(FP\); interface itable is 8-byte value" - MOVW y+16(FP), R1 // ERROR "invalid MOVW of y\+16\(FP\); interface itable is 8-byte value" - MOVV y+16(FP), R1 - MOVH y_itable+16(FP), R1 // ERROR "invalid MOVH of y_itable\+16\(FP\); interface itable is 8-byte value" - MOVW y_itable+16(FP), R1 // ERROR "invalid MOVW of y_itable\+16\(FP\); interface itable is 8-byte value" - MOVV y_itable+16(FP), R1 - MOVV y_type+16(FP), R1 // ERROR "unknown variable y_type; offset 16 is y_itable\+16\(FP\)" - MOVH y_data+16(FP), R1 // ERROR "invalid offset y_data\+16\(FP\); expected y_data\+24\(FP\)" - MOVW y_data+16(FP), R1 // ERROR "invalid offset y_data\+16\(FP\); expected y_data\+24\(FP\)" - MOVV y_data+16(FP), R1 // ERROR "invalid offset y_data\+16\(FP\); expected y_data\+24\(FP\)" - MOVH y_data+24(FP), R1 // ERROR "invalid MOVH of y_data\+24\(FP\); interface data is 8-byte value" - MOVW y_data+24(FP), R1 // ERROR "invalid MOVW of y_data\+24\(FP\); interface data is 8-byte value" - MOVV y_data+24(FP), R1 - RET - -TEXT ·returnint(SB),0,$0-8 - MOVB R1, ret+0(FP) // ERROR "invalid MOVB of ret\+0\(FP\); int is 8-byte value" - MOVH R1, ret+0(FP) // ERROR "invalid MOVH of ret\+0\(FP\); int is 8-byte value" - MOVW R1, ret+0(FP) // ERROR "invalid MOVW of ret\+0\(FP\); int is 8-byte value" - MOVV R1, ret+0(FP) - MOVV R1, ret+1(FP) // ERROR "invalid offset ret\+1\(FP\); expected ret\+0\(FP\)" - MOVV R1, r+0(FP) // ERROR "unknown variable r; offset 0 is ret\+0\(FP\)" - RET - -TEXT ·returnbyte(SB),0,$0-9 - MOVV x+0(FP), R1 - MOVB R1, ret+8(FP) - MOVH R1, ret+8(FP) // ERROR "invalid MOVH of ret\+8\(FP\); byte is 1-byte value" - MOVW R1, ret+8(FP) // ERROR "invalid MOVW of ret\+8\(FP\); byte is 1-byte value" - MOVV R1, ret+8(FP) // ERROR "invalid MOVV of ret\+8\(FP\); byte is 1-byte value" - MOVB R1, ret+7(FP) // ERROR "invalid offset ret\+7\(FP\); expected ret\+8\(FP\)" - RET - -TEXT ·returnnamed(SB),0,$0-41 - MOVB x+0(FP), R1 - MOVV R1, r1+8(FP) - MOVH R1, r2+16(FP) - MOVV R1, r3+24(FP) - MOVV R1, r3_base+24(FP) - MOVV R1, r3_len+32(FP) - MOVB R1, r4+40(FP) - MOVW R1, r1+8(FP) // ERROR "invalid MOVW of r1\+8\(FP\); int is 8-byte value" - RET - -TEXT ·returnintmissing(SB),0,$0-8 - RET // ERROR "RET without writing to 8-byte ret\+0\(FP\)" diff --git a/libgo/go/cmd/vet/testdata/asm/asm6.s b/libgo/go/cmd/vet/testdata/asm/asm6.s deleted file mode 100644 index 4e85ab3dcf9..00000000000 --- a/libgo/go/cmd/vet/testdata/asm/asm6.s +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build s390x -// +build vet_test - -TEXT ·arg1(SB),0,$0-2 - MOVB x+0(FP), R1 - MOVBZ y+1(FP), R2 - MOVH x+0(FP), R1 // ERROR "\[s390x\] arg1: invalid MOVH of x\+0\(FP\); int8 is 1-byte value" - MOVHZ y+1(FP), R1 // ERROR "invalid MOVHZ of y\+1\(FP\); uint8 is 1-byte value" - MOVW x+0(FP), R1 // ERROR "invalid MOVW of x\+0\(FP\); int8 is 1-byte value" - MOVWZ y+1(FP), R1 // ERROR "invalid MOVWZ of y\+1\(FP\); uint8 is 1-byte value" - MOVD x+0(FP), R1 // ERROR "invalid MOVD of x\+0\(FP\); int8 is 1-byte value" - MOVD y+1(FP), R1 // ERROR "invalid MOVD of y\+1\(FP\); uint8 is 1-byte value" - MOVB x+1(FP), R1 // ERROR "invalid offset x\+1\(FP\); expected x\+0\(FP\)" - MOVBZ y+2(FP), R1 // ERROR "invalid offset y\+2\(FP\); expected y\+1\(FP\)" - MOVB 16(R15), R1 // ERROR "16\(R15\) should be x\+0\(FP\)" - MOVB 17(R15), R1 // ERROR "17\(R15\) should be y\+1\(FP\)" - MOVB 18(R15), R1 // ERROR "use of 18\(R15\) points beyond argument frame" - RET - -TEXT ·arg2(SB),0,$0-4 - MOVBZ x+0(FP), R1 // ERROR "arg2: invalid MOVBZ of x\+0\(FP\); int16 is 2-byte value" - MOVB y+2(FP), R1 // ERROR "invalid MOVB of y\+2\(FP\); uint16 is 2-byte value" - MOVHZ x+0(FP), R1 - MOVH y+2(FP), R2 - MOVWZ x+0(FP), R1 // ERROR "invalid MOVWZ of x\+0\(FP\); int16 is 2-byte value" - MOVW y+2(FP), R1 // ERROR "invalid MOVW of y\+2\(FP\); uint16 is 2-byte value" - MOVD x+0(FP), R1 // ERROR "invalid MOVD of x\+0\(FP\); int16 is 2-byte value" - MOVD y+2(FP), R1 // ERROR "invalid MOVD of y\+2\(FP\); uint16 is 2-byte value" - MOVHZ x+2(FP), R1 // ERROR "invalid offset x\+2\(FP\); expected x\+0\(FP\)" - MOVH y+0(FP), R1 // ERROR "invalid offset y\+0\(FP\); expected y\+2\(FP\)" - RET - -TEXT ·arg4(SB),0,$0-2 // ERROR "arg4: wrong argument size 2; expected \$\.\.\.-8" - MOVB x+0(FP), R1 // ERROR "invalid MOVB of x\+0\(FP\); int32 is 4-byte value" - MOVB y+4(FP), R2 // ERROR "invalid MOVB of y\+4\(FP\); uint32 is 4-byte value" - MOVH x+0(FP), R1 // ERROR "invalid MOVH of x\+0\(FP\); int32 is 4-byte value" - MOVH y+4(FP), R1 // ERROR "invalid MOVH of y\+4\(FP\); uint32 is 4-byte value" - MOVW x+0(FP), R1 - MOVW y+4(FP), R1 - MOVD x+0(FP), R1 // ERROR "invalid MOVD of x\+0\(FP\); int32 is 4-byte value" - MOVD y+4(FP), R1 // ERROR "invalid MOVD of y\+4\(FP\); uint32 is 4-byte value" - MOVW x+4(FP), R1 // ERROR "invalid offset x\+4\(FP\); expected x\+0\(FP\)" - MOVW y+2(FP), R1 // ERROR "invalid offset y\+2\(FP\); expected y\+4\(FP\)" - RET - -TEXT ·arg8(SB),7,$0-2 // ERROR "wrong argument size 2; expected \$\.\.\.-16" - MOVB x+0(FP), R1 // ERROR "invalid MOVB of x\+0\(FP\); int64 is 8-byte value" - MOVB y+8(FP), R2 // ERROR "invalid MOVB of y\+8\(FP\); uint64 is 8-byte value" - MOVH x+0(FP), R1 // ERROR "invalid MOVH of x\+0\(FP\); int64 is 8-byte value" - MOVH y+8(FP), R1 // ERROR "invalid MOVH of y\+8\(FP\); uint64 is 8-byte value" - MOVW x+0(FP), R1 // ERROR "invalid MOVW of x\+0\(FP\); int64 is 8-byte value" - MOVW y+8(FP), R1 // ERROR "invalid MOVW of y\+8\(FP\); uint64 is 8-byte value" - MOVD x+0(FP), R1 - MOVD y+8(FP), R1 - MOVD x+8(FP), R1 // ERROR "invalid offset x\+8\(FP\); expected x\+0\(FP\)" - MOVD y+2(FP), R1 // ERROR "invalid offset y\+2\(FP\); expected y\+8\(FP\)" - RET - -TEXT ·argint(SB),0,$0-2 // ERROR "wrong argument size 2; expected \$\.\.\.-16" - MOVB x+0(FP), R1 // ERROR "invalid MOVB of x\+0\(FP\); int is 8-byte value" - MOVB y+8(FP), R2 // ERROR "invalid MOVB of y\+8\(FP\); uint is 8-byte value" - MOVH x+0(FP), R1 // ERROR "invalid MOVH of x\+0\(FP\); int is 8-byte value" - MOVH y+8(FP), R1 // ERROR "invalid MOVH of y\+8\(FP\); uint is 8-byte value" - MOVW x+0(FP), R1 // ERROR "invalid MOVW of x\+0\(FP\); int is 8-byte value" - MOVW y+8(FP), R1 // ERROR "invalid MOVW of y\+8\(FP\); uint is 8-byte value" - MOVD x+0(FP), R1 - MOVD y+8(FP), R1 - MOVD x+8(FP), R1 // ERROR "invalid offset x\+8\(FP\); expected x\+0\(FP\)" - MOVD y+2(FP), R1 // ERROR "invalid offset y\+2\(FP\); expected y\+8\(FP\)" - RET - -TEXT ·argptr(SB),7,$0-2 // ERROR "wrong argument size 2; expected \$\.\.\.-40" - MOVB x+0(FP), R1 // ERROR "invalid MOVB of x\+0\(FP\); \*byte is 8-byte value" - MOVB y+8(FP), R2 // ERROR "invalid MOVB of y\+8\(FP\); \*byte is 8-byte value" - MOVH x+0(FP), R1 // ERROR "invalid MOVH of x\+0\(FP\); \*byte is 8-byte value" - MOVH y+8(FP), R1 // ERROR "invalid MOVH of y\+8\(FP\); \*byte is 8-byte value" - MOVW x+0(FP), R1 // ERROR "invalid MOVW of x\+0\(FP\); \*byte is 8-byte value" - MOVW y+8(FP), R1 // ERROR "invalid MOVW of y\+8\(FP\); \*byte is 8-byte value" - MOVD x+0(FP), R1 - MOVD y+8(FP), R1 - MOVD x+8(FP), R1 // ERROR "invalid offset x\+8\(FP\); expected x\+0\(FP\)" - MOVD y+2(FP), R1 // ERROR "invalid offset y\+2\(FP\); expected y\+8\(FP\)" - MOVW c+16(FP), R1 // ERROR "invalid MOVW of c\+16\(FP\); chan int is 8-byte value" - MOVW m+24(FP), R1 // ERROR "invalid MOVW of m\+24\(FP\); map\[int\]int is 8-byte value" - MOVW f+32(FP), R1 // ERROR "invalid MOVW of f\+32\(FP\); func\(\) is 8-byte value" - RET - -TEXT ·argstring(SB),0,$32 // ERROR "wrong argument size 0; expected \$\.\.\.-32" - MOVH x+0(FP), R1 // ERROR "invalid MOVH of x\+0\(FP\); string base is 8-byte value" - MOVW x+0(FP), R1 // ERROR "invalid MOVW of x\+0\(FP\); string base is 8-byte value" - MOVD x+0(FP), R1 - MOVH x_base+0(FP), R1 // ERROR "invalid MOVH of x_base\+0\(FP\); string base is 8-byte value" - MOVW x_base+0(FP), R1 // ERROR "invalid MOVW of x_base\+0\(FP\); string base is 8-byte value" - MOVD x_base+0(FP), R1 - MOVH x_len+0(FP), R1 // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+8\(FP\)" - MOVW x_len+0(FP), R1 // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+8\(FP\)" - MOVD x_len+0(FP), R1 // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+8\(FP\)" - MOVH x_len+8(FP), R1 // ERROR "invalid MOVH of x_len\+8\(FP\); string len is 8-byte value" - MOVW x_len+8(FP), R1 // ERROR "invalid MOVW of x_len\+8\(FP\); string len is 8-byte value" - MOVD x_len+8(FP), R1 - MOVD y+0(FP), R1 // ERROR "invalid offset y\+0\(FP\); expected y\+16\(FP\)" - MOVD y_len+8(FP), R1 // ERROR "invalid offset y_len\+8\(FP\); expected y_len\+24\(FP\)" - RET - -TEXT ·argslice(SB),0,$48 // ERROR "wrong argument size 0; expected \$\.\.\.-48" - MOVH x+0(FP), R1 // ERROR "invalid MOVH of x\+0\(FP\); slice base is 8-byte value" - MOVW x+0(FP), R1 // ERROR "invalid MOVW of x\+0\(FP\); slice base is 8-byte value" - MOVD x+0(FP), R1 - MOVH x_base+0(FP), R1 // ERROR "invalid MOVH of x_base\+0\(FP\); slice base is 8-byte value" - MOVW x_base+0(FP), R1 // ERROR "invalid MOVW of x_base\+0\(FP\); slice base is 8-byte value" - MOVD x_base+0(FP), R1 - MOVH x_len+0(FP), R1 // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+8\(FP\)" - MOVW x_len+0(FP), R1 // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+8\(FP\)" - MOVD x_len+0(FP), R1 // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+8\(FP\)" - MOVH x_len+8(FP), R1 // ERROR "invalid MOVH of x_len\+8\(FP\); slice len is 8-byte value" - MOVW x_len+8(FP), R1 // ERROR "invalid MOVW of x_len\+8\(FP\); slice len is 8-byte value" - MOVD x_len+8(FP), R1 - MOVH x_cap+0(FP), R1 // ERROR "invalid offset x_cap\+0\(FP\); expected x_cap\+16\(FP\)" - MOVW x_cap+0(FP), R1 // ERROR "invalid offset x_cap\+0\(FP\); expected x_cap\+16\(FP\)" - MOVD x_cap+0(FP), R1 // ERROR "invalid offset x_cap\+0\(FP\); expected x_cap\+16\(FP\)" - MOVH x_cap+16(FP), R1 // ERROR "invalid MOVH of x_cap\+16\(FP\); slice cap is 8-byte value" - MOVW x_cap+16(FP), R1 // ERROR "invalid MOVW of x_cap\+16\(FP\); slice cap is 8-byte value" - MOVD x_cap+16(FP), R1 - MOVD y+0(FP), R1 // ERROR "invalid offset y\+0\(FP\); expected y\+24\(FP\)" - MOVD y_len+8(FP), R1 // ERROR "invalid offset y_len\+8\(FP\); expected y_len\+32\(FP\)" - MOVD y_cap+16(FP), R1 // ERROR "invalid offset y_cap\+16\(FP\); expected y_cap\+40\(FP\)" - RET - -TEXT ·argiface(SB),0,$0-32 - MOVH x+0(FP), R1 // ERROR "invalid MOVH of x\+0\(FP\); interface type is 8-byte value" - MOVW x+0(FP), R1 // ERROR "invalid MOVW of x\+0\(FP\); interface type is 8-byte value" - MOVD x+0(FP), R1 - MOVH x_type+0(FP), R1 // ERROR "invalid MOVH of x_type\+0\(FP\); interface type is 8-byte value" - MOVW x_type+0(FP), R1 // ERROR "invalid MOVW of x_type\+0\(FP\); interface type is 8-byte value" - MOVD x_type+0(FP), R1 - MOVD x_itable+0(FP), R1 // ERROR "unknown variable x_itable; offset 0 is x_type\+0\(FP\)" - MOVD x_itable+1(FP), R1 // ERROR "unknown variable x_itable; offset 1 is x_type\+0\(FP\)" - MOVH x_data+0(FP), R1 // ERROR "invalid offset x_data\+0\(FP\); expected x_data\+8\(FP\)" - MOVW x_data+0(FP), R1 // ERROR "invalid offset x_data\+0\(FP\); expected x_data\+8\(FP\)" - MOVD x_data+0(FP), R1 // ERROR "invalid offset x_data\+0\(FP\); expected x_data\+8\(FP\)" - MOVH x_data+8(FP), R1 // ERROR "invalid MOVH of x_data\+8\(FP\); interface data is 8-byte value" - MOVW x_data+8(FP), R1 // ERROR "invalid MOVW of x_data\+8\(FP\); interface data is 8-byte value" - MOVD x_data+8(FP), R1 - MOVH y+16(FP), R1 // ERROR "invalid MOVH of y\+16\(FP\); interface itable is 8-byte value" - MOVW y+16(FP), R1 // ERROR "invalid MOVW of y\+16\(FP\); interface itable is 8-byte value" - MOVD y+16(FP), R1 - MOVH y_itable+16(FP), R1 // ERROR "invalid MOVH of y_itable\+16\(FP\); interface itable is 8-byte value" - MOVW y_itable+16(FP), R1 // ERROR "invalid MOVW of y_itable\+16\(FP\); interface itable is 8-byte value" - MOVD y_itable+16(FP), R1 - MOVD y_type+16(FP), R1 // ERROR "unknown variable y_type; offset 16 is y_itable\+16\(FP\)" - MOVH y_data+16(FP), R1 // ERROR "invalid offset y_data\+16\(FP\); expected y_data\+24\(FP\)" - MOVW y_data+16(FP), R1 // ERROR "invalid offset y_data\+16\(FP\); expected y_data\+24\(FP\)" - MOVD y_data+16(FP), R1 // ERROR "invalid offset y_data\+16\(FP\); expected y_data\+24\(FP\)" - MOVH y_data+24(FP), R1 // ERROR "invalid MOVH of y_data\+24\(FP\); interface data is 8-byte value" - MOVW y_data+24(FP), R1 // ERROR "invalid MOVW of y_data\+24\(FP\); interface data is 8-byte value" - MOVD y_data+24(FP), R1 - RET - -TEXT ·returnint(SB),0,$0-8 - MOVB R1, ret+0(FP) // ERROR "invalid MOVB of ret\+0\(FP\); int is 8-byte value" - MOVH R1, ret+0(FP) // ERROR "invalid MOVH of ret\+0\(FP\); int is 8-byte value" - MOVW R1, ret+0(FP) // ERROR "invalid MOVW of ret\+0\(FP\); int is 8-byte value" - MOVD R1, ret+0(FP) - MOVD R1, ret+1(FP) // ERROR "invalid offset ret\+1\(FP\); expected ret\+0\(FP\)" - MOVD R1, r+0(FP) // ERROR "unknown variable r; offset 0 is ret\+0\(FP\)" - RET - -TEXT ·returnbyte(SB),0,$0-9 - MOVD x+0(FP), R1 - MOVB R1, ret+8(FP) - MOVH R1, ret+8(FP) // ERROR "invalid MOVH of ret\+8\(FP\); byte is 1-byte value" - MOVW R1, ret+8(FP) // ERROR "invalid MOVW of ret\+8\(FP\); byte is 1-byte value" - MOVD R1, ret+8(FP) // ERROR "invalid MOVD of ret\+8\(FP\); byte is 1-byte value" - MOVB R1, ret+7(FP) // ERROR "invalid offset ret\+7\(FP\); expected ret\+8\(FP\)" - RET - -TEXT ·returnnamed(SB),0,$0-41 - MOVB x+0(FP), R1 - MOVD R1, r1+8(FP) - MOVH R1, r2+16(FP) - MOVD R1, r3+24(FP) - MOVD R1, r3_base+24(FP) - MOVD R1, r3_len+32(FP) - MOVB R1, r4+40(FP) - MOVW R1, r1+8(FP) // ERROR "invalid MOVW of r1\+8\(FP\); int is 8-byte value" - RET - -TEXT ·returnintmissing(SB),0,$0-8 - RET // ERROR "RET without writing to 8-byte ret\+0\(FP\)" diff --git a/libgo/go/cmd/vet/testdata/asm/asm7.s b/libgo/go/cmd/vet/testdata/asm/asm7.s deleted file mode 100644 index d5ff5460a56..00000000000 --- a/libgo/go/cmd/vet/testdata/asm/asm7.s +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ppc64 ppc64le -// +build vet_test - -TEXT ·arg1(SB),0,$0-2 - MOVB x+0(FP), R3 - MOVBZ y+1(FP), R4 - MOVH x+0(FP), R3 // ERROR "\[(ppc64|ppc64le)\] arg1: invalid MOVH of x\+0\(FP\); int8 is 1-byte value" - MOVHZ y+1(FP), R3 // ERROR "invalid MOVHZ of y\+1\(FP\); uint8 is 1-byte value" - MOVW x+0(FP), R3 // ERROR "invalid MOVW of x\+0\(FP\); int8 is 1-byte value" - MOVWZ y+1(FP), R3 // ERROR "invalid MOVWZ of y\+1\(FP\); uint8 is 1-byte value" - MOVD x+0(FP), R3 // ERROR "invalid MOVD of x\+0\(FP\); int8 is 1-byte value" - MOVD y+1(FP), R3 // ERROR "invalid MOVD of y\+1\(FP\); uint8 is 1-byte value" - MOVB x+1(FP), R3 // ERROR "invalid offset x\+1\(FP\); expected x\+0\(FP\)" - MOVBZ y+2(FP), R3 // ERROR "invalid offset y\+2\(FP\); expected y\+1\(FP\)" - MOVB 16(R1), R3 // ERROR "16\(R1\) should be x\+0\(FP\)" - MOVB 17(R1), R3 // ERROR "17\(R1\) should be y\+1\(FP\)" - MOVB 18(R1), R3 // ERROR "use of 18\(R1\) points beyond argument frame" - RET - -TEXT ·arg2(SB),0,$0-4 - MOVBZ x+0(FP), R3 // ERROR "arg2: invalid MOVBZ of x\+0\(FP\); int16 is 2-byte value" - MOVB y+2(FP), R3 // ERROR "invalid MOVB of y\+2\(FP\); uint16 is 2-byte value" - MOVHZ x+0(FP), R3 - MOVH y+2(FP), R4 - MOVWZ x+0(FP), R3 // ERROR "invalid MOVWZ of x\+0\(FP\); int16 is 2-byte value" - MOVW y+2(FP), R3 // ERROR "invalid MOVW of y\+2\(FP\); uint16 is 2-byte value" - MOVD x+0(FP), R3 // ERROR "invalid MOVD of x\+0\(FP\); int16 is 2-byte value" - MOVD y+2(FP), R3 // ERROR "invalid MOVD of y\+2\(FP\); uint16 is 2-byte value" - MOVHZ x+2(FP), R3 // ERROR "invalid offset x\+2\(FP\); expected x\+0\(FP\)" - MOVH y+0(FP), R3 // ERROR "invalid offset y\+0\(FP\); expected y\+2\(FP\)" - RET - -TEXT ·arg4(SB),0,$0-2 // ERROR "arg4: wrong argument size 2; expected \$\.\.\.-8" - MOVB x+0(FP), R3 // ERROR "invalid MOVB of x\+0\(FP\); int32 is 4-byte value" - MOVB y+4(FP), R4 // ERROR "invalid MOVB of y\+4\(FP\); uint32 is 4-byte value" - MOVH x+0(FP), R3 // ERROR "invalid MOVH of x\+0\(FP\); int32 is 4-byte value" - MOVH y+4(FP), R3 // ERROR "invalid MOVH of y\+4\(FP\); uint32 is 4-byte value" - MOVW x+0(FP), R3 - MOVW y+4(FP), R3 - MOVD x+0(FP), R3 // ERROR "invalid MOVD of x\+0\(FP\); int32 is 4-byte value" - MOVD y+4(FP), R3 // ERROR "invalid MOVD of y\+4\(FP\); uint32 is 4-byte value" - MOVW x+4(FP), R3 // ERROR "invalid offset x\+4\(FP\); expected x\+0\(FP\)" - MOVW y+2(FP), R3 // ERROR "invalid offset y\+2\(FP\); expected y\+4\(FP\)" - RET - -TEXT ·arg8(SB),7,$0-2 // ERROR "wrong argument size 2; expected \$\.\.\.-16" - MOVB x+0(FP), R3 // ERROR "invalid MOVB of x\+0\(FP\); int64 is 8-byte value" - MOVB y+8(FP), R4 // ERROR "invalid MOVB of y\+8\(FP\); uint64 is 8-byte value" - MOVH x+0(FP), R3 // ERROR "invalid MOVH of x\+0\(FP\); int64 is 8-byte value" - MOVH y+8(FP), R3 // ERROR "invalid MOVH of y\+8\(FP\); uint64 is 8-byte value" - MOVW x+0(FP), R3 // ERROR "invalid MOVW of x\+0\(FP\); int64 is 8-byte value" - MOVW y+8(FP), R3 // ERROR "invalid MOVW of y\+8\(FP\); uint64 is 8-byte value" - MOVD x+0(FP), R3 - MOVD y+8(FP), R3 - MOVD x+8(FP), R3 // ERROR "invalid offset x\+8\(FP\); expected x\+0\(FP\)" - MOVD y+2(FP), R3 // ERROR "invalid offset y\+2\(FP\); expected y\+8\(FP\)" - RET - -TEXT ·argint(SB),0,$0-2 // ERROR "wrong argument size 2; expected \$\.\.\.-16" - MOVB x+0(FP), R3 // ERROR "invalid MOVB of x\+0\(FP\); int is 8-byte value" - MOVB y+8(FP), R4 // ERROR "invalid MOVB of y\+8\(FP\); uint is 8-byte value" - MOVH x+0(FP), R3 // ERROR "invalid MOVH of x\+0\(FP\); int is 8-byte value" - MOVH y+8(FP), R3 // ERROR "invalid MOVH of y\+8\(FP\); uint is 8-byte value" - MOVW x+0(FP), R3 // ERROR "invalid MOVW of x\+0\(FP\); int is 8-byte value" - MOVW y+8(FP), R3 // ERROR "invalid MOVW of y\+8\(FP\); uint is 8-byte value" - MOVD x+0(FP), R3 - MOVD y+8(FP), R3 - MOVD x+8(FP), R3 // ERROR "invalid offset x\+8\(FP\); expected x\+0\(FP\)" - MOVD y+2(FP), R3 // ERROR "invalid offset y\+2\(FP\); expected y\+8\(FP\)" - RET - -TEXT ·argptr(SB),7,$0-2 // ERROR "wrong argument size 2; expected \$\.\.\.-40" - MOVB x+0(FP), R3 // ERROR "invalid MOVB of x\+0\(FP\); \*byte is 8-byte value" - MOVB y+8(FP), R4 // ERROR "invalid MOVB of y\+8\(FP\); \*byte is 8-byte value" - MOVH x+0(FP), R3 // ERROR "invalid MOVH of x\+0\(FP\); \*byte is 8-byte value" - MOVH y+8(FP), R3 // ERROR "invalid MOVH of y\+8\(FP\); \*byte is 8-byte value" - MOVW x+0(FP), R3 // ERROR "invalid MOVW of x\+0\(FP\); \*byte is 8-byte value" - MOVW y+8(FP), R3 // ERROR "invalid MOVW of y\+8\(FP\); \*byte is 8-byte value" - MOVD x+0(FP), R3 - MOVD y+8(FP), R3 - MOVD x+8(FP), R3 // ERROR "invalid offset x\+8\(FP\); expected x\+0\(FP\)" - MOVD y+2(FP), R3 // ERROR "invalid offset y\+2\(FP\); expected y\+8\(FP\)" - MOVW c+16(FP), R3 // ERROR "invalid MOVW of c\+16\(FP\); chan int is 8-byte value" - MOVW m+24(FP), R3 // ERROR "invalid MOVW of m\+24\(FP\); map\[int\]int is 8-byte value" - MOVW f+32(FP), R3 // ERROR "invalid MOVW of f\+32\(FP\); func\(\) is 8-byte value" - RET - -TEXT ·argstring(SB),0,$32 // ERROR "wrong argument size 0; expected \$\.\.\.-32" - MOVH x+0(FP), R3 // ERROR "invalid MOVH of x\+0\(FP\); string base is 8-byte value" - MOVW x+0(FP), R3 // ERROR "invalid MOVW of x\+0\(FP\); string base is 8-byte value" - MOVD x+0(FP), R3 - MOVH x_base+0(FP), R3 // ERROR "invalid MOVH of x_base\+0\(FP\); string base is 8-byte value" - MOVW x_base+0(FP), R3 // ERROR "invalid MOVW of x_base\+0\(FP\); string base is 8-byte value" - MOVD x_base+0(FP), R3 - MOVH x_len+0(FP), R3 // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+8\(FP\)" - MOVW x_len+0(FP), R3 // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+8\(FP\)" - MOVD x_len+0(FP), R3 // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+8\(FP\)" - MOVH x_len+8(FP), R3 // ERROR "invalid MOVH of x_len\+8\(FP\); string len is 8-byte value" - MOVW x_len+8(FP), R3 // ERROR "invalid MOVW of x_len\+8\(FP\); string len is 8-byte value" - MOVD x_len+8(FP), R3 - MOVD y+0(FP), R3 // ERROR "invalid offset y\+0\(FP\); expected y\+16\(FP\)" - MOVD y_len+8(FP), R3 // ERROR "invalid offset y_len\+8\(FP\); expected y_len\+24\(FP\)" - RET - -TEXT ·argslice(SB),0,$48 // ERROR "wrong argument size 0; expected \$\.\.\.-48" - MOVH x+0(FP), R3 // ERROR "invalid MOVH of x\+0\(FP\); slice base is 8-byte value" - MOVW x+0(FP), R3 // ERROR "invalid MOVW of x\+0\(FP\); slice base is 8-byte value" - MOVD x+0(FP), R3 - MOVH x_base+0(FP), R3 // ERROR "invalid MOVH of x_base\+0\(FP\); slice base is 8-byte value" - MOVW x_base+0(FP), R3 // ERROR "invalid MOVW of x_base\+0\(FP\); slice base is 8-byte value" - MOVD x_base+0(FP), R3 - MOVH x_len+0(FP), R3 // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+8\(FP\)" - MOVW x_len+0(FP), R3 // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+8\(FP\)" - MOVD x_len+0(FP), R3 // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+8\(FP\)" - MOVH x_len+8(FP), R3 // ERROR "invalid MOVH of x_len\+8\(FP\); slice len is 8-byte value" - MOVW x_len+8(FP), R3 // ERROR "invalid MOVW of x_len\+8\(FP\); slice len is 8-byte value" - MOVD x_len+8(FP), R3 - MOVH x_cap+0(FP), R3 // ERROR "invalid offset x_cap\+0\(FP\); expected x_cap\+16\(FP\)" - MOVW x_cap+0(FP), R3 // ERROR "invalid offset x_cap\+0\(FP\); expected x_cap\+16\(FP\)" - MOVD x_cap+0(FP), R3 // ERROR "invalid offset x_cap\+0\(FP\); expected x_cap\+16\(FP\)" - MOVH x_cap+16(FP), R3 // ERROR "invalid MOVH of x_cap\+16\(FP\); slice cap is 8-byte value" - MOVW x_cap+16(FP), R3 // ERROR "invalid MOVW of x_cap\+16\(FP\); slice cap is 8-byte value" - MOVD x_cap+16(FP), R3 - MOVD y+0(FP), R3 // ERROR "invalid offset y\+0\(FP\); expected y\+24\(FP\)" - MOVD y_len+8(FP), R3 // ERROR "invalid offset y_len\+8\(FP\); expected y_len\+32\(FP\)" - MOVD y_cap+16(FP), R3 // ERROR "invalid offset y_cap\+16\(FP\); expected y_cap\+40\(FP\)" - RET - -TEXT ·argiface(SB),0,$0-32 - MOVH x+0(FP), R3 // ERROR "invalid MOVH of x\+0\(FP\); interface type is 8-byte value" - MOVW x+0(FP), R3 // ERROR "invalid MOVW of x\+0\(FP\); interface type is 8-byte value" - MOVD x+0(FP), R3 - MOVH x_type+0(FP), R3 // ERROR "invalid MOVH of x_type\+0\(FP\); interface type is 8-byte value" - MOVW x_type+0(FP), R3 // ERROR "invalid MOVW of x_type\+0\(FP\); interface type is 8-byte value" - MOVD x_type+0(FP), R3 - MOVD x_itable+0(FP), R3 // ERROR "unknown variable x_itable; offset 0 is x_type\+0\(FP\)" - MOVD x_itable+1(FP), R3 // ERROR "unknown variable x_itable; offset 1 is x_type\+0\(FP\)" - MOVH x_data+0(FP), R3 // ERROR "invalid offset x_data\+0\(FP\); expected x_data\+8\(FP\)" - MOVW x_data+0(FP), R3 // ERROR "invalid offset x_data\+0\(FP\); expected x_data\+8\(FP\)" - MOVD x_data+0(FP), R3 // ERROR "invalid offset x_data\+0\(FP\); expected x_data\+8\(FP\)" - MOVH x_data+8(FP), R3 // ERROR "invalid MOVH of x_data\+8\(FP\); interface data is 8-byte value" - MOVW x_data+8(FP), R3 // ERROR "invalid MOVW of x_data\+8\(FP\); interface data is 8-byte value" - MOVD x_data+8(FP), R3 - MOVH y+16(FP), R3 // ERROR "invalid MOVH of y\+16\(FP\); interface itable is 8-byte value" - MOVW y+16(FP), R3 // ERROR "invalid MOVW of y\+16\(FP\); interface itable is 8-byte value" - MOVD y+16(FP), R3 - MOVH y_itable+16(FP), R3 // ERROR "invalid MOVH of y_itable\+16\(FP\); interface itable is 8-byte value" - MOVW y_itable+16(FP), R3 // ERROR "invalid MOVW of y_itable\+16\(FP\); interface itable is 8-byte value" - MOVD y_itable+16(FP), R3 - MOVD y_type+16(FP), R3 // ERROR "unknown variable y_type; offset 16 is y_itable\+16\(FP\)" - MOVH y_data+16(FP), R3 // ERROR "invalid offset y_data\+16\(FP\); expected y_data\+24\(FP\)" - MOVW y_data+16(FP), R3 // ERROR "invalid offset y_data\+16\(FP\); expected y_data\+24\(FP\)" - MOVD y_data+16(FP), R3 // ERROR "invalid offset y_data\+16\(FP\); expected y_data\+24\(FP\)" - MOVH y_data+24(FP), R3 // ERROR "invalid MOVH of y_data\+24\(FP\); interface data is 8-byte value" - MOVW y_data+24(FP), R3 // ERROR "invalid MOVW of y_data\+24\(FP\); interface data is 8-byte value" - MOVD y_data+24(FP), R3 - RET - -TEXT ·returnint(SB),0,$0-8 - MOVB R3, ret+0(FP) // ERROR "invalid MOVB of ret\+0\(FP\); int is 8-byte value" - MOVH R3, ret+0(FP) // ERROR "invalid MOVH of ret\+0\(FP\); int is 8-byte value" - MOVW R3, ret+0(FP) // ERROR "invalid MOVW of ret\+0\(FP\); int is 8-byte value" - MOVD R3, ret+0(FP) - MOVD R3, ret+1(FP) // ERROR "invalid offset ret\+1\(FP\); expected ret\+0\(FP\)" - MOVD R3, r+0(FP) // ERROR "unknown variable r; offset 0 is ret\+0\(FP\)" - RET - -TEXT ·returnbyte(SB),0,$0-9 - MOVD x+0(FP), R3 - MOVB R3, ret+8(FP) - MOVH R3, ret+8(FP) // ERROR "invalid MOVH of ret\+8\(FP\); byte is 1-byte value" - MOVW R3, ret+8(FP) // ERROR "invalid MOVW of ret\+8\(FP\); byte is 1-byte value" - MOVD R3, ret+8(FP) // ERROR "invalid MOVD of ret\+8\(FP\); byte is 1-byte value" - MOVB R3, ret+7(FP) // ERROR "invalid offset ret\+7\(FP\); expected ret\+8\(FP\)" - RET - -TEXT ·returnnamed(SB),0,$0-41 - MOVB x+0(FP), R3 - MOVD R3, r1+8(FP) - MOVH R3, r2+16(FP) - MOVD R3, r3+24(FP) - MOVD R3, r3_base+24(FP) - MOVD R3, r3_len+32(FP) - MOVB R3, r4+40(FP) - MOVW R3, r1+8(FP) // ERROR "invalid MOVW of r1\+8\(FP\); int is 8-byte value" - RET - -TEXT ·returnintmissing(SB),0,$0-8 - RET // ERROR "RET without writing to 8-byte ret\+0\(FP\)" diff --git a/libgo/go/cmd/vet/testdata/asm8.s b/libgo/go/cmd/vet/testdata/asm8.s deleted file mode 100644 index 550d92a8d2d..00000000000 --- a/libgo/go/cmd/vet/testdata/asm8.s +++ /dev/null @@ -1,165 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build mipsle -// +build vet_test - -TEXT ·arg1(SB),0,$0-2 - MOVB x+0(FP), R1 - MOVBU y+1(FP), R2 - MOVH x+0(FP), R1 // ERROR "\[mipsle\] arg1: invalid MOVH of x\+0\(FP\); int8 is 1-byte value" - MOVHU y+1(FP), R1 // ERROR "invalid MOVHU of y\+1\(FP\); uint8 is 1-byte value" - MOVW x+0(FP), R1 // ERROR "invalid MOVW of x\+0\(FP\); int8 is 1-byte value" - MOVWU y+1(FP), R1 // ERROR "invalid MOVWU of y\+1\(FP\); uint8 is 1-byte value" - MOVW y+1(FP), R1 // ERROR "invalid MOVW of y\+1\(FP\); uint8 is 1-byte value" - MOVB x+1(FP), R1 // ERROR "invalid offset x\+1\(FP\); expected x\+0\(FP\)" - MOVBU y+2(FP), R1 // ERROR "invalid offset y\+2\(FP\); expected y\+1\(FP\)" - MOVB 8(R29), R1 // ERROR "8\(R29\) should be x\+0\(FP\)" - MOVB 9(R29), R1 // ERROR "9\(R29\) should be y\+1\(FP\)" - MOVB 10(R29), R1 // ERROR "use of 10\(R29\) points beyond argument frame" - RET - -TEXT ·arg2(SB),0,$0-4 - MOVBU x+0(FP), R1 // ERROR "arg2: invalid MOVBU of x\+0\(FP\); int16 is 2-byte value" - MOVB y+2(FP), R1 // ERROR "invalid MOVB of y\+2\(FP\); uint16 is 2-byte value" - MOVHU x+0(FP), R1 - MOVH y+2(FP), R2 - MOVWU x+0(FP), R1 // ERROR "invalid MOVWU of x\+0\(FP\); int16 is 2-byte value" - MOVW y+2(FP), R1 // ERROR "invalid MOVW of y\+2\(FP\); uint16 is 2-byte value" - MOVHU x+2(FP), R1 // ERROR "invalid offset x\+2\(FP\); expected x\+0\(FP\)" - MOVH y+0(FP), R1 // ERROR "invalid offset y\+0\(FP\); expected y\+2\(FP\)" - RET - -TEXT ·arg4(SB),0,$0-2 // ERROR "arg4: wrong argument size 2; expected \$\.\.\.-8" - MOVB x+0(FP), R1 // ERROR "invalid MOVB of x\+0\(FP\); int32 is 4-byte value" - MOVB y+4(FP), R2 // ERROR "invalid MOVB of y\+4\(FP\); uint32 is 4-byte value" - MOVH x+0(FP), R1 // ERROR "invalid MOVH of x\+0\(FP\); int32 is 4-byte value" - MOVH y+4(FP), R1 // ERROR "invalid MOVH of y\+4\(FP\); uint32 is 4-byte value" - MOVW x+0(FP), R1 - MOVW y+4(FP), R1 - MOVW x+4(FP), R1 // ERROR "invalid offset x\+4\(FP\); expected x\+0\(FP\)" - MOVW y+2(FP), R1 // ERROR "invalid offset y\+2\(FP\); expected y\+4\(FP\)" - RET - -TEXT ·arg8(SB),7,$0-2 // ERROR "wrong argument size 2; expected \$\.\.\.-16" - MOVB x+0(FP), R1 // ERROR "invalid MOVB of x\+0\(FP\); int64 is 8-byte value" - MOVB y+8(FP), R2 // ERROR "invalid MOVB of y\+8\(FP\); uint64 is 8-byte value" - MOVH x+0(FP), R1 // ERROR "invalid MOVH of x\+0\(FP\); int64 is 8-byte value" - MOVH y+8(FP), R1 // ERROR "invalid MOVH of y\+8\(FP\); uint64 is 8-byte value" - MOVW x+0(FP), R1 // ERROR "invalid MOVW of x\+0\(FP\); int64 is 8-byte value containing x_lo\+0\(FP\) and x_hi\+4\(FP\)" - MOVW x_lo+0(FP), R1 - MOVW x_hi+4(FP), R1 - MOVW y+8(FP), R1 // ERROR "invalid MOVW of y\+8\(FP\); uint64 is 8-byte value containing y_lo\+8\(FP\) and y_hi\+12\(FP\)" - MOVW y_lo+8(FP), R1 - MOVW y_hi+12(FP), R1 - RET - -TEXT ·argint(SB),0,$0-2 // ERROR "wrong argument size 2; expected \$\.\.\.-8" - MOVB x+0(FP), R1 // ERROR "invalid MOVB of x\+0\(FP\); int is 4-byte value" - MOVB y+4(FP), R2 // ERROR "invalid MOVB of y\+4\(FP\); uint is 4-byte value" - MOVH x+0(FP), R1 // ERROR "invalid MOVH of x\+0\(FP\); int is 4-byte value" - MOVH y+4(FP), R1 // ERROR "invalid MOVH of y\+4\(FP\); uint is 4-byte value" - MOVW x+0(FP), R1 - MOVW y+4(FP), R1 - MOVW x+4(FP), R1 // ERROR "invalid offset x\+4\(FP\); expected x\+0\(FP\)" - MOVW y+2(FP), R1 // ERROR "invalid offset y\+2\(FP\); expected y\+4\(FP\)" - RET - -TEXT ·argptr(SB),7,$0-2 // ERROR "wrong argument size 2; expected \$\.\.\.-20" - MOVB x+0(FP), R1 // ERROR "invalid MOVB of x\+0\(FP\); \*byte is 4-byte value" - MOVB y+4(FP), R2 // ERROR "invalid MOVB of y\+4\(FP\); \*byte is 4-byte value" - MOVH x+0(FP), R1 // ERROR "invalid MOVH of x\+0\(FP\); \*byte is 4-byte value" - MOVH y+4(FP), R1 // ERROR "invalid MOVH of y\+4\(FP\); \*byte is 4-byte value" - MOVW x+0(FP), R1 - MOVW y+4(FP), R1 - MOVW x+4(FP), R1 // ERROR "invalid offset x\+4\(FP\); expected x\+0\(FP\)" - MOVW y+2(FP), R1 // ERROR "invalid offset y\+2\(FP\); expected y\+4\(FP\)" - MOVH c+8(FP), R1 // ERROR "invalid MOVH of c\+8\(FP\); chan int is 4-byte value" - MOVH m+12(FP), R1 // ERROR "invalid MOVH of m\+12\(FP\); map\[int\]int is 4-byte value" - MOVH f+16(FP), R1 // ERROR "invalid MOVH of f\+16\(FP\); func\(\) is 4-byte value" - RET - -TEXT ·argstring(SB),0,$16 // ERROR "wrong argument size 0; expected \$\.\.\.-16" - MOVH x+0(FP), R1 // ERROR "invalid MOVH of x\+0\(FP\); string base is 4-byte value" - MOVW x+0(FP), R1 - MOVH x_base+0(FP), R1 // ERROR "invalid MOVH of x_base\+0\(FP\); string base is 4-byte value" - MOVW x_base+0(FP), R1 - MOVH x_len+0(FP), R1 // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+4\(FP\)" - MOVW x_len+0(FP), R1 // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+4\(FP\)" - MOVH x_len+4(FP), R1 // ERROR "invalid MOVH of x_len\+4\(FP\); string len is 4-byte value" - MOVW x_len+4(FP), R1 - MOVW y+0(FP), R1 // ERROR "invalid offset y\+0\(FP\); expected y\+8\(FP\)" - MOVW y_len+4(FP), R1 // ERROR "invalid offset y_len\+4\(FP\); expected y_len\+12\(FP\)" - RET - -TEXT ·argslice(SB),0,$24 // ERROR "wrong argument size 0; expected \$\.\.\.-24" - MOVH x+0(FP), R1 // ERROR "invalid MOVH of x\+0\(FP\); slice base is 4-byte value" - MOVW x+0(FP), R1 - MOVH x_base+0(FP), R1 // ERROR "invalid MOVH of x_base\+0\(FP\); slice base is 4-byte value" - MOVW x_base+0(FP), R1 - MOVH x_len+0(FP), R1 // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+4\(FP\)" - MOVW x_len+0(FP), R1 // ERROR "invalid offset x_len\+0\(FP\); expected x_len\+4\(FP\)" - MOVH x_len+4(FP), R1 // ERROR "invalid MOVH of x_len\+4\(FP\); slice len is 4-byte value" - MOVW x_len+4(FP), R1 - MOVH x_cap+0(FP), R1 // ERROR "invalid offset x_cap\+0\(FP\); expected x_cap\+8\(FP\)" - MOVW x_cap+0(FP), R1 // ERROR "invalid offset x_cap\+0\(FP\); expected x_cap\+8\(FP\)" - MOVH x_cap+8(FP), R1 // ERROR "invalid MOVH of x_cap\+8\(FP\); slice cap is 4-byte value" - MOVW x_cap+8(FP), R1 - MOVW y+0(FP), R1 // ERROR "invalid offset y\+0\(FP\); expected y\+12\(FP\)" - MOVW y_len+4(FP), R1 // ERROR "invalid offset y_len\+4\(FP\); expected y_len\+16\(FP\)" - MOVW y_cap+8(FP), R1 // ERROR "invalid offset y_cap\+8\(FP\); expected y_cap\+20\(FP\)" - RET - -TEXT ·argiface(SB),0,$0-16 - MOVH x+0(FP), R1 // ERROR "invalid MOVH of x\+0\(FP\); interface type is 4-byte value" - MOVW x+0(FP), R1 - MOVH x_type+0(FP), R1 // ERROR "invalid MOVH of x_type\+0\(FP\); interface type is 4-byte value" - MOVW x_type+0(FP), R1 - MOVQ x_itable+0(FP), R1 // ERROR "unknown variable x_itable; offset 0 is x_type\+0\(FP\)" - MOVQ x_itable+1(FP), R1 // ERROR "unknown variable x_itable; offset 1 is x_type\+0\(FP\)" - MOVH x_data+0(FP), R1 // ERROR "invalid offset x_data\+0\(FP\); expected x_data\+4\(FP\)" - MOVW x_data+0(FP), R1 // ERROR "invalid offset x_data\+0\(FP\); expected x_data\+4\(FP\)" - MOVQ x_data+0(FP), R1 // ERROR "invalid offset x_data\+0\(FP\); expected x_data\+4\(FP\)" - MOVH x_data+4(FP), R1 // ERROR "invalid MOVH of x_data\+4\(FP\); interface data is 4-byte value" - MOVW x_data+4(FP), R1 - MOVH y+8(FP), R1 // ERROR "invalid MOVH of y\+8\(FP\); interface itable is 4-byte value" - MOVW y+8(FP), R1 - MOVH y_itable+8(FP), R1 // ERROR "invalid MOVH of y_itable\+8\(FP\); interface itable is 4-byte value" - MOVW y_itable+8(FP), R1 - MOVW y_type+8(FP), AX // ERROR "unknown variable y_type; offset 8 is y_itable\+8\(FP\)" - MOVH y_data+8(FP), AX // ERROR "invalid offset y_data\+8\(FP\); expected y_data\+12\(FP\)" - MOVW y_data+8(FP), AX // ERROR "invalid offset y_data\+8\(FP\); expected y_data\+12\(FP\)" - MOVH y_data+12(FP), AX // ERROR "invalid MOVH of y_data\+12\(FP\); interface data is 4-byte value" - MOVW y_data+12(FP), AX - RET - -TEXT ·returnbyte(SB),0,$0-5 - MOVW x+0(FP), R1 - MOVB R1, ret+4(FP) - MOVH R1, ret+4(FP) // ERROR "invalid MOVH of ret\+4\(FP\); byte is 1-byte value" - MOVW R1, ret+4(FP) // ERROR "invalid MOVW of ret\+4\(FP\); byte is 1-byte value" - MOVB R1, ret+3(FP) // ERROR "invalid offset ret\+3\(FP\); expected ret\+4\(FP\)" - RET - -TEXT ·returnbyte(SB),0,$0-5 - MOVW x+0(FP), R1 - MOVB R1, ret+4(FP) - MOVH R1, ret+4(FP) // ERROR "invalid MOVH of ret\+4\(FP\); byte is 1-byte value" - MOVW R1, ret+4(FP) // ERROR "invalid MOVW of ret\+4\(FP\); byte is 1-byte value" - MOVB R1, ret+3(FP) // ERROR "invalid offset ret\+3\(FP\); expected ret\+4\(FP\)" - RET - -TEXT ·returnnamed(SB),0,$0-21 - MOVB x+0(FP), AX - MOVW R1, r1+4(FP) - MOVH R1, r2+8(FP) - MOVW R1, r3+12(FP) - MOVW R1, r3_base+12(FP) - MOVW R1, r3_len+16(FP) - MOVB R1, r4+20(FP) - MOVB R1, r1+4(FP) // ERROR "invalid MOVB of r1\+4\(FP\); int is 4-byte value" - RET - -TEXT ·returnintmissing(SB),0,$0-4 - RET // ERROR "RET without writing to 4-byte ret\+0\(FP\)" diff --git a/libgo/go/cmd/vet/testdata/atomic.go b/libgo/go/cmd/vet/testdata/atomic.go deleted file mode 100644 index 69730b4e6f0..00000000000 --- a/libgo/go/cmd/vet/testdata/atomic.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This file contains tests for the atomic checker. - -package testdata - -import ( - "sync/atomic" -) - -type Counter uint64 - -func AtomicTests() { - x := uint64(1) - x = atomic.AddUint64(&x, 1) // ERROR "direct assignment to atomic value" - _, x = 10, atomic.AddUint64(&x, 1) // ERROR "direct assignment to atomic value" - x, _ = atomic.AddUint64(&x, 1), 10 // ERROR "direct assignment to atomic value" - - y := &x - *y = atomic.AddUint64(y, 1) // ERROR "direct assignment to atomic value" - - var su struct{ Counter uint64 } - su.Counter = atomic.AddUint64(&su.Counter, 1) // ERROR "direct assignment to atomic value" - z1 := atomic.AddUint64(&su.Counter, 1) - _ = z1 // Avoid err "z declared and not used" - - var sp struct{ Counter *uint64 } - *sp.Counter = atomic.AddUint64(sp.Counter, 1) // ERROR "direct assignment to atomic value" - z2 := atomic.AddUint64(sp.Counter, 1) - _ = z2 // Avoid err "z declared and not used" - - au := []uint64{10, 20} - au[0] = atomic.AddUint64(&au[0], 1) // ERROR "direct assignment to atomic value" - au[1] = atomic.AddUint64(&au[0], 1) - - ap := []*uint64{&au[0], &au[1]} - *ap[0] = atomic.AddUint64(ap[0], 1) // ERROR "direct assignment to atomic value" - *ap[1] = atomic.AddUint64(ap[0], 1) - - x = atomic.AddUint64() // Used to make vet crash; now silently ignored. - - { - // A variable declaration creates a new variable in the current scope. - x := atomic.AddUint64(&x, 1) // ERROR "declaration of .x. shadows declaration at atomic.go:16" - - // Re-declaration assigns a new value. - x, w := atomic.AddUint64(&x, 1), 10 // ERROR "direct assignment to atomic value" - _ = w - } -} - -type T struct{} - -func (T) AddUint64(addr *uint64, delta uint64) uint64 { return 0 } - -func NonAtomic() { - x := uint64(1) - var atomic T - x = atomic.AddUint64(&x, 1) // ok; not the imported pkg -} diff --git a/libgo/go/cmd/vet/testdata/bool.go b/libgo/go/cmd/vet/testdata/bool.go deleted file mode 100644 index 80c44d25ca3..00000000000 --- a/libgo/go/cmd/vet/testdata/bool.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This file contains tests for the bool checker. - -package testdata - -import "io" - -type T int - -func (t T) Foo() int { return int(t) } - -type FT func() int - -var S []int - -func RatherStupidConditions() { - var f, g func() int - if f() == 0 || f() == 0 { // OK f might have side effects - } - var t T - _ = t.Foo() == 2 || t.Foo() == 2 // OK Foo might have side effects - if v, w := f(), g(); v == w || v == w { // ERROR "redundant or: v == w || v == w" - } - _ = f == nil || f == nil // ERROR "redundant or: f == nil || f == nil" - - _ = i == byte(1) || i == byte(1) // ERROR "redundant or: i == byte(1) || i == byte(1)" - _ = i == T(2) || i == T(2) // ERROR "redundant or: i == T(2) || i == T(2)" - _ = FT(f) == nil || FT(f) == nil // ERROR "redundant or: FT(f) == nil || FT(f) == nil" - - _ = (func() int)(f) == nil || (func() int)(f) == nil // ERROR "redundant or: (func() int)(f) == nil || (func() int)(f) == nil" - _ = append(S, 3) == nil || append(S, 3) == nil // OK append has side effects - - var namedFuncVar FT - _ = namedFuncVar() == namedFuncVar() // OK still func calls - - var c chan int - _ = 0 == <-c || 0 == <-c // OK subsequent receives may yield different values - for i, j := <-c, <-c; i == j || i == j; i, j = <-c, <-c { // ERROR "redundant or: i == j || i == j" - } - - var i, j, k int - _ = i+1 == 1 || i+1 == 1 // ERROR "redundant or: i\+1 == 1 || i\+1 == 1" - _ = i == 1 || j+1 == i || i == 1 // ERROR "redundant or: i == 1 || i == 1" - - _ = i == 1 || i == 1 || f() == 1 // ERROR "redundant or: i == 1 || i == 1" - _ = i == 1 || f() == 1 || i == 1 // OK f may alter i as a side effect - _ = f() == 1 || i == 1 || i == 1 // ERROR "redundant or: i == 1 || i == 1" - - // Test partition edge cases - _ = f() == 1 || i == 1 || i == 1 || j == 1 // ERROR "redundant or: i == 1 || i == 1" - _ = f() == 1 || j == 1 || i == 1 || i == 1 // ERROR "redundant or: i == 1 || i == 1" - _ = i == 1 || f() == 1 || i == 1 || i == 1 // ERROR "redundant or: i == 1 || i == 1" - _ = i == 1 || i == 1 || f() == 1 || i == 1 // ERROR "redundant or: i == 1 || i == 1" - _ = i == 1 || i == 1 || j == 1 || f() == 1 // ERROR "redundant or: i == 1 || i == 1" - _ = j == 1 || i == 1 || i == 1 || f() == 1 // ERROR "redundant or: i == 1 || i == 1" - _ = i == 1 || f() == 1 || f() == 1 || i == 1 - - _ = i == 1 || (i == 1 || i == 2) // ERROR "redundant or: i == 1 || i == 1" - _ = i == 1 || (f() == 1 || i == 1) // OK f may alter i as a side effect - _ = i == 1 || (i == 1 || f() == 1) // ERROR "redundant or: i == 1 || i == 1" - _ = i == 1 || (i == 2 || (i == 1 || i == 3)) // ERROR "redundant or: i == 1 || i == 1" - - var a, b bool - _ = i == 1 || (a || (i == 1 || b)) // ERROR "redundant or: i == 1 || i == 1" - - // Check that all redundant ors are flagged - _ = j == 0 || - i == 1 || - f() == 1 || - j == 0 || // ERROR "redundant or: j == 0 || j == 0" - i == 1 || // ERROR "redundant or: i == 1 || i == 1" - i == 1 || // ERROR "redundant or: i == 1 || i == 1" - i == 1 || - j == 0 || - k == 0 - - _ = i == 1*2*3 || i == 1*2*3 // ERROR "redundant or: i == 1\*2\*3 || i == 1\*2\*3" - - // These test that redundant, suspect expressions do not trigger multiple errors. - _ = i != 0 || i != 0 // ERROR "redundant or: i != 0 || i != 0" - _ = i == 0 && i == 0 // ERROR "redundant and: i == 0 && i == 0" - - // and is dual to or; check the basics and - // let the or tests pull the rest of the weight. - _ = 0 != <-c && 0 != <-c // OK subsequent receives may yield different values - _ = f() != 0 && f() != 0 // OK f might have side effects - _ = f != nil && f != nil // ERROR "redundant and: f != nil && f != nil" - _ = i != 1 && i != 1 && f() != 1 // ERROR "redundant and: i != 1 && i != 1" - _ = i != 1 && f() != 1 && i != 1 // OK f may alter i as a side effect - _ = f() != 1 && i != 1 && i != 1 // ERROR "redundant and: i != 1 && i != 1" -} - -func RoyallySuspectConditions() { - var i, j int - - _ = i == 0 || i == 1 // OK - _ = i != 0 || i != 1 // ERROR "suspect or: i != 0 || i != 1" - _ = i != 0 || 1 != i // ERROR "suspect or: i != 0 || 1 != i" - _ = 0 != i || 1 != i // ERROR "suspect or: 0 != i || 1 != i" - _ = 0 != i || i != 1 // ERROR "suspect or: 0 != i || i != 1" - - _ = (0 != i) || i != 1 // ERROR "suspect or: 0 != i || i != 1" - - _ = i+3 != 7 || j+5 == 0 || i+3 != 9 // ERROR "suspect or: i\+3 != 7 || i\+3 != 9" - - _ = i != 0 || j == 0 || i != 1 // ERROR "suspect or: i != 0 || i != 1" - - _ = i != 0 || i != 1<<4 // ERROR "suspect or: i != 0 || i != 1<<4" - - _ = i != 0 || j != 0 - _ = 0 != i || 0 != j - - var s string - _ = s != "one" || s != "the other" // ERROR "suspect or: s != .one. || s != .the other." - - _ = "et" != "alii" || "et" != "cetera" // ERROR "suspect or: .et. != .alii. || .et. != .cetera." - _ = "me gustas" != "tu" || "le gustas" != "tu" // OK we could catch this case, but it's not worth the code - - var err error - _ = err != nil || err != io.EOF // TODO catch this case? - - // Sanity check and. - _ = i != 0 && i != 1 // OK - _ = i == 0 && i == 1 // ERROR "suspect and: i == 0 && i == 1" - _ = i == 0 && 1 == i // ERROR "suspect and: i == 0 && 1 == i" - _ = 0 == i && 1 == i // ERROR "suspect and: 0 == i && 1 == i" - _ = 0 == i && i == 1 // ERROR "suspect and: 0 == i && i == 1" -} diff --git a/libgo/go/cmd/vet/testdata/buildtag/buildtag_bad.go b/libgo/go/cmd/vet/testdata/buildtag/buildtag_bad.go deleted file mode 100644 index fbe10cf748f..00000000000 --- a/libgo/go/cmd/vet/testdata/buildtag/buildtag_bad.go +++ /dev/null @@ -1,15 +0,0 @@ -// This file contains misplaced or malformed build constraints. -// The Go tool will skip it, because the constraints are invalid. -// It serves only to test the tag checker during make test. - -// Mention +build // ERROR "possible malformed \+build comment" - -// +build !!bang // ERROR "invalid double negative in build constraint" -// +build @#$ // ERROR "invalid non-alphanumeric build constraint" - -// +build toolate // ERROR "build comment must appear before package clause and be followed by a blank line" -package bad - -// This is package 'bad' rather than 'main' so the erroneous build -// tag doesn't end up looking like a package doc for the vet command -// when examined by godoc. diff --git a/libgo/go/cmd/vet/testdata/cgo/cgo.go b/libgo/go/cmd/vet/testdata/cgo/cgo.go deleted file mode 100644 index d0df7cf6787..00000000000 --- a/libgo/go/cmd/vet/testdata/cgo/cgo.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This file contains tests for the cgo checker. - -package testdata - -// void f(void *); -import "C" - -import "unsafe" - -func CgoTests() { - var c chan bool - C.f(*(*unsafe.Pointer)(unsafe.Pointer(&c))) // ERROR "embedded pointer" - C.f(unsafe.Pointer(&c)) // ERROR "embedded pointer" - - var m map[string]string - C.f(*(*unsafe.Pointer)(unsafe.Pointer(&m))) // ERROR "embedded pointer" - C.f(unsafe.Pointer(&m)) // ERROR "embedded pointer" - - var f func() - C.f(*(*unsafe.Pointer)(unsafe.Pointer(&f))) // ERROR "embedded pointer" - C.f(unsafe.Pointer(&f)) // ERROR "embedded pointer" - - var s []int - C.f(*(*unsafe.Pointer)(unsafe.Pointer(&s))) // ERROR "embedded pointer" - C.f(unsafe.Pointer(&s)) // ERROR "embedded pointer" - - var a [1][]int - C.f(*(*unsafe.Pointer)(unsafe.Pointer(&a))) // ERROR "embedded pointer" - C.f(unsafe.Pointer(&a)) // ERROR "embedded pointer" - - var st struct{ f []int } - C.f(*(*unsafe.Pointer)(unsafe.Pointer(&st))) // ERROR "embedded pointer" - C.f(unsafe.Pointer(&st)) // ERROR "embedded pointer" - - // The following cases are OK. - var i int - C.f(*(*unsafe.Pointer)(unsafe.Pointer(&i))) - C.f(unsafe.Pointer(&i)) - - C.f(*(*unsafe.Pointer)(unsafe.Pointer(&s[0]))) - C.f(unsafe.Pointer(&s[0])) - - var a2 [1]int - C.f(*(*unsafe.Pointer)(unsafe.Pointer(&a2))) - C.f(unsafe.Pointer(&a2)) - - var st2 struct{ i int } - C.f(*(*unsafe.Pointer)(unsafe.Pointer(&st2))) - C.f(unsafe.Pointer(&st2)) - - type cgoStruct struct{ p *cgoStruct } - C.f(unsafe.Pointer(&cgoStruct{})) - - C.CBytes([]byte("hello")) -} diff --git a/libgo/go/cmd/vet/testdata/cgo/cgo2.go b/libgo/go/cmd/vet/testdata/cgo/cgo2.go deleted file mode 100644 index 4f271168931..00000000000 --- a/libgo/go/cmd/vet/testdata/cgo/cgo2.go +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Test the cgo checker on a file that doesn't use cgo. - -package testdata - -var _ = C.f(*p(**p)) - -// Passing a pointer (via the slice), but C isn't cgo. -var _ = C.f([]int{3}) diff --git a/libgo/go/cmd/vet/testdata/cgo/cgo4.go b/libgo/go/cmd/vet/testdata/cgo/cgo4.go deleted file mode 100644 index 67b54506aba..00000000000 --- a/libgo/go/cmd/vet/testdata/cgo/cgo4.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Test the cgo checker on a file that doesn't use cgo, but has an -// import named "C". - -package testdata - -import C "fmt" - -var _ = C.Println(*p(**p)) - -// Passing a pointer (via a slice), but C is fmt, not cgo. -var _ = C.Println([]int{3}) diff --git a/libgo/go/cmd/vet/testdata/composite.go b/libgo/go/cmd/vet/testdata/composite.go deleted file mode 100644 index 3fe3eac78cb..00000000000 --- a/libgo/go/cmd/vet/testdata/composite.go +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This file contains the test for untagged struct literals. - -package testdata - -import ( - "flag" - "go/scanner" - "image" - "unicode" - - "path/to/unknownpkg" -) - -var Okay1 = []string{ - "Name", - "Usage", - "DefValue", -} - -var Okay2 = map[string]bool{ - "Name": true, - "Usage": true, - "DefValue": true, -} - -var Okay3 = struct { - X string - Y string - Z string -}{ - "Name", - "Usage", - "DefValue", -} - -var Okay4 = []struct { - A int - B int -}{ - {1, 2}, - {3, 4}, -} - -type MyStruct struct { - X string - Y string - Z string -} - -var Okay5 = &MyStruct{ - "Name", - "Usage", - "DefValue", -} - -var Okay6 = []MyStruct{ - {"foo", "bar", "baz"}, - {"aa", "bb", "cc"}, -} - -var Okay7 = []*MyStruct{ - {"foo", "bar", "baz"}, - {"aa", "bb", "cc"}, -} - -// Testing is awkward because we need to reference things from a separate package -// to trigger the warnings. - -var goodStructLiteral = flag.Flag{ - Name: "Name", - Usage: "Usage", -} -var badStructLiteral = flag.Flag{ // ERROR "unkeyed fields" - "Name", - "Usage", - nil, // Value - "DefValue", -} - -// SpecialCase is a named slice of CaseRange to test issue 9171. -var goodNamedSliceLiteral = unicode.SpecialCase{ - {Lo: 1, Hi: 2}, - unicode.CaseRange{Lo: 1, Hi: 2}, -} -var badNamedSliceLiteral = unicode.SpecialCase{ - {1, 2}, // ERROR "unkeyed fields" - unicode.CaseRange{1, 2}, // ERROR "unkeyed fields" -} - -// ErrorList is a named slice, so no warnings should be emitted. -var goodScannerErrorList = scanner.ErrorList{ - &scanner.Error{Msg: "foobar"}, -} -var badScannerErrorList = scanner.ErrorList{ - &scanner.Error{"foobar"}, // ERROR "unkeyed fields" -} - -// Check whitelisted structs: if vet is run with --compositewhitelist=false, -// this line triggers an error. -var whitelistedPoint = image.Point{1, 2} - -// Do not check type from unknown package. -// See issue 15408. -var unknownPkgVar = unknownpkg.Foobar{"foo", "bar"} - -// A named pointer slice of CaseRange to test issue 23539. In -// particular, we're interested in how some slice elements omit their -// type. -var goodNamedPointerSliceLiteral = []*unicode.CaseRange{ - {Lo: 1, Hi: 2}, - &unicode.CaseRange{Lo: 1, Hi: 2}, -} -var badNamedPointerSliceLiteral = []*unicode.CaseRange{ - {1, 2}, // ERROR "unkeyed fields" - &unicode.CaseRange{1, 2}, // ERROR "unkeyed fields" -} diff --git a/libgo/go/cmd/vet/testdata/copylock.go b/libgo/go/cmd/vet/testdata/copylock.go deleted file mode 100644 index e9902a27f10..00000000000 --- a/libgo/go/cmd/vet/testdata/copylock.go +++ /dev/null @@ -1,188 +0,0 @@ -package testdata - -import ( - "sync" - "sync/atomic" - "unsafe" - . "unsafe" - unsafe1 "unsafe" -) - -func OkFunc() { - var x *sync.Mutex - p := x - var y sync.Mutex - p = &y - - var z = sync.Mutex{} - w := sync.Mutex{} - - w = sync.Mutex{} - q := struct{ L sync.Mutex }{ - L: sync.Mutex{}, - } - - yy := []Tlock{ - Tlock{}, - Tlock{ - once: sync.Once{}, - }, - } - - nl := new(sync.Mutex) - mx := make([]sync.Mutex, 10) - xx := struct{ L *sync.Mutex }{ - L: new(sync.Mutex), - } -} - -type Tlock struct { - once sync.Once -} - -func BadFunc() { - var x *sync.Mutex - p := x - var y sync.Mutex - p = &y - *p = *x // ERROR "assignment copies lock value to \*p: sync.Mutex" - - var t Tlock - var tp *Tlock - tp = &t - *tp = t // ERROR "assignment copies lock value to \*tp: testdata.Tlock contains sync.Once contains sync.Mutex" - t = *tp // ERROR "assignment copies lock value to t: testdata.Tlock contains sync.Once contains sync.Mutex" - - y := *x // ERROR "assignment copies lock value to y: sync.Mutex" - var z = t // ERROR "variable declaration copies lock value to z: testdata.Tlock contains sync.Once contains sync.Mutex" - - w := struct{ L sync.Mutex }{ - L: *x, // ERROR "literal copies lock value from \*x: sync.Mutex" - } - var q = map[int]Tlock{ - 1: t, // ERROR "literal copies lock value from t: testdata.Tlock contains sync.Once contains sync.Mutex" - 2: *tp, // ERROR "literal copies lock value from \*tp: testdata.Tlock contains sync.Once contains sync.Mutex" - } - yy := []Tlock{ - t, // ERROR "literal copies lock value from t: testdata.Tlock contains sync.Once contains sync.Mutex" - *tp, // ERROR "literal copies lock value from \*tp: testdata.Tlock contains sync.Once contains sync.Mutex" - } - - // override 'new' keyword - new := func(interface{}) {} - new(t) // ERROR "call of new copies lock value: testdata.Tlock contains sync.Once contains sync.Mutex" - - // copy of array of locks - var muA [5]sync.Mutex - muB := muA // ERROR "assignment copies lock value to muB: sync.Mutex" - muA = muB // ERROR "assignment copies lock value to muA: sync.Mutex" - muSlice := muA[:] // OK - - // multidimensional array - var mmuA [5][5]sync.Mutex - mmuB := mmuA // ERROR "assignment copies lock value to mmuB: sync.Mutex" - mmuA = mmuB // ERROR "assignment copies lock value to mmuA: sync.Mutex" - mmuSlice := mmuA[:] // OK - - // slice copy is ok - var fmuA [5][][5]sync.Mutex - fmuB := fmuA // OK - fmuA = fmuB // OK - fmuSlice := fmuA[:] // OK -} - -func LenAndCapOnLockArrays() { - var a [5]sync.Mutex - aLen := len(a) // OK - aCap := cap(a) // OK - - // override 'len' and 'cap' keywords - - len := func(interface{}) {} - len(a) // ERROR "call of len copies lock value: sync.Mutex" - - cap := func(interface{}) {} - cap(a) // ERROR "call of cap copies lock value: sync.Mutex" -} - -func SizeofMutex() { - var mu sync.Mutex - unsafe.Sizeof(mu) // OK - unsafe1.Sizeof(mu) // OK - Sizeof(mu) // OK - unsafe := struct{ Sizeof func(interface{}) }{} - unsafe.Sizeof(mu) // ERROR "call of unsafe.Sizeof copies lock value: sync.Mutex" - Sizeof := func(interface{}) {} - Sizeof(mu) // ERROR "call of Sizeof copies lock value: sync.Mutex" -} - -// SyncTypesCheck checks copying of sync.* types except sync.Mutex -func SyncTypesCheck() { - // sync.RWMutex copying - var rwmuX sync.RWMutex - var rwmuXX = sync.RWMutex{} - rwmuX1 := new(sync.RWMutex) - rwmuY := rwmuX // ERROR "assignment copies lock value to rwmuY: sync.RWMutex" - rwmuY = rwmuX // ERROR "assignment copies lock value to rwmuY: sync.RWMutex" - var rwmuYY = rwmuX // ERROR "variable declaration copies lock value to rwmuYY: sync.RWMutex" - rwmuP := &rwmuX - rwmuZ := &sync.RWMutex{} - - // sync.Cond copying - var condX sync.Cond - var condXX = sync.Cond{} - condX1 := new(sync.Cond) - condY := condX // ERROR "assignment copies lock value to condY: sync.Cond contains sync.noCopy" - condY = condX // ERROR "assignment copies lock value to condY: sync.Cond contains sync.noCopy" - var condYY = condX // ERROR "variable declaration copies lock value to condYY: sync.Cond contains sync.noCopy" - condP := &condX - condZ := &sync.Cond{ - L: &sync.Mutex{}, - } - condZ = sync.NewCond(&sync.Mutex{}) - - // sync.WaitGroup copying - var wgX sync.WaitGroup - var wgXX = sync.WaitGroup{} - wgX1 := new(sync.WaitGroup) - wgY := wgX // ERROR "assignment copies lock value to wgY: sync.WaitGroup contains sync.noCopy" - wgY = wgX // ERROR "assignment copies lock value to wgY: sync.WaitGroup contains sync.noCopy" - var wgYY = wgX // ERROR "variable declaration copies lock value to wgYY: sync.WaitGroup contains sync.noCopy" - wgP := &wgX - wgZ := &sync.WaitGroup{} - - // sync.Pool copying - var poolX sync.Pool - var poolXX = sync.Pool{} - poolX1 := new(sync.Pool) - poolY := poolX // ERROR "assignment copies lock value to poolY: sync.Pool contains sync.noCopy" - poolY = poolX // ERROR "assignment copies lock value to poolY: sync.Pool contains sync.noCopy" - var poolYY = poolX // ERROR "variable declaration copies lock value to poolYY: sync.Pool contains sync.noCopy" - poolP := &poolX - poolZ := &sync.Pool{} - - // sync.Once copying - var onceX sync.Once - var onceXX = sync.Once{} - onceX1 := new(sync.Once) - onceY := onceX // ERROR "assignment copies lock value to onceY: sync.Once contains sync.Mutex" - onceY = onceX // ERROR "assignment copies lock value to onceY: sync.Once contains sync.Mutex" - var onceYY = onceX // ERROR "variable declaration copies lock value to onceYY: sync.Once contains sync.Mutex" - onceP := &onceX - onceZ := &sync.Once{} -} - -// AtomicTypesCheck checks copying of sync/atomic types -func AtomicTypesCheck() { - // atomic.Value copying - var vX atomic.Value - var vXX = atomic.Value{} - vX1 := new(atomic.Value) - // These are OK because the value has not been used yet. - // (And vet can't tell whether it has been used, so they're always OK.) - vY := vX - vY = vX - var vYY = vX - vP := &vX - vZ := &atomic.Value{} -} diff --git a/libgo/go/cmd/vet/testdata/copylock_func.go b/libgo/go/cmd/vet/testdata/copylock_func.go deleted file mode 100644 index 280747a3bf4..00000000000 --- a/libgo/go/cmd/vet/testdata/copylock_func.go +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This file contains tests for the copylock checker's -// function declaration analysis. - -package testdata - -import "sync" - -func OkFunc(*sync.Mutex) {} -func BadFunc(sync.Mutex) {} // ERROR "BadFunc passes lock by value: sync.Mutex" -func BadFunc2(sync.Map) {} // ERROR "BadFunc2 passes lock by value: sync.Map contains sync.Mutex" -func OkRet() *sync.Mutex {} -func BadRet() sync.Mutex {} // Don't warn about results - -var ( - OkClosure = func(*sync.Mutex) {} - BadClosure = func(sync.Mutex) {} // ERROR "func passes lock by value: sync.Mutex" - BadClosure2 = func(sync.Map) {} // ERROR "func passes lock by value: sync.Map contains sync.Mutex" -) - -type EmbeddedRWMutex struct { - sync.RWMutex -} - -func (*EmbeddedRWMutex) OkMeth() {} -func (EmbeddedRWMutex) BadMeth() {} // ERROR "BadMeth passes lock by value: testdata.EmbeddedRWMutex" -func OkFunc(e *EmbeddedRWMutex) {} -func BadFunc(EmbeddedRWMutex) {} // ERROR "BadFunc passes lock by value: testdata.EmbeddedRWMutex" -func OkRet() *EmbeddedRWMutex {} -func BadRet() EmbeddedRWMutex {} // Don't warn about results - -type FieldMutex struct { - s sync.Mutex -} - -func (*FieldMutex) OkMeth() {} -func (FieldMutex) BadMeth() {} // ERROR "BadMeth passes lock by value: testdata.FieldMutex contains sync.Mutex" -func OkFunc(*FieldMutex) {} -func BadFunc(FieldMutex, int) {} // ERROR "BadFunc passes lock by value: testdata.FieldMutex contains sync.Mutex" - -type L0 struct { - L1 -} - -type L1 struct { - l L2 -} - -type L2 struct { - sync.Mutex -} - -func (*L0) Ok() {} -func (L0) Bad() {} // ERROR "Bad passes lock by value: testdata.L0 contains testdata.L1 contains testdata.L2" - -type EmbeddedMutexPointer struct { - s *sync.Mutex // safe to copy this pointer -} - -func (*EmbeddedMutexPointer) Ok() {} -func (EmbeddedMutexPointer) AlsoOk() {} -func StillOk(EmbeddedMutexPointer) {} -func LookinGood() EmbeddedMutexPointer {} - -type EmbeddedLocker struct { - sync.Locker // safe to copy interface values -} - -func (*EmbeddedLocker) Ok() {} -func (EmbeddedLocker) AlsoOk() {} - -type CustomLock struct{} - -func (*CustomLock) Lock() {} -func (*CustomLock) Unlock() {} - -func Ok(*CustomLock) {} -func Bad(CustomLock) {} // ERROR "Bad passes lock by value: testdata.CustomLock" - -// Passing lock values into interface function arguments -func FuncCallInterfaceArg(f func(a int, b interface{})) { - var m sync.Mutex - var t struct{ lock sync.Mutex } - - f(1, "foo") - f(2, &t) - f(3, &sync.Mutex{}) - f(4, m) // ERROR "call of f copies lock value: sync.Mutex" - f(5, t) // ERROR "call of f copies lock value: struct.lock sync.Mutex. contains sync.Mutex" - var fntab []func(t) - fntab[0](t) // ERROR "call of fntab.0. copies lock value: struct.lock sync.Mutex. contains sync.Mutex" -} - -// Returning lock via interface value -func ReturnViaInterface(x int) (int, interface{}) { - var m sync.Mutex - var t struct{ lock sync.Mutex } - - switch x % 4 { - case 0: - return 0, "qwe" - case 1: - return 1, &sync.Mutex{} - case 2: - return 2, m // ERROR "return copies lock value: sync.Mutex" - default: - return 3, t // ERROR "return copies lock value: struct.lock sync.Mutex. contains sync.Mutex" - } -} - -// Some cases that we don't warn about. - -func AcceptedCases() { - x := EmbeddedRwMutex{} // composite literal on RHS is OK (#16227) - x = BadRet() // function call on RHS is OK (#16227) - x = *OKRet() // indirection of function call on RHS is OK (#16227) -} - -// TODO: Unfortunate cases - -// Non-ideal error message: -// Since we're looking for Lock methods, sync.Once's underlying -// sync.Mutex gets called out, but without any reference to the sync.Once. -type LocalOnce sync.Once - -func (LocalOnce) Bad() {} // ERROR "Bad passes lock by value: testdata.LocalOnce contains sync.Mutex" - -// False negative: -// LocalMutex doesn't have a Lock method. -// Nevertheless, it is probably a bad idea to pass it by value. -type LocalMutex sync.Mutex - -func (LocalMutex) Bad() {} // WANTED: An error here :( diff --git a/libgo/go/cmd/vet/testdata/copylock_range.go b/libgo/go/cmd/vet/testdata/copylock_range.go deleted file mode 100644 index f127381213c..00000000000 --- a/libgo/go/cmd/vet/testdata/copylock_range.go +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This file contains tests for the copylock checker's -// range statement analysis. - -package testdata - -import "sync" - -func rangeMutex() { - var mu sync.Mutex - var i int - - var s []sync.Mutex - for range s { - } - for i = range s { - } - for i := range s { - } - for i, _ = range s { - } - for i, _ := range s { - } - for _, mu = range s { // ERROR "range var mu copies lock: sync.Mutex" - } - for _, m := range s { // ERROR "range var m copies lock: sync.Mutex" - } - for i, mu = range s { // ERROR "range var mu copies lock: sync.Mutex" - } - for i, m := range s { // ERROR "range var m copies lock: sync.Mutex" - } - - var a [3]sync.Mutex - for _, m := range a { // ERROR "range var m copies lock: sync.Mutex" - } - - var m map[sync.Mutex]sync.Mutex - for k := range m { // ERROR "range var k copies lock: sync.Mutex" - } - for mu, _ = range m { // ERROR "range var mu copies lock: sync.Mutex" - } - for k, _ := range m { // ERROR "range var k copies lock: sync.Mutex" - } - for _, mu = range m { // ERROR "range var mu copies lock: sync.Mutex" - } - for _, v := range m { // ERROR "range var v copies lock: sync.Mutex" - } - - var c chan sync.Mutex - for range c { - } - for mu = range c { // ERROR "range var mu copies lock: sync.Mutex" - } - for v := range c { // ERROR "range var v copies lock: sync.Mutex" - } - - // Test non-idents in range variables - var t struct { - i int - mu sync.Mutex - } - for t.i, t.mu = range s { // ERROR "range var t.mu copies lock: sync.Mutex" - } -} diff --git a/libgo/go/cmd/vet/testdata/deadcode.go b/libgo/go/cmd/vet/testdata/deadcode.go deleted file mode 100644 index d1a7adee38d..00000000000 --- a/libgo/go/cmd/vet/testdata/deadcode.go +++ /dev/null @@ -1,2134 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// This file contains tests for the dead code checker. - -package testdata - -type T int - -var x interface{} -var c chan int - -func external() int // ok - -func _() int { -} - -func _() int { - print(1) -} - -func _() int { - print(1) - return 2 - println() // ERROR "unreachable code" -} - -func _() int { -L: - print(1) - goto L - println() // ERROR "unreachable code" -} - -func _() int { - print(1) - panic(2) - println() // ERROR "unreachable code" -} - -// but only builtin panic -func _() int { - var panic = func(int) {} - print(1) - panic(2) - println() // ok -} - -func _() int { - { - print(1) - return 2 - println() // ERROR "unreachable code" - } - println() // ok -} - -func _() int { - { - print(1) - return 2 - } - println() // ERROR "unreachable code" -} - -func _() int { -L: - { - print(1) - goto L - println() // ERROR "unreachable code" - } - println() // ok -} - -func _() int { -L: - { - print(1) - goto L - } - println() // ERROR "unreachable code" -} - -func _() int { - print(1) - { - panic(2) - } -} - -func _() int { - print(1) - { - panic(2) - println() // ERROR "unreachable code" - } -} - -func _() int { - print(1) - { - panic(2) - } - println() // ERROR "unreachable code" -} - -func _() int { - print(1) - return 2 - { // ERROR "unreachable code" - } -} - -func _() int { -L: - print(1) - goto L - { // ERROR "unreachable code" - } -} - -func _() int { - print(1) - panic(2) - { // ERROR "unreachable code" - } -} - -func _() int { - { - print(1) - return 2 - { // ERROR "unreachable code" - } - } -} - -func _() int { -L: - { - print(1) - goto L - { // ERROR "unreachable code" - } - } -} - -func _() int { - print(1) - { - panic(2) - { // ERROR "unreachable code" - } - } -} - -func _() int { - { - print(1) - return 2 - } - { // ERROR "unreachable code" - } -} - -func _() int { -L: - { - print(1) - goto L - } - { // ERROR "unreachable code" - } -} - -func _() int { - print(1) - { - panic(2) - } - { // ERROR "unreachable code" - } -} - -func _() int { - print(1) - if x == nil { - panic(2) - } else { - panic(3) - } - println() // ERROR "unreachable code" -} - -func _() int { -L: - print(1) - if x == nil { - panic(2) - } else { - goto L - } - println() // ERROR "unreachable code" -} - -func _() int { -L: - print(1) - if x == nil { - panic(2) - } else if x == 1 { - return 0 - } else if x != 2 { - panic(3) - } else { - goto L - } - println() // ERROR "unreachable code" -} - -// if-else chain missing final else is not okay, even if the -// conditions cover every possible case. - -func _() int { - print(1) - if x == nil { - panic(2) - } else if x != nil { - panic(3) - } - println() // ok -} - -func _() int { - print(1) - if x == nil { - panic(2) - } - println() // ok -} - -func _() int { -L: - print(1) - if x == nil { - panic(2) - } else if x == 1 { - return 0 - } else if x != 1 { - panic(3) - } - println() // ok -} - -func _() int { - print(1) - for { - } - println() // ERROR "unreachable code" -} - -func _() int { - for { - for { - break - } - } - println() // ERROR "unreachable code" -} - -func _() int { - for { - for { - break - println() // ERROR "unreachable code" - } - } -} - -func _() int { - for { - for { - continue - println() // ERROR "unreachable code" - } - } -} - -func _() int { - for { - L: - for { - break L - } - } - println() // ERROR "unreachable code" -} - -func _() int { - print(1) - for { - break - } - println() // ok -} - -func _() int { - for { - for { - } - break // ERROR "unreachable code" - } - println() // ok -} - -func _() int { -L: - for { - for { - break L - } - } - println() // ok -} - -func _() int { - print(1) - for x == nil { - } - println() // ok -} - -func _() int { - for x == nil { - for { - break - } - } - println() // ok -} - -func _() int { - for x == nil { - L: - for { - break L - } - } - println() // ok -} - -func _() int { - print(1) - for true { - } - println() // ok -} - -func _() int { - for true { - for { - break - } - } - println() // ok -} - -func _() int { - for true { - L: - for { - break L - } - } - println() // ok -} - -func _() int { - print(1) - select {} - println() // ERROR "unreachable code" -} - -func _() int { - print(1) - select { - case <-c: - print(2) - panic("abc") - println() // ERROR "unreachable code" - } -} - -func _() int { - print(1) - select { - case <-c: - print(2) - panic("abc") - } - println() // ERROR "unreachable code" -} - -func _() int { - print(1) - select { - case <-c: - print(2) - for { - } - println() // ERROR "unreachable code" - } -} - -func _() int { - print(1) - select { - case <-c: - print(2) - for { - } - } - println() // ERROR "unreachable code" -} - -func _() int { -L: - print(1) - select { - case <-c: - print(2) - panic("abc") - println() // ERROR "unreachable code" - case c <- 1: - print(2) - goto L - println() // ERROR "unreachable code" - } -} - -func _() int { -L: - print(1) - select { - case <-c: - print(2) - panic("abc") - case c <- 1: - print(2) - goto L - } - println() // ERROR "unreachable code" -} - -func _() int { - print(1) - select { - case <-c: - print(2) - panic("abc") - println() // ERROR "unreachable code" - default: - select {} - println() // ERROR "unreachable code" - } -} - -func _() int { - print(1) - select { - case <-c: - print(2) - panic("abc") - default: - select {} - } - println() // ERROR "unreachable code" -} - -func _() int { - print(1) - select { - case <-c: - print(2) - } - println() // ok -} - -func _() int { -L: - print(1) - select { - case <-c: - print(2) - panic("abc") - goto L // ERROR "unreachable code" - case c <- 1: - print(2) - } - println() // ok -} - -func _() int { - print(1) - select { - case <-c: - print(2) - panic("abc") - default: - print(2) - } - println() // ok -} - -func _() int { - print(1) - select { - default: - break - } - println() // ok -} - -func _() int { - print(1) - select { - case <-c: - print(2) - panic("abc") - break // ERROR "unreachable code" - } - println() // ok -} - -func _() int { - print(1) -L: - select { - case <-c: - print(2) - for { - break L - } - } - println() // ok -} - -func _() int { - print(1) -L: - select { - case <-c: - print(2) - panic("abc") - case c <- 1: - print(2) - break L - } - println() // ok -} - -func _() int { - print(1) - select { - case <-c: - print(1) - panic("abc") - default: - select {} - break // ERROR "unreachable code" - } - println() // ok -} - -func _() int { - print(1) - switch x { - case 1: - print(2) - panic(3) - println() // ERROR "unreachable code" - default: - return 4 - println() // ERROR "unreachable code" - } -} - -func _() int { - print(1) - switch x { - case 1: - print(2) - panic(3) - default: - return 4 - } - println() // ERROR "unreachable code" -} - -func _() int { - print(1) - switch x { - default: - return 4 - println() // ERROR "unreachable code" - case 1: - print(2) - panic(3) - println() // ERROR "unreachable code" - } -} - -func _() int { - print(1) - switch x { - default: - return 4 - case 1: - print(2) - panic(3) - } - println() // ERROR "unreachable code" -} - -func _() int { - print(1) - switch x { - case 1: - print(2) - fallthrough - default: - return 4 - println() // ERROR "unreachable code" - } -} - -func _() int { - print(1) - switch x { - case 1: - print(2) - fallthrough - default: - return 4 - } - println() // ERROR "unreachable code" -} - -func _() int { - print(1) - switch { - } - println() // ok -} - -func _() int { - print(1) - switch x { - case 1: - print(2) - panic(3) - case 2: - return 4 - } - println() // ok -} - -func _() int { - print(1) - switch x { - case 2: - return 4 - case 1: - print(2) - panic(3) - } - println() // ok -} - -func _() int { - print(1) - switch x { - case 1: - print(2) - fallthrough - case 2: - return 4 - } - println() // ok -} - -func _() int { - print(1) - switch x { - case 1: - print(2) - panic(3) - } - println() // ok -} - -func _() int { - print(1) -L: - switch x { - case 1: - print(2) - panic(3) - break L // ERROR "unreachable code" - default: - return 4 - } - println() // ok -} - -func _() int { - print(1) - switch x { - default: - return 4 - break // ERROR "unreachable code" - case 1: - print(2) - panic(3) - } - println() // ok -} - -func _() int { - print(1) -L: - switch x { - case 1: - print(2) - for { - break L - } - default: - return 4 - } - println() // ok -} - -func _() int { - print(1) - switch x.(type) { - case int: - print(2) - panic(3) - println() // ERROR "unreachable code" - default: - return 4 - println() // ERROR "unreachable code" - } -} - -func _() int { - print(1) - switch x.(type) { - case int: - print(2) - panic(3) - default: - return 4 - } - println() // ERROR "unreachable code" -} - -func _() int { - print(1) - switch x.(type) { - default: - return 4 - println() // ERROR "unreachable code" - case int: - print(2) - panic(3) - println() // ERROR "unreachable code" - } -} - -func _() int { - print(1) - switch x.(type) { - default: - return 4 - case int: - print(2) - panic(3) - } - println() // ERROR "unreachable code" -} - -func _() int { - print(1) - switch x.(type) { - case int: - print(2) - fallthrough - default: - return 4 - println() // ERROR "unreachable code" - } -} - -func _() int { - print(1) - switch x.(type) { - case int: - print(2) - fallthrough - default: - return 4 - } - println() // ERROR "unreachable code" -} - -func _() int { - print(1) - switch { - } - println() // ok -} - -func _() int { - print(1) - switch x.(type) { - case int: - print(2) - panic(3) - case float64: - return 4 - } - println() // ok -} - -func _() int { - print(1) - switch x.(type) { - case float64: - return 4 - case int: - print(2) - panic(3) - } - println() // ok -} - -func _() int { - print(1) - switch x.(type) { - case int: - print(2) - fallthrough - case float64: - return 4 - } - println() // ok -} - -func _() int { - print(1) - switch x.(type) { - case int: - print(2) - panic(3) - } - println() // ok -} - -func _() int { - print(1) -L: - switch x.(type) { - case int: - print(2) - panic(3) - break L // ERROR "unreachable code" - default: - return 4 - } - println() // ok -} - -func _() int { - print(1) - switch x.(type) { - default: - return 4 - break // ERROR "unreachable code" - case int: - print(2) - panic(3) - } - println() // ok -} - -func _() int { - print(1) -L: - switch x.(type) { - case int: - print(2) - for { - break L - } - default: - return 4 - } - println() // ok -} - -// again, but without the leading print(1). -// testing that everything works when the terminating statement is first. - -func _() int { - println() // ok -} - -func _() int { - return 2 - println() // ERROR "unreachable code" -} - -func _() int { -L: - goto L - println() // ERROR "unreachable code" -} - -func _() int { - panic(2) - println() // ERROR "unreachable code" -} - -// but only builtin panic -func _() int { - var panic = func(int) {} - panic(2) - println() // ok -} - -func _() int { - { - return 2 - println() // ERROR "unreachable code" - } -} - -func _() int { - { - return 2 - } - println() // ERROR "unreachable code" -} - -func _() int { -L: - { - goto L - println() // ERROR "unreachable code" - } -} - -func _() int { -L: - { - goto L - } - println() // ERROR "unreachable code" -} - -func _() int { - { - panic(2) - println() // ERROR "unreachable code" - } -} - -func _() int { - { - panic(2) - } - println() // ERROR "unreachable code" -} - -func _() int { - return 2 - { // ERROR "unreachable code" - } - println() // ok -} - -func _() int { -L: - goto L - { // ERROR "unreachable code" - } - println() // ok -} - -func _() int { - panic(2) - { // ERROR "unreachable code" - } - println() // ok -} - -func _() int { - { - return 2 - { // ERROR "unreachable code" - } - } - println() // ok -} - -func _() int { -L: - { - goto L - { // ERROR "unreachable code" - } - } - println() // ok -} - -func _() int { - { - panic(2) - { // ERROR "unreachable code" - } - } - println() // ok -} - -func _() int { - { - return 2 - } - { // ERROR "unreachable code" - } - println() // ok -} - -func _() int { -L: - { - goto L - } - { // ERROR "unreachable code" - } - println() // ok -} - -func _() int { - { - panic(2) - } - { // ERROR "unreachable code" - } - println() // ok -} - -// again, with func literals - -var _ = func() int { -} - -var _ = func() int { - print(1) -} - -var _ = func() int { - print(1) - return 2 - println() // ERROR "unreachable code" -} - -var _ = func() int { -L: - print(1) - goto L - println() // ERROR "unreachable code" -} - -var _ = func() int { - print(1) - panic(2) - println() // ERROR "unreachable code" -} - -// but only builtin panic -var _ = func() int { - var panic = func(int) {} - print(1) - panic(2) - println() // ok -} - -var _ = func() int { - { - print(1) - return 2 - println() // ERROR "unreachable code" - } - println() // ok -} - -var _ = func() int { - { - print(1) - return 2 - } - println() // ERROR "unreachable code" -} - -var _ = func() int { -L: - { - print(1) - goto L - println() // ERROR "unreachable code" - } - println() // ok -} - -var _ = func() int { -L: - { - print(1) - goto L - } - println() // ERROR "unreachable code" -} - -var _ = func() int { - print(1) - { - panic(2) - } -} - -var _ = func() int { - print(1) - { - panic(2) - println() // ERROR "unreachable code" - } -} - -var _ = func() int { - print(1) - { - panic(2) - } - println() // ERROR "unreachable code" -} - -var _ = func() int { - print(1) - return 2 - { // ERROR "unreachable code" - } -} - -var _ = func() int { -L: - print(1) - goto L - { // ERROR "unreachable code" - } -} - -var _ = func() int { - print(1) - panic(2) - { // ERROR "unreachable code" - } -} - -var _ = func() int { - { - print(1) - return 2 - { // ERROR "unreachable code" - } - } -} - -var _ = func() int { -L: - { - print(1) - goto L - { // ERROR "unreachable code" - } - } -} - -var _ = func() int { - print(1) - { - panic(2) - { // ERROR "unreachable code" - } - } -} - -var _ = func() int { - { - print(1) - return 2 - } - { // ERROR "unreachable code" - } -} - -var _ = func() int { -L: - { - print(1) - goto L - } - { // ERROR "unreachable code" - } -} - -var _ = func() int { - print(1) - { - panic(2) - } - { // ERROR "unreachable code" - } -} - -var _ = func() int { - print(1) - if x == nil { - panic(2) - } else { - panic(3) - } - println() // ERROR "unreachable code" -} - -var _ = func() int { -L: - print(1) - if x == nil { - panic(2) - } else { - goto L - } - println() // ERROR "unreachable code" -} - -var _ = func() int { -L: - print(1) - if x == nil { - panic(2) - } else if x == 1 { - return 0 - } else if x != 2 { - panic(3) - } else { - goto L - } - println() // ERROR "unreachable code" -} - -// if-else chain missing final else is not okay, even if the -// conditions cover every possible case. - -var _ = func() int { - print(1) - if x == nil { - panic(2) - } else if x != nil { - panic(3) - } - println() // ok -} - -var _ = func() int { - print(1) - if x == nil { - panic(2) - } - println() // ok -} - -var _ = func() int { -L: - print(1) - if x == nil { - panic(2) - } else if x == 1 { - return 0 - } else if x != 1 { - panic(3) - } - println() // ok -} - -var _ = func() int { - print(1) - for { - } - println() // ERROR "unreachable code" -} - -var _ = func() int { - for { - for { - break - } - } - println() // ERROR "unreachable code" -} - -var _ = func() int { - for { - for { - break - println() // ERROR "unreachable code" - } - } -} - -var _ = func() int { - for { - for { - continue - println() // ERROR "unreachable code" - } - } -} - -var _ = func() int { - for { - L: - for { - break L - } - } - println() // ERROR "unreachable code" -} - -var _ = func() int { - print(1) - for { - break - } - println() // ok -} - -var _ = func() int { - for { - for { - } - break // ERROR "unreachable code" - } - println() // ok -} - -var _ = func() int { -L: - for { - for { - break L - } - } - println() // ok -} - -var _ = func() int { - print(1) - for x == nil { - } - println() // ok -} - -var _ = func() int { - for x == nil { - for { - break - } - } - println() // ok -} - -var _ = func() int { - for x == nil { - L: - for { - break L - } - } - println() // ok -} - -var _ = func() int { - print(1) - for true { - } - println() // ok -} - -var _ = func() int { - for true { - for { - break - } - } - println() // ok -} - -var _ = func() int { - for true { - L: - for { - break L - } - } - println() // ok -} - -var _ = func() int { - print(1) - select {} - println() // ERROR "unreachable code" -} - -var _ = func() int { - print(1) - select { - case <-c: - print(2) - panic("abc") - println() // ERROR "unreachable code" - } -} - -var _ = func() int { - print(1) - select { - case <-c: - print(2) - panic("abc") - } - println() // ERROR "unreachable code" -} - -var _ = func() int { - print(1) - select { - case <-c: - print(2) - for { - } - println() // ERROR "unreachable code" - } -} - -var _ = func() int { - print(1) - select { - case <-c: - print(2) - for { - } - } - println() // ERROR "unreachable code" -} - -var _ = func() int { -L: - print(1) - select { - case <-c: - print(2) - panic("abc") - println() // ERROR "unreachable code" - case c <- 1: - print(2) - goto L - println() // ERROR "unreachable code" - } -} - -var _ = func() int { -L: - print(1) - select { - case <-c: - print(2) - panic("abc") - case c <- 1: - print(2) - goto L - } - println() // ERROR "unreachable code" -} - -var _ = func() int { - print(1) - select { - case <-c: - print(2) - panic("abc") - println() // ERROR "unreachable code" - default: - select {} - println() // ERROR "unreachable code" - } -} - -var _ = func() int { - print(1) - select { - case <-c: - print(2) - panic("abc") - default: - select {} - } - println() // ERROR "unreachable code" -} - -var _ = func() int { - print(1) - select { - case <-c: - print(2) - } - println() // ok -} - -var _ = func() int { -L: - print(1) - select { - case <-c: - print(2) - panic("abc") - goto L // ERROR "unreachable code" - case c <- 1: - print(2) - } - println() // ok -} - -var _ = func() int { - print(1) - select { - case <-c: - print(2) - panic("abc") - default: - print(2) - } - println() // ok -} - -var _ = func() int { - print(1) - select { - default: - break - } - println() // ok -} - -var _ = func() int { - print(1) - select { - case <-c: - print(2) - panic("abc") - break // ERROR "unreachable code" - } - println() // ok -} - -var _ = func() int { - print(1) -L: - select { - case <-c: - print(2) - for { - break L - } - } - println() // ok -} - -var _ = func() int { - print(1) -L: - select { - case <-c: - print(2) - panic("abc") - case c <- 1: - print(2) - break L - } - println() // ok -} - -var _ = func() int { - print(1) - select { - case <-c: - print(1) - panic("abc") - default: - select {} - break // ERROR "unreachable code" - } - println() // ok -} - -var _ = func() int { - print(1) - switch x { - case 1: - print(2) - panic(3) - println() // ERROR "unreachable code" - default: - return 4 - println() // ERROR "unreachable code" - } -} - -var _ = func() int { - print(1) - switch x { - case 1: - print(2) - panic(3) - default: - return 4 - } - println() // ERROR "unreachable code" -} - -var _ = func() int { - print(1) - switch x { - default: - return 4 - println() // ERROR "unreachable code" - case 1: - print(2) - panic(3) - println() // ERROR "unreachable code" - } -} - -var _ = func() int { - print(1) - switch x { - default: - return 4 - case 1: - print(2) - panic(3) - } - println() // ERROR "unreachable code" -} - -var _ = func() int { - print(1) - switch x { - case 1: - print(2) - fallthrough - default: - return 4 - println() // ERROR "unreachable code" - } -} - -var _ = func() int { - print(1) - switch x { - case 1: - print(2) - fallthrough - default: - return 4 - } - println() // ERROR "unreachable code" -} - -var _ = func() int { - print(1) - switch { - } - println() // ok -} - -var _ = func() int { - print(1) - switch x { - case 1: - print(2) - panic(3) - case 2: - return 4 - } - println() // ok -} - -var _ = func() int { - print(1) - switch x { - case 2: - return 4 - case 1: - print(2) - panic(3) - } - println() // ok -} - -var _ = func() int { - print(1) - switch x { - case 1: - print(2) - fallthrough - case 2: - return 4 - } - println() // ok -} - -var _ = func() int { - print(1) - switch x { - case 1: - print(2) - panic(3) - } - println() // ok -} - -var _ = func() int { - print(1) -L: - switch x { - case 1: - print(2) - panic(3) - break L // ERROR "unreachable code" - default: - return 4 - } - println() // ok -} - -var _ = func() int { - print(1) - switch x { - default: - return 4 - break // ERROR "unreachable code" - case 1: - print(2) - panic(3) - } - println() // ok -} - -var _ = func() int { - print(1) -L: - switch x { - case 1: - print(2) - for { - break L - } - default: - return 4 - } - println() // ok -} - -var _ = func() int { - print(1) - switch x.(type) { - case int: - print(2) - panic(3) - println() // ERROR "unreachable code" - default: - return 4 - println() // ERROR "unreachable code" - } -} - -var _ = func() int { - print(1) - switch x.(type) { - case int: - print(2) - panic(3) - default: - return 4 - } - println() // ERROR "unreachable code" -} - -var _ = func() int { - print(1) - switch x.(type) { - default: - return 4 - println() // ERROR "unreachable code" - case int: - print(2) - panic(3) - println() // ERROR "unreachable code" - } -} - -var _ = func() int { - print(1) - switch x.(type) { - default: - return 4 - case int: - print(2) - panic(3) - } - println() // ERROR "unreachable code" -} - -var _ = func() int { - print(1) - switch x.(type) { - case int: - print(2) - fallthrough - default: - return 4 - println() // ERROR "unreachable code" - } -} - -var _ = func() int { - print(1) - switch x.(type) { - case int: - print(2) - fallthrough - default: - return 4 - } - println() // ERROR "unreachable code" -} - -var _ = func() int { - print(1) - switch { - } - println() // ok -} - -var _ = func() int { - print(1) - switch x.(type) { - case int: - print(2) - panic(3) - case float64: - return 4 - } - println() // ok -} - -var _ = func() int { - print(1) - switch x.(type) { - case float64: - return 4 - case int: - print(2) - panic(3) - } - println() // ok -} - -var _ = func() int { - print(1) - switch x.(type) { - case int: - print(2) - fallthrough - case float64: - return 4 - } - println() // ok -} - -var _ = func() int { - print(1) - switch x.(type) { - case int: - print(2) - panic(3) - } - println() // ok -} - -var _ = func() int { - print(1) -L: - switch x.(type) { - case int: - print(2) - panic(3) - break L // ERROR "unreachable code" - default: - return 4 - } - println() // ok -} - -var _ = func() int { - print(1) - switch x.(type) { - default: - return 4 - break // ERROR "unreachable code" - case int: - print(2) - panic(3) - } - println() // ok -} - -var _ = func() int { - print(1) -L: - switch x.(type) { - case int: - print(2) - for { - break L - } - default: - return 4 - } - println() // ok -} - -// again, but without the leading print(1). -// testing that everything works when the terminating statement is first. - -var _ = func() int { - println() // ok -} - -var _ = func() int { - return 2 - println() // ERROR "unreachable code" -} - -var _ = func() int { -L: - goto L - println() // ERROR "unreachable code" -} - -var _ = func() int { - panic(2) - println() // ERROR "unreachable code" -} - -// but only builtin panic -var _ = func() int { - var panic = func(int) {} - panic(2) - println() // ok -} - -var _ = func() int { - { - return 2 - println() // ERROR "unreachable code" - } -} - -var _ = func() int { - { - return 2 - } - println() // ERROR "unreachable code" -} - -var _ = func() int { -L: - { - goto L - println() // ERROR "unreachable code" - } -} - -var _ = func() int { -L: - { - goto L - } - println() // ERROR "unreachable code" -} - -var _ = func() int { - { - panic(2) - println() // ERROR "unreachable code" - } -} - -var _ = func() int { - { - panic(2) - } - println() // ERROR "unreachable code" -} - -var _ = func() int { - return 2 - { // ERROR "unreachable code" - } - println() // ok -} - -var _ = func() int { -L: - goto L - { // ERROR "unreachable code" - } - println() // ok -} - -var _ = func() int { - panic(2) - { // ERROR "unreachable code" - } - println() // ok -} - -var _ = func() int { - { - return 2 - { // ERROR "unreachable code" - } - } - println() // ok -} - -var _ = func() int { -L: - { - goto L - { // ERROR "unreachable code" - } - } - println() // ok -} - -var _ = func() int { - { - panic(2) - { // ERROR "unreachable code" - } - } - println() // ok -} - -var _ = func() int { - { - return 2 - } - { // ERROR "unreachable code" - } - println() // ok -} - -var _ = func() int { -L: - { - goto L - } - { // ERROR "unreachable code" - } - println() // ok -} - -var _ = func() int { - { - panic(2) - } - { // ERROR "unreachable code" - } - println() // ok -} - -var _ = func() { - // goto without label used to panic - goto -} - -func _() int { - // Empty switch tag with non-bool case value used to panic. - switch { - case 1: - println() - } - println() -} diff --git a/libgo/go/cmd/vet/testdata/divergent/buf.go b/libgo/go/cmd/vet/testdata/divergent/buf.go deleted file mode 100644 index 0efe0f838d5..00000000000 --- a/libgo/go/cmd/vet/testdata/divergent/buf.go +++ /dev/null @@ -1,17 +0,0 @@ -// Test of examples with divergent packages. - -// Package buf ... -package buf - -// Buf is a ... -type Buf []byte - -// Append ... -func (*Buf) Append([]byte) {} - -func (Buf) Reset() {} - -func (Buf) Len() int { return 0 } - -// DefaultBuf is a ... -var DefaultBuf Buf diff --git a/libgo/go/cmd/vet/testdata/divergent/buf_test.go b/libgo/go/cmd/vet/testdata/divergent/buf_test.go deleted file mode 100644 index b75d55eaf4f..00000000000 --- a/libgo/go/cmd/vet/testdata/divergent/buf_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// Test of examples with divergent packages. - -package buf_test - -func Example() {} // OK because is package-level. - -func Example_suffix() {} // OK because refers to suffix annotation. - -func Example_BadSuffix() {} // ERROR "Example_BadSuffix has malformed example suffix: BadSuffix" - -func ExampleBuf() {} // OK because refers to known top-level type. - -func ExampleBuf_Append() {} // OK because refers to known method. - -func ExampleBuf_Clear() {} // ERROR "ExampleBuf_Clear refers to unknown field or method: Buf.Clear" - -func ExampleBuf_suffix() {} // OK because refers to suffix annotation. - -func ExampleBuf_Append_Bad() {} // ERROR "ExampleBuf_Append_Bad has malformed example suffix: Bad" - -func ExampleBuf_Append_suffix() {} // OK because refers to known method with valid suffix. - -func ExampleDefaultBuf() {} // OK because refers to top-level identifier. - -func ExampleBuf_Reset() bool { return true } // ERROR "ExampleBuf_Reset should return nothing" - -func ExampleBuf_Len(i int) {} // ERROR "ExampleBuf_Len should be niladic" - -// "Puffer" is German for "Buffer". - -func ExamplePuffer() {} // ERROR "ExamplePuffer refers to unknown identifier: Puffer" - -func ExamplePuffer_Append() {} // ERROR "ExamplePuffer_Append refers to unknown identifier: Puffer" - -func ExamplePuffer_suffix() {} // ERROR "ExamplePuffer_suffix refers to unknown identifier: Puffer" diff --git a/libgo/go/cmd/vet/testdata/httpresponse.go b/libgo/go/cmd/vet/testdata/httpresponse.go deleted file mode 100644 index 7302a64a3b6..00000000000 --- a/libgo/go/cmd/vet/testdata/httpresponse.go +++ /dev/null @@ -1,85 +0,0 @@ -package testdata - -import ( - "log" - "net/http" -) - -func goodHTTPGet() { - res, err := http.Get("http://foo.com") - if err != nil { - log.Fatal(err) - } - defer res.Body.Close() -} - -func badHTTPGet() { - res, err := http.Get("http://foo.com") - defer res.Body.Close() // ERROR "using res before checking for errors" - if err != nil { - log.Fatal(err) - } -} - -func badHTTPHead() { - res, err := http.Head("http://foo.com") - defer res.Body.Close() // ERROR "using res before checking for errors" - if err != nil { - log.Fatal(err) - } -} - -func goodClientGet() { - client := http.DefaultClient - res, err := client.Get("http://foo.com") - if err != nil { - log.Fatal(err) - } - defer res.Body.Close() -} - -func badClientPtrGet() { - client := http.DefaultClient - resp, err := client.Get("http://foo.com") - defer resp.Body.Close() // ERROR "using resp before checking for errors" - if err != nil { - log.Fatal(err) - } -} - -func badClientGet() { - client := http.Client{} - resp, err := client.Get("http://foo.com") - defer resp.Body.Close() // ERROR "using resp before checking for errors" - if err != nil { - log.Fatal(err) - } -} - -func badClientPtrDo() { - client := http.DefaultClient - req, err := http.NewRequest("GET", "http://foo.com", nil) - if err != nil { - log.Fatal(err) - } - - resp, err := client.Do(req) - defer resp.Body.Close() // ERROR "using resp before checking for errors" - if err != nil { - log.Fatal(err) - } -} - -func badClientDo() { - var client http.Client - req, err := http.NewRequest("GET", "http://foo.com", nil) - if err != nil { - log.Fatal(err) - } - - resp, err := client.Do(req) - defer resp.Body.Close() // ERROR "using resp before checking for errors" - if err != nil { - log.Fatal(err) - } -} diff --git a/libgo/go/cmd/vet/testdata/incomplete/examples_test.go b/libgo/go/cmd/vet/testdata/incomplete/examples_test.go deleted file mode 100644 index 445502b39ec..00000000000 --- a/libgo/go/cmd/vet/testdata/incomplete/examples_test.go +++ /dev/null @@ -1,33 +0,0 @@ -// Test of examples. - -package testdata - -func Example() {} // OK because is package-level. - -func Example_suffix() // OK because refers to suffix annotation. - -func Example_BadSuffix() // OK because non-test package was excluded. No false positives wanted. - -func ExampleBuf() // OK because non-test package was excluded. No false positives wanted. - -func ExampleBuf_Append() {} // OK because non-test package was excluded. No false positives wanted. - -func ExampleBuf_Clear() {} // OK because non-test package was excluded. No false positives wanted. - -func ExampleBuf_suffix() {} // OK because refers to suffix annotation. - -func ExampleBuf_Append_Bad() {} // OK because non-test package was excluded. No false positives wanted. - -func ExampleBuf_Append_suffix() {} // OK because refers to known method with valid suffix. - -func ExampleBuf_Reset() bool { return true } // ERROR "ExampleBuf_Reset should return nothing" - -func ExampleBuf_Len(i int) {} // ERROR "ExampleBuf_Len should be niladic" - -// "Puffer" is German for "Buffer". - -func ExamplePuffer() // OK because non-test package was excluded. No false positives wanted. - -func ExamplePuffer_Append() // OK because non-test package was excluded. No false positives wanted. - -func ExamplePuffer_suffix() // OK because non-test package was excluded. No false positives wanted. diff --git a/libgo/go/cmd/vet/testdata/lostcancel.go b/libgo/go/cmd/vet/testdata/lostcancel.go deleted file mode 100644 index b7549c00511..00000000000 --- a/libgo/go/cmd/vet/testdata/lostcancel.go +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package testdata - -import ( - "context" - "log" - "os" - "testing" -) - -// Check the three functions and assignment forms (var, :=, =) we look for. -// (Do these early: line numbers are fragile.) -func _() { - var ctx, cancel = context.WithCancel() // ERROR "the cancel function is not used on all paths \(possible context leak\)" -} // ERROR "this return statement may be reached without using the cancel var defined on line 17" - -func _() { - ctx, cancel2 := context.WithDeadline() // ERROR "the cancel2 function is not used..." -} // ERROR "may be reached without using the cancel2 var defined on line 21" - -func _() { - var ctx context.Context - var cancel3 func() - ctx, cancel3 = context.WithTimeout() // ERROR "function is not used..." -} // ERROR "this return statement may be reached without using the cancel3 var defined on line 27" - -func _() { - ctx, _ := context.WithCancel() // ERROR "the cancel function returned by context.WithCancel should be called, not discarded, to avoid a context leak" - ctx, _ = context.WithTimeout() // ERROR "the cancel function returned by context.WithTimeout should be called, not discarded, to avoid a context leak" - ctx, _ = context.WithDeadline() // ERROR "the cancel function returned by context.WithDeadline should be called, not discarded, to avoid a context leak" -} - -func _() { - ctx, cancel := context.WithCancel() - defer cancel() // ok -} - -func _() { - ctx, cancel := context.WithCancel() // ERROR "not used on all paths" - if condition { - cancel() - } - return // ERROR "this return statement may be reached without using the cancel var" -} - -func _() { - ctx, cancel := context.WithCancel() - if condition { - cancel() - } else { - // ok: infinite loop - for { - print(0) - } - } -} - -func _() { - ctx, cancel := context.WithCancel() // ERROR "not used on all paths" - if condition { - cancel() - } else { - for i := 0; i < 10; i++ { - print(0) - } - } -} // ERROR "this return statement may be reached without using the cancel var" - -func _() { - ctx, cancel := context.WithCancel() - // ok: used on all paths - switch someInt { - case 0: - new(testing.T).FailNow() - case 1: - log.Fatal() - case 2: - cancel() - case 3: - print("hi") - fallthrough - default: - os.Exit(1) - } -} - -func _() { - ctx, cancel := context.WithCancel() // ERROR "not used on all paths" - switch someInt { - case 0: - new(testing.T).FailNow() - case 1: - log.Fatal() - case 2: - cancel() - case 3: - print("hi") // falls through to implicit return - default: - os.Exit(1) - } -} // ERROR "this return statement may be reached without using the cancel var" - -func _(ch chan int) int { - ctx, cancel := context.WithCancel() // ERROR "not used on all paths" - select { - case <-ch: - new(testing.T).FailNow() - case y <- ch: - print("hi") // falls through to implicit return - case ch <- 1: - cancel() - default: - os.Exit(1) - } -} // ERROR "this return statement may be reached without using the cancel var" - -func _(ch chan int) int { - ctx, cancel := context.WithCancel() - // A blocking select must execute one of its cases. - select { - case <-ch: - panic() - } -} - -func _() { - go func() { - ctx, cancel := context.WithCancel() // ERROR "not used on all paths" - print(ctx) - }() // ERROR "may be reached without using the cancel var" -} - -var condition bool -var someInt int - -// Regression test for Go issue 16143. -func _() { - var x struct{ f func() } - x.f() -} - -// Regression test for Go issue 16230. -func _() (ctx context.Context, cancel func()) { - ctx, cancel = context.WithCancel() - return // a naked return counts as a load of the named result values -} - -// Same as above, but for literal function. -var _ = func() (ctx context.Context, cancel func()) { - ctx, cancel = context.WithCancel() - return -} diff --git a/libgo/go/cmd/vet/testdata/nilfunc.go b/libgo/go/cmd/vet/testdata/nilfunc.go deleted file mode 100644 index 2ce7bc8ca82..00000000000 --- a/libgo/go/cmd/vet/testdata/nilfunc.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package testdata - -func F() {} - -type T struct { - F func() -} - -func (T) M() {} - -var Fv = F - -func Comparison() { - var t T - var fn func() - if fn == nil || Fv == nil || t.F == nil { - // no error; these func vars or fields may be nil - } - if F == nil { // ERROR "comparison of function F == nil is always false" - panic("can't happen") - } - if t.M == nil { // ERROR "comparison of function M == nil is always false" - panic("can't happen") - } - if F != nil { // ERROR "comparison of function F != nil is always true" - if t.M != nil { // ERROR "comparison of function M != nil is always true" - return - } - } - panic("can't happen") -} diff --git a/libgo/go/cmd/vet/testdata/rangeloop.go b/libgo/go/cmd/vet/testdata/rangeloop.go deleted file mode 100644 index cd3b4cbc452..00000000000 --- a/libgo/go/cmd/vet/testdata/rangeloop.go +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This file contains tests for the rangeloop checker. - -package testdata - -func RangeLoopTests() { - var s []int - for i, v := range s { - go func() { - println(i) // ERROR "loop variable i captured by func literal" - println(v) // ERROR "loop variable v captured by func literal" - }() - } - for i, v := range s { - defer func() { - println(i) // ERROR "loop variable i captured by func literal" - println(v) // ERROR "loop variable v captured by func literal" - }() - } - for i := range s { - go func() { - println(i) // ERROR "loop variable i captured by func literal" - }() - } - for _, v := range s { - go func() { - println(v) // ERROR "loop variable v captured by func literal" - }() - } - for i, v := range s { - go func() { - println(i, v) - }() - println("unfortunately, we don't catch the error above because of this statement") - } - for i, v := range s { - go func(i, v int) { - println(i, v) - }(i, v) - } - for i, v := range s { - i, v := i, v - go func() { - println(i, v) - }() - } - // If the key of the range statement is not an identifier - // the code should not panic (it used to). - var x [2]int - var f int - for x[0], f = range s { - go func() { - _ = f // ERROR "loop variable f captured by func literal" - }() - } - type T struct { - v int - } - for _, v := range s { - go func() { - _ = T{v: 1} - _ = []int{v: 1} // ERROR "loop variable v captured by func literal" - }() - } - - // ordinary for-loops - for i := 0; i < 10; i++ { - go func() { - print(i) // ERROR "loop variable i captured by func literal" - }() - } - for i, j := 0, 1; i < 100; i, j = j, i+j { - go func() { - print(j) // ERROR "loop variable j captured by func literal" - }() - } - type cons struct { - car int - cdr *cons - } - var head *cons - for p := head; p != nil; p = p.next { - go func() { - print(p.car) // ERROR "loop variable p captured by func literal" - }() - } -} diff --git a/libgo/go/cmd/vet/testdata/shadow.go b/libgo/go/cmd/vet/testdata/shadow.go deleted file mode 100644 index c55cb2772a9..00000000000 --- a/libgo/go/cmd/vet/testdata/shadow.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This file contains tests for the shadowed variable checker. -// Some of these errors are caught by the compiler (shadowed return parameters for example) -// but are nonetheless useful tests. - -package testdata - -import "os" - -func ShadowRead(f *os.File, buf []byte) (err error) { - var x int - if f != nil { - err := 3 // OK - different type. - _ = err - } - if f != nil { - _, err := f.Read(buf) // ERROR "declaration of .err. shadows declaration at shadow.go:13" - if err != nil { - return err - } - i := 3 // OK - _ = i - } - if f != nil { - x := one() // ERROR "declaration of .x. shadows declaration at shadow.go:14" - var _, err = f.Read(buf) // ERROR "declaration of .err. shadows declaration at shadow.go:13" - if x == 1 && err != nil { - return err - } - } - for i := 0; i < 10; i++ { - i := i // OK: obviously intentional idiomatic redeclaration - go func() { - println(i) - }() - } - var shadowTemp interface{} - switch shadowTemp := shadowTemp.(type) { // OK: obviously intentional idiomatic redeclaration - case int: - println("OK") - _ = shadowTemp - } - if shadowTemp := shadowTemp; true { // OK: obviously intentional idiomatic redeclaration - var f *os.File // OK because f is not mentioned later in the function. - // The declaration of x is a shadow because x is mentioned below. - var x int // ERROR "declaration of .x. shadows declaration at shadow.go:14" - _, _, _ = x, f, shadowTemp - } - // Use a couple of variables to trigger shadowing errors. - _, _ = err, x - return -} - -func one() int { - return 1 -} diff --git a/libgo/go/cmd/vet/testdata/shift.go b/libgo/go/cmd/vet/testdata/shift.go deleted file mode 100644 index 73cbaf88418..00000000000 --- a/libgo/go/cmd/vet/testdata/shift.go +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This file contains tests for the suspicious shift checker. - -package testdata - -import ( - "fmt" - "unsafe" -) - -func ShiftTest() { - var i8 int8 - _ = i8 << 7 - _ = (i8 + 1) << 8 // ERROR ".i8 . 1. .8 bits. too small for shift of 8" - _ = i8 << (7 + 1) // ERROR "i8 .8 bits. too small for shift of 8" - _ = i8 >> 8 // ERROR "i8 .8 bits. too small for shift of 8" - i8 <<= 8 // ERROR "i8 .8 bits. too small for shift of 8" - i8 >>= 8 // ERROR "i8 .8 bits. too small for shift of 8" - var i16 int16 - _ = i16 << 15 - _ = i16 << 16 // ERROR "i16 .16 bits. too small for shift of 16" - _ = i16 >> 16 // ERROR "i16 .16 bits. too small for shift of 16" - i16 <<= 16 // ERROR "i16 .16 bits. too small for shift of 16" - i16 >>= 16 // ERROR "i16 .16 bits. too small for shift of 16" - var i32 int32 - _ = i32 << 31 - _ = i32 << 32 // ERROR "i32 .32 bits. too small for shift of 32" - _ = i32 >> 32 // ERROR "i32 .32 bits. too small for shift of 32" - i32 <<= 32 // ERROR "i32 .32 bits. too small for shift of 32" - i32 >>= 32 // ERROR "i32 .32 bits. too small for shift of 32" - var i64 int64 - _ = i64 << 63 - _ = i64 << 64 // ERROR "i64 .64 bits. too small for shift of 64" - _ = i64 >> 64 // ERROR "i64 .64 bits. too small for shift of 64" - i64 <<= 64 // ERROR "i64 .64 bits. too small for shift of 64" - i64 >>= 64 // ERROR "i64 .64 bits. too small for shift of 64" - var u8 uint8 - _ = u8 << 7 - _ = u8 << 8 // ERROR "u8 .8 bits. too small for shift of 8" - _ = u8 >> 8 // ERROR "u8 .8 bits. too small for shift of 8" - u8 <<= 8 // ERROR "u8 .8 bits. too small for shift of 8" - u8 >>= 8 // ERROR "u8 .8 bits. too small for shift of 8" - var u16 uint16 - _ = u16 << 15 - _ = u16 << 16 // ERROR "u16 .16 bits. too small for shift of 16" - _ = u16 >> 16 // ERROR "u16 .16 bits. too small for shift of 16" - u16 <<= 16 // ERROR "u16 .16 bits. too small for shift of 16" - u16 >>= 16 // ERROR "u16 .16 bits. too small for shift of 16" - var u32 uint32 - _ = u32 << 31 - _ = u32 << 32 // ERROR "u32 .32 bits. too small for shift of 32" - _ = u32 >> 32 // ERROR "u32 .32 bits. too small for shift of 32" - u32 <<= 32 // ERROR "u32 .32 bits. too small for shift of 32" - u32 >>= 32 // ERROR "u32 .32 bits. too small for shift of 32" - var u64 uint64 - _ = u64 << 63 - _ = u64 << 64 // ERROR "u64 .64 bits. too small for shift of 64" - _ = u64 >> 64 // ERROR "u64 .64 bits. too small for shift of 64" - u64 <<= 64 // ERROR "u64 .64 bits. too small for shift of 64" - u64 >>= 64 // ERROR "u64 .64 bits. too small for shift of 64" - _ = u64 << u64 // Non-constant shifts should succeed. - - var i int - _ = i << 31 - const in = 8 * unsafe.Sizeof(i) - _ = i << in // ERROR "too small for shift" - _ = i >> in // ERROR "too small for shift" - i <<= in // ERROR "too small for shift" - i >>= in // ERROR "too small for shift" - const ix = 8*unsafe.Sizeof(i) - 1 - _ = i << ix - _ = i >> ix - i <<= ix - i >>= ix - - var u uint - _ = u << 31 - const un = 8 * unsafe.Sizeof(u) - _ = u << un // ERROR "too small for shift" - _ = u >> un // ERROR "too small for shift" - u <<= un // ERROR "too small for shift" - u >>= un // ERROR "too small for shift" - const ux = 8*unsafe.Sizeof(u) - 1 - _ = u << ux - _ = u >> ux - u <<= ux - u >>= ux - - var p uintptr - _ = p << 31 - const pn = 8 * unsafe.Sizeof(p) - _ = p << pn // ERROR "too small for shift" - _ = p >> pn // ERROR "too small for shift" - p <<= pn // ERROR "too small for shift" - p >>= pn // ERROR "too small for shift" - const px = 8*unsafe.Sizeof(p) - 1 - _ = p << px - _ = p >> px - p <<= px - p >>= px - - const oneIf64Bit = ^uint(0) >> 63 // allow large shifts of constants; they are used for 32/64 bit compatibility tricks - - var h uintptr - h = h<<8 | (h >> (8 * (unsafe.Sizeof(h) - 1))) - h <<= 8 * unsafe.Sizeof(h) // ERROR "too small for shift" - h >>= 7 * unsafe.Alignof(h) - h >>= 8 * unsafe.Alignof(h) // ERROR "too small for shift" -} - -func ShiftDeadCode() { - var i int - const iBits = 8 * unsafe.Sizeof(i) - - if iBits <= 32 { - if iBits == 16 { - _ = i >> 8 - } else { - _ = i >> 16 - } - } else { - _ = i >> 32 - } - - if iBits >= 64 { - _ = i << 32 - if iBits == 128 { - _ = i << 64 - } - } else { - _ = i << 16 - } - - if iBits == 64 { - _ = i << 32 - } - - switch iBits { - case 128, 64: - _ = i << 32 - default: - _ = i << 16 - } - - switch { - case iBits < 32: - _ = i << 16 - case iBits > 64: - _ = i << 64 - default: - _ = i << 64 // ERROR "too small for shift" - } - - // Make sure other vet checks work in dead code. - if iBits == 1024 { - _ = i << 512 // OK - fmt.Printf("foo %s bar", 123) // ERROR "Printf" - } -} diff --git a/libgo/go/cmd/vet/testdata/src/asm/asm.go b/libgo/go/cmd/vet/testdata/src/asm/asm.go new file mode 100644 index 00000000000..72ff452aae8 --- /dev/null +++ b/libgo/go/cmd/vet/testdata/src/asm/asm.go @@ -0,0 +1,9 @@ +// Copyright 2010 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file contains declarations to test the assembly in asm1.s. + +package testdata + +func arg1(x int8, y uint8) diff --git a/libgo/go/cmd/vet/testdata/src/asm/asm1.s b/libgo/go/cmd/vet/testdata/src/asm/asm1.s new file mode 100644 index 00000000000..c3ba986fb8b --- /dev/null +++ b/libgo/go/cmd/vet/testdata/src/asm/asm1.s @@ -0,0 +1,8 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build amd64 + +TEXT ·arg1(SB),0,$0-2 + MOVW x+0(FP), AX // ERROR "\[amd64\] arg1: invalid MOVW of x\+0\(FP\); int8 is 1-byte value" diff --git a/libgo/go/cmd/vet/testdata/assign.go b/libgo/go/cmd/vet/testdata/src/assign/assign.go similarity index 97% rename from libgo/go/cmd/vet/testdata/assign.go rename to libgo/go/cmd/vet/testdata/src/assign/assign.go index 6140ad4db8c..112614e562c 100644 --- a/libgo/go/cmd/vet/testdata/assign.go +++ b/libgo/go/cmd/vet/testdata/src/assign/assign.go @@ -4,7 +4,7 @@ // This file contains tests for the useless-assignment checker. -package testdata +package assign import "math/rand" diff --git a/libgo/go/cmd/vet/testdata/src/atomic/atomic.go b/libgo/go/cmd/vet/testdata/src/atomic/atomic.go new file mode 100644 index 00000000000..650d56bdada --- /dev/null +++ b/libgo/go/cmd/vet/testdata/src/atomic/atomic.go @@ -0,0 +1,14 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file contains tests for the atomic checker. + +package atomic + +import "sync/atomic" + +func AtomicTests() { + x := uint64(1) + x = atomic.AddUint64(&x, 1) // ERROR "direct assignment to atomic value" +} diff --git a/libgo/go/cmd/vet/testdata/src/bool/bool.go b/libgo/go/cmd/vet/testdata/src/bool/bool.go new file mode 100644 index 00000000000..20e01aa46f0 --- /dev/null +++ b/libgo/go/cmd/vet/testdata/src/bool/bool.go @@ -0,0 +1,14 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file contains tests for the bool checker. + +package bool + +func _() { + var f, g func() int + + if v, w := f(), g(); v == w || v == w { // ERROR "redundant or: v == w || v == w" + } +} diff --git a/libgo/go/cmd/vet/testdata/buildtag/buildtag.go b/libgo/go/cmd/vet/testdata/src/buildtag/buildtag.go similarity index 100% rename from libgo/go/cmd/vet/testdata/buildtag/buildtag.go rename to libgo/go/cmd/vet/testdata/src/buildtag/buildtag.go diff --git a/libgo/go/cmd/vet/testdata/src/cgo/cgo.go b/libgo/go/cmd/vet/testdata/src/cgo/cgo.go new file mode 100644 index 00000000000..292d7fdab7d --- /dev/null +++ b/libgo/go/cmd/vet/testdata/src/cgo/cgo.go @@ -0,0 +1,18 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file contains tests for the cgo checker. + +package testdata + +// void f(void *p) {} +import "C" + +import "unsafe" + +func CgoTests() { + var c chan bool + C.f(*(*unsafe.Pointer)(unsafe.Pointer(&c))) // ERROR "embedded pointer" + C.f(unsafe.Pointer(&c)) // ERROR "embedded pointer" +} diff --git a/libgo/go/cmd/vet/testdata/src/composite/composite.go b/libgo/go/cmd/vet/testdata/src/composite/composite.go new file mode 100644 index 00000000000..63a28378515 --- /dev/null +++ b/libgo/go/cmd/vet/testdata/src/composite/composite.go @@ -0,0 +1,24 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file contains the test for untagged struct literals. + +package composite + +import "flag" + +// Testing is awkward because we need to reference things from a separate package +// to trigger the warnings. + +var goodStructLiteral = flag.Flag{ + Name: "Name", + Usage: "Usage", +} + +var badStructLiteral = flag.Flag{ // ERROR "unkeyed fields" + "Name", + "Usage", + nil, // Value + "DefValue", +} diff --git a/libgo/go/cmd/vet/testdata/src/copylock/copylock.go b/libgo/go/cmd/vet/testdata/src/copylock/copylock.go new file mode 100644 index 00000000000..8079cf3248b --- /dev/null +++ b/libgo/go/cmd/vet/testdata/src/copylock/copylock.go @@ -0,0 +1,11 @@ +package copylock + +import "sync" + +func BadFunc() { + var x *sync.Mutex + p := x + var y sync.Mutex + p = &y + *p = *x // ERROR "assignment copies lock value to \*p: sync.Mutex" +} diff --git a/libgo/go/cmd/vet/testdata/src/deadcode/deadcode.go b/libgo/go/cmd/vet/testdata/src/deadcode/deadcode.go new file mode 100644 index 00000000000..af83cdfbb1e --- /dev/null +++ b/libgo/go/cmd/vet/testdata/src/deadcode/deadcode.go @@ -0,0 +1,14 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file contains tests for the dead code checker. + +package deadcode + +func _() int { + print(1) + return 2 + println() // ERROR "unreachable code" + return 3 +} diff --git a/libgo/go/cmd/vet/testdata/src/httpresponse/httpresponse.go b/libgo/go/cmd/vet/testdata/src/httpresponse/httpresponse.go new file mode 100644 index 00000000000..6141f6e06dc --- /dev/null +++ b/libgo/go/cmd/vet/testdata/src/httpresponse/httpresponse.go @@ -0,0 +1,22 @@ +package httpresponse + +import ( + "log" + "net/http" +) + +func goodHTTPGet() { + res, err := http.Get("http://foo.com") + if err != nil { + log.Fatal(err) + } + defer res.Body.Close() +} + +func badHTTPGet() { + res, err := http.Get("http://foo.com") + defer res.Body.Close() // ERROR "using res before checking for errors" + if err != nil { + log.Fatal(err) + } +} diff --git a/libgo/go/cmd/vet/testdata/src/lostcancel/lostcancel.go b/libgo/go/cmd/vet/testdata/src/lostcancel/lostcancel.go new file mode 100644 index 00000000000..1bbb22d27b4 --- /dev/null +++ b/libgo/go/cmd/vet/testdata/src/lostcancel/lostcancel.go @@ -0,0 +1,14 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package lostcancel + +import "context" + +func _() { + var _, cancel = context.WithCancel(context.Background()) // ERROR "the cancel function is not used on all paths \(possible context leak\)" + if false { + _ = cancel + } +} // ERROR "this return statement may be reached without using the cancel var defined on line 10" diff --git a/libgo/go/cmd/vet/testdata/method.go b/libgo/go/cmd/vet/testdata/src/method/method.go similarity index 57% rename from libgo/go/cmd/vet/testdata/method.go rename to libgo/go/cmd/vet/testdata/src/method/method.go index 52b500df272..51c3f65fcc7 100644 --- a/libgo/go/cmd/vet/testdata/method.go +++ b/libgo/go/cmd/vet/testdata/src/method/method.go @@ -2,21 +2,13 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// This file contains tests for the canonical method checker. - // This file contains the code to check canonical methods. -package testdata +package method -import ( - "fmt" -) +import "fmt" type MethodTest int -func (t *MethodTest) Scan(x fmt.ScanState, c byte) { // ERROR "should have signature Scan" -} - -type MethodTestInterface interface { - ReadByte() byte // ERROR "should have signature ReadByte" +func (t *MethodTest) Scan(x fmt.ScanState, c byte) { // ERROR "should have signature Scan\(fmt\.ScanState, rune\) error" } diff --git a/libgo/go/cmd/vet/testdata/src/nilfunc/nilfunc.go b/libgo/go/cmd/vet/testdata/src/nilfunc/nilfunc.go new file mode 100644 index 00000000000..c34d60e0521 --- /dev/null +++ b/libgo/go/cmd/vet/testdata/src/nilfunc/nilfunc.go @@ -0,0 +1,13 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package nilfunc + +func F() {} + +func Comparison() { + if F == nil { // ERROR "comparison of function F == nil is always false" + panic("can't happen") + } +} diff --git a/libgo/go/cmd/vet/testdata/print.go b/libgo/go/cmd/vet/testdata/src/print/print.go similarity index 88% rename from libgo/go/cmd/vet/testdata/print.go rename to libgo/go/cmd/vet/testdata/src/print/print.go index ecafed5fa2f..6bacd0fd747 100644 --- a/libgo/go/cmd/vet/testdata/print.go +++ b/libgo/go/cmd/vet/testdata/src/print/print.go @@ -4,16 +4,10 @@ // This file contains tests for the printf checker. -// TODO(rsc): The user-defined wrapper tests are commented out -// because they produced too many false positives when vet was -// enabled during go test. See the TODO in ../print.go for a plan -// to fix that; when it's fixed, uncomment the user-defined wrapper tests. - -package testdata +package print import ( "fmt" - . "fmt" logpkg "log" // renamed to make it harder to see "math" "os" @@ -103,7 +97,7 @@ func PrintfTests() { fmt.Printf("%s", stringerarrayv) fmt.Printf("%v", notstringerarrayv) fmt.Printf("%T", notstringerarrayv) - fmt.Printf("%d", new(Formatter)) + fmt.Printf("%d", new(fmt.Formatter)) fmt.Printf("%*%", 2) // Ridiculous but allowed. fmt.Printf("%s", interface{}(nil)) // Nothing useful we can say. @@ -132,16 +126,16 @@ func PrintfTests() { fmt.Printf("%U", x) // ERROR "Printf format %U has arg x of wrong type float64" fmt.Printf("%x", nil) // ERROR "Printf format %x has arg nil of wrong type untyped nil" fmt.Printf("%X", 2.3) // ERROR "Printf format %X has arg 2.3 of wrong type float64" - fmt.Printf("%s", stringerv) // ERROR "Printf format %s has arg stringerv of wrong type testdata.ptrStringer" - fmt.Printf("%t", stringerv) // ERROR "Printf format %t has arg stringerv of wrong type testdata.ptrStringer" - fmt.Printf("%s", embeddedStringerv) // ERROR "Printf format %s has arg embeddedStringerv of wrong type testdata.embeddedStringer" - fmt.Printf("%t", embeddedStringerv) // ERROR "Printf format %t has arg embeddedStringerv of wrong type testdata.embeddedStringer" - fmt.Printf("%q", notstringerv) // ERROR "Printf format %q has arg notstringerv of wrong type testdata.notstringer" - fmt.Printf("%t", notstringerv) // ERROR "Printf format %t has arg notstringerv of wrong type testdata.notstringer" - fmt.Printf("%t", stringerarrayv) // ERROR "Printf format %t has arg stringerarrayv of wrong type testdata.stringerarray" - fmt.Printf("%t", notstringerarrayv) // ERROR "Printf format %t has arg notstringerarrayv of wrong type testdata.notstringerarray" - fmt.Printf("%q", notstringerarrayv) // ERROR "Printf format %q has arg notstringerarrayv of wrong type testdata.notstringerarray" - fmt.Printf("%d", BoolFormatter(true)) // ERROR "Printf format %d has arg BoolFormatter\(true\) of wrong type testdata.BoolFormatter" + fmt.Printf("%s", stringerv) // ERROR "Printf format %s has arg stringerv of wrong type print.ptrStringer" + fmt.Printf("%t", stringerv) // ERROR "Printf format %t has arg stringerv of wrong type print.ptrStringer" + fmt.Printf("%s", embeddedStringerv) // ERROR "Printf format %s has arg embeddedStringerv of wrong type print.embeddedStringer" + fmt.Printf("%t", embeddedStringerv) // ERROR "Printf format %t has arg embeddedStringerv of wrong type print.embeddedStringer" + fmt.Printf("%q", notstringerv) // ERROR "Printf format %q has arg notstringerv of wrong type print.notstringer" + fmt.Printf("%t", notstringerv) // ERROR "Printf format %t has arg notstringerv of wrong type print.notstringer" + fmt.Printf("%t", stringerarrayv) // ERROR "Printf format %t has arg stringerarrayv of wrong type print.stringerarray" + fmt.Printf("%t", notstringerarrayv) // ERROR "Printf format %t has arg notstringerarrayv of wrong type print.notstringerarray" + fmt.Printf("%q", notstringerarrayv) // ERROR "Printf format %q has arg notstringerarrayv of wrong type print.notstringerarray" + fmt.Printf("%d", BoolFormatter(true)) // ERROR "Printf format %d has arg BoolFormatter\(true\) of wrong type print.BoolFormatter" fmt.Printf("%z", FormatterVal(true)) // correct (the type is responsible for formatting) fmt.Printf("%d", FormatterVal(true)) // correct (the type is responsible for formatting) fmt.Printf("%s", nonemptyinterface) // correct (the type is responsible for formatting) @@ -192,10 +186,10 @@ func PrintfTests() { Printf("d%", 2) // ERROR "Printf format % is missing verb at end of string" Printf("%d", percentDV) Printf("%d", &percentDV) - Printf("%d", notPercentDV) // ERROR "Printf format %d has arg notPercentDV of wrong type testdata.notPercentDStruct" - Printf("%d", ¬PercentDV) // ERROR "Printf format %d has arg ¬PercentDV of wrong type \*testdata.notPercentDStruct" + Printf("%d", notPercentDV) // ERROR "Printf format %d has arg notPercentDV of wrong type print.notPercentDStruct" + Printf("%d", ¬PercentDV) // ERROR "Printf format %d has arg ¬PercentDV of wrong type \*print.notPercentDStruct" Printf("%p", ¬PercentDV) // Works regardless: we print it as a pointer. - Printf("%q", &percentDV) // ERROR "Printf format %q has arg &percentDV of wrong type \*testdata.percentDStruct" + Printf("%q", &percentDV) // ERROR "Printf format %q has arg &percentDV of wrong type \*print.percentDStruct" Printf("%s", percentSV) Printf("%s", &percentSV) // Good argument reorderings. @@ -240,7 +234,7 @@ func PrintfTests() { Printf("%T", someFunction) // ok: maybe someone wants to see the type // Bug: used to recur forever. Printf("%p %x", recursiveStructV, recursiveStructV.next) - Printf("%p %x", recursiveStruct1V, recursiveStruct1V.next) + Printf("%p %x", recursiveStruct1V, recursiveStruct1V.next) // ERROR "Printf format %x has arg recursiveStruct1V\.next of wrong type \*print\.RecursiveStruct2" Printf("%p %x", recursiveSliceV, recursiveSliceV) Printf("%p %x", recursiveMapV, recursiveMapV) // Special handling for Log. @@ -250,13 +244,13 @@ func PrintfTests() { t.Logf("%d", 3) t.Logf("%d", "hi") // ERROR "Logf format %d has arg \x22hi\x22 of wrong type string" - // Errorf(1, "%d", 3) // OK - // Errorf(1, "%d", "hi") // no error "Errorf format %d has arg \x22hi\x22 of wrong type string" + Errorf(1, "%d", 3) // OK + Errorf(1, "%d", "hi") // ERROR "Errorf format %d has arg \x22hi\x22 of wrong type string" // Multiple string arguments before variadic args - // errorf("WARNING", "foobar") // OK - // errorf("INFO", "s=%s, n=%d", "foo", 1) // OK - // errorf("ERROR", "%d") // no error "errorf format %d reads arg #1, but call has 0 args" + errorf("WARNING", "foobar") // OK + errorf("INFO", "s=%s, n=%d", "foo", 1) // OK + errorf("ERROR", "%d") // ERROR "errorf format %d reads arg #1, but call has 0 args" // Printf from external package // externalprintf.Printf("%d", 42) // OK @@ -348,46 +342,32 @@ func (ss *someStruct) log(f func(), args ...interface{}) {} // A function we use as a function value; it has no other purpose. func someFunction() {} -/* // Printf is used by the test so we must declare it. func Printf(format string, args ...interface{}) { - panic("don't call - testing only") + fmt.Printf(format, args...) } // Println is used by the test so we must declare it. func Println(args ...interface{}) { - panic("don't call - testing only") -} - -// Logf is used by the test so we must declare it. -func Logf(format string, args ...interface{}) { - panic("don't call - testing only") + fmt.Println(args...) } -// Log is used by the test so we must declare it. -func Log(args ...interface{}) { - panic("don't call - testing only") -} -*/ - // printf is used by the test so we must declare it. func printf(format string, args ...interface{}) { - panic("don't call - testing only") + fmt.Printf(format, args...) } -/* // Errorf is used by the test for a case in which the first parameter // is not a format string. func Errorf(i int, format string, args ...interface{}) { - panic("don't call - testing only") + _ = fmt.Errorf(format, args...) } // errorf is used by the test for a case in which the function accepts multiple // string parameters before variadic arguments func errorf(level, format string, args ...interface{}) { - panic("don't call - testing only") + _ = fmt.Errorf(format, args...) } -*/ // multi is used by the test. func multi() []interface{} { @@ -607,37 +587,37 @@ func UnexportedStringerOrError() { fmt.Printf("%s", unexportedInterface{3}) // ok; we can't see the problem us := unexportedStringer{} - fmt.Printf("%s", us) // ERROR "Printf format %s has arg us of wrong type testdata.unexportedStringer" - fmt.Printf("%s", &us) // ERROR "Printf format %s has arg &us of wrong type [*]testdata.unexportedStringer" + fmt.Printf("%s", us) // ERROR "Printf format %s has arg us of wrong type print.unexportedStringer" + fmt.Printf("%s", &us) // ERROR "Printf format %s has arg &us of wrong type [*]print.unexportedStringer" usf := unexportedStringerOtherFields{ s: "foo", S: "bar", } - fmt.Printf("%s", usf) // ERROR "Printf format %s has arg usf of wrong type testdata.unexportedStringerOtherFields" - fmt.Printf("%s", &usf) // ERROR "Printf format %s has arg &usf of wrong type [*]testdata.unexportedStringerOtherFields" + fmt.Printf("%s", usf) // ERROR "Printf format %s has arg usf of wrong type print.unexportedStringerOtherFields" + fmt.Printf("%s", &usf) // ERROR "Printf format %s has arg &usf of wrong type [*]print.unexportedStringerOtherFields" ue := unexportedError{ e: &errorer{}, } - fmt.Printf("%s", ue) // ERROR "Printf format %s has arg ue of wrong type testdata.unexportedError" - fmt.Printf("%s", &ue) // ERROR "Printf format %s has arg &ue of wrong type [*]testdata.unexportedError" + fmt.Printf("%s", ue) // ERROR "Printf format %s has arg ue of wrong type print.unexportedError" + fmt.Printf("%s", &ue) // ERROR "Printf format %s has arg &ue of wrong type [*]print.unexportedError" uef := unexportedErrorOtherFields{ s: "foo", e: &errorer{}, S: "bar", } - fmt.Printf("%s", uef) // ERROR "Printf format %s has arg uef of wrong type testdata.unexportedErrorOtherFields" - fmt.Printf("%s", &uef) // ERROR "Printf format %s has arg &uef of wrong type [*]testdata.unexportedErrorOtherFields" + fmt.Printf("%s", uef) // ERROR "Printf format %s has arg uef of wrong type print.unexportedErrorOtherFields" + fmt.Printf("%s", &uef) // ERROR "Printf format %s has arg &uef of wrong type [*]print.unexportedErrorOtherFields" uce := unexportedCustomError{ e: errorer{}, } - fmt.Printf("%s", uce) // ERROR "Printf format %s has arg uce of wrong type testdata.unexportedCustomError" + fmt.Printf("%s", uce) // ERROR "Printf format %s has arg uce of wrong type print.unexportedCustomError" uei := unexportedErrorInterface{} - fmt.Printf("%s", uei) // ERROR "Printf format %s has arg uei of wrong type testdata.unexportedErrorInterface" + fmt.Printf("%s", uei) // ERROR "Printf format %s has arg uei of wrong type print.unexportedErrorInterface" fmt.Println("foo\n", "bar") // not an error fmt.Println("foo\n") // ERROR "Println arg list ends with redundant newline" @@ -647,7 +627,7 @@ func UnexportedStringerOrError() { intSlice := []int{3, 4} fmt.Printf("%s", intSlice) // ERROR "Printf format %s has arg intSlice of wrong type \[\]int" nonStringerArray := [1]unexportedStringer{{}} - fmt.Printf("%s", nonStringerArray) // ERROR "Printf format %s has arg nonStringerArray of wrong type \[1\]testdata.unexportedStringer" + fmt.Printf("%s", nonStringerArray) // ERROR "Printf format %s has arg nonStringerArray of wrong type \[1\]print.unexportedStringer" fmt.Printf("%s", []stringer{3, 4}) // not an error fmt.Printf("%s", [2]stringer{3, 4}) // not an error } @@ -665,3 +645,37 @@ func dbg(format string, args ...interface{}) { } fmt.Printf(format, args...) } + +func PointersToCompoundTypes() { + stringSlice := []string{"a", "b"} + fmt.Printf("%s", &stringSlice) // not an error + + intSlice := []int{3, 4} + fmt.Printf("%s", &intSlice) // ERROR "Printf format %s has arg &intSlice of wrong type \*\[\]int" + + stringArray := [2]string{"a", "b"} + fmt.Printf("%s", &stringArray) // not an error + + intArray := [2]int{3, 4} + fmt.Printf("%s", &intArray) // ERROR "Printf format %s has arg &intArray of wrong type \*\[2\]int" + + stringStruct := struct{ F string }{"foo"} + fmt.Printf("%s", &stringStruct) // not an error + + intStruct := struct{ F int }{3} + fmt.Printf("%s", &intStruct) // ERROR "Printf format %s has arg &intStruct of wrong type \*struct{F int}" + + stringMap := map[string]string{"foo": "bar"} + fmt.Printf("%s", &stringMap) // not an error + + intMap := map[int]int{3: 4} + fmt.Printf("%s", &intMap) // ERROR "Printf format %s has arg &intMap of wrong type \*map\[int\]int" + + type T2 struct { + X string + } + type T1 struct { + X *T2 + } + fmt.Printf("%s\n", T1{&T2{"x"}}) // ERROR "Printf format %s has arg T1{&T2{.x.}} of wrong type print\.T1" +} diff --git a/libgo/go/cmd/vet/testdata/src/rangeloop/rangeloop.go b/libgo/go/cmd/vet/testdata/src/rangeloop/rangeloop.go new file mode 100644 index 00000000000..4e215641869 --- /dev/null +++ b/libgo/go/cmd/vet/testdata/src/rangeloop/rangeloop.go @@ -0,0 +1,17 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file contains tests for the rangeloop checker. + +package rangeloop + +func RangeLoopTests() { + var s []int + for i, v := range s { + go func() { + println(i) // ERROR "loop variable i captured by func literal" + println(v) // ERROR "loop variable v captured by func literal" + }() + } +} diff --git a/libgo/go/cmd/vet/testdata/src/shift/shift.go b/libgo/go/cmd/vet/testdata/src/shift/shift.go new file mode 100644 index 00000000000..6b7a5ac9e18 --- /dev/null +++ b/libgo/go/cmd/vet/testdata/src/shift/shift.go @@ -0,0 +1,13 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file contains tests for the suspicious shift checker. + +package shift + +func ShiftTest() { + var i8 int8 + _ = i8 << 7 + _ = (i8 + 1) << 8 // ERROR ".i8 . 1. .8 bits. too small for shift of 8" +} diff --git a/libgo/go/cmd/vet/testdata/src/structtag/structtag.go b/libgo/go/cmd/vet/testdata/src/structtag/structtag.go new file mode 100644 index 00000000000..cbcc4533760 --- /dev/null +++ b/libgo/go/cmd/vet/testdata/src/structtag/structtag.go @@ -0,0 +1,11 @@ +// Copyright 2010 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file contains the test for canonical struct tags. + +package structtag + +type StructTagTest struct { + A int "hello" // ERROR "`hello` not compatible with reflect.StructTag.Get: bad syntax for struct tag pair" +} diff --git a/libgo/go/cmd/vet/testdata/tagtest/file1.go b/libgo/go/cmd/vet/testdata/src/tagtest/file1.go similarity index 85% rename from libgo/go/cmd/vet/testdata/tagtest/file1.go rename to libgo/go/cmd/vet/testdata/src/tagtest/file1.go index 22a1509acc0..47fe3c80afe 100644 --- a/libgo/go/cmd/vet/testdata/tagtest/file1.go +++ b/libgo/go/cmd/vet/testdata/src/tagtest/file1.go @@ -6,5 +6,8 @@ package main +import "fmt" + func main() { + fmt.Printf("%s", 0) } diff --git a/libgo/go/cmd/vet/testdata/tagtest/file2.go b/libgo/go/cmd/vet/testdata/src/tagtest/file2.go similarity index 80% rename from libgo/go/cmd/vet/testdata/tagtest/file2.go rename to libgo/go/cmd/vet/testdata/src/tagtest/file2.go index ba7dd91bbd8..1f45efcbf2f 100644 --- a/libgo/go/cmd/vet/testdata/tagtest/file2.go +++ b/libgo/go/cmd/vet/testdata/src/tagtest/file2.go @@ -6,5 +6,8 @@ package main -func ignore() { +import "fmt" + +func main() { + fmt.Printf("%s", 0) } diff --git a/libgo/go/cmd/vet/testdata/testingpkg/tests.go b/libgo/go/cmd/vet/testdata/src/testingpkg/tests.go similarity index 100% rename from libgo/go/cmd/vet/testdata/testingpkg/tests.go rename to libgo/go/cmd/vet/testdata/src/testingpkg/tests.go diff --git a/libgo/go/cmd/vet/testdata/src/testingpkg/tests_test.go b/libgo/go/cmd/vet/testdata/src/testingpkg/tests_test.go new file mode 100644 index 00000000000..09bb98d980e --- /dev/null +++ b/libgo/go/cmd/vet/testdata/src/testingpkg/tests_test.go @@ -0,0 +1,3 @@ +package testdata + +func Example_BadSuffix() {} // ERROR "Example_BadSuffix has malformed example suffix: BadSuffix" diff --git a/libgo/go/cmd/vet/testdata/src/unmarshal/unmarshal.go b/libgo/go/cmd/vet/testdata/src/unmarshal/unmarshal.go new file mode 100644 index 00000000000..b387bbbd234 --- /dev/null +++ b/libgo/go/cmd/vet/testdata/src/unmarshal/unmarshal.go @@ -0,0 +1,18 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file contains tests for the unmarshal checker. + +package unmarshal + +import "encoding/json" + +func _() { + type t struct { + a int + } + var v t + + json.Unmarshal([]byte{}, v) // ERROR "call of Unmarshal passes non-pointer as second argument" +} diff --git a/libgo/go/cmd/vet/testdata/src/unsafeptr/unsafeptr.go b/libgo/go/cmd/vet/testdata/src/unsafeptr/unsafeptr.go new file mode 100644 index 00000000000..e9b866ea21b --- /dev/null +++ b/libgo/go/cmd/vet/testdata/src/unsafeptr/unsafeptr.go @@ -0,0 +1,14 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package unsafeptr + +import "unsafe" + +func _() { + var x unsafe.Pointer + var y uintptr + x = unsafe.Pointer(y) // ERROR "possible misuse of unsafe.Pointer" + _ = x +} diff --git a/libgo/go/cmd/vet/testdata/src/unused/unused.go b/libgo/go/cmd/vet/testdata/src/unused/unused.go new file mode 100644 index 00000000000..1e83e90d68f --- /dev/null +++ b/libgo/go/cmd/vet/testdata/src/unused/unused.go @@ -0,0 +1,13 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file contains tests for the unusedresult checker. + +package unused + +import "fmt" + +func _() { + fmt.Errorf("") // ERROR "result of fmt.Errorf call not used" +} diff --git a/libgo/go/cmd/vet/testdata/structtag.go b/libgo/go/cmd/vet/testdata/structtag.go deleted file mode 100644 index ce21e803c80..00000000000 --- a/libgo/go/cmd/vet/testdata/structtag.go +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This file contains the test for canonical struct tags. - -package testdata - -import "encoding/xml" - -type StructTagTest struct { - A int "hello" // ERROR "not compatible with reflect.StructTag.Get: bad syntax for struct tag pair" - B int "\tx:\"y\"" // ERROR "not compatible with reflect.StructTag.Get: bad syntax for struct tag key" - C int "x:\"y\"\tx:\"y\"" // ERROR "not compatible with reflect.StructTag.Get" - D int "x:`y`" // ERROR "not compatible with reflect.StructTag.Get: bad syntax for struct tag value" - E int "ct\brl:\"char\"" // ERROR "not compatible with reflect.StructTag.Get: bad syntax for struct tag pair" - F int `:"emptykey"` // ERROR "not compatible with reflect.StructTag.Get: bad syntax for struct tag key" - G int `x:"noEndQuote` // ERROR "not compatible with reflect.StructTag.Get: bad syntax for struct tag value" - H int `x:"trunc\x0"` // ERROR "not compatible with reflect.StructTag.Get: bad syntax for struct tag value" - I int `x:"foo",y:"bar"` // ERROR "not compatible with reflect.StructTag.Get: key:.value. pairs not separated by spaces" - J int `x:"foo"y:"bar"` // ERROR "not compatible with reflect.StructTag.Get: key:.value. pairs not separated by spaces" - OK0 int `x:"y" u:"v" w:""` - OK1 int `x:"y:z" u:"v" w:""` // note multiple colons. - OK2 int "k0:\"values contain spaces\" k1:\"literal\ttabs\" k2:\"and\\tescaped\\tabs\"" - OK3 int `under_scores:"and" CAPS:"ARE_OK"` -} - -type UnexportedEncodingTagTest struct { - x int `json:"xx"` // ERROR "struct field x has json tag but is not exported" - y int `xml:"yy"` // ERROR "struct field y has xml tag but is not exported" - z int - A int `json:"aa" xml:"bb"` -} - -type unexp struct{} - -type JSONEmbeddedField struct { - UnexportedEncodingTagTest `is:"embedded"` - unexp `is:"embedded,notexported" json:"unexp"` // OK for now, see issue 7363 -} - -type AnonymousJSON struct{} -type AnonymousXML struct{} - -type DuplicateJSONFields struct { - JSON int `json:"a"` - DuplicateJSON int `json:"a"` // ERROR "struct field DuplicateJSON repeats json tag .a. also at structtag.go:46" - IgnoredJSON int `json:"-"` - OtherIgnoredJSON int `json:"-"` - OmitJSON int `json:",omitempty"` - OtherOmitJSON int `json:",omitempty"` - DuplicateOmitJSON int `json:"a,omitempty"` // ERROR "struct field DuplicateOmitJSON repeats json tag .a. also at structtag.go:46" - NonJSON int `foo:"a"` - DuplicateNonJSON int `foo:"a"` - Embedded struct { - DuplicateJSON int `json:"a"` // OK because its not in the same struct type - } - AnonymousJSON `json:"a"` // ERROR "struct field AnonymousJSON repeats json tag .a. also at structtag.go:46" - - XML int `xml:"a"` - DuplicateXML int `xml:"a"` // ERROR "struct field DuplicateXML repeats xml tag .a. also at structtag.go:60" - IgnoredXML int `xml:"-"` - OtherIgnoredXML int `xml:"-"` - OmitXML int `xml:",omitempty"` - OtherOmitXML int `xml:",omitempty"` - DuplicateOmitXML int `xml:"a,omitempty"` // ERROR "struct field DuplicateOmitXML repeats xml tag .a. also at structtag.go:60" - NonXML int `foo:"a"` - DuplicateNonXML int `foo:"a"` - Embedded struct { - DuplicateXML int `xml:"a"` // OK because its not in the same struct type - } - AnonymousXML `xml:"a"` // ERROR "struct field AnonymousXML repeats xml tag .a. also at structtag.go:60" - Attribute struct { - XMLName xml.Name `xml:"b"` - NoDup int `xml:"b"` // OK because XMLName above affects enclosing struct. - Attr int `xml:"b,attr"` // OK because 0 is valid. - DupAttr int `xml:"b,attr"` // ERROR "struct field DupAttr repeats xml attribute tag .b. also at structtag.go:76" - DupOmitAttr int `xml:"b,omitempty,attr"` // ERROR "struct field DupOmitAttr repeats xml attribute tag .b. also at structtag.go:76" - - AnonymousXML `xml:"b,attr"` // ERROR "struct field AnonymousXML repeats xml attribute tag .b. also at structtag.go:76" - } -} - -type UnexpectedSpacetest struct { - A int `json:"a,omitempty"` - B int `json:"b, omitempty"` // ERROR "suspicious space in struct tag value" - C int `json:"c ,omitempty"` - D int `json:"d,omitempty, string"` // ERROR "suspicious space in struct tag value" - E int `xml:"e local"` - F int `xml:"f "` // ERROR "suspicious space in struct tag value" - G int `xml:" g"` // ERROR "suspicious space in struct tag value" - H int `xml:"h ,omitempty"` // ERROR "suspicious space in struct tag value" - I int `xml:"i, omitempty"` // ERROR "suspicious space in struct tag value" - J int `xml:"j local ,omitempty"` // ERROR "suspicious space in struct tag value" - K int `xml:"k local, omitempty"` // ERROR "suspicious space in struct tag value" - L int `xml:" l local,omitempty"` // ERROR "suspicious space in struct tag value" - M int `xml:"m local,omitempty"` // ERROR "suspicious space in struct tag value" - N int `xml:" "` // ERROR "suspicious space in struct tag value" - O int `xml:""` - P int `xml:","` - Q int `foo:" doesn't care "` -} diff --git a/libgo/go/cmd/vet/testdata/testingpkg/tests_test.go b/libgo/go/cmd/vet/testdata/testingpkg/tests_test.go deleted file mode 100644 index f5bbc3922a9..00000000000 --- a/libgo/go/cmd/vet/testdata/testingpkg/tests_test.go +++ /dev/null @@ -1,74 +0,0 @@ -package testdata - -import ( - "testing" -) - -// Buf is a ... -type Buf []byte - -// Append ... -func (*Buf) Append([]byte) {} - -func (Buf) Reset() {} - -func (Buf) Len() int { return 0 } - -// DefaultBuf is a ... -var DefaultBuf Buf - -func Example() {} // OK because is package-level. - -func Example_goodSuffix() // OK because refers to suffix annotation. - -func Example_BadSuffix() // ERROR "Example_BadSuffix has malformed example suffix: BadSuffix" - -func ExampleBuf() // OK because refers to known top-level type. - -func ExampleBuf_Append() {} // OK because refers to known method. - -func ExampleBuf_Clear() {} // ERROR "ExampleBuf_Clear refers to unknown field or method: Buf.Clear" - -func ExampleBuf_suffix() {} // OK because refers to suffix annotation. - -func ExampleBuf_Append_Bad() {} // ERROR "ExampleBuf_Append_Bad has malformed example suffix: Bad" - -func ExampleBuf_Append_suffix() {} // OK because refers to known method with valid suffix. - -func ExampleDefaultBuf() {} // OK because refers to top-level identifier. - -func ExampleBuf_Reset() bool { return true } // ERROR "ExampleBuf_Reset should return nothing" - -func ExampleBuf_Len(i int) {} // ERROR "ExampleBuf_Len should be niladic" - -// "Puffer" is German for "Buffer". - -func ExamplePuffer() // ERROR "ExamplePuffer refers to unknown identifier: Puffer" - -func ExamplePuffer_Append() // ERROR "ExamplePuffer_Append refers to unknown identifier: Puffer" - -func ExamplePuffer_suffix() // ERROR "ExamplePuffer_suffix refers to unknown identifier: Puffer" - -func nonTest() {} // OK because it doesn't start with "Test". - -func (Buf) TesthasReceiver() {} // OK because it has a receiver. - -func TestOKSuffix(*testing.T) {} // OK because first char after "Test" is Uppercase. - -func TestÜnicodeWorks(*testing.T) {} // OK because the first char after "Test" is Uppercase. - -func TestbadSuffix(*testing.T) {} // ERROR "first letter after 'Test' must not be lowercase" - -func TestemptyImportBadSuffix(*T) {} // ERROR "first letter after 'Test' must not be lowercase" - -func Test(*testing.T) {} // OK "Test" on its own is considered a test. - -func Testify() {} // OK because it takes no parameters. - -func TesttooManyParams(*testing.T, string) {} // OK because it takes too many parameters. - -func TesttooManyNames(a, b *testing.T) {} // OK because it takes too many names. - -func TestnoTParam(string) {} // OK because it doesn't take a *testing.T - -func BenchmarkbadSuffix(*testing.B) {} // ERROR "first letter after 'Benchmark' must not be lowercase" diff --git a/libgo/go/cmd/vet/testdata/unsafeptr.go b/libgo/go/cmd/vet/testdata/unsafeptr.go deleted file mode 100644 index ce852009ea7..00000000000 --- a/libgo/go/cmd/vet/testdata/unsafeptr.go +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package testdata - -import ( - "reflect" - "unsafe" -) - -func f() { - var x unsafe.Pointer - var y uintptr - x = unsafe.Pointer(y) // ERROR "possible misuse of unsafe.Pointer" - y = uintptr(x) - - // only allowed pointer arithmetic is ptr +/-/&^ num. - // num+ptr is technically okay but still flagged: write ptr+num instead. - x = unsafe.Pointer(uintptr(x) + 1) - x = unsafe.Pointer(1 + uintptr(x)) // ERROR "possible misuse of unsafe.Pointer" - x = unsafe.Pointer(uintptr(x) + uintptr(x)) // ERROR "possible misuse of unsafe.Pointer" - x = unsafe.Pointer(uintptr(x) - 1) - x = unsafe.Pointer(1 - uintptr(x)) // ERROR "possible misuse of unsafe.Pointer" - x = unsafe.Pointer(uintptr(x) &^ 3) - x = unsafe.Pointer(1 &^ uintptr(x)) // ERROR "possible misuse of unsafe.Pointer" - - // certain uses of reflect are okay - var v reflect.Value - x = unsafe.Pointer(v.Pointer()) - x = unsafe.Pointer(v.UnsafeAddr()) - var s1 *reflect.StringHeader - x = unsafe.Pointer(s1.Data) - var s2 *reflect.SliceHeader - x = unsafe.Pointer(s2.Data) - var s3 reflect.StringHeader - x = unsafe.Pointer(s3.Data) // ERROR "possible misuse of unsafe.Pointer" - var s4 reflect.SliceHeader - x = unsafe.Pointer(s4.Data) // ERROR "possible misuse of unsafe.Pointer" - - // but only in reflect - var vv V - x = unsafe.Pointer(vv.Pointer()) // ERROR "possible misuse of unsafe.Pointer" - x = unsafe.Pointer(vv.UnsafeAddr()) // ERROR "possible misuse of unsafe.Pointer" - var ss1 *StringHeader - x = unsafe.Pointer(ss1.Data) // ERROR "possible misuse of unsafe.Pointer" - var ss2 *SliceHeader - x = unsafe.Pointer(ss2.Data) // ERROR "possible misuse of unsafe.Pointer" - -} - -type V interface { - Pointer() uintptr - UnsafeAddr() uintptr -} - -type StringHeader struct { - Data uintptr -} - -type SliceHeader struct { - Data uintptr -} diff --git a/libgo/go/cmd/vet/testdata/unused.go b/libgo/go/cmd/vet/testdata/unused.go deleted file mode 100644 index d50f6594d9b..00000000000 --- a/libgo/go/cmd/vet/testdata/unused.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This file contains tests for the unusedresult checker. - -package testdata - -import ( - "bytes" - "errors" - "fmt" -) - -func _() { - fmt.Errorf("") // ERROR "result of fmt.Errorf call not used" - _ = fmt.Errorf("") - - errors.New("") // ERROR "result of errors.New call not used" - - err := errors.New("") - err.Error() // ERROR "result of \(error\).Error call not used" - - var buf bytes.Buffer - buf.String() // ERROR "result of \(bytes.Buffer\).String call not used" - - fmt.Sprint("") // ERROR "result of fmt.Sprint call not used" - fmt.Sprintf("") // ERROR "result of fmt.Sprintf call not used" -} diff --git a/libgo/go/cmd/vet/tests.go b/libgo/go/cmd/vet/tests.go deleted file mode 100644 index 5b157084fa2..00000000000 --- a/libgo/go/cmd/vet/tests.go +++ /dev/null @@ -1,187 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -import ( - "go/ast" - "go/types" - "strings" - "unicode" - "unicode/utf8" -) - -func init() { - register("tests", - "check for common mistaken usages of tests/documentation examples", - checkTestFunctions, - funcDecl) -} - -func isExampleSuffix(s string) bool { - r, size := utf8.DecodeRuneInString(s) - return size > 0 && unicode.IsLower(r) -} - -func isTestSuffix(name string) bool { - if len(name) == 0 { - // "Test" is ok. - return true - } - r, _ := utf8.DecodeRuneInString(name) - return !unicode.IsLower(r) -} - -func isTestParam(typ ast.Expr, wantType string) bool { - ptr, ok := typ.(*ast.StarExpr) - if !ok { - // Not a pointer. - return false - } - // No easy way of making sure it's a *testing.T or *testing.B: - // ensure the name of the type matches. - if name, ok := ptr.X.(*ast.Ident); ok { - return name.Name == wantType - } - if sel, ok := ptr.X.(*ast.SelectorExpr); ok { - return sel.Sel.Name == wantType - } - return false -} - -func lookup(name string, scopes []*types.Scope) types.Object { - for _, scope := range scopes { - if o := scope.Lookup(name); o != nil { - return o - } - } - return nil -} - -func extendedScope(f *File) []*types.Scope { - scopes := []*types.Scope{f.pkg.typesPkg.Scope()} - if f.basePkg != nil { - scopes = append(scopes, f.basePkg.typesPkg.Scope()) - } else { - // If basePkg is not specified (e.g. when checking a single file) try to - // find it among imports. - pkgName := f.pkg.typesPkg.Name() - if strings.HasSuffix(pkgName, "_test") { - basePkgName := strings.TrimSuffix(pkgName, "_test") - for _, p := range f.pkg.typesPkg.Imports() { - if p.Name() == basePkgName { - scopes = append(scopes, p.Scope()) - break - } - } - } - } - return scopes -} - -func checkExample(fn *ast.FuncDecl, f *File, report reporter) { - fnName := fn.Name.Name - if params := fn.Type.Params; len(params.List) != 0 { - report("%s should be niladic", fnName) - } - if results := fn.Type.Results; results != nil && len(results.List) != 0 { - report("%s should return nothing", fnName) - } - - if filesRun && !includesNonTest { - // The coherence checks between a test and the package it tests - // will report false positives if no non-test files have - // been provided. - return - } - - if fnName == "Example" { - // Nothing more to do. - return - } - - var ( - exName = strings.TrimPrefix(fnName, "Example") - elems = strings.SplitN(exName, "_", 3) - ident = elems[0] - obj = lookup(ident, extendedScope(f)) - ) - if ident != "" && obj == nil { - // Check ExampleFoo and ExampleBadFoo. - report("%s refers to unknown identifier: %s", fnName, ident) - // Abort since obj is absent and no subsequent checks can be performed. - return - } - if len(elems) < 2 { - // Nothing more to do. - return - } - - if ident == "" { - // Check Example_suffix and Example_BadSuffix. - if residual := strings.TrimPrefix(exName, "_"); !isExampleSuffix(residual) { - report("%s has malformed example suffix: %s", fnName, residual) - } - return - } - - mmbr := elems[1] - if !isExampleSuffix(mmbr) { - // Check ExampleFoo_Method and ExampleFoo_BadMethod. - if obj, _, _ := types.LookupFieldOrMethod(obj.Type(), true, obj.Pkg(), mmbr); obj == nil { - report("%s refers to unknown field or method: %s.%s", fnName, ident, mmbr) - } - } - if len(elems) == 3 && !isExampleSuffix(elems[2]) { - // Check ExampleFoo_Method_suffix and ExampleFoo_Method_Badsuffix. - report("%s has malformed example suffix: %s", fnName, elems[2]) - } -} - -func checkTest(fn *ast.FuncDecl, prefix string, report reporter) { - // Want functions with 0 results and 1 parameter. - if fn.Type.Results != nil && len(fn.Type.Results.List) > 0 || - fn.Type.Params == nil || - len(fn.Type.Params.List) != 1 || - len(fn.Type.Params.List[0].Names) > 1 { - return - } - - // The param must look like a *testing.T or *testing.B. - if !isTestParam(fn.Type.Params.List[0].Type, prefix[:1]) { - return - } - - if !isTestSuffix(fn.Name.Name[len(prefix):]) { - report("%s has malformed name: first letter after '%s' must not be lowercase", fn.Name.Name, prefix) - } -} - -type reporter func(format string, args ...interface{}) - -// checkTestFunctions walks Test, Benchmark and Example functions checking -// malformed names, wrong signatures and examples documenting nonexistent -// identifiers. -func checkTestFunctions(f *File, node ast.Node) { - if !strings.HasSuffix(f.name, "_test.go") { - return - } - - fn, ok := node.(*ast.FuncDecl) - if !ok || fn.Recv != nil { - // Ignore non-functions or functions with receivers. - return - } - - report := func(format string, args ...interface{}) { f.Badf(node.Pos(), format, args...) } - - switch { - case strings.HasPrefix(fn.Name.Name, "Example"): - checkExample(fn, f, report) - case strings.HasPrefix(fn.Name.Name, "Test"): - checkTest(fn, "Test", report) - case strings.HasPrefix(fn.Name.Name, "Benchmark"): - checkTest(fn, "Benchmark", report) - } -} diff --git a/libgo/go/cmd/vet/types.go b/libgo/go/cmd/vet/types.go deleted file mode 100644 index 60b61250b85..00000000000 --- a/libgo/go/cmd/vet/types.go +++ /dev/null @@ -1,313 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This file contains the pieces of the tool that use typechecking from the go/types package. - -package main - -import ( - "go/ast" - "go/build" - "go/importer" - "go/token" - "go/types" -) - -// stdImporter is the importer we use to import packages. -// It is shared so that all packages are imported by the same importer. -var stdImporter types.Importer - -var ( - errorType *types.Interface - stringerType *types.Interface // possibly nil - formatterType *types.Interface // possibly nil -) - -func inittypes() { - errorType = types.Universe.Lookup("error").Type().Underlying().(*types.Interface) - - if typ := importType("fmt", "Stringer"); typ != nil { - stringerType = typ.Underlying().(*types.Interface) - } - if typ := importType("fmt", "Formatter"); typ != nil { - formatterType = typ.Underlying().(*types.Interface) - } -} - -// isNamedType reports whether t is the named type path.name. -func isNamedType(t types.Type, path, name string) bool { - n, ok := t.(*types.Named) - if !ok { - return false - } - obj := n.Obj() - return obj.Name() == name && obj.Pkg() != nil && obj.Pkg().Path() == path -} - -// importType returns the type denoted by the qualified identifier -// path.name, and adds the respective package to the imports map -// as a side effect. In case of an error, importType returns nil. -func importType(path, name string) types.Type { - pkg, err := stdImporter.Import(path) - if err != nil { - // This can happen if the package at path hasn't been compiled yet. - warnf("import failed: %v", err) - return nil - } - if obj, ok := pkg.Scope().Lookup(name).(*types.TypeName); ok { - return obj.Type() - } - warnf("invalid type name %q", name) - return nil -} - -func (pkg *Package) check(fs *token.FileSet, astFiles []*ast.File) []error { - if stdImporter == nil { - if *source { - stdImporter = importer.For("source", nil) - } else { - stdImporter = importer.Default() - } - inittypes() - } - pkg.defs = make(map[*ast.Ident]types.Object) - pkg.uses = make(map[*ast.Ident]types.Object) - pkg.selectors = make(map[*ast.SelectorExpr]*types.Selection) - pkg.spans = make(map[types.Object]Span) - pkg.types = make(map[ast.Expr]types.TypeAndValue) - - var allErrors []error - config := types.Config{ - // We use the same importer for all imports to ensure that - // everybody sees identical packages for the given paths. - Importer: stdImporter, - // By providing a Config with our own error function, it will continue - // past the first error. We collect them all for printing later. - Error: func(e error) { - allErrors = append(allErrors, e) - }, - - Sizes: archSizes, - } - info := &types.Info{ - Selections: pkg.selectors, - Types: pkg.types, - Defs: pkg.defs, - Uses: pkg.uses, - } - typesPkg, err := config.Check(pkg.path, fs, astFiles, info) - if len(allErrors) == 0 && err != nil { - allErrors = append(allErrors, err) - } - pkg.typesPkg = typesPkg - // update spans - for id, obj := range pkg.defs { - pkg.growSpan(id, obj) - } - for id, obj := range pkg.uses { - pkg.growSpan(id, obj) - } - return allErrors -} - -// matchArgType reports an error if printf verb t is not appropriate -// for operand arg. -// -// typ is used only for recursive calls; external callers must supply nil. -// -// (Recursion arises from the compound types {map,chan,slice} which -// may be printed with %d etc. if that is appropriate for their element -// types.) -func (f *File) matchArgType(t printfArgType, typ types.Type, arg ast.Expr) bool { - return f.matchArgTypeInternal(t, typ, arg, make(map[types.Type]bool)) -} - -// matchArgTypeInternal is the internal version of matchArgType. It carries a map -// remembering what types are in progress so we don't recur when faced with recursive -// types or mutually recursive types. -func (f *File) matchArgTypeInternal(t printfArgType, typ types.Type, arg ast.Expr, inProgress map[types.Type]bool) bool { - // %v, %T accept any argument type. - if t == anyType { - return true - } - if typ == nil { - // external call - typ = f.pkg.types[arg].Type - if typ == nil { - return true // probably a type check problem - } - } - // If the type implements fmt.Formatter, we have nothing to check. - if f.isFormatter(typ) { - return true - } - // If we can use a string, might arg (dynamically) implement the Stringer or Error interface? - if t&argString != 0 && isConvertibleToString(typ) { - return true - } - - typ = typ.Underlying() - if inProgress[typ] { - // We're already looking at this type. The call that started it will take care of it. - return true - } - inProgress[typ] = true - - switch typ := typ.(type) { - case *types.Signature: - return t&argPointer != 0 - - case *types.Map: - // Recur: map[int]int matches %d. - return t&argPointer != 0 || - (f.matchArgTypeInternal(t, typ.Key(), arg, inProgress) && f.matchArgTypeInternal(t, typ.Elem(), arg, inProgress)) - - case *types.Chan: - return t&argPointer != 0 - - case *types.Array: - // Same as slice. - if types.Identical(typ.Elem().Underlying(), types.Typ[types.Byte]) && t&argString != 0 { - return true // %s matches []byte - } - // Recur: []int matches %d. - return t&argPointer != 0 || f.matchArgTypeInternal(t, typ.Elem(), arg, inProgress) - - case *types.Slice: - // Same as array. - if types.Identical(typ.Elem().Underlying(), types.Typ[types.Byte]) && t&argString != 0 { - return true // %s matches []byte - } - // Recur: []int matches %d. But watch out for - // type T []T - // If the element is a pointer type (type T[]*T), it's handled fine by the Pointer case below. - return t&argPointer != 0 || f.matchArgTypeInternal(t, typ.Elem(), arg, inProgress) - - case *types.Pointer: - // Ugly, but dealing with an edge case: a known pointer to an invalid type, - // probably something from a failed import. - if typ.Elem().String() == "invalid type" { - if *verbose { - f.Warnf(arg.Pos(), "printf argument %v is pointer to invalid or unknown type", f.gofmt(arg)) - } - return true // special case - } - // If it's actually a pointer with %p, it prints as one. - if t == argPointer { - return true - } - // If it's pointer to struct, that's equivalent in our analysis to whether we can print the struct. - if str, ok := typ.Elem().Underlying().(*types.Struct); ok { - return f.matchStructArgType(t, str, arg, inProgress) - } - // Check whether the rest can print pointers. - return t&argPointer != 0 - - case *types.Struct: - return f.matchStructArgType(t, typ, arg, inProgress) - - case *types.Interface: - // There's little we can do. - // Whether any particular verb is valid depends on the argument. - // The user may have reasonable prior knowledge of the contents of the interface. - return true - - case *types.Basic: - switch typ.Kind() { - case types.UntypedBool, - types.Bool: - return t&argBool != 0 - - case types.UntypedInt, - types.Int, - types.Int8, - types.Int16, - types.Int32, - types.Int64, - types.Uint, - types.Uint8, - types.Uint16, - types.Uint32, - types.Uint64, - types.Uintptr: - return t&argInt != 0 - - case types.UntypedFloat, - types.Float32, - types.Float64: - return t&argFloat != 0 - - case types.UntypedComplex, - types.Complex64, - types.Complex128: - return t&argComplex != 0 - - case types.UntypedString, - types.String: - return t&argString != 0 - - case types.UnsafePointer: - return t&(argPointer|argInt) != 0 - - case types.UntypedRune: - return t&(argInt|argRune) != 0 - - case types.UntypedNil: - return false - - case types.Invalid: - if *verbose { - f.Warnf(arg.Pos(), "printf argument %v has invalid or unknown type", f.gofmt(arg)) - } - return true // Probably a type check problem. - } - panic("unreachable") - } - - return false -} - -func isConvertibleToString(typ types.Type) bool { - if bt, ok := typ.(*types.Basic); ok && bt.Kind() == types.UntypedNil { - // We explicitly don't want untyped nil, which is - // convertible to both of the interfaces below, as it - // would just panic anyway. - return false - } - if types.ConvertibleTo(typ, errorType) { - return true // via .Error() - } - if stringerType != nil && types.ConvertibleTo(typ, stringerType) { - return true // via .String() - } - return false -} - -// hasBasicType reports whether x's type is a types.Basic with the given kind. -func (f *File) hasBasicType(x ast.Expr, kind types.BasicKind) bool { - t := f.pkg.types[x].Type - if t != nil { - t = t.Underlying() - } - b, ok := t.(*types.Basic) - return ok && b.Kind() == kind -} - -// matchStructArgType reports whether all the elements of the struct match the expected -// type. For instance, with "%d" all the elements must be printable with the "%d" format. -func (f *File) matchStructArgType(t printfArgType, typ *types.Struct, arg ast.Expr, inProgress map[types.Type]bool) bool { - for i := 0; i < typ.NumFields(); i++ { - typf := typ.Field(i) - if !f.matchArgTypeInternal(t, typf.Type(), arg, inProgress) { - return false - } - if t&argString != 0 && !typf.Exported() && isConvertibleToString(typf.Type()) { - // Issue #17798: unexported Stringer or error cannot be properly fomatted. - return false - } - } - return true -} - -var archSizes = types.SizesFor(build.Default.Compiler, build.Default.GOARCH) diff --git a/libgo/go/cmd/vet/unsafeptr.go b/libgo/go/cmd/vet/unsafeptr.go deleted file mode 100644 index cb2cc818897..00000000000 --- a/libgo/go/cmd/vet/unsafeptr.go +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Check for invalid uintptr -> unsafe.Pointer conversions. - -package main - -import ( - "go/ast" - "go/token" - "go/types" -) - -func init() { - register("unsafeptr", - "check for misuse of unsafe.Pointer", - checkUnsafePointer, - callExpr) -} - -func checkUnsafePointer(f *File, node ast.Node) { - x := node.(*ast.CallExpr) - if len(x.Args) != 1 { - return - } - if f.hasBasicType(x.Fun, types.UnsafePointer) && f.hasBasicType(x.Args[0], types.Uintptr) && !f.isSafeUintptr(x.Args[0]) { - f.Badf(x.Pos(), "possible misuse of unsafe.Pointer") - } -} - -// isSafeUintptr reports whether x - already known to be a uintptr - -// is safe to convert to unsafe.Pointer. It is safe if x is itself derived -// directly from an unsafe.Pointer via conversion and pointer arithmetic -// or if x is the result of reflect.Value.Pointer or reflect.Value.UnsafeAddr -// or obtained from the Data field of a *reflect.SliceHeader or *reflect.StringHeader. -func (f *File) isSafeUintptr(x ast.Expr) bool { - switch x := x.(type) { - case *ast.ParenExpr: - return f.isSafeUintptr(x.X) - - case *ast.SelectorExpr: - switch x.Sel.Name { - case "Data": - // reflect.SliceHeader and reflect.StringHeader are okay, - // but only if they are pointing at a real slice or string. - // It's not okay to do: - // var x SliceHeader - // x.Data = uintptr(unsafe.Pointer(...)) - // ... use x ... - // p := unsafe.Pointer(x.Data) - // because in the middle the garbage collector doesn't - // see x.Data as a pointer and so x.Data may be dangling - // by the time we get to the conversion at the end. - // For now approximate by saying that *Header is okay - // but Header is not. - pt, ok := f.pkg.types[x.X].Type.(*types.Pointer) - if ok { - t, ok := pt.Elem().(*types.Named) - if ok && t.Obj().Pkg().Path() == "reflect" { - switch t.Obj().Name() { - case "StringHeader", "SliceHeader": - return true - } - } - } - } - - case *ast.CallExpr: - switch len(x.Args) { - case 0: - // maybe call to reflect.Value.Pointer or reflect.Value.UnsafeAddr. - sel, ok := x.Fun.(*ast.SelectorExpr) - if !ok { - break - } - switch sel.Sel.Name { - case "Pointer", "UnsafeAddr": - t, ok := f.pkg.types[sel.X].Type.(*types.Named) - if ok && t.Obj().Pkg().Path() == "reflect" && t.Obj().Name() == "Value" { - return true - } - } - - case 1: - // maybe conversion of uintptr to unsafe.Pointer - return f.hasBasicType(x.Fun, types.Uintptr) && f.hasBasicType(x.Args[0], types.UnsafePointer) - } - - case *ast.BinaryExpr: - switch x.Op { - case token.ADD, token.SUB, token.AND_NOT: - return f.isSafeUintptr(x.X) && !f.isSafeUintptr(x.Y) - } - } - return false -} diff --git a/libgo/go/cmd/vet/unused.go b/libgo/go/cmd/vet/unused.go deleted file mode 100644 index 02fcd841cd0..00000000000 --- a/libgo/go/cmd/vet/unused.go +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This file defines the check for unused results of calls to certain -// pure functions. - -package main - -import ( - "flag" - "go/ast" - "go/token" - "go/types" - "strings" -) - -var unusedFuncsFlag = flag.String("unusedfuncs", - "errors.New,fmt.Errorf,fmt.Sprintf,fmt.Sprint,sort.Reverse", - "comma-separated list of functions whose results must be used") - -var unusedStringMethodsFlag = flag.String("unusedstringmethods", - "Error,String", - "comma-separated list of names of methods of type func() string whose results must be used") - -func init() { - register("unusedresult", - "check for unused result of calls to functions in -unusedfuncs list and methods in -unusedstringmethods list", - checkUnusedResult, - exprStmt) -} - -// func() string -var sigNoArgsStringResult = types.NewSignature(nil, nil, - types.NewTuple(types.NewVar(token.NoPos, nil, "", types.Typ[types.String])), - false) - -var unusedFuncs = make(map[string]bool) -var unusedStringMethods = make(map[string]bool) - -func initUnusedFlags() { - commaSplit := func(s string, m map[string]bool) { - if s != "" { - for _, name := range strings.Split(s, ",") { - if len(name) == 0 { - flag.Usage() - } - m[name] = true - } - } - } - commaSplit(*unusedFuncsFlag, unusedFuncs) - commaSplit(*unusedStringMethodsFlag, unusedStringMethods) -} - -func checkUnusedResult(f *File, n ast.Node) { - call, ok := unparen(n.(*ast.ExprStmt).X).(*ast.CallExpr) - if !ok { - return // not a call statement - } - fun := unparen(call.Fun) - - if f.pkg.types[fun].IsType() { - return // a conversion, not a call - } - - selector, ok := fun.(*ast.SelectorExpr) - if !ok { - return // neither a method call nor a qualified ident - } - - sel, ok := f.pkg.selectors[selector] - if ok && sel.Kind() == types.MethodVal { - // method (e.g. foo.String()) - obj := sel.Obj().(*types.Func) - sig := sel.Type().(*types.Signature) - if types.Identical(sig, sigNoArgsStringResult) { - if unusedStringMethods[obj.Name()] { - f.Badf(call.Lparen, "result of (%s).%s call not used", - sig.Recv().Type(), obj.Name()) - } - } - } else if !ok { - // package-qualified function (e.g. fmt.Errorf) - obj := f.pkg.uses[selector.Sel] - if obj, ok := obj.(*types.Func); ok { - qname := obj.Pkg().Path() + "." + obj.Name() - if unusedFuncs[qname] { - f.Badf(call.Lparen, "result of %v call not used", qname) - } - } - } -} diff --git a/libgo/go/cmd/vet/vet_test.go b/libgo/go/cmd/vet/vet_test.go index 3e42525e89b..1c7b8625f35 100644 --- a/libgo/go/cmd/vet/vet_test.go +++ b/libgo/go/cmd/vet/vet_test.go @@ -60,120 +60,92 @@ func Build(t *testing.T) { built = true } -func Vet(t *testing.T, files []string) { - flags := []string{ - "-printfuncs=Warn:1,Warnf:1", - "-all", - "-shadow", - } - cmd := exec.Command(binary, append(flags, files...)...) - errchk(cmd, files, t) -} - -// TestVet is equivalent to running this: -// go build -o ./testvet -// errorCheck the output of ./testvet -shadow -printfuncs='Warn:1,Warnf:1' testdata/*.go testdata/*.s -// rm ./testvet -// - -// TestVet tests self-contained files in testdata/*.go. -// -// If a file contains assembly or has inter-dependencies, it should be -// in its own test, like TestVetAsm, TestDivergentPackagesExamples, -// etc below. -func TestVet(t *testing.T) { - Build(t) - t.Parallel() - - gos, err := filepath.Glob(filepath.Join(dataDir, "*.go")) - if err != nil { - t.Fatal(err) - } - wide := runtime.GOMAXPROCS(0) - if wide > len(gos) { - wide = len(gos) - } - batch := make([][]string, wide) - for i, file := range gos { - // TODO: Remove print.go exception once we require type checking for everything, - // and then delete TestVetPrint. - if strings.HasSuffix(file, "print.go") { - continue - } - batch[i%wide] = append(batch[i%wide], file) - } - for i, files := range batch { - if len(files) == 0 { - continue - } - files := files - t.Run(fmt.Sprint(i), func(t *testing.T) { - t.Parallel() - t.Logf("files: %q", files) - Vet(t, files) - }) - } -} - -func TestVetPrint(t *testing.T) { - if runtime.Compiler == "gccgo" { - // This test currently fails with gccgo because, in - // the absence of standard library sources, gccgo can - // not deduce that the standard log package formatting - // functions are just printf wrappers. - t.Skip("skipping for gccgo because there are no standard library sources") - } - - Build(t) - file := filepath.Join("testdata", "print.go") - cmd := exec.Command( - "go", "vet", "-vettool="+binary, - "-printf", - "-printfuncs=Warn:1,Warnf:1", - file, - ) - errchk(cmd, []string{file}, t) -} - -func TestVetAsm(t *testing.T) { - Build(t) - - asmDir := filepath.Join(dataDir, "asm") - gos, err := filepath.Glob(filepath.Join(asmDir, "*.go")) - if err != nil { - t.Fatal(err) - } - asms, err := filepath.Glob(filepath.Join(asmDir, "*.s")) +func vetCmd(t *testing.T, args ...string) *exec.Cmd { + cmd := exec.Command(testenv.GoToolPath(t), "vet", "-vettool="+binary) + cmd.Args = append(cmd.Args, args...) + testdata, err := filepath.Abs("testdata") if err != nil { t.Fatal(err) } - - t.Parallel() - Vet(t, append(gos, asms...)) + cmd.Env = append(os.Environ(), "GOPATH="+testdata) + return cmd } -func TestVetDirs(t *testing.T) { +func TestVet(t *testing.T) { t.Parallel() Build(t) - for _, dir := range []string{ - "testingpkg", - "divergent", + for _, pkg := range []string{ + "asm", + "assign", + "atomic", + "bool", "buildtag", - "incomplete", // incomplete examples "cgo", + "composite", + "copylock", + "deadcode", + "httpresponse", + "lostcancel", + "method", + "nilfunc", + "print", + "rangeloop", + "shift", + "structtag", + "testingpkg", + // "testtag" has its own test + "unmarshal", + "unsafeptr", + "unused", } { - dir := dir - t.Run(dir, func(t *testing.T) { + pkg := pkg + t.Run(pkg, func(t *testing.T) { t.Parallel() - gos, err := filepath.Glob(filepath.Join("testdata", dir, "*.go")) + + // Skip cgo test on platforms without cgo. + if pkg == "cgo" && !cgoEnabled(t) { + return + } + + cmd := vetCmd(t, "-printfuncs=Warn,Warnf", pkg) + + // The asm test assumes amd64. + if pkg == "asm" { + if runtime.Compiler == "gccgo" { + t.Skip("asm test assumes gc") + } + cmd.Env = append(cmd.Env, "GOOS=linux", "GOARCH=amd64") + } + + dir := filepath.Join("testdata/src", pkg) + gos, err := filepath.Glob(filepath.Join(dir, "*.go")) if err != nil { t.Fatal(err) } - Vet(t, gos) + asms, err := filepath.Glob(filepath.Join(dir, "*.s")) + if err != nil { + t.Fatal(err) + } + var files []string + files = append(files, gos...) + files = append(files, asms...) + + errchk(cmd, files, t) }) } } +func cgoEnabled(t *testing.T) bool { + // Don't trust build.Default.CgoEnabled as it is false for + // cross-builds unless CGO_ENABLED is explicitly specified. + // That's fine for the builders, but causes commands like + // 'GOARCH=386 go test .' to fail. + // Instead, we ask the go command. + cmd := exec.Command(testenv.GoToolPath(t), "list", "-f", "{{context.CgoEnabled}}") + out, _ := cmd.CombinedOutput() + return string(out) == "true\n" +} + func errchk(c *exec.Cmd, files []string, t *testing.T) { output, err := c.CombinedOutput() if _, ok := err.(*exec.ExitError); !ok { @@ -194,44 +166,35 @@ func errchk(c *exec.Cmd, files []string, t *testing.T) { func TestTags(t *testing.T) { t.Parallel() Build(t) - for _, tag := range []string{"testtag", "x testtag y", "x,testtag,y"} { - tag := tag + for tag, wantFile := range map[string]int{ + "testtag": 1, // file1 + "x testtag y": 1, + "othertag": 2, + } { + tag, wantFile := tag, wantFile t.Run(tag, func(t *testing.T) { t.Parallel() t.Logf("-tags=%s", tag) - args := []string{ - "-tags=" + tag, - "-v", // We're going to look at the files it examines. - "testdata/tagtest", - } - cmd := exec.Command(binary, args...) + cmd := vetCmd(t, "-tags="+tag, "tagtest") output, err := cmd.CombinedOutput() - if err != nil { - t.Fatal(err) - } + + want := fmt.Sprintf("file%d.go", wantFile) + dontwant := fmt.Sprintf("file%d.go", 3-wantFile) + // file1 has testtag and file2 has !testtag. - if !bytes.Contains(output, []byte(filepath.Join("tagtest", "file1.go"))) { - t.Error("file1 was excluded, should be included") + if !bytes.Contains(output, []byte(filepath.Join("tagtest", want))) { + t.Errorf("%s: %s was excluded, should be included", tag, want) + } + if bytes.Contains(output, []byte(filepath.Join("tagtest", dontwant))) { + t.Errorf("%s: %s was included, should be excluded", tag, dontwant) } - if bytes.Contains(output, []byte(filepath.Join("tagtest", "file2.go"))) { - t.Error("file2 was included, should be excluded") + if t.Failed() { + t.Logf("err=%s, output=<<%s>>", err, output) } }) } } -// Issue #21188. -func TestVetVerbose(t *testing.T) { - t.Parallel() - Build(t) - cmd := exec.Command(binary, "-v", "-all", "testdata/cgo/cgo3.go") - out, err := cmd.CombinedOutput() - if err != nil { - t.Logf("%s", out) - t.Error(err) - } -} - // All declarations below were adapted from test/run.go. // errorCheck matches errors in outStr against comments in source files. @@ -241,10 +204,10 @@ func TestVetVerbose(t *testing.T) { // this function will report an error. // Likewise if outStr does not have an error for a line which has a comment, // or if the error message does not match the . -// The syntax is Perl but its best to stick to egrep. +// The syntax is Perl but it's best to stick to egrep. // // Sources files are supplied as fullshort slice. -// It consists of pairs: full path to source file and it's base name. +// It consists of pairs: full path to source file and its base name. func errorCheck(outStr string, wantAuto bool, fullshort ...string) (err error) { var errs []error out := splitOutput(outStr, wantAuto) @@ -252,7 +215,7 @@ func errorCheck(outStr string, wantAuto bool, fullshort ...string) (err error) { for i := range out { for j := 0; j < len(fullshort); j += 2 { full, short := fullshort[j], fullshort[j+1] - out[i] = strings.Replace(out[i], full, short, -1) + out[i] = strings.ReplaceAll(out[i], full, short) } } diff --git a/libgo/go/compress/bzip2/bzip2_test.go b/libgo/go/compress/bzip2/bzip2_test.go index 3848603e0dd..c432bb5226f 100644 --- a/libgo/go/compress/bzip2/bzip2_test.go +++ b/libgo/go/compress/bzip2/bzip2_test.go @@ -214,7 +214,7 @@ func TestZeroRead(t *testing.T) { var ( digits = mustLoadFile("testdata/e.txt.bz2") - twain = mustLoadFile("testdata/Mark.Twain-Tom.Sawyer.txt.bz2") + newton = mustLoadFile("testdata/Isaac.Newton-Opticks.txt.bz2") random = mustLoadFile("testdata/random.data.bz2") ) @@ -236,5 +236,5 @@ func benchmarkDecode(b *testing.B, compressed []byte) { } func BenchmarkDecodeDigits(b *testing.B) { benchmarkDecode(b, digits) } -func BenchmarkDecodeTwain(b *testing.B) { benchmarkDecode(b, twain) } +func BenchmarkDecodeNewton(b *testing.B) { benchmarkDecode(b, newton) } func BenchmarkDecodeRand(b *testing.B) { benchmarkDecode(b, random) } diff --git a/libgo/go/compress/bzip2/testdata/Isaac.Newton-Opticks.txt.bz2 b/libgo/go/compress/bzip2/testdata/Isaac.Newton-Opticks.txt.bz2 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/libgo/go/compress/flate/deflate_test.go b/libgo/go/compress/flate/deflate_test.go index fbea761721a..034040e56de 100644 --- a/libgo/go/compress/flate/deflate_test.go +++ b/libgo/go/compress/flate/deflate_test.go @@ -371,9 +371,9 @@ var deflateInflateStringTests = []deflateInflateStringTest{ [...]int{100018, 50650, 50960, 51150, 50930, 50790, 50790, 50790, 50790, 50790, 43683}, }, { - "../testdata/Mark.Twain-Tom.Sawyer.txt", - "Mark.Twain-Tom.Sawyer", - [...]int{407330, 187598, 180361, 172974, 169160, 163476, 160936, 160506, 160295, 160295, 233460}, + "testdata/Isaac.Newton-Opticks.txt", + "Isaac.Newton-Opticks", + [...]int{567248, 218338, 198211, 193152, 181100, 175427, 175427, 173597, 173422, 173422, 325240}, }, } @@ -654,7 +654,7 @@ func (w *failWriter) Write(b []byte) (int, error) { func TestWriterPersistentError(t *testing.T) { t.Parallel() - d, err := ioutil.ReadFile("../testdata/Mark.Twain-Tom.Sawyer.txt") + d, err := ioutil.ReadFile("testdata/Isaac.Newton-Opticks.txt") if err != nil { t.Fatalf("ReadFile: %v", err) } diff --git a/libgo/go/compress/flate/inflate.go b/libgo/go/compress/flate/inflate.go index 25e81f3f727..49921398e2b 100644 --- a/libgo/go/compress/flate/inflate.go +++ b/libgo/go/compress/flate/inflate.go @@ -65,7 +65,7 @@ func (e *WriteError) Error() string { return "flate: write error at offset " + strconv.FormatInt(e.Offset, 10) + ": " + e.Err.Error() } -// Resetter resets a ReadCloser returned by NewReader or NewReaderDict to +// Resetter resets a ReadCloser returned by NewReader or NewReaderDict // to switch to a new underlying Reader. This permits reusing a ReadCloser // instead of allocating a new one. type Resetter interface { @@ -89,7 +89,7 @@ type Resetter interface { // number of bits. // // See the following: -// http://www.gzip.org/algorithm.txt +// https://github.com/madler/zlib/raw/master/doc/algorithm.txt // chunk & 15 is number of bits // chunk >> 4 is value, including table link diff --git a/libgo/go/compress/flate/reader_test.go b/libgo/go/compress/flate/reader_test.go index b0a16ce18b9..e39d7f0f97e 100644 --- a/libgo/go/compress/flate/reader_test.go +++ b/libgo/go/compress/flate/reader_test.go @@ -27,8 +27,8 @@ var suites = []struct{ name, file string }{ // does not repeat, but there are only 10 possible digits, so it should be // reasonably compressible. {"Digits", "../testdata/e.txt"}, - // Twain is Mark Twain's classic English novel. - {"Twain", "../testdata/Mark.Twain-Tom.Sawyer.txt"}, + // Newton is Isaac Newtons's educational text on Opticks. + {"Newton", "testdata/Isaac.Newton-Opticks.txt"}, } func BenchmarkDecode(b *testing.B) { diff --git a/libgo/go/compress/flate/testdata/Isaac.Newton-Opticks.txt b/libgo/go/compress/flate/testdata/Isaac.Newton-Opticks.txt new file mode 100644 index 00000000000..15bb4c54d0b --- /dev/null +++ b/libgo/go/compress/flate/testdata/Isaac.Newton-Opticks.txt @@ -0,0 +1,9286 @@ +Produced by Suzanne Lybarger, steve harris, Josephine +Paolucci and the Online Distributed Proofreading Team at +http://www.pgdp.net. + + + + + + +OPTICKS: + +OR, A + +TREATISE + +OF THE + +_Reflections_, _Refractions_, +_Inflections_ and _Colours_ + +OF + +LIGHT. + +_The_ FOURTH EDITION, _corrected_. + +By Sir _ISAAC NEWTON_, Knt. + +LONDON: + +Printed for WILLIAM INNYS at the West-End of St. _Paul's_. MDCCXXX. + +TITLE PAGE OF THE 1730 EDITION + + + + +SIR ISAAC NEWTON'S ADVERTISEMENTS + + + + +Advertisement I + + +_Part of the ensuing Discourse about Light was written at the Desire of +some Gentlemen of the_ Royal-Society, _in the Year 1675, and then sent +to their Secretary, and read at their Meetings, and the rest was added +about twelve Years after to complete the Theory; except the third Book, +and the last Proposition of the Second, which were since put together +out of scatter'd Papers. To avoid being engaged in Disputes about these +Matters, I have hitherto delayed the printing, and should still have +delayed it, had not the Importunity of Friends prevailed upon me. If any +other Papers writ on this Subject are got out of my Hands they are +imperfect, and were perhaps written before I had tried all the +Experiments here set down, and fully satisfied my self about the Laws of +Refractions and Composition of Colours. I have here publish'd what I +think proper to come abroad, wishing that it may not be translated into +another Language without my Consent._ + +_The Crowns of Colours, which sometimes appear about the Sun and Moon, I +have endeavoured to give an Account of; but for want of sufficient +Observations leave that Matter to be farther examined. The Subject of +the Third Book I have also left imperfect, not having tried all the +Experiments which I intended when I was about these Matters, nor +repeated some of those which I did try, until I had satisfied my self +about all their Circumstances. To communicate what I have tried, and +leave the rest to others for farther Enquiry, is all my Design in +publishing these Papers._ + +_In a Letter written to Mr._ Leibnitz _in the year 1679, and published +by Dr._ Wallis, _I mention'd a Method by which I had found some general +Theorems about squaring Curvilinear Figures, or comparing them with the +Conic Sections, or other the simplest Figures with which they may be +compared. And some Years ago I lent out a Manuscript containing such +Theorems, and having since met with some Things copied out of it, I have +on this Occasion made it publick, prefixing to it an_ Introduction, _and +subjoining a_ Scholium _concerning that Method. And I have joined with +it another small Tract concerning the Curvilinear Figures of the Second +Kind, which was also written many Years ago, and made known to some +Friends, who have solicited the making it publick._ + + _I. N._ + +April 1, 1704. + + +Advertisement II + +_In this Second Edition of these Opticks I have omitted the Mathematical +Tracts publish'd at the End of the former Edition, as not belonging to +the Subject. And at the End of the Third Book I have added some +Questions. And to shew that I do not take Gravity for an essential +Property of Bodies, I have added one Question concerning its Cause, +chusing to propose it by way of a Question, because I am not yet +satisfied about it for want of Experiments._ + + _I. N._ + +July 16, 1717. + + +Advertisement to this Fourth Edition + +_This new Edition of Sir_ Isaac Newton's Opticks _is carefully printed +from the Third Edition, as it was corrected by the Author's own Hand, +and left before his Death with the Bookseller. Since Sir_ Isaac's +Lectiones Opticæ, _which he publickly read in the University of_ +Cambridge _in the Years 1669, 1670, and 1671, are lately printed, it has +been thought proper to make at the bottom of the Pages several Citations +from thence, where may be found the Demonstrations, which the Author +omitted in these_ Opticks. + + * * * * * + +Transcriber's Note: There are several greek letters used in the +descriptions of the illustrations. They are signified by [Greek: +letter]. Square roots are noted by the letters sqrt before the equation. + + * * * * * + +THE FIRST BOOK OF OPTICKS + + + + +_PART I._ + + +My Design in this Book is not to explain the Properties of Light by +Hypotheses, but to propose and prove them by Reason and Experiments: In +order to which I shall premise the following Definitions and Axioms. + + + + +_DEFINITIONS_ + + +DEFIN. I. + +_By the Rays of Light I understand its least Parts, and those as well +Successive in the same Lines, as Contemporary in several Lines._ For it +is manifest that Light consists of Parts, both Successive and +Contemporary; because in the same place you may stop that which comes +one moment, and let pass that which comes presently after; and in the +same time you may stop it in any one place, and let it pass in any +other. For that part of Light which is stopp'd cannot be the same with +that which is let pass. The least Light or part of Light, which may be +stopp'd alone without the rest of the Light, or propagated alone, or do +or suffer any thing alone, which the rest of the Light doth not or +suffers not, I call a Ray of Light. + + +DEFIN. II. + +_Refrangibility of the Rays of Light, is their Disposition to be +refracted or turned out of their Way in passing out of one transparent +Body or Medium into another. And a greater or less Refrangibility of +Rays, is their Disposition to be turned more or less out of their Way in +like Incidences on the same Medium._ Mathematicians usually consider the +Rays of Light to be Lines reaching from the luminous Body to the Body +illuminated, and the refraction of those Rays to be the bending or +breaking of those lines in their passing out of one Medium into another. +And thus may Rays and Refractions be considered, if Light be propagated +in an instant. But by an Argument taken from the Æquations of the times +of the Eclipses of _Jupiter's Satellites_, it seems that Light is +propagated in time, spending in its passage from the Sun to us about +seven Minutes of time: And therefore I have chosen to define Rays and +Refractions in such general terms as may agree to Light in both cases. + + +DEFIN. III. + +_Reflexibility of Rays, is their Disposition to be reflected or turned +back into the same Medium from any other Medium upon whose Surface they +fall. And Rays are more or less reflexible, which are turned back more +or less easily._ As if Light pass out of a Glass into Air, and by being +inclined more and more to the common Surface of the Glass and Air, +begins at length to be totally reflected by that Surface; those sorts of +Rays which at like Incidences are reflected most copiously, or by +inclining the Rays begin soonest to be totally reflected, are most +reflexible. + + +DEFIN. IV. + +_The Angle of Incidence is that Angle, which the Line described by the +incident Ray contains with the Perpendicular to the reflecting or +refracting Surface at the Point of Incidence._ + + +DEFIN. V. + +_The Angle of Reflexion or Refraction, is the Angle which the line +described by the reflected or refracted Ray containeth with the +Perpendicular to the reflecting or refracting Surface at the Point of +Incidence._ + + +DEFIN. VI. + +_The Sines of Incidence, Reflexion, and Refraction, are the Sines of the +Angles of Incidence, Reflexion, and Refraction._ + + +DEFIN. VII + +_The Light whose Rays are all alike Refrangible, I call Simple, +Homogeneal and Similar; and that whose Rays are some more Refrangible +than others, I call Compound, Heterogeneal and Dissimilar._ The former +Light I call Homogeneal, not because I would affirm it so in all +respects, but because the Rays which agree in Refrangibility, agree at +least in all those their other Properties which I consider in the +following Discourse. + + +DEFIN. VIII. + +_The Colours of Homogeneal Lights, I call Primary, Homogeneal and +Simple; and those of Heterogeneal Lights, Heterogeneal and Compound._ +For these are always compounded of the colours of Homogeneal Lights; as +will appear in the following Discourse. + + + + +_AXIOMS._ + + +AX. I. + +_The Angles of Reflexion and Refraction, lie in one and the same Plane +with the Angle of Incidence._ + + +AX. II. + +_The Angle of Reflexion is equal to the Angle of Incidence._ + + +AX. III. + +_If the refracted Ray be returned directly back to the Point of +Incidence, it shall be refracted into the Line before described by the +incident Ray._ + + +AX. IV. + +_Refraction out of the rarer Medium into the denser, is made towards the +Perpendicular; that is, so that the Angle of Refraction be less than the +Angle of Incidence._ + + +AX. V. + +_The Sine of Incidence is either accurately or very nearly in a given +Ratio to the Sine of Refraction._ + +Whence if that Proportion be known in any one Inclination of the +incident Ray, 'tis known in all the Inclinations, and thereby the +Refraction in all cases of Incidence on the same refracting Body may be +determined. Thus if the Refraction be made out of Air into Water, the +Sine of Incidence of the red Light is to the Sine of its Refraction as 4 +to 3. If out of Air into Glass, the Sines are as 17 to 11. In Light of +other Colours the Sines have other Proportions: but the difference is so +little that it need seldom be considered. + +[Illustration: FIG. 1] + +Suppose therefore, that RS [in _Fig._ 1.] represents the Surface of +stagnating Water, and that C is the point of Incidence in which any Ray +coming in the Air from A in the Line AC is reflected or refracted, and I +would know whither this Ray shall go after Reflexion or Refraction: I +erect upon the Surface of the Water from the point of Incidence the +Perpendicular CP and produce it downwards to Q, and conclude by the +first Axiom, that the Ray after Reflexion and Refraction, shall be +found somewhere in the Plane of the Angle of Incidence ACP produced. I +let fall therefore upon the Perpendicular CP the Sine of Incidence AD; +and if the reflected Ray be desired, I produce AD to B so that DB be +equal to AD, and draw CB. For this Line CB shall be the reflected Ray; +the Angle of Reflexion BCP and its Sine BD being equal to the Angle and +Sine of Incidence, as they ought to be by the second Axiom, But if the +refracted Ray be desired, I produce AD to H, so that DH may be to AD as +the Sine of Refraction to the Sine of Incidence, that is, (if the Light +be red) as 3 to 4; and about the Center C and in the Plane ACP with the +Radius CA describing a Circle ABE, I draw a parallel to the +Perpendicular CPQ, the Line HE cutting the Circumference in E, and +joining CE, this Line CE shall be the Line of the refracted Ray. For if +EF be let fall perpendicularly on the Line PQ, this Line EF shall be the +Sine of Refraction of the Ray CE, the Angle of Refraction being ECQ; and +this Sine EF is equal to DH, and consequently in Proportion to the Sine +of Incidence AD as 3 to 4. + +In like manner, if there be a Prism of Glass (that is, a Glass bounded +with two Equal and Parallel Triangular ends, and three plain and well +polished Sides, which meet in three Parallel Lines running from the +three Angles of one end to the three Angles of the other end) and if the +Refraction of the Light in passing cross this Prism be desired: Let ACB +[in _Fig._ 2.] represent a Plane cutting this Prism transversly to its +three Parallel lines or edges there where the Light passeth through it, +and let DE be the Ray incident upon the first side of the Prism AC where +the Light goes into the Glass; and by putting the Proportion of the Sine +of Incidence to the Sine of Refraction as 17 to 11 find EF the first +refracted Ray. Then taking this Ray for the Incident Ray upon the second +side of the Glass BC where the Light goes out, find the next refracted +Ray FG by putting the Proportion of the Sine of Incidence to the Sine of +Refraction as 11 to 17. For if the Sine of Incidence out of Air into +Glass be to the Sine of Refraction as 17 to 11, the Sine of Incidence +out of Glass into Air must on the contrary be to the Sine of Refraction +as 11 to 17, by the third Axiom. + +[Illustration: FIG. 2.] + +Much after the same manner, if ACBD [in _Fig._ 3.] represent a Glass +spherically convex on both sides (usually called a _Lens_, such as is a +Burning-glass, or Spectacle-glass, or an Object-glass of a Telescope) +and it be required to know how Light falling upon it from any lucid +point Q shall be refracted, let QM represent a Ray falling upon any +point M of its first spherical Surface ACB, and by erecting a +Perpendicular to the Glass at the point M, find the first refracted Ray +MN by the Proportion of the Sines 17 to 11. Let that Ray in going out of +the Glass be incident upon N, and then find the second refracted Ray +N_q_ by the Proportion of the Sines 11 to 17. And after the same manner +may the Refraction be found when the Lens is convex on one side and +plane or concave on the other, or concave on both sides. + +[Illustration: FIG. 3.] + + +AX. VI. + +_Homogeneal Rays which flow from several Points of any Object, and fall +perpendicularly or almost perpendicularly on any reflecting or +refracting Plane or spherical Surface, shall afterwards diverge from so +many other Points, or be parallel to so many other Lines, or converge to +so many other Points, either accurately or without any sensible Error. +And the same thing will happen, if the Rays be reflected or refracted +successively by two or three or more Plane or Spherical Surfaces._ + +The Point from which Rays diverge or to which they converge may be +called their _Focus_. And the Focus of the incident Rays being given, +that of the reflected or refracted ones may be found by finding the +Refraction of any two Rays, as above; or more readily thus. + +_Cas._ 1. Let ACB [in _Fig._ 4.] be a reflecting or refracting Plane, +and Q the Focus of the incident Rays, and Q_q_C a Perpendicular to that +Plane. And if this Perpendicular be produced to _q_, so that _q_C be +equal to QC, the Point _q_ shall be the Focus of the reflected Rays: Or +if _q_C be taken on the same side of the Plane with QC, and in +proportion to QC as the Sine of Incidence to the Sine of Refraction, the +Point _q_ shall be the Focus of the refracted Rays. + +[Illustration: FIG. 4.] + +_Cas._ 2. Let ACB [in _Fig._ 5.] be the reflecting Surface of any Sphere +whose Centre is E. Bisect any Radius thereof, (suppose EC) in T, and if +in that Radius on the same side the Point T you take the Points Q and +_q_, so that TQ, TE, and T_q_, be continual Proportionals, and the Point +Q be the Focus of the incident Rays, the Point _q_ shall be the Focus of +the reflected ones. + +[Illustration: FIG. 5.] + +_Cas._ 3. Let ACB [in _Fig._ 6.] be the refracting Surface of any Sphere +whose Centre is E. In any Radius thereof EC produced both ways take ET +and C_t_ equal to one another and severally in such Proportion to that +Radius as the lesser of the Sines of Incidence and Refraction hath to +the difference of those Sines. And then if in the same Line you find any +two Points Q and _q_, so that TQ be to ET as E_t_ to _tq_, taking _tq_ +the contrary way from _t_ which TQ lieth from T, and if the Point Q be +the Focus of any incident Rays, the Point _q_ shall be the Focus of the +refracted ones. + +[Illustration: FIG. 6.] + +And by the same means the Focus of the Rays after two or more Reflexions +or Refractions may be found. + +[Illustration: FIG. 7.] + +_Cas._ 4. Let ACBD [in _Fig._ 7.] be any refracting Lens, spherically +Convex or Concave or Plane on either side, and let CD be its Axis (that +is, the Line which cuts both its Surfaces perpendicularly, and passes +through the Centres of the Spheres,) and in this Axis produced let F and +_f_ be the Foci of the refracted Rays found as above, when the incident +Rays on both sides the Lens are parallel to the same Axis; and upon the +Diameter F_f_ bisected in E, describe a Circle. Suppose now that any +Point Q be the Focus of any incident Rays. Draw QE cutting the said +Circle in T and _t_, and therein take _tq_ in such proportion to _t_E as +_t_E or TE hath to TQ. Let _tq_ lie the contrary way from _t_ which TQ +doth from T, and _q_ shall be the Focus of the refracted Rays without +any sensible Error, provided the Point Q be not so remote from the Axis, +nor the Lens so broad as to make any of the Rays fall too obliquely on +the refracting Surfaces.[A] + +And by the like Operations may the reflecting or refracting Surfaces be +found when the two Foci are given, and thereby a Lens be formed, which +shall make the Rays flow towards or from what Place you please.[B] + +So then the Meaning of this Axiom is, that if Rays fall upon any Plane +or Spherical Surface or Lens, and before their Incidence flow from or +towards any Point Q, they shall after Reflexion or Refraction flow from +or towards the Point _q_ found by the foregoing Rules. And if the +incident Rays flow from or towards several points Q, the reflected or +refracted Rays shall flow from or towards so many other Points _q_ +found by the same Rules. Whether the reflected and refracted Rays flow +from or towards the Point _q_ is easily known by the situation of that +Point. For if that Point be on the same side of the reflecting or +refracting Surface or Lens with the Point Q, and the incident Rays flow +from the Point Q, the reflected flow towards the Point _q_ and the +refracted from it; and if the incident Rays flow towards Q, the +reflected flow from _q_, and the refracted towards it. And the contrary +happens when _q_ is on the other side of the Surface. + + +AX. VII. + +_Wherever the Rays which come from all the Points of any Object meet +again in so many Points after they have been made to converge by +Reflection or Refraction, there they will make a Picture of the Object +upon any white Body on which they fall._ + +So if PR [in _Fig._ 3.] represent any Object without Doors, and AB be a +Lens placed at a hole in the Window-shut of a dark Chamber, whereby the +Rays that come from any Point Q of that Object are made to converge and +meet again in the Point _q_; and if a Sheet of white Paper be held at +_q_ for the Light there to fall upon it, the Picture of that Object PR +will appear upon the Paper in its proper shape and Colours. For as the +Light which comes from the Point Q goes to the Point _q_, so the Light +which comes from other Points P and R of the Object, will go to so many +other correspondent Points _p_ and _r_ (as is manifest by the sixth +Axiom;) so that every Point of the Object shall illuminate a +correspondent Point of the Picture, and thereby make a Picture like the +Object in Shape and Colour, this only excepted, that the Picture shall +be inverted. And this is the Reason of that vulgar Experiment of casting +the Species of Objects from abroad upon a Wall or Sheet of white Paper +in a dark Room. + +In like manner, when a Man views any Object PQR, [in _Fig._ 8.] the +Light which comes from the several Points of the Object is so refracted +by the transparent skins and humours of the Eye, (that is, by the +outward coat EFG, called the _Tunica Cornea_, and by the crystalline +humour AB which is beyond the Pupil _mk_) as to converge and meet again +in so many Points in the bottom of the Eye, and there to paint the +Picture of the Object upon that skin (called the _Tunica Retina_) with +which the bottom of the Eye is covered. For Anatomists, when they have +taken off from the bottom of the Eye that outward and most thick Coat +called the _Dura Mater_, can then see through the thinner Coats, the +Pictures of Objects lively painted thereon. And these Pictures, +propagated by Motion along the Fibres of the Optick Nerves into the +Brain, are the cause of Vision. For accordingly as these Pictures are +perfect or imperfect, the Object is seen perfectly or imperfectly. If +the Eye be tinged with any colour (as in the Disease of the _Jaundice_) +so as to tinge the Pictures in the bottom of the Eye with that Colour, +then all Objects appear tinged with the same Colour. If the Humours of +the Eye by old Age decay, so as by shrinking to make the _Cornea_ and +Coat of the _Crystalline Humour_ grow flatter than before, the Light +will not be refracted enough, and for want of a sufficient Refraction +will not converge to the bottom of the Eye but to some place beyond it, +and by consequence paint in the bottom of the Eye a confused Picture, +and according to the Indistinctness of this Picture the Object will +appear confused. This is the reason of the decay of sight in old Men, +and shews why their Sight is mended by Spectacles. For those Convex +glasses supply the defect of plumpness in the Eye, and by increasing the +Refraction make the Rays converge sooner, so as to convene distinctly at +the bottom of the Eye if the Glass have a due degree of convexity. And +the contrary happens in short-sighted Men whose Eyes are too plump. For +the Refraction being now too great, the Rays converge and convene in the +Eyes before they come at the bottom; and therefore the Picture made in +the bottom and the Vision caused thereby will not be distinct, unless +the Object be brought so near the Eye as that the place where the +converging Rays convene may be removed to the bottom, or that the +plumpness of the Eye be taken off and the Refractions diminished by a +Concave-glass of a due degree of Concavity, or lastly that by Age the +Eye grow flatter till it come to a due Figure: For short-sighted Men see +remote Objects best in Old Age, and therefore they are accounted to have +the most lasting Eyes. + +[Illustration: FIG. 8.] + + +AX. VIII. + +_An Object seen by Reflexion or Refraction, appears in that place from +whence the Rays after their last Reflexion or Refraction diverge in +falling on the Spectator's Eye._ + +[Illustration: FIG. 9.] + +If the Object A [in FIG. 9.] be seen by Reflexion of a Looking-glass +_mn_, it shall appear, not in its proper place A, but behind the Glass +at _a_, from whence any Rays AB, AC, AD, which flow from one and the +same Point of the Object, do after their Reflexion made in the Points B, +C, D, diverge in going from the Glass to E, F, G, where they are +incident on the Spectator's Eyes. For these Rays do make the same +Picture in the bottom of the Eyes as if they had come from the Object +really placed at _a_ without the Interposition of the Looking-glass; and +all Vision is made according to the place and shape of that Picture. + +In like manner the Object D [in FIG. 2.] seen through a Prism, appears +not in its proper place D, but is thence translated to some other place +_d_ situated in the last refracted Ray FG drawn backward from F to _d_. + +[Illustration: FIG. 10.] + +And so the Object Q [in FIG. 10.] seen through the Lens AB, appears at +the place _q_ from whence the Rays diverge in passing from the Lens to +the Eye. Now it is to be noted, that the Image of the Object at _q_ is +so much bigger or lesser than the Object it self at Q, as the distance +of the Image at _q_ from the Lens AB is bigger or less than the distance +of the Object at Q from the same Lens. And if the Object be seen through +two or more such Convex or Concave-glasses, every Glass shall make a new +Image, and the Object shall appear in the place of the bigness of the +last Image. Which consideration unfolds the Theory of Microscopes and +Telescopes. For that Theory consists in almost nothing else than the +describing such Glasses as shall make the last Image of any Object as +distinct and large and luminous as it can conveniently be made. + +I have now given in Axioms and their Explications the sum of what hath +hitherto been treated of in Opticks. For what hath been generally +agreed on I content my self to assume under the notion of Principles, in +order to what I have farther to write. And this may suffice for an +Introduction to Readers of quick Wit and good Understanding not yet +versed in Opticks: Although those who are already acquainted with this +Science, and have handled Glasses, will more readily apprehend what +followeth. + +FOOTNOTES: + +[A] In our Author's _Lectiones Opticæ_, Part I. Sect. IV. Prop 29, 30, +there is an elegant Method of determining these _Foci_; not only in +spherical Surfaces, but likewise in any other curved Figure whatever: +And in Prop. 32, 33, the same thing is done for any Ray lying out of the +Axis. + +[B] _Ibid._ Prop. 34. + + + + +_PROPOSITIONS._ + + + +_PROP._ I. THEOR. I. + +_Lights which differ in Colour, differ also in Degrees of +Refrangibility._ + +The PROOF by Experiments. + +_Exper._ 1. + +I took a black oblong stiff Paper terminated by Parallel Sides, and with +a Perpendicular right Line drawn cross from one Side to the other, +distinguished it into two equal Parts. One of these parts I painted with +a red colour and the other with a blue. The Paper was very black, and +the Colours intense and thickly laid on, that the Phænomenon might be +more conspicuous. This Paper I view'd through a Prism of solid Glass, +whose two Sides through which the Light passed to the Eye were plane and +well polished, and contained an Angle of about sixty degrees; which +Angle I call the refracting Angle of the Prism. And whilst I view'd it, +I held it and the Prism before a Window in such manner that the Sides of +the Paper were parallel to the Prism, and both those Sides and the Prism +were parallel to the Horizon, and the cross Line was also parallel to +it: and that the Light which fell from the Window upon the Paper made an +Angle with the Paper, equal to that Angle which was made with the same +Paper by the Light reflected from it to the Eye. Beyond the Prism was +the Wall of the Chamber under the Window covered over with black Cloth, +and the Cloth was involved in Darkness that no Light might be reflected +from thence, which in passing by the Edges of the Paper to the Eye, +might mingle itself with the Light of the Paper, and obscure the +Phænomenon thereof. These things being thus ordered, I found that if the +refracting Angle of the Prism be turned upwards, so that the Paper may +seem to be lifted upwards by the Refraction, its blue half will be +lifted higher by the Refraction than its red half. But if the refracting +Angle of the Prism be turned downward, so that the Paper may seem to be +carried lower by the Refraction, its blue half will be carried something +lower thereby than its red half. Wherefore in both Cases the Light which +comes from the blue half of the Paper through the Prism to the Eye, does +in like Circumstances suffer a greater Refraction than the Light which +comes from the red half, and by consequence is more refrangible. + +_Illustration._ In the eleventh Figure, MN represents the Window, and DE +the Paper terminated with parallel Sides DJ and HE, and by the +transverse Line FG distinguished into two halfs, the one DG of an +intensely blue Colour, the other FE of an intensely red. And BAC_cab_ +represents the Prism whose refracting Planes AB_ba_ and AC_ca_ meet in +the Edge of the refracting Angle A_a_. This Edge A_a_ being upward, is +parallel both to the Horizon, and to the Parallel-Edges of the Paper DJ +and HE, and the transverse Line FG is perpendicular to the Plane of the +Window. And _de_ represents the Image of the Paper seen by Refraction +upwards in such manner, that the blue half DG is carried higher to _dg_ +than the red half FE is to _fe_, and therefore suffers a greater +Refraction. If the Edge of the refracting Angle be turned downward, the +Image of the Paper will be refracted downward; suppose to [Greek: de], +and the blue half will be refracted lower to [Greek: dg] than the red +half is to [Greek: pe]. + +[Illustration: FIG. 11.] + +_Exper._ 2. About the aforesaid Paper, whose two halfs were painted over +with red and blue, and which was stiff like thin Pasteboard, I lapped +several times a slender Thred of very black Silk, in such manner that +the several parts of the Thred might appear upon the Colours like so +many black Lines drawn over them, or like long and slender dark Shadows +cast upon them. I might have drawn black Lines with a Pen, but the +Threds were smaller and better defined. This Paper thus coloured and +lined I set against a Wall perpendicularly to the Horizon, so that one +of the Colours might stand to the Right Hand, and the other to the Left. +Close before the Paper, at the Confine of the Colours below, I placed a +Candle to illuminate the Paper strongly: For the Experiment was tried in +the Night. The Flame of the Candle reached up to the lower edge of the +Paper, or a very little higher. Then at the distance of six Feet, and +one or two Inches from the Paper upon the Floor I erected a Glass Lens +four Inches and a quarter broad, which might collect the Rays coming +from the several Points of the Paper, and make them converge towards so +many other Points at the same distance of six Feet, and one or two +Inches on the other side of the Lens, and so form the Image of the +coloured Paper upon a white Paper placed there, after the same manner +that a Lens at a Hole in a Window casts the Images of Objects abroad +upon a Sheet of white Paper in a dark Room. The aforesaid white Paper, +erected perpendicular to the Horizon, and to the Rays which fell upon it +from the Lens, I moved sometimes towards the Lens, sometimes from it, to +find the Places where the Images of the blue and red Parts of the +coloured Paper appeared most distinct. Those Places I easily knew by the +Images of the black Lines which I had made by winding the Silk about the +Paper. For the Images of those fine and slender Lines (which by reason +of their Blackness were like Shadows on the Colours) were confused and +scarce visible, unless when the Colours on either side of each Line were +terminated most distinctly, Noting therefore, as diligently as I could, +the Places where the Images of the red and blue halfs of the coloured +Paper appeared most distinct, I found that where the red half of the +Paper appeared distinct, the blue half appeared confused, so that the +black Lines drawn upon it could scarce be seen; and on the contrary, +where the blue half appeared most distinct, the red half appeared +confused, so that the black Lines upon it were scarce visible. And +between the two Places where these Images appeared distinct there was +the distance of an Inch and a half; the distance of the white Paper from +the Lens, when the Image of the red half of the coloured Paper appeared +most distinct, being greater by an Inch and an half than the distance of +the same white Paper from the Lens, when the Image of the blue half +appeared most distinct. In like Incidences therefore of the blue and red +upon the Lens, the blue was refracted more by the Lens than the red, so +as to converge sooner by an Inch and a half, and therefore is more +refrangible. + +_Illustration._ In the twelfth Figure (p. 27), DE signifies the coloured +Paper, DG the blue half, FE the red half, MN the Lens, HJ the white +Paper in that Place where the red half with its black Lines appeared +distinct, and _hi_ the same Paper in that Place where the blue half +appeared distinct. The Place _hi_ was nearer to the Lens MN than the +Place HJ by an Inch and an half. + +_Scholium._ The same Things succeed, notwithstanding that some of the +Circumstances be varied; as in the first Experiment when the Prism and +Paper are any ways inclined to the Horizon, and in both when coloured +Lines are drawn upon very black Paper. But in the Description of these +Experiments, I have set down such Circumstances, by which either the +Phænomenon might be render'd more conspicuous, or a Novice might more +easily try them, or by which I did try them only. The same Thing, I have +often done in the following Experiments: Concerning all which, this one +Admonition may suffice. Now from these Experiments it follows not, that +all the Light of the blue is more refrangible than all the Light of the +red: For both Lights are mixed of Rays differently refrangible, so that +in the red there are some Rays not less refrangible than those of the +blue, and in the blue there are some Rays not more refrangible than +those of the red: But these Rays, in proportion to the whole Light, are +but few, and serve to diminish the Event of the Experiment, but are not +able to destroy it. For, if the red and blue Colours were more dilute +and weak, the distance of the Images would be less than an Inch and a +half; and if they were more intense and full, that distance would be +greater, as will appear hereafter. These Experiments may suffice for the +Colours of Natural Bodies. For in the Colours made by the Refraction of +Prisms, this Proposition will appear by the Experiments which are now to +follow in the next Proposition. + + +_PROP._ II. THEOR. II. + +_The Light of the Sun consists of Rays differently Refrangible._ + +The PROOF by Experiments. + +[Illustration: FIG. 12.] + +[Illustration: FIG. 13.] + +_Exper._ 3. + +In a very dark Chamber, at a round Hole, about one third Part of an Inch +broad, made in the Shut of a Window, I placed a Glass Prism, whereby the +Beam of the Sun's Light, which came in at that Hole, might be refracted +upwards toward the opposite Wall of the Chamber, and there form a +colour'd Image of the Sun. The Axis of the Prism (that is, the Line +passing through the middle of the Prism from one end of it to the other +end parallel to the edge of the Refracting Angle) was in this and the +following Experiments perpendicular to the incident Rays. About this +Axis I turned the Prism slowly, and saw the refracted Light on the Wall, +or coloured Image of the Sun, first to descend, and then to ascend. +Between the Descent and Ascent, when the Image seemed Stationary, I +stopp'd the Prism, and fix'd it in that Posture, that it should be moved +no more. For in that Posture the Refractions of the Light at the two +Sides of the refracting Angle, that is, at the Entrance of the Rays into +the Prism, and at their going out of it, were equal to one another.[C] +So also in other Experiments, as often as I would have the Refractions +on both sides the Prism to be equal to one another, I noted the Place +where the Image of the Sun formed by the refracted Light stood still +between its two contrary Motions, in the common Period of its Progress +and Regress; and when the Image fell upon that Place, I made fast the +Prism. And in this Posture, as the most convenient, it is to be +understood that all the Prisms are placed in the following Experiments, +unless where some other Posture is described. The Prism therefore being +placed in this Posture, I let the refracted Light fall perpendicularly +upon a Sheet of white Paper at the opposite Wall of the Chamber, and +observed the Figure and Dimensions of the Solar Image formed on the +Paper by that Light. This Image was Oblong and not Oval, but terminated +with two Rectilinear and Parallel Sides, and two Semicircular Ends. On +its Sides it was bounded pretty distinctly, but on its Ends very +confusedly and indistinctly, the Light there decaying and vanishing by +degrees. The Breadth of this Image answered to the Sun's Diameter, and +was about two Inches and the eighth Part of an Inch, including the +Penumbra. For the Image was eighteen Feet and an half distant from the +Prism, and at this distance that Breadth, if diminished by the Diameter +of the Hole in the Window-shut, that is by a quarter of an Inch, +subtended an Angle at the Prism of about half a Degree, which is the +Sun's apparent Diameter. But the Length of the Image was about ten +Inches and a quarter, and the Length of the Rectilinear Sides about +eight Inches; and the refracting Angle of the Prism, whereby so great a +Length was made, was 64 degrees. With a less Angle the Length of the +Image was less, the Breadth remaining the same. If the Prism was turned +about its Axis that way which made the Rays emerge more obliquely out of +the second refracting Surface of the Prism, the Image soon became an +Inch or two longer, or more; and if the Prism was turned about the +contrary way, so as to make the Rays fall more obliquely on the first +refracting Surface, the Image soon became an Inch or two shorter. And +therefore in trying this Experiment, I was as curious as I could be in +placing the Prism by the above-mention'd Rule exactly in such a Posture, +that the Refractions of the Rays at their Emergence out of the Prism +might be equal to that at their Incidence on it. This Prism had some +Veins running along within the Glass from one end to the other, which +scattered some of the Sun's Light irregularly, but had no sensible +Effect in increasing the Length of the coloured Spectrum. For I tried +the same Experiment with other Prisms with the same Success. And +particularly with a Prism which seemed free from such Veins, and whose +refracting Angle was 62-1/2 Degrees, I found the Length of the Image +9-3/4 or 10 Inches at the distance of 18-1/2 Feet from the Prism, the +Breadth of the Hole in the Window-shut being 1/4 of an Inch, as before. +And because it is easy to commit a Mistake in placing the Prism in its +due Posture, I repeated the Experiment four or five Times, and always +found the Length of the Image that which is set down above. With another +Prism of clearer Glass and better Polish, which seemed free from Veins, +and whose refracting Angle was 63-1/2 Degrees, the Length of this Image +at the same distance of 18-1/2 Feet was also about 10 Inches, or 10-1/8. +Beyond these Measures for about a 1/4 or 1/3 of an Inch at either end of +the Spectrum the Light of the Clouds seemed to be a little tinged with +red and violet, but so very faintly, that I suspected that Tincture +might either wholly, or in great Measure arise from some Rays of the +Spectrum scattered irregularly by some Inequalities in the Substance and +Polish of the Glass, and therefore I did not include it in these +Measures. Now the different Magnitude of the hole in the Window-shut, +and different thickness of the Prism where the Rays passed through it, +and different inclinations of the Prism to the Horizon, made no sensible +changes in the length of the Image. Neither did the different matter of +the Prisms make any: for in a Vessel made of polished Plates of Glass +cemented together in the shape of a Prism and filled with Water, there +is the like Success of the Experiment according to the quantity of the +Refraction. It is farther to be observed, that the Rays went on in right +Lines from the Prism to the Image, and therefore at their very going out +of the Prism had all that Inclination to one another from which the +length of the Image proceeded, that is, the Inclination of more than two +degrees and an half. And yet according to the Laws of Opticks vulgarly +received, they could not possibly be so much inclined to one another.[D] +For let EG [_Fig._ 13. (p. 27)] represent the Window-shut, F the hole +made therein through which a beam of the Sun's Light was transmitted +into the darkened Chamber, and ABC a Triangular Imaginary Plane whereby +the Prism is feigned to be cut transversely through the middle of the +Light. Or if you please, let ABC represent the Prism it self, looking +directly towards the Spectator's Eye with its nearer end: And let XY be +the Sun, MN the Paper upon which the Solar Image or Spectrum is cast, +and PT the Image it self whose sides towards _v_ and _w_ are Rectilinear +and Parallel, and ends towards P and T Semicircular. YKHP and XLJT are +two Rays, the first of which comes from the lower part of the Sun to the +higher part of the Image, and is refracted in the Prism at K and H, and +the latter comes from the higher part of the Sun to the lower part of +the Image, and is refracted at L and J. Since the Refractions on both +sides the Prism are equal to one another, that is, the Refraction at K +equal to the Refraction at J, and the Refraction at L equal to the +Refraction at H, so that the Refractions of the incident Rays at K and L +taken together, are equal to the Refractions of the emergent Rays at H +and J taken together: it follows by adding equal things to equal things, +that the Refractions at K and H taken together, are equal to the +Refractions at J and L taken together, and therefore the two Rays being +equally refracted, have the same Inclination to one another after +Refraction which they had before; that is, the Inclination of half a +Degree answering to the Sun's Diameter. For so great was the inclination +of the Rays to one another before Refraction. So then, the length of the +Image PT would by the Rules of Vulgar Opticks subtend an Angle of half a +Degree at the Prism, and by Consequence be equal to the breadth _vw_; +and therefore the Image would be round. Thus it would be were the two +Rays XLJT and YKHP, and all the rest which form the Image P_w_T_v_, +alike refrangible. And therefore seeing by Experience it is found that +the Image is not round, but about five times longer than broad, the Rays +which going to the upper end P of the Image suffer the greatest +Refraction, must be more refrangible than those which go to the lower +end T, unless the Inequality of Refraction be casual. + +This Image or Spectrum PT was coloured, being red at its least refracted +end T, and violet at its most refracted end P, and yellow green and +blue in the intermediate Spaces. Which agrees with the first +Proposition, that Lights which differ in Colour, do also differ in +Refrangibility. The length of the Image in the foregoing Experiments, I +measured from the faintest and outmost red at one end, to the faintest +and outmost blue at the other end, excepting only a little Penumbra, +whose breadth scarce exceeded a quarter of an Inch, as was said above. + +_Exper._ 4. In the Sun's Beam which was propagated into the Room through +the hole in the Window-shut, at the distance of some Feet from the hole, +I held the Prism in such a Posture, that its Axis might be perpendicular +to that Beam. Then I looked through the Prism upon the hole, and turning +the Prism to and fro about its Axis, to make the Image of the Hole +ascend and descend, when between its two contrary Motions it seemed +Stationary, I stopp'd the Prism, that the Refractions of both sides of +the refracting Angle might be equal to each other, as in the former +Experiment. In this situation of the Prism viewing through it the said +Hole, I observed the length of its refracted Image to be many times +greater than its breadth, and that the most refracted part thereof +appeared violet, the least refracted red, the middle parts blue, green +and yellow in order. The same thing happen'd when I removed the Prism +out of the Sun's Light, and looked through it upon the hole shining by +the Light of the Clouds beyond it. And yet if the Refraction were done +regularly according to one certain Proportion of the Sines of Incidence +and Refraction as is vulgarly supposed, the refracted Image ought to +have appeared round. + +So then, by these two Experiments it appears, that in Equal Incidences +there is a considerable inequality of Refractions. But whence this +inequality arises, whether it be that some of the incident Rays are +refracted more, and others less, constantly, or by chance, or that one +and the same Ray is by Refraction disturbed, shatter'd, dilated, and as +it were split and spread into many diverging Rays, as _Grimaldo_ +supposes, does not yet appear by these Experiments, but will appear by +those that follow. + +_Exper._ 5. Considering therefore, that if in the third Experiment the +Image of the Sun should be drawn out into an oblong Form, either by a +Dilatation of every Ray, or by any other casual inequality of the +Refractions, the same oblong Image would by a second Refraction made +sideways be drawn out as much in breadth by the like Dilatation of the +Rays, or other casual inequality of the Refractions sideways, I tried +what would be the Effects of such a second Refraction. For this end I +ordered all things as in the third Experiment, and then placed a second +Prism immediately after the first in a cross Position to it, that it +might again refract the beam of the Sun's Light which came to it through +the first Prism. In the first Prism this beam was refracted upwards, and +in the second sideways. And I found that by the Refraction of the second +Prism, the breadth of the Image was not increased, but its superior +part, which in the first Prism suffered the greater Refraction, and +appeared violet and blue, did again in the second Prism suffer a greater +Refraction than its inferior part, which appeared red and yellow, and +this without any Dilatation of the Image in breadth. + +[Illustration: FIG. 14] + +_Illustration._ Let S [_Fig._ 14, 15.] represent the Sun, F the hole in +the Window, ABC the first Prism, DH the second Prism, Y the round Image +of the Sun made by a direct beam of Light when the Prisms are taken +away, PT the oblong Image of the Sun made by that beam passing through +the first Prism alone, when the second Prism is taken away, and _pt_ the +Image made by the cross Refractions of both Prisms together. Now if the +Rays which tend towards the several Points of the round Image Y were +dilated and spread by the Refraction of the first Prism, so that they +should not any longer go in single Lines to single Points, but that +every Ray being split, shattered, and changed from a Linear Ray to a +Superficies of Rays diverging from the Point of Refraction, and lying in +the Plane of the Angles of Incidence and Refraction, they should go in +those Planes to so many Lines reaching almost from one end of the Image +PT to the other, and if that Image should thence become oblong: those +Rays and their several parts tending towards the several Points of the +Image PT ought to be again dilated and spread sideways by the transverse +Refraction of the second Prism, so as to compose a four square Image, +such as is represented at [Greek: pt]. For the better understanding of +which, let the Image PT be distinguished into five equal parts PQK, +KQRL, LRSM, MSVN, NVT. And by the same irregularity that the orbicular +Light Y is by the Refraction of the first Prism dilated and drawn out +into a long Image PT, the Light PQK which takes up a space of the same +length and breadth with the Light Y ought to be by the Refraction of the +second Prism dilated and drawn out into the long Image _[Greek: p]qkp_, +and the Light KQRL into the long Image _kqrl_, and the Lights LRSM, +MSVN, NVT, into so many other long Images _lrsm_, _msvn_, _nvt[Greek: +t]_; and all these long Images would compose the four square Images +_[Greek: pt]_. Thus it ought to be were every Ray dilated by Refraction, +and spread into a triangular Superficies of Rays diverging from the +Point of Refraction. For the second Refraction would spread the Rays one +way as much as the first doth another, and so dilate the Image in +breadth as much as the first doth in length. And the same thing ought to +happen, were some rays casually refracted more than others. But the +Event is otherwise. The Image PT was not made broader by the Refraction +of the second Prism, but only became oblique, as 'tis represented at +_pt_, its upper end P being by the Refraction translated to a greater +distance than its lower end T. So then the Light which went towards the +upper end P of the Image, was (at equal Incidences) more refracted in +the second Prism, than the Light which tended towards the lower end T, +that is the blue and violet, than the red and yellow; and therefore was +more refrangible. The same Light was by the Refraction of the first +Prism translated farther from the place Y to which it tended before +Refraction; and therefore suffered as well in the first Prism as in the +second a greater Refraction than the rest of the Light, and by +consequence was more refrangible than the rest, even before its +incidence on the first Prism. + +Sometimes I placed a third Prism after the second, and sometimes also a +fourth after the third, by all which the Image might be often refracted +sideways: but the Rays which were more refracted than the rest in the +first Prism were also more refracted in all the rest, and that without +any Dilatation of the Image sideways: and therefore those Rays for their +constancy of a greater Refraction are deservedly reputed more +refrangible. + +[Illustration: FIG. 15] + +But that the meaning of this Experiment may more clearly appear, it is +to be considered that the Rays which are equally refrangible do fall +upon a Circle answering to the Sun's Disque. For this was proved in the +third Experiment. By a Circle I understand not here a perfect +geometrical Circle, but any orbicular Figure whose length is equal to +its breadth, and which, as to Sense, may seem circular. Let therefore AG +[in _Fig._ 15.] represent the Circle which all the most refrangible Rays +propagated from the whole Disque of the Sun, would illuminate and paint +upon the opposite Wall if they were alone; EL the Circle which all the +least refrangible Rays would in like manner illuminate and paint if they +were alone; BH, CJ, DK, the Circles which so many intermediate sorts of +Rays would successively paint upon the Wall, if they were singly +propagated from the Sun in successive order, the rest being always +intercepted; and conceive that there are other intermediate Circles +without Number, which innumerable other intermediate sorts of Rays would +successively paint upon the Wall if the Sun should successively emit +every sort apart. And seeing the Sun emits all these sorts at once, they +must all together illuminate and paint innumerable equal Circles, of all +which, being according to their degrees of Refrangibility placed in +order in a continual Series, that oblong Spectrum PT is composed which I +described in the third Experiment. Now if the Sun's circular Image Y [in +_Fig._ 15.] which is made by an unrefracted beam of Light was by any +Dilation of the single Rays, or by any other irregularity in the +Refraction of the first Prism, converted into the oblong Spectrum, PT: +then ought every Circle AG, BH, CJ, &c. in that Spectrum, by the cross +Refraction of the second Prism again dilating or otherwise scattering +the Rays as before, to be in like manner drawn out and transformed into +an oblong Figure, and thereby the breadth of the Image PT would be now +as much augmented as the length of the Image Y was before by the +Refraction of the first Prism; and thus by the Refractions of both +Prisms together would be formed a four square Figure _p[Greek: +p]t[Greek: t]_, as I described above. Wherefore since the breadth of the +Spectrum PT is not increased by the Refraction sideways, it is certain +that the Rays are not split or dilated, or otherways irregularly +scatter'd by that Refraction, but that every Circle is by a regular and +uniform Refraction translated entire into another Place, as the Circle +AG by the greatest Refraction into the place _ag_, the Circle BH by a +less Refraction into the place _bh_, the Circle CJ by a Refraction still +less into the place _ci_, and so of the rest; by which means a new +Spectrum _pt_ inclined to the former PT is in like manner composed of +Circles lying in a right Line; and these Circles must be of the same +bigness with the former, because the breadths of all the Spectrums Y, PT +and _pt_ at equal distances from the Prisms are equal. + +I considered farther, that by the breadth of the hole F through which +the Light enters into the dark Chamber, there is a Penumbra made in the +Circuit of the Spectrum Y, and that Penumbra remains in the rectilinear +Sides of the Spectrums PT and _pt_. I placed therefore at that hole a +Lens or Object-glass of a Telescope which might cast the Image of the +Sun distinctly on Y without any Penumbra at all, and found that the +Penumbra of the rectilinear Sides of the oblong Spectrums PT and _pt_ +was also thereby taken away, so that those Sides appeared as distinctly +defined as did the Circumference of the first Image Y. Thus it happens +if the Glass of the Prisms be free from Veins, and their sides be +accurately plane and well polished without those numberless Waves or +Curles which usually arise from Sand-holes a little smoothed in +polishing with Putty. If the Glass be only well polished and free from +Veins, and the Sides not accurately plane, but a little Convex or +Concave, as it frequently happens; yet may the three Spectrums Y, PT and +_pt_ want Penumbras, but not in equal distances from the Prisms. Now +from this want of Penumbras, I knew more certainly that every one of the +Circles was refracted according to some most regular, uniform and +constant Law. For if there were any irregularity in the Refraction, the +right Lines AE and GL, which all the Circles in the Spectrum PT do +touch, could not by that Refraction be translated into the Lines _ae_ +and _gl_ as distinct and straight as they were before, but there would +arise in those translated Lines some Penumbra or Crookedness or +Undulation, or other sensible Perturbation contrary to what is found by +Experience. Whatsoever Penumbra or Perturbation should be made in the +Circles by the cross Refraction of the second Prism, all that Penumbra +or Perturbation would be conspicuous in the right Lines _ae_ and _gl_ +which touch those Circles. And therefore since there is no such Penumbra +or Perturbation in those right Lines, there must be none in the +Circles. Since the distance between those Tangents or breadth of the +Spectrum is not increased by the Refractions, the Diameters of the +Circles are not increased thereby. Since those Tangents continue to be +right Lines, every Circle which in the first Prism is more or less +refracted, is exactly in the same proportion more or less refracted in +the second. And seeing all these things continue to succeed after the +same manner when the Rays are again in a third Prism, and again in a +fourth refracted sideways, it is evident that the Rays of one and the +same Circle, as to their degree of Refrangibility, continue always +uniform and homogeneal to one another, and that those of several Circles +do differ in degree of Refrangibility, and that in some certain and +constant Proportion. Which is the thing I was to prove. + +There is yet another Circumstance or two of this Experiment by which it +becomes still more plain and convincing. Let the second Prism DH [in +_Fig._ 16.] be placed not immediately after the first, but at some +distance from it; suppose in the mid-way between it and the Wall on +which the oblong Spectrum PT is cast, so that the Light from the first +Prism may fall upon it in the form of an oblong Spectrum [Greek: pt] +parallel to this second Prism, and be refracted sideways to form the +oblong Spectrum _pt_ upon the Wall. And you will find as before, that +this Spectrum _pt_ is inclined to that Spectrum PT, which the first +Prism forms alone without the second; the blue ends P and _p_ being +farther distant from one another than the red ones T and _t_, and by +consequence that the Rays which go to the blue end [Greek: p] of the +Image [Greek: pt], and which therefore suffer the greatest Refraction in +the first Prism, are again in the second Prism more refracted than the +rest. + +[Illustration: FIG. 16.] + +[Illustration: FIG. 17.] + +The same thing I try'd also by letting the Sun's Light into a dark Room +through two little round holes F and [Greek: ph] [in _Fig._ 17.] made in +the Window, and with two parallel Prisms ABC and [Greek: abg] placed at +those holes (one at each) refracting those two beams of Light to the +opposite Wall of the Chamber, in such manner that the two colour'd +Images PT and MN which they there painted were joined end to end and lay +in one straight Line, the red end T of the one touching the blue end M +of the other. For if these two refracted Beams were again by a third +Prism DH placed cross to the two first, refracted sideways, and the +Spectrums thereby translated to some other part of the Wall of the +Chamber, suppose the Spectrum PT to _pt_ and the Spectrum MN to _mn_, +these translated Spectrums _pt_ and _mn_ would not lie in one straight +Line with their ends contiguous as before, but be broken off from one +another and become parallel, the blue end _m_ of the Image _mn_ being by +a greater Refraction translated farther from its former place MT, than +the red end _t_ of the other Image _pt_ from the same place MT; which +puts the Proposition past Dispute. And this happens whether the third +Prism DH be placed immediately after the two first, or at a great +distance from them, so that the Light refracted in the two first Prisms +be either white and circular, or coloured and oblong when it falls on +the third. + +_Exper._ 6. In the middle of two thin Boards I made round holes a third +part of an Inch in diameter, and in the Window-shut a much broader hole +being made to let into my darkned Chamber a large Beam of the Sun's +Light; I placed a Prism behind the Shut in that beam to refract it +towards the opposite Wall, and close behind the Prism I fixed one of the +Boards, in such manner that the middle of the refracted Light might pass +through the hole made in it, and the rest be intercepted by the Board. +Then at the distance of about twelve Feet from the first Board I fixed +the other Board in such manner that the middle of the refracted Light +which came through the hole in the first Board, and fell upon the +opposite Wall, might pass through the hole in this other Board, and the +rest being intercepted by the Board might paint upon it the coloured +Spectrum of the Sun. And close behind this Board I fixed another Prism +to refract the Light which came through the hole. Then I returned +speedily to the first Prism, and by turning it slowly to and fro about +its Axis, I caused the Image which fell upon the second Board to move up +and down upon that Board, that all its parts might successively pass +through the hole in that Board and fall upon the Prism behind it. And in +the mean time, I noted the places on the opposite Wall to which that +Light after its Refraction in the second Prism did pass; and by the +difference of the places I found that the Light which being most +refracted in the first Prism did go to the blue end of the Image, was +again more refracted in the second Prism than the Light which went to +the red end of that Image, which proves as well the first Proposition as +the second. And this happened whether the Axis of the two Prisms were +parallel, or inclined to one another, and to the Horizon in any given +Angles. + +_Illustration._ Let F [in _Fig._ 18.] be the wide hole in the +Window-shut, through which the Sun shines upon the first Prism ABC, and +let the refracted Light fall upon the middle of the Board DE, and the +middle part of that Light upon the hole G made in the middle part of +that Board. Let this trajected part of that Light fall again upon the +middle of the second Board _de_, and there paint such an oblong coloured +Image of the Sun as was described in the third Experiment. By turning +the Prism ABC slowly to and fro about its Axis, this Image will be made +to move up and down the Board _de_, and by this means all its parts from +one end to the other may be made to pass successively through the hole +_g_ which is made in the middle of that Board. In the mean while another +Prism _abc_ is to be fixed next after that hole _g_, to refract the +trajected Light a second time. And these things being thus ordered, I +marked the places M and N of the opposite Wall upon which the refracted +Light fell, and found that whilst the two Boards and second Prism +remained unmoved, those places by turning the first Prism about its Axis +were changed perpetually. For when the lower part of the Light which +fell upon the second Board _de_ was cast through the hole _g_, it went +to a lower place M on the Wall and when the higher part of that Light +was cast through the same hole _g_, it went to a higher place N on the +Wall, and when any intermediate part of the Light was cast through that +hole, it went to some place on the Wall between M and N. The unchanged +Position of the holes in the Boards, made the Incidence of the Rays upon +the second Prism to be the same in all cases. And yet in that common +Incidence some of the Rays were more refracted, and others less. And +those were more refracted in this Prism, which by a greater Refraction +in the first Prism were more turned out of the way, and therefore for +their Constancy of being more refracted are deservedly called more +refrangible. + +[Illustration: FIG. 18.] + +[Illustration: FIG. 20.] + +_Exper._ 7. At two holes made near one another in my Window-shut I +placed two Prisms, one at each, which might cast upon the opposite Wall +(after the manner of the third Experiment) two oblong coloured Images of +the Sun. And at a little distance from the Wall I placed a long slender +Paper with straight and parallel edges, and ordered the Prisms and Paper +so, that the red Colour of one Image might fall directly upon one half +of the Paper, and the violet Colour of the other Image upon the other +half of the same Paper; so that the Paper appeared of two Colours, red +and violet, much after the manner of the painted Paper in the first and +second Experiments. Then with a black Cloth I covered the Wall behind +the Paper, that no Light might be reflected from it to disturb the +Experiment, and viewing the Paper through a third Prism held parallel +to it, I saw that half of it which was illuminated by the violet Light +to be divided from the other half by a greater Refraction, especially +when I went a good way off from the Paper. For when I viewed it too near +at hand, the two halfs of the Paper did not appear fully divided from +one another, but seemed contiguous at one of their Angles like the +painted Paper in the first Experiment. Which also happened when the +Paper was too broad. + +[Illustration: FIG. 19.] + +Sometimes instead of the Paper I used a white Thred, and this appeared +through the Prism divided into two parallel Threds as is represented in +the nineteenth Figure, where DG denotes the Thred illuminated with +violet Light from D to E and with red Light from F to G, and _defg_ are +the parts of the Thred seen by Refraction. If one half of the Thred be +constantly illuminated with red, and the other half be illuminated with +all the Colours successively, (which may be done by causing one of the +Prisms to be turned about its Axis whilst the other remains unmoved) +this other half in viewing the Thred through the Prism, will appear in +a continual right Line with the first half when illuminated with red, +and begin to be a little divided from it when illuminated with Orange, +and remove farther from it when illuminated with yellow, and still +farther when with green, and farther when with blue, and go yet farther +off when illuminated with Indigo, and farthest when with deep violet. +Which plainly shews, that the Lights of several Colours are more and +more refrangible one than another, in this Order of their Colours, red, +orange, yellow, green, blue, indigo, deep violet; and so proves as well +the first Proposition as the second. + +I caused also the coloured Spectrums PT [in _Fig._ 17.] and MN made in a +dark Chamber by the Refractions of two Prisms to lie in a Right Line end +to end, as was described above in the fifth Experiment, and viewing them +through a third Prism held parallel to their Length, they appeared no +longer in a Right Line, but became broken from one another, as they are +represented at _pt_ and _mn_, the violet end _m_ of the Spectrum _mn_ +being by a greater Refraction translated farther from its former Place +MT than the red end _t_ of the other Spectrum _pt_. + +I farther caused those two Spectrums PT [in _Fig._ 20.] and MN to become +co-incident in an inverted Order of their Colours, the red end of each +falling on the violet end of the other, as they are represented in the +oblong Figure PTMN; and then viewing them through a Prism DH held +parallel to their Length, they appeared not co-incident, as when view'd +with the naked Eye, but in the form of two distinct Spectrums _pt_ and +_mn_ crossing one another in the middle after the manner of the Letter +X. Which shews that the red of the one Spectrum and violet of the other, +which were co-incident at PN and MT, being parted from one another by a +greater Refraction of the violet to _p_ and _m_ than of the red to _n_ +and _t_, do differ in degrees of Refrangibility. + +I illuminated also a little Circular Piece of white Paper all over with +the Lights of both Prisms intermixed, and when it was illuminated with +the red of one Spectrum, and deep violet of the other, so as by the +Mixture of those Colours to appear all over purple, I viewed the Paper, +first at a less distance, and then at a greater, through a third Prism; +and as I went from the Paper, the refracted Image thereof became more +and more divided by the unequal Refraction of the two mixed Colours, and +at length parted into two distinct Images, a red one and a violet one, +whereof the violet was farthest from the Paper, and therefore suffered +the greatest Refraction. And when that Prism at the Window, which cast +the violet on the Paper was taken away, the violet Image disappeared; +but when the other Prism was taken away the red vanished; which shews, +that these two Images were nothing else than the Lights of the two +Prisms, which had been intermixed on the purple Paper, but were parted +again by their unequal Refractions made in the third Prism, through +which the Paper was view'd. This also was observable, that if one of the +Prisms at the Window, suppose that which cast the violet on the Paper, +was turned about its Axis to make all the Colours in this order, +violet, indigo, blue, green, yellow, orange, red, fall successively on +the Paper from that Prism, the violet Image changed Colour accordingly, +turning successively to indigo, blue, green, yellow and red, and in +changing Colour came nearer and nearer to the red Image made by the +other Prism, until when it was also red both Images became fully +co-incident. + +I placed also two Paper Circles very near one another, the one in the +red Light of one Prism, and the other in the violet Light of the other. +The Circles were each of them an Inch in diameter, and behind them the +Wall was dark, that the Experiment might not be disturbed by any Light +coming from thence. These Circles thus illuminated, I viewed through a +Prism, so held, that the Refraction might be made towards the red +Circle, and as I went from them they came nearer and nearer together, +and at length became co-incident; and afterwards when I went still +farther off, they parted again in a contrary Order, the violet by a +greater Refraction being carried beyond the red. + +_Exper._ 8. In Summer, when the Sun's Light uses to be strongest, I +placed a Prism at the Hole of the Window-shut, as in the third +Experiment, yet so that its Axis might be parallel to the Axis of the +World, and at the opposite Wall in the Sun's refracted Light, I placed +an open Book. Then going six Feet and two Inches from the Book, I placed +there the above-mentioned Lens, by which the Light reflected from the +Book might be made to converge and meet again at the distance of six +Feet and two Inches behind the Lens, and there paint the Species of the +Book upon a Sheet of white Paper much after the manner of the second +Experiment. The Book and Lens being made fast, I noted the Place where +the Paper was, when the Letters of the Book, illuminated by the fullest +red Light of the Solar Image falling upon it, did cast their Species on +that Paper most distinctly: And then I stay'd till by the Motion of the +Sun, and consequent Motion of his Image on the Book, all the Colours +from that red to the middle of the blue pass'd over those Letters; and +when those Letters were illuminated by that blue, I noted again the +Place of the Paper when they cast their Species most distinctly upon it: +And I found that this last Place of the Paper was nearer to the Lens +than its former Place by about two Inches and an half, or two and three +quarters. So much sooner therefore did the Light in the violet end of +the Image by a greater Refraction converge and meet, than the Light in +the red end. But in trying this, the Chamber was as dark as I could make +it. For, if these Colours be diluted and weakned by the Mixture of any +adventitious Light, the distance between the Places of the Paper will +not be so great. This distance in the second Experiment, where the +Colours of natural Bodies were made use of, was but an Inch and an half, +by reason of the Imperfection of those Colours. Here in the Colours of +the Prism, which are manifestly more full, intense, and lively than +those of natural Bodies, the distance is two Inches and three quarters. +And were the Colours still more full, I question not but that the +distance would be considerably greater. For the coloured Light of the +Prism, by the interfering of the Circles described in the second Figure +of the fifth Experiment, and also by the Light of the very bright Clouds +next the Sun's Body intermixing with these Colours, and by the Light +scattered by the Inequalities in the Polish of the Prism, was so very +much compounded, that the Species which those faint and dark Colours, +the indigo and violet, cast upon the Paper were not distinct enough to +be well observed. + +_Exper._ 9. A Prism, whose two Angles at its Base were equal to one +another, and half right ones, and the third a right one, I placed in a +Beam of the Sun's Light let into a dark Chamber through a Hole in the +Window-shut, as in the third Experiment. And turning the Prism slowly +about its Axis, until all the Light which went through one of its +Angles, and was refracted by it began to be reflected by its Base, at +which till then it went out of the Glass, I observed that those Rays +which had suffered the greatest Refraction were sooner reflected than +the rest. I conceived therefore, that those Rays of the reflected Light, +which were most refrangible, did first of all by a total Reflexion +become more copious in that Light than the rest, and that afterwards the +rest also, by a total Reflexion, became as copious as these. To try +this, I made the reflected Light pass through another Prism, and being +refracted by it to fall afterwards upon a Sheet of white Paper placed +at some distance behind it, and there by that Refraction to paint the +usual Colours of the Prism. And then causing the first Prism to be +turned about its Axis as above, I observed that when those Rays, which +in this Prism had suffered the greatest Refraction, and appeared of a +blue and violet Colour began to be totally reflected, the blue and +violet Light on the Paper, which was most refracted in the second Prism, +received a sensible Increase above that of the red and yellow, which was +least refracted; and afterwards, when the rest of the Light which was +green, yellow, and red, began to be totally reflected in the first +Prism, the Light of those Colours on the Paper received as great an +Increase as the violet and blue had done before. Whence 'tis manifest, +that the Beam of Light reflected by the Base of the Prism, being +augmented first by the more refrangible Rays, and afterwards by the less +refrangible ones, is compounded of Rays differently refrangible. And +that all such reflected Light is of the same Nature with the Sun's Light +before its Incidence on the Base of the Prism, no Man ever doubted; it +being generally allowed, that Light by such Reflexions suffers no +Alteration in its Modifications and Properties. I do not here take +Notice of any Refractions made in the sides of the first Prism, because +the Light enters it perpendicularly at the first side, and goes out +perpendicularly at the second side, and therefore suffers none. So then, +the Sun's incident Light being of the same Temper and Constitution with +his emergent Light, and the last being compounded of Rays differently +refrangible, the first must be in like manner compounded. + +[Illustration: FIG. 21.] + +_Illustration._ In the twenty-first Figure, ABC is the first Prism, BC +its Base, B and C its equal Angles at the Base, each of 45 Degrees, A +its rectangular Vertex, FM a beam of the Sun's Light let into a dark +Room through a hole F one third part of an Inch broad, M its Incidence +on the Base of the Prism, MG a less refracted Ray, MH a more refracted +Ray, MN the beam of Light reflected from the Base, VXY the second Prism +by which this beam in passing through it is refracted, N_t_ the less +refracted Light of this beam, and N_p_ the more refracted part thereof. +When the first Prism ABC is turned about its Axis according to the order +of the Letters ABC, the Rays MH emerge more and more obliquely out of +that Prism, and at length after their most oblique Emergence are +reflected towards N, and going on to _p_ do increase the Number of the +Rays N_p_. Afterwards by continuing the Motion of the first Prism, the +Rays MG are also reflected to N and increase the number of the Rays +N_t_. And therefore the Light MN admits into its Composition, first the +more refrangible Rays, and then the less refrangible Rays, and yet after +this Composition is of the same Nature with the Sun's immediate Light +FM, the Reflexion of the specular Base BC causing no Alteration therein. + +_Exper._ 10. Two Prisms, which were alike in Shape, I tied so together, +that their Axis and opposite Sides being parallel, they composed a +Parallelopiped. And, the Sun shining into my dark Chamber through a +little hole in the Window-shut, I placed that Parallelopiped in his beam +at some distance from the hole, in such a Posture, that the Axes of the +Prisms might be perpendicular to the incident Rays, and that those Rays +being incident upon the first Side of one Prism, might go on through the +two contiguous Sides of both Prisms, and emerge out of the last Side of +the second Prism. This Side being parallel to the first Side of the +first Prism, caused the emerging Light to be parallel to the incident. +Then, beyond these two Prisms I placed a third, which might refract that +emergent Light, and by that Refraction cast the usual Colours of the +Prism upon the opposite Wall, or upon a sheet of white Paper held at a +convenient Distance behind the Prism for that refracted Light to fall +upon it. After this I turned the Parallelopiped about its Axis, and +found that when the contiguous Sides of the two Prisms became so oblique +to the incident Rays, that those Rays began all of them to be +reflected, those Rays which in the third Prism had suffered the greatest +Refraction, and painted the Paper with violet and blue, were first of +all by a total Reflexion taken out of the transmitted Light, the rest +remaining and on the Paper painting their Colours of green, yellow, +orange and red, as before; and afterwards by continuing the Motion of +the two Prisms, the rest of the Rays also by a total Reflexion vanished +in order, according to their degrees of Refrangibility. The Light +therefore which emerged out of the two Prisms is compounded of Rays +differently refrangible, seeing the more refrangible Rays may be taken +out of it, while the less refrangible remain. But this Light being +trajected only through the parallel Superficies of the two Prisms, if it +suffer'd any change by the Refraction of one Superficies it lost that +Impression by the contrary Refraction of the other Superficies, and so +being restor'd to its pristine Constitution, became of the same Nature +and Condition as at first before its Incidence on those Prisms; and +therefore, before its Incidence, was as much compounded of Rays +differently refrangible, as afterwards. + +[Illustration: FIG. 22.] + +_Illustration._ In the twenty second Figure ABC and BCD are the two +Prisms tied together in the form of a Parallelopiped, their Sides BC and +CB being contiguous, and their Sides AB and CD parallel. And HJK is the +third Prism, by which the Sun's Light propagated through the hole F into +the dark Chamber, and there passing through those sides of the Prisms +AB, BC, CB and CD, is refracted at O to the white Paper PT, falling +there partly upon P by a greater Refraction, partly upon T by a less +Refraction, and partly upon R and other intermediate places by +intermediate Refractions. By turning the Parallelopiped ACBD about its +Axis, according to the order of the Letters A, C, D, B, at length when +the contiguous Planes BC and CB become sufficiently oblique to the Rays +FM, which are incident upon them at M, there will vanish totally out of +the refracted Light OPT, first of all the most refracted Rays OP, (the +rest OR and OT remaining as before) then the Rays OR and other +intermediate ones, and lastly, the least refracted Rays OT. For when +the Plane BC becomes sufficiently oblique to the Rays incident upon it, +those Rays will begin to be totally reflected by it towards N; and first +the most refrangible Rays will be totally reflected (as was explained in +the preceding Experiment) and by Consequence must first disappear at P, +and afterwards the rest as they are in order totally reflected to N, +they must disappear in the same order at R and T. So then the Rays which +at O suffer the greatest Refraction, may be taken out of the Light MO +whilst the rest of the Rays remain in it, and therefore that Light MO is +compounded of Rays differently refrangible. And because the Planes AB +and CD are parallel, and therefore by equal and contrary Refractions +destroy one anothers Effects, the incident Light FM must be of the same +Kind and Nature with the emergent Light MO, and therefore doth also +consist of Rays differently refrangible. These two Lights FM and MO, +before the most refrangible Rays are separated out of the emergent Light +MO, agree in Colour, and in all other Properties so far as my +Observation reaches, and therefore are deservedly reputed of the same +Nature and Constitution, and by Consequence the one is compounded as +well as the other. But after the most refrangible Rays begin to be +totally reflected, and thereby separated out of the emergent Light MO, +that Light changes its Colour from white to a dilute and faint yellow, a +pretty good orange, a very full red successively, and then totally +vanishes. For after the most refrangible Rays which paint the Paper at +P with a purple Colour, are by a total Reflexion taken out of the beam +of Light MO, the rest of the Colours which appear on the Paper at R and +T being mix'd in the Light MO compound there a faint yellow, and after +the blue and part of the green which appear on the Paper between P and R +are taken away, the rest which appear between R and T (that is the +yellow, orange, red and a little green) being mixed in the beam MO +compound there an orange; and when all the Rays are by Reflexion taken +out of the beam MO, except the least refrangible, which at T appear of a +full red, their Colour is the same in that beam MO as afterwards at T, +the Refraction of the Prism HJK serving only to separate the differently +refrangible Rays, without making any Alteration in their Colours, as +shall be more fully proved hereafter. All which confirms as well the +first Proposition as the second. + +_Scholium._ If this Experiment and the former be conjoined and made one +by applying a fourth Prism VXY [in _Fig._ 22.] to refract the reflected +beam MN towards _tp_, the Conclusion will be clearer. For then the Light +N_p_ which in the fourth Prism is more refracted, will become fuller and +stronger when the Light OP, which in the third Prism HJK is more +refracted, vanishes at P; and afterwards when the less refracted Light +OT vanishes at T, the less refracted Light N_t_ will become increased +whilst the more refracted Light at _p_ receives no farther increase. And +as the trajected beam MO in vanishing is always of such a Colour as +ought to result from the mixture of the Colours which fall upon the +Paper PT, so is the reflected beam MN always of such a Colour as ought +to result from the mixture of the Colours which fall upon the Paper +_pt_. For when the most refrangible Rays are by a total Reflexion taken +out of the beam MO, and leave that beam of an orange Colour, the Excess +of those Rays in the reflected Light, does not only make the violet, +indigo and blue at _p_ more full, but also makes the beam MN change from +the yellowish Colour of the Sun's Light, to a pale white inclining to +blue, and afterward recover its yellowish Colour again, so soon as all +the rest of the transmitted Light MOT is reflected. + +Now seeing that in all this variety of Experiments, whether the Trial be +made in Light reflected, and that either from natural Bodies, as in the +first and second Experiment, or specular, as in the ninth; or in Light +refracted, and that either before the unequally refracted Rays are by +diverging separated from one another, and losing their whiteness which +they have altogether, appear severally of several Colours, as in the +fifth Experiment; or after they are separated from one another, and +appear colour'd as in the sixth, seventh, and eighth Experiments; or in +Light trajected through parallel Superficies, destroying each others +Effects, as in the tenth Experiment; there are always found Rays, which +at equal Incidences on the same Medium suffer unequal Refractions, and +that without any splitting or dilating of single Rays, or contingence in +the inequality of the Refractions, as is proved in the fifth and sixth +Experiments. And seeing the Rays which differ in Refrangibility may be +parted and sorted from one another, and that either by Refraction as in +the third Experiment, or by Reflexion as in the tenth, and then the +several sorts apart at equal Incidences suffer unequal Refractions, and +those sorts are more refracted than others after Separation, which were +more refracted before it, as in the sixth and following Experiments, and +if the Sun's Light be trajected through three or more cross Prisms +successively, those Rays which in the first Prism are refracted more +than others, are in all the following Prisms refracted more than others +in the same Rate and Proportion, as appears by the fifth Experiment; +it's manifest that the Sun's Light is an heterogeneous Mixture of Rays, +some of which are constantly more refrangible than others, as was +proposed. + + +_PROP._ III. THEOR. III. + +_The Sun's Light consists of Rays differing in Reflexibility, and those +Rays are more reflexible than others which are more refrangible._ + +This is manifest by the ninth and tenth Experiments: For in the ninth +Experiment, by turning the Prism about its Axis, until the Rays within +it which in going out into the Air were refracted by its Base, became so +oblique to that Base, as to begin to be totally reflected thereby; those +Rays became first of all totally reflected, which before at equal +Incidences with the rest had suffered the greatest Refraction. And the +same thing happens in the Reflexion made by the common Base of the two +Prisms in the tenth Experiment. + + +_PROP._ IV. PROB. I. + +_To separate from one another the heterogeneous Rays of compound Light._ + +[Illustration: FIG. 23.] + +The heterogeneous Rays are in some measure separated from one another by +the Refraction of the Prism in the third Experiment, and in the fifth +Experiment, by taking away the Penumbra from the rectilinear sides of +the coloured Image, that Separation in those very rectilinear sides or +straight edges of the Image becomes perfect. But in all places between +those rectilinear edges, those innumerable Circles there described, +which are severally illuminated by homogeneal Rays, by interfering with +one another, and being every where commix'd, do render the Light +sufficiently compound. But if these Circles, whilst their Centers keep +their Distances and Positions, could be made less in Diameter, their +interfering one with another, and by Consequence the Mixture of the +heterogeneous Rays would be proportionally diminish'd. In the twenty +third Figure let AG, BH, CJ, DK, EL, FM be the Circles which so many +sorts of Rays flowing from the same disque of the Sun, do in the third +Experiment illuminate; of all which and innumerable other intermediate +ones lying in a continual Series between the two rectilinear and +parallel edges of the Sun's oblong Image PT, that Image is compos'd, as +was explained in the fifth Experiment. And let _ag_, _bh_, _ci_, _dk_, +_el_, _fm_ be so many less Circles lying in a like continual Series +between two parallel right Lines _af_ and _gm_ with the same distances +between their Centers, and illuminated by the same sorts of Rays, that +is the Circle _ag_ with the same sort by which the corresponding Circle +AG was illuminated, and the Circle _bh_ with the same sort by which the +corresponding Circle BH was illuminated, and the rest of the Circles +_ci_, _dk_, _el_, _fm_ respectively, with the same sorts of Rays by +which the several corresponding Circles CJ, DK, EL, FM were illuminated. +In the Figure PT composed of the greater Circles, three of those Circles +AG, BH, CJ, are so expanded into one another, that the three sorts of +Rays by which those Circles are illuminated, together with other +innumerable sorts of intermediate Rays, are mixed at QR in the middle +of the Circle BH. And the like Mixture happens throughout almost the +whole length of the Figure PT. But in the Figure _pt_ composed of the +less Circles, the three less Circles _ag_, _bh_, _ci_, which answer to +those three greater, do not extend into one another; nor are there any +where mingled so much as any two of the three sorts of Rays by which +those Circles are illuminated, and which in the Figure PT are all of +them intermingled at BH. + +Now he that shall thus consider it, will easily understand that the +Mixture is diminished in the same Proportion with the Diameters of the +Circles. If the Diameters of the Circles whilst their Centers remain the +same, be made three times less than before, the Mixture will be also +three times less; if ten times less, the Mixture will be ten times less, +and so of other Proportions. That is, the Mixture of the Rays in the +greater Figure PT will be to their Mixture in the less _pt_, as the +Latitude of the greater Figure is to the Latitude of the less. For the +Latitudes of these Figures are equal to the Diameters of their Circles. +And hence it easily follows, that the Mixture of the Rays in the +refracted Spectrum _pt_ is to the Mixture of the Rays in the direct and +immediate Light of the Sun, as the breadth of that Spectrum is to the +difference between the length and breadth of the same Spectrum. + +So then, if we would diminish the Mixture of the Rays, we are to +diminish the Diameters of the Circles. Now these would be diminished if +the Sun's Diameter to which they answer could be made less than it is, +or (which comes to the same Purpose) if without Doors, at a great +distance from the Prism towards the Sun, some opake Body were placed, +with a round hole in the middle of it, to intercept all the Sun's Light, +excepting so much as coming from the middle of his Body could pass +through that Hole to the Prism. For so the Circles AG, BH, and the rest, +would not any longer answer to the whole Disque of the Sun, but only to +that Part of it which could be seen from the Prism through that Hole, +that it is to the apparent Magnitude of that Hole view'd from the Prism. +But that these Circles may answer more distinctly to that Hole, a Lens +is to be placed by the Prism to cast the Image of the Hole, (that is, +every one of the Circles AG, BH, &c.) distinctly upon the Paper at PT, +after such a manner, as by a Lens placed at a Window, the Species of +Objects abroad are cast distinctly upon a Paper within the Room, and the +rectilinear Sides of the oblong Solar Image in the fifth Experiment +became distinct without any Penumbra. If this be done, it will not be +necessary to place that Hole very far off, no not beyond the Window. And +therefore instead of that Hole, I used the Hole in the Window-shut, as +follows. + +_Exper._ 11. In the Sun's Light let into my darken'd Chamber through a +small round Hole in my Window-shut, at about ten or twelve Feet from the +Window, I placed a Lens, by which the Image of the Hole might be +distinctly cast upon a Sheet of white Paper, placed at the distance of +six, eight, ten, or twelve Feet from the Lens. For, according to the +difference of the Lenses I used various distances, which I think not +worth the while to describe. Then immediately after the Lens I placed a +Prism, by which the trajected Light might be refracted either upwards or +sideways, and thereby the round Image, which the Lens alone did cast +upon the Paper might be drawn out into a long one with Parallel Sides, +as in the third Experiment. This oblong Image I let fall upon another +Paper at about the same distance from the Prism as before, moving the +Paper either towards the Prism or from it, until I found the just +distance where the Rectilinear Sides of the Image became most distinct. +For in this Case, the Circular Images of the Hole, which compose that +Image after the same manner that the Circles _ag_, _bh_, _ci_, &c. do +the Figure _pt_ [in _Fig._ 23.] were terminated most distinctly without +any Penumbra, and therefore extended into one another the least that +they could, and by consequence the Mixture of the heterogeneous Rays was +now the least of all. By this means I used to form an oblong Image (such +as is _pt_) [in _Fig._ 23, and 24.] of Circular Images of the Hole, +(such as are _ag_, _bh_, _ci_, &c.) and by using a greater or less Hole +in the Window-shut, I made the Circular Images _ag_, _bh_, _ci_, &c. of +which it was formed, to become greater or less at pleasure, and thereby +the Mixture of the Rays in the Image _pt_ to be as much, or as little as +I desired. + +[Illustration: FIG. 24.] + +_Illustration._ In the twenty-fourth Figure, F represents the Circular +Hole in the Window-shut, MN the Lens, whereby the Image or Species of +that Hole is cast distinctly upon a Paper at J, ABC the Prism, whereby +the Rays are at their emerging out of the Lens refracted from J towards +another Paper at _pt_, and the round Image at J is turned into an oblong +Image _pt_ falling on that other Paper. This Image _pt_ consists of +Circles placed one after another in a Rectilinear Order, as was +sufficiently explained in the fifth Experiment; and these Circles are +equal to the Circle J, and consequently answer in magnitude to the Hole +F; and therefore by diminishing that Hole they may be at pleasure +diminished, whilst their Centers remain in their Places. By this means I +made the Breadth of the Image _pt_ to be forty times, and sometimes +sixty or seventy times less than its Length. As for instance, if the +Breadth of the Hole F be one tenth of an Inch, and MF the distance of +the Lens from the Hole be 12 Feet; and if _p_B or _p_M the distance of +the Image _pt_ from the Prism or Lens be 10 Feet, and the refracting +Angle of the Prism be 62 Degrees, the Breadth of the Image _pt_ will be +one twelfth of an Inch, and the Length about six Inches, and therefore +the Length to the Breadth as 72 to 1, and by consequence the Light of +this Image 71 times less compound than the Sun's direct Light. And Light +thus far simple and homogeneal, is sufficient for trying all the +Experiments in this Book about simple Light. For the Composition of +heterogeneal Rays is in this Light so little, that it is scarce to be +discovered and perceiv'd by Sense, except perhaps in the indigo and +violet. For these being dark Colours do easily suffer a sensible Allay +by that little scattering Light which uses to be refracted irregularly +by the Inequalities of the Prism. + +Yet instead of the Circular Hole F, 'tis better to substitute an oblong +Hole shaped like a long Parallelogram with its Length parallel to the +Prism ABC. For if this Hole be an Inch or two long, and but a tenth or +twentieth Part of an Inch broad, or narrower; the Light of the Image +_pt_ will be as simple as before, or simpler, and the Image will become +much broader, and therefore more fit to have Experiments try'd in its +Light than before. + +Instead of this Parallelogram Hole may be substituted a triangular one +of equal Sides, whose Base, for instance, is about the tenth Part of an +Inch, and its Height an Inch or more. For by this means, if the Axis of +the Prism be parallel to the Perpendicular of the Triangle, the Image +_pt_ [in _Fig._ 25.] will now be form'd of equicrural Triangles _ag_, +_bh_, _ci_, _dk_, _el_, _fm_, &c. and innumerable other intermediate +ones answering to the triangular Hole in Shape and Bigness, and lying +one after another in a continual Series between two Parallel Lines _af_ +and _gm_. These Triangles are a little intermingled at their Bases, but +not at their Vertices; and therefore the Light on the brighter Side _af_ +of the Image, where the Bases of the Triangles are, is a little +compounded, but on the darker Side _gm_ is altogether uncompounded, and +in all Places between the Sides the Composition is proportional to the +distances of the Places from that obscurer Side _gm_. And having a +Spectrum _pt_ of such a Composition, we may try Experiments either in +its stronger and less simple Light near the Side _af_, or in its weaker +and simpler Light near the other Side _gm_, as it shall seem most +convenient. + +[Illustration: FIG. 25.] + +But in making Experiments of this kind, the Chamber ought to be made as +dark as can be, lest any Foreign Light mingle it self with the Light of +the Spectrum _pt_, and render it compound; especially if we would try +Experiments in the more simple Light next the Side _gm_ of the Spectrum; +which being fainter, will have a less proportion to the Foreign Light; +and so by the mixture of that Light be more troubled, and made more +compound. The Lens also ought to be good, such as may serve for optical +Uses, and the Prism ought to have a large Angle, suppose of 65 or 70 +Degrees, and to be well wrought, being made of Glass free from Bubbles +and Veins, with its Sides not a little convex or concave, as usually +happens, but truly plane, and its Polish elaborate, as in working +Optick-glasses, and not such as is usually wrought with Putty, whereby +the edges of the Sand-holes being worn away, there are left all over the +Glass a numberless Company of very little convex polite Risings like +Waves. The edges also of the Prism and Lens, so far as they may make any +irregular Refraction, must be covered with a black Paper glewed on. And +all the Light of the Sun's Beam let into the Chamber, which is useless +and unprofitable to the Experiment, ought to be intercepted with black +Paper, or other black Obstacles. For otherwise the useless Light being +reflected every way in the Chamber, will mix with the oblong Spectrum, +and help to disturb it. In trying these Things, so much diligence is not +altogether necessary, but it will promote the Success of the +Experiments, and by a very scrupulous Examiner of Things deserves to be +apply'd. It's difficult to get Glass Prisms fit for this Purpose, and +therefore I used sometimes prismatick Vessels made with pieces of broken +Looking-glasses, and filled with Rain Water. And to increase the +Refraction, I sometimes impregnated the Water strongly with _Saccharum +Saturni_. + + +_PROP._ V. THEOR. IV. + +_Homogeneal Light is refracted regularly without any Dilatation +splitting or shattering of the Rays, and the confused Vision of Objects +seen through refracting Bodies by heterogeneal Light arises from the +different Refrangibility of several sorts of Rays._ + +The first Part of this Proposition has been already sufficiently proved +in the fifth Experiment, and will farther appear by the Experiments +which follow. + +_Exper._ 12. In the middle of a black Paper I made a round Hole about a +fifth or sixth Part of an Inch in diameter. Upon this Paper I caused the +Spectrum of homogeneal Light described in the former Proposition, so to +fall, that some part of the Light might pass through the Hole of the +Paper. This transmitted part of the Light I refracted with a Prism +placed behind the Paper, and letting this refracted Light fall +perpendicularly upon a white Paper two or three Feet distant from the +Prism, I found that the Spectrum formed on the Paper by this Light was +not oblong, as when 'tis made (in the third Experiment) by refracting +the Sun's compound Light, but was (so far as I could judge by my Eye) +perfectly circular, the Length being no greater than the Breadth. Which +shews, that this Light is refracted regularly without any Dilatation of +the Rays. + +_Exper._ 13. In the homogeneal Light I placed a Paper Circle of a +quarter of an Inch in diameter, and in the Sun's unrefracted +heterogeneal white Light I placed another Paper Circle of the same +Bigness. And going from the Papers to the distance of some Feet, I +viewed both Circles through a Prism. The Circle illuminated by the Sun's +heterogeneal Light appeared very oblong, as in the fourth Experiment, +the Length being many times greater than the Breadth; but the other +Circle, illuminated with homogeneal Light, appeared circular and +distinctly defined, as when 'tis view'd with the naked Eye. Which proves +the whole Proposition. + +_Exper._ 14. In the homogeneal Light I placed Flies, and such-like +minute Objects, and viewing them through a Prism, I saw their Parts as +distinctly defined, as if I had viewed them with the naked Eye. The same +Objects placed in the Sun's unrefracted heterogeneal Light, which was +white, I viewed also through a Prism, and saw them most confusedly +defined, so that I could not distinguish their smaller Parts from one +another. I placed also the Letters of a small print, one while in the +homogeneal Light, and then in the heterogeneal, and viewing them through +a Prism, they appeared in the latter Case so confused and indistinct, +that I could not read them; but in the former they appeared so distinct, +that I could read readily, and thought I saw them as distinct, as when I +view'd them with my naked Eye. In both Cases I view'd the same Objects, +through the same Prism at the same distance from me, and in the same +Situation. There was no difference, but in the Light by which the +Objects were illuminated, and which in one Case was simple, and in the +other compound; and therefore, the distinct Vision in the former Case, +and confused in the latter, could arise from nothing else than from that +difference of the Lights. Which proves the whole Proposition. + +And in these three Experiments it is farther very remarkable, that the +Colour of homogeneal Light was never changed by the Refraction. + + +_PROP._ VI. THEOR. V. + +_The Sine of Incidence of every Ray considered apart, is to its Sine of +Refraction in a given Ratio._ + +That every Ray consider'd apart, is constant to it self in some degree +of Refrangibility, is sufficiently manifest out of what has been said. +Those Rays, which in the first Refraction, are at equal Incidences most +refracted, are also in the following Refractions at equal Incidences +most refracted; and so of the least refrangible, and the rest which have +any mean Degree of Refrangibility, as is manifest by the fifth, sixth, +seventh, eighth, and ninth Experiments. And those which the first Time +at like Incidences are equally refracted, are again at like Incidences +equally and uniformly refracted, and that whether they be refracted +before they be separated from one another, as in the fifth Experiment, +or whether they be refracted apart, as in the twelfth, thirteenth and +fourteenth Experiments. The Refraction therefore of every Ray apart is +regular, and what Rule that Refraction observes we are now to shew.[E] + +The late Writers in Opticks teach, that the Sines of Incidence are in a +given Proportion to the Sines of Refraction, as was explained in the +fifth Axiom, and some by Instruments fitted for measuring of +Refractions, or otherwise experimentally examining this Proportion, do +acquaint us that they have found it accurate. But whilst they, not +understanding the different Refrangibility of several Rays, conceived +them all to be refracted according to one and the same Proportion, 'tis +to be presumed that they adapted their Measures only to the middle of +the refracted Light; so that from their Measures we may conclude only +that the Rays which have a mean Degree of Refrangibility, that is, those +which when separated from the rest appear green, are refracted according +to a given Proportion of their Sines. And therefore we are now to shew, +that the like given Proportions obtain in all the rest. That it should +be so is very reasonable, Nature being ever conformable to her self; but +an experimental Proof is desired. And such a Proof will be had, if we +can shew that the Sines of Refraction of Rays differently refrangible +are one to another in a given Proportion when their Sines of Incidence +are equal. For, if the Sines of Refraction of all the Rays are in given +Proportions to the Sine of Refractions of a Ray which has a mean Degree +of Refrangibility, and this Sine is in a given Proportion to the equal +Sines of Incidence, those other Sines of Refraction will also be in +given Proportions to the equal Sines of Incidence. Now, when the Sines +of Incidence are equal, it will appear by the following Experiment, that +the Sines of Refraction are in a given Proportion to one another. + +[Illustration: FIG. 26.] + +_Exper._ 15. The Sun shining into a dark Chamber through a little round +Hole in the Window-shut, let S [in _Fig._ 26.] represent his round white +Image painted on the opposite Wall by his direct Light, PT his oblong +coloured Image made by refracting that Light with a Prism placed at the +Window; and _pt_, or _2p 2t_, _3p 3t_, his oblong colour'd Image made by +refracting again the same Light sideways with a second Prism placed +immediately after the first in a cross Position to it, as was explained +in the fifth Experiment; that is to say, _pt_ when the Refraction of the +second Prism is small, _2p 2t_ when its Refraction is greater, and _3p +3t_ when it is greatest. For such will be the diversity of the +Refractions, if the refracting Angle of the second Prism be of various +Magnitudes; suppose of fifteen or twenty Degrees to make the Image _pt_, +of thirty or forty to make the Image _2p 2t_, and of sixty to make the +Image _3p 3t_. But for want of solid Glass Prisms with Angles of +convenient Bignesses, there may be Vessels made of polished Plates of +Glass cemented together in the form of Prisms and filled with Water. +These things being thus ordered, I observed that all the solar Images or +coloured Spectrums PT, _pt_, _2p 2t_, _3p 3t_ did very nearly converge +to the place S on which the direct Light of the Sun fell and painted his +white round Image when the Prisms were taken away. The Axis of the +Spectrum PT, that is the Line drawn through the middle of it parallel to +its rectilinear Sides, did when produced pass exactly through the middle +of that white round Image S. And when the Refraction of the second Prism +was equal to the Refraction of the first, the refracting Angles of them +both being about 60 Degrees, the Axis of the Spectrum _3p 3t_ made by +that Refraction, did when produced pass also through the middle of the +same white round Image S. But when the Refraction of the second Prism +was less than that of the first, the produced Axes of the Spectrums _tp_ +or _2t 2p_ made by that Refraction did cut the produced Axis of the +Spectrum TP in the points _m_ and _n_, a little beyond the Center of +that white round Image S. Whence the proportion of the Line 3_t_T to the +Line 3_p_P was a little greater than the Proportion of 2_t_T or 2_p_P, +and this Proportion a little greater than that of _t_T to _p_P. Now when +the Light of the Spectrum PT falls perpendicularly upon the Wall, those +Lines 3_t_T, 3_p_P, and 2_t_T, and 2_p_P, and _t_T, _p_P, are the +Tangents of the Refractions, and therefore by this Experiment the +Proportions of the Tangents of the Refractions are obtained, from whence +the Proportions of the Sines being derived, they come out equal, so far +as by viewing the Spectrums, and using some mathematical Reasoning I +could estimate. For I did not make an accurate Computation. So then the +Proposition holds true in every Ray apart, so far as appears by +Experiment. And that it is accurately true, may be demonstrated upon +this Supposition. _That Bodies refract Light by acting upon its Rays in +Lines perpendicular to their Surfaces._ But in order to this +Demonstration, I must distinguish the Motion of every Ray into two +Motions, the one perpendicular to the refracting Surface, the other +parallel to it, and concerning the perpendicular Motion lay down the +following Proposition. + +If any Motion or moving thing whatsoever be incident with any Velocity +on any broad and thin space terminated on both sides by two parallel +Planes, and in its Passage through that space be urged perpendicularly +towards the farther Plane by any force which at given distances from the +Plane is of given Quantities; the perpendicular velocity of that Motion +or Thing, at its emerging out of that space, shall be always equal to +the square Root of the sum of the square of the perpendicular velocity +of that Motion or Thing at its Incidence on that space; and of the +square of the perpendicular velocity which that Motion or Thing would +have at its Emergence, if at its Incidence its perpendicular velocity +was infinitely little. + +And the same Proposition holds true of any Motion or Thing +perpendicularly retarded in its passage through that space, if instead +of the sum of the two Squares you take their difference. The +Demonstration Mathematicians will easily find out, and therefore I shall +not trouble the Reader with it. + +Suppose now that a Ray coming most obliquely in the Line MC [in _Fig._ +1.] be refracted at C by the Plane RS into the Line CN, and if it be +required to find the Line CE, into which any other Ray AC shall be +refracted; let MC, AD, be the Sines of Incidence of the two Rays, and +NG, EF, their Sines of Refraction, and let the equal Motions of the +incident Rays be represented by the equal Lines MC and AC, and the +Motion MC being considered as parallel to the refracting Plane, let the +other Motion AC be distinguished into two Motions AD and DC, one of +which AD is parallel, and the other DC perpendicular to the refracting +Surface. In like manner, let the Motions of the emerging Rays be +distinguish'd into two, whereof the perpendicular ones are MC/NG × CG +and AD/EF × CF. And if the force of the refracting Plane begins to act +upon the Rays either in that Plane or at a certain distance from it on +the one side, and ends at a certain distance from it on the other side, +and in all places between those two limits acts upon the Rays in Lines +perpendicular to that refracting Plane, and the Actions upon the Rays at +equal distances from the refracting Plane be equal, and at unequal ones +either equal or unequal according to any rate whatever; that Motion of +the Ray which is parallel to the refracting Plane, will suffer no +Alteration by that Force; and that Motion which is perpendicular to it +will be altered according to the rule of the foregoing Proposition. If +therefore for the perpendicular velocity of the emerging Ray CN you +write MC/NG × CG as above, then the perpendicular velocity of any other +emerging Ray CE which was AD/EF × CF, will be equal to the square Root +of CD_q_ + (_MCq/NGq_ × CG_q_). And by squaring these Equals, and adding +to them the Equals AD_q_ and MC_q_ - CD_q_, and dividing the Sums by the +Equals CF_q_ + EF_q_ and CG_q_ + NG_q_, you will have _MCq/NGq_ equal to +_ADq/EFq_. Whence AD, the Sine of Incidence, is to EF the Sine of +Refraction, as MC to NG, that is, in a given _ratio_. And this +Demonstration being general, without determining what Light is, or by +what kind of Force it is refracted, or assuming any thing farther than +that the refracting Body acts upon the Rays in Lines perpendicular to +its Surface; I take it to be a very convincing Argument of the full +truth of this Proposition. + +So then, if the _ratio_ of the Sines of Incidence and Refraction of any +sort of Rays be found in any one case, 'tis given in all cases; and this +may be readily found by the Method in the following Proposition. + + +_PROP._ VII. THEOR. VI. + +_The Perfection of Telescopes is impeded by the different Refrangibility +of the Rays of Light._ + +The Imperfection of Telescopes is vulgarly attributed to the spherical +Figures of the Glasses, and therefore Mathematicians have propounded to +figure them by the conical Sections. To shew that they are mistaken, I +have inserted this Proposition; the truth of which will appear by the +measure of the Refractions of the several sorts of Rays; and these +measures I thus determine. + +In the third Experiment of this first Part, where the refracting Angle +of the Prism was 62-1/2 Degrees, the half of that Angle 31 deg. 15 min. +is the Angle of Incidence of the Rays at their going out of the Glass +into the Air[F]; and the Sine of this Angle is 5188, the Radius being +10000. When the Axis of this Prism was parallel to the Horizon, and the +Refraction of the Rays at their Incidence on this Prism equal to that at +their Emergence out of it, I observed with a Quadrant the Angle which +the mean refrangible Rays, (that is those which went to the middle of +the Sun's coloured Image) made with the Horizon, and by this Angle and +the Sun's altitude observed at the same time, I found the Angle which +the emergent Rays contained with the incident to be 44 deg. and 40 min. +and the half of this Angle added to the Angle of Incidence 31 deg. 15 +min. makes the Angle of Refraction, which is therefore 53 deg. 35 min. +and its Sine 8047. These are the Sines of Incidence and Refraction of +the mean refrangible Rays, and their Proportion in round Numbers is 20 +to 31. This Glass was of a Colour inclining to green. The last of the +Prisms mentioned in the third Experiment was of clear white Glass. Its +refracting Angle 63-1/2 Degrees. The Angle which the emergent Rays +contained, with the incident 45 deg. 50 min. The Sine of half the first +Angle 5262. The Sine of half the Sum of the Angles 8157. And their +Proportion in round Numbers 20 to 31, as before. + +From the Length of the Image, which was about 9-3/4 or 10 Inches, +subduct its Breadth, which was 2-1/8 Inches, and the Remainder 7-3/4 +Inches would be the Length of the Image were the Sun but a Point, and +therefore subtends the Angle which the most and least refrangible Rays, +when incident on the Prism in the same Lines, do contain with one +another after their Emergence. Whence this Angle is 2 deg. 0´. 7´´. For +the distance between the Image and the Prism where this Angle is made, +was 18-1/2 Feet, and at that distance the Chord 7-3/4 Inches subtends an +Angle of 2 deg. 0´. 7´´. Now half this Angle is the Angle which these +emergent Rays contain with the emergent mean refrangible Rays, and a +quarter thereof, that is 30´. 2´´. may be accounted the Angle which they +would contain with the same emergent mean refrangible Rays, were they +co-incident to them within the Glass, and suffered no other Refraction +than that at their Emergence. For, if two equal Refractions, the one at +the Incidence of the Rays on the Prism, the other at their Emergence, +make half the Angle 2 deg. 0´. 7´´. then one of those Refractions will +make about a quarter of that Angle, and this quarter added to, and +subducted from the Angle of Refraction of the mean refrangible Rays, +which was 53 deg. 35´, gives the Angles of Refraction of the most and +least refrangible Rays 54 deg. 5´ 2´´, and 53 deg. 4´ 58´´, whose Sines +are 8099 and 7995, the common Angle of Incidence being 31 deg. 15´, and +its Sine 5188; and these Sines in the least round Numbers are in +proportion to one another, as 78 and 77 to 50. + +Now, if you subduct the common Sine of Incidence 50 from the Sines of +Refraction 77 and 78, the Remainders 27 and 28 shew, that in small +Refractions the Refraction of the least refrangible Rays is to the +Refraction of the most refrangible ones, as 27 to 28 very nearly, and +that the difference of the Refractions of the least refrangible and most +refrangible Rays is about the 27-1/2th Part of the whole Refraction of +the mean refrangible Rays. + +Whence they that are skilled in Opticks will easily understand,[G] that +the Breadth of the least circular Space, into which Object-glasses of +Telescopes can collect all sorts of Parallel Rays, is about the 27-1/2th +Part of half the Aperture of the Glass, or 55th Part of the whole +Aperture; and that the Focus of the most refrangible Rays is nearer to +the Object-glass than the Focus of the least refrangible ones, by about +the 27-1/2th Part of the distance between the Object-glass and the Focus +of the mean refrangible ones. + +And if Rays of all sorts, flowing from any one lucid Point in the Axis +of any convex Lens, be made by the Refraction of the Lens to converge to +Points not too remote from the Lens, the Focus of the most refrangible +Rays shall be nearer to the Lens than the Focus of the least refrangible +ones, by a distance which is to the 27-1/2th Part of the distance of the +Focus of the mean refrangible Rays from the Lens, as the distance +between that Focus and the lucid Point, from whence the Rays flow, is to +the distance between that lucid Point and the Lens very nearly. + +Now to examine whether the Difference between the Refractions, which the +most refrangible and the least refrangible Rays flowing from the same +Point suffer in the Object-glasses of Telescopes and such-like Glasses, +be so great as is here described, I contrived the following Experiment. + +_Exper._ 16. The Lens which I used in the second and eighth Experiments, +being placed six Feet and an Inch distant from any Object, collected the +Species of that Object by the mean refrangible Rays at the distance of +six Feet and an Inch from the Lens on the other side. And therefore by +the foregoing Rule, it ought to collect the Species of that Object by +the least refrangible Rays at the distance of six Feet and 3-2/3 Inches +from the Lens, and by the most refrangible ones at the distance of five +Feet and 10-1/3 Inches from it: So that between the two Places, where +these least and most refrangible Rays collect the Species, there may be +the distance of about 5-1/3 Inches. For by that Rule, as six Feet and an +Inch (the distance of the Lens from the lucid Object) is to twelve Feet +and two Inches (the distance of the lucid Object from the Focus of the +mean refrangible Rays) that is, as One is to Two; so is the 27-1/2th +Part of six Feet and an Inch (the distance between the Lens and the same +Focus) to the distance between the Focus of the most refrangible Rays +and the Focus of the least refrangible ones, which is therefore 5-17/55 +Inches, that is very nearly 5-1/3 Inches. Now to know whether this +Measure was true, I repeated the second and eighth Experiment with +coloured Light, which was less compounded than that I there made use of: +For I now separated the heterogeneous Rays from one another by the +Method I described in the eleventh Experiment, so as to make a coloured +Spectrum about twelve or fifteen Times longer than broad. This Spectrum +I cast on a printed Book, and placing the above-mentioned Lens at the +distance of six Feet and an Inch from this Spectrum to collect the +Species of the illuminated Letters at the same distance on the other +side, I found that the Species of the Letters illuminated with blue were +nearer to the Lens than those illuminated with deep red by about three +Inches, or three and a quarter; but the Species of the Letters +illuminated with indigo and violet appeared so confused and indistinct, +that I could not read them: Whereupon viewing the Prism, I found it was +full of Veins running from one end of the Glass to the other; so that +the Refraction could not be regular. I took another Prism therefore +which was free from Veins, and instead of the Letters I used two or +three Parallel black Lines a little broader than the Strokes of the +Letters, and casting the Colours upon these Lines in such manner, that +the Lines ran along the Colours from one end of the Spectrum to the +other, I found that the Focus where the indigo, or confine of this +Colour and violet cast the Species of the black Lines most distinctly, +to be about four Inches, or 4-1/4 nearer to the Lens than the Focus, +where the deepest red cast the Species of the same black Lines most +distinctly. The violet was so faint and dark, that I could not discern +the Species of the Lines distinctly by that Colour; and therefore +considering that the Prism was made of a dark coloured Glass inclining +to green, I took another Prism of clear white Glass; but the Spectrum of +Colours which this Prism made had long white Streams of faint Light +shooting out from both ends of the Colours, which made me conclude that +something was amiss; and viewing the Prism, I found two or three little +Bubbles in the Glass, which refracted the Light irregularly. Wherefore I +covered that Part of the Glass with black Paper, and letting the Light +pass through another Part of it which was free from such Bubbles, the +Spectrum of Colours became free from those irregular Streams of Light, +and was now such as I desired. But still I found the violet so dark and +faint, that I could scarce see the Species of the Lines by the violet, +and not at all by the deepest Part of it, which was next the end of the +Spectrum. I suspected therefore, that this faint and dark Colour might +be allayed by that scattering Light which was refracted, and reflected +irregularly, partly by some very small Bubbles in the Glasses, and +partly by the Inequalities of their Polish; which Light, tho' it was but +little, yet it being of a white Colour, might suffice to affect the +Sense so strongly as to disturb the Phænomena of that weak and dark +Colour the violet, and therefore I tried, as in the 12th, 13th, and 14th +Experiments, whether the Light of this Colour did not consist of a +sensible Mixture of heterogeneous Rays, but found it did not. Nor did +the Refractions cause any other sensible Colour than violet to emerge +out of this Light, as they would have done out of white Light, and by +consequence out of this violet Light had it been sensibly compounded +with white Light. And therefore I concluded, that the reason why I could +not see the Species of the Lines distinctly by this Colour, was only +the Darkness of this Colour, and Thinness of its Light, and its distance +from the Axis of the Lens; I divided therefore those Parallel black +Lines into equal Parts, by which I might readily know the distances of +the Colours in the Spectrum from one another, and noted the distances of +the Lens from the Foci of such Colours, as cast the Species of the Lines +distinctly, and then considered whether the difference of those +distances bear such proportion to 5-1/3 Inches, the greatest Difference +of the distances, which the Foci of the deepest red and violet ought to +have from the Lens, as the distance of the observed Colours from one +another in the Spectrum bear to the greatest distance of the deepest red +and violet measured in the Rectilinear Sides of the Spectrum, that is, +to the Length of those Sides, or Excess of the Length of the Spectrum +above its Breadth. And my Observations were as follows. + +When I observed and compared the deepest sensible red, and the Colour in +the Confine of green and blue, which at the Rectilinear Sides of the +Spectrum was distant from it half the Length of those Sides, the Focus +where the Confine of green and blue cast the Species of the Lines +distinctly on the Paper, was nearer to the Lens than the Focus, where +the red cast those Lines distinctly on it by about 2-1/2 or 2-3/4 +Inches. For sometimes the Measures were a little greater, sometimes a +little less, but seldom varied from one another above 1/3 of an Inch. +For it was very difficult to define the Places of the Foci, without some +little Errors. Now, if the Colours distant half the Length of the +Image, (measured at its Rectilinear Sides) give 2-1/2 or 2-3/4 +Difference of the distances of their Foci from the Lens, then the +Colours distant the whole Length ought to give 5 or 5-1/2 Inches +difference of those distances. + +But here it's to be noted, that I could not see the red to the full end +of the Spectrum, but only to the Center of the Semicircle which bounded +that end, or a little farther; and therefore I compared this red not +with that Colour which was exactly in the middle of the Spectrum, or +Confine of green and blue, but with that which verged a little more to +the blue than to the green: And as I reckoned the whole Length of the +Colours not to be the whole Length of the Spectrum, but the Length of +its Rectilinear Sides, so compleating the semicircular Ends into +Circles, when either of the observed Colours fell within those Circles, +I measured the distance of that Colour from the semicircular End of the +Spectrum, and subducting half this distance from the measured distance +of the two Colours, I took the Remainder for their corrected distance; +and in these Observations set down this corrected distance for the +difference of the distances of their Foci from the Lens. For, as the +Length of the Rectilinear Sides of the Spectrum would be the whole +Length of all the Colours, were the Circles of which (as we shewed) that +Spectrum consists contracted and reduced to Physical Points, so in that +Case this corrected distance would be the real distance of the two +observed Colours. + +When therefore I farther observed the deepest sensible red, and that +blue whose corrected distance from it was 7/12 Parts of the Length of +the Rectilinear Sides of the Spectrum, the difference of the distances +of their Foci from the Lens was about 3-1/4 Inches, and as 7 to 12, so +is 3-1/4 to 5-4/7. + +When I observed the deepest sensible red, and that indigo whose +corrected distance was 8/12 or 2/3 of the Length of the Rectilinear +Sides of the Spectrum, the difference of the distances of their Foci +from the Lens, was about 3-2/3 Inches, and as 2 to 3, so is 3-2/3 to +5-1/2. + +When I observed the deepest sensible red, and that deep indigo whose +corrected distance from one another was 9/12 or 3/4 of the Length of the +Rectilinear Sides of the Spectrum, the difference of the distances of +their Foci from the Lens was about 4 Inches; and as 3 to 4, so is 4 to +5-1/3. + +When I observed the deepest sensible red, and that Part of the violet +next the indigo, whose corrected distance from the red was 10/12 or 5/6 +of the Length of the Rectilinear Sides of the Spectrum, the difference +of the distances of their Foci from the Lens was about 4-1/2 Inches, and +as 5 to 6, so is 4-1/2 to 5-2/5. For sometimes, when the Lens was +advantageously placed, so that its Axis respected the blue, and all +Things else were well ordered, and the Sun shone clear, and I held my +Eye very near to the Paper on which the Lens cast the Species of the +Lines, I could see pretty distinctly the Species of those Lines by that +Part of the violet which was next the indigo; and sometimes I could see +them by above half the violet, For in making these Experiments I had +observed, that the Species of those Colours only appear distinct, which +were in or near the Axis of the Lens: So that if the blue or indigo were +in the Axis, I could see their Species distinctly; and then the red +appeared much less distinct than before. Wherefore I contrived to make +the Spectrum of Colours shorter than before, so that both its Ends might +be nearer to the Axis of the Lens. And now its Length was about 2-1/2 +Inches, and Breadth about 1/5 or 1/6 of an Inch. Also instead of the +black Lines on which the Spectrum was cast, I made one black Line +broader than those, that I might see its Species more easily; and this +Line I divided by short cross Lines into equal Parts, for measuring the +distances of the observed Colours. And now I could sometimes see the +Species of this Line with its Divisions almost as far as the Center of +the semicircular violet End of the Spectrum, and made these farther +Observations. + +When I observed the deepest sensible red, and that Part of the violet, +whose corrected distance from it was about 8/9 Parts of the Rectilinear +Sides of the Spectrum, the Difference of the distances of the Foci of +those Colours from the Lens, was one time 4-2/3, another time 4-3/4, +another time 4-7/8 Inches; and as 8 to 9, so are 4-2/3, 4-3/4, 4-7/8, to +5-1/4, 5-11/32, 5-31/64 respectively. + +When I observed the deepest sensible red, and deepest sensible violet, +(the corrected distance of which Colours, when all Things were ordered +to the best Advantage, and the Sun shone very clear, was about 11/12 or +15/16 Parts of the Length of the Rectilinear Sides of the coloured +Spectrum) I found the Difference of the distances of their Foci from the +Lens sometimes 4-3/4 sometimes 5-1/4, and for the most part 5 Inches or +thereabouts; and as 11 to 12, or 15 to 16, so is five Inches to 5-2/2 or +5-1/3 Inches. + +And by this Progression of Experiments I satisfied my self, that had the +Light at the very Ends of the Spectrum been strong enough to make the +Species of the black Lines appear plainly on the Paper, the Focus of the +deepest violet would have been found nearer to the Lens, than the Focus +of the deepest red, by about 5-1/3 Inches at least. And this is a +farther Evidence, that the Sines of Incidence and Refraction of the +several sorts of Rays, hold the same Proportion to one another in the +smallest Refractions which they do in the greatest. + +My Progress in making this nice and troublesome Experiment I have set +down more at large, that they that shall try it after me may be aware of +the Circumspection requisite to make it succeed well. And if they cannot +make it succeed so well as I did, they may notwithstanding collect by +the Proportion of the distance of the Colours of the Spectrum, to the +Difference of the distances of their Foci from the Lens, what would be +the Success in the more distant Colours by a better trial. And yet, if +they use a broader Lens than I did, and fix it to a long strait Staff, +by means of which it may be readily and truly directed to the Colour +whose Focus is desired, I question not but the Experiment will succeed +better with them than it did with me. For I directed the Axis as nearly +as I could to the middle of the Colours, and then the faint Ends of the +Spectrum being remote from the Axis, cast their Species less distinctly +on the Paper than they would have done, had the Axis been successively +directed to them. + +Now by what has been said, it's certain that the Rays which differ in +Refrangibility do not converge to the same Focus; but if they flow from +a lucid Point, as far from the Lens on one side as their Foci are on the +other, the Focus of the most refrangible Rays shall be nearer to the +Lens than that of the least refrangible, by above the fourteenth Part of +the whole distance; and if they flow from a lucid Point, so very remote +from the Lens, that before their Incidence they may be accounted +parallel, the Focus of the most refrangible Rays shall be nearer to the +Lens than the Focus of the least refrangible, by about the 27th or 28th +Part of their whole distance from it. And the Diameter of the Circle in +the middle Space between those two Foci which they illuminate, when they +fall there on any Plane, perpendicular to the Axis (which Circle is the +least into which they can all be gathered) is about the 55th Part of the +Diameter of the Aperture of the Glass. So that 'tis a wonder, that +Telescopes represent Objects so distinct as they do. But were all the +Rays of Light equally refrangible, the Error arising only from the +Sphericalness of the Figures of Glasses would be many hundred times +less. For, if the Object-glass of a Telescope be Plano-convex, and the +Plane side be turned towards the Object, and the Diameter of the +Sphere, whereof this Glass is a Segment, be called D, and the +Semi-diameter of the Aperture of the Glass be called S, and the Sine of +Incidence out of Glass into Air, be to the Sine of Refraction as I to R; +the Rays which come parallel to the Axis of the Glass, shall in the +Place where the Image of the Object is most distinctly made, be +scattered all over a little Circle, whose Diameter is _(Rq/Iq) × (S +cub./D quad.)_ very nearly,[H] as I gather by computing the Errors of +the Rays by the Method of infinite Series, and rejecting the Terms, +whose Quantities are inconsiderable. As for instance, if the Sine of +Incidence I, be to the Sine of Refraction R, as 20 to 31, and if D the +Diameter of the Sphere, to which the Convex-side of the Glass is ground, +be 100 Feet or 1200 Inches, and S the Semi-diameter of the Aperture be +two Inches, the Diameter of the little Circle, (that is (_Rq × S +cub.)/(Iq × D quad._)) will be (31 × 31 × 8)/(20 × 20 × 1200 × 1200) (or +961/72000000) Parts of an Inch. But the Diameter of the little Circle, +through which these Rays are scattered by unequal Refrangibility, will +be about the 55th Part of the Aperture of the Object-glass, which here +is four Inches. And therefore, the Error arising from the Spherical +Figure of the Glass, is to the Error arising from the different +Refrangibility of the Rays, as 961/72000000 to 4/55, that is as 1 to +5449; and therefore being in comparison so very little, deserves not to +be considered. + +[Illustration: FIG. 27.] + +But you will say, if the Errors caused by the different Refrangibility +be so very great, how comes it to pass, that Objects appear through +Telescopes so distinct as they do? I answer, 'tis because the erring +Rays are not scattered uniformly over all that Circular Space, but +collected infinitely more densely in the Center than in any other Part +of the Circle, and in the Way from the Center to the Circumference, grow +continually rarer and rarer, so as at the Circumference to become +infinitely rare; and by reason of their Rarity are not strong enough to +be visible, unless in the Center and very near it. Let ADE [in _Fig._ +27.] represent one of those Circles described with the Center C, and +Semi-diameter AC, and let BFG be a smaller Circle concentrick to the +former, cutting with its Circumference the Diameter AC in B, and bisect +AC in N; and by my reckoning, the Density of the Light in any Place B, +will be to its Density in N, as AB to BC; and the whole Light within the +lesser Circle BFG, will be to the whole Light within the greater AED, as +the Excess of the Square of AC above the Square of AB, is to the Square +of AC. As if BC be the fifth Part of AC, the Light will be four times +denser in B than in N, and the whole Light within the less Circle, will +be to the whole Light within the greater, as nine to twenty-five. Whence +it's evident, that the Light within the less Circle, must strike the +Sense much more strongly, than that faint and dilated Light round about +between it and the Circumference of the greater. + +But it's farther to be noted, that the most luminous of the Prismatick +Colours are the yellow and orange. These affect the Senses more strongly +than all the rest together, and next to these in strength are the red +and green. The blue compared with these is a faint and dark Colour, and +the indigo and violet are much darker and fainter, so that these +compared with the stronger Colours are little to be regarded. The Images +of Objects are therefore to be placed, not in the Focus of the mean +refrangible Rays, which are in the Confine of green and blue, but in the +Focus of those Rays which are in the middle of the orange and yellow; +there where the Colour is most luminous and fulgent, that is in the +brightest yellow, that yellow which inclines more to orange than to +green. And by the Refraction of these Rays (whose Sines of Incidence and +Refraction in Glass are as 17 and 11) the Refraction of Glass and +Crystal for Optical Uses is to be measured. Let us therefore place the +Image of the Object in the Focus of these Rays, and all the yellow and +orange will fall within a Circle, whose Diameter is about the 250th +Part of the Diameter of the Aperture of the Glass. And if you add the +brighter half of the red, (that half which is next the orange) and the +brighter half of the green, (that half which is next the yellow) about +three fifth Parts of the Light of these two Colours will fall within the +same Circle, and two fifth Parts will fall without it round about; and +that which falls without will be spread through almost as much more +space as that which falls within, and so in the gross be almost three +times rarer. Of the other half of the red and green, (that is of the +deep dark red and willow green) about one quarter will fall within this +Circle, and three quarters without, and that which falls without will be +spread through about four or five times more space than that which falls +within; and so in the gross be rarer, and if compared with the whole +Light within it, will be about 25 times rarer than all that taken in the +gross; or rather more than 30 or 40 times rarer, because the deep red in +the end of the Spectrum of Colours made by a Prism is very thin and +rare, and the willow green is something rarer than the orange and +yellow. The Light of these Colours therefore being so very much rarer +than that within the Circle, will scarce affect the Sense, especially +since the deep red and willow green of this Light, are much darker +Colours than the rest. And for the same reason the blue and violet being +much darker Colours than these, and much more rarified, may be +neglected. For the dense and bright Light of the Circle, will obscure +the rare and weak Light of these dark Colours round about it, and +render them almost insensible. The sensible Image of a lucid Point is +therefore scarce broader than a Circle, whose Diameter is the 250th Part +of the Diameter of the Aperture of the Object-glass of a good Telescope, +or not much broader, if you except a faint and dark misty Light round +about it, which a Spectator will scarce regard. And therefore in a +Telescope, whose Aperture is four Inches, and Length an hundred Feet, it +exceeds not 2´´ 45´´´, or 3´´. And in a Telescope whose Aperture is two +Inches, and Length 20 or 30 Feet, it may be 5´´ or 6´´, and scarce +above. And this answers well to Experience: For some Astronomers have +found the Diameters of the fix'd Stars, in Telescopes of between 20 and +60 Feet in length, to be about 5´´ or 6´´, or at most 8´´ or 10´´ in +diameter. But if the Eye-Glass be tincted faintly with the Smoak of a +Lamp or Torch, to obscure the Light of the Star, the fainter Light in +the Circumference of the Star ceases to be visible, and the Star (if the +Glass be sufficiently soiled with Smoak) appears something more like a +mathematical Point. And for the same Reason, the enormous Part of the +Light in the Circumference of every lucid Point ought to be less +discernible in shorter Telescopes than in longer, because the shorter +transmit less Light to the Eye. + +Now, that the fix'd Stars, by reason of their immense Distance, appear +like Points, unless so far as their Light is dilated by Refraction, may +appear from hence; that when the Moon passes over them and eclipses +them, their Light vanishes, not gradually like that of the Planets, but +all at once; and in the end of the Eclipse it returns into Sight all at +once, or certainly in less time than the second of a Minute; the +Refraction of the Moon's Atmosphere a little protracting the time in +which the Light of the Star first vanishes, and afterwards returns into +Sight. + +Now, if we suppose the sensible Image of a lucid Point, to be even 250 +times narrower than the Aperture of the Glass; yet this Image would be +still much greater than if it were only from the spherical Figure of the +Glass. For were it not for the different Refrangibility of the Rays, its +breadth in an 100 Foot Telescope whose aperture is 4 Inches, would be +but 961/72000000 parts of an Inch, as is manifest by the foregoing +Computation. And therefore in this case the greatest Errors arising from +the spherical Figure of the Glass, would be to the greatest sensible +Errors arising from the different Refrangibility of the Rays as +961/72000000 to 4/250 at most, that is only as 1 to 1200. And this +sufficiently shews that it is not the spherical Figures of Glasses, but +the different Refrangibility of the Rays which hinders the perfection of +Telescopes. + +There is another Argument by which it may appear that the different +Refrangibility of Rays, is the true cause of the imperfection of +Telescopes. For the Errors of the Rays arising from the spherical +Figures of Object-glasses, are as the Cubes of the Apertures of the +Object Glasses; and thence to make Telescopes of various Lengths magnify +with equal distinctness, the Apertures of the Object-glasses, and the +Charges or magnifying Powers ought to be as the Cubes of the square +Roots of their lengths; which doth not answer to Experience. But the +Errors of the Rays arising from the different Refrangibility, are as the +Apertures of the Object-glasses; and thence to make Telescopes of +various lengths, magnify with equal distinctness, their Apertures and +Charges ought to be as the square Roots of their lengths; and this +answers to Experience, as is well known. For Instance, a Telescope of 64 +Feet in length, with an Aperture of 2-2/3 Inches, magnifies about 120 +times, with as much distinctness as one of a Foot in length, with 1/3 of +an Inch aperture, magnifies 15 times. + +[Illustration: FIG. 28.] + +Now were it not for this different Refrangibility of Rays, Telescopes +might be brought to a greater perfection than we have yet describ'd, by +composing the Object-glass of two Glasses with Water between them. Let +ADFC [in _Fig._ 28.] represent the Object-glass composed of two Glasses +ABED and BEFC, alike convex on the outsides AGD and CHF, and alike +concave on the insides BME, BNE, with Water in the concavity BMEN. Let +the Sine of Incidence out of Glass into Air be as I to R, and out of +Water into Air, as K to R, and by consequence out of Glass into Water, +as I to K: and let the Diameter of the Sphere to which the convex sides +AGD and CHF are ground be D, and the Diameter of the Sphere to which the +concave sides BME and BNE, are ground be to D, as the Cube Root of +KK--KI to the Cube Root of RK--RI: and the Refractions on the concave +sides of the Glasses, will very much correct the Errors of the +Refractions on the convex sides, so far as they arise from the +sphericalness of the Figure. And by this means might Telescopes be +brought to sufficient perfection, were it not for the different +Refrangibility of several sorts of Rays. But by reason of this different +Refrangibility, I do not yet see any other means of improving Telescopes +by Refractions alone, than that of increasing their lengths, for which +end the late Contrivance of _Hugenius_ seems well accommodated. For very +long Tubes are cumbersome, and scarce to be readily managed, and by +reason of their length are very apt to bend, and shake by bending, so as +to cause a continual trembling in the Objects, whereby it becomes +difficult to see them distinctly: whereas by his Contrivance the Glasses +are readily manageable, and the Object-glass being fix'd upon a strong +upright Pole becomes more steady. + +Seeing therefore the Improvement of Telescopes of given lengths by +Refractions is desperate; I contrived heretofore a Perspective by +Reflexion, using instead of an Object-glass a concave Metal. The +diameter of the Sphere to which the Metal was ground concave was about +25 _English_ Inches, and by consequence the length of the Instrument +about six Inches and a quarter. The Eye-glass was Plano-convex, and the +diameter of the Sphere to which the convex side was ground was about 1/5 +of an Inch, or a little less, and by consequence it magnified between 30 +and 40 times. By another way of measuring I found that it magnified +about 35 times. The concave Metal bore an Aperture of an Inch and a +third part; but the Aperture was limited not by an opake Circle, +covering the Limb of the Metal round about, but by an opake Circle +placed between the Eyeglass and the Eye, and perforated in the middle +with a little round hole for the Rays to pass through to the Eye. For +this Circle by being placed here, stopp'd much of the erroneous Light, +which otherwise would have disturbed the Vision. By comparing it with a +pretty good Perspective of four Feet in length, made with a concave +Eye-glass, I could read at a greater distance with my own Instrument +than with the Glass. Yet Objects appeared much darker in it than in the +Glass, and that partly because more Light was lost by Reflexion in the +Metal, than by Refraction in the Glass, and partly because my Instrument +was overcharged. Had it magnified but 30 or 25 times, it would have made +the Object appear more brisk and pleasant. Two of these I made about 16 +Years ago, and have one of them still by me, by which I can prove the +truth of what I write. Yet it is not so good as at the first. For the +concave has been divers times tarnished and cleared again, by rubbing +it with very soft Leather. When I made these an Artist in _London_ +undertook to imitate it; but using another way of polishing them than I +did, he fell much short of what I had attained to, as I afterwards +understood by discoursing the Under-workman he had employed. The Polish +I used was in this manner. I had two round Copper Plates, each six +Inches in Diameter, the one convex, the other concave, ground very true +to one another. On the convex I ground the Object-Metal or Concave which +was to be polish'd, 'till it had taken the Figure of the Convex and was +ready for a Polish. Then I pitched over the convex very thinly, by +dropping melted Pitch upon it, and warming it to keep the Pitch soft, +whilst I ground it with the concave Copper wetted to make it spread +eavenly all over the convex. Thus by working it well I made it as thin +as a Groat, and after the convex was cold I ground it again to give it +as true a Figure as I could. Then I took Putty which I had made very +fine by washing it from all its grosser Particles, and laying a little +of this upon the Pitch, I ground it upon the Pitch with the concave +Copper, till it had done making a Noise; and then upon the Pitch I +ground the Object-Metal with a brisk motion, for about two or three +Minutes of time, leaning hard upon it. Then I put fresh Putty upon the +Pitch, and ground it again till it had done making a noise, and +afterwards ground the Object-Metal upon it as before. And this Work I +repeated till the Metal was polished, grinding it the last time with all +my strength for a good while together, and frequently breathing upon +the Pitch, to keep it moist without laying on any more fresh Putty. The +Object-Metal was two Inches broad, and about one third part of an Inch +thick, to keep it from bending. I had two of these Metals, and when I +had polished them both, I tried which was best, and ground the other +again, to see if I could make it better than that which I kept. And thus +by many Trials I learn'd the way of polishing, till I made those two +reflecting Perspectives I spake of above. For this Art of polishing will +be better learn'd by repeated Practice than by my Description. Before I +ground the Object-Metal on the Pitch, I always ground the Putty on it +with the concave Copper, till it had done making a noise, because if the +Particles of the Putty were not by this means made to stick fast in the +Pitch, they would by rolling up and down grate and fret the Object-Metal +and fill it full of little holes. + +But because Metal is more difficult to polish than Glass, and is +afterwards very apt to be spoiled by tarnishing, and reflects not so +much Light as Glass quick-silver'd over does: I would propound to use +instead of the Metal, a Glass ground concave on the foreside, and as +much convex on the backside, and quick-silver'd over on the convex side. +The Glass must be every where of the same thickness exactly. Otherwise +it will make Objects look colour'd and indistinct. By such a Glass I +tried about five or six Years ago to make a reflecting Telescope of four +Feet in length to magnify about 150 times, and I satisfied my self that +there wants nothing but a good Artist to bring the Design to +perfection. For the Glass being wrought by one of our _London_ Artists +after such a manner as they grind Glasses for Telescopes, though it +seemed as well wrought as the Object-glasses use to be, yet when it was +quick-silver'd, the Reflexion discovered innumerable Inequalities all +over the Glass. And by reason of these Inequalities, Objects appeared +indistinct in this Instrument. For the Errors of reflected Rays caused +by any Inequality of the Glass, are about six times greater than the +Errors of refracted Rays caused by the like Inequalities. Yet by this +Experiment I satisfied my self that the Reflexion on the concave side of +the Glass, which I feared would disturb the Vision, did no sensible +prejudice to it, and by consequence that nothing is wanting to perfect +these Telescopes, but good Workmen who can grind and polish Glasses +truly spherical. An Object-glass of a fourteen Foot Telescope, made by +an Artificer at _London_, I once mended considerably, by grinding it on +Pitch with Putty, and leaning very easily on it in the grinding, lest +the Putty should scratch it. Whether this way may not do well enough for +polishing these reflecting Glasses, I have not yet tried. But he that +shall try either this or any other way of polishing which he may think +better, may do well to make his Glasses ready for polishing, by grinding +them without that Violence, wherewith our _London_ Workmen press their +Glasses in grinding. For by such violent pressure, Glasses are apt to +bend a little in the grinding, and such bending will certainly spoil +their Figure. To recommend therefore the consideration of these +reflecting Glasses to such Artists as are curious in figuring Glasses, I +shall describe this optical Instrument in the following Proposition. + + +_PROP._ VIII. PROB. II. + +_To shorten Telescopes._ + +Let ABCD [in _Fig._ 29.] represent a Glass spherically concave on the +foreside AB, and as much convex on the backside CD, so that it be every +where of an equal thickness. Let it not be thicker on one side than on +the other, lest it make Objects appear colour'd and indistinct, and let +it be very truly wrought and quick-silver'd over on the backside; and +set in the Tube VXYZ which must be very black within. Let EFG represent +a Prism of Glass or Crystal placed near the other end of the Tube, in +the middle of it, by means of a handle of Brass or Iron FGK, to the end +of which made flat it is cemented. Let this Prism be rectangular at E, +and let the other two Angles at F and G be accurately equal to each +other, and by consequence equal to half right ones, and let the plane +sides FE and GE be square, and by consequence the third side FG a +rectangular Parallelogram, whose length is to its breadth in a +subduplicate proportion of two to one. Let it be so placed in the Tube, +that the Axis of the Speculum may pass through the middle of the square +side EF perpendicularly and by consequence through the middle of the +side FG at an Angle of 45 Degrees, and let the side EF be turned towards +the Speculum, and the distance of this Prism from the Speculum be such +that the Rays of the Light PQ, RS, &c. which are incident upon the +Speculum in Lines parallel to the Axis thereof, may enter the Prism at +the side EF, and be reflected by the side FG, and thence go out of it +through the side GE, to the Point T, which must be the common Focus of +the Speculum ABDC, and of a Plano-convex Eye-glass H, through which +those Rays must pass to the Eye. And let the Rays at their coming out of +the Glass pass through a small round hole, or aperture made in a little +plate of Lead, Brass, or Silver, wherewith the Glass is to be covered, +which hole must be no bigger than is necessary for Light enough to pass +through. For so it will render the Object distinct, the Plate in which +'tis made intercepting all the erroneous part of the Light which comes +from the verges of the Speculum AB. Such an Instrument well made, if it +be six Foot long, (reckoning the length from the Speculum to the Prism, +and thence to the Focus T) will bear an aperture of six Inches at the +Speculum, and magnify between two and three hundred times. But the hole +H here limits the aperture with more advantage, than if the aperture was +placed at the Speculum. If the Instrument be made longer or shorter, the +aperture must be in proportion as the Cube of the square-square Root of +the length, and the magnifying as the aperture. But it's convenient that +the Speculum be an Inch or two broader than the aperture at the least, +and that the Glass of the Speculum be thick, that it bend not in the +working. The Prism EFG must be no bigger than is necessary, and its back +side FG must not be quick-silver'd over. For without quicksilver it will +reflect all the Light incident on it from the Speculum. + +[Illustration: FIG. 29.] + +In this Instrument the Object will be inverted, but may be erected by +making the square sides FF and EG of the Prism EFG not plane but +spherically convex, that the Rays may cross as well before they come at +it as afterwards between it and the Eye-glass. If it be desired that the +Instrument bear a larger aperture, that may be also done by composing +the Speculum of two Glasses with Water between them. + +If the Theory of making Telescopes could at length be fully brought into +Practice, yet there would be certain Bounds beyond which Telescopes +could not perform. For the Air through which we look upon the Stars, is +in a perpetual Tremor; as may be seen by the tremulous Motion of Shadows +cast from high Towers, and by the twinkling of the fix'd Stars. But +these Stars do not twinkle when viewed through Telescopes which have +large apertures. For the Rays of Light which pass through divers parts +of the aperture, tremble each of them apart, and by means of their +various and sometimes contrary Tremors, fall at one and the same time +upon different points in the bottom of the Eye, and their trembling +Motions are too quick and confused to be perceived severally. And all +these illuminated Points constitute one broad lucid Point, composed of +those many trembling Points confusedly and insensibly mixed with one +another by very short and swift Tremors, and thereby cause the Star to +appear broader than it is, and without any trembling of the whole. Long +Telescopes may cause Objects to appear brighter and larger than short +ones can do, but they cannot be so formed as to take away that confusion +of the Rays which arises from the Tremors of the Atmosphere. The only +Remedy is a most serene and quiet Air, such as may perhaps be found on +the tops of the highest Mountains above the grosser Clouds. + +FOOTNOTES: + +[C] _See our_ Author's Lectiones Opticæ § 10. _Sect. II. § 29. and Sect. +III. Prop. 25._ + +[D] See our Author's _Lectiones Opticæ_, Part. I. Sect. 1. §5. + +[E] _This is very fully treated of in our_ Author's Lect. Optic. _Part_ +I. _Sect._ II. + +[F] _See our_ Author's Lect. Optic. Part I. Sect. II. § 29. + +[G] _This is demonstrated in our_ Author's Lect. Optic. _Part_ I. +_Sect._ IV. _Prop._ 37. + +[H] _How to do this, is shewn in our_ Author's Lect. Optic. _Part_ I. +_Sect._ IV. _Prop._ 31. + + + + +THE FIRST BOOK OF OPTICKS + + + + +_PART II._ + + +_PROP._ I. THEOR. I. + +_The Phænomena of Colours in refracted or reflected Light are not caused +by new Modifications of the Light variously impress'd, according to the +various Terminations of the Light and Shadow_. + +The PROOF by Experiments. + +_Exper._ 1. For if the Sun shine into a very dark Chamber through an +oblong hole F, [in _Fig._ 1.] whose breadth is the sixth or eighth part +of an Inch, or something less; and his beam FH do afterwards pass first +through a very large Prism ABC, distant about 20 Feet from the hole, and +parallel to it, and then (with its white part) through an oblong hole H, +whose breadth is about the fortieth or sixtieth part of an Inch, and +which is made in a black opake Body GI, and placed at the distance of +two or three Feet from the Prism, in a parallel Situation both to the +Prism and to the former hole, and if this white Light thus transmitted +through the hole H, fall afterwards upon a white Paper _pt_, placed +after that hole H, at the distance of three or four Feet from it, and +there paint the usual Colours of the Prism, suppose red at _t_, yellow +at _s_, green at _r_, blue at _q_, and violet at _p_; you may with an +Iron Wire, or any such like slender opake Body, whose breadth is about +the tenth part of an Inch, by intercepting the Rays at _k_, _l_, _m_, +_n_ or _o_, take away any one of the Colours at _t_, _s_, _r_, _q_ or +_p_, whilst the other Colours remain upon the Paper as before; or with +an Obstacle something bigger you may take away any two, or three, or +four Colours together, the rest remaining: So that any one of the +Colours as well as violet may become outmost in the Confine of the +Shadow towards _p_, and any one of them as well as red may become +outmost in the Confine of the Shadow towards _t_, and any one of them +may also border upon the Shadow made within the Colours by the Obstacle +R intercepting some intermediate part of the Light; and, lastly, any one +of them by being left alone, may border upon the Shadow on either hand. +All the Colours have themselves indifferently to any Confines of Shadow, +and therefore the differences of these Colours from one another, do not +arise from the different Confines of Shadow, whereby Light is variously +modified, as has hitherto been the Opinion of Philosophers. In trying +these things 'tis to be observed, that by how much the holes F and H are +narrower, and the Intervals between them and the Prism greater, and the +Chamber darker, by so much the better doth the Experiment succeed; +provided the Light be not so far diminished, but that the Colours at +_pt_ be sufficiently visible. To procure a Prism of solid Glass large +enough for this Experiment will be difficult, and therefore a prismatick +Vessel must be made of polish'd Glass Plates cemented together, and +filled with salt Water or clear Oil. + +[Illustration: FIG. 1.] + +_Exper._ 2. The Sun's Light let into a dark Chamber through the round +hole F, [in _Fig._ 2.] half an Inch wide, passed first through the Prism +ABC placed at the hole, and then through a Lens PT something more than +four Inches broad, and about eight Feet distant from the Prism, and +thence converged to O the Focus of the Lens distant from it about three +Feet, and there fell upon a white Paper DE. If that Paper was +perpendicular to that Light incident upon it, as 'tis represented in the +posture DE, all the Colours upon it at O appeared white. But if the +Paper being turned about an Axis parallel to the Prism, became very much +inclined to the Light, as 'tis represented in the Positions _de_ and +_[Greek: de]_; the same Light in the one case appeared yellow and red, +in the other blue. Here one and the same part of the Light in one and +the same place, according to the various Inclinations of the Paper, +appeared in one case white, in another yellow or red, in a third blue, +whilst the Confine of Light and shadow, and the Refractions of the Prism +in all these cases remained the same. + +[Illustration: FIG. 2.] + +[Illustration: FIG. 3.] + +_Exper._ 3. Such another Experiment may be more easily tried as follows. +Let a broad beam of the Sun's Light coming into a dark Chamber through a +hole in the Window-shut be refracted by a large Prism ABC, [in _Fig._ +3.] whose refracting Angle C is more than 60 Degrees, and so soon as it +comes out of the Prism, let it fall upon the white Paper DE glewed upon +a stiff Plane; and this Light, when the Paper is perpendicular to it, as +'tis represented in DE, will appear perfectly white upon the Paper; but +when the Paper is very much inclin'd to it in such a manner as to keep +always parallel to the Axis of the Prism, the whiteness of the whole +Light upon the Paper will according to the inclination of the Paper this +way or that way, change either into yellow and red, as in the posture +_de_, or into blue and violet, as in the posture [Greek: de]. And if the +Light before it fall upon the Paper be twice refracted the same way by +two parallel Prisms, these Colours will become the more conspicuous. +Here all the middle parts of the broad beam of white Light which fell +upon the Paper, did without any Confine of Shadow to modify it, become +colour'd all over with one uniform Colour, the Colour being always the +same in the middle of the Paper as at the edges, and this Colour changed +according to the various Obliquity of the reflecting Paper, without any +change in the Refractions or Shadow, or in the Light which fell upon the +Paper. And therefore these Colours are to be derived from some other +Cause than the new Modifications of Light by Refractions and Shadows. + +If it be asked, what then is their Cause? I answer, That the Paper in +the posture _de_, being more oblique to the more refrangible Rays than +to the less refrangible ones, is more strongly illuminated by the latter +than by the former, and therefore the less refrangible Rays are +predominant in the reflected Light. And where-ever they are predominant +in any Light, they tinge it with red or yellow, as may in some measure +appear by the first Proposition of the first Part of this Book, and will +more fully appear hereafter. And the contrary happens in the posture of +the Paper [Greek: de], the more refrangible Rays being then predominant +which always tinge Light with blues and violets. + +_Exper._ 4. The Colours of Bubbles with which Children play are various, +and change their Situation variously, without any respect to any Confine +or Shadow. If such a Bubble be cover'd with a concave Glass, to keep it +from being agitated by any Wind or Motion of the Air, the Colours will +slowly and regularly change their situation, even whilst the Eye and the +Bubble, and all Bodies which emit any Light, or cast any Shadow, remain +unmoved. And therefore their Colours arise from some regular Cause which +depends not on any Confine of Shadow. What this Cause is will be shewed +in the next Book. + +To these Experiments may be added the tenth Experiment of the first Part +of this first Book, where the Sun's Light in a dark Room being +trajected through the parallel Superficies of two Prisms tied together +in the form of a Parallelopipede, became totally of one uniform yellow +or red Colour, at its emerging out of the Prisms. Here, in the +production of these Colours, the Confine of Shadow can have nothing to +do. For the Light changes from white to yellow, orange and red +successively, without any alteration of the Confine of Shadow: And at +both edges of the emerging Light where the contrary Confines of Shadow +ought to produce different Effects, the Colour is one and the same, +whether it be white, yellow, orange or red: And in the middle of the +emerging Light, where there is no Confine of Shadow at all, the Colour +is the very same as at the edges, the whole Light at its very first +Emergence being of one uniform Colour, whether white, yellow, orange or +red, and going on thence perpetually without any change of Colour, such +as the Confine of Shadow is vulgarly supposed to work in refracted Light +after its Emergence. Neither can these Colours arise from any new +Modifications of the Light by Refractions, because they change +successively from white to yellow, orange and red, while the Refractions +remain the same, and also because the Refractions are made contrary ways +by parallel Superficies which destroy one another's Effects. They arise +not therefore from any Modifications of Light made by Refractions and +Shadows, but have some other Cause. What that Cause is we shewed above +in this tenth Experiment, and need not here repeat it. + +There is yet another material Circumstance of this Experiment. For this +emerging Light being by a third Prism HIK [in _Fig._ 22. _Part_ I.][I] +refracted towards the Paper PT, and there painting the usual Colours of +the Prism, red, yellow, green, blue, violet: If these Colours arose from +the Refractions of that Prism modifying the Light, they would not be in +the Light before its Incidence on that Prism. And yet in that Experiment +we found, that when by turning the two first Prisms about their common +Axis all the Colours were made to vanish but the red; the Light which +makes that red being left alone, appeared of the very same red Colour +before its Incidence on the third Prism. And in general we find by other +Experiments, that when the Rays which differ in Refrangibility are +separated from one another, and any one Sort of them is considered +apart, the Colour of the Light which they compose cannot be changed by +any Refraction or Reflexion whatever, as it ought to be were Colours +nothing else than Modifications of Light caused by Refractions, and +Reflexions, and Shadows. This Unchangeableness of Colour I am now to +describe in the following Proposition. + + +_PROP._ II. THEOR. II. + +_All homogeneal Light has its proper Colour answering to its Degree of +Refrangibility, and that Colour cannot be changed by Reflexions and +Refractions._ + +In the Experiments of the fourth Proposition of the first Part of this +first Book, when I had separated the heterogeneous Rays from one +another, the Spectrum _pt_ formed by the separated Rays, did in the +Progress from its End _p_, on which the most refrangible Rays fell, unto +its other End _t_, on which the least refrangible Rays fell, appear +tinged with this Series of Colours, violet, indigo, blue, green, yellow, +orange, red, together with all their intermediate Degrees in a continual +Succession perpetually varying. So that there appeared as many Degrees +of Colours, as there were sorts of Rays differing in Refrangibility. + +_Exper._ 5. Now, that these Colours could not be changed by Refraction, +I knew by refracting with a Prism sometimes one very little Part of this +Light, sometimes another very little Part, as is described in the +twelfth Experiment of the first Part of this Book. For by this +Refraction the Colour of the Light was never changed in the least. If +any Part of the red Light was refracted, it remained totally of the same +red Colour as before. No orange, no yellow, no green or blue, no other +new Colour was produced by that Refraction. Neither did the Colour any +ways change by repeated Refractions, but continued always the same red +entirely as at first. The like Constancy and Immutability I found also +in the blue, green, and other Colours. So also, if I looked through a +Prism upon any Body illuminated with any part of this homogeneal Light, +as in the fourteenth Experiment of the first Part of this Book is +described; I could not perceive any new Colour generated this way. All +Bodies illuminated with compound Light appear through Prisms confused, +(as was said above) and tinged with various new Colours, but those +illuminated with homogeneal Light appeared through Prisms neither less +distinct, nor otherwise colour'd, than when viewed with the naked Eyes. +Their Colours were not in the least changed by the Refraction of the +interposed Prism. I speak here of a sensible Change of Colour: For the +Light which I here call homogeneal, being not absolutely homogeneal, +there ought to arise some little Change of Colour from its +Heterogeneity. But, if that Heterogeneity was so little as it might be +made by the said Experiments of the fourth Proposition, that Change was +not sensible, and therefore in Experiments, where Sense is Judge, ought +to be accounted none at all. + +_Exper._ 6. And as these Colours were not changeable by Refractions, so +neither were they by Reflexions. For all white, grey, red, yellow, +green, blue, violet Bodies, as Paper, Ashes, red Lead, Orpiment, Indico +Bise, Gold, Silver, Copper, Grass, blue Flowers, Violets, Bubbles of +Water tinged with various Colours, Peacock's Feathers, the Tincture of +_Lignum Nephriticum_, and such-like, in red homogeneal Light appeared +totally red, in blue Light totally blue, in green Light totally green, +and so of other Colours. In the homogeneal Light of any Colour they all +appeared totally of that same Colour, with this only Difference, that +some of them reflected that Light more strongly, others more faintly. I +never yet found any Body, which by reflecting homogeneal Light could +sensibly change its Colour. + +From all which it is manifest, that if the Sun's Light consisted of but +one sort of Rays, there would be but one Colour in the whole World, nor +would it be possible to produce any new Colour by Reflexions and +Refractions, and by consequence that the variety of Colours depends upon +the Composition of Light. + + +_DEFINITION._ + +The homogeneal Light and Rays which appear red, or rather make Objects +appear so, I call Rubrifick or Red-making; those which make Objects +appear yellow, green, blue, and violet, I call Yellow-making, +Green-making, Blue-making, Violet-making, and so of the rest. And if at +any time I speak of Light and Rays as coloured or endued with Colours, I +would be understood to speak not philosophically and properly, but +grossly, and accordingly to such Conceptions as vulgar People in seeing +all these Experiments would be apt to frame. For the Rays to speak +properly are not coloured. In them there is nothing else than a certain +Power and Disposition to stir up a Sensation of this or that Colour. +For as Sound in a Bell or musical String, or other sounding Body, is +nothing but a trembling Motion, and in the Air nothing but that Motion +propagated from the Object, and in the Sensorium 'tis a Sense of that +Motion under the Form of Sound; so Colours in the Object are nothing but +a Disposition to reflect this or that sort of Rays more copiously than +the rest; in the Rays they are nothing but their Dispositions to +propagate this or that Motion into the Sensorium, and in the Sensorium +they are Sensations of those Motions under the Forms of Colours. + + +_PROP._ III. PROB. I. + +_To define the Refrangibility of the several sorts of homogeneal Light +answering to the several Colours._ + +For determining this Problem I made the following Experiment.[J] + +_Exper._ 7. When I had caused the Rectilinear Sides AF, GM, [in _Fig._ +4.] of the Spectrum of Colours made by the Prism to be distinctly +defined, as in the fifth Experiment of the first Part of this Book is +described, there were found in it all the homogeneal Colours in the same +Order and Situation one among another as in the Spectrum of simple +Light, described in the fourth Proposition of that Part. For the Circles +of which the Spectrum of compound Light PT is composed, and which in +the middle Parts of the Spectrum interfere, and are intermix'd with one +another, are not intermix'd in their outmost Parts where they touch +those Rectilinear Sides AF and GM. And therefore, in those Rectilinear +Sides when distinctly defined, there is no new Colour generated by +Refraction. I observed also, that if any where between the two outmost +Circles TMF and PGA a Right Line, as [Greek: gd], was cross to the +Spectrum, so as both Ends to fall perpendicularly upon its Rectilinear +Sides, there appeared one and the same Colour, and degree of Colour from +one End of this Line to the other. I delineated therefore in a Paper the +Perimeter of the Spectrum FAP GMT, and in trying the third Experiment of +the first Part of this Book, I held the Paper so that the Spectrum might +fall upon this delineated Figure, and agree with it exactly, whilst an +Assistant, whose Eyes for distinguishing Colours were more critical than +mine, did by Right Lines [Greek: ab, gd, ez,] &c. drawn cross the +Spectrum, note the Confines of the Colours, that is of the red M[Greek: +ab]F, of the orange [Greek: agdb], of the yellow [Greek: gezd], of the +green [Greek: eêthz], of the blue [Greek: êikth], of the indico [Greek: +ilmk], and of the violet [Greek: l]GA[Greek: m]. And this Operation +being divers times repeated both in the same, and in several Papers, I +found that the Observations agreed well enough with one another, and +that the Rectilinear Sides MG and FA were by the said cross Lines +divided after the manner of a Musical Chord. Let GM be produced to X, +that MX may be equal to GM, and conceive GX, [Greek: l]X, [Greek: i]X, +[Greek: ê]X, [Greek: e]X, [Greek: g]X, [Greek: a]X, MX, to be in +proportion to one another, as the Numbers, 1, 8/9, 5/6, 3/4, 2/3, 3/5, +9/16, 1/2, and so to represent the Chords of the Key, and of a Tone, a +third Minor, a fourth, a fifth, a sixth Major, a seventh and an eighth +above that Key: And the Intervals M[Greek: a], [Greek: ag], [Greek: ge], +[Greek: eê], [Greek: êi], [Greek: il], and [Greek: l]G, will be the +Spaces which the several Colours (red, orange, yellow, green, blue, +indigo, violet) take up. + +[Illustration: FIG. 4.] + +[Illustration: FIG. 5.] + +Now these Intervals or Spaces subtending the Differences of the +Refractions of the Rays going to the Limits of those Colours, that is, +to the Points M, [Greek: a], [Greek: g], [Greek: e], [Greek: ê], [Greek: +i], [Greek: l], G, may without any sensible Error be accounted +proportional to the Differences of the Sines of Refraction of those Rays +having one common Sine of Incidence, and therefore since the common Sine +of Incidence of the most and least refrangible Rays out of Glass into +Air was (by a Method described above) found in proportion to their Sines +of Refraction, as 50 to 77 and 78, divide the Difference between the +Sines of Refraction 77 and 78, as the Line GM is divided by those +Intervals, and you will have 77, 77-1/8, 77-1/5, 77-1/3, 77-1/2, 77-2/3, +77-7/9, 78, the Sines of Refraction of those Rays out of Glass into Air, +their common Sine of Incidence being 50. So then the Sines of the +Incidences of all the red-making Rays out of Glass into Air, were to the +Sines of their Refractions, not greater than 50 to 77, nor less than 50 +to 77-1/8, but they varied from one another according to all +intermediate Proportions. And the Sines of the Incidences of the +green-making Rays were to the Sines of their Refractions in all +Proportions from that of 50 to 77-1/3, unto that of 50 to 77-1/2. And +by the like Limits above-mentioned were the Refractions of the Rays +belonging to the rest of the Colours defined, the Sines of the +red-making Rays extending from 77 to 77-1/8, those of the orange-making +from 77-1/8 to 77-1/5, those of the yellow-making from 77-1/5 to 77-1/3, +those of the green-making from 77-1/3 to 77-1/2, those of the +blue-making from 77-1/2 to 77-2/3, those of the indigo-making from +77-2/3 to 77-7/9, and those of the violet from 77-7/9, to 78. + +These are the Laws of the Refractions made out of Glass into Air, and +thence by the third Axiom of the first Part of this Book, the Laws of +the Refractions made out of Air into Glass are easily derived. + +_Exper._ 8. I found moreover, that when Light goes out of Air through +several contiguous refracting Mediums as through Water and Glass, and +thence goes out again into Air, whether the refracting Superficies be +parallel or inclin'd to one another, that Light as often as by contrary +Refractions 'tis so corrected, that it emergeth in Lines parallel to +those in which it was incident, continues ever after to be white. But if +the emergent Rays be inclined to the incident, the Whiteness of the +emerging Light will by degrees in passing on from the Place of +Emergence, become tinged in its Edges with Colours. This I try'd by +refracting Light with Prisms of Glass placed within a Prismatick Vessel +of Water. Now those Colours argue a diverging and separation of the +heterogeneous Rays from one another by means of their unequal +Refractions, as in what follows will more fully appear. And, on the +contrary, the permanent whiteness argues, that in like Incidences of the +Rays there is no such separation of the emerging Rays, and by +consequence no inequality of their whole Refractions. Whence I seem to +gather the two following Theorems. + +1. The Excesses of the Sines of Refraction of several sorts of Rays +above their common Sine of Incidence when the Refractions are made out +of divers denser Mediums immediately into one and the same rarer Medium, +suppose of Air, are to one another in a given Proportion. + +2. The Proportion of the Sine of Incidence to the Sine of Refraction of +one and the same sort of Rays out of one Medium into another, is +composed of the Proportion of the Sine of Incidence to the Sine of +Refraction out of the first Medium into any third Medium, and of the +Proportion of the Sine of Incidence to the Sine of Refraction out of +that third Medium into the second Medium. + +By the first Theorem the Refractions of the Rays of every sort made out +of any Medium into Air are known by having the Refraction of the Rays of +any one sort. As for instance, if the Refractions of the Rays of every +sort out of Rain-water into Air be desired, let the common Sine of +Incidence out of Glass into Air be subducted from the Sines of +Refraction, and the Excesses will be 27, 27-1/8, 27-1/5, 27-1/3, 27-1/2, +27-2/3, 27-7/9, 28. Suppose now that the Sine of Incidence of the least +refrangible Rays be to their Sine of Refraction out of Rain-water into +Air as 3 to 4, and say as 1 the difference of those Sines is to 3 the +Sine of Incidence, so is 27 the least of the Excesses above-mentioned to +a fourth Number 81; and 81 will be the common Sine of Incidence out of +Rain-water into Air, to which Sine if you add all the above-mentioned +Excesses, you will have the desired Sines of the Refractions 108, +108-1/8, 108-1/5, 108-1/3, 108-1/2, 108-2/3, 108-7/9, 109. + +By the latter Theorem the Refraction out of one Medium into another is +gathered as often as you have the Refractions out of them both into any +third Medium. As if the Sine of Incidence of any Ray out of Glass into +Air be to its Sine of Refraction, as 20 to 31, and the Sine of Incidence +of the same Ray out of Air into Water, be to its Sine of Refraction as 4 +to 3; the Sine of Incidence of that Ray out of Glass into Water will be +to its Sine of Refraction as 20 to 31 and 4 to 3 jointly, that is, as +the Factum of 20 and 4 to the Factum of 31 and 3, or as 80 to 93. + +And these Theorems being admitted into Opticks, there would be scope +enough of handling that Science voluminously after a new manner,[K] not +only by teaching those things which tend to the perfection of Vision, +but also by determining mathematically all kinds of Phænomena of Colours +which could be produced by Refractions. For to do this, there is nothing +else requisite than to find out the Separations of heterogeneous Rays, +and their various Mixtures and Proportions in every Mixture. By this +way of arguing I invented almost all the Phænomena described in these +Books, beside some others less necessary to the Argument; and by the +successes I met with in the Trials, I dare promise, that to him who +shall argue truly, and then try all things with good Glasses and +sufficient Circumspection, the expected Event will not be wanting. But +he is first to know what Colours will arise from any others mix'd in any +assigned Proportion. + + +_PROP._ IV. THEOR. III. + +_Colours may be produced by Composition which shall be like to the +Colours of homogeneal Light as to the Appearance of Colour, but not as +to the Immutability of Colour and Constitution of Light. And those +Colours by how much they are more compounded by so much are they less +full and intense, and by too much Composition they maybe diluted and +weaken'd till they cease, and the Mixture becomes white or grey. There +may be also Colours produced by Composition, which are not fully like +any of the Colours of homogeneal Light._ + +For a Mixture of homogeneal red and yellow compounds an Orange, like in +appearance of Colour to that orange which in the series of unmixed +prismatick Colours lies between them; but the Light of one orange is +homogeneal as to Refrangibility, and that of the other is heterogeneal, +and the Colour of the one, if viewed through a Prism, remains unchanged, +that of the other is changed and resolved into its component Colours red +and yellow. And after the same manner other neighbouring homogeneal +Colours may compound new Colours, like the intermediate homogeneal ones, +as yellow and green, the Colour between them both, and afterwards, if +blue be added, there will be made a green the middle Colour of the three +which enter the Composition. For the yellow and blue on either hand, if +they are equal in quantity they draw the intermediate green equally +towards themselves in Composition, and so keep it as it were in +Æquilibrion, that it verge not more to the yellow on the one hand, and +to the blue on the other, but by their mix'd Actions remain still a +middle Colour. To this mix'd green there may be farther added some red +and violet, and yet the green will not presently cease, but only grow +less full and vivid, and by increasing the red and violet, it will grow +more and more dilute, until by the prevalence of the added Colours it be +overcome and turned into whiteness, or some other Colour. So if to the +Colour of any homogeneal Light, the Sun's white Light composed of all +sorts of Rays be added, that Colour will not vanish or change its +Species, but be diluted, and by adding more and more white it will be +diluted more and more perpetually. Lastly, If red and violet be mingled, +there will be generated according to their various Proportions various +Purples, such as are not like in appearance to the Colour of any +homogeneal Light, and of these Purples mix'd with yellow and blue may be +made other new Colours. + + +_PROP._ V. THEOR. IV. + +_Whiteness and all grey Colours between white and black, may be +compounded of Colours, and the whiteness of the Sun's Light is +compounded of all the primary Colours mix'd in a due Proportion._ + +The PROOF by Experiments. + +_Exper._ 9. The Sun shining into a dark Chamber through a little round +hole in the Window-shut, and his Light being there refracted by a Prism +to cast his coloured Image PT [in _Fig._ 5.] upon the opposite Wall: I +held a white Paper V to that image in such manner that it might be +illuminated by the colour'd Light reflected from thence, and yet not +intercept any part of that Light in its passage from the Prism to the +Spectrum. And I found that when the Paper was held nearer to any Colour +than to the rest, it appeared of that Colour to which it approached +nearest; but when it was equally or almost equally distant from all the +Colours, so that it might be equally illuminated by them all it appeared +white. And in this last situation of the Paper, if some Colours were +intercepted, the Paper lost its white Colour, and appeared of the Colour +of the rest of the Light which was not intercepted. So then the Paper +was illuminated with Lights of various Colours, namely, red, yellow, +green, blue and violet, and every part of the Light retained its proper +Colour, until it was incident on the Paper, and became reflected thence +to the Eye; so that if it had been either alone (the rest of the Light +being intercepted) or if it had abounded most, and been predominant in +the Light reflected from the Paper, it would have tinged the Paper with +its own Colour; and yet being mixed with the rest of the Colours in a +due proportion, it made the Paper look white, and therefore by a +Composition with the rest produced that Colour. The several parts of the +coloured Light reflected from the Spectrum, whilst they are propagated +from thence through the Air, do perpetually retain their proper Colours, +because wherever they fall upon the Eyes of any Spectator, they make the +several parts of the Spectrum to appear under their proper Colours. They +retain therefore their proper Colours when they fall upon the Paper V, +and so by the confusion and perfect mixture of those Colours compound +the whiteness of the Light reflected from thence. + +_Exper._ 10. Let that Spectrum or solar Image PT [in _Fig._ 6.] fall now +upon the Lens MN above four Inches broad, and about six Feet distant +from the Prism ABC and so figured that it may cause the coloured Light +which divergeth from the Prism to converge and meet again at its Focus +G, about six or eight Feet distant from the Lens, and there to fall +perpendicularly upon a white Paper DE. And if you move this Paper to and +fro, you will perceive that near the Lens, as at _de_, the whole solar +Image (suppose at _pt_) will appear upon it intensely coloured after the +manner above-explained, and that by receding from the Lens those Colours +will perpetually come towards one another, and by mixing more and more +dilute one another continually, until at length the Paper come to the +Focus G, where by a perfect mixture they will wholly vanish and be +converted into whiteness, the whole Light appearing now upon the Paper +like a little white Circle. And afterwards by receding farther from the +Lens, the Rays which before converged will now cross one another in the +Focus G, and diverge from thence, and thereby make the Colours to appear +again, but yet in a contrary order; suppose at [Greek: de], where the +red _t_ is now above which before was below, and the violet _p_ is below +which before was above. + +Let us now stop the Paper at the Focus G, where the Light appears +totally white and circular, and let us consider its whiteness. I say, +that this is composed of the converging Colours. For if any of those +Colours be intercepted at the Lens, the whiteness will cease and +degenerate into that Colour which ariseth from the composition of the +other Colours which are not intercepted. And then if the intercepted +Colours be let pass and fall upon that compound Colour, they mix with +it, and by their mixture restore the whiteness. So if the violet, blue +and green be intercepted, the remaining yellow, orange and red will +compound upon the Paper an orange, and then if the intercepted Colours +be let pass, they will fall upon this compounded orange, and together +with it decompound a white. So also if the red and violet be +intercepted, the remaining yellow, green and blue, will compound a green +upon the Paper, and then the red and violet being let pass will fall +upon this green, and together with it decompound a white. And that in +this Composition of white the several Rays do not suffer any Change in +their colorific Qualities by acting upon one another, but are only +mixed, and by a mixture of their Colours produce white, may farther +appear by these Arguments. + +[Illustration: FIG. 6.] + +If the Paper be placed beyond the Focus G, suppose at [Greek: de], and +then the red Colour at the Lens be alternately intercepted, and let pass +again, the violet Colour on the Paper will not suffer any Change +thereby, as it ought to do if the several sorts of Rays acted upon one +another in the Focus G, where they cross. Neither will the red upon the +Paper be changed by any alternate stopping, and letting pass the violet +which crosseth it. + +And if the Paper be placed at the Focus G, and the white round Image at +G be viewed through the Prism HIK, and by the Refraction of that Prism +be translated to the place _rv_, and there appear tinged with various +Colours, namely, the violet at _v_ and red at _r_, and others between, +and then the red Colours at the Lens be often stopp'd and let pass by +turns, the red at _r_ will accordingly disappear, and return as often, +but the violet at _v_ will not thereby suffer any Change. And so by +stopping and letting pass alternately the blue at the Lens, the blue at +_v_ will accordingly disappear and return, without any Change made in +the red at _r_. The red therefore depends on one sort of Rays, and the +blue on another sort, which in the Focus G where they are commix'd, do +not act on one another. And there is the same Reason of the other +Colours. + +I considered farther, that when the most refrangible Rays P_p_, and the +least refrangible ones T_t_, are by converging inclined to one another, +the Paper, if held very oblique to those Rays in the Focus G, might +reflect one sort of them more copiously than the other sort, and by that +Means the reflected Light would be tinged in that Focus with the Colour +of the predominant Rays, provided those Rays severally retained their +Colours, or colorific Qualities in the Composition of White made by them +in that Focus. But if they did not retain them in that White, but became +all of them severally endued there with a Disposition to strike the +Sense with the Perception of White, then they could never lose their +Whiteness by such Reflexions. I inclined therefore the Paper to the Rays +very obliquely, as in the second Experiment of this second Part of the +first Book, that the most refrangible Rays, might be more copiously +reflected than the rest, and the Whiteness at Length changed +successively into blue, indigo, and violet. Then I inclined it the +contrary Way, that the least refrangible Rays might be more copious in +the reflected Light than the rest, and the Whiteness turned successively +to yellow, orange, and red. + +Lastly, I made an Instrument XY in fashion of a Comb, whose Teeth being +in number sixteen, were about an Inch and a half broad, and the +Intervals of the Teeth about two Inches wide. Then by interposing +successively the Teeth of this Instrument near the Lens, I intercepted +Part of the Colours by the interposed Tooth, whilst the rest of them +went on through the Interval of the Teeth to the Paper DE, and there +painted a round Solar Image. But the Paper I had first placed so, that +the Image might appear white as often as the Comb was taken away; and +then the Comb being as was said interposed, that Whiteness by reason of +the intercepted Part of the Colours at the Lens did always change into +the Colour compounded of those Colours which were not intercepted, and +that Colour was by the Motion of the Comb perpetually varied so, that in +the passing of every Tooth over the Lens all these Colours, red, yellow, +green, blue, and purple, did always succeed one another. I caused +therefore all the Teeth to pass successively over the Lens, and when the +Motion was slow, there appeared a perpetual Succession of the Colours +upon the Paper: But if I so much accelerated the Motion, that the +Colours by reason of their quick Succession could not be distinguished +from one another, the Appearance of the single Colours ceased. There was +no red, no yellow, no green, no blue, nor purple to be seen any longer, +but from a Confusion of them all there arose one uniform white Colour. +Of the Light which now by the Mixture of all the Colours appeared white, +there was no Part really white. One Part was red, another yellow, a +third green, a fourth blue, a fifth purple, and every Part retains its +proper Colour till it strike the Sensorium. If the Impressions follow +one another slowly, so that they may be severally perceived, there is +made a distinct Sensation of all the Colours one after another in a +continual Succession. But if the Impressions follow one another so +quickly, that they cannot be severally perceived, there ariseth out of +them all one common Sensation, which is neither of this Colour alone nor +of that alone, but hath it self indifferently to 'em all, and this is a +Sensation of Whiteness. By the Quickness of the Successions, the +Impressions of the several Colours are confounded in the Sensorium, and +out of that Confusion ariseth a mix'd Sensation. If a burning Coal be +nimbly moved round in a Circle with Gyrations continually repeated, the +whole Circle will appear like Fire; the reason of which is, that the +Sensation of the Coal in the several Places of that Circle remains +impress'd on the Sensorium, until the Coal return again to the same +Place. And so in a quick Consecution of the Colours the Impression of +every Colour remains in the Sensorium, until a Revolution of all the +Colours be compleated, and that first Colour return again. The +Impressions therefore of all the successive Colours are at once in the +Sensorium, and jointly stir up a Sensation of them all; and so it is +manifest by this Experiment, that the commix'd Impressions of all the +Colours do stir up and beget a Sensation of white, that is, that +Whiteness is compounded of all the Colours. + +And if the Comb be now taken away, that all the Colours may at once pass +from the Lens to the Paper, and be there intermixed, and together +reflected thence to the Spectator's Eyes; their Impressions on the +Sensorium being now more subtilly and perfectly commixed there, ought +much more to stir up a Sensation of Whiteness. + +You may instead of the Lens use two Prisms HIK and LMN, which by +refracting the coloured Light the contrary Way to that of the first +Refraction, may make the diverging Rays converge and meet again in G, as +you see represented in the seventh Figure. For where they meet and mix, +they will compose a white Light, as when a Lens is used. + +_Exper._ 11. Let the Sun's coloured Image PT [in _Fig._ 8.] fall upon +the Wall of a dark Chamber, as in the third Experiment of the first +Book, and let the same be viewed through a Prism _abc_, held parallel to +the Prism ABC, by whose Refraction that Image was made, and let it now +appear lower than before, suppose in the Place S over-against the red +Colour T. And if you go near to the Image PT, the Spectrum S will appear +oblong and coloured like the Image PT; but if you recede from it, the +Colours of the spectrum S will be contracted more and more, and at +length vanish, that Spectrum S becoming perfectly round and white; and +if you recede yet farther, the Colours will emerge again, but in a +contrary Order. Now that Spectrum S appears white in that Case, when the +Rays of several sorts which converge from the several Parts of the Image +PT, to the Prism _abc_, are so refracted unequally by it, that in their +Passage from the Prism to the Eye they may diverge from one and the same +Point of the Spectrum S, and so fall afterwards upon one and the same +Point in the bottom of the Eye, and there be mingled. + +[Illustration: FIG. 7.] + +[Illustration: FIG. 8.] + +And farther, if the Comb be here made use of, by whose Teeth the Colours +at the Image PT may be successively intercepted; the Spectrum S, when +the Comb is moved slowly, will be perpetually tinged with successive +Colours: But when by accelerating the Motion of the Comb, the Succession +of the Colours is so quick that they cannot be severally seen, that +Spectrum S, by a confused and mix'd Sensation of them all, will appear +white. + +_Exper._ 12. The Sun shining through a large Prism ABC [in _Fig._ 9.] +upon a Comb XY, placed immediately behind the Prism, his Light which +passed through the Interstices of the Teeth fell upon a white Paper DE. +The Breadths of the Teeth were equal to their Interstices, and seven +Teeth together with their Interstices took up an Inch in Breadth. Now, +when the Paper was about two or three Inches distant from the Comb, the +Light which passed through its several Interstices painted so many +Ranges of Colours, _kl_, _mn_, _op_, _qr_, &c. which were parallel to +one another, and contiguous, and without any Mixture of white. And these +Ranges of Colours, if the Comb was moved continually up and down with a +reciprocal Motion, ascended and descended in the Paper, and when the +Motion of the Comb was so quick, that the Colours could not be +distinguished from one another, the whole Paper by their Confusion and +Mixture in the Sensorium appeared white. + +[Illustration: FIG. 9.] + +Let the Comb now rest, and let the Paper be removed farther from the +Prism, and the several Ranges of Colours will be dilated and expanded +into one another more and more, and by mixing their Colours will dilute +one another, and at length, when the distance of the Paper from the Comb +is about a Foot, or a little more (suppose in the Place 2D 2E) they will +so far dilute one another, as to become white. + +With any Obstacle, let all the Light be now stopp'd which passes through +any one Interval of the Teeth, so that the Range of Colours which comes +from thence may be taken away, and you will see the Light of the rest of +the Ranges to be expanded into the Place of the Range taken away, and +there to be coloured. Let the intercepted Range pass on as before, and +its Colours falling upon the Colours of the other Ranges, and mixing +with them, will restore the Whiteness. + +Let the Paper 2D 2E be now very much inclined to the Rays, so that the +most refrangible Rays may be more copiously reflected than the rest, and +the white Colour of the Paper through the Excess of those Rays will be +changed into blue and violet. Let the Paper be as much inclined the +contrary way, that the least refrangible Rays may be now more copiously +reflected than the rest, and by their Excess the Whiteness will be +changed into yellow and red. The several Rays therefore in that white +Light do retain their colorific Qualities, by which those of any sort, +whenever they become more copious than the rest, do by their Excess and +Predominance cause their proper Colour to appear. + +And by the same way of arguing, applied to the third Experiment of this +second Part of the first Book, it may be concluded, that the white +Colour of all refracted Light at its very first Emergence, where it +appears as white as before its Incidence, is compounded of various +Colours. + +[Illustration: FIG. 10.] + +_Exper._ 13. In the foregoing Experiment the several Intervals of the +Teeth of the Comb do the Office of so many Prisms, every Interval +producing the Phænomenon of one Prism. Whence instead of those Intervals +using several Prisms, I try'd to compound Whiteness by mixing their +Colours, and did it by using only three Prisms, as also by using only +two as follows. Let two Prisms ABC and _abc_, [in _Fig._ 10.] whose +refracting Angles B and _b_ are equal, be so placed parallel to one +another, that the refracting Angle B of the one may touch the Angle _c_ +at the Base of the other, and their Planes CB and _cb_, at which the +Rays emerge, may lie in Directum. Then let the Light trajected through +them fall upon the Paper MN, distant about 8 or 12 Inches from the +Prisms. And the Colours generated by the interior Limits B and _c_ of +the two Prisms, will be mingled at PT, and there compound white. For if +either Prism be taken away, the Colours made by the other will appear in +that Place PT, and when the Prism is restored to its Place again, so +that its Colours may there fall upon the Colours of the other, the +Mixture of them both will restore the Whiteness. + +This Experiment succeeds also, as I have tried, when the Angle _b_ of +the lower Prism, is a little greater than the Angle B of the upper, and +between the interior Angles B and _c_, there intercedes some Space B_c_, +as is represented in the Figure, and the refracting Planes BC and _bc_, +are neither in Directum, nor parallel to one another. For there is +nothing more requisite to the Success of this Experiment, than that the +Rays of all sorts may be uniformly mixed upon the Paper in the Place PT. +If the most refrangible Rays coming from the superior Prism take up all +the Space from M to P, the Rays of the same sort which come from the +inferior Prism ought to begin at P, and take up all the rest of the +Space from thence towards N. If the least refrangible Rays coming from +the superior Prism take up the Space MT, the Rays of the same kind which +come from the other Prism ought to begin at T, and take up the +remaining Space TN. If one sort of the Rays which have intermediate +Degrees of Refrangibility, and come from the superior Prism be extended +through the Space MQ, and another sort of those Rays through the Space +MR, and a third sort of them through the Space MS, the same sorts of +Rays coming from the lower Prism, ought to illuminate the remaining +Spaces QN, RN, SN, respectively. And the same is to be understood of all +the other sorts of Rays. For thus the Rays of every sort will be +scattered uniformly and evenly through the whole Space MN, and so being +every where mix'd in the same Proportion, they must every where produce +the same Colour. And therefore, since by this Mixture they produce white +in the Exterior Spaces MP and TN, they must also produce white in the +Interior Space PT. This is the reason of the Composition by which +Whiteness was produced in this Experiment, and by what other way soever +I made the like Composition, the Result was Whiteness. + +Lastly, If with the Teeth of a Comb of a due Size, the coloured Lights +of the two Prisms which fall upon the Space PT be alternately +intercepted, that Space PT, when the Motion of the Comb is slow, will +always appear coloured, but by accelerating the Motion of the Comb so +much that the successive Colours cannot be distinguished from one +another, it will appear white. + +_Exper._ 14. Hitherto I have produced Whiteness by mixing the Colours of +Prisms. If now the Colours of natural Bodies are to be mingled, let +Water a little thicken'd with Soap be agitated to raise a Froth, and +after that Froth has stood a little, there will appear to one that shall +view it intently various Colours every where in the Surfaces of the +several Bubbles; but to one that shall go so far off, that he cannot +distinguish the Colours from one another, the whole Froth will grow +white with a perfect Whiteness. + +_Exper._ 15. Lastly, In attempting to compound a white, by mixing the +coloured Powders which Painters use, I consider'd that all colour'd +Powders do suppress and stop in them a very considerable Part of the +Light by which they are illuminated. For they become colour'd by +reflecting the Light of their own Colours more copiously, and that of +all other Colours more sparingly, and yet they do not reflect the Light +of their own Colours so copiously as white Bodies do. If red Lead, for +instance, and a white Paper, be placed in the red Light of the colour'd +Spectrum made in a dark Chamber by the Refraction of a Prism, as is +described in the third Experiment of the first Part of this Book; the +Paper will appear more lucid than the red Lead, and therefore reflects +the red-making Rays more copiously than red Lead doth. And if they be +held in the Light of any other Colour, the Light reflected by the Paper +will exceed the Light reflected by the red Lead in a much greater +Proportion. And the like happens in Powders of other Colours. And +therefore by mixing such Powders, we are not to expect a strong and +full White, such as is that of Paper, but some dusky obscure one, such +as might arise from a Mixture of Light and Darkness, or from white and +black, that is, a grey, or dun, or russet brown, such as are the Colours +of a Man's Nail, of a Mouse, of Ashes, of ordinary Stones, of Mortar, of +Dust and Dirt in High-ways, and the like. And such a dark white I have +often produced by mixing colour'd Powders. For thus one Part of red +Lead, and five Parts of _Viride Æris_, composed a dun Colour like that +of a Mouse. For these two Colours were severally so compounded of +others, that in both together were a Mixture of all Colours; and there +was less red Lead used than _Viride Æris_, because of the Fulness of its +Colour. Again, one Part of red Lead, and four Parts of blue Bise, +composed a dun Colour verging a little to purple, and by adding to this +a certain Mixture of Orpiment and _Viride Æris_ in a due Proportion, the +Mixture lost its purple Tincture, and became perfectly dun. But the +Experiment succeeded best without Minium thus. To Orpiment I added by +little and little a certain full bright purple, which Painters use, +until the Orpiment ceased to be yellow, and became of a pale red. Then I +diluted that red by adding a little _Viride Æris_, and a little more +blue Bise than _Viride Æris_, until it became of such a grey or pale +white, as verged to no one of the Colours more than to another. For thus +it became of a Colour equal in Whiteness to that of Ashes, or of Wood +newly cut, or of a Man's Skin. The Orpiment reflected more Light than +did any other of the Powders, and therefore conduced more to the +Whiteness of the compounded Colour than they. To assign the Proportions +accurately may be difficult, by reason of the different Goodness of +Powders of the same kind. Accordingly, as the Colour of any Powder is +more or less full and luminous, it ought to be used in a less or greater +Proportion. + +Now, considering that these grey and dun Colours may be also produced by +mixing Whites and Blacks, and by consequence differ from perfect Whites, +not in Species of Colours, but only in degree of Luminousness, it is +manifest that there is nothing more requisite to make them perfectly +white than to increase their Light sufficiently; and, on the contrary, +if by increasing their Light they can be brought to perfect Whiteness, +it will thence also follow, that they are of the same Species of Colour +with the best Whites, and differ from them only in the Quantity of +Light. And this I tried as follows. I took the third of the +above-mention'd grey Mixtures, (that which was compounded of Orpiment, +Purple, Bise, and _Viride Æris_) and rubbed it thickly upon the Floor of +my Chamber, where the Sun shone upon it through the opened Casement; and +by it, in the shadow, I laid a Piece of white Paper of the same Bigness. +Then going from them to the distance of 12 or 18 Feet, so that I could +not discern the Unevenness of the Surface of the Powder, nor the little +Shadows let fall from the gritty Particles thereof; the Powder appeared +intensely white, so as to transcend even the Paper it self in Whiteness, +especially if the Paper were a little shaded from the Light of the +Clouds, and then the Paper compared with the Powder appeared of such a +grey Colour as the Powder had done before. But by laying the Paper where +the Sun shines through the Glass of the Window, or by shutting the +Window that the Sun might shine through the Glass upon the Powder, and +by such other fit Means of increasing or decreasing the Lights wherewith +the Powder and Paper were illuminated, the Light wherewith the Powder is +illuminated may be made stronger in such a due Proportion than the Light +wherewith the Paper is illuminated, that they shall both appear exactly +alike in Whiteness. For when I was trying this, a Friend coming to visit +me, I stopp'd him at the Door, and before I told him what the Colours +were, or what I was doing; I asked him, Which of the two Whites were the +best, and wherein they differed? And after he had at that distance +viewed them well, he answer'd, that they were both good Whites, and that +he could not say which was best, nor wherein their Colours differed. +Now, if you consider, that this White of the Powder in the Sun-shine was +compounded of the Colours which the component Powders (Orpiment, Purple, +Bise, and _Viride Æris_) have in the same Sun-shine, you must +acknowledge by this Experiment, as well as by the former, that perfect +Whiteness may be compounded of Colours. + +From what has been said it is also evident, that the Whiteness of the +Sun's Light is compounded of all the Colours wherewith the several sorts +of Rays whereof that Light consists, when by their several +Refrangibilities they are separated from one another, do tinge Paper or +any other white Body whereon they fall. For those Colours (by _Prop._ +II. _Part_ 2.) are unchangeable, and whenever all those Rays with those +their Colours are mix'd again, they reproduce the same white Light as +before. + + +_PROP._ VI. PROB. II. + +_In a mixture of Primary Colours, the Quantity and Quality of each being +given, to know the Colour of the Compound._ + +[Illustration: FIG. 11.] + +With the Center O [in _Fig._ 11.] and Radius OD describe a Circle ADF, +and distinguish its Circumference into seven Parts DE, EF, FG, GA, AB, +BC, CD, proportional to the seven Musical Tones or Intervals of the +eight Sounds, _Sol_, _la_, _fa_, _sol_, _la_, _mi_, _fa_, _sol_, +contained in an eight, that is, proportional to the Number 1/9, 1/16, +1/10, 1/9, 1/16, 1/16, 1/9. Let the first Part DE represent a red +Colour, the second EF orange, the third FG yellow, the fourth CA green, +the fifth AB blue, the sixth BC indigo, and the seventh CD violet. And +conceive that these are all the Colours of uncompounded Light gradually +passing into one another, as they do when made by Prisms; the +Circumference DEFGABCD, representing the whole Series of Colours from +one end of the Sun's colour'd Image to the other, so that from D to E be +all degrees of red, at E the mean Colour between red and orange, from E +to F all degrees of orange, at F the mean between orange and yellow, +from F to G all degrees of yellow, and so on. Let _p_ be the Center of +Gravity of the Arch DE, and _q_, _r_, _s_, _t_, _u_, _x_, the Centers of +Gravity of the Arches EF, FG, GA, AB, BC, and CD respectively, and about +those Centers of Gravity let Circles proportional to the Number of Rays +of each Colour in the given Mixture be describ'd: that is, the Circle +_p_ proportional to the Number of the red-making Rays in the Mixture, +the Circle _q_ proportional to the Number of the orange-making Rays in +the Mixture, and so of the rest. Find the common Center of Gravity of +all those Circles, _p_, _q_, _r_, _s_, _t_, _u_, _x_. Let that Center be +Z; and from the Center of the Circle ADF, through Z to the +Circumference, drawing the Right Line OY, the Place of the Point Y in +the Circumference shall shew the Colour arising from the Composition of +all the Colours in the given Mixture, and the Line OZ shall be +proportional to the Fulness or Intenseness of the Colour, that is, to +its distance from Whiteness. As if Y fall in the middle between F and G, +the compounded Colour shall be the best yellow; if Y verge from the +middle towards F or G, the compound Colour shall accordingly be a +yellow, verging towards orange or green. If Z fall upon the +Circumference, the Colour shall be intense and florid in the highest +Degree; if it fall in the mid-way between the Circumference and Center, +it shall be but half so intense, that is, it shall be such a Colour as +would be made by diluting the intensest yellow with an equal quantity of +whiteness; and if it fall upon the center O, the Colour shall have lost +all its intenseness, and become a white. But it is to be noted, That if +the point Z fall in or near the line OD, the main ingredients being the +red and violet, the Colour compounded shall not be any of the prismatick +Colours, but a purple, inclining to red or violet, accordingly as the +point Z lieth on the side of the line DO towards E or towards C, and in +general the compounded violet is more bright and more fiery than the +uncompounded. Also if only two of the primary Colours which in the +circle are opposite to one another be mixed in an equal proportion, the +point Z shall fall upon the center O, and yet the Colour compounded of +those two shall not be perfectly white, but some faint anonymous Colour. +For I could never yet by mixing only two primary Colours produce a +perfect white. Whether it may be compounded of a mixture of three taken +at equal distances in the circumference I do not know, but of four or +five I do not much question but it may. But these are Curiosities of +little or no moment to the understanding the Phænomena of Nature. For in +all whites produced by Nature, there uses to be a mixture of all sorts +of Rays, and by consequence a composition of all Colours. + +To give an instance of this Rule; suppose a Colour is compounded of +these homogeneal Colours, of violet one part, of indigo one part, of +blue two parts, of green three parts, of yellow five parts, of orange +six parts, and of red ten parts. Proportional to these parts describe +the Circles _x_, _v_, _t_, _s_, _r_, _q_, _p_, respectively, that is, so +that if the Circle _x_ be one, the Circle _v_ may be one, the Circle _t_ +two, the Circle _s_ three, and the Circles _r_, _q_ and _p_, five, six +and ten. Then I find Z the common center of gravity of these Circles, +and through Z drawing the Line OY, the Point Y falls upon the +circumference between E and F, something nearer to E than to F, and +thence I conclude, that the Colour compounded of these Ingredients will +be an orange, verging a little more to red than to yellow. Also I find +that OZ is a little less than one half of OY, and thence I conclude, +that this orange hath a little less than half the fulness or intenseness +of an uncompounded orange; that is to say, that it is such an orange as +may be made by mixing an homogeneal orange with a good white in the +proportion of the Line OZ to the Line ZY, this Proportion being not of +the quantities of mixed orange and white Powders, but of the quantities +of the Lights reflected from them. + +This Rule I conceive accurate enough for practice, though not +mathematically accurate; and the truth of it may be sufficiently proved +to Sense, by stopping any of the Colours at the Lens in the tenth +Experiment of this Book. For the rest of the Colours which are not +stopp'd, but pass on to the Focus of the Lens, will there compound +either accurately or very nearly such a Colour, as by this Rule ought to +result from their Mixture. + + +_PROP._ VII. THEOR. V. + +_All the Colours in the Universe which are made by Light, and depend not +on the Power of Imagination, are either the Colours of homogeneal +Lights, or compounded of these, and that either accurately or very +nearly, according to the Rule of the foregoing Problem._ + +For it has been proved (in _Prop. 1. Part 2._) that the changes of +Colours made by Refractions do not arise from any new Modifications of +the Rays impress'd by those Refractions, and by the various Terminations +of Light and Shadow, as has been the constant and general Opinion of +Philosophers. It has also been proved that the several Colours of the +homogeneal Rays do constantly answer to their degrees of Refrangibility, +(_Prop._ 1. _Part_ 1. and _Prop._ 2. _Part_ 2.) and that their degrees +of Refrangibility cannot be changed by Refractions and Reflexions +(_Prop._ 2. _Part_ 1.) and by consequence that those their Colours are +likewise immutable. It has also been proved directly by refracting and +reflecting homogeneal Lights apart, that their Colours cannot be +changed, (_Prop._ 2. _Part_ 2.) It has been proved also, that when the +several sorts of Rays are mixed, and in crossing pass through the same +space, they do not act on one another so as to change each others +colorific qualities. (_Exper._ 10. _Part_ 2.) but by mixing their +Actions in the Sensorium beget a Sensation differing from what either +would do apart, that is a Sensation of a mean Colour between their +proper Colours; and particularly when by the concourse and mixtures of +all sorts of Rays, a white Colour is produced, the white is a mixture of +all the Colours which the Rays would have apart, (_Prop._ 5. _Part_ 2.) +The Rays in that mixture do not lose or alter their several colorific +qualities, but by all their various kinds of Actions mix'd in the +Sensorium, beget a Sensation of a middling Colour between all their +Colours, which is whiteness. For whiteness is a mean between all +Colours, having it self indifferently to them all, so as with equal +facility to be tinged with any of them. A red Powder mixed with a little +blue, or a blue with a little red, doth not presently lose its Colour, +but a white Powder mix'd with any Colour is presently tinged with that +Colour, and is equally capable of being tinged with any Colour whatever. +It has been shewed also, that as the Sun's Light is mix'd of all sorts +of Rays, so its whiteness is a mixture of the Colours of all sorts of +Rays; those Rays having from the beginning their several colorific +qualities as well as their several Refrangibilities, and retaining them +perpetually unchanged notwithstanding any Refractions or Reflexions they +may at any time suffer, and that whenever any sort of the Sun's Rays is +by any means (as by Reflexion in _Exper._ 9, and 10. _Part_ 1. or by +Refraction as happens in all Refractions) separated from the rest, they +then manifest their proper Colours. These things have been prov'd, and +the sum of all this amounts to the Proposition here to be proved. For if +the Sun's Light is mix'd of several sorts of Rays, each of which have +originally their several Refrangibilities and colorific Qualities, and +notwithstanding their Refractions and Reflexions, and their various +Separations or Mixtures, keep those their original Properties +perpetually the same without alteration; then all the Colours in the +World must be such as constantly ought to arise from the original +colorific qualities of the Rays whereof the Lights consist by which +those Colours are seen. And therefore if the reason of any Colour +whatever be required, we have nothing else to do than to consider how +the Rays in the Sun's Light have by Reflexions or Refractions, or other +causes, been parted from one another, or mixed together; or otherwise to +find out what sorts of Rays are in the Light by which that Colour is +made, and in what Proportion; and then by the last Problem to learn the +Colour which ought to arise by mixing those Rays (or their Colours) in +that proportion. I speak here of Colours so far as they arise from +Light. For they appear sometimes by other Causes, as when by the power +of Phantasy we see Colours in a Dream, or a Mad-man sees things before +him which are not there; or when we see Fire by striking the Eye, or see +Colours like the Eye of a Peacock's Feather, by pressing our Eyes in +either corner whilst we look the other way. Where these and such like +Causes interpose not, the Colour always answers to the sort or sorts of +the Rays whereof the Light consists, as I have constantly found in +whatever Phænomena of Colours I have hitherto been able to examine. I +shall in the following Propositions give instances of this in the +Phænomena of chiefest note. + + +_PROP._ VIII. PROB. III. + +_By the discovered Properties of Light to explain the Colours made by +Prisms._ + +Let ABC [in _Fig._ 12.] represent a Prism refracting the Light of the +Sun, which comes into a dark Chamber through a hole F[Greek: ph] almost +as broad as the Prism, and let MN represent a white Paper on which the +refracted Light is cast, and suppose the most refrangible or deepest +violet-making Rays fall upon the Space P[Greek: p], the least +refrangible or deepest red-making Rays upon the Space T[Greek: t], the +middle sort between the indigo-making and blue-making Rays upon the +Space Q[Greek: ch], the middle sort of the green-making Rays upon the +Space R, the middle sort between the yellow-making and orange-making +Rays upon the Space S[Greek: s], and other intermediate sorts upon +intermediate Spaces. For so the Spaces upon which the several sorts +adequately fall will by reason of the different Refrangibility of those +sorts be one lower than another. Now if the Paper MN be so near the +Prism that the Spaces PT and [Greek: pt] do not interfere with one +another, the distance between them T[Greek: p] will be illuminated by +all the sorts of Rays in that proportion to one another which they have +at their very first coming out of the Prism, and consequently be white. +But the Spaces PT and [Greek: pt] on either hand, will not be +illuminated by them all, and therefore will appear coloured. And +particularly at P, where the outmost violet-making Rays fall alone, the +Colour must be the deepest violet. At Q where the violet-making and +indigo-making Rays are mixed, it must be a violet inclining much to +indigo. At R where the violet-making, indigo-making, blue-making, and +one half of the green-making Rays are mixed, their Colours must (by the +construction of the second Problem) compound a middle Colour between +indigo and blue. At S where all the Rays are mixed, except the +red-making and orange-making, their Colours ought by the same Rule to +compound a faint blue, verging more to green than indigo. And in the +progress from S to T, this blue will grow more and more faint and +dilute, till at T, where all the Colours begin to be mixed, it ends in +whiteness. + +[Illustration: FIG. 12.] + +So again, on the other side of the white at [Greek: t], where the least +refrangible or utmost red-making Rays are alone, the Colour must be the +deepest red. At [Greek: s] the mixture of red and orange will compound a +red inclining to orange. At [Greek: r] the mixture of red, orange, +yellow, and one half of the green must compound a middle Colour between +orange and yellow. At [Greek: ch] the mixture of all Colours but violet +and indigo will compound a faint yellow, verging more to green than to +orange. And this yellow will grow more faint and dilute continually in +its progress from [Greek: ch] to [Greek: p], where by a mixture of all +sorts of Rays it will become white. + +These Colours ought to appear were the Sun's Light perfectly white: But +because it inclines to yellow, the Excess of the yellow-making Rays +whereby 'tis tinged with that Colour, being mixed with the faint blue +between S and T, will draw it to a faint green. And so the Colours in +order from P to [Greek: t] ought to be violet, indigo, blue, very faint +green, white, faint yellow, orange, red. Thus it is by the computation: +And they that please to view the Colours made by a Prism will find it so +in Nature. + +These are the Colours on both sides the white when the Paper is held +between the Prism and the Point X where the Colours meet, and the +interjacent white vanishes. For if the Paper be held still farther off +from the Prism, the most refrangible and least refrangible Rays will be +wanting in the middle of the Light, and the rest of the Rays which are +found there, will by mixture produce a fuller green than before. Also +the yellow and blue will now become less compounded, and by consequence +more intense than before. And this also agrees with experience. + +And if one look through a Prism upon a white Object encompassed with +blackness or darkness, the reason of the Colours arising on the edges is +much the same, as will appear to one that shall a little consider it. If +a black Object be encompassed with a white one, the Colours which appear +through the Prism are to be derived from the Light of the white one, +spreading into the Regions of the black, and therefore they appear in a +contrary order to that, when a white Object is surrounded with black. +And the same is to be understood when an Object is viewed, whose parts +are some of them less luminous than others. For in the borders of the +more and less luminous Parts, Colours ought always by the same +Principles to arise from the Excess of the Light of the more luminous, +and to be of the same kind as if the darker parts were black, but yet to +be more faint and dilute. + +What is said of Colours made by Prisms may be easily applied to Colours +made by the Glasses of Telescopes or Microscopes, or by the Humours of +the Eye. For if the Object-glass of a Telescope be thicker on one side +than on the other, or if one half of the Glass, or one half of the Pupil +of the Eye be cover'd with any opake substance; the Object-glass, or +that part of it or of the Eye which is not cover'd, may be consider'd as +a Wedge with crooked Sides, and every Wedge of Glass or other pellucid +Substance has the effect of a Prism in refracting the Light which passes +through it.[L] + +How the Colours in the ninth and tenth Experiments of the first Part +arise from the different Reflexibility of Light, is evident by what was +there said. But it is observable in the ninth Experiment, that whilst +the Sun's direct Light is yellow, the Excess of the blue-making Rays in +the reflected beam of Light MN, suffices only to bring that yellow to a +pale white inclining to blue, and not to tinge it with a manifestly blue +Colour. To obtain therefore a better blue, I used instead of the yellow +Light of the Sun the white Light of the Clouds, by varying a little the +Experiment, as follows. + +[Illustration: FIG. 13.] + +_Exper._ 16 Let HFG [in _Fig._ 13.] represent a Prism in the open Air, +and S the Eye of the Spectator, viewing the Clouds by their Light coming +into the Prism at the Plane Side FIGK, and reflected in it by its Base +HEIG, and thence going out through its Plane Side HEFK to the Eye. And +when the Prism and Eye are conveniently placed, so that the Angles of +Incidence and Reflexion at the Base may be about 40 Degrees, the +Spectator will see a Bow MN of a blue Colour, running from one End of +the Base to the other, with the Concave Side towards him, and the Part +of the Base IMNG beyond this Bow will be brighter than the other Part +EMNH on the other Side of it. This blue Colour MN being made by nothing +else than by Reflexion of a specular Superficies, seems so odd a +Phænomenon, and so difficult to be explained by the vulgar Hypothesis of +Philosophers, that I could not but think it deserved to be taken Notice +of. Now for understanding the Reason of it, suppose the Plane ABC to cut +the Plane Sides and Base of the Prism perpendicularly. From the Eye to +the Line BC, wherein that Plane cuts the Base, draw the Lines S_p_ and +S_t_, in the Angles S_pc_ 50 degr. 1/9, and S_tc_ 49 degr. 1/28, and the +Point _p_ will be the Limit beyond which none of the most refrangible +Rays can pass through the Base of the Prism, and be refracted, whose +Incidence is such that they may be reflected to the Eye; and the Point +_t_ will be the like Limit for the least refrangible Rays, that is, +beyond which none of them can pass through the Base, whose Incidence is +such that by Reflexion they may come to the Eye. And the Point _r_ taken +in the middle Way between _p_ and _t_, will be the like Limit for the +meanly refrangible Rays. And therefore all the least refrangible Rays +which fall upon the Base beyond _t_, that is, between _t_ and B, and can +come from thence to the Eye, will be reflected thither: But on this side +_t_, that is, between _t_ and _c_, many of these Rays will be +transmitted through the Base. And all the most refrangible Rays which +fall upon the Base beyond _p_, that is, between, _p_ and B, and can by +Reflexion come from thence to the Eye, will be reflected thither, but +every where between _p_ and _c_, many of these Rays will get through the +Base, and be refracted; and the same is to be understood of the meanly +refrangible Rays on either side of the Point _r_. Whence it follows, +that the Base of the Prism must every where between _t_ and B, by a +total Reflexion of all sorts of Rays to the Eye, look white and bright. +And every where between _p_ and C, by reason of the Transmission of many +Rays of every sort, look more pale, obscure, and dark. But at _r_, and +in other Places between _p_ and _t_, where all the more refrangible Rays +are reflected to the Eye, and many of the less refrangible are +transmitted, the Excess of the most refrangible in the reflected Light +will tinge that Light with their Colour, which is violet and blue. And +this happens by taking the Line C _prt_ B any where between the Ends of +the Prism HG and EI. + + +_PROP._ IX. PROB. IV. + +_By the discovered Properties of Light to explain the Colours of the +Rain-bow._ + +[Illustration: FIG. 14.] + +This Bow never appears, but where it rains in the Sun-shine, and may be +made artificially by spouting up Water which may break aloft, and +scatter into Drops, and fall down like Rain. For the Sun shining upon +these Drops certainly causes the Bow to appear to a Spectator standing +in a due Position to the Rain and Sun. And hence it is now agreed upon, +that this Bow is made by Refraction of the Sun's Light in drops of +falling Rain. This was understood by some of the Antients, and of late +more fully discover'd and explain'd by the famous _Antonius de Dominis_ +Archbishop of _Spalato_, in his book _De Radiis Visûs & Lucis_, +published by his Friend _Bartolus_ at _Venice_, in the Year 1611, and +written above 20 Years before. For he teaches there how the interior Bow +is made in round Drops of Rain by two Refractions of the Sun's Light, +and one Reflexion between them, and the exterior by two Refractions, and +two sorts of Reflexions between them in each Drop of Water, and proves +his Explications by Experiments made with a Phial full of Water, and +with Globes of Glass filled with Water, and placed in the Sun to make +the Colours of the two Bows appear in them. The same Explication +_Des-Cartes_ hath pursued in his Meteors, and mended that of the +exterior Bow. But whilst they understood not the true Origin of Colours, +it's necessary to pursue it here a little farther. For understanding +therefore how the Bow is made, let a Drop of Rain, or any other +spherical transparent Body be represented by the Sphere BNFG, [in _Fig._ +14.] described with the Center C, and Semi-diameter CN. And let AN be +one of the Sun's Rays incident upon it at N, and thence refracted to F, +where let it either go out of the Sphere by Refraction towards V, or be +reflected to G; and at G let it either go out by Refraction to R, or be +reflected to H; and at H let it go out by Refraction towards S, cutting +the incident Ray in Y. Produce AN and RG, till they meet in X, and upon +AX and NF, let fall the Perpendiculars CD and CE, and produce CD till it +fall upon the Circumference at L. Parallel to the incident Ray AN draw +the Diameter BQ, and let the Sine of Incidence out of Air into Water be +to the Sine of Refraction as I to R. Now, if you suppose the Point of +Incidence N to move from the Point B, continually till it come to L, the +Arch QF will first increase and then decrease, and so will the Angle AXR +which the Rays AN and GR contain; and the Arch QF and Angle AXR will be +biggest when ND is to CN as sqrt(II - RR) to sqrt(3)RR, in which +case NE will be to ND as 2R to I. Also the Angle AYS, which the Rays AN +and HS contain will first decrease, and then increase and grow least +when ND is to CN as sqrt(II - RR) to sqrt(8)RR, in which case NE +will be to ND, as 3R to I. And so the Angle which the next emergent Ray +(that is, the emergent Ray after three Reflexions) contains with the +incident Ray AN will come to its Limit when ND is to CN as sqrt(II - +RR) to sqrt(15)RR, in which case NE will be to ND as 4R to I. And the +Angle which the Ray next after that Emergent, that is, the Ray emergent +after four Reflexions, contains with the Incident, will come to its +Limit, when ND is to CN as sqrt(II - RR) to sqrt(24)RR, in which +case NE will be to ND as 5R to I; and so on infinitely, the Numbers 3, +8, 15, 24, &c. being gather'd by continual Addition of the Terms of the +arithmetical Progression 3, 5, 7, 9, &c. The Truth of all this +Mathematicians will easily examine.[M] + +Now it is to be observed, that as when the Sun comes to his Tropicks, +Days increase and decrease but a very little for a great while together; +so when by increasing the distance CD, these Angles come to their +Limits, they vary their quantity but very little for some time together, +and therefore a far greater number of the Rays which fall upon all the +Points N in the Quadrant BL, shall emerge in the Limits of these Angles, +than in any other Inclinations. And farther it is to be observed, that +the Rays which differ in Refrangibility will have different Limits of +their Angles of Emergence, and by consequence according to their +different Degrees of Refrangibility emerge most copiously in different +Angles, and being separated from one another appear each in their proper +Colours. And what those Angles are may be easily gather'd from the +foregoing Theorem by Computation. + +For in the least refrangible Rays the Sines I and R (as was found above) +are 108 and 81, and thence by Computation the greatest Angle AXR will be +found 42 Degrees and 2 Minutes, and the least Angle AYS, 50 Degrees and +57 Minutes. And in the most refrangible Rays the Sines I and R are 109 +and 81, and thence by Computation the greatest Angle AXR will be found +40 Degrees and 17 Minutes, and the least Angle AYS 54 Degrees and 7 +Minutes. + +Suppose now that O [in _Fig._ 15.] is the Spectator's Eye, and OP a Line +drawn parallel to the Sun's Rays and let POE, POF, POG, POH, be Angles +of 40 Degr. 17 Min. 42 Degr. 2 Min. 50 Degr. 57 Min. and 54 Degr. 7 Min. +respectively, and these Angles turned about their common Side OP, shall +with their other Sides OE, OF; OG, OH, describe the Verges of two +Rain-bows AF, BE and CHDG. For if E, F, G, H, be drops placed any where +in the conical Superficies described by OE, OF, OG, OH, and be +illuminated by the Sun's Rays SE, SF, SG, SH; the Angle SEO being equal +to the Angle POE, or 40 Degr. 17 Min. shall be the greatest Angle in +which the most refrangible Rays can after one Reflexion be refracted to +the Eye, and therefore all the Drops in the Line OE shall send the most +refrangible Rays most copiously to the Eye, and thereby strike the +Senses with the deepest violet Colour in that Region. And in like +manner the Angle SFO being equal to the Angle POF, or 42 Degr. 2 Min. +shall be the greatest in which the least refrangible Rays after one +Reflexion can emerge out of the Drops, and therefore those Rays shall +come most copiously to the Eye from the Drops in the Line OF, and strike +the Senses with the deepest red Colour in that Region. And by the same +Argument, the Rays which have intermediate Degrees of Refrangibility +shall come most copiously from Drops between E and F, and strike the +Senses with the intermediate Colours, in the Order which their Degrees +of Refrangibility require, that is in the Progress from E to F, or from +the inside of the Bow to the outside in this order, violet, indigo, +blue, green, yellow, orange, red. But the violet, by the mixture of the +white Light of the Clouds, will appear faint and incline to purple. + +[Illustration: FIG. 15.] + +Again, the Angle SGO being equal to the Angle POG, or 50 Gr. 51 Min. +shall be the least Angle in which the least refrangible Rays can after +two Reflexions emerge out of the Drops, and therefore the least +refrangible Rays shall come most copiously to the Eye from the Drops in +the Line OG, and strike the Sense with the deepest red in that Region. +And the Angle SHO being equal to the Angle POH, or 54 Gr. 7 Min. shall +be the least Angle, in which the most refrangible Rays after two +Reflexions can emerge out of the Drops; and therefore those Rays shall +come most copiously to the Eye from the Drops in the Line OH, and strike +the Senses with the deepest violet in that Region. And by the same +Argument, the Drops in the Regions between G and H shall strike the +Sense with the intermediate Colours in the Order which their Degrees of +Refrangibility require, that is, in the Progress from G to H, or from +the inside of the Bow to the outside in this order, red, orange, yellow, +green, blue, indigo, violet. And since these four Lines OE, OF, OG, OH, +may be situated any where in the above-mention'd conical Superficies; +what is said of the Drops and Colours in these Lines is to be understood +of the Drops and Colours every where in those Superficies. + +Thus shall there be made two Bows of Colours, an interior and stronger, +by one Reflexion in the Drops, and an exterior and fainter by two; for +the Light becomes fainter by every Reflexion. And their Colours shall +lie in a contrary Order to one another, the red of both Bows bordering +upon the Space GF, which is between the Bows. The Breadth of the +interior Bow EOF measured cross the Colours shall be 1 Degr. 45 Min. and +the Breadth of the exterior GOH shall be 3 Degr. 10 Min. and the +distance between them GOF shall be 8 Gr. 15 Min. the greatest +Semi-diameter of the innermost, that is, the Angle POF being 42 Gr. 2 +Min. and the least Semi-diameter of the outermost POG, being 50 Gr. 57 +Min. These are the Measures of the Bows, as they would be were the Sun +but a Point; for by the Breadth of his Body, the Breadth of the Bows +will be increased, and their Distance decreased by half a Degree, and so +the breadth of the interior Iris will be 2 Degr. 15 Min. that of the +exterior 3 Degr. 40 Min. their distance 8 Degr. 25 Min. the greatest +Semi-diameter of the interior Bow 42 Degr. 17 Min. and the least of the +exterior 50 Degr. 42 Min. And such are the Dimensions of the Bows in the +Heavens found to be very nearly, when their Colours appear strong and +perfect. For once, by such means as I then had, I measured the greatest +Semi-diameter of the interior Iris about 42 Degrees, and the breadth of +the red, yellow and green in that Iris 63 or 64 Minutes, besides the +outmost faint red obscured by the brightness of the Clouds, for which we +may allow 3 or 4 Minutes more. The breadth of the blue was about 40 +Minutes more besides the violet, which was so much obscured by the +brightness of the Clouds, that I could not measure its breadth. But +supposing the breadth of the blue and violet together to equal that of +the red, yellow and green together, the whole breadth of this Iris will +be about 2-1/4 Degrees, as above. The least distance between this Iris +and the exterior Iris was about 8 Degrees and 30 Minutes. The exterior +Iris was broader than the interior, but so faint, especially on the blue +side, that I could not measure its breadth distinctly. At another time +when both Bows appeared more distinct, I measured the breadth of the +interior Iris 2 Gr. 10´, and the breadth of the red, yellow and green in +the exterior Iris, was to the breadth of the same Colours in the +interior as 3 to 2. + +This Explication of the Rain-bow is yet farther confirmed by the known +Experiment (made by _Antonius de Dominis_ and _Des-Cartes_) of hanging +up any where in the Sun-shine a Glass Globe filled with Water, and +viewing it in such a posture, that the Rays which come from the Globe to +the Eye may contain with the Sun's Rays an Angle of either 42 or 50 +Degrees. For if the Angle be about 42 or 43 Degrees, the Spectator +(suppose at O) shall see a full red Colour in that side of the Globe +opposed to the Sun as 'tis represented at F, and if that Angle become +less (suppose by depressing the Globe to E) there will appear other +Colours, yellow, green and blue successive in the same side of the +Globe. But if the Angle be made about 50 Degrees (suppose by lifting up +the Globe to G) there will appear a red Colour in that side of the Globe +towards the Sun, and if the Angle be made greater (suppose by lifting +up the Globe to H) the red will turn successively to the other Colours, +yellow, green and blue. The same thing I have tried, by letting a Globe +rest, and raising or depressing the Eye, or otherwise moving it to make +the Angle of a just magnitude. + +I have heard it represented, that if the Light of a Candle be refracted +by a Prism to the Eye; when the blue Colour falls upon the Eye, the +Spectator shall see red in the Prism, and when the red falls upon the +Eye he shall see blue; and if this were certain, the Colours of the +Globe and Rain-bow ought to appear in a contrary order to what we find. +But the Colours of the Candle being very faint, the mistake seems to +arise from the difficulty of discerning what Colours fall on the Eye. +For, on the contrary, I have sometimes had occasion to observe in the +Sun's Light refracted by a Prism, that the Spectator always sees that +Colour in the Prism which falls upon his Eye. And the same I have found +true also in Candle-light. For when the Prism is moved slowly from the +Line which is drawn directly from the Candle to the Eye, the red appears +first in the Prism and then the blue, and therefore each of them is seen +when it falls upon the Eye. For the red passes over the Eye first, and +then the blue. + +The Light which comes through drops of Rain by two Refractions without +any Reflexion, ought to appear strongest at the distance of about 26 +Degrees from the Sun, and to decay gradually both ways as the distance +from him increases and decreases. And the same is to be understood of +Light transmitted through spherical Hail-stones. And if the Hail be a +little flatted, as it often is, the Light transmitted may grow so strong +at a little less distance than that of 26 Degrees, as to form a Halo +about the Sun or Moon; which Halo, as often as the Hail-stones are duly +figured may be colour'd, and then it must be red within by the least +refrangible Rays, and blue without by the most refrangible ones, +especially if the Hail-stones have opake Globules of Snow in their +center to intercept the Light within the Halo (as _Hugenius_ has +observ'd) and make the inside thereof more distinctly defined than it +would otherwise be. For such Hail-stones, though spherical, by +terminating the Light by the Snow, may make a Halo red within and +colourless without, and darker in the red than without, as Halos used to +be. For of those Rays which pass close by the Snow the Rubriform will be +least refracted, and so come to the Eye in the directest Lines. + +The Light which passes through a drop of Rain after two Refractions, and +three or more Reflexions, is scarce strong enough to cause a sensible +Bow; but in those Cylinders of Ice by which _Hugenius_ explains the +_Parhelia_, it may perhaps be sensible. + + +_PROP._ X. PROB. V. + +_By the discovered Properties of Light to explain the permanent Colours +of Natural Bodies._ + +These Colours arise from hence, that some natural Bodies reflect some +sorts of Rays, others other sorts more copiously than the rest. Minium +reflects the least refrangible or red-making Rays most copiously, and +thence appears red. Violets reflect the most refrangible most copiously, +and thence have their Colour, and so of other Bodies. Every Body +reflects the Rays of its own Colour more copiously than the rest, and +from their excess and predominance in the reflected Light has its +Colour. + +_Exper._ 17. For if in the homogeneal Lights obtained by the solution of +the Problem proposed in the fourth Proposition of the first Part of this +Book, you place Bodies of several Colours, you will find, as I have +done, that every Body looks most splendid and luminous in the Light of +its own Colour. Cinnaber in the homogeneal red Light is most +resplendent, in the green Light it is manifestly less resplendent, and +in the blue Light still less. Indigo in the violet blue Light is most +resplendent, and its splendor is gradually diminish'd, as it is removed +thence by degrees through the green and yellow Light to the red. By a +Leek the green Light, and next that the blue and yellow which compound +green, are more strongly reflected than the other Colours red and +violet, and so of the rest. But to make these Experiments the more +manifest, such Bodies ought to be chosen as have the fullest and most +vivid Colours, and two of those Bodies are to be compared together. +Thus, for instance, if Cinnaber and _ultra_-marine blue, or some other +full blue be held together in the red homogeneal Light, they will both +appear red, but the Cinnaber will appear of a strongly luminous and +resplendent red, and the _ultra_-marine blue of a faint obscure and dark +red; and if they be held together in the blue homogeneal Light, they +will both appear blue, but the _ultra_-marine will appear of a strongly +luminous and resplendent blue, and the Cinnaber of a faint and dark +blue. Which puts it out of dispute that the Cinnaber reflects the red +Light much more copiously than the _ultra_-marine doth, and the +_ultra_-marine reflects the blue Light much more copiously than the +Cinnaber doth. The same Experiment may be tried successfully with red +Lead and Indigo, or with any other two colour'd Bodies, if due allowance +be made for the different strength or weakness of their Colour and +Light. + +And as the reason of the Colours of natural Bodies is evident by these +Experiments, so it is farther confirmed and put past dispute by the two +first Experiments of the first Part, whereby 'twas proved in such Bodies +that the reflected Lights which differ in Colours do differ also in +degrees of Refrangibility. For thence it's certain, that some Bodies +reflect the more refrangible, others the less refrangible Rays more +copiously. + +And that this is not only a true reason of these Colours, but even the +only reason, may appear farther from this Consideration, that the Colour +of homogeneal Light cannot be changed by the Reflexion of natural +Bodies. + +For if Bodies by Reflexion cannot in the least change the Colour of any +one sort of Rays, they cannot appear colour'd by any other means than by +reflecting those which either are of their own Colour, or which by +mixture must produce it. + +But in trying Experiments of this kind care must be had that the Light +be sufficiently homogeneal. For if Bodies be illuminated by the ordinary +prismatick Colours, they will appear neither of their own Day-light +Colours, nor of the Colour of the Light cast on them, but of some middle +Colour between both, as I have found by Experience. Thus red Lead (for +instance) illuminated with the ordinary prismatick green will not appear +either red or green, but orange or yellow, or between yellow and green, +accordingly as the green Light by which 'tis illuminated is more or less +compounded. For because red Lead appears red when illuminated with white +Light, wherein all sorts of Rays are equally mix'd, and in the green +Light all sorts of Rays are not equally mix'd, the Excess of the +yellow-making, green-making and blue-making Rays in the incident green +Light, will cause those Rays to abound so much in the reflected Light, +as to draw the Colour from red towards their Colour. And because the red +Lead reflects the red-making Rays most copiously in proportion to their +number, and next after them the orange-making and yellow-making Rays; +these Rays in the reflected Light will be more in proportion to the +Light than they were in the incident green Light, and thereby will draw +the reflected Light from green towards their Colour. And therefore the +red Lead will appear neither red nor green, but of a Colour between +both. + +In transparently colour'd Liquors 'tis observable, that their Colour +uses to vary with their thickness. Thus, for instance, a red Liquor in a +conical Glass held between the Light and the Eye, looks of a pale and +dilute yellow at the bottom where 'tis thin, and a little higher where +'tis thicker grows orange, and where 'tis still thicker becomes red, and +where 'tis thickest the red is deepest and darkest. For it is to be +conceiv'd that such a Liquor stops the indigo-making and violet-making +Rays most easily, the blue-making Rays more difficultly, the +green-making Rays still more difficultly, and the red-making most +difficultly: And that if the thickness of the Liquor be only so much as +suffices to stop a competent number of the violet-making and +indigo-making Rays, without diminishing much the number of the rest, the +rest must (by _Prop._ 6. _Part_ 2.) compound a pale yellow. But if the +Liquor be so much thicker as to stop also a great number of the +blue-making Rays, and some of the green-making, the rest must compound +an orange; and where it is so thick as to stop also a great number of +the green-making and a considerable number of the yellow-making, the +rest must begin to compound a red, and this red must grow deeper and +darker as the yellow-making and orange-making Rays are more and more +stopp'd by increasing the thickness of the Liquor, so that few Rays +besides the red-making can get through. + +Of this kind is an Experiment lately related to me by Mr. _Halley_, who, +in diving deep into the Sea in a diving Vessel, found in a clear +Sun-shine Day, that when he was sunk many Fathoms deep into the Water +the upper part of his Hand on which the Sun shone directly through the +Water and through a small Glass Window in the Vessel appeared of a red +Colour, like that of a Damask Rose, and the Water below and the under +part of his Hand illuminated by Light reflected from the Water below +look'd green. For thence it may be gather'd, that the Sea-Water reflects +back the violet and blue-making Rays most easily, and lets the +red-making Rays pass most freely and copiously to great Depths. For +thereby the Sun's direct Light at all great Depths, by reason of the +predominating red-making Rays, must appear red; and the greater the +Depth is, the fuller and intenser must that red be. And at such Depths +as the violet-making Rays scarce penetrate unto, the blue-making, +green-making, and yellow-making Rays being reflected from below more +copiously than the red-making ones, must compound a green. + +Now, if there be two Liquors of full Colours, suppose a red and blue, +and both of them so thick as suffices to make their Colours sufficiently +full; though either Liquor be sufficiently transparent apart, yet will +you not be able to see through both together. For, if only the +red-making Rays pass through one Liquor, and only the blue-making +through the other, no Rays can pass through both. This Mr. _Hook_ tried +casually with Glass Wedges filled with red and blue Liquors, and was +surprized at the unexpected Event, the reason of it being then unknown; +which makes me trust the more to his Experiment, though I have not tried +it my self. But he that would repeat it, must take care the Liquors be +of very good and full Colours. + +Now, whilst Bodies become coloured by reflecting or transmitting this or +that sort of Rays more copiously than the rest, it is to be conceived +that they stop and stifle in themselves the Rays which they do not +reflect or transmit. For, if Gold be foliated and held between your Eye +and the Light, the Light looks of a greenish blue, and therefore massy +Gold lets into its Body the blue-making Rays to be reflected to and fro +within it till they be stopp'd and stifled, whilst it reflects the +yellow-making outwards, and thereby looks yellow. And much after the +same manner that Leaf Gold is yellow by reflected, and blue by +transmitted Light, and massy Gold is yellow in all Positions of the Eye; +there are some Liquors, as the Tincture of _Lignum Nephriticum_, and +some sorts of Glass which transmit one sort of Light most copiously, and +reflect another sort, and thereby look of several Colours, according to +the Position of the Eye to the Light. But, if these Liquors or Glasses +were so thick and massy that no Light could get through them, I question +not but they would like all other opake Bodies appear of one and the +same Colour in all Positions of the Eye, though this I cannot yet affirm +by Experience. For all colour'd Bodies, so far as my Observation +reaches, may be seen through if made sufficiently thin, and therefore +are in some measure transparent, and differ only in degrees of +Transparency from tinged transparent Liquors; these Liquors, as well as +those Bodies, by a sufficient Thickness becoming opake. A transparent +Body which looks of any Colour by transmitted Light, may also look of +the same Colour by reflected Light, the Light of that Colour being +reflected by the farther Surface of the Body, or by the Air beyond it. +And then the reflected Colour will be diminished, and perhaps cease, by +making the Body very thick, and pitching it on the backside to diminish +the Reflexion of its farther Surface, so that the Light reflected from +the tinging Particles may predominate. In such Cases, the Colour of the +reflected Light will be apt to vary from that of the Light transmitted. +But whence it is that tinged Bodies and Liquors reflect some sort of +Rays, and intromit or transmit other sorts, shall be said in the next +Book. In this Proposition I content my self to have put it past dispute, +that Bodies have such Properties, and thence appear colour'd. + + +_PROP._ XI. PROB. VI. + +_By mixing colour'd Lights to compound a beam of Light of the same +Colour and Nature with a beam of the Sun's direct Light, and therein to +experience the Truth of the foregoing Propositions._ + +[Illustration: FIG. 16.] + +Let ABC _abc_ [in _Fig._ 16.] represent a Prism, by which the Sun's +Light let into a dark Chamber through the Hole F, may be refracted +towards the Lens MN, and paint upon it at _p_, _q_, _r_, _s_, and _t_, +the usual Colours violet, blue, green, yellow, and red, and let the +diverging Rays by the Refraction of this Lens converge again towards X, +and there, by the mixture of all those their Colours, compound a white +according to what was shewn above. Then let another Prism DEG _deg_, +parallel to the former, be placed at X, to refract that white Light +upwards towards Y. Let the refracting Angles of the Prisms, and their +distances from the Lens be equal, so that the Rays which converged from +the Lens towards X, and without Refraction, would there have crossed and +diverged again, may by the Refraction of the second Prism be reduced +into Parallelism and diverge no more. For then those Rays will recompose +a beam of white Light XY. If the refracting Angle of either Prism be the +bigger, that Prism must be so much the nearer to the Lens. You will know +when the Prisms and the Lens are well set together, by observing if the +beam of Light XY, which comes out of the second Prism be perfectly white +to the very edges of the Light, and at all distances from the Prism +continue perfectly and totally white like a beam of the Sun's Light. For +till this happens, the Position of the Prisms and Lens to one another +must be corrected; and then if by the help of a long beam of Wood, as is +represented in the Figure, or by a Tube, or some other such Instrument, +made for that Purpose, they be made fast in that Situation, you may try +all the same Experiments in this compounded beam of Light XY, which have +been made in the Sun's direct Light. For this compounded beam of Light +has the same appearance, and is endow'd with all the same Properties +with a direct beam of the Sun's Light, so far as my Observation reaches. +And in trying Experiments in this beam you may by stopping any of the +Colours, _p_, _q_, _r_, _s_, and _t_, at the Lens, see how the Colours +produced in the Experiments are no other than those which the Rays had +at the Lens before they entered the Composition of this Beam: And by +consequence, that they arise not from any new Modifications of the Light +by Refractions and Reflexions, but from the various Separations and +Mixtures of the Rays originally endow'd with their colour-making +Qualities. + +So, for instance, having with a Lens 4-1/4 Inches broad, and two Prisms +on either hand 6-1/4 Feet distant from the Lens, made such a beam of +compounded Light; to examine the reason of the Colours made by Prisms, I +refracted this compounded beam of Light XY with another Prism HIK _kh_, +and thereby cast the usual Prismatick Colours PQRST upon the Paper LV +placed behind. And then by stopping any of the Colours _p_, _q_, _r_, +_s_, _t_, at the Lens, I found that the same Colour would vanish at the +Paper. So if the Purple _p_ was stopp'd at the Lens, the Purple P upon +the Paper would vanish, and the rest of the Colours would remain +unalter'd, unless perhaps the blue, so far as some purple latent in it +at the Lens might be separated from it by the following Refractions. And +so by intercepting the green upon the Lens, the green R upon the Paper +would vanish, and so of the rest; which plainly shews, that as the white +beam of Light XY was compounded of several Lights variously colour'd at +the Lens, so the Colours which afterwards emerge out of it by new +Refractions are no other than those of which its Whiteness was +compounded. The Refraction of the Prism HIK _kh_ generates the Colours +PQRST upon the Paper, not by changing the colorific Qualities of the +Rays, but by separating the Rays which had the very same colorific +Qualities before they enter'd the Composition of the refracted beam of +white Light XY. For otherwise the Rays which were of one Colour at the +Lens might be of another upon the Paper, contrary to what we find. + +So again, to examine the reason of the Colours of natural Bodies, I +placed such Bodies in the Beam of Light XY, and found that they all +appeared there of those their own Colours which they have in Day-light, +and that those Colours depend upon the Rays which had the same Colours +at the Lens before they enter'd the Composition of that beam. Thus, for +instance, Cinnaber illuminated by this beam appears of the same red +Colour as in Day-light; and if at the Lens you intercept the +green-making and blue-making Rays, its redness will become more full and +lively: But if you there intercept the red-making Rays, it will not any +longer appear red, but become yellow or green, or of some other Colour, +according to the sorts of Rays which you do not intercept. So Gold in +this Light XY appears of the same yellow Colour as in Day-light, but by +intercepting at the Lens a due Quantity of the yellow-making Rays it +will appear white like Silver (as I have tried) which shews that its +yellowness arises from the Excess of the intercepted Rays tinging that +Whiteness with their Colour when they are let pass. So the Infusion of +_Lignum Nephriticum_ (as I have also tried) when held in this beam of +Light XY, looks blue by the reflected Part of the Light, and red by the +transmitted Part of it, as when 'tis view'd in Day-light; but if you +intercept the blue at the Lens the Infusion will lose its reflected blue +Colour, whilst its transmitted red remains perfect, and by the loss of +some blue-making Rays, wherewith it was allay'd, becomes more intense +and full. And, on the contrary, if the red and orange-making Rays be +intercepted at the Lens, the Infusion will lose its transmitted red, +whilst its blue will remain and become more full and perfect. Which +shews, that the Infusion does not tinge the Rays with blue and red, but +only transmits those most copiously which were red-making before, and +reflects those most copiously which were blue-making before. And after +the same manner may the Reasons of other Phænomena be examined, by +trying them in this artificial beam of Light XY. + +FOOTNOTES: + +[I] See p. 59. + +[J] _See our_ Author's Lect. Optic. _Part_ II. _Sect._ II. _p._ 239. + +[K] _As is done in our_ Author's Lect. Optic. _Part_ I. _Sect._ III. +_and_ IV. _and Part_ II. _Sect._ II. + +[L] _See our_ Author's Lect. Optic. _Part_ II. _Sect._ II. _pag._ 269, +&c. + +[M] _This is demonstrated in our_ Author's Lect. Optic. _Part_ I. +_Sect._ IV. _Prop._ 35 _and_ 36. + + + + +THE + +SECOND BOOK + +OF + +OPTICKS + + + + +_PART I._ + +_Observations concerning the Reflexions, Refractions, and Colours of +thin transparent Bodies._ + + +It has been observed by others, that transparent Substances, as Glass, +Water, Air, &c. when made very thin by being blown into Bubbles, or +otherwise formed into Plates, do exhibit various Colours according to +their various thinness, altho' at a greater thickness they appear very +clear and colourless. In the former Book I forbore to treat of these +Colours, because they seemed of a more difficult Consideration, and were +not necessary for establishing the Properties of Light there discoursed +of. But because they may conduce to farther Discoveries for compleating +the Theory of Light, especially as to the constitution of the parts of +natural Bodies, on which their Colours or Transparency depend; I have +here set down an account of them. To render this Discourse short and +distinct, I have first described the principal of my Observations, and +then consider'd and made use of them. The Observations are these. + +_Obs._ 1. Compressing two Prisms hard together that their sides (which +by chance were a very little convex) might somewhere touch one another: +I found the place in which they touched to become absolutely +transparent, as if they had there been one continued piece of Glass. For +when the Light fell so obliquely on the Air, which in other places was +between them, as to be all reflected; it seemed in that place of contact +to be wholly transmitted, insomuch that when look'd upon, it appeared +like a black or dark spot, by reason that little or no sensible Light +was reflected from thence, as from other places; and when looked through +it seemed (as it were) a hole in that Air which was formed into a thin +Plate, by being compress'd between the Glasses. And through this hole +Objects that were beyond might be seen distinctly, which could not at +all be seen through other parts of the Glasses where the Air was +interjacent. Although the Glasses were a little convex, yet this +transparent spot was of a considerable breadth, which breadth seemed +principally to proceed from the yielding inwards of the parts of the +Glasses, by reason of their mutual pressure. For by pressing them very +hard together it would become much broader than otherwise. + +_Obs._ 2. When the Plate of Air, by turning the Prisms about their +common Axis, became so little inclined to the incident Rays, that some +of them began to be transmitted, there arose in it many slender Arcs of +Colours which at first were shaped almost like the Conchoid, as you see +them delineated in the first Figure. And by continuing the Motion of the +Prisms, these Arcs increased and bended more and more about the said +transparent spot, till they were compleated into Circles or Rings +incompassing it, and afterwards continually grew more and more +contracted. + +[Illustration: FIG. 1.] + +These Arcs at their first appearance were of a violet and blue Colour, +and between them were white Arcs of Circles, which presently by +continuing the Motion of the Prisms became a little tinged in their +inward Limbs with red and yellow, and to their outward Limbs the blue +was adjacent. So that the order of these Colours from the central dark +spot, was at that time white, blue, violet; black, red, orange, yellow, +white, blue, violet, &c. But the yellow and red were much fainter than +the blue and violet. + +The Motion of the Prisms about their Axis being continued, these Colours +contracted more and more, shrinking towards the whiteness on either +side of it, until they totally vanished into it. And then the Circles in +those parts appear'd black and white, without any other Colours +intermix'd. But by farther moving the Prisms about, the Colours again +emerged out of the whiteness, the violet and blue at its inward Limb, +and at its outward Limb the red and yellow. So that now their order from +the central Spot was white, yellow, red; black; violet, blue, white, +yellow, red, &c. contrary to what it was before. + +_Obs._ 3. When the Rings or some parts of them appeared only black and +white, they were very distinct and well defined, and the blackness +seemed as intense as that of the central Spot. Also in the Borders of +the Rings, where the Colours began to emerge out of the whiteness, they +were pretty distinct, which made them visible to a very great multitude. +I have sometimes number'd above thirty Successions (reckoning every +black and white Ring for one Succession) and seen more of them, which by +reason of their smalness I could not number. But in other Positions of +the Prisms, at which the Rings appeared of many Colours, I could not +distinguish above eight or nine of them, and the Exterior of those were +very confused and dilute. + +In these two Observations to see the Rings distinct, and without any +other Colour than Black and white, I found it necessary to hold my Eye +at a good distance from them. For by approaching nearer, although in the +same inclination of my Eye to the Plane of the Rings, there emerged a +bluish Colour out of the white, which by dilating it self more and more +into the black, render'd the Circles less distinct, and left the white a +little tinged with red and yellow. I found also by looking through a +slit or oblong hole, which was narrower than the pupil of my Eye, and +held close to it parallel to the Prisms, I could see the Circles much +distincter and visible to a far greater number than otherwise. + +_Obs._ 4. To observe more nicely the order of the Colours which arose +out of the white Circles as the Rays became less and less inclined to +the Plate of Air; I took two Object-glasses, the one a Plano-convex for +a fourteen Foot Telescope, and the other a large double Convex for one +of about fifty Foot; and upon this, laying the other with its plane side +downwards, I pressed them slowly together, to make the Colours +successively emerge in the middle of the Circles, and then slowly lifted +the upper Glass from the lower to make them successively vanish again in +the same place. The Colour, which by pressing the Glasses together, +emerged last in the middle of the other Colours, would upon its first +appearance look like a Circle of a Colour almost uniform from the +circumference to the center and by compressing the Glasses still more, +grow continually broader until a new Colour emerged in its center, and +thereby it became a Ring encompassing that new Colour. And by +compressing the Glasses still more, the diameter of this Ring would +increase, and the breadth of its Orbit or Perimeter decrease until +another new Colour emerged in the center of the last: And so on until a +third, a fourth, a fifth, and other following new Colours successively +emerged there, and became Rings encompassing the innermost Colour, the +last of which was the black Spot. And, on the contrary, by lifting up +the upper Glass from the lower, the diameter of the Rings would +decrease, and the breadth of their Orbit increase, until their Colours +reached successively to the center; and then they being of a +considerable breadth, I could more easily discern and distinguish their +Species than before. And by this means I observ'd their Succession and +Quantity to be as followeth. + +Next to the pellucid central Spot made by the contact of the Glasses +succeeded blue, white, yellow, and red. The blue was so little in +quantity, that I could not discern it in the Circles made by the Prisms, +nor could I well distinguish any violet in it, but the yellow and red +were pretty copious, and seemed about as much in extent as the white, +and four or five times more than the blue. The next Circuit in order of +Colours immediately encompassing these were violet, blue, green, yellow, +and red: and these were all of them copious and vivid, excepting the +green, which was very little in quantity, and seemed much more faint and +dilute than the other Colours. Of the other four, the violet was the +least in extent, and the blue less than the yellow or red. The third +Circuit or Order was purple, blue, green, yellow, and red; in which the +purple seemed more reddish than the violet in the former Circuit, and +the green was much more conspicuous, being as brisk and copious as any +of the other Colours, except the yellow, but the red began to be a +little faded, inclining very much to purple. After this succeeded the +fourth Circuit of green and red. The green was very copious and lively, +inclining on the one side to blue, and on the other side to yellow. But +in this fourth Circuit there was neither violet, blue, nor yellow, and +the red was very imperfect and dirty. Also the succeeding Colours became +more and more imperfect and dilute, till after three or four revolutions +they ended in perfect whiteness. Their form, when the Glasses were most +compress'd so as to make the black Spot appear in the center, is +delineated in the second Figure; where _a_, _b_, _c_, _d_, _e_: _f_, +_g_, _h_, _i_, _k_: _l_, _m_, _n_, _o_, _p_: _q_, _r_: _s_, _t_: _v_, +_x_: _y_, _z_, denote the Colours reckon'd in order from the center, +black, blue, white, yellow, red: violet, blue, green, yellow, red: +purple, blue, green, yellow, red: green, red: greenish blue, red: +greenish blue, pale red: greenish blue, reddish white. + +[Illustration: FIG. 2.] + +_Obs._ 5. To determine the interval of the Glasses, or thickness of the +interjacent Air, by which each Colour was produced, I measured the +Diameters of the first six Rings at the most lucid part of their Orbits, +and squaring them, I found their Squares to be in the arithmetical +Progression of the odd Numbers, 1, 3, 5, 7, 9, 11. And since one of +these Glasses was plane, and the other spherical, their Intervals at +those Rings must be in the same Progression. I measured also the +Diameters of the dark or faint Rings between the more lucid Colours, and +found their Squares to be in the arithmetical Progression of the even +Numbers, 2, 4, 6, 8, 10, 12. And it being very nice and difficult to +take these measures exactly; I repeated them divers times at divers +parts of the Glasses, that by their Agreement I might be confirmed in +them. And the same method I used in determining some others of the +following Observations. + +_Obs._ 6. The Diameter of the sixth Ring at the most lucid part of its +Orbit was 58/100 parts of an Inch, and the Diameter of the Sphere on +which the double convex Object-glass was ground was about 102 Feet, and +hence I gathered the thickness of the Air or Aereal Interval of the +Glasses at that Ring. But some time after, suspecting that in making +this Observation I had not determined the Diameter of the Sphere with +sufficient accurateness, and being uncertain whether the Plano-convex +Glass was truly plane, and not something concave or convex on that side +which I accounted plane; and whether I had not pressed the Glasses +together, as I often did, to make them touch; (For by pressing such +Glasses together their parts easily yield inwards, and the Rings thereby +become sensibly broader than they would be, did the Glasses keep their +Figures.) I repeated the Experiment, and found the Diameter of the sixth +lucid Ring about 55/100 parts of an Inch. I repeated the Experiment also +with such an Object-glass of another Telescope as I had at hand. This +was a double Convex ground on both sides to one and the same Sphere, and +its Focus was distant from it 83-2/5 Inches. And thence, if the Sines of +Incidence and Refraction of the bright yellow Light be assumed in +proportion as 11 to 17, the Diameter of the Sphere to which the Glass +was figured will by computation be found 182 Inches. This Glass I laid +upon a flat one, so that the black Spot appeared in the middle of the +Rings of Colours without any other Pressure than that of the weight of +the Glass. And now measuring the Diameter of the fifth dark Circle as +accurately as I could, I found it the fifth part of an Inch precisely. +This Measure was taken with the points of a pair of Compasses on the +upper Surface on the upper Glass, and my Eye was about eight or nine +Inches distance from the Glass, almost perpendicularly over it, and the +Glass was 1/6 of an Inch thick, and thence it is easy to collect that +the true Diameter of the Ring between the Glasses was greater than its +measur'd Diameter above the Glasses in the Proportion of 80 to 79, or +thereabouts, and by consequence equal to 16/79 parts of an Inch, and its +true Semi-diameter equal to 8/79 parts. Now as the Diameter of the +Sphere (182 Inches) is to the Semi-diameter of this fifth dark Ring +(8/79 parts of an Inch) so is this Semi-diameter to the thickness of the +Air at this fifth dark Ring; which is therefore 32/567931 or +100/1774784. Parts of an Inch; and the fifth Part thereof, _viz._ the +1/88739 Part of an Inch, is the Thickness of the Air at the first of +these dark Rings. + +The same Experiment I repeated with another double convex Object-glass +ground on both sides to one and the same Sphere. Its Focus was distant +from it 168-1/2 Inches, and therefore the Diameter of that Sphere was +184 Inches. This Glass being laid upon the same plain Glass, the +Diameter of the fifth of the dark Rings, when the black Spot in their +Center appear'd plainly without pressing the Glasses, was by the measure +of the Compasses upon the upper Glass 121/600 Parts of an Inch, and by +consequence between the Glasses it was 1222/6000: For the upper Glass +was 1/8 of an Inch thick, and my Eye was distant from it 8 Inches. And a +third proportional to half this from the Diameter of the Sphere is +5/88850 Parts of an Inch. This is therefore the Thickness of the Air at +this Ring, and a fifth Part thereof, _viz._ the 1/88850th Part of an +Inch is the Thickness thereof at the first of the Rings, as above. + +I tried the same Thing, by laying these Object-glasses upon flat Pieces +of a broken Looking-glass, and found the same Measures of the Rings: +Which makes me rely upon them till they can be determin'd more +accurately by Glasses ground to larger Spheres, though in such Glasses +greater care must be taken of a true Plane. + +These Dimensions were taken, when my Eye was placed almost +perpendicularly over the Glasses, being about an Inch, or an Inch and a +quarter, distant from the incident Rays, and eight Inches distant from +the Glass; so that the Rays were inclined to the Glass in an Angle of +about four Degrees. Whence by the following Observation you will +understand, that had the Rays been perpendicular to the Glasses, the +Thickness of the Air at these Rings would have been less in the +Proportion of the Radius to the Secant of four Degrees, that is, of +10000 to 10024. Let the Thicknesses found be therefore diminish'd in +this Proportion, and they will become 1/88952 and 1/89063, or (to use +the nearest round Number) the 1/89000th Part of an Inch. This is the +Thickness of the Air at the darkest Part of the first dark Ring made by +perpendicular Rays; and half this Thickness multiplied by the +Progression, 1, 3, 5, 7, 9, 11, &c. gives the Thicknesses of the Air at +the most luminous Parts of all the brightest Rings, _viz._ 1/178000, +3/178000, 5/178000, 7/178000, &c. their arithmetical Means 2/178000, +4/178000, 6/178000, &c. being its Thicknesses at the darkest Parts of +all the dark ones. + +_Obs._ 7. The Rings were least, when my Eye was placed perpendicularly +over the Glasses in the Axis of the Rings: And when I view'd them +obliquely they became bigger, continually swelling as I removed my Eye +farther from the Axis. And partly by measuring the Diameter of the same +Circle at several Obliquities of my Eye, partly by other Means, as also +by making use of the two Prisms for very great Obliquities, I found its +Diameter, and consequently the Thickness of the Air at its Perimeter in +all those Obliquities to be very nearly in the Proportions express'd in +this Table. + +-------------------+--------------------+----------+---------- +Angle of Incidence |Angle of Refraction |Diameter |Thickness + on | into | of the | of the + the Air. | the Air. | Ring. | Air. +-------------------+--------------------+----------+---------- + Deg. Min. | | | + | | | + 00 00 | 00 00 | 10 | 10 + | | | + 06 26 | 10 00 | 10-1/13 | 10-2/13 + | | | + 12 45 | 20 00 | 10-1/3 | 10-2/3 + | | | + 18 49 | 30 00 | 10-3/4 | 11-1/2 + | | | + 24 30 | 40 00 | 11-2/5 | 13 + | | | + 29 37 | 50 00 | 12-1/2 | 15-1/2 + | | | + 33 58 | 60 00 | 14 | 20 + | | | + 35 47 | 65 00 | 15-1/4 | 23-1/4 + | | | + 37 19 | 70 00 | 16-4/5 | 28-1/4 + | | | + 38 33 | 75 00 | 19-1/4 | 37 + | | | + 39 27 | 80 00 | 22-6/7 | 52-1/4 + | | | + 40 00 | 85 00 | 29 | 84-1/12 + | | | + 40 11 | 90 00 | 35 | 122-1/2 +-------------------+--------------------+----------+---------- + +In the two first Columns are express'd the Obliquities of the incident +and emergent Rays to the Plate of the Air, that is, their Angles of +Incidence and Refraction. In the third Column the Diameter of any +colour'd Ring at those Obliquities is expressed in Parts, of which ten +constitute that Diameter when the Rays are perpendicular. And in the +fourth Column the Thickness of the Air at the Circumference of that Ring +is expressed in Parts, of which also ten constitute its Thickness when +the Rays are perpendicular. + +And from these Measures I seem to gather this Rule: That the Thickness +of the Air is proportional to the Secant of an Angle, whose Sine is a +certain mean Proportional between the Sines of Incidence and Refraction. +And that mean Proportional, so far as by these Measures I can determine +it, is the first of an hundred and six arithmetical mean Proportionals +between those Sines counted from the bigger Sine, that is, from the Sine +of Refraction when the Refraction is made out of the Glass into the +Plate of Air, or from the Sine of Incidence when the Refraction is made +out of the Plate of Air into the Glass. + +_Obs._ 8. The dark Spot in the middle of the Rings increased also by the +Obliquation of the Eye, although almost insensibly. But, if instead of +the Object-glasses the Prisms were made use of, its Increase was more +manifest when viewed so obliquely that no Colours appear'd about it. It +was least when the Rays were incident most obliquely on the interjacent +Air, and as the obliquity decreased it increased more and more until the +colour'd Rings appear'd, and then decreased again, but not so much as it +increased before. And hence it is evident, that the Transparency was +not only at the absolute Contact of the Glasses, but also where they had +some little Interval. I have sometimes observed the Diameter of that +Spot to be between half and two fifth parts of the Diameter of the +exterior Circumference of the red in the first Circuit or Revolution of +Colours when view'd almost perpendicularly; whereas when view'd +obliquely it hath wholly vanish'd and become opake and white like the +other parts of the Glass; whence it may be collected that the Glasses +did then scarcely, or not at all, touch one another, and that their +Interval at the perimeter of that Spot when view'd perpendicularly was +about a fifth or sixth part of their Interval at the circumference of +the said red. + +_Obs._ 9. By looking through the two contiguous Object-glasses, I found +that the interjacent Air exhibited Rings of Colours, as well by +transmitting Light as by reflecting it. The central Spot was now white, +and from it the order of the Colours were yellowish red; black, violet, +blue, white, yellow, red; violet, blue, green, yellow, red, &c. But +these Colours were very faint and dilute, unless when the Light was +trajected very obliquely through the Glasses: For by that means they +became pretty vivid. Only the first yellowish red, like the blue in the +fourth Observation, was so little and faint as scarcely to be discern'd. +Comparing the colour'd Rings made by Reflexion, with these made by +transmission of the Light; I found that white was opposite to black, red +to blue, yellow to violet, and green to a Compound of red and violet. +That is, those parts of the Glass were black when looked through, which +when looked upon appeared white, and on the contrary. And so those which +in one case exhibited blue, did in the other case exhibit red. And the +like of the other Colours. The manner you have represented in the third +Figure, where AB, CD, are the Surfaces of the Glasses contiguous at E, +and the black Lines between them are their Distances in arithmetical +Progression, and the Colours written above are seen by reflected Light, +and those below by Light transmitted (p. 209). + +_Obs._ 10. Wetting the Object-glasses a little at their edges, the Water +crept in slowly between them, and the Circles thereby became less and +the Colours more faint: Insomuch that as the Water crept along, one half +of them at which it first arrived would appear broken off from the other +half, and contracted into a less Room. By measuring them I found the +Proportions of their Diameters to the Diameters of the like Circles made +by Air to be about seven to eight, and consequently the Intervals of the +Glasses at like Circles, caused by those two Mediums Water and Air, are +as about three to four. Perhaps it may be a general Rule, That if any +other Medium more or less dense than Water be compress'd between the +Glasses, their Intervals at the Rings caused thereby will be to their +Intervals caused by interjacent Air, as the Sines are which measure the +Refraction made out of that Medium into Air. + +_Obs._ 11. When the Water was between the Glasses, if I pressed the +upper Glass variously at its edges to make the Rings move nimbly from +one place to another, a little white Spot would immediately follow the +center of them, which upon creeping in of the ambient Water into that +place would presently vanish. Its appearance was such as interjacent Air +would have caused, and it exhibited the same Colours. But it was not +air, for where any Bubbles of Air were in the Water they would not +vanish. The Reflexion must have rather been caused by a subtiler Medium, +which could recede through the Glasses at the creeping in of the Water. + +_Obs._ 12. These Observations were made in the open Air. But farther to +examine the Effects of colour'd Light falling on the Glasses, I darken'd +the Room, and view'd them by Reflexion of the Colours of a Prism cast on +a Sheet of white Paper, my Eye being so placed that I could see the +colour'd Paper by Reflexion in the Glasses, as in a Looking-glass. And +by this means the Rings became distincter and visible to a far greater +number than in the open Air. I have sometimes seen more than twenty of +them, whereas in the open Air I could not discern above eight or nine. + +[Illustration: FIG. 3.] + +_Obs._ 13. Appointing an Assistant to move the Prism to and fro about +its Axis, that all the Colours might successively fall on that part of +the Paper which I saw by Reflexion from that part of the Glasses, where +the Circles appear'd, so that all the Colours might be successively +reflected from the Circles to my Eye, whilst I held it immovable, I +found the Circles which the red Light made to be manifestly bigger than +those which were made by the blue and violet. And it was very pleasant +to see them gradually swell or contract accordingly as the Colour of the +Light was changed. The Interval of the Glasses at any of the Rings when +they were made by the utmost red Light, was to their Interval at the +same Ring when made by the utmost violet, greater than as 3 to 2, and +less than as 13 to 8. By the most of my Observations it was as 14 to 9. +And this Proportion seem'd very nearly the same in all Obliquities of my +Eye; unless when two Prisms were made use of instead of the +Object-glasses. For then at a certain great obliquity of my Eye, the +Rings made by the several Colours seem'd equal, and at a greater +obliquity those made by the violet would be greater than the same Rings +made by the red: the Refraction of the Prism in this case causing the +most refrangible Rays to fall more obliquely on that plate of the Air +than the least refrangible ones. Thus the Experiment succeeded in the +colour'd Light, which was sufficiently strong and copious to make the +Rings sensible. And thence it may be gather'd, that if the most +refrangible and least refrangible Rays had been copious enough to make +the Rings sensible without the mixture of other Rays, the Proportion +which here was 14 to 9 would have been a little greater, suppose 14-1/4 +or 14-1/3 to 9. + +_Obs._ 14. Whilst the Prism was turn'd about its Axis with an uniform +Motion, to make all the several Colours fall successively upon the +Object-glasses, and thereby to make the Rings contract and dilate: The +Contraction or Dilatation of each Ring thus made by the variation of its +Colour was swiftest in the red, and slowest in the violet, and in the +intermediate Colours it had intermediate degrees of Celerity. Comparing +the quantity of Contraction and Dilatation made by all the degrees of +each Colour, I found that it was greatest in the red; less in the +yellow, still less in the blue, and least in the violet. And to make as +just an Estimation as I could of the Proportions of their Contractions +or Dilatations, I observ'd that the whole Contraction or Dilatation of +the Diameter of any Ring made by all the degrees of red, was to that of +the Diameter of the same Ring made by all the degrees of violet, as +about four to three, or five to four, and that when the Light was of the +middle Colour between yellow and green, the Diameter of the Ring was +very nearly an arithmetical Mean between the greatest Diameter of the +same Ring made by the outmost red, and the least Diameter thereof made +by the outmost violet: Contrary to what happens in the Colours of the +oblong Spectrum made by the Refraction of a Prism, where the red is most +contracted, the violet most expanded, and in the midst of all the +Colours is the Confine of green and blue. And hence I seem to collect +that the thicknesses of the Air between the Glasses there, where the +Ring is successively made by the limits of the five principal Colours +(red, yellow, green, blue, violet) in order (that is, by the extreme +red, by the limit of red and yellow in the middle of the orange, by the +limit of yellow and green, by the limit of green and blue, by the limit +of blue and violet in the middle of the indigo, and by the extreme +violet) are to one another very nearly as the sixth lengths of a Chord +which found the Notes in a sixth Major, _sol_, _la_, _mi_, _fa_, _sol_, +_la_. But it agrees something better with the Observation to say, that +the thicknesses of the Air between the Glasses there, where the Rings +are successively made by the limits of the seven Colours, red, orange, +yellow, green, blue, indigo, violet in order, are to one another as the +Cube Roots of the Squares of the eight lengths of a Chord, which found +the Notes in an eighth, _sol_, _la_, _fa_, _sol_, _la_, _mi_, _fa_, +_sol_; that is, as the Cube Roots of the Squares of the Numbers, 1, 8/9, +5/6, 3/4, 2/3, 3/5, 9/16, 1/2. + +_Obs._ 15. These Rings were not of various Colours like those made in +the open Air, but appeared all over of that prismatick Colour only with +which they were illuminated. And by projecting the prismatick Colours +immediately upon the Glasses, I found that the Light which fell on the +dark Spaces which were between the Colour'd Rings was transmitted +through the Glasses without any variation of Colour. For on a white +Paper placed behind, it would paint Rings of the same Colour with those +which were reflected, and of the bigness of their immediate Spaces. And +from thence the origin of these Rings is manifest; namely, that the Air +between the Glasses, according to its various thickness, is disposed in +some places to reflect, and in others to transmit the Light of any one +Colour (as you may see represented in the fourth Figure) and in the same +place to reflect that of one Colour where it transmits that of another. + +[Illustration: FIG. 4.] + +_Obs._ 16. The Squares of the Diameters of these Rings made by any +prismatick Colour were in arithmetical Progression, as in the fifth +Observation. And the Diameter of the sixth Circle, when made by the +citrine yellow, and viewed almost perpendicularly was about 58/100 parts +of an Inch, or a little less, agreeable to the sixth Observation. + +The precedent Observations were made with a rarer thin Medium, +terminated by a denser, such as was Air or Water compress'd between two +Glasses. In those that follow are set down the Appearances of a denser +Medium thin'd within a rarer, such as are Plates of Muscovy Glass, +Bubbles of Water, and some other thin Substances terminated on all sides +with air. + +_Obs._ 17. If a Bubble be blown with Water first made tenacious by +dissolving a little Soap in it, 'tis a common Observation, that after a +while it will appear tinged with a great variety of Colours. To defend +these Bubbles from being agitated by the external Air (whereby their +Colours are irregularly moved one among another, so that no accurate +Observation can be made of them,) as soon as I had blown any of them I +cover'd it with a clear Glass, and by that means its Colours emerged in +a very regular order, like so many concentrick Rings encompassing the +top of the Bubble. And as the Bubble grew thinner by the continual +subsiding of the Water, these Rings dilated slowly and overspread the +whole Bubble, descending in order to the bottom of it, where they +vanish'd successively. In the mean while, after all the Colours were +emerged at the top, there grew in the center of the Rings a small round +black Spot, like that in the first Observation, which continually +dilated it self till it became sometimes more than 1/2 or 3/4 of an Inch +in breadth before the Bubble broke. At first I thought there had been no +Light reflected from the Water in that place, but observing it more +curiously, I saw within it several smaller round Spots, which appeared +much blacker and darker than the rest, whereby I knew that there was +some Reflexion at the other places which were not so dark as those +Spots. And by farther Tryal I found that I could see the Images of some +things (as of a Candle or the Sun) very faintly reflected, not only from +the great black Spot, but also from the little darker Spots which were +within it. + +Besides the aforesaid colour'd Rings there would often appear small +Spots of Colours, ascending and descending up and down the sides of the +Bubble, by reason of some Inequalities in the subsiding of the Water. +And sometimes small black Spots generated at the sides would ascend up +to the larger black Spot at the top of the Bubble, and unite with it. + +_Obs._ 18. Because the Colours of these Bubbles were more extended and +lively than those of the Air thinn'd between two Glasses, and so more +easy to be distinguish'd, I shall here give you a farther description of +their order, as they were observ'd in viewing them by Reflexion of the +Skies when of a white Colour, whilst a black substance was placed +behind the Bubble. And they were these, red, blue; red, blue; red, blue; +red, green; red, yellow, green, blue, purple; red, yellow, green, blue, +violet; red, yellow, white, blue, black. + +The three first Successions of red and blue were very dilute and dirty, +especially the first, where the red seem'd in a manner to be white. +Among these there was scarce any other Colour sensible besides red and +blue, only the blues (and principally the second blue) inclined a little +to green. + +The fourth red was also dilute and dirty, but not so much as the former +three; after that succeeded little or no yellow, but a copious green, +which at first inclined a little to yellow, and then became a pretty +brisk and good willow green, and afterwards changed to a bluish Colour; +but there succeeded neither blue nor violet. + +The fifth red at first inclined very much to purple, and afterwards +became more bright and brisk, but yet not very pure. This was succeeded +with a very bright and intense yellow, which was but little in quantity, +and soon chang'd to green: But that green was copious and something more +pure, deep and lively, than the former green. After that follow'd an +excellent blue of a bright Sky-colour, and then a purple, which was less +in quantity than the blue, and much inclined to red. + +The sixth red was at first of a very fair and lively scarlet, and soon +after of a brighter Colour, being very pure and brisk, and the best of +all the reds. Then after a lively orange follow'd an intense bright and +copious yellow, which was also the best of all the yellows, and this +changed first to a greenish yellow, and then to a greenish blue; but the +green between the yellow and the blue, was very little and dilute, +seeming rather a greenish white than a green. The blue which succeeded +became very good, and of a very bright Sky-colour, but yet something +inferior to the former blue; and the violet was intense and deep with +little or no redness in it. And less in quantity than the blue. + +In the last red appeared a tincture of scarlet next to violet, which +soon changed to a brighter Colour, inclining to an orange; and the +yellow which follow'd was at first pretty good and lively, but +afterwards it grew more dilute until by degrees it ended in perfect +whiteness. And this whiteness, if the Water was very tenacious and +well-temper'd, would slowly spread and dilate it self over the greater +part of the Bubble; continually growing paler at the top, where at +length it would crack in many places, and those cracks, as they dilated, +would appear of a pretty good, but yet obscure and dark Sky-colour; the +white between the blue Spots diminishing, until it resembled the Threds +of an irregular Net-work, and soon after vanish'd, and left all the +upper part of the Bubble of the said dark blue Colour. And this Colour, +after the aforesaid manner, dilated it self downwards, until sometimes +it hath overspread the whole Bubble. In the mean while at the top, which +was of a darker blue than the bottom, and appear'd also full of many +round blue Spots, something darker than the rest, there would emerge +one or more very black Spots, and within those, other Spots of an +intenser blackness, which I mention'd in the former Observation; and +these continually dilated themselves until the Bubble broke. + +If the Water was not very tenacious, the black Spots would break forth +in the white, without any sensible intervention of the blue. And +sometimes they would break forth within the precedent yellow, or red, or +perhaps within the blue of the second order, before the intermediate +Colours had time to display themselves. + +By this description you may perceive how great an affinity these Colours +have with those of Air described in the fourth Observation, although set +down in a contrary order, by reason that they begin to appear when the +Bubble is thickest, and are most conveniently reckon'd from the lowest +and thickest part of the Bubble upwards. + +_Obs._ 19. Viewing in several oblique Positions of my Eye the Rings of +Colours emerging on the top of the Bubble, I found that they were +sensibly dilated by increasing the obliquity, but yet not so much by far +as those made by thinn'd Air in the seventh Observation. For there they +were dilated so much as, when view'd most obliquely, to arrive at a part +of the Plate more than twelve times thicker than that where they +appear'd when viewed perpendicularly; whereas in this case the thickness +of the Water, at which they arrived when viewed most obliquely, was to +that thickness which exhibited them by perpendicular Rays, something +less than as 8 to 5. By the best of my Observations it was between 15 +and 15-1/2 to 10; an increase about 24 times less than in the other +case. + +Sometimes the Bubble would become of an uniform thickness all over, +except at the top of it near the black Spot, as I knew, because it would +exhibit the same appearance of Colours in all Positions of the Eye. And +then the Colours which were seen at its apparent circumference by the +obliquest Rays, would be different from those that were seen in other +places, by Rays less oblique to it. And divers Spectators might see the +same part of it of differing Colours, by viewing it at very differing +Obliquities. Now observing how much the Colours at the same places of +the Bubble, or at divers places of equal thickness, were varied by the +several Obliquities of the Rays; by the assistance of the 4th, 14th, +16th and 18th Observations, as they are hereafter explain'd, I collect +the thickness of the Water requisite to exhibit any one and the same +Colour, at several Obliquities, to be very nearly in the Proportion +expressed in this Table. + +-----------------+------------------+---------------- + Incidence on | Refraction into | Thickness of + the Water. | the Water. | the Water. +-----------------+------------------+---------------- + Deg. Min. | Deg. Min. | + | | + 00 00 | 00 00 | 10 + | | + 15 00 | 11 11 | 10-1/4 + | | + 30 00 | 22 1 | 10-4/5 + | | + 45 00 | 32 2 | 11-4/5 + | | + 60 00 | 40 30 | 13 + | | + 75 00 | 46 25 | 14-1/2 + | | + 90 00 | 48 35 | 15-1/5 +-----------------+------------------+---------------- + +In the two first Columns are express'd the Obliquities of the Rays to +the Superficies of the Water, that is, their Angles of Incidence and +Refraction. Where I suppose, that the Sines which measure them are in +round Numbers, as 3 to 4, though probably the Dissolution of Soap in the +Water, may a little alter its refractive Virtue. In the third Column, +the Thickness of the Bubble, at which any one Colour is exhibited in +those several Obliquities, is express'd in Parts, of which ten +constitute its Thickness when the Rays are perpendicular. And the Rule +found by the seventh Observation agrees well with these Measures, if +duly apply'd; namely, that the Thickness of a Plate of Water requisite +to exhibit one and the same Colour at several Obliquities of the Eye, is +proportional to the Secant of an Angle, whose Sine is the first of an +hundred and six arithmetical mean Proportionals between the Sines of +Incidence and Refraction counted from the lesser Sine, that is, from the +Sine of Refraction when the Refraction is made out of Air into Water, +otherwise from the Sine of Incidence. + +I have sometimes observ'd, that the Colours which arise on polish'd +Steel by heating it, or on Bell-metal, and some other metalline +Substances, when melted and pour'd on the Ground, where they may cool in +the open Air, have, like the Colours of Water-bubbles, been a little +changed by viewing them at divers Obliquities, and particularly that a +deep blue, or violet, when view'd very obliquely, hath been changed to a +deep red. But the Changes of these Colours are not so great and +sensible as of those made by Water. For the Scoria, or vitrified Part of +the Metal, which most Metals when heated or melted do continually +protrude, and send out to their Surface, and which by covering the +Metals in form of a thin glassy Skin, causes these Colours, is much +denser than Water; and I find that the Change made by the Obliquation of +the Eye is least in Colours of the densest thin Substances. + +_Obs._ 20. As in the ninth Observation, so here, the Bubble, by +transmitted Light, appear'd of a contrary Colour to that, which it +exhibited by Reflexion. Thus when the Bubble being look'd on by the +Light of the Clouds reflected from it, seemed red at its apparent +Circumference, if the Clouds at the same time, or immediately after, +were view'd through it, the Colour at its Circumference would be blue. +And, on the contrary, when by reflected Light it appeared blue, it would +appear red by transmitted Light. + +_Obs._ 21. By wetting very thin Plates of _Muscovy_ Glass, whose +thinness made the like Colours appear, the Colours became more faint and +languid, especially by wetting the Plates on that side opposite to the +Eye: But I could not perceive any variation of their Species. So then +the thickness of a Plate requisite to produce any Colour, depends only +on the density of the Plate, and not on that of the ambient Medium. And +hence, by the 10th and 16th Observations, may be known the thickness +which Bubbles of Water, or Plates of _Muscovy_ Glass, or other +Substances, have at any Colour produced by them. + +_Obs._ 22. A thin transparent Body, which is denser than its ambient +Medium, exhibits more brisk and vivid Colours than that which is so much +rarer; as I have particularly observed in the Air and Glass. For blowing +Glass very thin at a Lamp Furnace, those Plates encompassed with Air did +exhibit Colours much more vivid than those of Air made thin between two +Glasses. + +_Obs._ 23. Comparing the quantity of Light reflected from the several +Rings, I found that it was most copious from the first or inmost, and in +the exterior Rings became gradually less and less. Also the whiteness of +the first Ring was stronger than that reflected from those parts of the +thin Medium or Plate which were without the Rings; as I could manifestly +perceive by viewing at a distance the Rings made by the two +Object-glasses; or by comparing two Bubbles of Water blown at distant +Times, in the first of which the Whiteness appear'd, which succeeded all +the Colours, and in the other, the Whiteness which preceded them all. + +_Obs._ 24. When the two Object-glasses were lay'd upon one another, so +as to make the Rings of the Colours appear, though with my naked Eye I +could not discern above eight or nine of those Rings, yet by viewing +them through a Prism I have seen a far greater Multitude, insomuch that +I could number more than forty, besides many others, that were so very +small and close together, that I could not keep my Eye steady on them +severally so as to number them, but by their Extent I have sometimes +estimated them to be more than an hundred. And I believe the Experiment +may be improved to the Discovery of far greater Numbers. For they seem +to be really unlimited, though visible only so far as they can be +separated by the Refraction of the Prism, as I shall hereafter explain. + +[Illustration: FIG. 5.] + +But it was but one side of these Rings, namely, that towards which the +Refraction was made, which by that Refraction was render'd distinct, and +the other side became more confused than when view'd by the naked Eye, +insomuch that there I could not discern above one or two, and sometimes +none of those Rings, of which I could discern eight or nine with my +naked Eye. And their Segments or Arcs, which on the other side appear'd +so numerous, for the most part exceeded not the third Part of a Circle. +If the Refraction was very great, or the Prism very distant from the +Object-glasses, the middle Part of those Arcs became also confused, so +as to disappear and constitute an even Whiteness, whilst on either side +their Ends, as also the whole Arcs farthest from the Center, became +distincter than before, appearing in the Form as you see them design'd +in the fifth Figure. + +The Arcs, where they seem'd distinctest, were only white and black +successively, without any other Colours intermix'd. But in other Places +there appeared Colours, whose Order was inverted by the refraction in +such manner, that if I first held the Prism very near the +Object-glasses, and then gradually removed it farther off towards my +Eye, the Colours of the 2d, 3d, 4th, and following Rings, shrunk towards +the white that emerged between them, until they wholly vanish'd into it +at the middle of the Arcs, and afterwards emerged again in a contrary +Order. But at the Ends of the Arcs they retain'd their Order unchanged. + +I have sometimes so lay'd one Object-glass upon the other, that to the +naked Eye they have all over seem'd uniformly white, without the least +Appearance of any of the colour'd Rings; and yet by viewing them through +a Prism, great Multitudes of those Rings have discover'd themselves. And +in like manner Plates of _Muscovy_ Glass, and Bubbles of Glass blown at +a Lamp-Furnace, which were not so thin as to exhibit any Colours to the +naked Eye, have through the Prism exhibited a great Variety of them +ranged irregularly up and down in the Form of Waves. And so Bubbles of +Water, before they began to exhibit their Colours to the naked Eye of a +Bystander, have appeared through a Prism, girded about with many +parallel and horizontal Rings; to produce which Effect, it was necessary +to hold the Prism parallel, or very nearly parallel to the Horizon, and +to dispose it so that the Rays might be refracted upwards. + + + + +THE + +SECOND BOOK + +OF + +OPTICKS + + +_PART II._ + +_Remarks upon the foregoing Observations._ + + +Having given my Observations of these Colours, before I make use of them +to unfold the Causes of the Colours of natural Bodies, it is convenient +that by the simplest of them, such as are the 2d, 3d, 4th, 9th, 12th, +18th, 20th, and 24th, I first explain the more compounded. And first to +shew how the Colours in the fourth and eighteenth Observations are +produced, let there be taken in any Right Line from the Point Y, [in +_Fig._ 6.] the Lengths YA, YB, YC, YD, YE, YF, YG, YH, in proportion to +one another, as the Cube-Roots of the Squares of the Numbers, 1/2, 9/16, +3/5, 2/3, 3/4, 5/6, 8/9, 1, whereby the Lengths of a Musical Chord to +sound all the Notes in an eighth are represented; that is, in the +Proportion of the Numbers 6300, 6814, 7114, 7631, 8255, 8855, 9243, +10000. And at the Points A, B, C, D, E, F, G, H, let Perpendiculars +A[Greek: a], B[Greek: b], &c. be erected, by whose Intervals the Extent +of the several Colours set underneath against them, is to be +represented. Then divide the Line _A[Greek: a]_ in such Proportion as +the Numbers 1, 2, 3, 5, 6, 7, 9, 10, 11, &c. set at the Points of +Division denote. And through those Divisions from Y draw Lines 1I, 2K, +3L, 5M, 6N, 7O, &c. + +Now, if A2 be supposed to represent the Thickness of any thin +transparent Body, at which the outmost Violet is most copiously +reflected in the first Ring, or Series of Colours, then by the 13th +Observation, HK will represent its Thickness, at which the utmost Red is +most copiously reflected in the same Series. Also by the 5th and 16th +Observations, A6 and HN will denote the Thicknesses at which those +extreme Colours are most copiously reflected in the second Series, and +A10 and HQ the Thicknesses at which they are most copiously reflected in +the third Series, and so on. And the Thickness at which any of the +intermediate Colours are reflected most copiously, will, according to +the 14th Observation, be defined by the distance of the Line AH from the +intermediate parts of the Lines 2K, 6N, 10Q, &c. against which the Names +of those Colours are written below. + +[Illustration: FIG. 6.] + +But farther, to define the Latitude of these Colours in each Ring or +Series, let A1 design the least thickness, and A3 the greatest +thickness, at which the extreme violet in the first Series is reflected, +and let HI, and HL, design the like limits for the extreme red, and let +the intermediate Colours be limited by the intermediate parts of the +Lines 1I, and 3L, against which the Names of those Colours are written, +and so on: But yet with this caution, that the Reflexions be supposed +strongest at the intermediate Spaces, 2K, 6N, 10Q, &c. and from thence +to decrease gradually towards these limits, 1I, 3L, 5M, 7O, &c. on +either side; where you must not conceive them to be precisely limited, +but to decay indefinitely. And whereas I have assign'd the same Latitude +to every Series, I did it, because although the Colours in the first +Series seem to be a little broader than the rest, by reason of a +stronger Reflexion there, yet that inequality is so insensible as +scarcely to be determin'd by Observation. + +Now according to this Description, conceiving that the Rays originally +of several Colours are by turns reflected at the Spaces 1I, L3, 5M, O7, +9PR11, &c. and transmitted at the Spaces AHI1, 3LM5, 7OP9, &c. it is +easy to know what Colour must in the open Air be exhibited at any +thickness of a transparent thin Body. For if a Ruler be applied parallel +to AH, at that distance from it by which the thickness of the Body is +represented, the alternate Spaces 1IL3, 5MO7, &c. which it crosseth will +denote the reflected original Colours, of which the Colour exhibited in +the open Air is compounded. Thus if the constitution of the green in the +third Series of Colours be desired, apply the Ruler as you see at +[Greek: prsph], and by its passing through some of the blue at [Greek: +p] and yellow at [Greek: s], as well as through the green at [Greek: r], +you may conclude that the green exhibited at that thickness of the Body +is principally constituted of original green, but not without a mixture +of some blue and yellow. + +By this means you may know how the Colours from the center of the Rings +outward ought to succeed in order as they were described in the 4th and +18th Observations. For if you move the Ruler gradually from AH through +all distances, having pass'd over the first Space which denotes little +or no Reflexion to be made by thinnest Substances, it will first arrive +at 1 the violet, and then very quickly at the blue and green, which +together with that violet compound blue, and then at the yellow and red, +by whose farther addition that blue is converted into whiteness, which +whiteness continues during the transit of the edge of the Ruler from I +to 3, and after that by the successive deficience of its component +Colours, turns first to compound yellow, and then to red, and last of +all the red ceaseth at L. Then begin the Colours of the second Series, +which succeed in order during the transit of the edge of the Ruler from +5 to O, and are more lively than before, because more expanded and +severed. And for the same reason instead of the former white there +intercedes between the blue and yellow a mixture of orange, yellow, +green, blue and indigo, all which together ought to exhibit a dilute and +imperfect green. So the Colours of the third Series all succeed in +order; first, the violet, which a little interferes with the red of the +second order, and is thereby inclined to a reddish purple; then the blue +and green, which are less mix'd with other Colours, and consequently +more lively than before, especially the green: Then follows the yellow, +some of which towards the green is distinct and good, but that part of +it towards the succeeding red, as also that red is mix'd with the violet +and blue of the fourth Series, whereby various degrees of red very much +inclining to purple are compounded. This violet and blue, which should +succeed this red, being mixed with, and hidden in it, there succeeds a +green. And this at first is much inclined to blue, but soon becomes a +good green, the only unmix'd and lively Colour in this fourth Series. +For as it verges towards the yellow, it begins to interfere with the +Colours of the fifth Series, by whose mixture the succeeding yellow and +red are very much diluted and made dirty, especially the yellow, which +being the weaker Colour is scarce able to shew it self. After this the +several Series interfere more and more, and their Colours become more +and more intermix'd, till after three or four more revolutions (in which +the red and blue predominate by turns) all sorts of Colours are in all +places pretty equally blended, and compound an even whiteness. + +And since by the 15th Observation the Rays endued with one Colour are +transmitted, where those of another Colour are reflected, the reason of +the Colours made by the transmitted Light in the 9th and 20th +Observations is from hence evident. + +If not only the Order and Species of these Colours, but also the precise +thickness of the Plate, or thin Body at which they are exhibited, be +desired in parts of an Inch, that may be also obtained by assistance of +the 6th or 16th Observations. For according to those Observations the +thickness of the thinned Air, which between two Glasses exhibited the +most luminous parts of the first six Rings were 1/178000, 3/178000, +5/178000, 7/178000, 9/178000, 11/178000 parts of an Inch. Suppose the +Light reflected most copiously at these thicknesses be the bright +citrine yellow, or confine of yellow and orange, and these thicknesses +will be F[Greek: l], F[Greek: m], F[Greek: u], F[Greek: x], F[Greek: o], +F[Greek: t]. And this being known, it is easy to determine what +thickness of Air is represented by G[Greek: ph], or by any other +distance of the Ruler from AH. + +But farther, since by the 10th Observation the thickness of Air was to +the thickness of Water, which between the same Glasses exhibited the +same Colour, as 4 to 3, and by the 21st Observation the Colours of thin +Bodies are not varied by varying the ambient Medium; the thickness of a +Bubble of Water, exhibiting any Colour, will be 3/4 of the thickness of +Air producing the same Colour. And so according to the same 10th and +21st Observations, the thickness of a Plate of Glass, whose Refraction +of the mean refrangible Ray, is measured by the proportion of the Sines +31 to 20, may be 20/31 of the thickness of Air producing the same +Colours; and the like of other Mediums. I do not affirm, that this +proportion of 20 to 31, holds in all the Rays; for the Sines of other +sorts of Rays have other Proportions. But the differences of those +Proportions are so little that I do not here consider them. On these +Grounds I have composed the following Table, wherein the thickness of +Air, Water, and Glass, at which each Colour is most intense and +specifick, is expressed in parts of an Inch divided into ten hundred +thousand equal parts. + +Now if this Table be compared with the 6th Scheme, you will there see +the constitution of each Colour, as to its Ingredients, or the original +Colours of which it is compounded, and thence be enabled to judge of its +Intenseness or Imperfection; which may suffice in explication of the 4th +and 18th Observations, unless it be farther desired to delineate the +manner how the Colours appear, when the two Object-glasses are laid upon +one another. To do which, let there be described a large Arc of a +Circle, and a streight Line which may touch that Arc, and parallel to +that Tangent several occult Lines, at such distances from it, as the +Numbers set against the several Colours in the Table denote. For the +Arc, and its Tangent, will represent the Superficies of the Glasses +terminating the interjacent Air; and the places where the occult Lines +cut the Arc will show at what distances from the center, or Point of +contact, each Colour is reflected. + +_The thickness of colour'd Plates and Particles of_ + _____________|_______________ + / \ + Air. Water. Glass. + |---------+----------+----------+ + {Very black | 1/2 | 3/8 | 10/31 | + {Black | 1 | 3/4 | 20/31 | + {Beginning of | | | | + { Black | 2 | 1-1/2 | 1-2/7 | +Their Colours of the {Blue | 2-2/5 | 1-4/5 | 1-11/22 | +first Order, {White | 5-1/4 | 3-7/8 | 3-2/5 | + {Yellow | 7-1/9 | 5-1/3 | 4-3/5 | + {Orange | 8 | 6 | 5-1/6 | + {Red | 9 | 6-3/4 | 5-4/5 | + |---------+----------+----------| + {Violet | 11-1/6 | 8-3/8 | 7-1/5 | + {Indigo | 12-5/6 | 9-5/8 | 8-2/11 | + {Blue | 14 | 10-1/2 | 9 | + {Green | 15-1/8 | 11-2/3 | 9-5/7 | +Of the second order, {Yellow | 16-2/7 | 12-1/5 | 10-2/5 | + {Orange | 17-2/9 | 13 | 11-1/9 | + {Bright red | 18-1/3 | 13-3/4 | 11-5/6 | + {Scarlet | 19-2/3 | 14-3/4 | 12-2/3 | + |---------+----------+----------| + {Purple | 21 | 15-3/4 | 13-11/20 | + {Indigo | 22-1/10 | 16-4/7 | 14-1/4 | + {Blue | 23-2/5 | 17-11/20 | 15-1/10 | +Of the third Order, {Green | 25-1/5 | 18-9/10 | 16-1/4 | + {Yellow | 27-1/7 | 20-1/3 | 17-1/2 | + {Red | 29 | 21-3/4 | 18-5/7 | + {Bluish red | 32 | 24 | 20-2/3 | + |---------+----------+----------| + {Bluish green | 34 | 25-1/2 | 22 | + {Green | 35-2/7 | 26-1/2 | 22-3/4 | +Of the fourth Order, {Yellowish green | 36 | 27 | 23-2/9 | + {Red | 40-1/3 | 30-1/4 | 26 | + |---------+----------+----------| + {Greenish blue | 46 | 34-1/2 | 29-2/3 | +Of the fifth Order, {Red | 52-1/2 | 39-3/8 | 34 | + |---------+----------+----------| + {Greenish blue | 58-3/4 | 44 | 38 | +Of the sixth Order, {Red | 65 | 48-3/4 | 42 | + |---------+----------+----------| +Of the seventh Order, {Greenish blue | 71 | 53-1/4 | 45-4/5 | + {Ruddy White | 77 | 57-3/4 | 49-2/3 | + |---------+----------+----------| + +There are also other Uses of this Table: For by its assistance the +thickness of the Bubble in the 19th Observation was determin'd by the +Colours which it exhibited. And so the bigness of the parts of natural +Bodies may be conjectured by their Colours, as shall be hereafter shewn. +Also, if two or more very thin Plates be laid one upon another, so as to +compose one Plate equalling them all in thickness, the resulting Colour +may be hereby determin'd. For instance, Mr. _Hook_ observed, as is +mentioned in his _Micrographia_, that a faint yellow Plate of _Muscovy_ +Glass laid upon a blue one, constituted a very deep purple. The yellow +of the first Order is a faint one, and the thickness of the Plate +exhibiting it, according to the Table is 4-3/5, to which add 9, the +thickness exhibiting blue of the second Order, and the Sum will be +13-3/5, which is the thickness exhibiting the purple of the third Order. + +To explain, in the next place, the circumstances of the 2d and 3d +Observations; that is, how the Rings of the Colours may (by turning the +Prisms about their common Axis the contrary way to that expressed in +those Observations) be converted into white and black Rings, and +afterwards into Rings of Colours again, the Colours of each Ring lying +now in an inverted order; it must be remember'd, that those Rings of +Colours are dilated by the obliquation of the Rays to the Air which +intercedes the Glasses, and that according to the Table in the 7th +Observation, their Dilatation or Increase of their Diameter is most +manifest and speedy when they are obliquest. Now the Rays of yellow +being more refracted by the first Superficies of the said Air than those +of red, are thereby made more oblique to the second Superficies, at +which they are reflected to produce the colour'd Rings, and consequently +the yellow Circle in each Ring will be more dilated than the red; and +the Excess of its Dilatation will be so much the greater, by how much +the greater is the obliquity of the Rays, until at last it become of +equal extent with the red of the same Ring. And for the same reason the +green, blue and violet, will be also so much dilated by the still +greater obliquity of their Rays, as to become all very nearly of equal +extent with the red, that is, equally distant from the center of the +Rings. And then all the Colours of the same Ring must be co-incident, +and by their mixture exhibit a white Ring. And these white Rings must +have black and dark Rings between them, because they do not spread and +interfere with one another, as before. And for that reason also they +must become distincter, and visible to far greater numbers. But yet the +violet being obliquest will be something more dilated, in proportion to +its extent, than the other Colours, and so very apt to appear at the +exterior Verges of the white. + +Afterwards, by a greater obliquity of the Rays, the violet and blue +become more sensibly dilated than the red and yellow, and so being +farther removed from the center of the Rings, the Colours must emerge +out of the white in an order contrary to that which they had before; the +violet and blue at the exterior Limbs of each Ring, and the red and +yellow at the interior. And the violet, by reason of the greatest +obliquity of its Rays, being in proportion most of all expanded, will +soonest appear at the exterior Limb of each white Ring, and become more +conspicuous than the rest. And the several Series of Colours belonging +to the several Rings, will, by their unfolding and spreading, begin +again to interfere, and thereby render the Rings less distinct, and not +visible to so great numbers. + +If instead of the Prisms the Object-glasses be made use of, the Rings +which they exhibit become not white and distinct by the obliquity of the +Eye, by reason that the Rays in their passage through that Air which +intercedes the Glasses are very nearly parallel to those Lines in which +they were first incident on the Glasses, and consequently the Rays +endued with several Colours are not inclined one more than another to +that Air, as it happens in the Prisms. + +There is yet another circumstance of these Experiments to be consider'd, +and that is why the black and white Rings which when view'd at a +distance appear distinct, should not only become confused by viewing +them near at hand, but also yield a violet Colour at both the edges of +every white Ring. And the reason is, that the Rays which enter the Eye +at several parts of the Pupil, have several Obliquities to the Glasses, +and those which are most oblique, if consider'd apart, would represent +the Rings bigger than those which are the least oblique. Whence the +breadth of the Perimeter of every white Ring is expanded outwards by the +obliquest Rays, and inwards by the least oblique. And this Expansion is +so much the greater by how much the greater is the difference of the +Obliquity; that is, by how much the Pupil is wider, or the Eye nearer to +the Glasses. And the breadth of the violet must be most expanded, +because the Rays apt to excite a Sensation of that Colour are most +oblique to a second or farther Superficies of the thinn'd Air at which +they are reflected, and have also the greatest variation of Obliquity, +which makes that Colour soonest emerge out of the edges of the white. +And as the breadth of every Ring is thus augmented, the dark Intervals +must be diminish'd, until the neighbouring Rings become continuous, and +are blended, the exterior first, and then those nearer the center; so +that they can no longer be distinguish'd apart, but seem to constitute +an even and uniform whiteness. + +Among all the Observations there is none accompanied with so odd +circumstances as the twenty-fourth. Of those the principal are, that in +thin Plates, which to the naked Eye seem of an even and uniform +transparent whiteness, without any terminations of Shadows, the +Refraction of a Prism should make Rings of Colours appear, whereas it +usually makes Objects appear colour'd only there where they are +terminated with Shadows, or have parts unequally luminous; and that it +should make those Rings exceedingly distinct and white, although it +usually renders Objects confused and coloured. The Cause of these things +you will understand by considering, that all the Rings of Colours are +really in the Plate, when view'd with the naked Eye, although by reason +of the great breadth of their Circumferences they so much interfere and +are blended together, that they seem to constitute an uniform whiteness. +But when the Rays pass through the Prism to the Eye, the Orbits of the +several Colours in every Ring are refracted, some more than others, +according to their degrees of Refrangibility: By which means the Colours +on one side of the Ring (that is in the circumference on one side of its +center), become more unfolded and dilated, and those on the other side +more complicated and contracted. And where by a due Refraction they are +so much contracted, that the several Rings become narrower than to +interfere with one another, they must appear distinct, and also white, +if the constituent Colours be so much contracted as to be wholly +co-incident. But on the other side, where the Orbit of every Ring is +made broader by the farther unfolding of its Colours, it must interfere +more with other Rings than before, and so become less distinct. + +[Illustration: FIG. 7.] + +To explain this a little farther, suppose the concentrick Circles AV, +and BX, [in _Fig._ 7.] represent the red and violet of any Order, which, +together with the intermediate Colours, constitute any one of these +Rings. Now these being view'd through a Prism, the violet Circle BX, +will, by a greater Refraction, be farther translated from its place than +the red AV, and so approach nearer to it on that side of the Circles, +towards which the Refractions are made. For instance, if the red be +translated to _av_, the violet may be translated to _bx_, so as to +approach nearer to it at _x_ than before; and if the red be farther +translated to av, the violet may be so much farther translated to bx as +to convene with it at x; and if the red be yet farther translated to +[Greek: aY], the violet may be still so much farther translated to +[Greek: bx] as to pass beyond it at [Greek: x], and convene with it at +_e_ and _f_. And this being understood not only of the red and violet, +but of all the other intermediate Colours, and also of every revolution +of those Colours, you will easily perceive how those of the same +revolution or order, by their nearness at _xv_ and [Greek: Yx], and +their coincidence at xv, _e_ and _f_, ought to constitute pretty +distinct Arcs of Circles, especially at xv, or at _e_ and _f_; and that +they will appear severally at _x_[Greek: u] and at xv exhibit whiteness +by their coincidence, and again appear severally at [Greek: Yx], but yet +in a contrary order to that which they had before, and still retain +beyond _e_ and _f_. But on the other side, at _ab_, ab, or [Greek: ab], +these Colours must become much more confused by being dilated and spread +so as to interfere with those of other Orders. And the same confusion +will happen at [Greek: Ux] between _e_ and _f_, if the Refraction be +very great, or the Prism very distant from the Object-glasses: In which +case no parts of the Rings will be seen, save only two little Arcs at +_e_ and _f_, whose distance from one another will be augmented by +removing the Prism still farther from the Object-glasses: And these +little Arcs must be distinctest and whitest at their middle, and at +their ends, where they begin to grow confused, they must be colour'd. +And the Colours at one end of every Arc must be in a contrary order to +those at the other end, by reason that they cross in the intermediate +white; namely, their ends, which verge towards [Greek: Ux], will be red +and yellow on that side next the center, and blue and violet on the +other side. But their other ends which verge from [Greek: Ux], will on +the contrary be blue and violet on that side towards the center, and on +the other side red and yellow. + +Now as all these things follow from the properties of Light by a +mathematical way of reasoning, so the truth of them may be manifested by +Experiments. For in a dark Room, by viewing these Rings through a Prism, +by reflexion of the several prismatick Colours, which an assistant +causes to move to and fro upon a Wall or Paper from whence they are +reflected, whilst the Spectator's Eye, the Prism, and the +Object-glasses, (as in the 13th Observation,) are placed steady; the +Position of the Circles made successively by the several Colours, will +be found such, in respect of one another, as I have described in the +Figures _abxv_, or abxv, or _[Greek: abxU]_. And by the same method the +truth of the Explications of other Observations may be examined. + +By what hath been said, the like Phænomena of Water and thin Plates of +Glass may be understood. But in small fragments of those Plates there is +this farther observable, that where they lie flat upon a Table, and are +turned about their centers whilst they are view'd through a Prism, they +will in some postures exhibit Waves of various Colours; and some of them +exhibit these Waves in one or two Positions only, but the most of them +do in all Positions exhibit them, and make them for the most part appear +almost all over the Plates. The reason is, that the Superficies of such +Plates are not even, but have many Cavities and Swellings, which, how +shallow soever, do a little vary the thickness of the Plate. For at the +several sides of those Cavities, for the Reasons newly described, there +ought to be produced Waves in several postures of the Prism. Now though +it be but some very small and narrower parts of the Glass, by which +these Waves for the most part are caused, yet they may seem to extend +themselves over the whole Glass, because from the narrowest of those +parts there are Colours of several Orders, that is, of several Rings, +confusedly reflected, which by Refraction of the Prism are unfolded, +separated, and, according to their degrees of Refraction, dispersed to +several places, so as to constitute so many several Waves, as there were +divers orders of Colours promiscuously reflected from that part of the +Glass. + +These are the principal Phænomena of thin Plates or Bubbles, whose +Explications depend on the properties of Light, which I have heretofore +deliver'd. And these you see do necessarily follow from them, and agree +with them, even to their very least circumstances; and not only so, but +do very much tend to their proof. Thus, by the 24th Observation it +appears, that the Rays of several Colours, made as well by thin Plates +or Bubbles, as by Refractions of a Prism, have several degrees of +Refrangibility; whereby those of each order, which at the reflexion from +the Plate or Bubble are intermix'd with those of other orders, are +separated from them by Refraction, and associated together so as to +become visible by themselves like Arcs of Circles. For if the Rays were +all alike refrangible, 'tis impossible that the whiteness, which to the +naked Sense appears uniform, should by Refraction have its parts +transposed and ranged into those black and white Arcs. + +It appears also that the unequal Refractions of difform Rays proceed not +from any contingent irregularities; such as are Veins, an uneven Polish, +or fortuitous Position of the Pores of Glass; unequal and casual Motions +in the Air or Æther, the spreading, breaking, or dividing the same Ray +into many diverging parts; or the like. For, admitting any such +irregularities, it would be impossible for Refractions to render those +Rings so very distinct, and well defined, as they do in the 24th +Observation. It is necessary therefore that every Ray have its proper +and constant degree of Refrangibility connate with it, according to +which its refraction is ever justly and regularly perform'd; and that +several Rays have several of those degrees. + +And what is said of their Refrangibility may be also understood of their +Reflexibility, that is, of their Dispositions to be reflected, some at a +greater, and others at a less thickness of thin Plates or Bubbles; +namely, that those Dispositions are also connate with the Rays, and +immutable; as may appear by the 13th, 14th, and 15th Observations, +compared with the fourth and eighteenth. + +By the Precedent Observations it appears also, that whiteness is a +dissimilar mixture of all Colours, and that Light is a mixture of Rays +endued with all those Colours. For, considering the multitude of the +Rings of Colours in the 3d, 12th, and 24th Observations, it is manifest, +that although in the 4th and 18th Observations there appear no more than +eight or nine of those Rings, yet there are really a far greater number, +which so much interfere and mingle with one another, as after those +eight or nine revolutions to dilute one another wholly, and constitute +an even and sensibly uniform whiteness. And consequently that whiteness +must be allow'd a mixture of all Colours, and the Light which conveys it +to the Eye must be a mixture of Rays endued with all those Colours. + +But farther; by the 24th Observation it appears, that there is a +constant relation between Colours and Refrangibility; the most +refrangible Rays being violet, the least refrangible red, and those of +intermediate Colours having proportionably intermediate degrees of +Refrangibility. And by the 13th, 14th, and 15th Observations, compared +with the 4th or 18th there appears to be the same constant relation +between Colour and Reflexibility; the violet being in like circumstances +reflected at least thicknesses of any thin Plate or Bubble, the red at +greatest thicknesses, and the intermediate Colours at intermediate +thicknesses. Whence it follows, that the colorifick Dispositions of +Rays are also connate with them, and immutable; and by consequence, that +all the Productions and Appearances of Colours in the World are derived, +not from any physical Change caused in Light by Refraction or Reflexion, +but only from the various Mixtures or Separations of Rays, by virtue of +their different Refrangibility or Reflexibility. And in this respect the +Science of Colours becomes a Speculation as truly mathematical as any +other part of Opticks. I mean, so far as they depend on the Nature of +Light, and are not produced or alter'd by the Power of Imagination, or +by striking or pressing the Eye. + + + + +THE + +SECOND BOOK + +OF + +OPTICKS + + +_PART III._ + +_Of the permanent Colours of natural Bodies, and the Analogy between +them and the Colours of thin transparent Plates._ + +I am now come to another part of this Design, which is to consider how +the Phænomena of thin transparent Plates stand related to those of all +other natural Bodies. Of these Bodies I have already told you that they +appear of divers Colours, accordingly as they are disposed to reflect +most copiously the Rays originally endued with those Colours. But their +Constitutions, whereby they reflect some Rays more copiously than +others, remain to be discover'd; and these I shall endeavour to manifest +in the following Propositions. + + +PROP. I. + +_Those Superficies of transparent Bodies reflect the greatest quantity +of Light, which have the greatest refracting Power; that is, which +intercede Mediums that differ most in their refractive Densities. And in +the Confines of equally refracting Mediums there is no Reflexion._ + +The Analogy between Reflexion and Refraction will appear by considering, +that when Light passeth obliquely out of one Medium into another which +refracts from the perpendicular, the greater is the difference of their +refractive Density, the less Obliquity of Incidence is requisite to +cause a total Reflexion. For as the Sines are which measure the +Refraction, so is the Sine of Incidence at which the total Reflexion +begins, to the Radius of the Circle; and consequently that Angle of +Incidence is least where there is the greatest difference of the Sines. +Thus in the passing of Light out of Water into Air, where the Refraction +is measured by the Ratio of the Sines 3 to 4, the total Reflexion begins +when the Angle of Incidence is about 48 Degrees 35 Minutes. In passing +out of Glass into Air, where the Refraction is measured by the Ratio of +the Sines 20 to 31, the total Reflexion begins when the Angle of +Incidence is 40 Degrees 10 Minutes; and so in passing out of Crystal, or +more strongly refracting Mediums into Air, there is still a less +obliquity requisite to cause a total reflexion. Superficies therefore +which refract most do soonest reflect all the Light which is incident on +them, and so must be allowed most strongly reflexive. + +But the truth of this Proposition will farther appear by observing, that +in the Superficies interceding two transparent Mediums, (such as are +Air, Water, Oil, common Glass, Crystal, metalline Glasses, Island +Glasses, white transparent Arsenick, Diamonds, &c.) the Reflexion is +stronger or weaker accordingly, as the Superficies hath a greater or +less refracting Power. For in the Confine of Air and Sal-gem 'tis +stronger than in the Confine of Air and Water, and still stronger in the +Confine of Air and common Glass or Crystal, and stronger in the Confine +of Air and a Diamond. If any of these, and such like transparent Solids, +be immerged in Water, its Reflexion becomes, much weaker than before; +and still weaker if they be immerged in the more strongly refracting +Liquors of well rectified Oil of Vitriol or Spirit of Turpentine. If +Water be distinguish'd into two parts by any imaginary Surface, the +Reflexion in the Confine of those two parts is none at all. In the +Confine of Water and Ice 'tis very little; in that of Water and Oil 'tis +something greater; in that of Water and Sal-gem still greater; and in +that of Water and Glass, or Crystal or other denser Substances still +greater, accordingly as those Mediums differ more or less in their +refracting Powers. Hence in the Confine of common Glass and Crystal, +there ought to be a weak Reflexion, and a stronger Reflexion in the +Confine of common and metalline Glass; though I have not yet tried +this. But in the Confine of two Glasses of equal density, there is not +any sensible Reflexion; as was shewn in the first Observation. And the +same may be understood of the Superficies interceding two Crystals, or +two Liquors, or any other Substances in which no Refraction is caused. +So then the reason why uniform pellucid Mediums (such as Water, Glass, +or Crystal,) have no sensible Reflexion but in their external +Superficies, where they are adjacent to other Mediums of a different +density, is because all their contiguous parts have one and the same +degree of density. + + +PROP. II. + +_The least parts of almost all natural Bodies are in some measure +transparent: And the Opacity of those Bodies ariseth from the multitude +of Reflexions caused in their internal Parts._ + +That this is so has been observed by others, and will easily be granted +by them that have been conversant with Microscopes. And it may be also +tried by applying any substance to a hole through which some Light is +immitted into a dark Room. For how opake soever that Substance may seem +in the open Air, it will by that means appear very manifestly +transparent, if it be of a sufficient thinness. Only white metalline +Bodies must be excepted, which by reason of their excessive density seem +to reflect almost all the Light incident on their first Superficies; +unless by solution in Menstruums they be reduced into very small +Particles, and then they become transparent. + + +PROP. III. + +_Between the parts of opake and colour'd Bodies are many Spaces, either +empty, or replenish'd with Mediums of other Densities; as Water between +the tinging Corpuscles wherewith any Liquor is impregnated, Air between +the aqueous Globules that constitute Clouds or Mists; and for the most +part Spaces void of both Air and Water, but yet perhaps not wholly void +of all Substance, between the parts of hard Bodies._ + +The truth of this is evinced by the two precedent Propositions: For by +the second Proposition there are many Reflexions made by the internal +parts of Bodies, which, by the first Proposition, would not happen if +the parts of those Bodies were continued without any such Interstices +between them; because Reflexions are caused only in Superficies, which +intercede Mediums of a differing density, by _Prop._ 1. + +But farther, that this discontinuity of parts is the principal Cause of +the opacity of Bodies, will appear by considering, that opake Substances +become transparent by filling their Pores with any Substance of equal or +almost equal density with their parts. Thus Paper dipped in Water or +Oil, the _Oculus Mundi_ Stone steep'd in Water, Linnen Cloth oiled or +varnish'd, and many other Substances soaked in such Liquors as will +intimately pervade their little Pores, become by that means more +transparent than otherwise; so, on the contrary, the most transparent +Substances, may, by evacuating their Pores, or separating their parts, +be render'd sufficiently opake; as Salts or wet Paper, or the _Oculus +Mundi_ Stone by being dried, Horn by being scraped, Glass by being +reduced to Powder, or otherwise flawed; Turpentine by being stirred +about with Water till they mix imperfectly, and Water by being form'd +into many small Bubbles, either alone in the form of Froth, or by +shaking it together with Oil of Turpentine, or Oil Olive, or with some +other convenient Liquor, with which it will not perfectly incorporate. +And to the increase of the opacity of these Bodies, it conduces +something, that by the 23d Observation the Reflexions of very thin +transparent Substances are considerably stronger than those made by the +same Substances of a greater thickness. + + +PROP. IV. + +_The Parts of Bodies and their Interstices must not be less than of some +definite bigness, to render them opake and colour'd._ + +For the opakest Bodies, if their parts be subtilly divided, (as Metals, +by being dissolved in acid Menstruums, &c.) become perfectly +transparent. And you may also remember, that in the eighth Observation +there was no sensible reflexion at the Superficies of the +Object-glasses, where they were very near one another, though they did +not absolutely touch. And in the 17th Observation the Reflexion of the +Water-bubble where it became thinnest was almost insensible, so as to +cause very black Spots to appear on the top of the Bubble, by the want +of reflected Light. + +On these grounds I perceive it is that Water, Salt, Glass, Stones, and +such like Substances, are transparent. For, upon divers Considerations, +they seem to be as full of Pores or Interstices between their parts as +other Bodies are, but yet their Parts and Interstices to be too small to +cause Reflexions in their common Surfaces. + + +PROP. V. + +_The transparent parts of Bodies, according to their several sizes, +reflect Rays of one Colour, and transmit those of another, on the same +grounds that thin Plates or Bubbles do reflect or transmit those Rays. +And this I take to be the ground of all their Colours._ + +For if a thinn'd or plated Body, which being of an even thickness, +appears all over of one uniform Colour, should be slit into Threads, or +broken into Fragments, of the same thickness with the Plate; I see no +reason why every Thread or Fragment should not keep its Colour, and by +consequence why a heap of those Threads or Fragments should not +constitute a Mass or Powder of the same Colour, which the Plate +exhibited before it was broken. And the parts of all natural Bodies +being like so many Fragments of a Plate, must on the same grounds +exhibit the same Colours. + +Now, that they do so will appear by the affinity of their Properties. +The finely colour'd Feathers of some Birds, and particularly those of +Peacocks Tails, do, in the very same part of the Feather, appear of +several Colours in several Positions of the Eye, after the very same +manner that thin Plates were found to do in the 7th and 19th +Observations, and therefore their Colours arise from the thinness of the +transparent parts of the Feathers; that is, from the slenderness of the +very fine Hairs, or _Capillamenta_, which grow out of the sides of the +grosser lateral Branches or Fibres of those Feathers. And to the same +purpose it is, that the Webs of some Spiders, by being spun very fine, +have appeared colour'd, as some have observ'd, and that the colour'd +Fibres of some Silks, by varying the Position of the Eye, do vary their +Colour. Also the Colours of Silks, Cloths, and other Substances, which +Water or Oil can intimately penetrate, become more faint and obscure by +being immerged in those Liquors, and recover their Vigor again by being +dried; much after the manner declared of thin Bodies in the 10th and +21st Observations. Leaf-Gold, some sorts of painted Glass, the Infusion +of _Lignum Nephriticum_, and some other Substances, reflect one Colour, +and transmit another; like thin Bodies in the 9th and 20th Observations. +And some of those colour'd Powders which Painters use, may have their +Colours a little changed, by being very elaborately and finely ground. +Where I see not what can be justly pretended for those changes, besides +the breaking of their parts into less parts by that contrition, after +the same manner that the Colour of a thin Plate is changed by varying +its thickness. For which reason also it is that the colour'd Flowers of +Plants and Vegetables, by being bruised, usually become more transparent +than before, or at least in some degree or other change their Colours. +Nor is it much less to my purpose, that, by mixing divers Liquors, very +odd and remarkable Productions and Changes of Colours may be effected, +of which no cause can be more obvious and rational than that the saline +Corpuscles of one Liquor do variously act upon or unite with the tinging +Corpuscles of another, so as to make them swell, or shrink, (whereby not +only their bulk but their density also may be changed,) or to divide +them into smaller Corpuscles, (whereby a colour'd Liquor may become +transparent,) or to make many of them associate into one cluster, +whereby two transparent Liquors may compose a colour'd one. For we see +how apt those saline Menstruums are to penetrate and dissolve Substances +to which they are applied, and some of them to precipitate what others +dissolve. In like manner, if we consider the various Phænomena of the +Atmosphere, we may observe, that when Vapours are first raised, they +hinder not the transparency of the Air, being divided into parts too +small to cause any Reflexion in their Superficies. But when in order to +compose drops of Rain they begin to coalesce and constitute Globules of +all intermediate sizes, those Globules, when they become of convenient +size to reflect some Colours and transmit others, may constitute Clouds +of various Colours according to their sizes. And I see not what can be +rationally conceived in so transparent a Substance as Water for the +production of these Colours, besides the various sizes of its fluid and +globular Parcels. + + +PROP. VI. + +_The parts of Bodies on which their Colours depend, are denser than the +Medium which pervades their Interstices._ + +This will appear by considering, that the Colour of a Body depends not +only on the Rays which are incident perpendicularly on its parts, but on +those also which are incident at all other Angles. And that according to +the 7th Observation, a very little variation of obliquity will change +the reflected Colour, where the thin Body or small Particles is rarer +than the ambient Medium, insomuch that such a small Particle will at +diversly oblique Incidences reflect all sorts of Colours, in so great a +variety that the Colour resulting from them all, confusedly reflected +from a heap of such Particles, must rather be a white or grey than any +other Colour, or at best it must be but a very imperfect and dirty +Colour. Whereas if the thin Body or small Particle be much denser than +the ambient Medium, the Colours, according to the 19th Observation, are +so little changed by the variation of obliquity, that the Rays which +are reflected least obliquely may predominate over the rest, so much as +to cause a heap of such Particles to appear very intensely of their +Colour. + +It conduces also something to the confirmation of this Proposition, +that, according to the 22d Observation, the Colours exhibited by the +denser thin Body within the rarer, are more brisk than those exhibited +by the rarer within the denser. + + +PROP. VII. + +_The bigness of the component parts of natural Bodies may be conjectured +by their Colours._ + +For since the parts of these Bodies, by _Prop._ 5. do most probably +exhibit the same Colours with a Plate of equal thickness, provided they +have the same refractive density; and since their parts seem for the +most part to have much the same density with Water or Glass, as by many +circumstances is obvious to collect; to determine the sizes of those +parts, you need only have recourse to the precedent Tables, in which the +thickness of Water or Glass exhibiting any Colour is expressed. Thus if +it be desired to know the diameter of a Corpuscle, which being of equal +density with Glass shall reflect green of the third Order; the Number +16-1/4 shews it to be (16-1/4)/10000 parts of an Inch. + +The greatest difficulty is here to know of what Order the Colour of any +Body is. And for this end we must have recourse to the 4th and 18th +Observations; from whence may be collected these particulars. + +_Scarlets_, and other _reds_, _oranges_, and _yellows_, if they be pure +and intense, are most probably of the second order. Those of the first +and third order also may be pretty good; only the yellow of the first +order is faint, and the orange and red of the third Order have a great +Mixture of violet and blue. + +There may be good _Greens_ of the fourth Order, but the purest are of +the third. And of this Order the green of all Vegetables seems to be, +partly by reason of the Intenseness of their Colours, and partly because +when they wither some of them turn to a greenish yellow, and others to a +more perfect yellow or orange, or perhaps to red, passing first through +all the aforesaid intermediate Colours. Which Changes seem to be +effected by the exhaling of the Moisture which may leave the tinging +Corpuscles more dense, and something augmented by the Accretion of the +oily and earthy Part of that Moisture. Now the green, without doubt, is +of the same Order with those Colours into which it changeth, because the +Changes are gradual, and those Colours, though usually not very full, +yet are often too full and lively to be of the fourth Order. + +_Blues_ and _Purples_ may be either of the second or third Order, but +the best are of the third. Thus the Colour of Violets seems to be of +that Order, because their Syrup by acid Liquors turns red, and by +urinous and alcalizate turns green. For since it is of the Nature of +Acids to dissolve or attenuate, and of Alcalies to precipitate or +incrassate, if the Purple Colour of the Syrup was of the second Order, +an acid Liquor by attenuating its tinging Corpuscles would change it to +a red of the first Order, and an Alcali by incrassating them would +change it to a green of the second Order; which red and green, +especially the green, seem too imperfect to be the Colours produced by +these Changes. But if the said Purple be supposed of the third Order, +its Change to red of the second, and green of the third, may without any +Inconvenience be allow'd. + +If there be found any Body of a deeper and less reddish Purple than that +of the Violets, its Colour most probably is of the second Order. But yet +there being no Body commonly known whose Colour is constantly more deep +than theirs, I have made use of their Name to denote the deepest and +least reddish Purples, such as manifestly transcend their Colour in +purity. + +The _blue_ of the first Order, though very faint and little, may +possibly be the Colour of some Substances; and particularly the azure +Colour of the Skies seems to be of this Order. For all Vapours when they +begin to condense and coalesce into small Parcels, become first of that +Bigness, whereby such an Azure must be reflected before they can +constitute Clouds of other Colours. And so this being the first Colour +which Vapours begin to reflect, it ought to be the Colour of the finest +and most transparent Skies, in which Vapours are not arrived to that +Grossness requisite to reflect other Colours, as we find it is by +Experience. + +_Whiteness_, if most intense and luminous, is that of the first Order, +if less strong and luminous, a Mixture of the Colours of several Orders. +Of this last kind is the Whiteness of Froth, Paper, Linnen, and most +white Substances; of the former I reckon that of white Metals to be. For +whilst the densest of Metals, Gold, if foliated, is transparent, and all +Metals become transparent if dissolved in Menstruums or vitrified, the +Opacity of white Metals ariseth not from their Density alone. They being +less dense than Gold would be more transparent than it, did not some +other Cause concur with their Density to make them opake. And this Cause +I take to be such a Bigness of their Particles as fits them to reflect +the white of the first order. For, if they be of other Thicknesses they +may reflect other Colours, as is manifest by the Colours which appear +upon hot Steel in tempering it, and sometimes upon the Surface of melted +Metals in the Skin or Scoria which arises upon them in their cooling. +And as the white of the first order is the strongest which can be made +by Plates of transparent Substances, so it ought to be stronger in the +denser Substances of Metals than in the rarer of Air, Water, and Glass. +Nor do I see but that metallick Substances of such a Thickness as may +fit them to reflect the white of the first order, may, by reason of +their great Density (according to the Tenor of the first of these +Propositions) reflect all the Light incident upon them, and so be as +opake and splendent as it's possible for any Body to be. Gold, or Copper +mix'd with less than half their Weight of Silver, or Tin, or Regulus of +Antimony, in fusion, or amalgamed with a very little Mercury, become +white; which shews both that the Particles of white Metals have much +more Superficies, and so are smaller, than those of Gold and Copper, and +also that they are so opake as not to suffer the Particles of Gold or +Copper to shine through them. Now it is scarce to be doubted but that +the Colours of Gold and Copper are of the second and third order, and +therefore the Particles of white Metals cannot be much bigger than is +requisite to make them reflect the white of the first order. The +Volatility of Mercury argues that they are not much bigger, nor may they +be much less, lest they lose their Opacity, and become either +transparent as they do when attenuated by Vitrification, or by Solution +in Menstruums, or black as they do when ground smaller, by rubbing +Silver, or Tin, or Lead, upon other Substances to draw black Lines. The +first and only Colour which white Metals take by grinding their +Particles smaller, is black, and therefore their white ought to be that +which borders upon the black Spot in the Center of the Rings of Colours, +that is, the white of the first order. But, if you would hence gather +the Bigness of metallick Particles, you must allow for their Density. +For were Mercury transparent, its Density is such that the Sine of +Incidence upon it (by my Computation) would be to the Sine of its +Refraction, as 71 to 20, or 7 to 2. And therefore the Thickness of its +Particles, that they may exhibit the same Colours with those of Bubbles +of Water, ought to be less than the Thickness of the Skin of those +Bubbles in the Proportion of 2 to 7. Whence it's possible, that the +Particles of Mercury may be as little as the Particles of some +transparent and volatile Fluids, and yet reflect the white of the first +order. + +Lastly, for the production of _black_, the Corpuscles must be less than +any of those which exhibit Colours. For at all greater sizes there is +too much Light reflected to constitute this Colour. But if they be +supposed a little less than is requisite to reflect the white and very +faint blue of the first order, they will, according to the 4th, 8th, +17th and 18th Observations, reflect so very little Light as to appear +intensely black, and yet may perhaps variously refract it to and fro +within themselves so long, until it happen to be stifled and lost, by +which means they will appear black in all positions of the Eye without +any transparency. And from hence may be understood why Fire, and the +more subtile dissolver Putrefaction, by dividing the Particles of +Substances, turn them to black, why small quantities of black Substances +impart their Colour very freely and intensely to other Substances to +which they are applied; the minute Particles of these, by reason of +their very great number, easily overspreading the gross Particles of +others; why Glass ground very elaborately with Sand on a Copper Plate, +'till it be well polish'd, makes the Sand, together with what is worn +off from the Glass and Copper, become very black: why black Substances +do soonest of all others become hot in the Sun's Light and burn, (which +Effect may proceed partly from the multitude of Refractions in a little +room, and partly from the easy Commotion of so very small Corpuscles;) +and why blacks are usually a little inclined to a bluish Colour. For +that they are so may be seen by illuminating white Paper by Light +reflected from black Substances. For the Paper will usually appear of a +bluish white; and the reason is, that black borders in the obscure blue +of the order described in the 18th Observation, and therefore reflects +more Rays of that Colour than of any other. + +In these Descriptions I have been the more particular, because it is not +impossible but that Microscopes may at length be improved to the +discovery of the Particles of Bodies on which their Colours depend, if +they are not already in some measure arrived to that degree of +perfection. For if those Instruments are or can be so far improved as +with sufficient distinctness to represent Objects five or six hundred +times bigger than at a Foot distance they appear to our naked Eyes, I +should hope that we might be able to discover some of the greatest of +those Corpuscles. And by one that would magnify three or four thousand +times perhaps they might all be discover'd, but those which produce +blackness. In the mean while I see nothing material in this Discourse +that may rationally be doubted of, excepting this Position: That +transparent Corpuscles of the same thickness and density with a Plate, +do exhibit the same Colour. And this I would have understood not without +some Latitude, as well because those Corpuscles may be of irregular +Figures, and many Rays must be obliquely incident on them, and so have +a shorter way through them than the length of their Diameters, as +because the straitness of the Medium put in on all sides within such +Corpuscles may a little alter its Motions or other qualities on which +the Reflexion depends. But yet I cannot much suspect the last, because I +have observed of some small Plates of Muscovy Glass which were of an +even thickness, that through a Microscope they have appeared of the same +Colour at their edges and corners where the included Medium was +terminated, which they appeared of in other places. However it will add +much to our Satisfaction, if those Corpuscles can be discover'd with +Microscopes; which if we shall at length attain to, I fear it will be +the utmost improvement of this Sense. For it seems impossible to see the +more secret and noble Works of Nature within the Corpuscles by reason of +their transparency. + + +PROP. VIII. + +_The Cause of Reflexion is not the impinging of Light on the solid or +impervious parts of Bodies, as is commonly believed._ + +This will appear by the following Considerations. First, That in the +passage of Light out of Glass into Air there is a Reflexion as strong as +in its passage out of Air into Glass, or rather a little stronger, and +by many degrees stronger than in its passage out of Glass into Water. +And it seems not probable that Air should have more strongly reflecting +parts than Water or Glass. But if that should possibly be supposed, yet +it will avail nothing; for the Reflexion is as strong or stronger when +the Air is drawn away from the Glass, (suppose by the Air-Pump invented +by _Otto Gueriet_, and improved and made useful by Mr. _Boyle_) as when +it is adjacent to it. Secondly, If Light in its passage out of Glass +into Air be incident more obliquely than at an Angle of 40 or 41 Degrees +it is wholly reflected, if less obliquely it is in great measure +transmitted. Now it is not to be imagined that Light at one degree of +obliquity should meet with Pores enough in the Air to transmit the +greater part of it, and at another degree of obliquity should meet with +nothing but parts to reflect it wholly, especially considering that in +its passage out of Air into Glass, how oblique soever be its Incidence, +it finds Pores enough in the Glass to transmit a great part of it. If +any Man suppose that it is not reflected by the Air, but by the outmost +superficial parts of the Glass, there is still the same difficulty: +Besides, that such a Supposition is unintelligible, and will also appear +to be false by applying Water behind some part of the Glass instead of +Air. For so in a convenient obliquity of the Rays, suppose of 45 or 46 +Degrees, at which they are all reflected where the Air is adjacent to +the Glass, they shall be in great measure transmitted where the Water is +adjacent to it; which argues, that their Reflexion or Transmission +depends on the constitution of the Air and Water behind the Glass, and +not on the striking of the Rays upon the parts of the Glass. Thirdly, +If the Colours made by a Prism placed at the entrance of a Beam of Light +into a darken'd Room be successively cast on a second Prism placed at a +greater distance from the former, in such manner that they are all alike +incident upon it, the second Prism may be so inclined to the incident +Rays, that those which are of a blue Colour shall be all reflected by +it, and yet those of a red Colour pretty copiously transmitted. Now if +the Reflexion be caused by the parts of Air or Glass, I would ask, why +at the same Obliquity of Incidence the blue should wholly impinge on +those parts, so as to be all reflected, and yet the red find Pores +enough to be in a great measure transmitted. Fourthly, Where two Glasses +touch one another, there is no sensible Reflexion, as was declared in +the first Observation; and yet I see no reason why the Rays should not +impinge on the parts of Glass, as much when contiguous to other Glass as +when contiguous to Air. Fifthly, When the top of a Water-Bubble (in the +17th Observation,) by the continual subsiding and exhaling of the Water +grew very thin, there was such a little and almost insensible quantity +of Light reflected from it, that it appeared intensely black; whereas +round about that black Spot, where the Water was thicker, the Reflexion +was so strong as to make the Water seem very white. Nor is it only at +the least thickness of thin Plates or Bubbles, that there is no manifest +Reflexion, but at many other thicknesses continually greater and +greater. For in the 15th Observation the Rays of the same Colour were by +turns transmitted at one thickness, and reflected at another thickness, +for an indeterminate number of Successions. And yet in the Superficies +of the thinned Body, where it is of any one thickness, there are as many +parts for the Rays to impinge on, as where it is of any other thickness. +Sixthly, If Reflexion were caused by the parts of reflecting Bodies, it +would be impossible for thin Plates or Bubbles, at one and the same +place, to reflect the Rays of one Colour, and transmit those of another, +as they do according to the 13th and 15th Observations. For it is not to +be imagined that at one place the Rays which, for instance, exhibit a +blue Colour, should have the fortune to dash upon the parts, and those +which exhibit a red to hit upon the Pores of the Body; and then at +another place, where the Body is either a little thicker or a little +thinner, that on the contrary the blue should hit upon its pores, and +the red upon its parts. Lastly, Were the Rays of Light reflected by +impinging on the solid parts of Bodies, their Reflexions from polish'd +Bodies could not be so regular as they are. For in polishing Glass with +Sand, Putty, or Tripoly, it is not to be imagined that those Substances +can, by grating and fretting the Glass, bring all its least Particles to +an accurate Polish; so that all their Surfaces shall be truly plain or +truly spherical, and look all the same way, so as together to compose +one even Surface. The smaller the Particles of those Substances are, the +smaller will be the Scratches by which they continually fret and wear +away the Glass until it be polish'd; but be they never so small they can +wear away the Glass no otherwise than by grating and scratching it, and +breaking the Protuberances; and therefore polish it no otherwise than by +bringing its roughness to a very fine Grain, so that the Scratches and +Frettings of the Surface become too small to be visible. And therefore +if Light were reflected by impinging upon the solid parts of the Glass, +it would be scatter'd as much by the most polish'd Glass as by the +roughest. So then it remains a Problem, how Glass polish'd by fretting +Substances can reflect Light so regularly as it does. And this Problem +is scarce otherwise to be solved, than by saying, that the Reflexion of +a Ray is effected, not by a single point of the reflecting Body, but by +some power of the Body which is evenly diffused all over its Surface, +and by which it acts upon the Ray without immediate Contact. For that +the parts of Bodies do act upon Light at a distance shall be shewn +hereafter. + +Now if Light be reflected, not by impinging on the solid parts of +Bodies, but by some other principle; it's probable that as many of its +Rays as impinge on the solid parts of Bodies are not reflected but +stifled and lost in the Bodies. For otherwise we must allow two sorts of +Reflexions. Should all the Rays be reflected which impinge on the +internal parts of clear Water or Crystal, those Substances would rather +have a cloudy Colour than a clear Transparency. To make Bodies look +black, it's necessary that many Rays be stopp'd, retained, and lost in +them; and it seems not probable that any Rays can be stopp'd and +stifled in them which do not impinge on their parts. + +And hence we may understand that Bodies are much more rare and porous +than is commonly believed. Water is nineteen times lighter, and by +consequence nineteen times rarer than Gold; and Gold is so rare as very +readily and without the least opposition to transmit the magnetick +Effluvia, and easily to admit Quicksilver into its Pores, and to let +Water pass through it. For a concave Sphere of Gold filled with Water, +and solder'd up, has, upon pressing the Sphere with great force, let the +Water squeeze through it, and stand all over its outside in multitudes +of small Drops, like Dew, without bursting or cracking the Body of the +Gold, as I have been inform'd by an Eye witness. From all which we may +conclude, that Gold has more Pores than solid parts, and by consequence +that Water has above forty times more Pores than Parts. And he that +shall find out an Hypothesis, by which Water may be so rare, and yet not +be capable of compression by force, may doubtless by the same Hypothesis +make Gold, and Water, and all other Bodies, as much rarer as he pleases; +so that Light may find a ready passage through transparent Substances. + +The Magnet acts upon Iron through all dense Bodies not magnetick nor red +hot, without any diminution of its Virtue; as for instance, through +Gold, Silver, Lead, Glass, Water. The gravitating Power of the Sun is +transmitted through the vast Bodies of the Planets without any +diminution, so as to act upon all their parts to their very centers +with the same Force and according to the same Laws, as if the part upon +which it acts were not surrounded with the Body of the Planet, The Rays +of Light, whether they be very small Bodies projected, or only Motion or +Force propagated, are moved in right Lines; and whenever a Ray of Light +is by any Obstacle turned out of its rectilinear way, it will never +return into the same rectilinear way, unless perhaps by very great +accident. And yet Light is transmitted through pellucid solid Bodies in +right Lines to very great distances. How Bodies can have a sufficient +quantity of Pores for producing these Effects is very difficult to +conceive, but perhaps not altogether impossible. For the Colours of +Bodies arise from the Magnitudes of the Particles which reflect them, as +was explained above. Now if we conceive these Particles of Bodies to be +so disposed amongst themselves, that the Intervals or empty Spaces +between them may be equal in magnitude to them all; and that these +Particles may be composed of other Particles much smaller, which have as +much empty Space between them as equals all the Magnitudes of these +smaller Particles: And that in like manner these smaller Particles are +again composed of others much smaller, all which together are equal to +all the Pores or empty Spaces between them; and so on perpetually till +you come to solid Particles, such as have no Pores or empty Spaces +within them: And if in any gross Body there be, for instance, three such +degrees of Particles, the least of which are solid; this Body will have +seven times more Pores than solid Parts. But if there be four such +degrees of Particles, the least of which are solid, the Body will have +fifteen times more Pores than solid Parts. If there be five degrees, the +Body will have one and thirty times more Pores than solid Parts. If six +degrees, the Body will have sixty and three times more Pores than solid +Parts. And so on perpetually. And there are other ways of conceiving how +Bodies may be exceeding porous. But what is really their inward Frame is +not yet known to us. + + +PROP. IX. + +_Bodies reflect and refract Light by one and the same power, variously +exercised in various Circumstances._ + +This appears by several Considerations. First, Because when Light goes +out of Glass into Air, as obliquely as it can possibly do. If its +Incidence be made still more oblique, it becomes totally reflected. For +the power of the Glass after it has refracted the Light as obliquely as +is possible, if the Incidence be still made more oblique, becomes too +strong to let any of its Rays go through, and by consequence causes +total Reflexions. Secondly, Because Light is alternately reflected and +transmitted by thin Plates of Glass for many Successions, accordingly as +the thickness of the Plate increases in an arithmetical Progression. For +here the thickness of the Glass determines whether that Power by which +Glass acts upon Light shall cause it to be reflected, or suffer it to +be transmitted. And, Thirdly, because those Surfaces of transparent +Bodies which have the greatest refracting power, reflect the greatest +quantity of Light, as was shewn in the first Proposition. + + +PROP. X. + +_If Light be swifter in Bodies than in Vacuo, in the proportion of the +Sines which measure the Refraction of the Bodies, the Forces of the +Bodies to reflect and refract Light, are very nearly proportional to the +densities of the same Bodies; excepting that unctuous and sulphureous +Bodies refract more than others of this same density._ + +[Illustration: FIG. 8.] + +Let AB represent the refracting plane Surface of any Body, and IC a Ray +incident very obliquely upon the Body in C, so that the Angle ACI may be +infinitely little, and let CR be the refracted Ray. From a given Point B +perpendicular to the refracting Surface erect BR meeting with the +refracting Ray CR in R, and if CR represent the Motion of the refracted +Ray, and this Motion be distinguish'd into two Motions CB and BR, +whereof CB is parallel to the refracting Plane, and BR perpendicular to +it: CB shall represent the Motion of the incident Ray, and BR the +Motion generated by the Refraction, as Opticians have of late explain'd. + +Now if any Body or Thing, in moving through any Space of a given breadth +terminated on both sides by two parallel Planes, be urged forward in all +parts of that Space by Forces tending directly forwards towards the last +Plane, and before its Incidence on the first Plane, had no Motion +towards it, or but an infinitely little one; and if the Forces in all +parts of that Space, between the Planes, be at equal distances from the +Planes equal to one another, but at several distances be bigger or less +in any given Proportion, the Motion generated by the Forces in the whole +passage of the Body or thing through that Space shall be in a +subduplicate Proportion of the Forces, as Mathematicians will easily +understand. And therefore, if the Space of activity of the refracting +Superficies of the Body be consider'd as such a Space, the Motion of the +Ray generated by the refracting Force of the Body, during its passage +through that Space, that is, the Motion BR, must be in subduplicate +Proportion of that refracting Force. I say therefore, that the Square of +the Line BR, and by consequence the refracting Force of the Body, is +very nearly as the density of the same Body. For this will appear by the +following Table, wherein the Proportion of the Sines which measure the +Refractions of several Bodies, the Square of BR, supposing CB an unite, +the Densities of the Bodies estimated by their Specifick Gravities, and +their Refractive Power in respect of their Densities are set down in +several Columns. + +---------------------+----------------+----------------+----------+----------- + | | | | + | | The Square | The | The + | | of BR, to | density | refractive + | The Proportion | which the | and | Power of + | of the Sines of| refracting | specifick| the Body + | Incidence and | force of the | gravity | in respect + The refracting | Refraction of | Body is | of the | of its + Bodies. | yellow Light. | proportionate. | Body. | density. +---------------------+----------------+----------------+----------+----------- +A Pseudo-Topazius, | | | | + being a natural, | | | | + pellucid, brittle, | 23 to 14 | 1'699 | 4'27 | 3979 + hairy Stone, of a | | | | + yellow Colour. | | | | +Air. | 3201 to 3200 | 0'000625 | 0'0012 | 5208 +Glass of Antimony. | 17 to 9 | 2'568 | 5'28 | 4864 +A Selenitis. | 61 to 41 | 1'213 | 2'252 | 5386 +Glass vulgar. | 31 to 20 | 1'4025 | 2'58 | 5436 +Crystal of the Rock. | 25 to 16 | 1'445 | 2'65 | 5450 +Island Crystal. | 5 to 3 | 1'778 | 2'72 | 6536 +Sal Gemmæ. | 17 to 11 | 1'388 | 2'143 | 6477 +Alume. | 35 to 24 | 1'1267 | 1'714 | 6570 +Borax. | 22 to 15 | 1'1511 | 1'714 | 6716 +Niter. | 32 to 21 | 1'345 | 1'9 | 7079 +Dantzick Vitriol. | 303 to 200 | 1'295 | 1'715 | 7551 +Oil of Vitriol. | 10 to 7 | 1'041 | 1'7 | 6124 +Rain Water. | 529 to 396 | 0'7845 | 1' | 7845 +Gum Arabick. | 31 to 21 | 1'179 | 1'375 | 8574 +Spirit of Wine well | | | | + rectified. | 100 to 73 | 0'8765 | 0'866 | 10121 +Camphire. | 3 to 2 | 1'25 | 0'996 | 12551 +Oil Olive. | 22 to 15 | 1'1511 | 0'913 | 12607 +Linseed Oil. | 40 to 27 | 1'1948 | 0'932 | 12819 +Spirit of Turpentine.| 25 to 17 | 1'1626 | 0'874 | 13222 +Amber. | 14 to 9 | 1'42 | 1'04 | 13654 +A Diamond. | 100 to 41 | 4'949 | 3'4 | 14556 +---------------------+----------------+----------------+----------+----------- + +The Refraction of the Air in this Table is determin'd by that of the +Atmosphere observed by Astronomers. For, if Light pass through many +refracting Substances or Mediums gradually denser and denser, and +terminated with parallel Surfaces, the Sum of all the Refractions will +be equal to the single Refraction which it would have suffer'd in +passing immediately out of the first Medium into the last. And this +holds true, though the Number of the refracting Substances be increased +to Infinity, and the Distances from one another as much decreased, so +that the Light may be refracted in every Point of its Passage, and by +continual Refractions bent into a Curve-Line. And therefore the whole +Refraction of Light in passing through the Atmosphere from the highest +and rarest Part thereof down to the lowest and densest Part, must be +equal to the Refraction which it would suffer in passing at like +Obliquity out of a Vacuum immediately into Air of equal Density with +that in the lowest Part of the Atmosphere. + +Now, although a Pseudo-Topaz, a Selenitis, Rock Crystal, Island Crystal, +Vulgar Glass (that is, Sand melted together) and Glass of Antimony, +which are terrestrial stony alcalizate Concretes, and Air which probably +arises from such Substances by Fermentation, be Substances very +differing from one another in Density, yet by this Table, they have +their refractive Powers almost in the same Proportion to one another as +their Densities are, excepting that the Refraction of that strange +Substance, Island Crystal is a little bigger than the rest. And +particularly Air, which is 3500 Times rarer than the Pseudo-Topaz, and +4400 Times rarer than Glass of Antimony, and 2000 Times rarer than the +Selenitis, Glass vulgar, or Crystal of the Rock, has notwithstanding its +rarity the same refractive Power in respect of its Density which those +very dense Substances have in respect of theirs, excepting so far as +those differ from one another. + +Again, the Refraction of Camphire, Oil Olive, Linseed Oil, Spirit of +Turpentine and Amber, which are fat sulphureous unctuous Bodies, and a +Diamond, which probably is an unctuous Substance coagulated, have their +refractive Powers in Proportion to one another as their Densities +without any considerable Variation. But the refractive Powers of these +unctuous Substances are two or three Times greater in respect of their +Densities than the refractive Powers of the former Substances in respect +of theirs. + +Water has a refractive Power in a middle degree between those two sorts +of Substances, and probably is of a middle nature. For out of it grow +all vegetable and animal Substances, which consist as well of +sulphureous fat and inflamable Parts, as of earthy lean and alcalizate +ones. + +Salts and Vitriols have refractive Powers in a middle degree between +those of earthy Substances and Water, and accordingly are composed of +those two sorts of Substances. For by distillation and rectification of +their Spirits a great Part of them goes into Water, and a great Part +remains behind in the form of a dry fix'd Earth capable of +Vitrification. + +Spirit of Wine has a refractive Power in a middle degree between those +of Water and oily Substances, and accordingly seems to be composed of +both, united by Fermentation; the Water, by means of some saline Spirits +with which 'tis impregnated, dissolving the Oil, and volatizing it by +the Action. For Spirit of Wine is inflamable by means of its oily Parts, +and being distilled often from Salt of Tartar, grow by every +distillation more and more aqueous and phlegmatick. And Chymists +observe, that Vegetables (as Lavender, Rue, Marjoram, &c.) distilled +_per se_, before fermentation yield Oils without any burning Spirits, +but after fermentation yield ardent Spirits without Oils: Which shews, +that their Oil is by fermentation converted into Spirit. They find also, +that if Oils be poured in a small quantity upon fermentating Vegetables, +they distil over after fermentation in the form of Spirits. + +So then, by the foregoing Table, all Bodies seem to have their +refractive Powers proportional to their Densities, (or very nearly;) +excepting so far as they partake more or less of sulphureous oily +Particles, and thereby have their refractive Power made greater or less. +Whence it seems rational to attribute the refractive Power of all Bodies +chiefly, if not wholly, to the sulphureous Parts with which they abound. +For it's probable that all Bodies abound more or less with Sulphurs. And +as Light congregated by a Burning-glass acts most upon sulphureous +Bodies, to turn them into Fire and Flame; so, since all Action is +mutual, Sulphurs ought to act most upon Light. For that the action +between Light and Bodies is mutual, may appear from this Consideration; +That the densest Bodies which refract and reflect Light most strongly, +grow hottest in the Summer Sun, by the action of the refracted or +reflected Light. + +I have hitherto explain'd the power of Bodies to reflect and refract, +and shew'd, that thin transparent Plates, Fibres, and Particles, do, +according to their several thicknesses and densities, reflect several +sorts of Rays, and thereby appear of several Colours; and by consequence +that nothing more is requisite for producing all the Colours of natural +Bodies, than the several sizes and densities of their transparent +Particles. But whence it is that these Plates, Fibres, and Particles, +do, according to their several thicknesses and densities, reflect +several sorts of Rays, I have not yet explain'd. To give some insight +into this matter, and make way for understanding the next part of this +Book, I shall conclude this part with a few more Propositions. Those +which preceded respect the nature of Bodies, these the nature of Light: +For both must be understood, before the reason of their Actions upon one +another can be known. And because the last Proposition depended upon the +velocity of Light, I will begin with a Proposition of that kind. + + +PROP. XI. + +_Light is propagated from luminous Bodies in time, and spends about +seven or eight Minutes of an Hour in passing from the Sun to the Earth._ + +This was observed first by _Roemer_, and then by others, by means of the +Eclipses of the Satellites of _Jupiter_. For these Eclipses, when the +Earth is between the Sun and _Jupiter_, happen about seven or eight +Minutes sooner than they ought to do by the Tables, and when the Earth +is beyond the Sun they happen about seven or eight Minutes later than +they ought to do; the reason being, that the Light of the Satellites has +farther to go in the latter case than in the former by the Diameter of +the Earth's Orbit. Some inequalities of time may arise from the +Excentricities of the Orbs of the Satellites; but those cannot answer in +all the Satellites, and at all times to the Position and Distance of the +Earth from the Sun. The mean motions of _Jupiter_'s Satellites is also +swifter in his descent from his Aphelium to his Perihelium, than in his +ascent in the other half of his Orb. But this inequality has no respect +to the position of the Earth, and in the three interior Satellites is +insensible, as I find by computation from the Theory of their Gravity. + + +PROP. XII. + +_Every Ray of Light in its passage through any refracting Surface is put +into a certain transient Constitution or State, which in the progress of +the Ray returns at equal Intervals, and disposes the Ray at every return +to be easily transmitted through the next refracting Surface, and +between the returns to be easily reflected by it._ + +This is manifest by the 5th, 9th, 12th, and 15th Observations. For by +those Observations it appears, that one and the same sort of Rays at +equal Angles of Incidence on any thin transparent Plate, is alternately +reflected and transmitted for many Successions accordingly as the +thickness of the Plate increases in arithmetical Progression of the +Numbers, 0, 1, 2, 3, 4, 5, 6, 7, 8, &c. so that if the first Reflexion +(that which makes the first or innermost of the Rings of Colours there +described) be made at the thickness 1, the Rays shall be transmitted at +the thicknesses 0, 2, 4, 6, 8, 10, 12, &c. and thereby make the central +Spot and Rings of Light, which appear by transmission, and be reflected +at the thickness 1, 3, 5, 7, 9, 11, &c. and thereby make the Rings which +appear by Reflexion. And this alternate Reflexion and Transmission, as I +gather by the 24th Observation, continues for above an hundred +vicissitudes, and by the Observations in the next part of this Book, for +many thousands, being propagated from one Surface of a Glass Plate to +the other, though the thickness of the Plate be a quarter of an Inch or +above: So that this alternation seems to be propagated from every +refracting Surface to all distances without end or limitation. + +This alternate Reflexion and Refraction depends on both the Surfaces of +every thin Plate, because it depends on their distance. By the 21st +Observation, if either Surface of a thin Plate of _Muscovy_ Glass be +wetted, the Colours caused by the alternate Reflexion and Refraction +grow faint, and therefore it depends on them both. + +It is therefore perform'd at the second Surface; for if it were +perform'd at the first, before the Rays arrive at the second, it would +not depend on the second. + +It is also influenced by some action or disposition, propagated from the +first to the second, because otherwise at the second it would not depend +on the first. And this action or disposition, in its propagation, +intermits and returns by equal Intervals, because in all its progress it +inclines the Ray at one distance from the first Surface to be reflected +by the second, at another to be transmitted by it, and that by equal +Intervals for innumerable vicissitudes. And because the Ray is disposed +to Reflexion at the distances 1, 3, 5, 7, 9, &c. and to Transmission at +the distances 0, 2, 4, 6, 8, 10, &c. (for its transmission through the +first Surface, is at the distance 0, and it is transmitted through both +together, if their distance be infinitely little or much less than 1) +the disposition to be transmitted at the distances 2, 4, 6, 8, 10, &c. +is to be accounted a return of the same disposition which the Ray first +had at the distance 0, that is at its transmission through the first +refracting Surface. All which is the thing I would prove. + +What kind of action or disposition this is; Whether it consists in a +circulating or a vibrating motion of the Ray, or of the Medium, or +something else, I do not here enquire. Those that are averse from +assenting to any new Discoveries, but such as they can explain by an +Hypothesis, may for the present suppose, that as Stones by falling upon +Water put the Water into an undulating Motion, and all Bodies by +percussion excite vibrations in the Air; so the Rays of Light, by +impinging on any refracting or reflecting Surface, excite vibrations in +the refracting or reflecting Medium or Substance, and by exciting them +agitate the solid parts of the refracting or reflecting Body, and by +agitating them cause the Body to grow warm or hot; that the vibrations +thus excited are propagated in the refracting or reflecting Medium or +Substance, much after the manner that vibrations are propagated in the +Air for causing Sound, and move faster than the Rays so as to overtake +them; and that when any Ray is in that part of the vibration which +conspires with its Motion, it easily breaks through a refracting +Surface, but when it is in the contrary part of the vibration which +impedes its Motion, it is easily reflected; and, by consequence, that +every Ray is successively disposed to be easily reflected, or easily +transmitted, by every vibration which overtakes it. But whether this +Hypothesis be true or false I do not here consider. I content my self +with the bare Discovery, that the Rays of Light are by some cause or +other alternately disposed to be reflected or refracted for many +vicissitudes. + + +DEFINITION. + +_The returns of the disposition of any Ray to be reflected I will call +its_ Fits of easy Reflexion, _and those of its disposition to be +transmitted its_ Fits of easy Transmission, _and the space it passes +between every return and the next return, the_ Interval of its Fits. + + +PROP. XIII. + +_The reason why the Surfaces of all thick transparent Bodies reflect +part of the Light incident on them, and refract the rest, is, that some +Rays at their Incidence are in Fits of easy Reflexion, and others in +Fits of easy Transmission._ + +This may be gather'd from the 24th Observation, where the Light +reflected by thin Plates of Air and Glass, which to the naked Eye +appear'd evenly white all over the Plate, did through a Prism appear +waved with many Successions of Light and Darkness made by alternate Fits +of easy Reflexion and easy Transmission, the Prism severing and +distinguishing the Waves of which the white reflected Light was +composed, as was explain'd above. + +And hence Light is in Fits of easy Reflexion and easy Transmission, +before its Incidence on transparent Bodies. And probably it is put into +such fits at its first emission from luminous Bodies, and continues in +them during all its progress. For these Fits are of a lasting nature, as +will appear by the next part of this Book. + +In this Proposition I suppose the transparent Bodies to be thick; +because if the thickness of the Body be much less than the Interval of +the Fits of easy Reflexion and Transmission of the Rays, the Body loseth +its reflecting power. For if the Rays, which at their entering into the +Body are put into Fits of easy Transmission, arrive at the farthest +Surface of the Body before they be out of those Fits, they must be +transmitted. And this is the reason why Bubbles of Water lose their +reflecting power when they grow very thin; and why all opake Bodies, +when reduced into very small parts, become transparent. + + +PROP. XIV. + +_Those Surfaces of transparent Bodies, which if the Ray be in a Fit of +Refraction do refract it most strongly, if the Ray be in a Fit of +Reflexion do reflect it most easily._ + +For we shewed above, in _Prop._ 8. that the cause of Reflexion is not +the impinging of Light on the solid impervious parts of Bodies, but some +other power by which those solid parts act on Light at a distance. We +shewed also in _Prop._ 9. that Bodies reflect and refract Light by one +and the same power, variously exercised in various circumstances; and in +_Prop._ 1. that the most strongly refracting Surfaces reflect the most +Light: All which compared together evince and rarify both this and the +last Proposition. + + +PROP. XV. + +_In any one and the same sort of Rays, emerging in any Angle out of any +refracting Surface into one and the same Medium, the Interval of the +following Fits of easy Reflexion and Transmission are either accurately +or very nearly, as the Rectangle of the Secant of the Angle of +Refraction, and of the Secant of another Angle, whose Sine is the first +of 106 arithmetical mean Proportionals, between the Sines of Incidence +and Refraction, counted from the Sine of Refraction._ + +This is manifest by the 7th and 19th Observations. + + +PROP. XVI. + +_In several sorts of Rays emerging in equal Angles out of any refracting +Surface into the same Medium, the Intervals of the following Fits of +easy Reflexion and easy Transmission are either accurately, or very +nearly, as the Cube-Roots of the Squares of the lengths of a Chord, +which found the Notes in an Eight_, sol, la, fa, sol, la, mi, fa, sol, +_with all their intermediate degrees answering to the Colours of those +Rays, according to the Analogy described in the seventh Experiment of +the second Part of the first Book._ + +This is manifest by the 13th and 14th Observations. + + +PROP. XVII. + +_If Rays of any sort pass perpendicularly into several Mediums, the +Intervals of the Fits of easy Reflexion and Transmission in any one +Medium, are to those Intervals in any other, as the Sine of Incidence to +the Sine of Refraction, when the Rays pass out of the first of those two +Mediums into the second._ + +This is manifest by the 10th Observation. + + +PROP. XVIII. + +_If the Rays which paint the Colour in the Confine of yellow and orange +pass perpendicularly out of any Medium into Air, the Intervals of their +Fits of easy Reflexion are the 1/89000th part of an Inch. And of the +same length are the Intervals of their Fits of easy Transmission._ + +This is manifest by the 6th Observation. From these Propositions it is +easy to collect the Intervals of the Fits of easy Reflexion and easy +Transmission of any sort of Rays refracted in any angle into any Medium; +and thence to know, whether the Rays shall be reflected or transmitted +at their subsequent Incidence upon any other pellucid Medium. Which +thing, being useful for understanding the next part of this Book, was +here to be set down. And for the same reason I add the two following +Propositions. + + +PROP. XIX. + +_If any sort of Rays falling on the polite Surface of any pellucid +Medium be reflected back, the Fits of easy Reflexion, which they have at +the point of Reflexion, shall still continue to return; and the Returns +shall be at distances from the point of Reflexion in the arithmetical +progression of the Numbers 2, 4, 6, 8, 10, 12, &c. and between these +Fits the Rays shall be in Fits of easy Transmission._ + +For since the Fits of easy Reflexion and easy Transmission are of a +returning nature, there is no reason why these Fits, which continued +till the Ray arrived at the reflecting Medium, and there inclined the +Ray to Reflexion, should there cease. And if the Ray at the point of +Reflexion was in a Fit of easy Reflexion, the progression of the +distances of these Fits from that point must begin from 0, and so be of +the Numbers 0, 2, 4, 6, 8, &c. And therefore the progression of the +distances of the intermediate Fits of easy Transmission, reckon'd from +the same point, must be in the progression of the odd Numbers 1, 3, 5, +7, 9, &c. contrary to what happens when the Fits are propagated from +points of Refraction. + + +PROP. XX. + +_The Intervals of the Fits of easy Reflexion and easy Transmission, +propagated from points of Reflexion into any Medium, are equal to the +Intervals of the like Fits, which the same Rays would have, if refracted +into the same Medium in Angles of Refraction equal to their Angles of +Reflexion._ + +For when Light is reflected by the second Surface of thin Plates, it +goes out afterwards freely at the first Surface to make the Rings of +Colours which appear by Reflexion; and, by the freedom of its egress, +makes the Colours of these Rings more vivid and strong than those which +appear on the other side of the Plates by the transmitted Light. The +reflected Rays are therefore in Fits of easy Transmission at their +egress; which would not always happen, if the Intervals of the Fits +within the Plate after Reflexion were not equal, both in length and +number, to their Intervals before it. And this confirms also the +proportions set down in the former Proposition. For if the Rays both in +going in and out at the first Surface be in Fits of easy Transmission, +and the Intervals and Numbers of those Fits between the first and second +Surface, before and after Reflexion, be equal, the distances of the Fits +of easy Transmission from either Surface, must be in the same +progression after Reflexion as before; that is, from the first Surface +which transmitted them in the progression of the even Numbers 0, 2, 4, +6, 8, &c. and from the second which reflected them, in that of the odd +Numbers 1, 3, 5, 7, &c. But these two Propositions will become much more +evident by the Observations in the following part of this Book. + + + + +THE + +SECOND BOOK + +OF + +OPTICKS + + +_PART IV._ + +_Observations concerning the Reflexions and Colours of thick transparent +polish'd Plates._ + +There is no Glass or Speculum how well soever polished, but, besides the +Light which it refracts or reflects regularly, scatters every way +irregularly a faint Light, by means of which the polish'd Surface, when +illuminated in a dark room by a beam of the Sun's Light, may be easily +seen in all positions of the Eye. There are certain Phænomena of this +scatter'd Light, which when I first observed them, seem'd very strange +and surprizing to me. My Observations were as follows. + +_Obs._ 1. The Sun shining into my darken'd Chamber through a hole one +third of an Inch wide, I let the intromitted beam of Light fall +perpendicularly upon a Glass Speculum ground concave on one side and +convex on the other, to a Sphere of five Feet and eleven Inches Radius, +and Quick-silver'd over on the convex side. And holding a white opake +Chart, or a Quire of Paper at the center of the Spheres to which the +Speculum was ground, that is, at the distance of about five Feet and +eleven Inches from the Speculum, in such manner, that the beam of Light +might pass through a little hole made in the middle of the Chart to the +Speculum, and thence be reflected back to the same hole: I observed upon +the Chart four or five concentric Irises or Rings of Colours, like +Rain-bows, encompassing the hole much after the manner that those, which +in the fourth and following Observations of the first part of this Book +appear'd between the Object-glasses, encompassed the black Spot, but yet +larger and fainter than those. These Rings as they grew larger and +larger became diluter and fainter, so that the fifth was scarce visible. +Yet sometimes, when the Sun shone very clear, there appear'd faint +Lineaments of a sixth and seventh. If the distance of the Chart from the +Speculum was much greater or much less than that of six Feet, the Rings +became dilute and vanish'd. And if the distance of the Speculum from the +Window was much greater than that of six Feet, the reflected beam of +Light would be so broad at the distance of six Feet from the Speculum +where the Rings appear'd, as to obscure one or two of the innermost +Rings. And therefore I usually placed the Speculum at about six Feet +from the Window; so that its Focus might there fall in with the center +of its concavity at the Rings upon the Chart. And this Posture is always +to be understood in the following Observations where no other is +express'd. + +_Obs._ 2. The Colours of these Rain-bows succeeded one another from the +center outwards, in the same form and order with those which were made +in the ninth Observation of the first Part of this Book by Light not +reflected, but transmitted through the two Object-glasses. For, first, +there was in their common center a white round Spot of faint Light, +something broader than the reflected beam of Light, which beam sometimes +fell upon the middle of the Spot, and sometimes by a little inclination +of the Speculum receded from the middle, and left the Spot white to the +center. + +This white Spot was immediately encompassed with a dark grey or russet, +and that dark grey with the Colours of the first Iris; which Colours on +the inside next the dark grey were a little violet and indigo, and next +to that a blue, which on the outside grew pale, and then succeeded a +little greenish yellow, and after that a brighter yellow, and then on +the outward edge of the Iris a red which on the outside inclined to +purple. + +This Iris was immediately encompassed with a second, whose Colours were +in order from the inside outwards, purple, blue, green, yellow, light +red, a red mix'd with purple. + +Then immediately follow'd the Colours of the third Iris, which were in +order outwards a green inclining to purple, a good green, and a red more +bright than that of the former Iris. + +The fourth and fifth Iris seem'd of a bluish green within, and red +without, but so faintly that it was difficult to discern the Colours. + +_Obs._ 3. Measuring the Diameters of these Rings upon the Chart as +accurately as I could, I found them also in the same proportion to one +another with the Rings made by Light transmitted through the two +Object-glasses. For the Diameters of the four first of the bright Rings +measured between the brightest parts of their Orbits, at the distance of +six Feet from the Speculum were 1-11/16, 2-3/8, 2-11/12, 3-3/8 Inches, +whose Squares are in arithmetical progression of the numbers 1, 2, 3, 4. +If the white circular Spot in the middle be reckon'd amongst the Rings, +and its central Light, where it seems to be most luminous, be put +equipollent to an infinitely little Ring; the Squares of the Diameters +of the Rings will be in the progression 0, 1, 2, 3, 4, &c. I measured +also the Diameters of the dark Circles between these luminous ones, and +found their Squares in the progression of the numbers 1/2, 1-1/2, 2-1/2, +3-1/2, &c. the Diameters of the first four at the distance of six Feet +from the Speculum, being 1-3/16, 2-1/16, 2-2/3, 3-3/20 Inches. If the +distance of the Chart from the Speculum was increased or diminished, the +Diameters of the Circles were increased or diminished proportionally. + +_Obs._ 4. By the analogy between these Rings and those described in the +Observations of the first Part of this Book, I suspected that there +were many more of them which spread into one another, and by interfering +mix'd their Colours, and diluted one another so that they could not be +seen apart. I viewed them therefore through a Prism, as I did those in +the 24th Observation of the first Part of this Book. And when the Prism +was so placed as by refracting the Light of their mix'd Colours to +separate them, and distinguish the Rings from one another, as it did +those in that Observation, I could then see them distincter than before, +and easily number eight or nine of them, and sometimes twelve or +thirteen. And had not their Light been so very faint, I question not but +that I might have seen many more. + +_Obs._ 5. Placing a Prism at the Window to refract the intromitted beam +of Light, and cast the oblong Spectrum of Colours on the Speculum: I +covered the Speculum with a black Paper which had in the middle of it a +hole to let any one of the Colours pass through to the Speculum, whilst +the rest were intercepted by the Paper. And now I found Rings of that +Colour only which fell upon the Speculum. If the Speculum was +illuminated with red, the Rings were totally red with dark Intervals, if +with blue they were totally blue, and so of the other Colours. And when +they were illuminated with any one Colour, the Squares of their +Diameters measured between their most luminous Parts, were in the +arithmetical Progression of the Numbers, 0, 1, 2, 3, 4 and the Squares +of the Diameters of their dark Intervals in the Progression of the +intermediate Numbers 1/2, 1-1/2, 2-1/2, 3-1/2. But if the Colour was +varied, they varied their Magnitude. In the red they were largest, in +the indigo and violet least, and in the intermediate Colours yellow, +green, and blue, they were of several intermediate Bignesses answering +to the Colour, that is, greater in yellow than in green, and greater in +green than in blue. And hence I knew, that when the Speculum was +illuminated with white Light, the red and yellow on the outside of the +Rings were produced by the least refrangible Rays, and the blue and +violet by the most refrangible, and that the Colours of each Ring spread +into the Colours of the neighbouring Rings on either side, after the +manner explain'd in the first and second Part of this Book, and by +mixing diluted one another so that they could not be distinguish'd, +unless near the Center where they were least mix'd. For in this +Observation I could see the Rings more distinctly, and to a greater +Number than before, being able in the yellow Light to number eight or +nine of them, besides a faint shadow of a tenth. To satisfy my self how +much the Colours of the several Rings spread into one another, I +measured the Diameters of the second and third Rings, and found them +when made by the Confine of the red and orange to be to the same +Diameters when made by the Confine of blue and indigo, as 9 to 8, or +thereabouts. For it was hard to determine this Proportion accurately. +Also the Circles made successively by the red, yellow, and green, +differ'd more from one another than those made successively by the +green, blue, and indigo. For the Circle made by the violet was too dark +to be seen. To carry on the Computation, let us therefore suppose that +the Differences of the Diameters of the Circles made by the outmost red, +the Confine of red and orange, the Confine of orange and yellow, the +Confine of yellow and green, the Confine of green and blue, the Confine +of blue and indigo, the Confine of indigo and violet, and outmost +violet, are in proportion as the Differences of the Lengths of a +Monochord which sound the Tones in an Eight; _sol_, _la_, _fa_, _sol_, +_la_, _mi_, _fa_, _sol_, that is, as the Numbers 1/9, 1/18, 1/12, 1/12, +2/27, 1/27, 1/18. And if the Diameter of the Circle made by the Confine +of red and orange be 9A, and that of the Circle made by the Confine of +blue and indigo be 8A as above; their difference 9A-8A will be to the +difference of the Diameters of the Circles made by the outmost red, and +by the Confine of red and orange, as 1/18 + 1/12 + 1/12 + 2/27 to 1/9, +that is as 8/27 to 1/9, or 8 to 3, and to the difference of the Circles +made by the outmost violet, and by the Confine of blue and indigo, as +1/18 + 1/12 + 1/12 + 2/27 to 1/27 + 1/18, that is, as 8/27 to 5/54, or +as 16 to 5. And therefore these differences will be 3/8A and 5/16A. Add +the first to 9A and subduct the last from 8A, and you will have the +Diameters of the Circles made by the least and most refrangible Rays +75/8A and ((61-1/2)/8)A. These diameters are therefore to one another as +75 to 61-1/2 or 50 to 41, and their Squares as 2500 to 1681, that is, as +3 to 2 very nearly. Which proportion differs not much from the +proportion of the Diameters of the Circles made by the outmost red and +outmost violet, in the 13th Observation of the first part of this Book. + +_Obs._ 6. Placing my Eye where these Rings appear'd plainest, I saw the +Speculum tinged all over with Waves of Colours, (red, yellow, green, +blue;) like those which in the Observations of the first part of this +Book appeared between the Object-glasses, and upon Bubbles of Water, but +much larger. And after the manner of those, they were of various +magnitudes in various Positions of the Eye, swelling and shrinking as I +moved my Eye this way and that way. They were formed like Arcs of +concentrick Circles, as those were; and when my Eye was over against the +center of the concavity of the Speculum, (that is, 5 Feet and 10 Inches +distant from the Speculum,) their common center was in a right Line with +that center of concavity, and with the hole in the Window. But in other +postures of my Eye their center had other positions. They appear'd by +the Light of the Clouds propagated to the Speculum through the hole in +the Window; and when the Sun shone through that hole upon the Speculum, +his Light upon it was of the Colour of the Ring whereon it fell, but by +its splendor obscured the Rings made by the Light of the Clouds, unless +when the Speculum was removed to a great distance from the Window, so +that his Light upon it might be broad and faint. By varying the position +of my Eye, and moving it nearer to or farther from the direct beam of +the Sun's Light, the Colour of the Sun's reflected Light constantly +varied upon the Speculum, as it did upon my Eye, the same Colour always +appearing to a Bystander upon my Eye which to me appear'd upon the +Speculum. And thence I knew that the Rings of Colours upon the Chart +were made by these reflected Colours, propagated thither from the +Speculum in several Angles, and that their production depended not upon +the termination of Light and Shadow. + +_Obs._ 7. By the Analogy of all these Phænomena with those of the like +Rings of Colours described in the first part of this Book, it seemed to +me that these Colours were produced by this thick Plate of Glass, much +after the manner that those were produced by very thin Plates. For, upon +trial, I found that if the Quick-silver were rubb'd off from the +backside of the Speculum, the Glass alone would cause the same Rings of +Colours, but much more faint than before; and therefore the Phænomenon +depends not upon the Quick-silver, unless so far as the Quick-silver by +increasing the Reflexion of the backside of the Glass increases the +Light of the Rings of Colours. I found also that a Speculum of Metal +without Glass made some Years since for optical uses, and very well +wrought, produced none of those Rings; and thence I understood that +these Rings arise not from one specular Surface alone, but depend upon +the two Surfaces of the Plate of Glass whereof the Speculum was made, +and upon the thickness of the Glass between them. For as in the 7th and +19th Observations of the first part of this Book a thin Plate of Air, +Water, or Glass of an even thickness appeared of one Colour when the +Rays were perpendicular to it, of another when they were a little +oblique, of another when more oblique, of another when still more +oblique, and so on; so here, in the sixth Observation, the Light which +emerged out of the Glass in several Obliquities, made the Glass appear +of several Colours, and being propagated in those Obliquities to the +Chart, there painted Rings of those Colours. And as the reason why a +thin Plate appeared of several Colours in several Obliquities of the +Rays, was, that the Rays of one and the same sort are reflected by the +thin Plate at one obliquity and transmitted at another, and those of +other sorts transmitted where these are reflected, and reflected where +these are transmitted: So the reason why the thick Plate of Glass +whereof the Speculum was made did appear of various Colours in various +Obliquities, and in those Obliquities propagated those Colours to the +Chart, was, that the Rays of one and the same sort did at one Obliquity +emerge out of the Glass, at another did not emerge, but were reflected +back towards the Quick-silver by the hither Surface of the Glass, and +accordingly as the Obliquity became greater and greater, emerged and +were reflected alternately for many Successions; and that in one and the +same Obliquity the Rays of one sort were reflected, and those of another +transmitted. This is manifest by the fifth Observation of this part of +this Book. For in that Observation, when the Speculum was illuminated by +any one of the prismatick Colours, that Light made many Rings of the +same Colour upon the Chart with dark Intervals, and therefore at its +emergence out of the Speculum was alternately transmitted and not +transmitted from the Speculum to the Chart for many Successions, +according to the various Obliquities of its Emergence. And when the +Colour cast on the Speculum by the Prism was varied, the Rings became of +the Colour cast on it, and varied their bigness with their Colour, and +therefore the Light was now alternately transmitted and not transmitted +from the Speculum to the Chart at other Obliquities than before. It +seemed to me therefore that these Rings were of one and the same +original with those of thin Plates, but yet with this difference, that +those of thin Plates are made by the alternate Reflexions and +Transmissions of the Rays at the second Surface of the Plate, after one +passage through it; but here the Rays go twice through the Plate before +they are alternately reflected and transmitted. First, they go through +it from the first Surface to the Quick-silver, and then return through +it from the Quick-silver to the first Surface, and there are either +transmitted to the Chart or reflected back to the Quick-silver, +accordingly as they are in their Fits of easy Reflexion or Transmission +when they arrive at that Surface. For the Intervals of the Fits of the +Rays which fall perpendicularly on the Speculum, and are reflected back +in the same perpendicular Lines, by reason of the equality of these +Angles and Lines, are of the same length and number within the Glass +after Reflexion as before, by the 19th Proposition of the third part of +this Book. And therefore since all the Rays that enter through the +first Surface are in their Fits of easy Transmission at their entrance, +and as many of these as are reflected by the second are in their Fits of +easy Reflexion there, all these must be again in their Fits of easy +Transmission at their return to the first, and by consequence there go +out of the Glass to the Chart, and form upon it the white Spot of Light +in the center of the Rings. For the reason holds good in all sorts of +Rays, and therefore all sorts must go out promiscuously to that Spot, +and by their mixture cause it to be white. But the Intervals of the Fits +of those Rays which are reflected more obliquely than they enter, must +be greater after Reflexion than before, by the 15th and 20th +Propositions. And thence it may happen that the Rays at their return to +the first Surface, may in certain Obliquities be in Fits of easy +Reflexion, and return back to the Quick-silver, and in other +intermediate Obliquities be again in Fits of easy Transmission, and so +go out to the Chart, and paint on it the Rings of Colours about the +white Spot. And because the Intervals of the Fits at equal obliquities +are greater and fewer in the less refrangible Rays, and less and more +numerous in the more refrangible, therefore the less refrangible at +equal obliquities shall make fewer Rings than the more refrangible, and +the Rings made by those shall be larger than the like number of Rings +made by these; that is, the red Rings shall be larger than the yellow, +the yellow than the green, the green than the blue, and the blue than +the violet, as they were really found to be in the fifth Observation. +And therefore the first Ring of all Colours encompassing the white Spot +of Light shall be red without any violet within, and yellow, and green, +and blue in the middle, as it was found in the second Observation; and +these Colours in the second Ring, and those that follow, shall be more +expanded, till they spread into one another, and blend one another by +interfering. + +These seem to be the reasons of these Rings in general; and this put me +upon observing the thickness of the Glass, and considering whether the +dimensions and proportions of the Rings may be truly derived from it by +computation. + +_Obs._ 8. I measured therefore the thickness of this concavo-convex +Plate of Glass, and found it every where 1/4 of an Inch precisely. Now, +by the sixth Observation of the first Part of this Book, a thin Plate of +Air transmits the brightest Light of the first Ring, that is, the bright +yellow, when its thickness is the 1/89000th part of an Inch; and by the +tenth Observation of the same Part, a thin Plate of Glass transmits the +same Light of the same Ring, when its thickness is less in proportion of +the Sine of Refraction to the Sine of Incidence, that is, when its +thickness is the 11/1513000th or 1/137545th part of an Inch, supposing +the Sines are as 11 to 17. And if this thickness be doubled, it +transmits the same bright Light of the second Ring; if tripled, it +transmits that of the third, and so on; the bright yellow Light in all +these cases being in its Fits of Transmission. And therefore if its +thickness be multiplied 34386 times, so as to become 1/4 of an Inch, it +transmits the same bright Light of the 34386th Ring. Suppose this be the +bright yellow Light transmitted perpendicularly from the reflecting +convex side of the Glass through the concave side to the white Spot in +the center of the Rings of Colours on the Chart: And by a Rule in the +7th and 19th Observations in the first Part of this Book, and by the +15th and 20th Propositions of the third Part of this Book, if the Rays +be made oblique to the Glass, the thickness of the Glass requisite to +transmit the same bright Light of the same Ring in any obliquity, is to +this thickness of 1/4 of an Inch, as the Secant of a certain Angle to +the Radius, the Sine of which Angle is the first of an hundred and six +arithmetical Means between the Sines of Incidence and Refraction, +counted from the Sine of Incidence when the Refraction is made out of +any plated Body into any Medium encompassing it; that is, in this case, +out of Glass into Air. Now if the thickness of the Glass be increased by +degrees, so as to bear to its first thickness, (_viz._ that of a quarter +of an Inch,) the Proportions which 34386 (the number of Fits of the +perpendicular Rays in going through the Glass towards the white Spot in +the center of the Rings,) hath to 34385, 34384, 34383, and 34382, (the +numbers of the Fits of the oblique Rays in going through the Glass +towards the first, second, third, and fourth Rings of Colours,) and if +the first thickness be divided into 100000000 equal parts, the increased +thicknesses will be 100002908, 100005816, 100008725, and 100011633, and +the Angles of which these thicknesses are Secants will be 26´ 13´´, 37´ +5´´, 45´ 6´´, and 52´ 26´´, the Radius being 100000000; and the Sines of +these Angles are 762, 1079, 1321, and 1525, and the proportional Sines +of Refraction 1172, 1659, 2031, and 2345, the Radius being 100000. For +since the Sines of Incidence out of Glass into Air are to the Sines of +Refraction as 11 to 17, and to the above-mentioned Secants as 11 to the +first of 106 arithmetical Means between 11 and 17, that is, as 11 to +11-6/106, those Secants will be to the Sines of Refraction as 11-6/106, +to 17, and by this Analogy will give these Sines. So then, if the +obliquities of the Rays to the concave Surface of the Glass be such that +the Sines of their Refraction in passing out of the Glass through that +Surface into the Air be 1172, 1659, 2031, 2345, the bright Light of the +34386th Ring shall emerge at the thicknesses of the Glass, which are to +1/4 of an Inch as 34386 to 34385, 34384, 34383, 34382, respectively. And +therefore, if the thickness in all these Cases be 1/4 of an Inch (as it +is in the Glass of which the Speculum was made) the bright Light of the +34385th Ring shall emerge where the Sine of Refraction is 1172, and that +of the 34384th, 34383th, and 34382th Ring where the Sine is 1659, 2031, +and 2345 respectively. And in these Angles of Refraction the Light of +these Rings shall be propagated from the Speculum to the Chart, and +there paint Rings about the white central round Spot of Light which we +said was the Light of the 34386th Ring. And the Semidiameters of these +Rings shall subtend the Angles of Refraction made at the +Concave-Surface of the Speculum, and by consequence their Diameters +shall be to the distance of the Chart from the Speculum as those Sines +of Refraction doubled are to the Radius, that is, as 1172, 1659, 2031, +and 2345, doubled are to 100000. And therefore, if the distance of the +Chart from the Concave-Surface of the Speculum be six Feet (as it was in +the third of these Observations) the Diameters of the Rings of this +bright yellow Light upon the Chart shall be 1'688, 2'389, 2'925, 3'375 +Inches: For these Diameters are to six Feet, as the above-mention'd +Sines doubled are to the Radius. Now, these Diameters of the bright +yellow Rings, thus found by Computation are the very same with those +found in the third of these Observations by measuring them, _viz._ with +1-11/16, 2-3/8, 2-11/12, and 3-3/8 Inches, and therefore the Theory of +deriving these Rings from the thickness of the Plate of Glass of which +the Speculum was made, and from the Obliquity of the emerging Rays +agrees with the Observation. In this Computation I have equalled the +Diameters of the bright Rings made by Light of all Colours, to the +Diameters of the Rings made by the bright yellow. For this yellow makes +the brightest Part of the Rings of all Colours. If you desire the +Diameters of the Rings made by the Light of any other unmix'd Colour, +you may find them readily by putting them to the Diameters of the bright +yellow ones in a subduplicate Proportion of the Intervals of the Fits of +the Rays of those Colours when equally inclined to the refracting or +reflecting Surface which caused those Fits, that is, by putting the +Diameters of the Rings made by the Rays in the Extremities and Limits of +the seven Colours, red, orange, yellow, green, blue, indigo, violet, +proportional to the Cube-roots of the Numbers, 1, 8/9, 5/6, 3/4, 2/3, +3/5, 9/16, 1/2, which express the Lengths of a Monochord sounding the +Notes in an Eighth: For by this means the Diameters of the Rings of +these Colours will be found pretty nearly in the same Proportion to one +another, which they ought to have by the fifth of these Observations. + +And thus I satisfy'd my self, that these Rings were of the same kind and +Original with those of thin Plates, and by consequence that the Fits or +alternate Dispositions of the Rays to be reflected and transmitted are +propagated to great distances from every reflecting and refracting +Surface. But yet to put the matter out of doubt, I added the following +Observation. + +_Obs._ 9. If these Rings thus depend on the thickness of the Plate of +Glass, their Diameters at equal distances from several Speculums made of +such concavo-convex Plates of Glass as are ground on the same Sphere, +ought to be reciprocally in a subduplicate Proportion of the thicknesses +of the Plates of Glass. And if this Proportion be found true by +experience it will amount to a demonstration that these Rings (like +those formed in thin Plates) do depend on the thickness of the Glass. I +procured therefore another concavo-convex Plate of Glass ground on both +sides to the same Sphere with the former Plate. Its thickness was 5/62 +Parts of an Inch; and the Diameters of the three first bright Rings +measured between the brightest Parts of their Orbits at the distance of +six Feet from the Glass were 3·4-1/6·5-1/8· Inches. Now, the thickness +of the other Glass being 1/4 of an Inch was to the thickness of this +Glass as 1/4 to 5/62, that is as 31 to 10, or 310000000 to 100000000, +and the Roots of these Numbers are 17607 and 10000, and in the +Proportion of the first of these Roots to the second are the Diameters +of the bright Rings made in this Observation by the thinner Glass, +3·4-1/6·5-1/8, to the Diameters of the same Rings made in the third of +these Observations by the thicker Glass 1-11/16, 2-3/8. 2-11/12, that +is, the Diameters of the Rings are reciprocally in a subduplicate +Proportion of the thicknesses of the Plates of Glass. + +So then in Plates of Glass which are alike concave on one side, and +alike convex on the other side, and alike quick-silver'd on the convex +sides, and differ in nothing but their thickness, the Diameters of the +Rings are reciprocally in a subduplicate Proportion of the thicknesses +of the Plates. And this shews sufficiently that the Rings depend on both +the Surfaces of the Glass. They depend on the convex Surface, because +they are more luminous when that Surface is quick-silver'd over than +when it is without Quick-silver. They depend also upon the concave +Surface, because without that Surface a Speculum makes them not. They +depend on both Surfaces, and on the distances between them, because +their bigness is varied by varying only that distance. And this +dependence is of the same kind with that which the Colours of thin +Plates have on the distance of the Surfaces of those Plates, because the +bigness of the Rings, and their Proportion to one another, and the +variation of their bigness arising from the variation of the thickness +of the Glass, and the Orders of their Colours, is such as ought to +result from the Propositions in the end of the third Part of this Book, +derived from the Phænomena of the Colours of thin Plates set down in the +first Part. + +There are yet other Phænomena of these Rings of Colours, but such as +follow from the same Propositions, and therefore confirm both the Truth +of those Propositions, and the Analogy between these Rings and the Rings +of Colours made by very thin Plates. I shall subjoin some of them. + +_Obs._ 10. When the beam of the Sun's Light was reflected back from the +Speculum not directly to the hole in the Window, but to a place a little +distant from it, the common center of that Spot, and of all the Rings of +Colours fell in the middle way between the beam of the incident Light, +and the beam of the reflected Light, and by consequence in the center of +the spherical concavity of the Speculum, whenever the Chart on which the +Rings of Colours fell was placed at that center. And as the beam of +reflected Light by inclining the Speculum receded more and more from the +beam of incident Light and from the common center of the colour'd Rings +between them, those Rings grew bigger and bigger, and so also did the +white round Spot, and new Rings of Colours emerged successively out of +their common center, and the white Spot became a white Ring +encompassing them; and the incident and reflected beams of Light always +fell upon the opposite parts of this white Ring, illuminating its +Perimeter like two mock Suns in the opposite parts of an Iris. So then +the Diameter of this Ring, measured from the middle of its Light on one +side to the middle of its Light on the other side, was always equal to +the distance between the middle of the incident beam of Light, and the +middle of the reflected beam measured at the Chart on which the Rings +appeared: And the Rays which form'd this Ring were reflected by the +Speculum in Angles equal to their Angles of Incidence, and by +consequence to their Angles of Refraction at their entrance into the +Glass, but yet their Angles of Reflexion were not in the same Planes +with their Angles of Incidence. + +_Obs._ 11. The Colours of the new Rings were in a contrary order to +those of the former, and arose after this manner. The white round Spot +of Light in the middle of the Rings continued white to the center till +the distance of the incident and reflected beams at the Chart was about +7/8 parts of an Inch, and then it began to grow dark in the middle. And +when that distance was about 1-3/16 of an Inch, the white Spot was +become a Ring encompassing a dark round Spot which in the middle +inclined to violet and indigo. And the luminous Rings encompassing it +were grown equal to those dark ones which in the four first Observations +encompassed them, that is to say, the white Spot was grown a white Ring +equal to the first of those dark Rings, and the first of those luminous +Rings was now grown equal to the second of those dark ones, and the +second of those luminous ones to the third of those dark ones, and so +on. For the Diameters of the luminous Rings were now 1-3/16, 2-1/16, +2-2/3, 3-3/20, &c. Inches. + +When the distance between the incident and reflected beams of Light +became a little bigger, there emerged out of the middle of the dark Spot +after the indigo a blue, and then out of that blue a pale green, and +soon after a yellow and red. And when the Colour at the center was +brightest, being between yellow and red, the bright Rings were grown +equal to those Rings which in the four first Observations next +encompassed them; that is to say, the white Spot in the middle of those +Rings was now become a white Ring equal to the first of those bright +Rings, and the first of those bright ones was now become equal to the +second of those, and so on. For the Diameters of the white Ring, and of +the other luminous Rings encompassing it, were now 1-11/16, 2-3/8, +2-11/12, 3-3/8, &c. or thereabouts. + +When the distance of the two beams of Light at the Chart was a little +more increased, there emerged out of the middle in order after the red, +a purple, a blue, a green, a yellow, and a red inclining much to purple, +and when the Colour was brightest being between yellow and red, the +former indigo, blue, green, yellow and red, were become an Iris or Ring +of Colours equal to the first of those luminous Rings which appeared in +the four first Observations, and the white Ring which was now become +the second of the luminous Rings was grown equal to the second of those, +and the first of those which was now become the third Ring was become +equal to the third of those, and so on. For their Diameters were +1-11/16, 2-3/8, 2-11/12, 3-3/8 Inches, the distance of the two beams of +Light, and the Diameter of the white Ring being 2-3/8 Inches. + +When these two beams became more distant there emerged out of the middle +of the purplish red, first a darker round Spot, and then out of the +middle of that Spot a brighter. And now the former Colours (purple, +blue, green, yellow, and purplish red) were become a Ring equal to the +first of the bright Rings mentioned in the four first Observations, and +the Rings about this Ring were grown equal to the Rings about that +respectively; the distance between the two beams of Light and the +Diameter of the white Ring (which was now become the third Ring) being +about 3 Inches. + +The Colours of the Rings in the middle began now to grow very dilute, +and if the distance between the two Beams was increased half an Inch, or +an Inch more, they vanish'd whilst the white Ring, with one or two of +the Rings next it on either side, continued still visible. But if the +distance of the two beams of Light was still more increased, these also +vanished: For the Light which coming from several parts of the hole in +the Window fell upon the Speculum in several Angles of Incidence, made +Rings of several bignesses, which diluted and blotted out one another, +as I knew by intercepting some part of that Light. For if I intercepted +that part which was nearest to the Axis of the Speculum the Rings would +be less, if the other part which was remotest from it they would be +bigger. + +_Obs._ 12. When the Colours of the Prism were cast successively on the +Speculum, that Ring which in the two last Observations was white, was of +the same bigness in all the Colours, but the Rings without it were +greater in the green than in the blue, and still greater in the yellow, +and greatest in the red. And, on the contrary, the Rings within that +white Circle were less in the green than in the blue, and still less in +the yellow, and least in the red. For the Angles of Reflexion of those +Rays which made this Ring, being equal to their Angles of Incidence, the +Fits of every reflected Ray within the Glass after Reflexion are equal +in length and number to the Fits of the same Ray within the Glass before +its Incidence on the reflecting Surface. And therefore since all the +Rays of all sorts at their entrance into the Glass were in a Fit of +Transmission, they were also in a Fit of Transmission at their returning +to the same Surface after Reflexion; and by consequence were +transmitted, and went out to the white Ring on the Chart. This is the +reason why that Ring was of the same bigness in all the Colours, and why +in a mixture of all it appears white. But in Rays which are reflected in +other Angles, the Intervals of the Fits of the least refrangible being +greatest, make the Rings of their Colour in their progress from this +white Ring, either outwards or inwards, increase or decrease by the +greatest steps; so that the Rings of this Colour without are greatest, +and within least. And this is the reason why in the last Observation, +when the Speculum was illuminated with white Light, the exterior Rings +made by all Colours appeared red without and blue within, and the +interior blue without and red within. + +These are the Phænomena of thick convexo-concave Plates of Glass, which +are every where of the same thickness. There are yet other Phænomena +when these Plates are a little thicker on one side than on the other, +and others when the Plates are more or less concave than convex, or +plano-convex, or double-convex. For in all these cases the Plates make +Rings of Colours, but after various manners; all which, so far as I have +yet observed, follow from the Propositions in the end of the third part +of this Book, and so conspire to confirm the truth of those +Propositions. But the Phænomena are too various, and the Calculations +whereby they follow from those Propositions too intricate to be here +prosecuted. I content my self with having prosecuted this kind of +Phænomena so far as to discover their Cause, and by discovering it to +ratify the Propositions in the third Part of this Book. + +_Obs._ 13. As Light reflected by a Lens quick-silver'd on the backside +makes the Rings of Colours above described, so it ought to make the like +Rings of Colours in passing through a drop of Water. At the first +Reflexion of the Rays within the drop, some Colours ought to be +transmitted, as in the case of a Lens, and others to be reflected back +to the Eye. For instance, if the Diameter of a small drop or globule of +Water be about the 500th part of an Inch, so that a red-making Ray in +passing through the middle of this globule has 250 Fits of easy +Transmission within the globule, and that all the red-making Rays which +are at a certain distance from this middle Ray round about it have 249 +Fits within the globule, and all the like Rays at a certain farther +distance round about it have 248 Fits, and all those at a certain +farther distance 247 Fits, and so on; these concentrick Circles of Rays +after their transmission, falling on a white Paper, will make +concentrick Rings of red upon the Paper, supposing the Light which +passes through one single globule, strong enough to be sensible. And, in +like manner, the Rays of other Colours will make Rings of other Colours. +Suppose now that in a fair Day the Sun shines through a thin Cloud of +such globules of Water or Hail, and that the globules are all of the +same bigness; and the Sun seen through this Cloud shall appear +encompassed with the like concentrick Rings of Colours, and the Diameter +of the first Ring of red shall be 7-1/4 Degrees, that of the second +10-1/4 Degrees, that of the third 12 Degrees 33 Minutes. And accordingly +as the Globules of Water are bigger or less, the Rings shall be less or +bigger. This is the Theory, and Experience answers it. For in _June_ +1692, I saw by reflexion in a Vessel of stagnating Water three Halos, +Crowns, or Rings of Colours about the Sun, like three little Rain-bows, +concentrick to his Body. The Colours of the first or innermost Crown +were blue next the Sun, red without, and white in the middle between the +blue and red. Those of the second Crown were purple and blue within, and +pale red without, and green in the middle. And those of the third were +pale blue within, and pale red without; these Crowns enclosed one +another immediately, so that their Colours proceeded in this continual +order from the Sun outward: blue, white, red; purple, blue, green, pale +yellow and red; pale blue, pale red. The Diameter of the second Crown +measured from the middle of the yellow and red on one side of the Sun, +to the middle of the same Colour on the other side was 9-1/3 Degrees, or +thereabouts. The Diameters of the first and third I had not time to +measure, but that of the first seemed to be about five or six Degrees, +and that of the third about twelve. The like Crowns appear sometimes +about the Moon; for in the beginning of the Year 1664, _Febr._ 19th at +Night, I saw two such Crowns about her. The Diameter of the first or +innermost was about three Degrees, and that of the second about five +Degrees and an half. Next about the Moon was a Circle of white, and next +about that the inner Crown, which was of a bluish green within next the +white, and of a yellow and red without, and next about these Colours +were blue and green on the inside of the outward Crown, and red on the +outside of it. At the same time there appear'd a Halo about 22 Degrees +35´ distant from the center of the Moon. It was elliptical, and its long +Diameter was perpendicular to the Horizon, verging below farthest from +the Moon. I am told that the Moon has sometimes three or more +concentrick Crowns of Colours encompassing one another next about her +Body. The more equal the globules of Water or Ice are to one another, +the more Crowns of Colours will appear, and the Colours will be the more +lively. The Halo at the distance of 22-1/2 Degrees from the Moon is of +another sort. By its being oval and remoter from the Moon below than +above, I conclude, that it was made by Refraction in some sort of Hail +or Snow floating in the Air in an horizontal posture, the refracting +Angle being about 58 or 60 Degrees. + + + + +THE + +THIRD BOOK + +OF + +OPTICKS + + +_PART I._ + +_Observations concerning the Inflexions of the Rays of Light, and the +Colours made thereby._ + +Grimaldo has inform'd us, that if a beam of the Sun's Light be let into +a dark Room through a very small hole, the Shadows of things in this +Light will be larger than they ought to be if the Rays went on by the +Bodies in straight Lines, and that these Shadows have three parallel +Fringes, Bands or Ranks of colour'd Light adjacent to them. But if the +Hole be enlarged the Fringes grow broad and run into one another, so +that they cannot be distinguish'd. These broad Shadows and Fringes have +been reckon'd by some to proceed from the ordinary refraction of the +Air, but without due examination of the Matter. For the circumstances of +the Phænomenon, so far as I have observed them, are as follows. + +_Obs._ 1. I made in a piece of Lead a small Hole with a Pin, whose +breadth was the 42d part of an Inch. For 21 of those Pins laid together +took up the breadth of half an Inch. Through this Hole I let into my +darken'd Chamber a beam of the Sun's Light, and found that the Shadows +of Hairs, Thred, Pins, Straws, and such like slender Substances placed +in this beam of Light, were considerably broader than they ought to be, +if the Rays of Light passed on by these Bodies in right Lines. And +particularly a Hair of a Man's Head, whose breadth was but the 280th +part of an Inch, being held in this Light, at the distance of about +twelve Feet from the Hole, did cast a Shadow which at the distance of +four Inches from the Hair was the sixtieth part of an Inch broad, that +is, above four times broader than the Hair, and at the distance of two +Feet from the Hair was about the eight and twentieth part of an Inch +broad, that is, ten times broader than the Hair, and at the distance of +ten Feet was the eighth part of an Inch broad, that is 35 times broader. + +Nor is it material whether the Hair be encompassed with Air, or with any +other pellucid Substance. For I wetted a polish'd Plate of Glass, and +laid the Hair in the Water upon the Glass, and then laying another +polish'd Plate of Glass upon it, so that the Water might fill up the +space between the Glasses, I held them in the aforesaid beam of Light, +so that the Light might pass through them perpendicularly, and the +Shadow of the Hair was at the same distances as big as before. The +Shadows of Scratches made in polish'd Plates of Glass were also much +broader than they ought to be, and the Veins in polish'd Plates of Glass +did also cast the like broad Shadows. And therefore the great breadth of +these Shadows proceeds from some other cause than the Refraction of the +Air. + +Let the Circle X [in _Fig._ 1.] represent the middle of the Hair; ADG, +BEH, CFI, three Rays passing by one side of the Hair at several +distances; KNQ, LOR, MPS, three other Rays passing by the other side of +the Hair at the like distances; D, E, F, and N, O, P, the places where +the Rays are bent in their passage by the Hair; G, H, I, and Q, R, S, +the places where the Rays fall on a Paper GQ; IS the breadth of the +Shadow of the Hair cast on the Paper, and TI, VS, two Rays passing to +the Points I and S without bending when the Hair is taken away. And it's +manifest that all the Light between these two Rays TI and VS is bent in +passing by the Hair, and turned aside from the Shadow IS, because if any +part of this Light were not bent it would fall on the Paper within the +Shadow, and there illuminate the Paper, contrary to experience. And +because when the Paper is at a great distance from the Hair, the Shadow +is broad, and therefore the Rays TI and VS are at a great distance from +one another, it follows that the Hair acts upon the Rays of Light at a +good distance in their passing by it. But the Action is strongest on the +Rays which pass by at least distances, and grows weaker and weaker +accordingly as the Rays pass by at distances greater and greater, as is +represented in the Scheme: For thence it comes to pass, that the Shadow +of the Hair is much broader in proportion to the distance of the Paper +from the Hair, when the Paper is nearer the Hair, than when it is at a +great distance from it. + +_Obs._ 2. The Shadows of all Bodies (Metals, Stones, Glass, Wood, Horn, +Ice, &c.) in this Light were border'd with three Parallel Fringes or +Bands of colour'd Light, whereof that which was contiguous to the Shadow +was broadest and most luminous, and that which was remotest from it was +narrowest, and so faint, as not easily to be visible. It was difficult +to distinguish the Colours, unless when the Light fell very obliquely +upon a smooth Paper, or some other smooth white Body, so as to make them +appear much broader than they would otherwise do. And then the Colours +were plainly visible in this Order: The first or innermost Fringe was +violet and deep blue next the Shadow, and then light blue, green, and +yellow in the middle, and red without. The second Fringe was almost +contiguous to the first, and the third to the second, and both were blue +within, and yellow and red without, but their Colours were very faint, +especially those of the third. The Colours therefore proceeded in this +order from the Shadow; violet, indigo, pale blue, green, yellow, red; +blue, yellow, red; pale blue, pale yellow and red. The Shadows made by +Scratches and Bubbles in polish'd Plates of Glass were border'd with the +like Fringes of colour'd Light. And if Plates of Looking-glass sloop'd +off near the edges with a Diamond-cut, be held in the same beam of +Light, the Light which passes through the parallel Planes of the Glass +will be border'd with the like Fringes of Colours where those Planes +meet with the Diamond-cut, and by this means there will sometimes appear +four or five Fringes of Colours. Let AB, CD [in _Fig._ 2.] represent the +parallel Planes of a Looking-glass, and BD the Plane of the Diamond-cut, +making at B a very obtuse Angle with the Plane AB. And let all the Light +between the Rays ENI and FBM pass directly through the parallel Planes +of the Glass, and fall upon the Paper between I and M, and all the Light +between the Rays GO and HD be refracted by the oblique Plane of the +Diamond-cut BD, and fall upon the Paper between K and L; and the Light +which passes directly through the parallel Planes of the Glass, and +falls upon the Paper between I and M, will be border'd with three or +more Fringes at M. + +[Illustration: FIG. 1.] + +[Illustration: FIG. 2.] + +So by looking on the Sun through a Feather or black Ribband held close +to the Eye, several Rain-bows will appear; the Shadows which the Fibres +or Threds cast on the _Tunica Retina_, being border'd with the like +Fringes of Colours. + +_Obs._ 3. When the Hair was twelve Feet distant from this Hole, and its +Shadow fell obliquely upon a flat white Scale of Inches and Parts of an +Inch placed half a Foot beyond it, and also when the Shadow fell +perpendicularly upon the same Scale placed nine Feet beyond it; I +measured the breadth of the Shadow and Fringes as accurately as I could, +and found them in Parts of an Inch as follows. + +-------------------------------------------+-----------+-------- + | half a | Nine + At the Distance of | Foot | Feet +-------------------------------------------+-----------+-------- +The breadth of the Shadow | 1/54 | 1/9 +-------------------------------------------+-----------+-------- +The breadth between the Middles of the | 1/38 | + brightest Light of the innermost Fringes | or | + on either side the Shadow | 1/39 | 7/50 +-------------------------------------------+-----------+-------- +The breadth between the Middles of the | | + brightest Light of the middlemost Fringes| | + on either side the Shadow | 1/23-1/2 | 4/17 +-------------------------------------------+-----------+-------- +The breadth between the Middles of the | 1/18 | + brightest Light of the outmost Fringes | or | + on either side the Shadow | 1/18-1/2 | 3/10 +-------------------------------------------+-----------+-------- +The distance between the Middles of the | | + brightest Light of the first and second | | + Fringes | 1/120 | 1/21 +-------------------------------------------+-----------+-------- +The distance between the Middles of the | | + brightest Light of the second and third | | + Fringes | 1/170 | 1/31 +-------------------------------------------+-----------+-------- +The breadth of the luminous Part (green, | | + white, yellow, and red) of the first | | + Fringe | 1/170 | 1/32 +-------------------------------------------+-----------+-------- +The breadth of the darker Space between | | + the first and second Fringes | 1/240 | 1/45 +-------------------------------------------+-----------+-------- +The breadth of the luminous Part of the | | + second Fringe | 1/290 | 1/55 +-------------------------------------------+-----------+-------- +The breadth of the darker Space between | | + the second and third Fringes | 1/340 | 1/63 +-------------------------------------------+-----------+-------- + +These Measures I took by letting the Shadow of the Hair, at half a Foot +distance, fall so obliquely on the Scale, as to appear twelve times +broader than when it fell perpendicularly on it at the same distance, +and setting down in this Table the twelfth part of the Measures I then +took. + +_Obs._ 4. When the Shadow and Fringes were cast obliquely upon a smooth +white Body, and that Body was removed farther and farther from the Hair, +the first Fringe began to appear and look brighter than the rest of the +Light at the distance of less than a quarter of an Inch from the Hair, +and the dark Line or Shadow between that and the second Fringe began to +appear at a less distance from the Hair than that of the third part of +an Inch. The second Fringe began to appear at a distance from the Hair +of less than half an Inch, and the Shadow between that and the third +Fringe at a distance less than an inch, and the third Fringe at a +distance less than three Inches. At greater distances they became much +more sensible, but kept very nearly the same proportion of their +breadths and intervals which they had at their first appearing. For the +distance between the middle of the first, and middle of the second +Fringe, was to the distance between the middle of the second and middle +of the third Fringe, as three to two, or ten to seven. And the last of +these two distances was equal to the breadth of the bright Light or +luminous part of the first Fringe. And this breadth was to the breadth +of the bright Light of the second Fringe as seven to four, and to the +dark Interval of the first and second Fringe as three to two, and to +the like dark Interval between the second and third as two to one. For +the breadths of the Fringes seem'd to be in the progression of the +Numbers 1, sqrt(1/3), sqrt(1/5), and their Intervals to be in the +same progression with them; that is, the Fringes and their Intervals +together to be in the continual progression of the Numbers 1, +sqrt(1/2), sqrt(1/3), sqrt(1/4), sqrt(1/5), or thereabouts. And +these Proportions held the same very nearly at all distances from the +Hair; the dark Intervals of the Fringes being as broad in proportion to +the breadth of the Fringes at their first appearance as afterwards at +great distances from the Hair, though not so dark and distinct. + +_Obs._ 5. The Sun shining into my darken'd Chamber through a hole a +quarter of an Inch broad, I placed at the distance of two or three Feet +from the Hole a Sheet of Pasteboard, which was black'd all over on both +sides, and in the middle of it had a hole about three quarters of an +Inch square for the Light to pass through. And behind the hole I +fasten'd to the Pasteboard with Pitch the blade of a sharp Knife, to +intercept some part of the Light which passed through the hole. The +Planes of the Pasteboard and blade of the Knife were parallel to one +another, and perpendicular to the Rays. And when they were so placed +that none of the Sun's Light fell on the Pasteboard, but all of it +passed through the hole to the Knife, and there part of it fell upon the +blade of the Knife, and part of it passed by its edge; I let this part +of the Light which passed by, fall on a white Paper two or three Feet +beyond the Knife, and there saw two streams of faint Light shoot out +both ways from the beam of Light into the shadow, like the Tails of +Comets. But because the Sun's direct Light by its brightness upon the +Paper obscured these faint streams, so that I could scarce see them, I +made a little hole in the midst of the Paper for that Light to pass +through and fall on a black Cloth behind it; and then I saw the two +streams plainly. They were like one another, and pretty nearly equal in +length, and breadth, and quantity of Light. Their Light at that end next +the Sun's direct Light was pretty strong for the space of about a +quarter of an Inch, or half an Inch, and in all its progress from that +direct Light decreased gradually till it became insensible. The whole +length of either of these streams measured upon the paper at the +distance of three Feet from the Knife was about six or eight Inches; so +that it subtended an Angle at the edge of the Knife of about 10 or 12, +or at most 14 Degrees. Yet sometimes I thought I saw it shoot three or +four Degrees farther, but with a Light so very faint that I could scarce +perceive it, and suspected it might (in some measure at least) arise +from some other cause than the two streams did. For placing my Eye in +that Light beyond the end of that stream which was behind the Knife, and +looking towards the Knife, I could see a line of Light upon its edge, +and that not only when my Eye was in the line of the Streams, but also +when it was without that line either towards the point of the Knife, or +towards the handle. This line of Light appear'd contiguous to the edge +of the Knife, and was narrower than the Light of the innermost Fringe, +and narrowest when my Eye was farthest from the direct Light, and +therefore seem'd to pass between the Light of that Fringe and the edge +of the Knife, and that which passed nearest the edge to be most bent, +though not all of it. + +_Obs._ 6. I placed another Knife by this, so that their edges might be +parallel, and look towards one another, and that the beam of Light might +fall upon both the Knives, and some part of it pass between their edges. +And when the distance of their edges was about the 400th part of an +Inch, the stream parted in the middle, and left a Shadow between the two +parts. This Shadow was so black and dark that all the Light which passed +between the Knives seem'd to be bent, and turn'd aside to the one hand +or to the other. And as the Knives still approach'd one another the +Shadow grew broader, and the streams shorter at their inward ends which +were next the Shadow, until upon the contact of the Knives the whole +Light vanish'd, leaving its place to the Shadow. + +And hence I gather that the Light which is least bent, and goes to the +inward ends of the streams, passes by the edges of the Knives at the +greatest distance, and this distance when the Shadow begins to appear +between the streams, is about the 800th part of an Inch. And the Light +which passes by the edges of the Knives at distances still less and +less, is more and more bent, and goes to those parts of the streams +which are farther and farther from the direct Light; because when the +Knives approach one another till they touch, those parts of the streams +vanish last which are farthest from the direct Light. + +_Obs._ 7. In the fifth Observation the Fringes did not appear, but by +reason of the breadth of the hole in the Window became so broad as to +run into one another, and by joining, to make one continued Light in the +beginning of the streams. But in the sixth, as the Knives approached one +another, a little before the Shadow appeared between the two streams, +the Fringes began to appear on the inner ends of the Streams on either +side of the direct Light; three on one side made by the edge of one +Knife, and three on the other side made by the edge of the other Knife. +They were distinctest when the Knives were placed at the greatest +distance from the hole in the Window, and still became more distinct by +making the hole less, insomuch that I could sometimes see a faint +lineament of a fourth Fringe beyond the three above mention'd. And as +the Knives continually approach'd one another, the Fringes grew +distincter and larger, until they vanish'd. The outmost Fringe vanish'd +first, and the middlemost next, and the innermost last. And after they +were all vanish'd, and the line of Light which was in the middle between +them was grown very broad, enlarging it self on both sides into the +streams of Light described in the fifth Observation, the above-mention'd +Shadow began to appear in the middle of this line, and divide it along +the middle into two lines of Light, and increased until the whole Light +vanish'd. This enlargement of the Fringes was so great that the Rays +which go to the innermost Fringe seem'd to be bent above twenty times +more when this Fringe was ready to vanish, than when one of the Knives +was taken away. + +And from this and the former Observation compared, I gather, that the +Light of the first Fringe passed by the edge of the Knife at a distance +greater than the 800th part of an Inch, and the Light of the second +Fringe passed by the edge of the Knife at a greater distance than the +Light of the first Fringe did, and that of the third at a greater +distance than that of the second, and that of the streams of Light +described in the fifth and sixth Observations passed by the edges of the +Knives at less distances than that of any of the Fringes. + +_Obs._ 8. I caused the edges of two Knives to be ground truly strait, +and pricking their points into a Board so that their edges might look +towards one another, and meeting near their points contain a rectilinear +Angle, I fasten'd their Handles together with Pitch to make this Angle +invariable. The distance of the edges of the Knives from one another at +the distance of four Inches from the angular Point, where the edges of +the Knives met, was the eighth part of an Inch; and therefore the Angle +contain'd by the edges was about one Degree 54: The Knives thus fix'd +together I placed in a beam of the Sun's Light, let into my darken'd +Chamber through a Hole the 42d Part of an Inch wide, at the distance of +10 or 15 Feet from the Hole, and let the Light which passed between +their edges fall very obliquely upon a smooth white Ruler at the +distance of half an Inch, or an Inch from the Knives, and there saw the +Fringes by the two edges of the Knives run along the edges of the +Shadows of the Knives in Lines parallel to those edges without growing +sensibly broader, till they met in Angles equal to the Angle contained +by the edges of the Knives, and where they met and joined they ended +without crossing one another. But if the Ruler was held at a much +greater distance from the Knives, the Fringes where they were farther +from the Place of their Meeting, were a little narrower, and became +something broader and broader as they approach'd nearer and nearer to +one another, and after they met they cross'd one another, and then +became much broader than before. + +Whence I gather that the distances at which the Fringes pass by the +Knives are not increased nor alter'd by the approach of the Knives, but +the Angles in which the Rays are there bent are much increased by that +approach; and that the Knife which is nearest any Ray determines which +way the Ray shall be bent, and the other Knife increases the bent. + +_Obs._ 9. When the Rays fell very obliquely upon the Ruler at the +distance of the third Part of an Inch from the Knives, the dark Line +between the first and second Fringe of the Shadow of one Knife, and the +dark Line between the first and second Fringe of the Shadow of the other +knife met with one another, at the distance of the fifth Part of an Inch +from the end of the Light which passed between the Knives at the +concourse of their edges. And therefore the distance of the edges of the +Knives at the meeting of these dark Lines was the 160th Part of an Inch. +For as four Inches to the eighth Part of an Inch, so is any Length of +the edges of the Knives measured from the point of their concourse to +the distance of the edges of the Knives at the end of that Length, and +so is the fifth Part of an Inch to the 160th Part. So then the dark +Lines above-mention'd meet in the middle of the Light which passes +between the Knives where they are distant the 160th Part of an Inch, and +the one half of that Light passes by the edge of one Knife at a distance +not greater than the 320th Part of an Inch, and falling upon the Paper +makes the Fringes of the Shadow of that Knife, and the other half passes +by the edge of the other Knife, at a distance not greater than the 320th +Part of an Inch, and falling upon the Paper makes the Fringes of the +Shadow of the other Knife. But if the Paper be held at a distance from +the Knives greater than the third Part of an Inch, the dark Lines +above-mention'd meet at a greater distance than the fifth Part of an +Inch from the end of the Light which passed between the Knives at the +concourse of their edges; and therefore the Light which falls upon the +Paper where those dark Lines meet passes between the Knives where the +edges are distant above the 160th part of an Inch. + +For at another time, when the two Knives were distant eight Feet and +five Inches from the little hole in the Window, made with a small Pin as +above, the Light which fell upon the Paper where the aforesaid dark +lines met, passed between the Knives, where the distance between their +edges was as in the following Table, when the distance of the Paper from +the Knives was also as follows. + +-----------------------------+------------------------------ + | Distances between the edges + Distances of the Paper | of the Knives in millesimal + from the Knives in Inches. | parts of an Inch. +-----------------------------+------------------------------ + 1-1/2. | 0'012 + 3-1/3. | 0'020 + 8-3/5. | 0'034 + 32. | 0'057 + 96. | 0'081 + 131. | 0'087 +_____________________________|______________________________ + +And hence I gather, that the Light which makes the Fringes upon the +Paper is not the same Light at all distances of the Paper from the +Knives, but when the Paper is held near the Knives, the Fringes are made +by Light which passes by the edges of the Knives at a less distance, and +is more bent than when the Paper is held at a greater distance from the +Knives. + +[Illustration: FIG. 3.] + +_Obs._ 10. When the Fringes of the Shadows of the Knives fell +perpendicularly upon a Paper at a great distance from the Knives, they +were in the form of Hyperbola's, and their Dimensions were as follows. +Let CA, CB [in _Fig._ 3.] represent Lines drawn upon the Paper parallel +to the edges of the Knives, and between which all the Light would fall, +if it passed between the edges of the Knives without inflexion; DE a +Right Line drawn through C making the Angles ACD, BCE, equal to one +another, and terminating all the Light which falls upon the Paper from +the point where the edges of the Knives meet; _eis_, _fkt_, and _glv_, +three hyperbolical Lines representing the Terminus of the Shadow of one +of the Knives, the dark Line between the first and second Fringes of +that Shadow, and the dark Line between the second and third Fringes of +the same Shadow; _xip_, _ykq_, and _zlr_, three other hyperbolical Lines +representing the Terminus of the Shadow of the other Knife, the dark +Line between the first and second Fringes of that Shadow, and the dark +line between the second and third Fringes of the same Shadow. And +conceive that these three Hyperbola's are like and equal to the former +three, and cross them in the points _i_, _k_, and _l_, and that the +Shadows of the Knives are terminated and distinguish'd from the first +luminous Fringes by the lines _eis_ and _xip_, until the meeting and +crossing of the Fringes, and then those lines cross the Fringes in the +form of dark lines, terminating the first luminous Fringes within side, +and distinguishing them from another Light which begins to appear at +_i_, and illuminates all the triangular space _ip_DE_s_ comprehended by +these dark lines, and the right line DE. Of these Hyperbola's one +Asymptote is the line DE, and their other Asymptotes are parallel to the +lines CA and CB. Let _rv_ represent a line drawn any where upon the +Paper parallel to the Asymptote DE, and let this line cross the right +lines AC in _m_, and BC in _n_, and the six dark hyperbolical lines in +_p_, _q_, _r_; _s_, _t_, _v_; and by measuring the distances _ps_, _qt_, +_rv_, and thence collecting the lengths of the Ordinates _np_, _nq_, +_nr_ or _ms_, _mt_, _mv_, and doing this at several distances of the +line _rv_ from the Asymptote DD, you may find as many points of these +Hyperbola's as you please, and thereby know that these curve lines are +Hyperbola's differing little from the conical Hyperbola. And by +measuring the lines C_i_, C_k_, C_l_, you may find other points of these +Curves. + +For instance; when the Knives were distant from the hole in the Window +ten Feet, and the Paper from the Knives nine Feet, and the Angle +contained by the edges of the Knives to which the Angle ACB is equal, +was subtended by a Chord which was to the Radius as 1 to 32, and the +distance of the line _rv_ from the Asymptote DE was half an Inch: I +measured the lines _ps_, _qt_, _rv_, and found them 0'35, 0'65, 0'98 +Inches respectively; and by adding to their halfs the line 1/2 _mn_, +(which here was the 128th part of an Inch, or 0'0078 Inches,) the Sums +_np_, _nq_, _nr_, were 0'1828, 0'3328, 0'4978 Inches. I measured also +the distances of the brightest parts of the Fringes which run between +_pq_ and _st_, _qr_ and _tv_, and next beyond _r_ and _v_, and found +them 0'5, 0'8, and 1'17 Inches. + +_Obs._ 11. The Sun shining into my darken'd Room through a small round +hole made in a Plate of Lead with a slender Pin, as above; I placed at +the hole a Prism to refract the Light, and form on the opposite Wall the +Spectrum of Colours, described in the third Experiment of the first +Book. And then I found that the Shadows of all Bodies held in the +colour'd Light between the Prism and the Wall, were border'd with +Fringes of the Colour of that Light in which they were held. In the full +red Light they were totally red without any sensible blue or violet, and +in the deep blue Light they were totally blue without any sensible red +or yellow; and so in the green Light they were totally green, excepting +a little yellow and blue, which were mixed in the green Light of the +Prism. And comparing the Fringes made in the several colour'd Lights, I +found that those made in the red Light were largest, those made in the +violet were least, and those made in the green were of a middle bigness. +For the Fringes with which the Shadow of a Man's Hair were bordered, +being measured cross the Shadow at the distance of six Inches from the +Hair, the distance between the middle and most luminous part of the +first or innermost Fringe on one side of the Shadow, and that of the +like Fringe on the other side of the Shadow, was in the full red Light +1/37-1/4 of an Inch, and in the full violet 7/46. And the like distance +between the middle and most luminous parts of the second Fringes on +either side the Shadow was in the full red Light 1/22, and in the violet +1/27 of an Inch. And these distances of the Fringes held the same +proportion at all distances from the Hair without any sensible +variation. + +So then the Rays which made these Fringes in the red Light passed by the +Hair at a greater distance than those did which made the like Fringes in +the violet; and therefore the Hair in causing these Fringes acted alike +upon the red Light or least refrangible Rays at a greater distance, and +upon the violet or most refrangible Rays at a less distance, and by +those actions disposed the red Light into Larger Fringes, and the violet +into smaller, and the Lights of intermediate Colours into Fringes of +intermediate bignesses without changing the Colour of any sort of Light. + +When therefore the Hair in the first and second of these Observations +was held in the white beam of the Sun's Light, and cast a Shadow which +was border'd with three Fringes of coloured Light, those Colours arose +not from any new modifications impress'd upon the Rays of Light by the +Hair, but only from the various inflexions whereby the several Sorts of +Rays were separated from one another, which before separation, by the +mixture of all their Colours, composed the white beam of the Sun's +Light, but whenever separated compose Lights of the several Colours +which they are originally disposed to exhibit. In this 11th Observation, +where the Colours are separated before the Light passes by the Hair, the +least refrangible Rays, which when separated from the rest make red, +were inflected at a greater distance from the Hair, so as to make three +red Fringes at a greater distance from the middle of the Shadow of the +Hair; and the most refrangible Rays which when separated make violet, +were inflected at a less distance from the Hair, so as to make three +violet Fringes at a less distance from the middle of the Shadow of the +Hair. And other Rays of intermediate degrees of Refrangibility were +inflected at intermediate distances from the Hair, so as to make Fringes +of intermediate Colours at intermediate distances from the middle of the +Shadow of the Hair. And in the second Observation, where all the Colours +are mix'd in the white Light which passes by the Hair, these Colours are +separated by the various inflexions of the Rays, and the Fringes which +they make appear all together, and the innermost Fringes being +contiguous make one broad Fringe composed of all the Colours in due +order, the violet lying on the inside of the Fringe next the Shadow, the +red on the outside farthest from the Shadow, and the blue, green, and +yellow, in the middle. And, in like manner, the middlemost Fringes of +all the Colours lying in order, and being contiguous, make another broad +Fringe composed of all the Colours; and the outmost Fringes of all the +Colours lying in order, and being contiguous, make a third broad Fringe +composed of all the Colours. These are the three Fringes of colour'd +Light with which the Shadows of all Bodies are border'd in the second +Observation. + +When I made the foregoing Observations, I design'd to repeat most of +them with more care and exactness, and to make some new ones for +determining the manner how the Rays of Light are bent in their passage +by Bodies, for making the Fringes of Colours with the dark lines between +them. But I was then interrupted, and cannot now think of taking these +things into farther Consideration. And since I have not finish'd this +part of my Design, I shall conclude with proposing only some Queries, in +order to a farther search to be made by others. + +_Query_ 1. Do not Bodies act upon Light at a distance, and by their +action bend its Rays; and is not this action (_cæteris paribus_) +strongest at the least distance? + +_Qu._ 2. Do not the Rays which differ in Refrangibility differ also in +Flexibity; and are they not by their different Inflexions separated from +one another, so as after separation to make the Colours in the three +Fringes above described? And after what manner are they inflected to +make those Fringes? + +_Qu._ 3. Are not the Rays of Light in passing by the edges and sides of +Bodies, bent several times backwards and forwards, with a motion like +that of an Eel? And do not the three Fringes of colour'd Light +above-mention'd arise from three such bendings? + +_Qu._ 4. Do not the Rays of Light which fall upon Bodies, and are +reflected or refracted, begin to bend before they arrive at the Bodies; +and are they not reflected, refracted, and inflected, by one and the +same Principle, acting variously in various Circumstances? + +_Qu._ 5. Do not Bodies and Light act mutually upon one another; that is +to say, Bodies upon Light in emitting, reflecting, refracting and +inflecting it, and Light upon Bodies for heating them, and putting their +parts into a vibrating motion wherein heat consists? + +_Qu._ 6. Do not black Bodies conceive heat more easily from Light than +those of other Colours do, by reason that the Light falling on them is +not reflected outwards, but enters the Bodies, and is often reflected +and refracted within them, until it be stifled and lost? + +_Qu._ 7. Is not the strength and vigor of the action between Light and +sulphureous Bodies observed above, one reason why sulphureous Bodies +take fire more readily, and burn more vehemently than other Bodies do? + +_Qu._ 8. Do not all fix'd Bodies, when heated beyond a certain degree, +emit Light and shine; and is not this Emission perform'd by the +vibrating motions of their parts? And do not all Bodies which abound +with terrestrial parts, and especially with sulphureous ones, emit Light +as often as those parts are sufficiently agitated; whether that +agitation be made by Heat, or by Friction, or Percussion, or +Putrefaction, or by any vital Motion, or any other Cause? As for +instance; Sea-Water in a raging Storm; Quick-silver agitated in _vacuo_; +the Back of a Cat, or Neck of a Horse, obliquely struck or rubbed in a +dark place; Wood, Flesh and Fish while they putrefy; Vapours arising +from putrefy'd Waters, usually call'd _Ignes Fatui_; Stacks of moist Hay +or Corn growing hot by fermentation; Glow-worms and the Eyes of some +Animals by vital Motions; the vulgar _Phosphorus_ agitated by the +attrition of any Body, or by the acid Particles of the Air; Amber and +some Diamonds by striking, pressing or rubbing them; Scrapings of Steel +struck off with a Flint; Iron hammer'd very nimbly till it become so hot +as to kindle Sulphur thrown upon it; the Axletrees of Chariots taking +fire by the rapid rotation of the Wheels; and some Liquors mix'd with +one another whose Particles come together with an Impetus, as Oil of +Vitriol distilled from its weight of Nitre, and then mix'd with twice +its weight of Oil of Anniseeds. So also a Globe of Glass about 8 or 10 +Inches in diameter, being put into a Frame where it may be swiftly +turn'd round its Axis, will in turning shine where it rubs against the +palm of ones Hand apply'd to it: And if at the same time a piece of +white Paper or white Cloth, or the end of ones Finger be held at the +distance of about a quarter of an Inch or half an Inch from that part of +the Glass where it is most in motion, the electrick Vapour which is +excited by the friction of the Glass against the Hand, will by dashing +against the white Paper, Cloth or Finger, be put into such an agitation +as to emit Light, and make the white Paper, Cloth or Finger, appear +lucid like a Glowworm; and in rushing out of the Glass will sometimes +push against the finger so as to be felt. And the same things have been +found by rubbing a long and large Cylinder or Glass or Amber with a +Paper held in ones hand, and continuing the friction till the Glass grew +warm. + +_Qu._ 9. Is not Fire a Body heated so hot as to emit Light copiously? +For what else is a red hot Iron than Fire? And what else is a burning +Coal than red hot Wood? + +_Qu._ 10. Is not Flame a Vapour, Fume or Exhalation heated red hot, that +is, so hot as to shine? For Bodies do not flame without emitting a +copious Fume, and this Fume burns in the Flame. The _Ignis Fatuus_ is a +Vapour shining without heat, and is there not the same difference +between this Vapour and Flame, as between rotten Wood shining without +heat and burning Coals of Fire? In distilling hot Spirits, if the Head +of the Still be taken off, the Vapour which ascends out of the Still +will take fire at the Flame of a Candle, and turn into Flame, and the +Flame will run along the Vapour from the Candle to the Still. Some +Bodies heated by Motion, or Fermentation, if the heat grow intense, fume +copiously, and if the heat be great enough the Fumes will shine and +become Flame. Metals in fusion do not flame for want of a copious Fume, +except Spelter, which fumes copiously, and thereby flames. All flaming +Bodies, as Oil, Tallow, Wax, Wood, fossil Coals, Pitch, Sulphur, by +flaming waste and vanish into burning Smoke, which Smoke, if the Flame +be put out, is very thick and visible, and sometimes smells strongly, +but in the Flame loses its smell by burning, and according to the nature +of the Smoke the Flame is of several Colours, as that of Sulphur blue, +that of Copper open'd with sublimate green, that of Tallow yellow, that +of Camphire white. Smoke passing through Flame cannot but grow red hot, +and red hot Smoke can have no other appearance than that of Flame. When +Gun-powder takes fire, it goes away into Flaming Smoke. For the Charcoal +and Sulphur easily take fire, and set fire to the Nitre, and the Spirit +of the Nitre being thereby rarified into Vapour, rushes out with +Explosion much after the manner that the Vapour of Water rushes out of +an Æolipile; the Sulphur also being volatile is converted into Vapour, +and augments the Explosion. And the acid Vapour of the Sulphur (namely +that which distils under a Bell into Oil of Sulphur,) entring violently +into the fix'd Body of the Nitre, sets loose the Spirit of the Nitre, +and excites a great Fermentation, whereby the Heat is farther augmented, +and the fix'd Body of the Nitre is also rarified into Fume, and the +Explosion is thereby made more vehement and quick. For if Salt of Tartar +be mix'd with Gun-powder, and that Mixture be warm'd till it takes fire, +the Explosion will be more violent and quick than that of Gun-powder +alone; which cannot proceed from any other cause than the action of the +Vapour of the Gun-powder upon the Salt of Tartar, whereby that Salt is +rarified. The Explosion of Gun-powder arises therefore from the violent +action whereby all the Mixture being quickly and vehemently heated, is +rarified and converted into Fume and Vapour: which Vapour, by the +violence of that action, becoming so hot as to shine, appears in the +form of Flame. + +_Qu._ 11. Do not great Bodies conserve their heat the longest, their +parts heating one another, and may not great dense and fix'd Bodies, +when heated beyond a certain degree, emit Light so copiously, as by the +Emission and Re-action of its Light, and the Reflexions and Refractions +of its Rays within its Pores to grow still hotter, till it comes to a +certain period of heat, such as is that of the Sun? And are not the Sun +and fix'd Stars great Earths vehemently hot, whose heat is conserved by +the greatness of the Bodies, and the mutual Action and Reaction between +them, and the Light which they emit, and whose parts are kept from +fuming away, not only by their fixity, but also by the vast weight and +density of the Atmospheres incumbent upon them; and very strongly +compressing them, and condensing the Vapours and Exhalations which arise +from them? For if Water be made warm in any pellucid Vessel emptied of +Air, that Water in the _Vacuum_ will bubble and boil as vehemently as it +would in the open Air in a Vessel set upon the Fire till it conceives a +much greater heat. For the weight of the incumbent Atmosphere keeps down +the Vapours, and hinders the Water from boiling, until it grow much +hotter than is requisite to make it boil _in vacuo_. Also a mixture of +Tin and Lead being put upon a red hot Iron _in vacuo_ emits a Fume and +Flame, but the same Mixture in the open Air, by reason of the incumbent +Atmosphere, does not so much as emit any Fume which can be perceived by +Sight. In like manner the great weight of the Atmosphere which lies upon +the Globe of the Sun may hinder Bodies there from rising up and going +away from the Sun in the form of Vapours and Fumes, unless by means of a +far greater heat than that which on the Surface of our Earth would very +easily turn them into Vapours and Fumes. And the same great weight may +condense those Vapours and Exhalations as soon as they shall at any time +begin to ascend from the Sun, and make them presently fall back again +into him, and by that action increase his Heat much after the manner +that in our Earth the Air increases the Heat of a culinary Fire. And the +same weight may hinder the Globe of the Sun from being diminish'd, +unless by the Emission of Light, and a very small quantity of Vapours +and Exhalations. + +_Qu._ 12. Do not the Rays of Light in falling upon the bottom of the Eye +excite Vibrations in the _Tunica Retina_? Which Vibrations, being +propagated along the solid Fibres of the optick Nerves into the Brain, +cause the Sense of seeing. For because dense Bodies conserve their Heat +a long time, and the densest Bodies conserve their Heat the longest, the +Vibrations of their parts are of a lasting nature, and therefore may be +propagated along solid Fibres of uniform dense Matter to a great +distance, for conveying into the Brain the impressions made upon all the +Organs of Sense. For that Motion which can continue long in one and the +same part of a Body, can be propagated a long way from one part to +another, supposing the Body homogeneal, so that the Motion may not be +reflected, refracted, interrupted or disorder'd by any unevenness of the +Body. + +_Qu._ 13. Do not several sorts of Rays make Vibrations of several +bignesses, which according to their bignesses excite Sensations of +several Colours, much after the manner that the Vibrations of the Air, +according to their several bignesses excite Sensations of several +Sounds? And particularly do not the most refrangible Rays excite the +shortest Vibrations for making a Sensation of deep violet, the least +refrangible the largest for making a Sensation of deep red, and the +several intermediate sorts of Rays, Vibrations of several intermediate +bignesses to make Sensations of the several intermediate Colours? + +_Qu._ 14. May not the harmony and discord of Colours arise from the +proportions of the Vibrations propagated through the Fibres of the +optick Nerves into the Brain, as the harmony and discord of Sounds arise +from the proportions of the Vibrations of the Air? For some Colours, if +they be view'd together, are agreeable to one another, as those of Gold +and Indigo, and others disagree. + +_Qu._ 15. Are not the Species of Objects seen with both Eyes united +where the optick Nerves meet before they come into the Brain, the Fibres +on the right side of both Nerves uniting there, and after union going +thence into the Brain in the Nerve which is on the right side of the +Head, and the Fibres on the left side of both Nerves uniting in the same +place, and after union going into the Brain in the Nerve which is on the +left side of the Head, and these two Nerves meeting in the Brain in such +a manner that their Fibres make but one entire Species or Picture, half +of which on the right side of the Sensorium comes from the right side of +both Eyes through the right side of both optick Nerves to the place +where the Nerves meet, and from thence on the right side of the Head +into the Brain, and the other half on the left side of the Sensorium +comes in like manner from the left side of both Eyes. For the optick +Nerves of such Animals as look the same way with both Eyes (as of Men, +Dogs, Sheep, Oxen, &c.) meet before they come into the Brain, but the +optick Nerves of such Animals as do not look the same way with both Eyes +(as of Fishes, and of the Chameleon,) do not meet, if I am rightly +inform'd. + +_Qu._ 16. When a Man in the dark presses either corner of his Eye with +his Finger, and turns his Eye away from his Finger, he will see a Circle +of Colours like those in the Feather of a Peacock's Tail. If the Eye and +the Finger remain quiet these Colours vanish in a second Minute of Time, +but if the Finger be moved with a quavering Motion they appear again. Do +not these Colours arise from such Motions excited in the bottom of the +Eye by the Pressure and Motion of the Finger, as, at other times are +excited there by Light for causing Vision? And do not the Motions once +excited continue about a Second of Time before they cease? And when a +Man by a stroke upon his Eye sees a flash of Light, are not the like +Motions excited in the _Retina_ by the stroke? And when a Coal of Fire +moved nimbly in the circumference of a Circle, makes the whole +circumference appear like a Circle of Fire; is it not because the +Motions excited in the bottom of the Eye by the Rays of Light are of a +lasting nature, and continue till the Coal of Fire in going round +returns to its former place? And considering the lastingness of the +Motions excited in the bottom of the Eye by Light, are they not of a +vibrating nature? + +_Qu._ 17. If a stone be thrown into stagnating Water, the Waves excited +thereby continue some time to arise in the place where the Stone fell +into the Water, and are propagated from thence in concentrick Circles +upon the Surface of the Water to great distances. And the Vibrations or +Tremors excited in the Air by percussion, continue a little time to move +from the place of percussion in concentrick Spheres to great distances. +And in like manner, when a Ray of Light falls upon the Surface of any +pellucid Body, and is there refracted or reflected, may not Waves of +Vibrations, or Tremors, be thereby excited in the refracting or +reflecting Medium at the point of Incidence, and continue to arise +there, and to be propagated from thence as long as they continue to +arise and be propagated, when they are excited in the bottom of the Eye +by the Pressure or Motion of the Finger, or by the Light which comes +from the Coal of Fire in the Experiments above-mention'd? and are not +these Vibrations propagated from the point of Incidence to great +distances? And do they not overtake the Rays of Light, and by overtaking +them successively, do they not put them into the Fits of easy Reflexion +and easy Transmission described above? For if the Rays endeavour to +recede from the densest part of the Vibration, they may be alternately +accelerated and retarded by the Vibrations overtaking them. + +_Qu._ 18. If in two large tall cylindrical Vessels of Glass inverted, +two little Thermometers be suspended so as not to touch the Vessels, and +the Air be drawn out of one of these Vessels, and these Vessels thus +prepared be carried out of a cold place into a warm one; the Thermometer +_in vacuo_ will grow warm as much, and almost as soon as the Thermometer +which is not _in vacuo_. And when the Vessels are carried back into the +cold place, the Thermometer _in vacuo_ will grow cold almost as soon as +the other Thermometer. Is not the Heat of the warm Room convey'd through +the _Vacuum_ by the Vibrations of a much subtiler Medium than Air, which +after the Air was drawn out remained in the _Vacuum_? And is not this +Medium the same with that Medium by which Light is refracted and +reflected, and by whose Vibrations Light communicates Heat to Bodies, +and is put into Fits of easy Reflexion and easy Transmission? And do not +the Vibrations of this Medium in hot Bodies contribute to the +intenseness and duration of their Heat? And do not hot Bodies +communicate their Heat to contiguous cold ones, by the Vibrations of +this Medium propagated from them into the cold ones? And is not this +Medium exceedingly more rare and subtile than the Air, and exceedingly +more elastick and active? And doth it not readily pervade all Bodies? +And is it not (by its elastick force) expanded through all the Heavens? + +_Qu._ 19. Doth not the Refraction of Light proceed from the different +density of this Æthereal Medium in different places, the Light receding +always from the denser parts of the Medium? And is not the density +thereof greater in free and open Spaces void of Air and other grosser +Bodies, than within the Pores of Water, Glass, Crystal, Gems, and other +compact Bodies? For when Light passes through Glass or Crystal, and +falling very obliquely upon the farther Surface thereof is totally +reflected, the total Reflexion ought to proceed rather from the density +and vigour of the Medium without and beyond the Glass, than from the +rarity and weakness thereof. + +_Qu._ 20. Doth not this Æthereal Medium in passing out of Water, Glass, +Crystal, and other compact and dense Bodies into empty Spaces, grow +denser and denser by degrees, and by that means refract the Rays of +Light not in a point, but by bending them gradually in curve Lines? And +doth not the gradual condensation of this Medium extend to some distance +from the Bodies, and thereby cause the Inflexions of the Rays of Light, +which pass by the edges of dense Bodies, at some distance from the +Bodies? + +_Qu._ 21. Is not this Medium much rarer within the dense Bodies of the +Sun, Stars, Planets and Comets, than in the empty celestial Spaces +between them? And in passing from them to great distances, doth it not +grow denser and denser perpetually, and thereby cause the gravity of +those great Bodies towards one another, and of their parts towards the +Bodies; every Body endeavouring to go from the denser parts of the +Medium towards the rarer? For if this Medium be rarer within the Sun's +Body than at its Surface, and rarer there than at the hundredth part of +an Inch from its Body, and rarer there than at the fiftieth part of an +Inch from its Body, and rarer there than at the Orb of _Saturn_; I see +no reason why the Increase of density should stop any where, and not +rather be continued through all distances from the Sun to _Saturn_, and +beyond. And though this Increase of density may at great distances be +exceeding slow, yet if the elastick force of this Medium be exceeding +great, it may suffice to impel Bodies from the denser parts of the +Medium towards the rarer, with all that power which we call Gravity. And +that the elastick force of this Medium is exceeding great, may be +gather'd from the swiftness of its Vibrations. Sounds move about 1140 +_English_ Feet in a second Minute of Time, and in seven or eight Minutes +of Time they move about one hundred _English_ Miles. Light moves from +the Sun to us in about seven or eight Minutes of Time, which distance is +about 70,000,000 _English_ Miles, supposing the horizontal Parallax of +the Sun to be about 12´´. And the Vibrations or Pulses of this Medium, +that they may cause the alternate Fits of easy Transmission and easy +Reflexion, must be swifter than Light, and by consequence above 700,000 +times swifter than Sounds. And therefore the elastick force of this +Medium, in proportion to its density, must be above 700000 x 700000 +(that is, above 490,000,000,000) times greater than the elastick force +of the Air is in proportion to its density. For the Velocities of the +Pulses of elastick Mediums are in a subduplicate _Ratio_ of the +Elasticities and the Rarities of the Mediums taken together. + +As Attraction is stronger in small Magnets than in great ones in +proportion to their Bulk, and Gravity is greater in the Surfaces of +small Planets than in those of great ones in proportion to their bulk, +and small Bodies are agitated much more by electric attraction than +great ones; so the smallness of the Rays of Light may contribute very +much to the power of the Agent by which they are refracted. And so if +any one should suppose that _Æther_ (like our Air) may contain Particles +which endeavour to recede from one another (for I do not know what this +_Æther_ is) and that its Particles are exceedingly smaller than those of +Air, or even than those of Light: The exceeding smallness of its +Particles may contribute to the greatness of the force by which those +Particles may recede from one another, and thereby make that Medium +exceedingly more rare and elastick than Air, and by consequence +exceedingly less able to resist the motions of Projectiles, and +exceedingly more able to press upon gross Bodies, by endeavouring to +expand it self. + +_Qu._ 22. May not Planets and Comets, and all gross Bodies, perform +their Motions more freely, and with less resistance in this Æthereal +Medium than in any Fluid, which fills all Space adequately without +leaving any Pores, and by consequence is much denser than Quick-silver +or Gold? And may not its resistance be so small, as to be +inconsiderable? For instance; If this _Æther_ (for so I will call it) +should be supposed 700000 times more elastick than our Air, and above +700000 times more rare; its resistance would be above 600,000,000 times +less than that of Water. And so small a resistance would scarce make any +sensible alteration in the Motions of the Planets in ten thousand +Years. If any one would ask how a Medium can be so rare, let him tell me +how the Air, in the upper parts of the Atmosphere, can be above an +hundred thousand thousand times rarer than Gold. Let him also tell me, +how an electrick Body can by Friction emit an Exhalation so rare and +subtile, and yet so potent, as by its Emission to cause no sensible +Diminution of the weight of the electrick Body, and to be expanded +through a Sphere, whose Diameter is above two Feet, and yet to be able +to agitate and carry up Leaf Copper, or Leaf Gold, at the distance of +above a Foot from the electrick Body? And how the Effluvia of a Magnet +can be so rare and subtile, as to pass through a Plate of Glass without +any Resistance or Diminution of their Force, and yet so potent as to +turn a magnetick Needle beyond the Glass? + +_Qu._ 23. Is not Vision perform'd chiefly by the Vibrations of this +Medium, excited in the bottom of the Eye by the Rays of Light, and +propagated through the solid, pellucid and uniform Capillamenta of the +optick Nerves into the place of Sensation? And is not Hearing perform'd +by the Vibrations either of this or some other Medium, excited in the +auditory Nerves by the Tremors of the Air, and propagated through the +solid, pellucid and uniform Capillamenta of those Nerves into the place +of Sensation? And so of the other Senses. + +_Qu._ 24. Is not Animal Motion perform'd by the Vibrations of this +Medium, excited in the Brain by the power of the Will, and propagated +from thence through the solid, pellucid and uniform Capillamenta of the +Nerves into the Muscles, for contracting and dilating them? I suppose +that the Capillamenta of the Nerves are each of them solid and uniform, +that the vibrating Motion of the Æthereal Medium may be propagated along +them from one end to the other uniformly, and without interruption: For +Obstructions in the Nerves create Palsies. And that they may be +sufficiently uniform, I suppose them to be pellucid when view'd singly, +tho' the Reflexions in their cylindrical Surfaces may make the whole +Nerve (composed of many Capillamenta) appear opake and white. For +opacity arises from reflecting Surfaces, such as may disturb and +interrupt the Motions of this Medium. + +[Sidenote: _See the following Scheme, p. 356._] + +_Qu._ 25. Are there not other original Properties of the Rays of Light, +besides those already described? An instance of another original +Property we have in the Refraction of Island Crystal, described first by +_Erasmus Bartholine_, and afterwards more exactly by _Hugenius_, in his +Book _De la Lumiere_. This Crystal is a pellucid fissile Stone, clear as +Water or Crystal of the Rock, and without Colour; enduring a red Heat +without losing its transparency, and in a very strong Heat calcining +without Fusion. Steep'd a Day or two in Water, it loses its natural +Polish. Being rubb'd on Cloth, it attracts pieces of Straws and other +light things, like Ambar or Glass; and with _Aqua fortis_ it makes an +Ebullition. It seems to be a sort of Talk, and is found in form of an +oblique Parallelopiped, with six parallelogram Sides and eight solid +Angles. The obtuse Angles of the Parallelograms are each of them 101 +Degrees and 52 Minutes; the acute ones 78 Degrees and 8 Minutes. Two of +the solid Angles opposite to one another, as C and E, are compassed each +of them with three of these obtuse Angles, and each of the other six +with one obtuse and two acute ones. It cleaves easily in planes parallel +to any of its Sides, and not in any other Planes. It cleaves with a +glossy polite Surface not perfectly plane, but with some little +unevenness. It is easily scratch'd, and by reason of its softness it +takes a Polish very difficultly. It polishes better upon polish'd +Looking-glass than upon Metal, and perhaps better upon Pitch, Leather or +Parchment. Afterwards it must be rubb'd with a little Oil or white of an +Egg, to fill up its Scratches; whereby it will become very transparent +and polite. But for several Experiments, it is not necessary to polish +it. If a piece of this crystalline Stone be laid upon a Book, every +Letter of the Book seen through it will appear double, by means of a +double Refraction. And if any beam of Light falls either +perpendicularly, or in any oblique Angle upon any Surface of this +Crystal, it becomes divided into two beams by means of the same double +Refraction. Which beams are of the same Colour with the incident beam of +Light, and seem equal to one another in the quantity of their Light, or +very nearly equal. One of these Refractions is perform'd by the usual +Rule of Opticks, the Sine of Incidence out of Air into this Crystal +being to the Sine of Refraction, as five to three. The other +Refraction, which may be called the unusual Refraction, is perform'd by +the following Rule. + +[Illustration: FIG. 4.] + +Let ADBC represent the refracting Surface of the Crystal, C the biggest +solid Angle at that Surface, GEHF the opposite Surface, and CK a +perpendicular on that Surface. This perpendicular makes with the edge of +the Crystal CF, an Angle of 19 Degr. 3'. Join KF, and in it take KL, so +that the Angle KCL be 6 Degr. 40'. and the Angle LCF 12 Degr. 23'. And +if ST represent any beam of Light incident at T in any Angle upon the +refracting Surface ADBC, let TV be the refracted beam determin'd by the +given Portion of the Sines 5 to 3, according to the usual Rule of +Opticks. Draw VX parallel and equal to KL. Draw it the same way from V +in which L lieth from K; and joining TX, this line TX shall be the other +refracted beam carried from T to X, by the unusual Refraction. + +If therefore the incident beam ST be perpendicular to the refracting +Surface, the two beams TV and TX, into which it shall become divided, +shall be parallel to the lines CK and CL; one of those beams going +through the Crystal perpendicularly, as it ought to do by the usual Laws +of Opticks, and the other TX by an unusual Refraction diverging from the +perpendicular, and making with it an Angle VTX of about 6-2/3 Degrees, +as is found by Experience. And hence, the Plane VTX, and such like +Planes which are parallel to the Plane CFK, may be called the Planes of +perpendicular Refraction. And the Coast towards which the lines KL and +VX are drawn, may be call'd the Coast of unusual Refraction. + +In like manner Crystal of the Rock has a double Refraction: But the +difference of the two Refractions is not so great and manifest as in +Island Crystal. + +When the beam ST incident on Island Crystal is divided into two beams TV +and TX, and these two beams arrive at the farther Surface of the Glass; +the beam TV, which was refracted at the first Surface after the usual +manner, shall be again refracted entirely after the usual manner at the +second Surface; and the beam TX, which was refracted after the unusual +manner in the first Surface, shall be again refracted entirely after the +unusual manner in the second Surface; so that both these beams shall +emerge out of the second Surface in lines parallel to the first incident +beam ST. + +And if two pieces of Island Crystal be placed one after another, in such +manner that all the Surfaces of the latter be parallel to all the +corresponding Surfaces of the former: The Rays which are refracted after +the usual manner in the first Surface of the first Crystal, shall be +refracted after the usual manner in all the following Surfaces; and the +Rays which are refracted after the unusual manner in the first Surface, +shall be refracted after the unusual manner in all the following +Surfaces. And the same thing happens, though the Surfaces of the +Crystals be any ways inclined to one another, provided that their Planes +of perpendicular Refraction be parallel to one another. + +And therefore there is an original difference in the Rays of Light, by +means of which some Rays are in this Experiment constantly refracted +after the usual manner, and others constantly after the unusual manner: +For if the difference be not original, but arises from new Modifications +impress'd on the Rays at their first Refraction, it would be alter'd by +new Modifications in the three following Refractions; whereas it suffers +no alteration, but is constant, and has the same effect upon the Rays in +all the Refractions. The unusual Refraction is therefore perform'd by an +original property of the Rays. And it remains to be enquired, whether +the Rays have not more original Properties than are yet discover'd. + +_Qu._ 26. Have not the Rays of Light several sides, endued with several +original Properties? For if the Planes of perpendicular Refraction of +the second Crystal be at right Angles with the Planes of perpendicular +Refraction of the first Crystal, the Rays which are refracted after the +usual manner in passing through the first Crystal, will be all of them +refracted after the unusual manner in passing through the second +Crystal; and the Rays which are refracted after the unusual manner in +passing through the first Crystal, will be all of them refracted after +the usual manner in passing through the second Crystal. And therefore +there are not two sorts of Rays differing in their nature from one +another, one of which is constantly and in all Positions refracted after +the usual manner, and the other constantly and in all Positions after +the unusual manner. The difference between the two sorts of Rays in the +Experiment mention'd in the 25th Question, was only in the Positions of +the Sides of the Rays to the Planes of perpendicular Refraction. For one +and the same Ray is here refracted sometimes after the usual, and +sometimes after the unusual manner, according to the Position which its +Sides have to the Crystals. If the Sides of the Ray are posited the same +way to both Crystals, it is refracted after the same manner in them +both: But if that side of the Ray which looks towards the Coast of the +unusual Refraction of the first Crystal, be 90 Degrees from that side of +the same Ray which looks toward the Coast of the unusual Refraction of +the second Crystal, (which may be effected by varying the Position of +the second Crystal to the first, and by consequence to the Rays of +Light,) the Ray shall be refracted after several manners in the several +Crystals. There is nothing more required to determine whether the Rays +of Light which fall upon the second Crystal shall be refracted after +the usual or after the unusual manner, but to turn about this Crystal, +so that the Coast of this Crystal's unusual Refraction may be on this or +on that side of the Ray. And therefore every Ray may be consider'd as +having four Sides or Quarters, two of which opposite to one another +incline the Ray to be refracted after the unusual manner, as often as +either of them are turn'd towards the Coast of unusual Refraction; and +the other two, whenever either of them are turn'd towards the Coast of +unusual Refraction, do not incline it to be otherwise refracted than +after the usual manner. The two first may therefore be call'd the Sides +of unusual Refraction. And since these Dispositions were in the Rays +before their Incidence on the second, third, and fourth Surfaces of the +two Crystals, and suffered no alteration (so far as appears,) by the +Refraction of the Rays in their passage through those Surfaces, and the +Rays were refracted by the same Laws in all the four Surfaces; it +appears that those Dispositions were in the Rays originally, and +suffer'd no alteration by the first Refraction, and that by means of +those Dispositions the Rays were refracted at their Incidence on the +first Surface of the first Crystal, some of them after the usual, and +some of them after the unusual manner, accordingly as their Sides of +unusual Refraction were then turn'd towards the Coast of the unusual +Refraction of that Crystal, or sideways from it. + +Every Ray of Light has therefore two opposite Sides, originally endued +with a Property on which the unusual Refraction depends, and the other +two opposite Sides not endued with that Property. And it remains to be +enquired, whether there are not more Properties of Light by which the +Sides of the Rays differ, and are distinguished from one another. + +In explaining the difference of the Sides of the Rays above mention'd, I +have supposed that the Rays fall perpendicularly on the first Crystal. +But if they fall obliquely on it, the Success is the same. Those Rays +which are refracted after the usual manner in the first Crystal, will be +refracted after the unusual manner in the second Crystal, supposing the +Planes of perpendicular Refraction to be at right Angles with one +another, as above; and on the contrary. + +If the Planes of the perpendicular Refraction of the two Crystals be +neither parallel nor perpendicular to one another, but contain an acute +Angle: The two beams of Light which emerge out of the first Crystal, +will be each of them divided into two more at their Incidence on the +second Crystal. For in this case the Rays in each of the two beams will +some of them have their Sides of unusual Refraction, and some of them +their other Sides turn'd towards the Coast of the unusual Refraction of +the second Crystal. + +_Qu._ 27. Are not all Hypotheses erroneous which have hitherto been +invented for explaining the Phænomena of Light, by new Modifications of +the Rays? For those Phænomena depend not upon new Modifications, as has +been supposed, but upon the original and unchangeable Properties of the +Rays. + +_Qu._ 28. Are not all Hypotheses erroneous, in which Light is supposed +to consist in Pression or Motion, propagated through a fluid Medium? For +in all these Hypotheses the Phænomena of Light have been hitherto +explain'd by supposing that they arise from new Modifications of the +Rays; which is an erroneous Supposition. + +If Light consisted only in Pression propagated without actual Motion, it +would not be able to agitate and heat the Bodies which refract and +reflect it. If it consisted in Motion propagated to all distances in an +instant, it would require an infinite force every moment, in every +shining Particle, to generate that Motion. And if it consisted in +Pression or Motion, propagated either in an instant or in time, it would +bend into the Shadow. For Pression or Motion cannot be propagated in a +Fluid in right Lines, beyond an Obstacle which stops part of the Motion, +but will bend and spread every way into the quiescent Medium which lies +beyond the Obstacle. Gravity tends downwards, but the Pressure of Water +arising from Gravity tends every way with equal Force, and is propagated +as readily, and with as much force sideways as downwards, and through +crooked passages as through strait ones. The Waves on the Surface of +stagnating Water, passing by the sides of a broad Obstacle which stops +part of them, bend afterwards and dilate themselves gradually into the +quiet Water behind the Obstacle. The Waves, Pulses or Vibrations of the +Air, wherein Sounds consist, bend manifestly, though not so much as the +Waves of Water. For a Bell or a Cannon may be heard beyond a Hill which +intercepts the sight of the sounding Body, and Sounds are propagated as +readily through crooked Pipes as through streight ones. But Light is +never known to follow crooked Passages nor to bend into the Shadow. For +the fix'd Stars by the Interposition of any of the Planets cease to be +seen. And so do the Parts of the Sun by the Interposition of the Moon, +_Mercury_ or _Venus_. The Rays which pass very near to the edges of any +Body, are bent a little by the action of the Body, as we shew'd above; +but this bending is not towards but from the Shadow, and is perform'd +only in the passage of the Ray by the Body, and at a very small distance +from it. So soon as the Ray is past the Body, it goes right on. + +[Sidenote: _Mais pour dire comment cela se fait, je n'ay rien trove +jusqu' ici qui me satisfasse._ C. H. de la lumiere, c. 5, p. 91.] + +To explain the unusual Refraction of Island Crystal by Pression or +Motion propagated, has not hitherto been attempted (to my knowledge) +except by _Huygens_, who for that end supposed two several vibrating +Mediums within that Crystal. But when he tried the Refractions in two +successive pieces of that Crystal, and found them such as is mention'd +above; he confessed himself at a loss for explaining them. For Pressions +or Motions, propagated from a shining Body through an uniform Medium, +must be on all sides alike; whereas by those Experiments it appears, +that the Rays of Light have different Properties in their different +Sides. He suspected that the Pulses of _Æther_ in passing through the +first Crystal might receive certain new Modifications, which might +determine them to be propagated in this or that Medium within the +second Crystal, according to the Position of that Crystal. But what +Modifications those might be he could not say, nor think of any thing +satisfactory in that Point. And if he had known that the unusual +Refraction depends not on new Modifications, but on the original and +unchangeable Dispositions of the Rays, he would have found it as +difficult to explain how those Dispositions which he supposed to be +impress'd on the Rays by the first Crystal, could be in them before +their Incidence on that Crystal, and in general, how all Rays emitted by +shining Bodies, can have those Dispositions in them from the beginning. +To me, at least, this seems inexplicable, if Light be nothing else than +Pression or Motion propagated through _Æther_. + +And it is as difficult to explain by these Hypotheses, how Rays can be +alternately in Fits of easy Reflexion and easy Transmission; unless +perhaps one might suppose that there are in all Space two Æthereal +vibrating Mediums, and that the Vibrations of one of them constitute +Light, and the Vibrations of the other are swifter, and as often as they +overtake the Vibrations of the first, put them into those Fits. But how +two _Æthers_ can be diffused through all Space, one of which acts upon +the other, and by consequence is re-acted upon, without retarding, +shattering, dispersing and confounding one anothers Motions, is +inconceivable. And against filling the Heavens with fluid Mediums, +unless they be exceeding rare, a great Objection arises from the regular +and very lasting Motions of the Planets and Comets in all manner of +Courses through the Heavens. For thence it is manifest, that the Heavens +are void of all sensible Resistance, and by consequence of all sensible +Matter. + +For the resisting Power of fluid Mediums arises partly from the +Attrition of the Parts of the Medium, and partly from the _Vis inertiæ_ +of the Matter. That part of the Resistance of a spherical Body which +arises from the Attrition of the Parts of the Medium is very nearly as +the Diameter, or, at the most, as the _Factum_ of the Diameter, and the +Velocity of the spherical Body together. And that part of the Resistance +which arises from the _Vis inertiæ_ of the Matter, is as the Square of +that _Factum_. And by this difference the two sorts of Resistance may be +distinguish'd from one another in any Medium; and these being +distinguish'd, it will be found that almost all the Resistance of Bodies +of a competent Magnitude moving in Air, Water, Quick-silver, and such +like Fluids with a competent Velocity, arises from the _Vis inertiæ_ of +the Parts of the Fluid. + +Now that part of the resisting Power of any Medium which arises from the +Tenacity, Friction or Attrition of the Parts of the Medium, may be +diminish'd by dividing the Matter into smaller Parts, and making the +Parts more smooth and slippery: But that part of the Resistance which +arises from the _Vis inertiæ_, is proportional to the Density of the +Matter, and cannot be diminish'd by dividing the Matter into smaller +Parts, nor by any other means than by decreasing the Density of the +Medium. And for these Reasons the Density of fluid Mediums is very +nearly proportional to their Resistance. Liquors which differ not much +in Density, as Water, Spirit of Wine, Spirit of Turpentine, hot Oil, +differ not much in Resistance. Water is thirteen or fourteen times +lighter than Quick-silver and by consequence thirteen or fourteen times +rarer, and its Resistance is less than that of Quick-silver in the same +Proportion, or thereabouts, as I have found by Experiments made with +Pendulums. The open Air in which we breathe is eight or nine hundred +times lighter than Water, and by consequence eight or nine hundred times +rarer, and accordingly its Resistance is less than that of Water in the +same Proportion, or thereabouts; as I have also found by Experiments +made with Pendulums. And in thinner Air the Resistance is still less, +and at length, by ratifying the Air, becomes insensible. For small +Feathers falling in the open Air meet with great Resistance, but in a +tall Glass well emptied of Air, they fall as fast as Lead or Gold, as I +have seen tried several times. Whence the Resistance seems still to +decrease in proportion to the Density of the Fluid. For I do not find by +any Experiments, that Bodies moving in Quick-silver, Water or Air, meet +with any other sensible Resistance than what arises from the Density and +Tenacity of those sensible Fluids, as they would do if the Pores of +those Fluids, and all other Spaces, were filled with a dense and +subtile Fluid. Now if the Resistance in a Vessel well emptied of Air, +was but an hundred times less than in the open Air, it would be about a +million of times less than in Quick-silver. But it seems to be much less +in such a Vessel, and still much less in the Heavens, at the height of +three or four hundred Miles from the Earth, or above. For Mr. _Boyle_ +has shew'd that Air may be rarified above ten thousand times in Vessels +of Glass; and the Heavens are much emptier of Air than any _Vacuum_ we +can make below. For since the Air is compress'd by the Weight of the +incumbent Atmosphere, and the Density of Air is proportional to the +Force compressing it, it follows by Computation, that at the height of +about seven and a half _English_ Miles from the Earth, the Air is four +times rarer than at the Surface of the Earth; and at the height of 15 +Miles it is sixteen times rarer than that at the Surface of the Earth; +and at the height of 22-1/2, 30, or 38 Miles, it is respectively 64, +256, or 1024 times rarer, or thereabouts; and at the height of 76, 152, +228 Miles, it is about 1000000, 1000000000000, or 1000000000000000000 +times rarer; and so on. + +Heat promotes Fluidity very much by diminishing the Tenacity of Bodies. +It makes many Bodies fluid which are not fluid in cold, and increases +the Fluidity of tenacious Liquids, as of Oil, Balsam, and Honey, and +thereby decreases their Resistance. But it decreases not the Resistance +of Water considerably, as it would do if any considerable part of the +Resistance of Water arose from the Attrition or Tenacity of its Parts. +And therefore the Resistance of Water arises principally and almost +entirely from the _Vis inertiæ_ of its Matter; and by consequence, if +the Heavens were as dense as Water, they would not have much less +Resistance than Water; if as dense as Quick-silver, they would not have +much less Resistance than Quick-silver; if absolutely dense, or full of +Matter without any _Vacuum_, let the Matter be never so subtil and +fluid, they would have a greater Resistance than Quick-silver. A solid +Globe in such a Medium would lose above half its Motion in moving three +times the length of its Diameter, and a Globe not solid (such as are the +Planets,) would be retarded sooner. And therefore to make way for the +regular and lasting Motions of the Planets and Comets, it's necessary to +empty the Heavens of all Matter, except perhaps some very thin Vapours, +Steams, or Effluvia, arising from the Atmospheres of the Earth, Planets, +and Comets, and from such an exceedingly rare Æthereal Medium as we +described above. A dense Fluid can be of no use for explaining the +Phænomena of Nature, the Motions of the Planets and Comets being better +explain'd without it. It serves only to disturb and retard the Motions +of those great Bodies, and make the Frame of Nature languish: And in the +Pores of Bodies, it serves only to stop the vibrating Motions of their +Parts, wherein their Heat and Activity consists. And as it is of no use, +and hinders the Operations of Nature, and makes her languish, so there +is no evidence for its Existence, and therefore it ought to be rejected. +And if it be rejected, the Hypotheses that Light consists in Pression +or Motion, propagated through such a Medium, are rejected with it. + +And for rejecting such a Medium, we have the Authority of those the +oldest and most celebrated Philosophers of _Greece_ and _Phoenicia_, +who made a _Vacuum_, and Atoms, and the Gravity of Atoms, the first +Principles of their Philosophy; tacitly attributing Gravity to some +other Cause than dense Matter. Later Philosophers banish the +Consideration of such a Cause out of natural Philosophy, feigning +Hypotheses for explaining all things mechanically, and referring other +Causes to Metaphysicks: Whereas the main Business of natural Philosophy +is to argue from Phænomena without feigning Hypotheses, and to deduce +Causes from Effects, till we come to the very first Cause, which +certainly is not mechanical; and not only to unfold the Mechanism of the +World, but chiefly to resolve these and such like Questions. What is +there in places almost empty of Matter, and whence is it that the Sun +and Planets gravitate towards one another, without dense Matter between +them? Whence is it that Nature doth nothing in vain; and whence arises +all that Order and Beauty which we see in the World? To what end are +Comets, and whence is it that Planets move all one and the same way in +Orbs concentrick, while Comets move all manner of ways in Orbs very +excentrick; and what hinders the fix'd Stars from falling upon one +another? How came the Bodies of Animals to be contrived with so much +Art, and for what ends were their several Parts? Was the Eye contrived +without Skill in Opticks, and the Ear without Knowledge of Sounds? How +do the Motions of the Body follow from the Will, and whence is the +Instinct in Animals? Is not the Sensory of Animals that place to which +the sensitive Substance is present, and into which the sensible Species +of Things are carried through the Nerves and Brain, that there they may +be perceived by their immediate presence to that Substance? And these +things being rightly dispatch'd, does it not appear from Phænomena that +there is a Being incorporeal, living, intelligent, omnipresent, who in +infinite Space, as it were in his Sensory, sees the things themselves +intimately, and throughly perceives them, and comprehends them wholly by +their immediate presence to himself: Of which things the Images only +carried through the Organs of Sense into our little Sensoriums, are +there seen and beheld by that which in us perceives and thinks. And +though every true Step made in this Philosophy brings us not immediately +to the Knowledge of the first Cause, yet it brings us nearer to it, and +on that account is to be highly valued. + +_Qu._ 29. Are not the Rays of Light very small Bodies emitted from +shining Substances? For such Bodies will pass through uniform Mediums in +right Lines without bending into the Shadow, which is the Nature of the +Rays of Light. They will also be capable of several Properties, and be +able to conserve their Properties unchanged in passing through several +Mediums, which is another Condition of the Rays of Light. Pellucid +Substances act upon the Rays of Light at a distance in refracting, +reflecting, and inflecting them, and the Rays mutually agitate the Parts +of those Substances at a distance for heating them; and this Action and +Re-action at a distance very much resembles an attractive Force between +Bodies. If Refraction be perform'd by Attraction of the Rays, the Sines +of Incidence must be to the Sines of Refraction in a given Proportion, +as we shew'd in our Principles of Philosophy: And this Rule is true by +Experience. The Rays of Light in going out of Glass into a _Vacuum_, are +bent towards the Glass; and if they fall too obliquely on the _Vacuum_, +they are bent backwards into the Glass, and totally reflected; and this +Reflexion cannot be ascribed to the Resistance of an absolute _Vacuum_, +but must be caused by the Power of the Glass attracting the Rays at +their going out of it into the _Vacuum_, and bringing them back. For if +the farther Surface of the Glass be moisten'd with Water or clear Oil, +or liquid and clear Honey, the Rays which would otherwise be reflected +will go into the Water, Oil, or Honey; and therefore are not reflected +before they arrive at the farther Surface of the Glass, and begin to go +out of it. If they go out of it into the Water, Oil, or Honey, they go +on, because the Attraction of the Glass is almost balanced and rendered +ineffectual by the contrary Attraction of the Liquor. But if they go out +of it into a _Vacuum_ which has no Attraction to balance that of the +Glass, the Attraction of the Glass either bends and refracts them, or +brings them back and reflects them. And this is still more evident by +laying together two Prisms of Glass, or two Object-glasses of very long +Telescopes, the one plane, the other a little convex, and so compressing +them that they do not fully touch, nor are too far asunder. For the +Light which falls upon the farther Surface of the first Glass where the +Interval between the Glasses is not above the ten hundred thousandth +Part of an Inch, will go through that Surface, and through the Air or +_Vacuum_ between the Glasses, and enter into the second Glass, as was +explain'd in the first, fourth, and eighth Observations of the first +Part of the second Book. But, if the second Glass be taken away, the +Light which goes out of the second Surface of the first Glass into the +Air or _Vacuum_, will not go on forwards, but turns back into the first +Glass, and is reflected; and therefore it is drawn back by the Power of +the first Glass, there being nothing else to turn it back. Nothing more +is requisite for producing all the variety of Colours, and degrees of +Refrangibility, than that the Rays of Light be Bodies of different +Sizes, the least of which may take violet the weakest and darkest of the +Colours, and be more easily diverted by refracting Surfaces from the +right Course; and the rest as they are bigger and bigger, may make the +stronger and more lucid Colours, blue, green, yellow, and red, and be +more and more difficultly diverted. Nothing more is requisite for +putting the Rays of Light into Fits of easy Reflexion and easy +Transmission, than that they be small Bodies which by their attractive +Powers, or some other Force, stir up Vibrations in what they act upon, +which Vibrations being swifter than the Rays, overtake them +successively, and agitate them so as by turns to increase and decrease +their Velocities, and thereby put them into those Fits. And lastly, the +unusual Refraction of Island-Crystal looks very much as if it were +perform'd by some kind of attractive virtue lodged in certain Sides both +of the Rays, and of the Particles of the Crystal. For were it not for +some kind of Disposition or Virtue lodged in some Sides of the Particles +of the Crystal, and not in their other Sides, and which inclines and +bends the Rays towards the Coast of unusual Refraction, the Rays which +fall perpendicularly on the Crystal, would not be refracted towards that +Coast rather than towards any other Coast, both at their Incidence and +at their Emergence, so as to emerge perpendicularly by a contrary +Situation of the Coast of unusual Refraction at the second Surface; the +Crystal acting upon the Rays after they have pass'd through it, and are +emerging into the Air; or, if you please, into a _Vacuum_. And since the +Crystal by this Disposition or Virtue does not act upon the Rays, unless +when one of their Sides of unusual Refraction looks towards that Coast, +this argues a Virtue or Disposition in those Sides of the Rays, which +answers to, and sympathizes with that Virtue or Disposition of the +Crystal, as the Poles of two Magnets answer to one another. And as +Magnetism may be intended and remitted, and is found only in the Magnet +and in Iron: So this Virtue of refracting the perpendicular Rays is +greater in Island-Crystal, less in Crystal of the Rock, and is not yet +found in other Bodies. I do not say that this Virtue is magnetical: It +seems to be of another kind. I only say, that whatever it be, it's +difficult to conceive how the Rays of Light, unless they be Bodies, can +have a permanent Virtue in two of their Sides which is not in their +other Sides, and this without any regard to their Position to the Space +or Medium through which they pass. + +What I mean in this Question by a _Vacuum_, and by the Attractions of +the Rays of Light towards Glass or Crystal, may be understood by what +was said in the 18th, 19th, and 20th Questions. + +_Quest._ 30. Are not gross Bodies and Light convertible into one +another, and may not Bodies receive much of their Activity from the +Particles of Light which enter their Composition? For all fix'd Bodies +being heated emit Light so long as they continue sufficiently hot, and +Light mutually stops in Bodies as often as its Rays strike upon their +Parts, as we shew'd above. I know no Body less apt to shine than Water; +and yet Water by frequent Distillations changes into fix'd Earth, as Mr. +_Boyle_ has try'd; and then this Earth being enabled to endure a +sufficient Heat, shines by Heat like other Bodies. + +The changing of Bodies into Light, and Light into Bodies, is very +conformable to the Course of Nature, which seems delighted with +Transmutations. Water, which is a very fluid tasteless Salt, she changes +by Heat into Vapour, which is a sort of Air, and by Cold into Ice, which +is a hard, pellucid, brittle, fusible Stone; and this Stone returns into +Water by Heat, and Vapour returns into Water by Cold. Earth by Heat +becomes Fire, and by Cold returns into Earth. Dense Bodies by +Fermentation rarify into several sorts of Air, and this Air by +Fermentation, and sometimes without it, returns into dense Bodies. +Mercury appears sometimes in the form of a fluid Metal, sometimes in the +form of a hard brittle Metal, sometimes in the form of a corrosive +pellucid Salt call'd Sublimate, sometimes in the form of a tasteless, +pellucid, volatile white Earth, call'd _Mercurius Dulcis_; or in that of +a red opake volatile Earth, call'd Cinnaber; or in that of a red or +white Precipitate, or in that of a fluid Salt; and in Distillation it +turns into Vapour, and being agitated _in Vacuo_, it shines like Fire. +And after all these Changes it returns again into its first form of +Mercury. Eggs grow from insensible Magnitudes, and change into Animals; +Tadpoles into Frogs; and Worms into Flies. All Birds, Beasts and Fishes, +Insects, Trees, and other Vegetables, with their several Parts, grow out +of Water and watry Tinctures and Salts, and by Putrefaction return again +into watry Substances. And Water standing a few Days in the open Air, +yields a Tincture, which (like that of Malt) by standing longer yields a +Sediment and a Spirit, but before Putrefaction is fit Nourishment for +Animals and Vegetables. And among such various and strange +Transmutations, why may not Nature change Bodies into Light, and Light +into Bodies? + +_Quest._ 31. Have not the small Particles of Bodies certain Powers, +Virtues, or Forces, by which they act at a distance, not only upon the +Rays of Light for reflecting, refracting, and inflecting them, but also +upon one another for producing a great Part of the Phænomena of Nature? +For it's well known, that Bodies act one upon another by the Attractions +of Gravity, Magnetism, and Electricity; and these Instances shew the +Tenor and Course of Nature, and make it not improbable but that there +may be more attractive Powers than these. For Nature is very consonant +and conformable to her self. How these Attractions may be perform'd, I +do not here consider. What I call Attraction may be perform'd by +impulse, or by some other means unknown to me. I use that Word here to +signify only in general any Force by which Bodies tend towards one +another, whatsoever be the Cause. For we must learn from the Phænomena +of Nature what Bodies attract one another, and what are the Laws and +Properties of the Attraction, before we enquire the Cause by which the +Attraction is perform'd. The Attractions of Gravity, Magnetism, and +Electricity, reach to very sensible distances, and so have been observed +by vulgar Eyes, and there may be others which reach to so small +distances as hitherto escape Observation; and perhaps electrical +Attraction may reach to such small distances, even without being excited +by Friction. + +For when Salt of Tartar runs _per Deliquium_, is not this done by an +Attraction between the Particles of the Salt of Tartar, and the +Particles of the Water which float in the Air in the form of Vapours? +And why does not common Salt, or Salt-petre, or Vitriol, run _per +Deliquium_, but for want of such an Attraction? Or why does not Salt of +Tartar draw more Water out of the Air than in a certain Proportion to +its quantity, but for want of an attractive Force after it is satiated +with Water? And whence is it but from this attractive Power that Water +which alone distils with a gentle luke-warm Heat, will not distil from +Salt of Tartar without a great Heat? And is it not from the like +attractive Power between the Particles of Oil of Vitriol and the +Particles of Water, that Oil of Vitriol draws to it a good quantity of +Water out of the Air, and after it is satiated draws no more, and in +Distillation lets go the Water very difficultly? And when Water and Oil +of Vitriol poured successively into the same Vessel grow very hot in the +mixing, does not this Heat argue a great Motion in the Parts of the +Liquors? And does not this Motion argue, that the Parts of the two +Liquors in mixing coalesce with Violence, and by consequence rush +towards one another with an accelerated Motion? And when _Aqua fortis_, +or Spirit of Vitriol poured upon Filings of Iron dissolves the Filings +with a great Heat and Ebullition, is not this Heat and Ebullition +effected by a violent Motion of the Parts, and does not that Motion +argue that the acid Parts of the Liquor rush towards the Parts of the +Metal with violence, and run forcibly into its Pores till they get +between its outmost Particles, and the main Mass of the Metal, and +surrounding those Particles loosen them from the main Mass, and set them +at liberty to float off into the Water? And when the acid Particles, +which alone would distil with an easy Heat, will not separate from the +Particles of the Metal without a very violent Heat, does not this +confirm the Attraction between them? + +When Spirit of Vitriol poured upon common Salt or Salt-petre makes an +Ebullition with the Salt, and unites with it, and in Distillation the +Spirit of the common Salt or Salt-petre comes over much easier than it +would do before, and the acid part of the Spirit of Vitriol stays +behind; does not this argue that the fix'd Alcaly of the Salt attracts +the acid Spirit of the Vitriol more strongly than its own Spirit, and +not being able to hold them both, lets go its own? And when Oil of +Vitriol is drawn off from its weight of Nitre, and from both the +Ingredients a compound Spirit of Nitre is distilled, and two parts of +this Spirit are poured on one part of Oil of Cloves or Carraway Seeds, +or of any ponderous Oil of vegetable or animal Substances, or Oil of +Turpentine thicken'd with a little Balsam of Sulphur, and the Liquors +grow so very hot in mixing, as presently to send up a burning Flame; +does not this very great and sudden Heat argue that the two Liquors mix +with violence, and that their Parts in mixing run towards one another +with an accelerated Motion, and clash with the greatest Force? And is it +not for the same reason that well rectified Spirit of Wine poured on the +same compound Spirit flashes; and that the _Pulvis fulminans_, composed +of Sulphur, Nitre, and Salt of Tartar, goes off with a more sudden and +violent Explosion than Gun-powder, the acid Spirits of the Sulphur and +Nitre rushing towards one another, and towards the Salt of Tartar, with +so great a violence, as by the shock to turn the whole at once into +Vapour and Flame? Where the Dissolution is slow, it makes a slow +Ebullition and a gentle Heat; and where it is quicker, it makes a +greater Ebullition with more heat; and where it is done at once, the +Ebullition is contracted into a sudden Blast or violent Explosion, with +a heat equal to that of Fire and Flame. So when a Drachm of the +above-mention'd compound Spirit of Nitre was poured upon half a Drachm +of Oil of Carraway Seeds _in vacuo_, the Mixture immediately made a +flash like Gun-powder, and burst the exhausted Receiver, which was a +Glass six Inches wide, and eight Inches deep. And even the gross Body of +Sulphur powder'd, and with an equal weight of Iron Filings and a little +Water made into Paste, acts upon the Iron, and in five or six hours +grows too hot to be touch'd, and emits a Flame. And by these Experiments +compared with the great quantity of Sulphur with which the Earth +abounds, and the warmth of the interior Parts of the Earth, and hot +Springs, and burning Mountains, and with Damps, mineral Coruscations, +Earthquakes, hot suffocating Exhalations, Hurricanes, and Spouts; we may +learn that sulphureous Steams abound in the Bowels of the Earth and +ferment with Minerals, and sometimes take fire with a sudden Coruscation +and Explosion; and if pent up in subterraneous Caverns, burst the +Caverns with a great shaking of the Earth, as in springing of a Mine. +And then the Vapour generated by the Explosion, expiring through the +Pores of the Earth, feels hot and suffocates, and makes Tempests and +Hurricanes, and sometimes causes the Land to slide, or the Sea to boil, +and carries up the Water thereof in Drops, which by their weight fall +down again in Spouts. Also some sulphureous Steams, at all times when +the Earth is dry, ascending into the Air, ferment there with nitrous +Acids, and sometimes taking fire cause Lightning and Thunder, and fiery +Meteors. For the Air abounds with acid Vapours fit to promote +Fermentations, as appears by the rusting of Iron and Copper in it, the +kindling of Fire by blowing, and the beating of the Heart by means of +Respiration. Now the above-mention'd Motions are so great and violent as +to shew that in Fermentations the Particles of Bodies which almost rest, +are put into new Motions by a very potent Principle, which acts upon +them only when they approach one another, and causes them to meet and +clash with great violence, and grow hot with the motion, and dash one +another into pieces, and vanish into Air, and Vapour, and Flame. + +When Salt of Tartar _per deliquium_, being poured into the Solution of +any Metal, precipitates the Metal and makes it fall down to the bottom +of the Liquor in the form of Mud: Does not this argue that the acid +Particles are attracted more strongly by the Salt of Tartar than by the +Metal, and by the stronger Attraction go from the Metal to the Salt of +Tartar? And so when a Solution of Iron in _Aqua fortis_ dissolves the +_Lapis Calaminaris_, and lets go the Iron, or a Solution of Copper +dissolves Iron immersed in it and lets go the Copper, or a Solution of +Silver dissolves Copper and lets go the Silver, or a Solution of Mercury +in _Aqua fortis_ being poured upon Iron, Copper, Tin, or Lead, dissolves +the Metal and lets go the Mercury; does not this argue that the acid +Particles of the _Aqua fortis_ are attracted more strongly by the _Lapis +Calaminaris_ than by Iron, and more strongly by Iron than by Copper, and +more strongly by Copper than by Silver, and more strongly by Iron, +Copper, Tin, and Lead, than by Mercury? And is it not for the same +reason that Iron requires more _Aqua fortis_ to dissolve it than Copper, +and Copper more than the other Metals; and that of all Metals, Iron is +dissolved most easily, and is most apt to rust; and next after Iron, +Copper? + +When Oil of Vitriol is mix'd with a little Water, or is run _per +deliquium_, and in Distillation the Water ascends difficultly, and +brings over with it some part of the Oil of Vitriol in the form of +Spirit of Vitriol, and this Spirit being poured upon Iron, Copper, or +Salt of Tartar, unites with the Body and lets go the Water; doth not +this shew that the acid Spirit is attracted by the Water, and more +attracted by the fix'd Body than by the Water, and therefore lets go the +Water to close with the fix'd Body? And is it not for the same reason +that the Water and acid Spirits which are mix'd together in Vinegar, +_Aqua fortis_, and Spirit of Salt, cohere and rise together in +Distillation; but if the _Menstruum_ be poured on Salt of Tartar, or on +Lead, or Iron, or any fix'd Body which it can dissolve, the Acid by a +stronger Attraction adheres to the Body, and lets go the Water? And is +it not also from a mutual Attraction that the Spirits of Soot and +Sea-Salt unite and compose the Particles of Sal-armoniac, which are less +volatile than before, because grosser and freer from Water; and that the +Particles of Sal-armoniac in Sublimation carry up the Particles of +Antimony, which will not sublime alone; and that the Particles of +Mercury uniting with the acid Particles of Spirit of Salt compose +Mercury sublimate, and with the Particles of Sulphur, compose Cinnaber; +and that the Particles of Spirit of Wine and Spirit of Urine well +rectified unite, and letting go the Water which dissolved them, compose +a consistent Body; and that in subliming Cinnaber from Salt of Tartar, +or from quick Lime, the Sulphur by a stronger Attraction of the Salt or +Lime lets go the Mercury, and stays with the fix'd Body; and that when +Mercury sublimate is sublimed from Antimony, or from Regulus of +Antimony, the Spirit of Salt lets go the Mercury, and unites with the +antimonial metal which attracts it more strongly, and stays with it till +the Heat be great enough to make them both ascend together, and then +carries up the Metal with it in the form of a very fusible Salt, called +Butter of Antimony, although the Spirit of Salt alone be almost as +volatile as Water, and the Antimony alone as fix'd as Lead? + +When _Aqua fortis_ dissolves Silver and not Gold, and _Aqua regia_ +dissolves Gold and not Silver, may it not be said that _Aqua fortis_ is +subtil enough to penetrate Gold as well as Silver, but wants the +attractive Force to give it Entrance; and that _Aqua regia_ is subtil +enough to penetrate Silver as well as Gold, but wants the attractive +Force to give it Entrance? For _Aqua regia_ is nothing else than _Aqua +fortis_ mix'd with some Spirit of Salt, or with Sal-armoniac; and even +common Salt dissolved in _Aqua fortis_, enables the _Menstruum_ to +dissolve Gold, though the Salt be a gross Body. When therefore Spirit of +Salt precipitates Silver out of _Aqua fortis_, is it not done by +attracting and mixing with the _Aqua fortis_, and not attracting, or +perhaps repelling Silver? And when Water precipitates Antimony out of +the Sublimate of Antimony and Sal-armoniac, or out of Butter of +Antimony, is it not done by its dissolving, mixing with, and weakening +the Sal-armoniac or Spirit of Salt, and its not attracting, or perhaps +repelling the Antimony? And is it not for want of an attractive virtue +between the Parts of Water and Oil, of Quick-silver and Antimony, of +Lead and Iron, that these Substances do not mix; and by a weak +Attraction, that Quick-silver and Copper mix difficultly; and from a +strong one, that Quick-silver and Tin, Antimony and Iron, Water and +Salts, mix readily? And in general, is it not from the same Principle +that Heat congregates homogeneal Bodies, and separates heterogeneal +ones? + +When Arsenick with Soap gives a Regulus, and with Mercury sublimate a +volatile fusible Salt, like Butter of Antimony, doth not this shew that +Arsenick, which is a Substance totally volatile, is compounded of fix'd +and volatile Parts, strongly cohering by a mutual Attraction, so that +the volatile will not ascend without carrying up the fixed? And so, when +an equal weight of Spirit of Wine and Oil of Vitriol are digested +together, and in Distillation yield two fragrant and volatile Spirits +which will not mix with one another, and a fix'd black Earth remains +behind; doth not this shew that Oil of Vitriol is composed of volatile +and fix'd Parts strongly united by Attraction, so as to ascend together +in form of a volatile, acid, fluid Salt, until the Spirit of Wine +attracts and separates the volatile Parts from the fixed? And therefore, +since Oil of Sulphur _per Campanam_ is of the same Nature with Oil of +Vitriol, may it not be inferred, that Sulphur is also a mixture of +volatile and fix'd Parts so strongly cohering by Attraction, as to +ascend together in Sublimation. By dissolving Flowers of Sulphur in Oil +of Turpentine, and distilling the Solution, it is found that Sulphur is +composed of an inflamable thick Oil or fat Bitumen, an acid Salt, a very +fix'd Earth, and a little Metal. The three first were found not much +unequal to one another, the fourth in so small a quantity as scarce to +be worth considering. The acid Salt dissolved in Water, is the same with +Oil of Sulphur _per Campanam_, and abounding much in the Bowels of the +Earth, and particularly in Markasites, unites it self to the other +Ingredients of the Markasite, which are, Bitumen, Iron, Copper, and +Earth, and with them compounds Allum, Vitriol, and Sulphur. With the +Earth alone it compounds Allum; with the Metal alone, or Metal and +Earth together, it compounds Vitriol; and with the Bitumen and Earth it +compounds Sulphur. Whence it comes to pass that Markasites abound with +those three Minerals. And is it not from the mutual Attraction of the +Ingredients that they stick together for compounding these Minerals, and +that the Bitumen carries up the other Ingredients of the Sulphur, which +without it would not sublime? And the same Question may be put +concerning all, or almost all the gross Bodies in Nature. For all the +Parts of Animals and Vegetables are composed of Substances volatile and +fix'd, fluid and solid, as appears by their Analysis; and so are Salts +and Minerals, so far as Chymists have been hitherto able to examine +their Composition. + +When Mercury sublimate is re-sublimed with fresh Mercury, and becomes +_Mercurius Dulcis_, which is a white tasteless Earth scarce dissolvable +in Water, and _Mercurius Dulcis_ re-sublimed with Spirit of Salt returns +into Mercury sublimate; and when Metals corroded with a little acid turn +into rust, which is an Earth tasteless and indissolvable in Water, and +this Earth imbibed with more acid becomes a metallick Salt; and when +some Stones, as Spar of Lead, dissolved in proper _Menstruums_ become +Salts; do not these things shew that Salts are dry Earth and watry Acid +united by Attraction, and that the Earth will not become a Salt without +so much acid as makes it dissolvable in Water? Do not the sharp and +pungent Tastes of Acids arise from the strong Attraction whereby the +acid Particles rush upon and agitate the Particles of the Tongue? And +when Metals are dissolved in acid _Menstruums_, and the Acids in +conjunction with the Metal act after a different manner, so that the +Compound has a different Taste much milder than before, and sometimes a +sweet one; is it not because the Acids adhere to the metallick +Particles, and thereby lose much of their Activity? And if the Acid be +in too small a Proportion to make the Compound dissolvable in Water, +will it not by adhering strongly to the Metal become unactive and lose +its Taste, and the Compound be a tasteless Earth? For such things as are +not dissolvable by the Moisture of the Tongue, act not upon the Taste. + +As Gravity makes the Sea flow round the denser and weightier Parts of +the Globe of the Earth, so the Attraction may make the watry Acid flow +round the denser and compacter Particles of Earth for composing the +Particles of Salt. For otherwise the Acid would not do the Office of a +Medium between the Earth and common Water, for making Salts dissolvable +in the Water; nor would Salt of Tartar readily draw off the Acid from +dissolved Metals, nor Metals the Acid from Mercury. Now, as in the great +Globe of the Earth and Sea, the densest Bodies by their Gravity sink +down in Water, and always endeavour to go towards the Center of the +Globe; so in Particles of Salt, the densest Matter may always endeavour +to approach the Center of the Particle: So that a Particle of Salt may +be compared to a Chaos; being dense, hard, dry, and earthy in the +Center; and rare, soft, moist, and watry in the Circumference. And +hence it seems to be that Salts are of a lasting Nature, being scarce +destroy'd, unless by drawing away their watry Parts by violence, or by +letting them soak into the Pores of the central Earth by a gentle Heat +in Putrefaction, until the Earth be dissolved by the Water, and +separated into smaller Particles, which by reason of their Smallness +make the rotten Compound appear of a black Colour. Hence also it may be, +that the Parts of Animals and Vegetables preserve their several Forms, +and assimilate their Nourishment; the soft and moist Nourishment easily +changing its Texture by a gentle Heat and Motion, till it becomes like +the dense, hard, dry, and durable Earth in the Center of each Particle. +But when the Nourishment grows unfit to be assimilated, or the central +Earth grows too feeble to assimilate it, the Motion ends in Confusion, +Putrefaction, and Death. + +If a very small quantity of any Salt or Vitriol be dissolved in a great +quantity of Water, the Particles of the Salt or Vitriol will not sink to +the bottom, though they be heavier in Specie than the Water, but will +evenly diffuse themselves into all the Water, so as to make it as saline +at the top as at the bottom. And does not this imply that the Parts of +the Salt or Vitriol recede from one another, and endeavour to expand +themselves, and get as far asunder as the quantity of Water in which +they float, will allow? And does not this Endeavour imply that they have +a repulsive Force by which they fly from one another, or at least, that +they attract the Water more strongly than they do one another? For as +all things ascend in Water which are less attracted than Water, by the +gravitating Power of the Earth; so all the Particles of Salt which float +in Water, and are less attracted than Water by any one Particle of Salt, +must recede from that Particle, and give way to the more attracted +Water. + +When any saline Liquor is evaporated to a Cuticle and let cool, the Salt +concretes in regular Figures; which argues, that the Particles of the +Salt before they concreted, floated in the Liquor at equal distances in +rank and file, and by consequence that they acted upon one another by +some Power which at equal distances is equal, at unequal distances +unequal. For by such a Power they will range themselves uniformly, and +without it they will float irregularly, and come together as +irregularly. And since the Particles of Island-Crystal act all the same +way upon the Rays of Light for causing the unusual Refraction, may it +not be supposed that in the Formation of this Crystal, the Particles not +only ranged themselves in rank and file for concreting in regular +Figures, but also by some kind of polar Virtue turned their homogeneal +Sides the same way. + +The Parts of all homogeneal hard Bodies which fully touch one another, +stick together very strongly. And for explaining how this may be, some +have invented hooked Atoms, which is begging the Question; and others +tell us that Bodies are glued together by rest, that is, by an occult +Quality, or rather by nothing; and others, that they stick together by +conspiring Motions, that is, by relative rest amongst themselves. I had +rather infer from their Cohesion, that their Particles attract one +another by some Force, which in immediate Contact is exceeding strong, +at small distances performs the chymical Operations above-mention'd, and +reaches not far from the Particles with any sensible Effect. + +All Bodies seem to be composed of hard Particles: For otherwise Fluids +would not congeal; as Water, Oils, Vinegar, and Spirit or Oil of Vitriol +do by freezing; Mercury by Fumes of Lead; Spirit of Nitre and Mercury, +by dissolving the Mercury and evaporating the Flegm; Spirit of Wine and +Spirit of Urine, by deflegming and mixing them; and Spirit of Urine and +Spirit of Salt, by subliming them together to make Sal-armoniac. Even +the Rays of Light seem to be hard Bodies; for otherwise they would not +retain different Properties in their different Sides. And therefore +Hardness may be reckon'd the Property of all uncompounded Matter. At +least, this seems to be as evident as the universal Impenetrability of +Matter. For all Bodies, so far as Experience reaches, are either hard, +or may be harden'd; and we have no other Evidence of universal +Impenetrability, besides a large Experience without an experimental +Exception. Now if compound Bodies are so very hard as we find some of +them to be, and yet are very porous, and consist of Parts which are only +laid together; the simple Particles which are void of Pores, and were +never yet divided, must be much harder. For such hard Particles being +heaped up together, can scarce touch one another in more than a few +Points, and therefore must be separable by much less Force than is +requisite to break a solid Particle, whose Parts touch in all the Space +between them, without any Pores or Interstices to weaken their Cohesion. +And how such very hard Particles which are only laid together and touch +only in a few Points, can stick together, and that so firmly as they do, +without the assistance of something which causes them to be attracted or +press'd towards one another, is very difficult to conceive. + +The same thing I infer also from the cohering of two polish'd Marbles +_in vacuo_, and from the standing of Quick-silver in the Barometer at +the height of 50, 60 or 70 Inches, or above, when ever it is well-purged +of Air and carefully poured in, so that its Parts be every where +contiguous both to one another and to the Glass. The Atmosphere by its +weight presses the Quick-silver into the Glass, to the height of 29 or +30 Inches. And some other Agent raises it higher, not by pressing it +into the Glass, but by making its Parts stick to the Glass, and to one +another. For upon any discontinuation of Parts, made either by Bubbles +or by shaking the Glass, the whole Mercury falls down to the height of +29 or 30 Inches. + +And of the same kind with these Experiments are those that follow. If +two plane polish'd Plates of Glass (suppose two pieces of a polish'd +Looking-glass) be laid together, so that their sides be parallel and at +a very small distance from one another, and then their lower edges be +dipped into Water, the Water will rise up between them. And the less +the distance of the Glasses is, the greater will be the height to which +the Water will rise. If the distance be about the hundredth part of an +Inch, the Water will rise to the height of about an Inch; and if the +distance be greater or less in any Proportion, the height will be +reciprocally proportional to the distance very nearly. For the +attractive Force of the Glasses is the same, whether the distance +between them be greater or less; and the weight of the Water drawn up is +the same, if the height of it be reciprocally proportional to the +distance of the Glasses. And in like manner, Water ascends between two +Marbles polish'd plane, when their polish'd sides are parallel, and at a +very little distance from one another, And if slender Pipes of Glass be +dipped at one end into stagnating Water, the Water will rise up within +the Pipe, and the height to which it rises will be reciprocally +proportional to the Diameter of the Cavity of the Pipe, and will equal +the height to which it rises between two Planes of Glass, if the +Semi-diameter of the Cavity of the Pipe be equal to the distance between +the Planes, or thereabouts. And these Experiments succeed after the same +manner _in vacuo_ as in the open Air, (as hath been tried before the +Royal Society,) and therefore are not influenced by the Weight or +Pressure of the Atmosphere. + +And if a large Pipe of Glass be filled with sifted Ashes well pressed +together in the Glass, and one end of the Pipe be dipped into stagnating +Water, the Water will rise up slowly in the Ashes, so as in the space +of a Week or Fortnight to reach up within the Glass, to the height of 30 +or 40 Inches above the stagnating Water. And the Water rises up to this +height by the Action only of those Particles of the Ashes which are upon +the Surface of the elevated Water; the Particles which are within the +Water, attracting or repelling it as much downwards as upwards. And +therefore the Action of the Particles is very strong. But the Particles +of the Ashes being not so dense and close together as those of Glass, +their Action is not so strong as that of Glass, which keeps Quick-silver +suspended to the height of 60 or 70 Inches, and therefore acts with a +Force which would keep Water suspended to the height of above 60 Feet. + +By the same Principle, a Sponge sucks in Water, and the Glands in the +Bodies of Animals, according to their several Natures and Dispositions, +suck in various Juices from the Blood. + +If two plane polish'd Plates of Glass three or four Inches broad, and +twenty or twenty five long, be laid one of them parallel to the Horizon, +the other upon the first, so as at one of their ends to touch one +another, and contain an Angle of about 10 or 15 Minutes, and the same be +first moisten'd on their inward sides with a clean Cloth dipp'd into Oil +of Oranges or Spirit of Turpentine, and a Drop or two of the Oil or +Spirit be let fall upon the lower Glass at the other; so soon as the +upper Glass is laid down upon the lower, so as to touch it at one end as +above, and to touch the Drop at the other end, making with the lower +Glass an Angle of about 10 or 15 Minutes; the Drop will begin to move +towards the Concourse of the Glasses, and will continue to move with an +accelerated Motion, till it arrives at that Concourse of the Glasses. +For the two Glasses attract the Drop, and make it run that way towards +which the Attractions incline. And if when the Drop is in motion you +lift up that end of the Glasses where they meet, and towards which the +Drop moves, the Drop will ascend between the Glasses, and therefore is +attracted. And as you lift up the Glasses more and more, the Drop will +ascend slower and slower, and at length rest, being then carried +downward by its Weight, as much as upwards by the Attraction. And by +this means you may know the Force by which the Drop is attracted at all +distances from the Concourse of the Glasses. + +Now by some Experiments of this kind, (made by Mr. _Hauksbee_) it has +been found that the Attraction is almost reciprocally in a duplicate +Proportion of the distance of the middle of the Drop from the Concourse +of the Glasses, _viz._ reciprocally in a simple Proportion, by reason of +the spreading of the Drop, and its touching each Glass in a larger +Surface; and again reciprocally in a simple Proportion, by reason of the +Attractions growing stronger within the same quantity of attracting +Surface. The Attraction therefore within the same quantity of attracting +Surface, is reciprocally as the distance between the Glasses. And +therefore where the distance is exceeding small, the Attraction must be +exceeding great. By the Table in the second Part of the second Book, +wherein the thicknesses of colour'd Plates of Water between two Glasses +are set down, the thickness of the Plate where it appears very black, is +three eighths of the ten hundred thousandth part of an Inch. And where +the Oil of Oranges between the Glasses is of this thickness, the +Attraction collected by the foregoing Rule, seems to be so strong, as +within a Circle of an Inch in diameter, to suffice to hold up a Weight +equal to that of a Cylinder of Water of an Inch in diameter, and two or +three Furlongs in length. And where it is of a less thickness the +Attraction may be proportionally greater, and continue to increase, +until the thickness do not exceed that of a single Particle of the Oil. +There are therefore Agents in Nature able to make the Particles of +Bodies stick together by very strong Attractions. And it is the Business +of experimental Philosophy to find them out. + +Now the smallest Particles of Matter may cohere by the strongest +Attractions, and compose bigger Particles of weaker Virtue; and many of +these may cohere and compose bigger Particles whose Virtue is still +weaker, and so on for divers Successions, until the Progression end in +the biggest Particles on which the Operations in Chymistry, and the +Colours of natural Bodies depend, and which by cohering compose Bodies +of a sensible Magnitude. If the Body is compact, and bends or yields +inward to Pression without any sliding of its Parts, it is hard and +elastick, returning to its Figure with a Force rising from the mutual +Attraction of its Parts. If the Parts slide upon one another, the Body +is malleable or soft. If they slip easily, and are of a fit Size to be +agitated by Heat, and the Heat is big enough to keep them in Agitation, +the Body is fluid; and if it be apt to stick to things, it is humid; and +the Drops of every fluid affect a round Figure by the mutual Attraction +of their Parts, as the Globe of the Earth and Sea affects a round Figure +by the mutual Attraction of its Parts by Gravity. + +Since Metals dissolved in Acids attract but a small quantity of the +Acid, their attractive Force can reach but to a small distance from +them. And as in Algebra, where affirmative Quantities vanish and cease, +there negative ones begin; so in Mechanicks, where Attraction ceases, +there a repulsive Virtue ought to succeed. And that there is such a +Virtue, seems to follow from the Reflexions and Inflexions of the Rays +of Light. For the Rays are repelled by Bodies in both these Cases, +without the immediate Contact of the reflecting or inflecting Body. It +seems also to follow from the Emission of Light; the Ray so soon as it +is shaken off from a shining Body by the vibrating Motion of the Parts +of the Body, and gets beyond the reach of Attraction, being driven away +with exceeding great Velocity. For that Force which is sufficient to +turn it back in Reflexion, may be sufficient to emit it. It seems also +to follow from the Production of Air and Vapour. The Particles when they +are shaken off from Bodies by Heat or Fermentation, so soon as they are +beyond the reach of the Attraction of the Body, receding from it, and +also from one another with great Strength, and keeping at a distance, +so as sometimes to take up above a Million of Times more space than they +did before in the form of a dense Body. Which vast Contraction and +Expansion seems unintelligible, by feigning the Particles of Air to be +springy and ramous, or rolled up like Hoops, or by any other means than +a repulsive Power. The Particles of Fluids which do not cohere too +strongly, and are of such a Smallness as renders them most susceptible +of those Agitations which keep Liquors in a Fluor, are most easily +separated and rarified into Vapour, and in the Language of the Chymists, +they are volatile, rarifying with an easy Heat, and condensing with +Cold. But those which are grosser, and so less susceptible of Agitation, +or cohere by a stronger Attraction, are not separated without a stronger +Heat, or perhaps not without Fermentation. And these last are the Bodies +which Chymists call fix'd, and being rarified by Fermentation, become +true permanent Air; those Particles receding from one another with the +greatest Force, and being most difficultly brought together, which upon +Contact cohere most strongly. And because the Particles of permanent Air +are grosser, and arise from denser Substances than those of Vapours, +thence it is that true Air is more ponderous than Vapour, and that a +moist Atmosphere is lighter than a dry one, quantity for quantity. From +the same repelling Power it seems to be that Flies walk upon the Water +without wetting their Feet; and that the Object-glasses of long +Telescopes lie upon one another without touching; and that dry Powders +are difficultly made to touch one another so as to stick together, +unless by melting them, or wetting them with Water, which by exhaling +may bring them together; and that two polish'd Marbles, which by +immediate Contact stick together, are difficultly brought so close +together as to stick. + +And thus Nature will be very conformable to her self and very simple, +performing all the great Motions of the heavenly Bodies by the +Attraction of Gravity which intercedes those Bodies, and almost all the +small ones of their Particles by some other attractive and repelling +Powers which intercede the Particles. The _Vis inertiæ_ is a passive +Principle by which Bodies persist in their Motion or Rest, receive +Motion in proportion to the Force impressing it, and resist as much as +they are resisted. By this Principle alone there never could have been +any Motion in the World. Some other Principle was necessary for putting +Bodies into Motion; and now they are in Motion, some other Principle is +necessary for conserving the Motion. For from the various Composition of +two Motions, 'tis very certain that there is not always the same +quantity of Motion in the World. For if two Globes joined by a slender +Rod, revolve about their common Center of Gravity with an uniform +Motion, while that Center moves on uniformly in a right Line drawn in +the Plane of their circular Motion; the Sum of the Motions of the two +Globes, as often as the Globes are in the right Line described by their +common Center of Gravity, will be bigger than the Sum of their Motions, +when they are in a Line perpendicular to that right Line. By this +Instance it appears that Motion may be got or lost. But by reason of the +Tenacity of Fluids, and Attrition of their Parts, and the Weakness of +Elasticity in Solids, Motion is much more apt to be lost than got, and +is always upon the Decay. For Bodies which are either absolutely hard, +or so soft as to be void of Elasticity, will not rebound from one +another. Impenetrability makes them only stop. If two equal Bodies meet +directly _in vacuo_, they will by the Laws of Motion stop where they +meet, and lose all their Motion, and remain in rest, unless they be +elastick, and receive new Motion from their Spring. If they have so much +Elasticity as suffices to make them re-bound with a quarter, or half, or +three quarters of the Force with which they come together, they will +lose three quarters, or half, or a quarter of their Motion. And this may +be try'd, by letting two equal Pendulums fall against one another from +equal heights. If the Pendulums be of Lead or soft Clay, they will lose +all or almost all their Motions: If of elastick Bodies they will lose +all but what they recover from their Elasticity. If it be said, that +they can lose no Motion but what they communicate to other Bodies, the +consequence is, that _in vacuo_ they can lose no Motion, but when they +meet they must go on and penetrate one another's Dimensions. If three +equal round Vessels be filled, the one with Water, the other with Oil, +the third with molten Pitch, and the Liquors be stirred about alike to +give them a vortical Motion; the Pitch by its Tenacity will lose its +Motion quickly, the Oil being less tenacious will keep it longer, and +the Water being less tenacious will keep it longest, but yet will lose +it in a short time. Whence it is easy to understand, that if many +contiguous Vortices of molten Pitch were each of them as large as those +which some suppose to revolve about the Sun and fix'd Stars, yet these +and all their Parts would, by their Tenacity and Stiffness, communicate +their Motion to one another till they all rested among themselves. +Vortices of Oil or Water, or some fluider Matter, might continue longer +in Motion; but unless the Matter were void of all Tenacity and Attrition +of Parts, and Communication of Motion, (which is not to be supposed,) +the Motion would constantly decay. Seeing therefore the variety of +Motion which we find in the World is always decreasing, there is a +necessity of conserving and recruiting it by active Principles, such as +are the cause of Gravity, by which Planets and Comets keep their Motions +in their Orbs, and Bodies acquire great Motion in falling; and the cause +of Fermentation, by which the Heart and Blood of Animals are kept in +perpetual Motion and Heat; the inward Parts of the Earth are constantly +warm'd, and in some places grow very hot; Bodies burn and shine, +Mountains take fire, the Caverns of the Earth are blown up, and the Sun +continues violently hot and lucid, and warms all things by his Light. +For we meet with very little Motion in the World, besides what is owing +to these active Principles. And if it were not for these Principles, the +Bodies of the Earth, Planets, Comets, Sun, and all things in them, +would grow cold and freeze, and become inactive Masses; and all +Putrefaction, Generation, Vegetation and Life would cease, and the +Planets and Comets would not remain in their Orbs. + +All these things being consider'd, it seems probable to me, that God in +the Beginning form'd Matter in solid, massy, hard, impenetrable, +moveable Particles, of such Sizes and Figures, and with such other +Properties, and in such Proportion to Space, as most conduced to the End +for which he form'd them; and that these primitive Particles being +Solids, are incomparably harder than any porous Bodies compounded of +them; even so very hard, as never to wear or break in pieces; no +ordinary Power being able to divide what God himself made one in the +first Creation. While the Particles continue entire, they may compose +Bodies of one and the same Nature and Texture in all Ages: But should +they wear away, or break in pieces, the Nature of Things depending on +them, would be changed. Water and Earth, composed of old worn Particles +and Fragments of Particles, would not be of the same Nature and Texture +now, with Water and Earth composed of entire Particles in the Beginning. +And therefore, that Nature may be lasting, the Changes of corporeal +Things are to be placed only in the various Separations and new +Associations and Motions of these permanent Particles; compound Bodies +being apt to break, not in the midst of solid Particles, but where those +Particles are laid together, and only touch in a few Points. + +It seems to me farther, that these Particles have not only a _Vis +inertiæ_, accompanied with such passive Laws of Motion as naturally +result from that Force, but also that they are moved by certain active +Principles, such as is that of Gravity, and that which causes +Fermentation, and the Cohesion of Bodies. These Principles I consider, +not as occult Qualities, supposed to result from the specifick Forms of +Things, but as general Laws of Nature, by which the Things themselves +are form'd; their Truth appearing to us by Phænomena, though their +Causes be not yet discover'd. For these are manifest Qualities, and +their Causes only are occult. And the _Aristotelians_ gave the Name of +occult Qualities, not to manifest Qualities, but to such Qualities only +as they supposed to lie hid in Bodies, and to be the unknown Causes of +manifest Effects: Such as would be the Causes of Gravity, and of +magnetick and electrick Attractions, and of Fermentations, if we should +suppose that these Forces or Actions arose from Qualities unknown to us, +and uncapable of being discovered and made manifest. Such occult +Qualities put a stop to the Improvement of natural Philosophy, and +therefore of late Years have been rejected. To tell us that every +Species of Things is endow'd with an occult specifick Quality by which +it acts and produces manifest Effects, is to tell us nothing: But to +derive two or three general Principles of Motion from Phænomena, and +afterwards to tell us how the Properties and Actions of all corporeal +Things follow from those manifest Principles, would be a very great step +in Philosophy, though the Causes of those Principles were not yet +discover'd: And therefore I scruple not to propose the Principles of +Motion above-mention'd, they being of very general Extent, and leave +their Causes to be found out. + +Now by the help of these Principles, all material Things seem to have +been composed of the hard and solid Particles above-mention'd, variously +associated in the first Creation by the Counsel of an intelligent Agent. +For it became him who created them to set them in order. And if he did +so, it's unphilosophical to seek for any other Origin of the World, or +to pretend that it might arise out of a Chaos by the mere Laws of +Nature; though being once form'd, it may continue by those Laws for many +Ages. For while Comets move in very excentrick Orbs in all manner of +Positions, blind Fate could never make all the Planets move one and the +same way in Orbs concentrick, some inconsiderable Irregularities +excepted, which may have risen from the mutual Actions of Comets and +Planets upon one another, and which will be apt to increase, till this +System wants a Reformation. Such a wonderful Uniformity in the Planetary +System must be allowed the Effect of Choice. And so must the Uniformity +in the Bodies of Animals, they having generally a right and a left side +shaped alike, and on either side of their Bodies two Legs behind, and +either two Arms, or two Legs, or two Wings before upon their Shoulders, +and between their Shoulders a Neck running down into a Back-bone, and a +Head upon it; and in the Head two Ears, two Eyes, a Nose, a Mouth, and +a Tongue, alike situated. Also the first Contrivance of those very +artificial Parts of Animals, the Eyes, Ears, Brain, Muscles, Heart, +Lungs, Midriff, Glands, Larynx, Hands, Wings, swimming Bladders, natural +Spectacles, and other Organs of Sense and Motion; and the Instinct of +Brutes and Insects, can be the effect of nothing else than the Wisdom +and Skill of a powerful ever-living Agent, who being in all Places, is +more able by his Will to move the Bodies within his boundless uniform +Sensorium, and thereby to form and reform the Parts of the Universe, +than we are by our Will to move the Parts of our own Bodies. And yet we +are not to consider the World as the Body of God, or the several Parts +thereof, as the Parts of God. He is an uniform Being, void of Organs, +Members or Parts, and they are his Creatures subordinate to him, and +subservient to his Will; and he is no more the Soul of them, than the +Soul of Man is the Soul of the Species of Things carried through the +Organs of Sense into the place of its Sensation, where it perceives them +by means of its immediate Presence, without the Intervention of any +third thing. The Organs of Sense are not for enabling the Soul to +perceive the Species of Things in its Sensorium, but only for conveying +them thither; and God has no need of such Organs, he being every where +present to the Things themselves. And since Space is divisible _in +infinitum_, and Matter is not necessarily in all places, it may be also +allow'd that God is able to create Particles of Matter of several Sizes +and Figures, and in several Proportions to Space, and perhaps of +different Densities and Forces, and thereby to vary the Laws of Nature, +and make Worlds of several sorts in several Parts of the Universe. At +least, I see nothing of Contradiction in all this. + +As in Mathematicks, so in Natural Philosophy, the Investigation of +difficult Things by the Method of Analysis, ought ever to precede the +Method of Composition. This Analysis consists in making Experiments and +Observations, and in drawing general Conclusions from them by Induction, +and admitting of no Objections against the Conclusions, but such as are +taken from Experiments, or other certain Truths. For Hypotheses are not +to be regarded in experimental Philosophy. And although the arguing from +Experiments and Observations by Induction be no Demonstration of general +Conclusions; yet it is the best way of arguing which the Nature of +Things admits of, and may be looked upon as so much the stronger, by how +much the Induction is more general. And if no Exception occur from +Phænomena, the Conclusion may be pronounced generally. But if at any +time afterwards any Exception shall occur from Experiments, it may then +begin to be pronounced with such Exceptions as occur. By this way of +Analysis we may proceed from Compounds to Ingredients, and from Motions +to the Forces producing them; and in general, from Effects to their +Causes, and from particular Causes to more general ones, till the +Argument end in the most general. This is the Method of Analysis: And +the Synthesis consists in assuming the Causes discover'd, and +establish'd as Principles, and by them explaining the Phænomena +proceeding from them, and proving the Explanations. + +In the two first Books of these Opticks, I proceeded by this Analysis to +discover and prove the original Differences of the Rays of Light in +respect of Refrangibility, Reflexibility, and Colour, and their +alternate Fits of easy Reflexion and easy Transmission, and the +Properties of Bodies, both opake and pellucid, on which their Reflexions +and Colours depend. And these Discoveries being proved, may be assumed +in the Method of Composition for explaining the Phænomena arising from +them: An Instance of which Method I gave in the End of the first Book. +In this third Book I have only begun the Analysis of what remains to be +discover'd about Light and its Effects upon the Frame of Nature, hinting +several things about it, and leaving the Hints to be examin'd and +improv'd by the farther Experiments and Observations of such as are +inquisitive. And if natural Philosophy in all its Parts, by pursuing +this Method, shall at length be perfected, the Bounds of Moral +Philosophy will be also enlarged. For so far as we can know by natural +Philosophy what is the first Cause, what Power he has over us, and what +Benefits we receive from him, so far our Duty towards him, as well as +that towards one another, will appear to us by the Light of Nature. And +no doubt, if the Worship of false Gods had not blinded the Heathen, +their moral Philosophy would have gone farther than to the four +Cardinal Virtues; and instead of teaching the Transmigration of Souls, +and to worship the Sun and Moon, and dead Heroes, they would have taught +us to worship our true Author and Benefactor, as their Ancestors did +under the Government of _Noah_ and his Sons before they corrupted +themselves. \ No newline at end of file diff --git a/libgo/go/compress/testdata/Mark.Twain-Tom.Sawyer.txt b/libgo/go/compress/testdata/Mark.Twain-Tom.Sawyer.txt deleted file mode 100644 index c9106fd522c..00000000000 --- a/libgo/go/compress/testdata/Mark.Twain-Tom.Sawyer.txt +++ /dev/null @@ -1,8465 +0,0 @@ -Produced by David Widger. The previous edition was updated by Jose -Menendez. - - - - - - THE ADVENTURES OF TOM SAWYER - BY - MARK TWAIN - (Samuel Langhorne Clemens) - - - - - P R E F A C E - -MOST of the adventures recorded in this book really occurred; one or -two were experiences of my own, the rest those of boys who were -schoolmates of mine. Huck Finn is drawn from life; Tom Sawyer also, but -not from an individual--he is a combination of the characteristics of -three boys whom I knew, and therefore belongs to the composite order of -architecture. - -The odd superstitions touched upon were all prevalent among children -and slaves in the West at the period of this story--that is to say, -thirty or forty years ago. - -Although my book is intended mainly for the entertainment of boys and -girls, I hope it will not be shunned by men and women on that account, -for part of my plan has been to try to pleasantly remind adults of what -they once were themselves, and of how they felt and thought and talked, -and what queer enterprises they sometimes engaged in. - - THE AUTHOR. - -HARTFORD, 1876. - - - - T O M S A W Y E R - - - -CHAPTER I - -"TOM!" - -No answer. - -"TOM!" - -No answer. - -"What's gone with that boy, I wonder? You TOM!" - -No answer. - -The old lady pulled her spectacles down and looked over them about the -room; then she put them up and looked out under them. She seldom or -never looked THROUGH them for so small a thing as a boy; they were her -state pair, the pride of her heart, and were built for "style," not -service--she could have seen through a pair of stove-lids just as well. -She looked perplexed for a moment, and then said, not fiercely, but -still loud enough for the furniture to hear: - -"Well, I lay if I get hold of you I'll--" - -She did not finish, for by this time she was bending down and punching -under the bed with the broom, and so she needed breath to punctuate the -punches with. She resurrected nothing but the cat. - -"I never did see the beat of that boy!" - -She went to the open door and stood in it and looked out among the -tomato vines and "jimpson" weeds that constituted the garden. No Tom. -So she lifted up her voice at an angle calculated for distance and -shouted: - -"Y-o-u-u TOM!" - -There was a slight noise behind her and she turned just in time to -seize a small boy by the slack of his roundabout and arrest his flight. - -"There! I might 'a' thought of that closet. What you been doing in -there?" - -"Nothing." - -"Nothing! Look at your hands. And look at your mouth. What IS that -truck?" - -"I don't know, aunt." - -"Well, I know. It's jam--that's what it is. Forty times I've said if -you didn't let that jam alone I'd skin you. Hand me that switch." - -The switch hovered in the air--the peril was desperate-- - -"My! Look behind you, aunt!" - -The old lady whirled round, and snatched her skirts out of danger. The -lad fled on the instant, scrambled up the high board-fence, and -disappeared over it. - -His aunt Polly stood surprised a moment, and then broke into a gentle -laugh. - -"Hang the boy, can't I never learn anything? Ain't he played me tricks -enough like that for me to be looking out for him by this time? But old -fools is the biggest fools there is. Can't learn an old dog new tricks, -as the saying is. But my goodness, he never plays them alike, two days, -and how is a body to know what's coming? He 'pears to know just how -long he can torment me before I get my dander up, and he knows if he -can make out to put me off for a minute or make me laugh, it's all down -again and I can't hit him a lick. I ain't doing my duty by that boy, -and that's the Lord's truth, goodness knows. Spare the rod and spile -the child, as the Good Book says. I'm a laying up sin and suffering for -us both, I know. He's full of the Old Scratch, but laws-a-me! he's my -own dead sister's boy, poor thing, and I ain't got the heart to lash -him, somehow. Every time I let him off, my conscience does hurt me so, -and every time I hit him my old heart most breaks. Well-a-well, man -that is born of woman is of few days and full of trouble, as the -Scripture says, and I reckon it's so. He'll play hookey this evening, * -and [* Southwestern for "afternoon"] I'll just be obleeged to make him -work, to-morrow, to punish him. It's mighty hard to make him work -Saturdays, when all the boys is having holiday, but he hates work more -than he hates anything else, and I've GOT to do some of my duty by him, -or I'll be the ruination of the child." - -Tom did play hookey, and he had a very good time. He got back home -barely in season to help Jim, the small colored boy, saw next-day's -wood and split the kindlings before supper--at least he was there in -time to tell his adventures to Jim while Jim did three-fourths of the -work. Tom's younger brother (or rather half-brother) Sid was already -through with his part of the work (picking up chips), for he was a -quiet boy, and had no adventurous, troublesome ways. - -While Tom was eating his supper, and stealing sugar as opportunity -offered, Aunt Polly asked him questions that were full of guile, and -very deep--for she wanted to trap him into damaging revealments. Like -many other simple-hearted souls, it was her pet vanity to believe she -was endowed with a talent for dark and mysterious diplomacy, and she -loved to contemplate her most transparent devices as marvels of low -cunning. Said she: - -"Tom, it was middling warm in school, warn't it?" - -"Yes'm." - -"Powerful warm, warn't it?" - -"Yes'm." - -"Didn't you want to go in a-swimming, Tom?" - -A bit of a scare shot through Tom--a touch of uncomfortable suspicion. -He searched Aunt Polly's face, but it told him nothing. So he said: - -"No'm--well, not very much." - -The old lady reached out her hand and felt Tom's shirt, and said: - -"But you ain't too warm now, though." And it flattered her to reflect -that she had discovered that the shirt was dry without anybody knowing -that that was what she had in her mind. But in spite of her, Tom knew -where the wind lay, now. So he forestalled what might be the next move: - -"Some of us pumped on our heads--mine's damp yet. See?" - -Aunt Polly was vexed to think she had overlooked that bit of -circumstantial evidence, and missed a trick. Then she had a new -inspiration: - -"Tom, you didn't have to undo your shirt collar where I sewed it, to -pump on your head, did you? Unbutton your jacket!" - -The trouble vanished out of Tom's face. He opened his jacket. His -shirt collar was securely sewed. - -"Bother! Well, go 'long with you. I'd made sure you'd played hookey -and been a-swimming. But I forgive ye, Tom. I reckon you're a kind of a -singed cat, as the saying is--better'n you look. THIS time." - -She was half sorry her sagacity had miscarried, and half glad that Tom -had stumbled into obedient conduct for once. - -But Sidney said: - -"Well, now, if I didn't think you sewed his collar with white thread, -but it's black." - -"Why, I did sew it with white! Tom!" - -But Tom did not wait for the rest. As he went out at the door he said: - -"Siddy, I'll lick you for that." - -In a safe place Tom examined two large needles which were thrust into -the lapels of his jacket, and had thread bound about them--one needle -carried white thread and the other black. He said: - -"She'd never noticed if it hadn't been for Sid. Confound it! sometimes -she sews it with white, and sometimes she sews it with black. I wish to -geeminy she'd stick to one or t'other--I can't keep the run of 'em. But -I bet you I'll lam Sid for that. I'll learn him!" - -He was not the Model Boy of the village. He knew the model boy very -well though--and loathed him. - -Within two minutes, or even less, he had forgotten all his troubles. -Not because his troubles were one whit less heavy and bitter to him -than a man's are to a man, but because a new and powerful interest bore -them down and drove them out of his mind for the time--just as men's -misfortunes are forgotten in the excitement of new enterprises. This -new interest was a valued novelty in whistling, which he had just -acquired from a negro, and he was suffering to practise it undisturbed. -It consisted in a peculiar bird-like turn, a sort of liquid warble, -produced by touching the tongue to the roof of the mouth at short -intervals in the midst of the music--the reader probably remembers how -to do it, if he has ever been a boy. Diligence and attention soon gave -him the knack of it, and he strode down the street with his mouth full -of harmony and his soul full of gratitude. He felt much as an -astronomer feels who has discovered a new planet--no doubt, as far as -strong, deep, unalloyed pleasure is concerned, the advantage was with -the boy, not the astronomer. - -The summer evenings were long. It was not dark, yet. Presently Tom -checked his whistle. A stranger was before him--a boy a shade larger -than himself. A new-comer of any age or either sex was an impressive -curiosity in the poor little shabby village of St. Petersburg. This boy -was well dressed, too--well dressed on a week-day. This was simply -astounding. His cap was a dainty thing, his close-buttoned blue cloth -roundabout was new and natty, and so were his pantaloons. He had shoes -on--and it was only Friday. He even wore a necktie, a bright bit of -ribbon. He had a citified air about him that ate into Tom's vitals. The -more Tom stared at the splendid marvel, the higher he turned up his -nose at his finery and the shabbier and shabbier his own outfit seemed -to him to grow. Neither boy spoke. If one moved, the other moved--but -only sidewise, in a circle; they kept face to face and eye to eye all -the time. Finally Tom said: - -"I can lick you!" - -"I'd like to see you try it." - -"Well, I can do it." - -"No you can't, either." - -"Yes I can." - -"No you can't." - -"I can." - -"You can't." - -"Can!" - -"Can't!" - -An uncomfortable pause. Then Tom said: - -"What's your name?" - -"'Tisn't any of your business, maybe." - -"Well I 'low I'll MAKE it my business." - -"Well why don't you?" - -"If you say much, I will." - -"Much--much--MUCH. There now." - -"Oh, you think you're mighty smart, DON'T you? I could lick you with -one hand tied behind me, if I wanted to." - -"Well why don't you DO it? You SAY you can do it." - -"Well I WILL, if you fool with me." - -"Oh yes--I've seen whole families in the same fix." - -"Smarty! You think you're SOME, now, DON'T you? Oh, what a hat!" - -"You can lump that hat if you don't like it. I dare you to knock it -off--and anybody that'll take a dare will suck eggs." - -"You're a liar!" - -"You're another." - -"You're a fighting liar and dasn't take it up." - -"Aw--take a walk!" - -"Say--if you give me much more of your sass I'll take and bounce a -rock off'n your head." - -"Oh, of COURSE you will." - -"Well I WILL." - -"Well why don't you DO it then? What do you keep SAYING you will for? -Why don't you DO it? It's because you're afraid." - -"I AIN'T afraid." - -"You are." - -"I ain't." - -"You are." - -Another pause, and more eying and sidling around each other. Presently -they were shoulder to shoulder. Tom said: - -"Get away from here!" - -"Go away yourself!" - -"I won't." - -"I won't either." - -So they stood, each with a foot placed at an angle as a brace, and -both shoving with might and main, and glowering at each other with -hate. But neither could get an advantage. After struggling till both -were hot and flushed, each relaxed his strain with watchful caution, -and Tom said: - -"You're a coward and a pup. I'll tell my big brother on you, and he -can thrash you with his little finger, and I'll make him do it, too." - -"What do I care for your big brother? I've got a brother that's bigger -than he is--and what's more, he can throw him over that fence, too." -[Both brothers were imaginary.] - -"That's a lie." - -"YOUR saying so don't make it so." - -Tom drew a line in the dust with his big toe, and said: - -"I dare you to step over that, and I'll lick you till you can't stand -up. Anybody that'll take a dare will steal sheep." - -The new boy stepped over promptly, and said: - -"Now you said you'd do it, now let's see you do it." - -"Don't you crowd me now; you better look out." - -"Well, you SAID you'd do it--why don't you do it?" - -"By jingo! for two cents I WILL do it." - -The new boy took two broad coppers out of his pocket and held them out -with derision. Tom struck them to the ground. In an instant both boys -were rolling and tumbling in the dirt, gripped together like cats; and -for the space of a minute they tugged and tore at each other's hair and -clothes, punched and scratched each other's nose, and covered -themselves with dust and glory. Presently the confusion took form, and -through the fog of battle Tom appeared, seated astride the new boy, and -pounding him with his fists. "Holler 'nuff!" said he. - -The boy only struggled to free himself. He was crying--mainly from rage. - -"Holler 'nuff!"--and the pounding went on. - -At last the stranger got out a smothered "'Nuff!" and Tom let him up -and said: - -"Now that'll learn you. Better look out who you're fooling with next -time." - -The new boy went off brushing the dust from his clothes, sobbing, -snuffling, and occasionally looking back and shaking his head and -threatening what he would do to Tom the "next time he caught him out." -To which Tom responded with jeers, and started off in high feather, and -as soon as his back was turned the new boy snatched up a stone, threw -it and hit him between the shoulders and then turned tail and ran like -an antelope. Tom chased the traitor home, and thus found out where he -lived. He then held a position at the gate for some time, daring the -enemy to come outside, but the enemy only made faces at him through the -window and declined. At last the enemy's mother appeared, and called -Tom a bad, vicious, vulgar child, and ordered him away. So he went -away; but he said he "'lowed" to "lay" for that boy. - -He got home pretty late that night, and when he climbed cautiously in -at the window, he uncovered an ambuscade, in the person of his aunt; -and when she saw the state his clothes were in her resolution to turn -his Saturday holiday into captivity at hard labor became adamantine in -its firmness. - - - -CHAPTER II - -SATURDAY morning was come, and all the summer world was bright and -fresh, and brimming with life. There was a song in every heart; and if -the heart was young the music issued at the lips. There was cheer in -every face and a spring in every step. The locust-trees were in bloom -and the fragrance of the blossoms filled the air. Cardiff Hill, beyond -the village and above it, was green with vegetation and it lay just far -enough away to seem a Delectable Land, dreamy, reposeful, and inviting. - -Tom appeared on the sidewalk with a bucket of whitewash and a -long-handled brush. He surveyed the fence, and all gladness left him and -a deep melancholy settled down upon his spirit. Thirty yards of board -fence nine feet high. Life to him seemed hollow, and existence but a -burden. Sighing, he dipped his brush and passed it along the topmost -plank; repeated the operation; did it again; compared the insignificant -whitewashed streak with the far-reaching continent of unwhitewashed -fence, and sat down on a tree-box discouraged. Jim came skipping out at -the gate with a tin pail, and singing Buffalo Gals. Bringing water from -the town pump had always been hateful work in Tom's eyes, before, but -now it did not strike him so. He remembered that there was company at -the pump. White, mulatto, and negro boys and girls were always there -waiting their turns, resting, trading playthings, quarrelling, -fighting, skylarking. And he remembered that although the pump was only -a hundred and fifty yards off, Jim never got back with a bucket of -water under an hour--and even then somebody generally had to go after -him. Tom said: - -"Say, Jim, I'll fetch the water if you'll whitewash some." - -Jim shook his head and said: - -"Can't, Mars Tom. Ole missis, she tole me I got to go an' git dis -water an' not stop foolin' roun' wid anybody. She say she spec' Mars -Tom gwine to ax me to whitewash, an' so she tole me go 'long an' 'tend -to my own business--she 'lowed SHE'D 'tend to de whitewashin'." - -"Oh, never you mind what she said, Jim. That's the way she always -talks. Gimme the bucket--I won't be gone only a a minute. SHE won't -ever know." - -"Oh, I dasn't, Mars Tom. Ole missis she'd take an' tar de head off'n -me. 'Deed she would." - -"SHE! She never licks anybody--whacks 'em over the head with her -thimble--and who cares for that, I'd like to know. She talks awful, but -talk don't hurt--anyways it don't if she don't cry. Jim, I'll give you -a marvel. I'll give you a white alley!" - -Jim began to waver. - -"White alley, Jim! And it's a bully taw." - -"My! Dat's a mighty gay marvel, I tell you! But Mars Tom I's powerful -'fraid ole missis--" - -"And besides, if you will I'll show you my sore toe." - -Jim was only human--this attraction was too much for him. He put down -his pail, took the white alley, and bent over the toe with absorbing -interest while the bandage was being unwound. In another moment he was -flying down the street with his pail and a tingling rear, Tom was -whitewashing with vigor, and Aunt Polly was retiring from the field -with a slipper in her hand and triumph in her eye. - -But Tom's energy did not last. He began to think of the fun he had -planned for this day, and his sorrows multiplied. Soon the free boys -would come tripping along on all sorts of delicious expeditions, and -they would make a world of fun of him for having to work--the very -thought of it burnt him like fire. He got out his worldly wealth and -examined it--bits of toys, marbles, and trash; enough to buy an -exchange of WORK, maybe, but not half enough to buy so much as half an -hour of pure freedom. So he returned his straitened means to his -pocket, and gave up the idea of trying to buy the boys. At this dark -and hopeless moment an inspiration burst upon him! Nothing less than a -great, magnificent inspiration. - -He took up his brush and went tranquilly to work. Ben Rogers hove in -sight presently--the very boy, of all boys, whose ridicule he had been -dreading. Ben's gait was the hop-skip-and-jump--proof enough that his -heart was light and his anticipations high. He was eating an apple, and -giving a long, melodious whoop, at intervals, followed by a deep-toned -ding-dong-dong, ding-dong-dong, for he was personating a steamboat. As -he drew near, he slackened speed, took the middle of the street, leaned -far over to starboard and rounded to ponderously and with laborious -pomp and circumstance--for he was personating the Big Missouri, and -considered himself to be drawing nine feet of water. He was boat and -captain and engine-bells combined, so he had to imagine himself -standing on his own hurricane-deck giving the orders and executing them: - -"Stop her, sir! Ting-a-ling-ling!" The headway ran almost out, and he -drew up slowly toward the sidewalk. - -"Ship up to back! Ting-a-ling-ling!" His arms straightened and -stiffened down his sides. - -"Set her back on the stabboard! Ting-a-ling-ling! Chow! ch-chow-wow! -Chow!" His right hand, meantime, describing stately circles--for it was -representing a forty-foot wheel. - -"Let her go back on the labboard! Ting-a-lingling! Chow-ch-chow-chow!" -The left hand began to describe circles. - -"Stop the stabboard! Ting-a-ling-ling! Stop the labboard! Come ahead -on the stabboard! Stop her! Let your outside turn over slow! -Ting-a-ling-ling! Chow-ow-ow! Get out that head-line! LIVELY now! -Come--out with your spring-line--what're you about there! Take a turn -round that stump with the bight of it! Stand by that stage, now--let her -go! Done with the engines, sir! Ting-a-ling-ling! SH'T! S'H'T! SH'T!" -(trying the gauge-cocks). - -Tom went on whitewashing--paid no attention to the steamboat. Ben -stared a moment and then said: "Hi-YI! YOU'RE up a stump, ain't you!" - -No answer. Tom surveyed his last touch with the eye of an artist, then -he gave his brush another gentle sweep and surveyed the result, as -before. Ben ranged up alongside of him. Tom's mouth watered for the -apple, but he stuck to his work. Ben said: - -"Hello, old chap, you got to work, hey?" - -Tom wheeled suddenly and said: - -"Why, it's you, Ben! I warn't noticing." - -"Say--I'm going in a-swimming, I am. Don't you wish you could? But of -course you'd druther WORK--wouldn't you? Course you would!" - -Tom contemplated the boy a bit, and said: - -"What do you call work?" - -"Why, ain't THAT work?" - -Tom resumed his whitewashing, and answered carelessly: - -"Well, maybe it is, and maybe it ain't. All I know, is, it suits Tom -Sawyer." - -"Oh come, now, you don't mean to let on that you LIKE it?" - -The brush continued to move. - -"Like it? Well, I don't see why I oughtn't to like it. Does a boy get -a chance to whitewash a fence every day?" - -That put the thing in a new light. Ben stopped nibbling his apple. Tom -swept his brush daintily back and forth--stepped back to note the -effect--added a touch here and there--criticised the effect again--Ben -watching every move and getting more and more interested, more and more -absorbed. Presently he said: - -"Say, Tom, let ME whitewash a little." - -Tom considered, was about to consent; but he altered his mind: - -"No--no--I reckon it wouldn't hardly do, Ben. You see, Aunt Polly's -awful particular about this fence--right here on the street, you know ---but if it was the back fence I wouldn't mind and SHE wouldn't. Yes, -she's awful particular about this fence; it's got to be done very -careful; I reckon there ain't one boy in a thousand, maybe two -thousand, that can do it the way it's got to be done." - -"No--is that so? Oh come, now--lemme just try. Only just a little--I'd -let YOU, if you was me, Tom." - -"Ben, I'd like to, honest injun; but Aunt Polly--well, Jim wanted to -do it, but she wouldn't let him; Sid wanted to do it, and she wouldn't -let Sid. Now don't you see how I'm fixed? If you was to tackle this -fence and anything was to happen to it--" - -"Oh, shucks, I'll be just as careful. Now lemme try. Say--I'll give -you the core of my apple." - -"Well, here--No, Ben, now don't. I'm afeard--" - -"I'll give you ALL of it!" - -Tom gave up the brush with reluctance in his face, but alacrity in his -heart. And while the late steamer Big Missouri worked and sweated in -the sun, the retired artist sat on a barrel in the shade close by, -dangled his legs, munched his apple, and planned the slaughter of more -innocents. There was no lack of material; boys happened along every -little while; they came to jeer, but remained to whitewash. By the time -Ben was fagged out, Tom had traded the next chance to Billy Fisher for -a kite, in good repair; and when he played out, Johnny Miller bought in -for a dead rat and a string to swing it with--and so on, and so on, -hour after hour. And when the middle of the afternoon came, from being -a poor poverty-stricken boy in the morning, Tom was literally rolling -in wealth. He had besides the things before mentioned, twelve marbles, -part of a jews-harp, a piece of blue bottle-glass to look through, a -spool cannon, a key that wouldn't unlock anything, a fragment of chalk, -a glass stopper of a decanter, a tin soldier, a couple of tadpoles, six -fire-crackers, a kitten with only one eye, a brass doorknob, a -dog-collar--but no dog--the handle of a knife, four pieces of -orange-peel, and a dilapidated old window sash. - -He had had a nice, good, idle time all the while--plenty of company ---and the fence had three coats of whitewash on it! If he hadn't run out -of whitewash he would have bankrupted every boy in the village. - -Tom said to himself that it was not such a hollow world, after all. He -had discovered a great law of human action, without knowing it--namely, -that in order to make a man or a boy covet a thing, it is only -necessary to make the thing difficult to attain. If he had been a great -and wise philosopher, like the writer of this book, he would now have -comprehended that Work consists of whatever a body is OBLIGED to do, -and that Play consists of whatever a body is not obliged to do. And -this would help him to understand why constructing artificial flowers -or performing on a tread-mill is work, while rolling ten-pins or -climbing Mont Blanc is only amusement. There are wealthy gentlemen in -England who drive four-horse passenger-coaches twenty or thirty miles -on a daily line, in the summer, because the privilege costs them -considerable money; but if they were offered wages for the service, -that would turn it into work and then they would resign. - -The boy mused awhile over the substantial change which had taken place -in his worldly circumstances, and then wended toward headquarters to -report. - - - -CHAPTER III - -TOM presented himself before Aunt Polly, who was sitting by an open -window in a pleasant rearward apartment, which was bedroom, -breakfast-room, dining-room, and library, combined. The balmy summer -air, the restful quiet, the odor of the flowers, and the drowsing murmur -of the bees had had their effect, and she was nodding over her knitting ---for she had no company but the cat, and it was asleep in her lap. Her -spectacles were propped up on her gray head for safety. She had thought -that of course Tom had deserted long ago, and she wondered at seeing him -place himself in her power again in this intrepid way. He said: "Mayn't -I go and play now, aunt?" - -"What, a'ready? How much have you done?" - -"It's all done, aunt." - -"Tom, don't lie to me--I can't bear it." - -"I ain't, aunt; it IS all done." - -Aunt Polly placed small trust in such evidence. She went out to see -for herself; and she would have been content to find twenty per cent. -of Tom's statement true. When she found the entire fence whitewashed, -and not only whitewashed but elaborately coated and recoated, and even -a streak added to the ground, her astonishment was almost unspeakable. -She said: - -"Well, I never! There's no getting round it, you can work when you're -a mind to, Tom." And then she diluted the compliment by adding, "But -it's powerful seldom you're a mind to, I'm bound to say. Well, go 'long -and play; but mind you get back some time in a week, or I'll tan you." - -She was so overcome by the splendor of his achievement that she took -him into the closet and selected a choice apple and delivered it to -him, along with an improving lecture upon the added value and flavor a -treat took to itself when it came without sin through virtuous effort. -And while she closed with a happy Scriptural flourish, he "hooked" a -doughnut. - -Then he skipped out, and saw Sid just starting up the outside stairway -that led to the back rooms on the second floor. Clods were handy and -the air was full of them in a twinkling. They raged around Sid like a -hail-storm; and before Aunt Polly could collect her surprised faculties -and sally to the rescue, six or seven clods had taken personal effect, -and Tom was over the fence and gone. There was a gate, but as a general -thing he was too crowded for time to make use of it. His soul was at -peace, now that he had settled with Sid for calling attention to his -black thread and getting him into trouble. - -Tom skirted the block, and came round into a muddy alley that led by -the back of his aunt's cow-stable. He presently got safely beyond the -reach of capture and punishment, and hastened toward the public square -of the village, where two "military" companies of boys had met for -conflict, according to previous appointment. Tom was General of one of -these armies, Joe Harper (a bosom friend) General of the other. These -two great commanders did not condescend to fight in person--that being -better suited to the still smaller fry--but sat together on an eminence -and conducted the field operations by orders delivered through -aides-de-camp. Tom's army won a great victory, after a long and -hard-fought battle. Then the dead were counted, prisoners exchanged, -the terms of the next disagreement agreed upon, and the day for the -necessary battle appointed; after which the armies fell into line and -marched away, and Tom turned homeward alone. - -As he was passing by the house where Jeff Thatcher lived, he saw a new -girl in the garden--a lovely little blue-eyed creature with yellow hair -plaited into two long-tails, white summer frock and embroidered -pantalettes. The fresh-crowned hero fell without firing a shot. A -certain Amy Lawrence vanished out of his heart and left not even a -memory of herself behind. He had thought he loved her to distraction; -he had regarded his passion as adoration; and behold it was only a poor -little evanescent partiality. He had been months winning her; she had -confessed hardly a week ago; he had been the happiest and the proudest -boy in the world only seven short days, and here in one instant of time -she had gone out of his heart like a casual stranger whose visit is -done. - -He worshipped this new angel with furtive eye, till he saw that she -had discovered him; then he pretended he did not know she was present, -and began to "show off" in all sorts of absurd boyish ways, in order to -win her admiration. He kept up this grotesque foolishness for some -time; but by-and-by, while he was in the midst of some dangerous -gymnastic performances, he glanced aside and saw that the little girl -was wending her way toward the house. Tom came up to the fence and -leaned on it, grieving, and hoping she would tarry yet awhile longer. -She halted a moment on the steps and then moved toward the door. Tom -heaved a great sigh as she put her foot on the threshold. But his face -lit up, right away, for she tossed a pansy over the fence a moment -before she disappeared. - -The boy ran around and stopped within a foot or two of the flower, and -then shaded his eyes with his hand and began to look down street as if -he had discovered something of interest going on in that direction. -Presently he picked up a straw and began trying to balance it on his -nose, with his head tilted far back; and as he moved from side to side, -in his efforts, he edged nearer and nearer toward the pansy; finally -his bare foot rested upon it, his pliant toes closed upon it, and he -hopped away with the treasure and disappeared round the corner. But -only for a minute--only while he could button the flower inside his -jacket, next his heart--or next his stomach, possibly, for he was not -much posted in anatomy, and not hypercritical, anyway. - -He returned, now, and hung about the fence till nightfall, "showing -off," as before; but the girl never exhibited herself again, though Tom -comforted himself a little with the hope that she had been near some -window, meantime, and been aware of his attentions. Finally he strode -home reluctantly, with his poor head full of visions. - -All through supper his spirits were so high that his aunt wondered -"what had got into the child." He took a good scolding about clodding -Sid, and did not seem to mind it in the least. He tried to steal sugar -under his aunt's very nose, and got his knuckles rapped for it. He said: - -"Aunt, you don't whack Sid when he takes it." - -"Well, Sid don't torment a body the way you do. You'd be always into -that sugar if I warn't watching you." - -Presently she stepped into the kitchen, and Sid, happy in his -immunity, reached for the sugar-bowl--a sort of glorying over Tom which -was wellnigh unbearable. But Sid's fingers slipped and the bowl dropped -and broke. Tom was in ecstasies. In such ecstasies that he even -controlled his tongue and was silent. He said to himself that he would -not speak a word, even when his aunt came in, but would sit perfectly -still till she asked who did the mischief; and then he would tell, and -there would be nothing so good in the world as to see that pet model -"catch it." He was so brimful of exultation that he could hardly hold -himself when the old lady came back and stood above the wreck -discharging lightnings of wrath from over her spectacles. He said to -himself, "Now it's coming!" And the next instant he was sprawling on -the floor! The potent palm was uplifted to strike again when Tom cried -out: - -"Hold on, now, what 'er you belting ME for?--Sid broke it!" - -Aunt Polly paused, perplexed, and Tom looked for healing pity. But -when she got her tongue again, she only said: - -"Umf! Well, you didn't get a lick amiss, I reckon. You been into some -other audacious mischief when I wasn't around, like enough." - -Then her conscience reproached her, and she yearned to say something -kind and loving; but she judged that this would be construed into a -confession that she had been in the wrong, and discipline forbade that. -So she kept silence, and went about her affairs with a troubled heart. -Tom sulked in a corner and exalted his woes. He knew that in her heart -his aunt was on her knees to him, and he was morosely gratified by the -consciousness of it. He would hang out no signals, he would take notice -of none. He knew that a yearning glance fell upon him, now and then, -through a film of tears, but he refused recognition of it. He pictured -himself lying sick unto death and his aunt bending over him beseeching -one little forgiving word, but he would turn his face to the wall, and -die with that word unsaid. Ah, how would she feel then? And he pictured -himself brought home from the river, dead, with his curls all wet, and -his sore heart at rest. How she would throw herself upon him, and how -her tears would fall like rain, and her lips pray God to give her back -her boy and she would never, never abuse him any more! But he would lie -there cold and white and make no sign--a poor little sufferer, whose -griefs were at an end. He so worked upon his feelings with the pathos -of these dreams, that he had to keep swallowing, he was so like to -choke; and his eyes swam in a blur of water, which overflowed when he -winked, and ran down and trickled from the end of his nose. And such a -luxury to him was this petting of his sorrows, that he could not bear -to have any worldly cheeriness or any grating delight intrude upon it; -it was too sacred for such contact; and so, presently, when his cousin -Mary danced in, all alive with the joy of seeing home again after an -age-long visit of one week to the country, he got up and moved in -clouds and darkness out at one door as she brought song and sunshine in -at the other. - -He wandered far from the accustomed haunts of boys, and sought -desolate places that were in harmony with his spirit. A log raft in the -river invited him, and he seated himself on its outer edge and -contemplated the dreary vastness of the stream, wishing, the while, -that he could only be drowned, all at once and unconsciously, without -undergoing the uncomfortable routine devised by nature. Then he thought -of his flower. He got it out, rumpled and wilted, and it mightily -increased his dismal felicity. He wondered if she would pity him if she -knew? Would she cry, and wish that she had a right to put her arms -around his neck and comfort him? Or would she turn coldly away like all -the hollow world? This picture brought such an agony of pleasurable -suffering that he worked it over and over again in his mind and set it -up in new and varied lights, till he wore it threadbare. At last he -rose up sighing and departed in the darkness. - -About half-past nine or ten o'clock he came along the deserted street -to where the Adored Unknown lived; he paused a moment; no sound fell -upon his listening ear; a candle was casting a dull glow upon the -curtain of a second-story window. Was the sacred presence there? He -climbed the fence, threaded his stealthy way through the plants, till -he stood under that window; he looked up at it long, and with emotion; -then he laid him down on the ground under it, disposing himself upon -his back, with his hands clasped upon his breast and holding his poor -wilted flower. And thus he would die--out in the cold world, with no -shelter over his homeless head, no friendly hand to wipe the -death-damps from his brow, no loving face to bend pityingly over him -when the great agony came. And thus SHE would see him when she looked -out upon the glad morning, and oh! would she drop one little tear upon -his poor, lifeless form, would she heave one little sigh to see a bright -young life so rudely blighted, so untimely cut down? - -The window went up, a maid-servant's discordant voice profaned the -holy calm, and a deluge of water drenched the prone martyr's remains! - -The strangling hero sprang up with a relieving snort. There was a whiz -as of a missile in the air, mingled with the murmur of a curse, a sound -as of shivering glass followed, and a small, vague form went over the -fence and shot away in the gloom. - -Not long after, as Tom, all undressed for bed, was surveying his -drenched garments by the light of a tallow dip, Sid woke up; but if he -had any dim idea of making any "references to allusions," he thought -better of it and held his peace, for there was danger in Tom's eye. - -Tom turned in without the added vexation of prayers, and Sid made -mental note of the omission. - - - -CHAPTER IV - -THE sun rose upon a tranquil world, and beamed down upon the peaceful -village like a benediction. Breakfast over, Aunt Polly had family -worship: it began with a prayer built from the ground up of solid -courses of Scriptural quotations, welded together with a thin mortar of -originality; and from the summit of this she delivered a grim chapter -of the Mosaic Law, as from Sinai. - -Then Tom girded up his loins, so to speak, and went to work to "get -his verses." Sid had learned his lesson days before. Tom bent all his -energies to the memorizing of five verses, and he chose part of the -Sermon on the Mount, because he could find no verses that were shorter. -At the end of half an hour Tom had a vague general idea of his lesson, -but no more, for his mind was traversing the whole field of human -thought, and his hands were busy with distracting recreations. Mary -took his book to hear him recite, and he tried to find his way through -the fog: - -"Blessed are the--a--a--" - -"Poor"-- - -"Yes--poor; blessed are the poor--a--a--" - -"In spirit--" - -"In spirit; blessed are the poor in spirit, for they--they--" - -"THEIRS--" - -"For THEIRS. Blessed are the poor in spirit, for theirs is the kingdom -of heaven. Blessed are they that mourn, for they--they--" - -"Sh--" - -"For they--a--" - -"S, H, A--" - -"For they S, H--Oh, I don't know what it is!" - -"SHALL!" - -"Oh, SHALL! for they shall--for they shall--a--a--shall mourn--a--a-- -blessed are they that shall--they that--a--they that shall mourn, for -they shall--a--shall WHAT? Why don't you tell me, Mary?--what do you -want to be so mean for?" - -"Oh, Tom, you poor thick-headed thing, I'm not teasing you. I wouldn't -do that. You must go and learn it again. Don't you be discouraged, Tom, -you'll manage it--and if you do, I'll give you something ever so nice. -There, now, that's a good boy." - -"All right! What is it, Mary, tell me what it is." - -"Never you mind, Tom. You know if I say it's nice, it is nice." - -"You bet you that's so, Mary. All right, I'll tackle it again." - -And he did "tackle it again"--and under the double pressure of -curiosity and prospective gain he did it with such spirit that he -accomplished a shining success. Mary gave him a brand-new "Barlow" -knife worth twelve and a half cents; and the convulsion of delight that -swept his system shook him to his foundations. True, the knife would -not cut anything, but it was a "sure-enough" Barlow, and there was -inconceivable grandeur in that--though where the Western boys ever got -the idea that such a weapon could possibly be counterfeited to its -injury is an imposing mystery and will always remain so, perhaps. Tom -contrived to scarify the cupboard with it, and was arranging to begin -on the bureau, when he was called off to dress for Sunday-school. - -Mary gave him a tin basin of water and a piece of soap, and he went -outside the door and set the basin on a little bench there; then he -dipped the soap in the water and laid it down; turned up his sleeves; -poured out the water on the ground, gently, and then entered the -kitchen and began to wipe his face diligently on the towel behind the -door. But Mary removed the towel and said: - -"Now ain't you ashamed, Tom. You mustn't be so bad. Water won't hurt -you." - -Tom was a trifle disconcerted. The basin was refilled, and this time -he stood over it a little while, gathering resolution; took in a big -breath and began. When he entered the kitchen presently, with both eyes -shut and groping for the towel with his hands, an honorable testimony -of suds and water was dripping from his face. But when he emerged from -the towel, he was not yet satisfactory, for the clean territory stopped -short at his chin and his jaws, like a mask; below and beyond this line -there was a dark expanse of unirrigated soil that spread downward in -front and backward around his neck. Mary took him in hand, and when she -was done with him he was a man and a brother, without distinction of -color, and his saturated hair was neatly brushed, and its short curls -wrought into a dainty and symmetrical general effect. [He privately -smoothed out the curls, with labor and difficulty, and plastered his -hair close down to his head; for he held curls to be effeminate, and -his own filled his life with bitterness.] Then Mary got out a suit of -his clothing that had been used only on Sundays during two years--they -were simply called his "other clothes"--and so by that we know the -size of his wardrobe. The girl "put him to rights" after he had dressed -himself; she buttoned his neat roundabout up to his chin, turned his -vast shirt collar down over his shoulders, brushed him off and crowned -him with his speckled straw hat. He now looked exceedingly improved and -uncomfortable. He was fully as uncomfortable as he looked; for there -was a restraint about whole clothes and cleanliness that galled him. He -hoped that Mary would forget his shoes, but the hope was blighted; she -coated them thoroughly with tallow, as was the custom, and brought them -out. He lost his temper and said he was always being made to do -everything he didn't want to do. But Mary said, persuasively: - -"Please, Tom--that's a good boy." - -So he got into the shoes snarling. Mary was soon ready, and the three -children set out for Sunday-school--a place that Tom hated with his -whole heart; but Sid and Mary were fond of it. - -Sabbath-school hours were from nine to half-past ten; and then church -service. Two of the children always remained for the sermon -voluntarily, and the other always remained too--for stronger reasons. -The church's high-backed, uncushioned pews would seat about three -hundred persons; the edifice was but a small, plain affair, with a sort -of pine board tree-box on top of it for a steeple. At the door Tom -dropped back a step and accosted a Sunday-dressed comrade: - -"Say, Billy, got a yaller ticket?" - -"Yes." - -"What'll you take for her?" - -"What'll you give?" - -"Piece of lickrish and a fish-hook." - -"Less see 'em." - -Tom exhibited. They were satisfactory, and the property changed hands. -Then Tom traded a couple of white alleys for three red tickets, and -some small trifle or other for a couple of blue ones. He waylaid other -boys as they came, and went on buying tickets of various colors ten or -fifteen minutes longer. He entered the church, now, with a swarm of -clean and noisy boys and girls, proceeded to his seat and started a -quarrel with the first boy that came handy. The teacher, a grave, -elderly man, interfered; then turned his back a moment and Tom pulled a -boy's hair in the next bench, and was absorbed in his book when the boy -turned around; stuck a pin in another boy, presently, in order to hear -him say "Ouch!" and got a new reprimand from his teacher. Tom's whole -class were of a pattern--restless, noisy, and troublesome. When they -came to recite their lessons, not one of them knew his verses -perfectly, but had to be prompted all along. However, they worried -through, and each got his reward--in small blue tickets, each with a -passage of Scripture on it; each blue ticket was pay for two verses of -the recitation. Ten blue tickets equalled a red one, and could be -exchanged for it; ten red tickets equalled a yellow one; for ten yellow -tickets the superintendent gave a very plainly bound Bible (worth forty -cents in those easy times) to the pupil. How many of my readers would -have the industry and application to memorize two thousand verses, even -for a Dore Bible? And yet Mary had acquired two Bibles in this way--it -was the patient work of two years--and a boy of German parentage had -won four or five. He once recited three thousand verses without -stopping; but the strain upon his mental faculties was too great, and -he was little better than an idiot from that day forth--a grievous -misfortune for the school, for on great occasions, before company, the -superintendent (as Tom expressed it) had always made this boy come out -and "spread himself." Only the older pupils managed to keep their -tickets and stick to their tedious work long enough to get a Bible, and -so the delivery of one of these prizes was a rare and noteworthy -circumstance; the successful pupil was so great and conspicuous for -that day that on the spot every scholar's heart was fired with a fresh -ambition that often lasted a couple of weeks. It is possible that Tom's -mental stomach had never really hungered for one of those prizes, but -unquestionably his entire being had for many a day longed for the glory -and the eclat that came with it. - -In due course the superintendent stood up in front of the pulpit, with -a closed hymn-book in his hand and his forefinger inserted between its -leaves, and commanded attention. When a Sunday-school superintendent -makes his customary little speech, a hymn-book in the hand is as -necessary as is the inevitable sheet of music in the hand of a singer -who stands forward on the platform and sings a solo at a concert ---though why, is a mystery: for neither the hymn-book nor the sheet of -music is ever referred to by the sufferer. This superintendent was a -slim creature of thirty-five, with a sandy goatee and short sandy hair; -he wore a stiff standing-collar whose upper edge almost reached his -ears and whose sharp points curved forward abreast the corners of his -mouth--a fence that compelled a straight lookout ahead, and a turning -of the whole body when a side view was required; his chin was propped -on a spreading cravat which was as broad and as long as a bank-note, -and had fringed ends; his boot toes were turned sharply up, in the -fashion of the day, like sleigh-runners--an effect patiently and -laboriously produced by the young men by sitting with their toes -pressed against a wall for hours together. Mr. Walters was very earnest -of mien, and very sincere and honest at heart; and he held sacred -things and places in such reverence, and so separated them from worldly -matters, that unconsciously to himself his Sunday-school voice had -acquired a peculiar intonation which was wholly absent on week-days. He -began after this fashion: - -"Now, children, I want you all to sit up just as straight and pretty -as you can and give me all your attention for a minute or two. There ---that is it. That is the way good little boys and girls should do. I see -one little girl who is looking out of the window--I am afraid she -thinks I am out there somewhere--perhaps up in one of the trees making -a speech to the little birds. [Applausive titter.] I want to tell you -how good it makes me feel to see so many bright, clean little faces -assembled in a place like this, learning to do right and be good." And -so forth and so on. It is not necessary to set down the rest of the -oration. It was of a pattern which does not vary, and so it is familiar -to us all. - -The latter third of the speech was marred by the resumption of fights -and other recreations among certain of the bad boys, and by fidgetings -and whisperings that extended far and wide, washing even to the bases -of isolated and incorruptible rocks like Sid and Mary. But now every -sound ceased suddenly, with the subsidence of Mr. Walters' voice, and -the conclusion of the speech was received with a burst of silent -gratitude. - -A good part of the whispering had been occasioned by an event which -was more or less rare--the entrance of visitors: lawyer Thatcher, -accompanied by a very feeble and aged man; a fine, portly, middle-aged -gentleman with iron-gray hair; and a dignified lady who was doubtless -the latter's wife. The lady was leading a child. Tom had been restless -and full of chafings and repinings; conscience-smitten, too--he could -not meet Amy Lawrence's eye, he could not brook her loving gaze. But -when he saw this small new-comer his soul was all ablaze with bliss in -a moment. The next moment he was "showing off" with all his might ---cuffing boys, pulling hair, making faces--in a word, using every art -that seemed likely to fascinate a girl and win her applause. His -exaltation had but one alloy--the memory of his humiliation in this -angel's garden--and that record in sand was fast washing out, under -the waves of happiness that were sweeping over it now. - -The visitors were given the highest seat of honor, and as soon as Mr. -Walters' speech was finished, he introduced them to the school. The -middle-aged man turned out to be a prodigious personage--no less a one -than the county judge--altogether the most august creation these -children had ever looked upon--and they wondered what kind of material -he was made of--and they half wanted to hear him roar, and were half -afraid he might, too. He was from Constantinople, twelve miles away--so -he had travelled, and seen the world--these very eyes had looked upon -the county court-house--which was said to have a tin roof. The awe -which these reflections inspired was attested by the impressive silence -and the ranks of staring eyes. This was the great Judge Thatcher, -brother of their own lawyer. Jeff Thatcher immediately went forward, to -be familiar with the great man and be envied by the school. It would -have been music to his soul to hear the whisperings: - -"Look at him, Jim! He's a going up there. Say--look! he's a going to -shake hands with him--he IS shaking hands with him! By jings, don't you -wish you was Jeff?" - -Mr. Walters fell to "showing off," with all sorts of official -bustlings and activities, giving orders, delivering judgments, -discharging directions here, there, everywhere that he could find a -target. The librarian "showed off"--running hither and thither with his -arms full of books and making a deal of the splutter and fuss that -insect authority delights in. The young lady teachers "showed off" ---bending sweetly over pupils that were lately being boxed, lifting -pretty warning fingers at bad little boys and patting good ones -lovingly. The young gentlemen teachers "showed off" with small -scoldings and other little displays of authority and fine attention to -discipline--and most of the teachers, of both sexes, found business up -at the library, by the pulpit; and it was business that frequently had -to be done over again two or three times (with much seeming vexation). -The little girls "showed off" in various ways, and the little boys -"showed off" with such diligence that the air was thick with paper wads -and the murmur of scufflings. And above it all the great man sat and -beamed a majestic judicial smile upon all the house, and warmed himself -in the sun of his own grandeur--for he was "showing off," too. - -There was only one thing wanting to make Mr. Walters' ecstasy -complete, and that was a chance to deliver a Bible-prize and exhibit a -prodigy. Several pupils had a few yellow tickets, but none had enough ---he had been around among the star pupils inquiring. He would have given -worlds, now, to have that German lad back again with a sound mind. - -And now at this moment, when hope was dead, Tom Sawyer came forward -with nine yellow tickets, nine red tickets, and ten blue ones, and -demanded a Bible. This was a thunderbolt out of a clear sky. Walters -was not expecting an application from this source for the next ten -years. But there was no getting around it--here were the certified -checks, and they were good for their face. Tom was therefore elevated -to a place with the Judge and the other elect, and the great news was -announced from headquarters. It was the most stunning surprise of the -decade, and so profound was the sensation that it lifted the new hero -up to the judicial one's altitude, and the school had two marvels to -gaze upon in place of one. The boys were all eaten up with envy--but -those that suffered the bitterest pangs were those who perceived too -late that they themselves had contributed to this hated splendor by -trading tickets to Tom for the wealth he had amassed in selling -whitewashing privileges. These despised themselves, as being the dupes -of a wily fraud, a guileful snake in the grass. - -The prize was delivered to Tom with as much effusion as the -superintendent could pump up under the circumstances; but it lacked -somewhat of the true gush, for the poor fellow's instinct taught him -that there was a mystery here that could not well bear the light, -perhaps; it was simply preposterous that this boy had warehoused two -thousand sheaves of Scriptural wisdom on his premises--a dozen would -strain his capacity, without a doubt. - -Amy Lawrence was proud and glad, and she tried to make Tom see it in -her face--but he wouldn't look. She wondered; then she was just a grain -troubled; next a dim suspicion came and went--came again; she watched; -a furtive glance told her worlds--and then her heart broke, and she was -jealous, and angry, and the tears came and she hated everybody. Tom -most of all (she thought). - -Tom was introduced to the Judge; but his tongue was tied, his breath -would hardly come, his heart quaked--partly because of the awful -greatness of the man, but mainly because he was her parent. He would -have liked to fall down and worship him, if it were in the dark. The -Judge put his hand on Tom's head and called him a fine little man, and -asked him what his name was. The boy stammered, gasped, and got it out: - -"Tom." - -"Oh, no, not Tom--it is--" - -"Thomas." - -"Ah, that's it. I thought there was more to it, maybe. That's very -well. But you've another one I daresay, and you'll tell it to me, won't -you?" - -"Tell the gentleman your other name, Thomas," said Walters, "and say -sir. You mustn't forget your manners." - -"Thomas Sawyer--sir." - -"That's it! That's a good boy. Fine boy. Fine, manly little fellow. -Two thousand verses is a great many--very, very great many. And you -never can be sorry for the trouble you took to learn them; for -knowledge is worth more than anything there is in the world; it's what -makes great men and good men; you'll be a great man and a good man -yourself, some day, Thomas, and then you'll look back and say, It's all -owing to the precious Sunday-school privileges of my boyhood--it's all -owing to my dear teachers that taught me to learn--it's all owing to -the good superintendent, who encouraged me, and watched over me, and -gave me a beautiful Bible--a splendid elegant Bible--to keep and have -it all for my own, always--it's all owing to right bringing up! That is -what you will say, Thomas--and you wouldn't take any money for those -two thousand verses--no indeed you wouldn't. And now you wouldn't mind -telling me and this lady some of the things you've learned--no, I know -you wouldn't--for we are proud of little boys that learn. Now, no -doubt you know the names of all the twelve disciples. Won't you tell us -the names of the first two that were appointed?" - -Tom was tugging at a button-hole and looking sheepish. He blushed, -now, and his eyes fell. Mr. Walters' heart sank within him. He said to -himself, it is not possible that the boy can answer the simplest -question--why DID the Judge ask him? Yet he felt obliged to speak up -and say: - -"Answer the gentleman, Thomas--don't be afraid." - -Tom still hung fire. - -"Now I know you'll tell me," said the lady. "The names of the first -two disciples were--" - -"DAVID AND GOLIAH!" - -Let us draw the curtain of charity over the rest of the scene. - - - -CHAPTER V - -ABOUT half-past ten the cracked bell of the small church began to -ring, and presently the people began to gather for the morning sermon. -The Sunday-school children distributed themselves about the house and -occupied pews with their parents, so as to be under supervision. Aunt -Polly came, and Tom and Sid and Mary sat with her--Tom being placed -next the aisle, in order that he might be as far away from the open -window and the seductive outside summer scenes as possible. The crowd -filed up the aisles: the aged and needy postmaster, who had seen better -days; the mayor and his wife--for they had a mayor there, among other -unnecessaries; the justice of the peace; the widow Douglass, fair, -smart, and forty, a generous, good-hearted soul and well-to-do, her -hill mansion the only palace in the town, and the most hospitable and -much the most lavish in the matter of festivities that St. Petersburg -could boast; the bent and venerable Major and Mrs. Ward; lawyer -Riverson, the new notable from a distance; next the belle of the -village, followed by a troop of lawn-clad and ribbon-decked young -heart-breakers; then all the young clerks in town in a body--for they -had stood in the vestibule sucking their cane-heads, a circling wall of -oiled and simpering admirers, till the last girl had run their gantlet; -and last of all came the Model Boy, Willie Mufferson, taking as heedful -care of his mother as if she were cut glass. He always brought his -mother to church, and was the pride of all the matrons. The boys all -hated him, he was so good. And besides, he had been "thrown up to them" -so much. His white handkerchief was hanging out of his pocket behind, as -usual on Sundays--accidentally. Tom had no handkerchief, and he looked -upon boys who had as snobs. - -The congregation being fully assembled, now, the bell rang once more, -to warn laggards and stragglers, and then a solemn hush fell upon the -church which was only broken by the tittering and whispering of the -choir in the gallery. The choir always tittered and whispered all -through service. There was once a church choir that was not ill-bred, -but I have forgotten where it was, now. It was a great many years ago, -and I can scarcely remember anything about it, but I think it was in -some foreign country. - -The minister gave out the hymn, and read it through with a relish, in -a peculiar style which was much admired in that part of the country. -His voice began on a medium key and climbed steadily up till it reached -a certain point, where it bore with strong emphasis upon the topmost -word and then plunged down as if from a spring-board: - - Shall I be car-ri-ed toe the skies, on flow'ry BEDS of ease, - - Whilst others fight to win the prize, and sail thro' BLOODY seas? - -He was regarded as a wonderful reader. At church "sociables" he was -always called upon to read poetry; and when he was through, the ladies -would lift up their hands and let them fall helplessly in their laps, -and "wall" their eyes, and shake their heads, as much as to say, "Words -cannot express it; it is too beautiful, TOO beautiful for this mortal -earth." - -After the hymn had been sung, the Rev. Mr. Sprague turned himself into -a bulletin-board, and read off "notices" of meetings and societies and -things till it seemed that the list would stretch out to the crack of -doom--a queer custom which is still kept up in America, even in cities, -away here in this age of abundant newspapers. Often, the less there is -to justify a traditional custom, the harder it is to get rid of it. - -And now the minister prayed. A good, generous prayer it was, and went -into details: it pleaded for the church, and the little children of the -church; for the other churches of the village; for the village itself; -for the county; for the State; for the State officers; for the United -States; for the churches of the United States; for Congress; for the -President; for the officers of the Government; for poor sailors, tossed -by stormy seas; for the oppressed millions groaning under the heel of -European monarchies and Oriental despotisms; for such as have the light -and the good tidings, and yet have not eyes to see nor ears to hear -withal; for the heathen in the far islands of the sea; and closed with -a supplication that the words he was about to speak might find grace -and favor, and be as seed sown in fertile ground, yielding in time a -grateful harvest of good. Amen. - -There was a rustling of dresses, and the standing congregation sat -down. The boy whose history this book relates did not enjoy the prayer, -he only endured it--if he even did that much. He was restive all -through it; he kept tally of the details of the prayer, unconsciously ---for he was not listening, but he knew the ground of old, and the -clergyman's regular route over it--and when a little trifle of new -matter was interlarded, his ear detected it and his whole nature -resented it; he considered additions unfair, and scoundrelly. In the -midst of the prayer a fly had lit on the back of the pew in front of -him and tortured his spirit by calmly rubbing its hands together, -embracing its head with its arms, and polishing it so vigorously that -it seemed to almost part company with the body, and the slender thread -of a neck was exposed to view; scraping its wings with its hind legs -and smoothing them to its body as if they had been coat-tails; going -through its whole toilet as tranquilly as if it knew it was perfectly -safe. As indeed it was; for as sorely as Tom's hands itched to grab for -it they did not dare--he believed his soul would be instantly destroyed -if he did such a thing while the prayer was going on. But with the -closing sentence his hand began to curve and steal forward; and the -instant the "Amen" was out the fly was a prisoner of war. His aunt -detected the act and made him let it go. - -The minister gave out his text and droned along monotonously through -an argument that was so prosy that many a head by and by began to nod ---and yet it was an argument that dealt in limitless fire and brimstone -and thinned the predestined elect down to a company so small as to be -hardly worth the saving. Tom counted the pages of the sermon; after -church he always knew how many pages there had been, but he seldom knew -anything else about the discourse. However, this time he was really -interested for a little while. The minister made a grand and moving -picture of the assembling together of the world's hosts at the -millennium when the lion and the lamb should lie down together and a -little child should lead them. But the pathos, the lesson, the moral of -the great spectacle were lost upon the boy; he only thought of the -conspicuousness of the principal character before the on-looking -nations; his face lit with the thought, and he said to himself that he -wished he could be that child, if it was a tame lion. - -Now he lapsed into suffering again, as the dry argument was resumed. -Presently he bethought him of a treasure he had and got it out. It was -a large black beetle with formidable jaws--a "pinchbug," he called it. -It was in a percussion-cap box. The first thing the beetle did was to -take him by the finger. A natural fillip followed, the beetle went -floundering into the aisle and lit on its back, and the hurt finger -went into the boy's mouth. The beetle lay there working its helpless -legs, unable to turn over. Tom eyed it, and longed for it; but it was -safe out of his reach. Other people uninterested in the sermon found -relief in the beetle, and they eyed it too. Presently a vagrant poodle -dog came idling along, sad at heart, lazy with the summer softness and -the quiet, weary of captivity, sighing for change. He spied the beetle; -the drooping tail lifted and wagged. He surveyed the prize; walked -around it; smelt at it from a safe distance; walked around it again; -grew bolder, and took a closer smell; then lifted his lip and made a -gingerly snatch at it, just missing it; made another, and another; -began to enjoy the diversion; subsided to his stomach with the beetle -between his paws, and continued his experiments; grew weary at last, -and then indifferent and absent-minded. His head nodded, and little by -little his chin descended and touched the enemy, who seized it. There -was a sharp yelp, a flirt of the poodle's head, and the beetle fell a -couple of yards away, and lit on its back once more. The neighboring -spectators shook with a gentle inward joy, several faces went behind -fans and handkerchiefs, and Tom was entirely happy. The dog looked -foolish, and probably felt so; but there was resentment in his heart, -too, and a craving for revenge. So he went to the beetle and began a -wary attack on it again; jumping at it from every point of a circle, -lighting with his fore-paws within an inch of the creature, making even -closer snatches at it with his teeth, and jerking his head till his -ears flapped again. But he grew tired once more, after a while; tried -to amuse himself with a fly but found no relief; followed an ant -around, with his nose close to the floor, and quickly wearied of that; -yawned, sighed, forgot the beetle entirely, and sat down on it. Then -there was a wild yelp of agony and the poodle went sailing up the -aisle; the yelps continued, and so did the dog; he crossed the house in -front of the altar; he flew down the other aisle; he crossed before the -doors; he clamored up the home-stretch; his anguish grew with his -progress, till presently he was but a woolly comet moving in its orbit -with the gleam and the speed of light. At last the frantic sufferer -sheered from its course, and sprang into its master's lap; he flung it -out of the window, and the voice of distress quickly thinned away and -died in the distance. - -By this time the whole church was red-faced and suffocating with -suppressed laughter, and the sermon had come to a dead standstill. The -discourse was resumed presently, but it went lame and halting, all -possibility of impressiveness being at an end; for even the gravest -sentiments were constantly being received with a smothered burst of -unholy mirth, under cover of some remote pew-back, as if the poor -parson had said a rarely facetious thing. It was a genuine relief to -the whole congregation when the ordeal was over and the benediction -pronounced. - -Tom Sawyer went home quite cheerful, thinking to himself that there -was some satisfaction about divine service when there was a bit of -variety in it. He had but one marring thought; he was willing that the -dog should play with his pinchbug, but he did not think it was upright -in him to carry it off. - - - -CHAPTER VI - -MONDAY morning found Tom Sawyer miserable. Monday morning always found -him so--because it began another week's slow suffering in school. He -generally began that day with wishing he had had no intervening -holiday, it made the going into captivity and fetters again so much -more odious. - -Tom lay thinking. Presently it occurred to him that he wished he was -sick; then he could stay home from school. Here was a vague -possibility. He canvassed his system. No ailment was found, and he -investigated again. This time he thought he could detect colicky -symptoms, and he began to encourage them with considerable hope. But -they soon grew feeble, and presently died wholly away. He reflected -further. Suddenly he discovered something. One of his upper front teeth -was loose. This was lucky; he was about to begin to groan, as a -"starter," as he called it, when it occurred to him that if he came -into court with that argument, his aunt would pull it out, and that -would hurt. So he thought he would hold the tooth in reserve for the -present, and seek further. Nothing offered for some little time, and -then he remembered hearing the doctor tell about a certain thing that -laid up a patient for two or three weeks and threatened to make him -lose a finger. So the boy eagerly drew his sore toe from under the -sheet and held it up for inspection. But now he did not know the -necessary symptoms. However, it seemed well worth while to chance it, -so he fell to groaning with considerable spirit. - -But Sid slept on unconscious. - -Tom groaned louder, and fancied that he began to feel pain in the toe. - -No result from Sid. - -Tom was panting with his exertions by this time. He took a rest and -then swelled himself up and fetched a succession of admirable groans. - -Sid snored on. - -Tom was aggravated. He said, "Sid, Sid!" and shook him. This course -worked well, and Tom began to groan again. Sid yawned, stretched, then -brought himself up on his elbow with a snort, and began to stare at -Tom. Tom went on groaning. Sid said: - -"Tom! Say, Tom!" [No response.] "Here, Tom! TOM! What is the matter, -Tom?" And he shook him and looked in his face anxiously. - -Tom moaned out: - -"Oh, don't, Sid. Don't joggle me." - -"Why, what's the matter, Tom? I must call auntie." - -"No--never mind. It'll be over by and by, maybe. Don't call anybody." - -"But I must! DON'T groan so, Tom, it's awful. How long you been this -way?" - -"Hours. Ouch! Oh, don't stir so, Sid, you'll kill me." - -"Tom, why didn't you wake me sooner? Oh, Tom, DON'T! It makes my -flesh crawl to hear you. Tom, what is the matter?" - -"I forgive you everything, Sid. [Groan.] Everything you've ever done -to me. When I'm gone--" - -"Oh, Tom, you ain't dying, are you? Don't, Tom--oh, don't. Maybe--" - -"I forgive everybody, Sid. [Groan.] Tell 'em so, Sid. And Sid, you -give my window-sash and my cat with one eye to that new girl that's -come to town, and tell her--" - -But Sid had snatched his clothes and gone. Tom was suffering in -reality, now, so handsomely was his imagination working, and so his -groans had gathered quite a genuine tone. - -Sid flew down-stairs and said: - -"Oh, Aunt Polly, come! Tom's dying!" - -"Dying!" - -"Yes'm. Don't wait--come quick!" - -"Rubbage! I don't believe it!" - -But she fled up-stairs, nevertheless, with Sid and Mary at her heels. -And her face grew white, too, and her lip trembled. When she reached -the bedside she gasped out: - -"You, Tom! Tom, what's the matter with you?" - -"Oh, auntie, I'm--" - -"What's the matter with you--what is the matter with you, child?" - -"Oh, auntie, my sore toe's mortified!" - -The old lady sank down into a chair and laughed a little, then cried a -little, then did both together. This restored her and she said: - -"Tom, what a turn you did give me. Now you shut up that nonsense and -climb out of this." - -The groans ceased and the pain vanished from the toe. The boy felt a -little foolish, and he said: - -"Aunt Polly, it SEEMED mortified, and it hurt so I never minded my -tooth at all." - -"Your tooth, indeed! What's the matter with your tooth?" - -"One of them's loose, and it aches perfectly awful." - -"There, there, now, don't begin that groaning again. Open your mouth. -Well--your tooth IS loose, but you're not going to die about that. -Mary, get me a silk thread, and a chunk of fire out of the kitchen." - -Tom said: - -"Oh, please, auntie, don't pull it out. It don't hurt any more. I wish -I may never stir if it does. Please don't, auntie. I don't want to stay -home from school." - -"Oh, you don't, don't you? So all this row was because you thought -you'd get to stay home from school and go a-fishing? Tom, Tom, I love -you so, and you seem to try every way you can to break my old heart -with your outrageousness." By this time the dental instruments were -ready. The old lady made one end of the silk thread fast to Tom's tooth -with a loop and tied the other to the bedpost. Then she seized the -chunk of fire and suddenly thrust it almost into the boy's face. The -tooth hung dangling by the bedpost, now. - -But all trials bring their compensations. As Tom wended to school -after breakfast, he was the envy of every boy he met because the gap in -his upper row of teeth enabled him to expectorate in a new and -admirable way. He gathered quite a following of lads interested in the -exhibition; and one that had cut his finger and had been a centre of -fascination and homage up to this time, now found himself suddenly -without an adherent, and shorn of his glory. His heart was heavy, and -he said with a disdain which he did not feel that it wasn't anything to -spit like Tom Sawyer; but another boy said, "Sour grapes!" and he -wandered away a dismantled hero. - -Shortly Tom came upon the juvenile pariah of the village, Huckleberry -Finn, son of the town drunkard. Huckleberry was cordially hated and -dreaded by all the mothers of the town, because he was idle and lawless -and vulgar and bad--and because all their children admired him so, and -delighted in his forbidden society, and wished they dared to be like -him. Tom was like the rest of the respectable boys, in that he envied -Huckleberry his gaudy outcast condition, and was under strict orders -not to play with him. So he played with him every time he got a chance. -Huckleberry was always dressed in the cast-off clothes of full-grown -men, and they were in perennial bloom and fluttering with rags. His hat -was a vast ruin with a wide crescent lopped out of its brim; his coat, -when he wore one, hung nearly to his heels and had the rearward buttons -far down the back; but one suspender supported his trousers; the seat -of the trousers bagged low and contained nothing, the fringed legs -dragged in the dirt when not rolled up. - -Huckleberry came and went, at his own free will. He slept on doorsteps -in fine weather and in empty hogsheads in wet; he did not have to go to -school or to church, or call any being master or obey anybody; he could -go fishing or swimming when and where he chose, and stay as long as it -suited him; nobody forbade him to fight; he could sit up as late as he -pleased; he was always the first boy that went barefoot in the spring -and the last to resume leather in the fall; he never had to wash, nor -put on clean clothes; he could swear wonderfully. In a word, everything -that goes to make life precious that boy had. So thought every -harassed, hampered, respectable boy in St. Petersburg. - -Tom hailed the romantic outcast: - -"Hello, Huckleberry!" - -"Hello yourself, and see how you like it." - -"What's that you got?" - -"Dead cat." - -"Lemme see him, Huck. My, he's pretty stiff. Where'd you get him?" - -"Bought him off'n a boy." - -"What did you give?" - -"I give a blue ticket and a bladder that I got at the slaughter-house." - -"Where'd you get the blue ticket?" - -"Bought it off'n Ben Rogers two weeks ago for a hoop-stick." - -"Say--what is dead cats good for, Huck?" - -"Good for? Cure warts with." - -"No! Is that so? I know something that's better." - -"I bet you don't. What is it?" - -"Why, spunk-water." - -"Spunk-water! I wouldn't give a dern for spunk-water." - -"You wouldn't, wouldn't you? D'you ever try it?" - -"No, I hain't. But Bob Tanner did." - -"Who told you so!" - -"Why, he told Jeff Thatcher, and Jeff told Johnny Baker, and Johnny -told Jim Hollis, and Jim told Ben Rogers, and Ben told a nigger, and -the nigger told me. There now!" - -"Well, what of it? They'll all lie. Leastways all but the nigger. I -don't know HIM. But I never see a nigger that WOULDN'T lie. Shucks! Now -you tell me how Bob Tanner done it, Huck." - -"Why, he took and dipped his hand in a rotten stump where the -rain-water was." - -"In the daytime?" - -"Certainly." - -"With his face to the stump?" - -"Yes. Least I reckon so." - -"Did he say anything?" - -"I don't reckon he did. I don't know." - -"Aha! Talk about trying to cure warts with spunk-water such a blame -fool way as that! Why, that ain't a-going to do any good. You got to go -all by yourself, to the middle of the woods, where you know there's a -spunk-water stump, and just as it's midnight you back up against the -stump and jam your hand in and say: - - 'Barley-corn, barley-corn, injun-meal shorts, - Spunk-water, spunk-water, swaller these warts,' - -and then walk away quick, eleven steps, with your eyes shut, and then -turn around three times and walk home without speaking to anybody. -Because if you speak the charm's busted." - -"Well, that sounds like a good way; but that ain't the way Bob Tanner -done." - -"No, sir, you can bet he didn't, becuz he's the wartiest boy in this -town; and he wouldn't have a wart on him if he'd knowed how to work -spunk-water. I've took off thousands of warts off of my hands that way, -Huck. I play with frogs so much that I've always got considerable many -warts. Sometimes I take 'em off with a bean." - -"Yes, bean's good. I've done that." - -"Have you? What's your way?" - -"You take and split the bean, and cut the wart so as to get some -blood, and then you put the blood on one piece of the bean and take and -dig a hole and bury it 'bout midnight at the crossroads in the dark of -the moon, and then you burn up the rest of the bean. You see that piece -that's got the blood on it will keep drawing and drawing, trying to -fetch the other piece to it, and so that helps the blood to draw the -wart, and pretty soon off she comes." - -"Yes, that's it, Huck--that's it; though when you're burying it if you -say 'Down bean; off wart; come no more to bother me!' it's better. -That's the way Joe Harper does, and he's been nearly to Coonville and -most everywheres. But say--how do you cure 'em with dead cats?" - -"Why, you take your cat and go and get in the graveyard 'long about -midnight when somebody that was wicked has been buried; and when it's -midnight a devil will come, or maybe two or three, but you can't see -'em, you can only hear something like the wind, or maybe hear 'em talk; -and when they're taking that feller away, you heave your cat after 'em -and say, 'Devil follow corpse, cat follow devil, warts follow cat, I'm -done with ye!' That'll fetch ANY wart." - -"Sounds right. D'you ever try it, Huck?" - -"No, but old Mother Hopkins told me." - -"Well, I reckon it's so, then. Becuz they say she's a witch." - -"Say! Why, Tom, I KNOW she is. She witched pap. Pap says so his own -self. He come along one day, and he see she was a-witching him, so he -took up a rock, and if she hadn't dodged, he'd a got her. Well, that -very night he rolled off'n a shed wher' he was a layin drunk, and broke -his arm." - -"Why, that's awful. How did he know she was a-witching him?" - -"Lord, pap can tell, easy. Pap says when they keep looking at you -right stiddy, they're a-witching you. Specially if they mumble. Becuz -when they mumble they're saying the Lord's Prayer backards." - -"Say, Hucky, when you going to try the cat?" - -"To-night. I reckon they'll come after old Hoss Williams to-night." - -"But they buried him Saturday. Didn't they get him Saturday night?" - -"Why, how you talk! How could their charms work till midnight?--and -THEN it's Sunday. Devils don't slosh around much of a Sunday, I don't -reckon." - -"I never thought of that. That's so. Lemme go with you?" - -"Of course--if you ain't afeard." - -"Afeard! 'Tain't likely. Will you meow?" - -"Yes--and you meow back, if you get a chance. Last time, you kep' me -a-meowing around till old Hays went to throwing rocks at me and says -'Dern that cat!' and so I hove a brick through his window--but don't -you tell." - -"I won't. I couldn't meow that night, becuz auntie was watching me, -but I'll meow this time. Say--what's that?" - -"Nothing but a tick." - -"Where'd you get him?" - -"Out in the woods." - -"What'll you take for him?" - -"I don't know. I don't want to sell him." - -"All right. It's a mighty small tick, anyway." - -"Oh, anybody can run a tick down that don't belong to them. I'm -satisfied with it. It's a good enough tick for me." - -"Sho, there's ticks a plenty. I could have a thousand of 'em if I -wanted to." - -"Well, why don't you? Becuz you know mighty well you can't. This is a -pretty early tick, I reckon. It's the first one I've seen this year." - -"Say, Huck--I'll give you my tooth for him." - -"Less see it." - -Tom got out a bit of paper and carefully unrolled it. Huckleberry -viewed it wistfully. The temptation was very strong. At last he said: - -"Is it genuwyne?" - -Tom lifted his lip and showed the vacancy. - -"Well, all right," said Huckleberry, "it's a trade." - -Tom enclosed the tick in the percussion-cap box that had lately been -the pinchbug's prison, and the boys separated, each feeling wealthier -than before. - -When Tom reached the little isolated frame schoolhouse, he strode in -briskly, with the manner of one who had come with all honest speed. -He hung his hat on a peg and flung himself into his seat with -business-like alacrity. The master, throned on high in his great -splint-bottom arm-chair, was dozing, lulled by the drowsy hum of study. -The interruption roused him. - -"Thomas Sawyer!" - -Tom knew that when his name was pronounced in full, it meant trouble. - -"Sir!" - -"Come up here. Now, sir, why are you late again, as usual?" - -Tom was about to take refuge in a lie, when he saw two long tails of -yellow hair hanging down a back that he recognized by the electric -sympathy of love; and by that form was THE ONLY VACANT PLACE on the -girls' side of the schoolhouse. He instantly said: - -"I STOPPED TO TALK WITH HUCKLEBERRY FINN!" - -The master's pulse stood still, and he stared helplessly. The buzz of -study ceased. The pupils wondered if this foolhardy boy had lost his -mind. The master said: - -"You--you did what?" - -"Stopped to talk with Huckleberry Finn." - -There was no mistaking the words. - -"Thomas Sawyer, this is the most astounding confession I have ever -listened to. No mere ferule will answer for this offence. Take off your -jacket." - -The master's arm performed until it was tired and the stock of -switches notably diminished. Then the order followed: - -"Now, sir, go and sit with the girls! And let this be a warning to you." - -The titter that rippled around the room appeared to abash the boy, but -in reality that result was caused rather more by his worshipful awe of -his unknown idol and the dread pleasure that lay in his high good -fortune. He sat down upon the end of the pine bench and the girl -hitched herself away from him with a toss of her head. Nudges and winks -and whispers traversed the room, but Tom sat still, with his arms upon -the long, low desk before him, and seemed to study his book. - -By and by attention ceased from him, and the accustomed school murmur -rose upon the dull air once more. Presently the boy began to steal -furtive glances at the girl. She observed it, "made a mouth" at him and -gave him the back of her head for the space of a minute. When she -cautiously faced around again, a peach lay before her. She thrust it -away. Tom gently put it back. She thrust it away again, but with less -animosity. Tom patiently returned it to its place. Then she let it -remain. Tom scrawled on his slate, "Please take it--I got more." The -girl glanced at the words, but made no sign. Now the boy began to draw -something on the slate, hiding his work with his left hand. For a time -the girl refused to notice; but her human curiosity presently began to -manifest itself by hardly perceptible signs. The boy worked on, -apparently unconscious. The girl made a sort of noncommittal attempt to -see, but the boy did not betray that he was aware of it. At last she -gave in and hesitatingly whispered: - -"Let me see it." - -Tom partly uncovered a dismal caricature of a house with two gable -ends to it and a corkscrew of smoke issuing from the chimney. Then the -girl's interest began to fasten itself upon the work and she forgot -everything else. When it was finished, she gazed a moment, then -whispered: - -"It's nice--make a man." - -The artist erected a man in the front yard, that resembled a derrick. -He could have stepped over the house; but the girl was not -hypercritical; she was satisfied with the monster, and whispered: - -"It's a beautiful man--now make me coming along." - -Tom drew an hour-glass with a full moon and straw limbs to it and -armed the spreading fingers with a portentous fan. The girl said: - -"It's ever so nice--I wish I could draw." - -"It's easy," whispered Tom, "I'll learn you." - -"Oh, will you? When?" - -"At noon. Do you go home to dinner?" - -"I'll stay if you will." - -"Good--that's a whack. What's your name?" - -"Becky Thatcher. What's yours? Oh, I know. It's Thomas Sawyer." - -"That's the name they lick me by. I'm Tom when I'm good. You call me -Tom, will you?" - -"Yes." - -Now Tom began to scrawl something on the slate, hiding the words from -the girl. But she was not backward this time. She begged to see. Tom -said: - -"Oh, it ain't anything." - -"Yes it is." - -"No it ain't. You don't want to see." - -"Yes I do, indeed I do. Please let me." - -"You'll tell." - -"No I won't--deed and deed and double deed won't." - -"You won't tell anybody at all? Ever, as long as you live?" - -"No, I won't ever tell ANYbody. Now let me." - -"Oh, YOU don't want to see!" - -"Now that you treat me so, I WILL see." And she put her small hand -upon his and a little scuffle ensued, Tom pretending to resist in -earnest but letting his hand slip by degrees till these words were -revealed: "I LOVE YOU." - -"Oh, you bad thing!" And she hit his hand a smart rap, but reddened -and looked pleased, nevertheless. - -Just at this juncture the boy felt a slow, fateful grip closing on his -ear, and a steady lifting impulse. In that wise he was borne across the -house and deposited in his own seat, under a peppering fire of giggles -from the whole school. Then the master stood over him during a few -awful moments, and finally moved away to his throne without saying a -word. But although Tom's ear tingled, his heart was jubilant. - -As the school quieted down Tom made an honest effort to study, but the -turmoil within him was too great. In turn he took his place in the -reading class and made a botch of it; then in the geography class and -turned lakes into mountains, mountains into rivers, and rivers into -continents, till chaos was come again; then in the spelling class, and -got "turned down," by a succession of mere baby words, till he brought -up at the foot and yielded up the pewter medal which he had worn with -ostentation for months. - - - -CHAPTER VII - -THE harder Tom tried to fasten his mind on his book, the more his -ideas wandered. So at last, with a sigh and a yawn, he gave it up. It -seemed to him that the noon recess would never come. The air was -utterly dead. There was not a breath stirring. It was the sleepiest of -sleepy days. The drowsing murmur of the five and twenty studying -scholars soothed the soul like the spell that is in the murmur of bees. -Away off in the flaming sunshine, Cardiff Hill lifted its soft green -sides through a shimmering veil of heat, tinted with the purple of -distance; a few birds floated on lazy wing high in the air; no other -living thing was visible but some cows, and they were asleep. Tom's -heart ached to be free, or else to have something of interest to do to -pass the dreary time. His hand wandered into his pocket and his face -lit up with a glow of gratitude that was prayer, though he did not know -it. Then furtively the percussion-cap box came out. He released the -tick and put him on the long flat desk. The creature probably glowed -with a gratitude that amounted to prayer, too, at this moment, but it -was premature: for when he started thankfully to travel off, Tom turned -him aside with a pin and made him take a new direction. - -Tom's bosom friend sat next him, suffering just as Tom had been, and -now he was deeply and gratefully interested in this entertainment in an -instant. This bosom friend was Joe Harper. The two boys were sworn -friends all the week, and embattled enemies on Saturdays. Joe took a -pin out of his lapel and began to assist in exercising the prisoner. -The sport grew in interest momently. Soon Tom said that they were -interfering with each other, and neither getting the fullest benefit of -the tick. So he put Joe's slate on the desk and drew a line down the -middle of it from top to bottom. - -"Now," said he, "as long as he is on your side you can stir him up and -I'll let him alone; but if you let him get away and get on my side, -you're to leave him alone as long as I can keep him from crossing over." - -"All right, go ahead; start him up." - -The tick escaped from Tom, presently, and crossed the equator. Joe -harassed him awhile, and then he got away and crossed back again. This -change of base occurred often. While one boy was worrying the tick with -absorbing interest, the other would look on with interest as strong, -the two heads bowed together over the slate, and the two souls dead to -all things else. At last luck seemed to settle and abide with Joe. The -tick tried this, that, and the other course, and got as excited and as -anxious as the boys themselves, but time and again just as he would -have victory in his very grasp, so to speak, and Tom's fingers would be -twitching to begin, Joe's pin would deftly head him off, and keep -possession. At last Tom could stand it no longer. The temptation was -too strong. So he reached out and lent a hand with his pin. Joe was -angry in a moment. Said he: - -"Tom, you let him alone." - -"I only just want to stir him up a little, Joe." - -"No, sir, it ain't fair; you just let him alone." - -"Blame it, I ain't going to stir him much." - -"Let him alone, I tell you." - -"I won't!" - -"You shall--he's on my side of the line." - -"Look here, Joe Harper, whose is that tick?" - -"I don't care whose tick he is--he's on my side of the line, and you -sha'n't touch him." - -"Well, I'll just bet I will, though. He's my tick and I'll do what I -blame please with him, or die!" - -A tremendous whack came down on Tom's shoulders, and its duplicate on -Joe's; and for the space of two minutes the dust continued to fly from -the two jackets and the whole school to enjoy it. The boys had been too -absorbed to notice the hush that had stolen upon the school awhile -before when the master came tiptoeing down the room and stood over -them. He had contemplated a good part of the performance before he -contributed his bit of variety to it. - -When school broke up at noon, Tom flew to Becky Thatcher, and -whispered in her ear: - -"Put on your bonnet and let on you're going home; and when you get to -the corner, give the rest of 'em the slip, and turn down through the -lane and come back. I'll go the other way and come it over 'em the same -way." - -So the one went off with one group of scholars, and the other with -another. In a little while the two met at the bottom of the lane, and -when they reached the school they had it all to themselves. Then they -sat together, with a slate before them, and Tom gave Becky the pencil -and held her hand in his, guiding it, and so created another surprising -house. When the interest in art began to wane, the two fell to talking. -Tom was swimming in bliss. He said: - -"Do you love rats?" - -"No! I hate them!" - -"Well, I do, too--LIVE ones. But I mean dead ones, to swing round your -head with a string." - -"No, I don't care for rats much, anyway. What I like is chewing-gum." - -"Oh, I should say so! I wish I had some now." - -"Do you? I've got some. I'll let you chew it awhile, but you must give -it back to me." - -That was agreeable, so they chewed it turn about, and dangled their -legs against the bench in excess of contentment. - -"Was you ever at a circus?" said Tom. - -"Yes, and my pa's going to take me again some time, if I'm good." - -"I been to the circus three or four times--lots of times. Church ain't -shucks to a circus. There's things going on at a circus all the time. -I'm going to be a clown in a circus when I grow up." - -"Oh, are you! That will be nice. They're so lovely, all spotted up." - -"Yes, that's so. And they get slathers of money--most a dollar a day, -Ben Rogers says. Say, Becky, was you ever engaged?" - -"What's that?" - -"Why, engaged to be married." - -"No." - -"Would you like to?" - -"I reckon so. I don't know. What is it like?" - -"Like? Why it ain't like anything. You only just tell a boy you won't -ever have anybody but him, ever ever ever, and then you kiss and that's -all. Anybody can do it." - -"Kiss? What do you kiss for?" - -"Why, that, you know, is to--well, they always do that." - -"Everybody?" - -"Why, yes, everybody that's in love with each other. Do you remember -what I wrote on the slate?" - -"Ye--yes." - -"What was it?" - -"I sha'n't tell you." - -"Shall I tell YOU?" - -"Ye--yes--but some other time." - -"No, now." - -"No, not now--to-morrow." - -"Oh, no, NOW. Please, Becky--I'll whisper it, I'll whisper it ever so -easy." - -Becky hesitating, Tom took silence for consent, and passed his arm -about her waist and whispered the tale ever so softly, with his mouth -close to her ear. And then he added: - -"Now you whisper it to me--just the same." - -She resisted, for a while, and then said: - -"You turn your face away so you can't see, and then I will. But you -mustn't ever tell anybody--WILL you, Tom? Now you won't, WILL you?" - -"No, indeed, indeed I won't. Now, Becky." - -He turned his face away. She bent timidly around till her breath -stirred his curls and whispered, "I--love--you!" - -Then she sprang away and ran around and around the desks and benches, -with Tom after her, and took refuge in a corner at last, with her -little white apron to her face. Tom clasped her about her neck and -pleaded: - -"Now, Becky, it's all done--all over but the kiss. Don't you be afraid -of that--it ain't anything at all. Please, Becky." And he tugged at her -apron and the hands. - -By and by she gave up, and let her hands drop; her face, all glowing -with the struggle, came up and submitted. Tom kissed the red lips and -said: - -"Now it's all done, Becky. And always after this, you know, you ain't -ever to love anybody but me, and you ain't ever to marry anybody but -me, ever never and forever. Will you?" - -"No, I'll never love anybody but you, Tom, and I'll never marry -anybody but you--and you ain't to ever marry anybody but me, either." - -"Certainly. Of course. That's PART of it. And always coming to school -or when we're going home, you're to walk with me, when there ain't -anybody looking--and you choose me and I choose you at parties, because -that's the way you do when you're engaged." - -"It's so nice. I never heard of it before." - -"Oh, it's ever so gay! Why, me and Amy Lawrence--" - -The big eyes told Tom his blunder and he stopped, confused. - -"Oh, Tom! Then I ain't the first you've ever been engaged to!" - -The child began to cry. Tom said: - -"Oh, don't cry, Becky, I don't care for her any more." - -"Yes, you do, Tom--you know you do." - -Tom tried to put his arm about her neck, but she pushed him away and -turned her face to the wall, and went on crying. Tom tried again, with -soothing words in his mouth, and was repulsed again. Then his pride was -up, and he strode away and went outside. He stood about, restless and -uneasy, for a while, glancing at the door, every now and then, hoping -she would repent and come to find him. But she did not. Then he began -to feel badly and fear that he was in the wrong. It was a hard struggle -with him to make new advances, now, but he nerved himself to it and -entered. She was still standing back there in the corner, sobbing, with -her face to the wall. Tom's heart smote him. He went to her and stood a -moment, not knowing exactly how to proceed. Then he said hesitatingly: - -"Becky, I--I don't care for anybody but you." - -No reply--but sobs. - -"Becky"--pleadingly. "Becky, won't you say something?" - -More sobs. - -Tom got out his chiefest jewel, a brass knob from the top of an -andiron, and passed it around her so that she could see it, and said: - -"Please, Becky, won't you take it?" - -She struck it to the floor. Then Tom marched out of the house and over -the hills and far away, to return to school no more that day. Presently -Becky began to suspect. She ran to the door; he was not in sight; she -flew around to the play-yard; he was not there. Then she called: - -"Tom! Come back, Tom!" - -She listened intently, but there was no answer. She had no companions -but silence and loneliness. So she sat down to cry again and upbraid -herself; and by this time the scholars began to gather again, and she -had to hide her griefs and still her broken heart and take up the cross -of a long, dreary, aching afternoon, with none among the strangers -about her to exchange sorrows with. - - - -CHAPTER VIII - -TOM dodged hither and thither through lanes until he was well out of -the track of returning scholars, and then fell into a moody jog. He -crossed a small "branch" two or three times, because of a prevailing -juvenile superstition that to cross water baffled pursuit. Half an hour -later he was disappearing behind the Douglas mansion on the summit of -Cardiff Hill, and the schoolhouse was hardly distinguishable away off -in the valley behind him. He entered a dense wood, picked his pathless -way to the centre of it, and sat down on a mossy spot under a spreading -oak. There was not even a zephyr stirring; the dead noonday heat had -even stilled the songs of the birds; nature lay in a trance that was -broken by no sound but the occasional far-off hammering of a -woodpecker, and this seemed to render the pervading silence and sense -of loneliness the more profound. The boy's soul was steeped in -melancholy; his feelings were in happy accord with his surroundings. He -sat long with his elbows on his knees and his chin in his hands, -meditating. It seemed to him that life was but a trouble, at best, and -he more than half envied Jimmy Hodges, so lately released; it must be -very peaceful, he thought, to lie and slumber and dream forever and -ever, with the wind whispering through the trees and caressing the -grass and the flowers over the grave, and nothing to bother and grieve -about, ever any more. If he only had a clean Sunday-school record he -could be willing to go, and be done with it all. Now as to this girl. -What had he done? Nothing. He had meant the best in the world, and been -treated like a dog--like a very dog. She would be sorry some day--maybe -when it was too late. Ah, if he could only die TEMPORARILY! - -But the elastic heart of youth cannot be compressed into one -constrained shape long at a time. Tom presently began to drift -insensibly back into the concerns of this life again. What if he turned -his back, now, and disappeared mysteriously? What if he went away--ever -so far away, into unknown countries beyond the seas--and never came -back any more! How would she feel then! The idea of being a clown -recurred to him now, only to fill him with disgust. For frivolity and -jokes and spotted tights were an offense, when they intruded themselves -upon a spirit that was exalted into the vague august realm of the -romantic. No, he would be a soldier, and return after long years, all -war-worn and illustrious. No--better still, he would join the Indians, -and hunt buffaloes and go on the warpath in the mountain ranges and the -trackless great plains of the Far West, and away in the future come -back a great chief, bristling with feathers, hideous with paint, and -prance into Sunday-school, some drowsy summer morning, with a -bloodcurdling war-whoop, and sear the eyeballs of all his companions -with unappeasable envy. But no, there was something gaudier even than -this. He would be a pirate! That was it! NOW his future lay plain -before him, and glowing with unimaginable splendor. How his name would -fill the world, and make people shudder! How gloriously he would go -plowing the dancing seas, in his long, low, black-hulled racer, the -Spirit of the Storm, with his grisly flag flying at the fore! And at -the zenith of his fame, how he would suddenly appear at the old village -and stalk into church, brown and weather-beaten, in his black velvet -doublet and trunks, his great jack-boots, his crimson sash, his belt -bristling with horse-pistols, his crime-rusted cutlass at his side, his -slouch hat with waving plumes, his black flag unfurled, with the skull -and crossbones on it, and hear with swelling ecstasy the whisperings, -"It's Tom Sawyer the Pirate!--the Black Avenger of the Spanish Main!" - -Yes, it was settled; his career was determined. He would run away from -home and enter upon it. He would start the very next morning. Therefore -he must now begin to get ready. He would collect his resources -together. He went to a rotten log near at hand and began to dig under -one end of it with his Barlow knife. He soon struck wood that sounded -hollow. He put his hand there and uttered this incantation impressively: - -"What hasn't come here, come! What's here, stay here!" - -Then he scraped away the dirt, and exposed a pine shingle. He took it -up and disclosed a shapely little treasure-house whose bottom and sides -were of shingles. In it lay a marble. Tom's astonishment was boundless! -He scratched his head with a perplexed air, and said: - -"Well, that beats anything!" - -Then he tossed the marble away pettishly, and stood cogitating. The -truth was, that a superstition of his had failed, here, which he and -all his comrades had always looked upon as infallible. If you buried a -marble with certain necessary incantations, and left it alone a -fortnight, and then opened the place with the incantation he had just -used, you would find that all the marbles you had ever lost had -gathered themselves together there, meantime, no matter how widely they -had been separated. But now, this thing had actually and unquestionably -failed. Tom's whole structure of faith was shaken to its foundations. -He had many a time heard of this thing succeeding but never of its -failing before. It did not occur to him that he had tried it several -times before, himself, but could never find the hiding-places -afterward. He puzzled over the matter some time, and finally decided -that some witch had interfered and broken the charm. He thought he -would satisfy himself on that point; so he searched around till he -found a small sandy spot with a little funnel-shaped depression in it. -He laid himself down and put his mouth close to this depression and -called-- - -"Doodle-bug, doodle-bug, tell me what I want to know! Doodle-bug, -doodle-bug, tell me what I want to know!" - -The sand began to work, and presently a small black bug appeared for a -second and then darted under again in a fright. - -"He dasn't tell! So it WAS a witch that done it. I just knowed it." - -He well knew the futility of trying to contend against witches, so he -gave up discouraged. But it occurred to him that he might as well have -the marble he had just thrown away, and therefore he went and made a -patient search for it. But he could not find it. Now he went back to -his treasure-house and carefully placed himself just as he had been -standing when he tossed the marble away; then he took another marble -from his pocket and tossed it in the same way, saying: - -"Brother, go find your brother!" - -He watched where it stopped, and went there and looked. But it must -have fallen short or gone too far; so he tried twice more. The last -repetition was successful. The two marbles lay within a foot of each -other. - -Just here the blast of a toy tin trumpet came faintly down the green -aisles of the forest. Tom flung off his jacket and trousers, turned a -suspender into a belt, raked away some brush behind the rotten log, -disclosing a rude bow and arrow, a lath sword and a tin trumpet, and in -a moment had seized these things and bounded away, barelegged, with -fluttering shirt. He presently halted under a great elm, blew an -answering blast, and then began to tiptoe and look warily out, this way -and that. He said cautiously--to an imaginary company: - -"Hold, my merry men! Keep hid till I blow." - -Now appeared Joe Harper, as airily clad and elaborately armed as Tom. -Tom called: - -"Hold! Who comes here into Sherwood Forest without my pass?" - -"Guy of Guisborne wants no man's pass. Who art thou that--that--" - -"Dares to hold such language," said Tom, prompting--for they talked -"by the book," from memory. - -"Who art thou that dares to hold such language?" - -"I, indeed! I am Robin Hood, as thy caitiff carcase soon shall know." - -"Then art thou indeed that famous outlaw? Right gladly will I dispute -with thee the passes of the merry wood. Have at thee!" - -They took their lath swords, dumped their other traps on the ground, -struck a fencing attitude, foot to foot, and began a grave, careful -combat, "two up and two down." Presently Tom said: - -"Now, if you've got the hang, go it lively!" - -So they "went it lively," panting and perspiring with the work. By and -by Tom shouted: - -"Fall! fall! Why don't you fall?" - -"I sha'n't! Why don't you fall yourself? You're getting the worst of -it." - -"Why, that ain't anything. I can't fall; that ain't the way it is in -the book. The book says, 'Then with one back-handed stroke he slew poor -Guy of Guisborne.' You're to turn around and let me hit you in the -back." - -There was no getting around the authorities, so Joe turned, received -the whack and fell. - -"Now," said Joe, getting up, "you got to let me kill YOU. That's fair." - -"Why, I can't do that, it ain't in the book." - -"Well, it's blamed mean--that's all." - -"Well, say, Joe, you can be Friar Tuck or Much the miller's son, and -lam me with a quarter-staff; or I'll be the Sheriff of Nottingham and -you be Robin Hood a little while and kill me." - -This was satisfactory, and so these adventures were carried out. Then -Tom became Robin Hood again, and was allowed by the treacherous nun to -bleed his strength away through his neglected wound. And at last Joe, -representing a whole tribe of weeping outlaws, dragged him sadly forth, -gave his bow into his feeble hands, and Tom said, "Where this arrow -falls, there bury poor Robin Hood under the greenwood tree." Then he -shot the arrow and fell back and would have died, but he lit on a -nettle and sprang up too gaily for a corpse. - -The boys dressed themselves, hid their accoutrements, and went off -grieving that there were no outlaws any more, and wondering what modern -civilization could claim to have done to compensate for their loss. -They said they would rather be outlaws a year in Sherwood Forest than -President of the United States forever. - - - -CHAPTER IX - -AT half-past nine, that night, Tom and Sid were sent to bed, as usual. -They said their prayers, and Sid was soon asleep. Tom lay awake and -waited, in restless impatience. When it seemed to him that it must be -nearly daylight, he heard the clock strike ten! This was despair. He -would have tossed and fidgeted, as his nerves demanded, but he was -afraid he might wake Sid. So he lay still, and stared up into the dark. -Everything was dismally still. By and by, out of the stillness, little, -scarcely perceptible noises began to emphasize themselves. The ticking -of the clock began to bring itself into notice. Old beams began to -crack mysteriously. The stairs creaked faintly. Evidently spirits were -abroad. A measured, muffled snore issued from Aunt Polly's chamber. And -now the tiresome chirping of a cricket that no human ingenuity could -locate, began. Next the ghastly ticking of a deathwatch in the wall at -the bed's head made Tom shudder--it meant that somebody's days were -numbered. Then the howl of a far-off dog rose on the night air, and was -answered by a fainter howl from a remoter distance. Tom was in an -agony. At last he was satisfied that time had ceased and eternity -begun; he began to doze, in spite of himself; the clock chimed eleven, -but he did not hear it. And then there came, mingling with his -half-formed dreams, a most melancholy caterwauling. The raising of a -neighboring window disturbed him. A cry of "Scat! you devil!" and the -crash of an empty bottle against the back of his aunt's woodshed -brought him wide awake, and a single minute later he was dressed and -out of the window and creeping along the roof of the "ell" on all -fours. He "meow'd" with caution once or twice, as he went; then jumped -to the roof of the woodshed and thence to the ground. Huckleberry Finn -was there, with his dead cat. The boys moved off and disappeared in the -gloom. At the end of half an hour they were wading through the tall -grass of the graveyard. - -It was a graveyard of the old-fashioned Western kind. It was on a -hill, about a mile and a half from the village. It had a crazy board -fence around it, which leaned inward in places, and outward the rest of -the time, but stood upright nowhere. Grass and weeds grew rank over the -whole cemetery. All the old graves were sunken in, there was not a -tombstone on the place; round-topped, worm-eaten boards staggered over -the graves, leaning for support and finding none. "Sacred to the memory -of" So-and-So had been painted on them once, but it could no longer -have been read, on the most of them, now, even if there had been light. - -A faint wind moaned through the trees, and Tom feared it might be the -spirits of the dead, complaining at being disturbed. The boys talked -little, and only under their breath, for the time and the place and the -pervading solemnity and silence oppressed their spirits. They found the -sharp new heap they were seeking, and ensconced themselves within the -protection of three great elms that grew in a bunch within a few feet -of the grave. - -Then they waited in silence for what seemed a long time. The hooting -of a distant owl was all the sound that troubled the dead stillness. -Tom's reflections grew oppressive. He must force some talk. So he said -in a whisper: - -"Hucky, do you believe the dead people like it for us to be here?" - -Huckleberry whispered: - -"I wisht I knowed. It's awful solemn like, AIN'T it?" - -"I bet it is." - -There was a considerable pause, while the boys canvassed this matter -inwardly. Then Tom whispered: - -"Say, Hucky--do you reckon Hoss Williams hears us talking?" - -"O' course he does. Least his sperrit does." - -Tom, after a pause: - -"I wish I'd said Mister Williams. But I never meant any harm. -Everybody calls him Hoss." - -"A body can't be too partic'lar how they talk 'bout these-yer dead -people, Tom." - -This was a damper, and conversation died again. - -Presently Tom seized his comrade's arm and said: - -"Sh!" - -"What is it, Tom?" And the two clung together with beating hearts. - -"Sh! There 'tis again! Didn't you hear it?" - -"I--" - -"There! Now you hear it." - -"Lord, Tom, they're coming! They're coming, sure. What'll we do?" - -"I dono. Think they'll see us?" - -"Oh, Tom, they can see in the dark, same as cats. I wisht I hadn't -come." - -"Oh, don't be afeard. I don't believe they'll bother us. We ain't -doing any harm. If we keep perfectly still, maybe they won't notice us -at all." - -"I'll try to, Tom, but, Lord, I'm all of a shiver." - -"Listen!" - -The boys bent their heads together and scarcely breathed. A muffled -sound of voices floated up from the far end of the graveyard. - -"Look! See there!" whispered Tom. "What is it?" - -"It's devil-fire. Oh, Tom, this is awful." - -Some vague figures approached through the gloom, swinging an -old-fashioned tin lantern that freckled the ground with innumerable -little spangles of light. Presently Huckleberry whispered with a -shudder: - -"It's the devils sure enough. Three of 'em! Lordy, Tom, we're goners! -Can you pray?" - -"I'll try, but don't you be afeard. They ain't going to hurt us. 'Now -I lay me down to sleep, I--'" - -"Sh!" - -"What is it, Huck?" - -"They're HUMANS! One of 'em is, anyway. One of 'em's old Muff Potter's -voice." - -"No--'tain't so, is it?" - -"I bet I know it. Don't you stir nor budge. He ain't sharp enough to -notice us. Drunk, the same as usual, likely--blamed old rip!" - -"All right, I'll keep still. Now they're stuck. Can't find it. Here -they come again. Now they're hot. Cold again. Hot again. Red hot! -They're p'inted right, this time. Say, Huck, I know another o' them -voices; it's Injun Joe." - -"That's so--that murderin' half-breed! I'd druther they was devils a -dern sight. What kin they be up to?" - -The whisper died wholly out, now, for the three men had reached the -grave and stood within a few feet of the boys' hiding-place. - -"Here it is," said the third voice; and the owner of it held the -lantern up and revealed the face of young Doctor Robinson. - -Potter and Injun Joe were carrying a handbarrow with a rope and a -couple of shovels on it. They cast down their load and began to open -the grave. The doctor put the lantern at the head of the grave and came -and sat down with his back against one of the elm trees. He was so -close the boys could have touched him. - -"Hurry, men!" he said, in a low voice; "the moon might come out at any -moment." - -They growled a response and went on digging. For some time there was -no noise but the grating sound of the spades discharging their freight -of mould and gravel. It was very monotonous. Finally a spade struck -upon the coffin with a dull woody accent, and within another minute or -two the men had hoisted it out on the ground. They pried off the lid -with their shovels, got out the body and dumped it rudely on the -ground. The moon drifted from behind the clouds and exposed the pallid -face. The barrow was got ready and the corpse placed on it, covered -with a blanket, and bound to its place with the rope. Potter took out a -large spring-knife and cut off the dangling end of the rope and then -said: - -"Now the cussed thing's ready, Sawbones, and you'll just out with -another five, or here she stays." - -"That's the talk!" said Injun Joe. - -"Look here, what does this mean?" said the doctor. "You required your -pay in advance, and I've paid you." - -"Yes, and you done more than that," said Injun Joe, approaching the -doctor, who was now standing. "Five years ago you drove me away from -your father's kitchen one night, when I come to ask for something to -eat, and you said I warn't there for any good; and when I swore I'd get -even with you if it took a hundred years, your father had me jailed for -a vagrant. Did you think I'd forget? The Injun blood ain't in me for -nothing. And now I've GOT you, and you got to SETTLE, you know!" - -He was threatening the doctor, with his fist in his face, by this -time. The doctor struck out suddenly and stretched the ruffian on the -ground. Potter dropped his knife, and exclaimed: - -"Here, now, don't you hit my pard!" and the next moment he had -grappled with the doctor and the two were struggling with might and -main, trampling the grass and tearing the ground with their heels. -Injun Joe sprang to his feet, his eyes flaming with passion, snatched -up Potter's knife, and went creeping, catlike and stooping, round and -round about the combatants, seeking an opportunity. All at once the -doctor flung himself free, seized the heavy headboard of Williams' -grave and felled Potter to the earth with it--and in the same instant -the half-breed saw his chance and drove the knife to the hilt in the -young man's breast. He reeled and fell partly upon Potter, flooding him -with his blood, and in the same moment the clouds blotted out the -dreadful spectacle and the two frightened boys went speeding away in -the dark. - -Presently, when the moon emerged again, Injun Joe was standing over -the two forms, contemplating them. The doctor murmured inarticulately, -gave a long gasp or two and was still. The half-breed muttered: - -"THAT score is settled--damn you." - -Then he robbed the body. After which he put the fatal knife in -Potter's open right hand, and sat down on the dismantled coffin. Three ---four--five minutes passed, and then Potter began to stir and moan. His -hand closed upon the knife; he raised it, glanced at it, and let it -fall, with a shudder. Then he sat up, pushing the body from him, and -gazed at it, and then around him, confusedly. His eyes met Joe's. - -"Lord, how is this, Joe?" he said. - -"It's a dirty business," said Joe, without moving. - -"What did you do it for?" - -"I! I never done it!" - -"Look here! That kind of talk won't wash." - -Potter trembled and grew white. - -"I thought I'd got sober. I'd no business to drink to-night. But it's -in my head yet--worse'n when we started here. I'm all in a muddle; -can't recollect anything of it, hardly. Tell me, Joe--HONEST, now, old -feller--did I do it? Joe, I never meant to--'pon my soul and honor, I -never meant to, Joe. Tell me how it was, Joe. Oh, it's awful--and him -so young and promising." - -"Why, you two was scuffling, and he fetched you one with the headboard -and you fell flat; and then up you come, all reeling and staggering -like, and snatched the knife and jammed it into him, just as he fetched -you another awful clip--and here you've laid, as dead as a wedge til -now." - -"Oh, I didn't know what I was a-doing. I wish I may die this minute if -I did. It was all on account of the whiskey and the excitement, I -reckon. I never used a weepon in my life before, Joe. I've fought, but -never with weepons. They'll all say that. Joe, don't tell! Say you -won't tell, Joe--that's a good feller. I always liked you, Joe, and -stood up for you, too. Don't you remember? You WON'T tell, WILL you, -Joe?" And the poor creature dropped on his knees before the stolid -murderer, and clasped his appealing hands. - -"No, you've always been fair and square with me, Muff Potter, and I -won't go back on you. There, now, that's as fair as a man can say." - -"Oh, Joe, you're an angel. I'll bless you for this the longest day I -live." And Potter began to cry. - -"Come, now, that's enough of that. This ain't any time for blubbering. -You be off yonder way and I'll go this. Move, now, and don't leave any -tracks behind you." - -Potter started on a trot that quickly increased to a run. The -half-breed stood looking after him. He muttered: - -"If he's as much stunned with the lick and fuddled with the rum as he -had the look of being, he won't think of the knife till he's gone so -far he'll be afraid to come back after it to such a place by himself ---chicken-heart!" - -Two or three minutes later the murdered man, the blanketed corpse, the -lidless coffin, and the open grave were under no inspection but the -moon's. The stillness was complete again, too. - - - -CHAPTER X - -THE two boys flew on and on, toward the village, speechless with -horror. They glanced backward over their shoulders from time to time, -apprehensively, as if they feared they might be followed. Every stump -that started up in their path seemed a man and an enemy, and made them -catch their breath; and as they sped by some outlying cottages that lay -near the village, the barking of the aroused watch-dogs seemed to give -wings to their feet. - -"If we can only get to the old tannery before we break down!" -whispered Tom, in short catches between breaths. "I can't stand it much -longer." - -Huckleberry's hard pantings were his only reply, and the boys fixed -their eyes on the goal of their hopes and bent to their work to win it. -They gained steadily on it, and at last, breast to breast, they burst -through the open door and fell grateful and exhausted in the sheltering -shadows beyond. By and by their pulses slowed down, and Tom whispered: - -"Huckleberry, what do you reckon'll come of this?" - -"If Doctor Robinson dies, I reckon hanging'll come of it." - -"Do you though?" - -"Why, I KNOW it, Tom." - -Tom thought a while, then he said: - -"Who'll tell? We?" - -"What are you talking about? S'pose something happened and Injun Joe -DIDN'T hang? Why, he'd kill us some time or other, just as dead sure as -we're a laying here." - -"That's just what I was thinking to myself, Huck." - -"If anybody tells, let Muff Potter do it, if he's fool enough. He's -generally drunk enough." - -Tom said nothing--went on thinking. Presently he whispered: - -"Huck, Muff Potter don't know it. How can he tell?" - -"What's the reason he don't know it?" - -"Because he'd just got that whack when Injun Joe done it. D'you reckon -he could see anything? D'you reckon he knowed anything?" - -"By hokey, that's so, Tom!" - -"And besides, look-a-here--maybe that whack done for HIM!" - -"No, 'taint likely, Tom. He had liquor in him; I could see that; and -besides, he always has. Well, when pap's full, you might take and belt -him over the head with a church and you couldn't phase him. He says so, -his own self. So it's the same with Muff Potter, of course. But if a -man was dead sober, I reckon maybe that whack might fetch him; I dono." - -After another reflective silence, Tom said: - -"Hucky, you sure you can keep mum?" - -"Tom, we GOT to keep mum. You know that. That Injun devil wouldn't -make any more of drownding us than a couple of cats, if we was to -squeak 'bout this and they didn't hang him. Now, look-a-here, Tom, less -take and swear to one another--that's what we got to do--swear to keep -mum." - -"I'm agreed. It's the best thing. Would you just hold hands and swear -that we--" - -"Oh no, that wouldn't do for this. That's good enough for little -rubbishy common things--specially with gals, cuz THEY go back on you -anyway, and blab if they get in a huff--but there orter be writing -'bout a big thing like this. And blood." - -Tom's whole being applauded this idea. It was deep, and dark, and -awful; the hour, the circumstances, the surroundings, were in keeping -with it. He picked up a clean pine shingle that lay in the moonlight, -took a little fragment of "red keel" out of his pocket, got the moon on -his work, and painfully scrawled these lines, emphasizing each slow -down-stroke by clamping his tongue between his teeth, and letting up -the pressure on the up-strokes. [See next page.] - - "Huck Finn and - Tom Sawyer swears - they will keep mum - about This and They - wish They may Drop - down dead in Their - Tracks if They ever - Tell and Rot." - -Huckleberry was filled with admiration of Tom's facility in writing, -and the sublimity of his language. He at once took a pin from his lapel -and was going to prick his flesh, but Tom said: - -"Hold on! Don't do that. A pin's brass. It might have verdigrease on -it." - -"What's verdigrease?" - -"It's p'ison. That's what it is. You just swaller some of it once ---you'll see." - -So Tom unwound the thread from one of his needles, and each boy -pricked the ball of his thumb and squeezed out a drop of blood. In -time, after many squeezes, Tom managed to sign his initials, using the -ball of his little finger for a pen. Then he showed Huckleberry how to -make an H and an F, and the oath was complete. They buried the shingle -close to the wall, with some dismal ceremonies and incantations, and -the fetters that bound their tongues were considered to be locked and -the key thrown away. - -A figure crept stealthily through a break in the other end of the -ruined building, now, but they did not notice it. - -"Tom," whispered Huckleberry, "does this keep us from EVER telling ---ALWAYS?" - -"Of course it does. It don't make any difference WHAT happens, we got -to keep mum. We'd drop down dead--don't YOU know that?" - -"Yes, I reckon that's so." - -They continued to whisper for some little time. Presently a dog set up -a long, lugubrious howl just outside--within ten feet of them. The boys -clasped each other suddenly, in an agony of fright. - -"Which of us does he mean?" gasped Huckleberry. - -"I dono--peep through the crack. Quick!" - -"No, YOU, Tom!" - -"I can't--I can't DO it, Huck!" - -"Please, Tom. There 'tis again!" - -"Oh, lordy, I'm thankful!" whispered Tom. "I know his voice. It's Bull -Harbison." * - -[* If Mr. Harbison owned a slave named Bull, Tom would have spoken of -him as "Harbison's Bull," but a son or a dog of that name was "Bull -Harbison."] - -"Oh, that's good--I tell you, Tom, I was most scared to death; I'd a -bet anything it was a STRAY dog." - -The dog howled again. The boys' hearts sank once more. - -"Oh, my! that ain't no Bull Harbison!" whispered Huckleberry. "DO, Tom!" - -Tom, quaking with fear, yielded, and put his eye to the crack. His -whisper was hardly audible when he said: - -"Oh, Huck, IT S A STRAY DOG!" - -"Quick, Tom, quick! Who does he mean?" - -"Huck, he must mean us both--we're right together." - -"Oh, Tom, I reckon we're goners. I reckon there ain't no mistake 'bout -where I'LL go to. I been so wicked." - -"Dad fetch it! This comes of playing hookey and doing everything a -feller's told NOT to do. I might a been good, like Sid, if I'd a tried ---but no, I wouldn't, of course. But if ever I get off this time, I lay -I'll just WALLER in Sunday-schools!" And Tom began to snuffle a little. - -"YOU bad!" and Huckleberry began to snuffle too. "Consound it, Tom -Sawyer, you're just old pie, 'longside o' what I am. Oh, LORDY, lordy, -lordy, I wisht I only had half your chance." - -Tom choked off and whispered: - -"Look, Hucky, look! He's got his BACK to us!" - -Hucky looked, with joy in his heart. - -"Well, he has, by jingoes! Did he before?" - -"Yes, he did. But I, like a fool, never thought. Oh, this is bully, -you know. NOW who can he mean?" - -The howling stopped. Tom pricked up his ears. - -"Sh! What's that?" he whispered. - -"Sounds like--like hogs grunting. No--it's somebody snoring, Tom." - -"That IS it! Where 'bouts is it, Huck?" - -"I bleeve it's down at 'tother end. Sounds so, anyway. Pap used to -sleep there, sometimes, 'long with the hogs, but laws bless you, he -just lifts things when HE snores. Besides, I reckon he ain't ever -coming back to this town any more." - -The spirit of adventure rose in the boys' souls once more. - -"Hucky, do you das't to go if I lead?" - -"I don't like to, much. Tom, s'pose it's Injun Joe!" - -Tom quailed. But presently the temptation rose up strong again and the -boys agreed to try, with the understanding that they would take to -their heels if the snoring stopped. So they went tiptoeing stealthily -down, the one behind the other. When they had got to within five steps -of the snorer, Tom stepped on a stick, and it broke with a sharp snap. -The man moaned, writhed a little, and his face came into the moonlight. -It was Muff Potter. The boys' hearts had stood still, and their hopes -too, when the man moved, but their fears passed away now. They tiptoed -out, through the broken weather-boarding, and stopped at a little -distance to exchange a parting word. That long, lugubrious howl rose on -the night air again! They turned and saw the strange dog standing -within a few feet of where Potter was lying, and FACING Potter, with -his nose pointing heavenward. - -"Oh, geeminy, it's HIM!" exclaimed both boys, in a breath. - -"Say, Tom--they say a stray dog come howling around Johnny Miller's -house, 'bout midnight, as much as two weeks ago; and a whippoorwill -come in and lit on the banisters and sung, the very same evening; and -there ain't anybody dead there yet." - -"Well, I know that. And suppose there ain't. Didn't Gracie Miller fall -in the kitchen fire and burn herself terrible the very next Saturday?" - -"Yes, but she ain't DEAD. And what's more, she's getting better, too." - -"All right, you wait and see. She's a goner, just as dead sure as Muff -Potter's a goner. That's what the niggers say, and they know all about -these kind of things, Huck." - -Then they separated, cogitating. When Tom crept in at his bedroom -window the night was almost spent. He undressed with excessive caution, -and fell asleep congratulating himself that nobody knew of his -escapade. He was not aware that the gently-snoring Sid was awake, and -had been so for an hour. - -When Tom awoke, Sid was dressed and gone. There was a late look in the -light, a late sense in the atmosphere. He was startled. Why had he not -been called--persecuted till he was up, as usual? The thought filled -him with bodings. Within five minutes he was dressed and down-stairs, -feeling sore and drowsy. The family were still at table, but they had -finished breakfast. There was no voice of rebuke; but there were -averted eyes; there was a silence and an air of solemnity that struck a -chill to the culprit's heart. He sat down and tried to seem gay, but it -was up-hill work; it roused no smile, no response, and he lapsed into -silence and let his heart sink down to the depths. - -After breakfast his aunt took him aside, and Tom almost brightened in -the hope that he was going to be flogged; but it was not so. His aunt -wept over him and asked him how he could go and break her old heart so; -and finally told him to go on, and ruin himself and bring her gray -hairs with sorrow to the grave, for it was no use for her to try any -more. This was worse than a thousand whippings, and Tom's heart was -sorer now than his body. He cried, he pleaded for forgiveness, promised -to reform over and over again, and then received his dismissal, feeling -that he had won but an imperfect forgiveness and established but a -feeble confidence. - -He left the presence too miserable to even feel revengeful toward Sid; -and so the latter's prompt retreat through the back gate was -unnecessary. He moped to school gloomy and sad, and took his flogging, -along with Joe Harper, for playing hookey the day before, with the air -of one whose heart was busy with heavier woes and wholly dead to -trifles. Then he betook himself to his seat, rested his elbows on his -desk and his jaws in his hands, and stared at the wall with the stony -stare of suffering that has reached the limit and can no further go. -His elbow was pressing against some hard substance. After a long time -he slowly and sadly changed his position, and took up this object with -a sigh. It was in a paper. He unrolled it. A long, lingering, colossal -sigh followed, and his heart broke. It was his brass andiron knob! - -This final feather broke the camel's back. - - - -CHAPTER XI - -CLOSE upon the hour of noon the whole village was suddenly electrified -with the ghastly news. No need of the as yet undreamed-of telegraph; -the tale flew from man to man, from group to group, from house to -house, with little less than telegraphic speed. Of course the -schoolmaster gave holiday for that afternoon; the town would have -thought strangely of him if he had not. - -A gory knife had been found close to the murdered man, and it had been -recognized by somebody as belonging to Muff Potter--so the story ran. -And it was said that a belated citizen had come upon Potter washing -himself in the "branch" about one or two o'clock in the morning, and -that Potter had at once sneaked off--suspicious circumstances, -especially the washing which was not a habit with Potter. It was also -said that the town had been ransacked for this "murderer" (the public -are not slow in the matter of sifting evidence and arriving at a -verdict), but that he could not be found. Horsemen had departed down -all the roads in every direction, and the Sheriff "was confident" that -he would be captured before night. - -All the town was drifting toward the graveyard. Tom's heartbreak -vanished and he joined the procession, not because he would not a -thousand times rather go anywhere else, but because an awful, -unaccountable fascination drew him on. Arrived at the dreadful place, -he wormed his small body through the crowd and saw the dismal -spectacle. It seemed to him an age since he was there before. Somebody -pinched his arm. He turned, and his eyes met Huckleberry's. Then both -looked elsewhere at once, and wondered if anybody had noticed anything -in their mutual glance. But everybody was talking, and intent upon the -grisly spectacle before them. - -"Poor fellow!" "Poor young fellow!" "This ought to be a lesson to -grave robbers!" "Muff Potter'll hang for this if they catch him!" This -was the drift of remark; and the minister said, "It was a judgment; His -hand is here." - -Now Tom shivered from head to heel; for his eye fell upon the stolid -face of Injun Joe. At this moment the crowd began to sway and struggle, -and voices shouted, "It's him! it's him! he's coming himself!" - -"Who? Who?" from twenty voices. - -"Muff Potter!" - -"Hallo, he's stopped!--Look out, he's turning! Don't let him get away!" - -People in the branches of the trees over Tom's head said he wasn't -trying to get away--he only looked doubtful and perplexed. - -"Infernal impudence!" said a bystander; "wanted to come and take a -quiet look at his work, I reckon--didn't expect any company." - -The crowd fell apart, now, and the Sheriff came through, -ostentatiously leading Potter by the arm. The poor fellow's face was -haggard, and his eyes showed the fear that was upon him. When he stood -before the murdered man, he shook as with a palsy, and he put his face -in his hands and burst into tears. - -"I didn't do it, friends," he sobbed; "'pon my word and honor I never -done it." - -"Who's accused you?" shouted a voice. - -This shot seemed to carry home. Potter lifted his face and looked -around him with a pathetic hopelessness in his eyes. He saw Injun Joe, -and exclaimed: - -"Oh, Injun Joe, you promised me you'd never--" - -"Is that your knife?" and it was thrust before him by the Sheriff. - -Potter would have fallen if they had not caught him and eased him to -the ground. Then he said: - -"Something told me 't if I didn't come back and get--" He shuddered; -then waved his nerveless hand with a vanquished gesture and said, "Tell -'em, Joe, tell 'em--it ain't any use any more." - -Then Huckleberry and Tom stood dumb and staring, and heard the -stony-hearted liar reel off his serene statement, they expecting every -moment that the clear sky would deliver God's lightnings upon his head, -and wondering to see how long the stroke was delayed. And when he had -finished and still stood alive and whole, their wavering impulse to -break their oath and save the poor betrayed prisoner's life faded and -vanished away, for plainly this miscreant had sold himself to Satan and -it would be fatal to meddle with the property of such a power as that. - -"Why didn't you leave? What did you want to come here for?" somebody -said. - -"I couldn't help it--I couldn't help it," Potter moaned. "I wanted to -run away, but I couldn't seem to come anywhere but here." And he fell -to sobbing again. - -Injun Joe repeated his statement, just as calmly, a few minutes -afterward on the inquest, under oath; and the boys, seeing that the -lightnings were still withheld, were confirmed in their belief that Joe -had sold himself to the devil. He was now become, to them, the most -balefully interesting object they had ever looked upon, and they could -not take their fascinated eyes from his face. - -They inwardly resolved to watch him nights, when opportunity should -offer, in the hope of getting a glimpse of his dread master. - -Injun Joe helped to raise the body of the murdered man and put it in a -wagon for removal; and it was whispered through the shuddering crowd -that the wound bled a little! The boys thought that this happy -circumstance would turn suspicion in the right direction; but they were -disappointed, for more than one villager remarked: - -"It was within three feet of Muff Potter when it done it." - -Tom's fearful secret and gnawing conscience disturbed his sleep for as -much as a week after this; and at breakfast one morning Sid said: - -"Tom, you pitch around and talk in your sleep so much that you keep me -awake half the time." - -Tom blanched and dropped his eyes. - -"It's a bad sign," said Aunt Polly, gravely. "What you got on your -mind, Tom?" - -"Nothing. Nothing 't I know of." But the boy's hand shook so that he -spilled his coffee. - -"And you do talk such stuff," Sid said. "Last night you said, 'It's -blood, it's blood, that's what it is!' You said that over and over. And -you said, 'Don't torment me so--I'll tell!' Tell WHAT? What is it -you'll tell?" - -Everything was swimming before Tom. There is no telling what might -have happened, now, but luckily the concern passed out of Aunt Polly's -face and she came to Tom's relief without knowing it. She said: - -"Sho! It's that dreadful murder. I dream about it most every night -myself. Sometimes I dream it's me that done it." - -Mary said she had been affected much the same way. Sid seemed -satisfied. Tom got out of the presence as quick as he plausibly could, -and after that he complained of toothache for a week, and tied up his -jaws every night. He never knew that Sid lay nightly watching, and -frequently slipped the bandage free and then leaned on his elbow -listening a good while at a time, and afterward slipped the bandage -back to its place again. Tom's distress of mind wore off gradually and -the toothache grew irksome and was discarded. If Sid really managed to -make anything out of Tom's disjointed mutterings, he kept it to himself. - -It seemed to Tom that his schoolmates never would get done holding -inquests on dead cats, and thus keeping his trouble present to his -mind. Sid noticed that Tom never was coroner at one of these inquiries, -though it had been his habit to take the lead in all new enterprises; -he noticed, too, that Tom never acted as a witness--and that was -strange; and Sid did not overlook the fact that Tom even showed a -marked aversion to these inquests, and always avoided them when he -could. Sid marvelled, but said nothing. However, even inquests went out -of vogue at last, and ceased to torture Tom's conscience. - -Every day or two, during this time of sorrow, Tom watched his -opportunity and went to the little grated jail-window and smuggled such -small comforts through to the "murderer" as he could get hold of. The -jail was a trifling little brick den that stood in a marsh at the edge -of the village, and no guards were afforded for it; indeed, it was -seldom occupied. These offerings greatly helped to ease Tom's -conscience. - -The villagers had a strong desire to tar-and-feather Injun Joe and -ride him on a rail, for body-snatching, but so formidable was his -character that nobody could be found who was willing to take the lead -in the matter, so it was dropped. He had been careful to begin both of -his inquest-statements with the fight, without confessing the -grave-robbery that preceded it; therefore it was deemed wisest not -to try the case in the courts at present. - - - -CHAPTER XII - -ONE of the reasons why Tom's mind had drifted away from its secret -troubles was, that it had found a new and weighty matter to interest -itself about. Becky Thatcher had stopped coming to school. Tom had -struggled with his pride a few days, and tried to "whistle her down the -wind," but failed. He began to find himself hanging around her father's -house, nights, and feeling very miserable. She was ill. What if she -should die! There was distraction in the thought. He no longer took an -interest in war, nor even in piracy. The charm of life was gone; there -was nothing but dreariness left. He put his hoop away, and his bat; -there was no joy in them any more. His aunt was concerned. She began to -try all manner of remedies on him. She was one of those people who are -infatuated with patent medicines and all new-fangled methods of -producing health or mending it. She was an inveterate experimenter in -these things. When something fresh in this line came out she was in a -fever, right away, to try it; not on herself, for she was never ailing, -but on anybody else that came handy. She was a subscriber for all the -"Health" periodicals and phrenological frauds; and the solemn ignorance -they were inflated with was breath to her nostrils. All the "rot" they -contained about ventilation, and how to go to bed, and how to get up, -and what to eat, and what to drink, and how much exercise to take, and -what frame of mind to keep one's self in, and what sort of clothing to -wear, was all gospel to her, and she never observed that her -health-journals of the current month customarily upset everything they -had recommended the month before. She was as simple-hearted and honest -as the day was long, and so she was an easy victim. She gathered -together her quack periodicals and her quack medicines, and thus armed -with death, went about on her pale horse, metaphorically speaking, with -"hell following after." But she never suspected that she was not an -angel of healing and the balm of Gilead in disguise, to the suffering -neighbors. - -The water treatment was new, now, and Tom's low condition was a -windfall to her. She had him out at daylight every morning, stood him -up in the woodshed and drowned him with a deluge of cold water; then -she scrubbed him down with a towel like a file, and so brought him to; -then she rolled him up in a wet sheet and put him away under blankets -till she sweated his soul clean and "the yellow stains of it came -through his pores"--as Tom said. - -Yet notwithstanding all this, the boy grew more and more melancholy -and pale and dejected. She added hot baths, sitz baths, shower baths, -and plunges. The boy remained as dismal as a hearse. She began to -assist the water with a slim oatmeal diet and blister-plasters. She -calculated his capacity as she would a jug's, and filled him up every -day with quack cure-alls. - -Tom had become indifferent to persecution by this time. This phase -filled the old lady's heart with consternation. This indifference must -be broken up at any cost. Now she heard of Pain-killer for the first -time. She ordered a lot at once. She tasted it and was filled with -gratitude. It was simply fire in a liquid form. She dropped the water -treatment and everything else, and pinned her faith to Pain-killer. She -gave Tom a teaspoonful and watched with the deepest anxiety for the -result. Her troubles were instantly at rest, her soul at peace again; -for the "indifference" was broken up. The boy could not have shown a -wilder, heartier interest, if she had built a fire under him. - -Tom felt that it was time to wake up; this sort of life might be -romantic enough, in his blighted condition, but it was getting to have -too little sentiment and too much distracting variety about it. So he -thought over various plans for relief, and finally hit pon that of -professing to be fond of Pain-killer. He asked for it so often that he -became a nuisance, and his aunt ended by telling him to help himself -and quit bothering her. If it had been Sid, she would have had no -misgivings to alloy her delight; but since it was Tom, she watched the -bottle clandestinely. She found that the medicine did really diminish, -but it did not occur to her that the boy was mending the health of a -crack in the sitting-room floor with it. - -One day Tom was in the act of dosing the crack when his aunt's yellow -cat came along, purring, eying the teaspoon avariciously, and begging -for a taste. Tom said: - -"Don't ask for it unless you want it, Peter." - -But Peter signified that he did want it. - -"You better make sure." - -Peter was sure. - -"Now you've asked for it, and I'll give it to you, because there ain't -anything mean about me; but if you find you don't like it, you mustn't -blame anybody but your own self." - -Peter was agreeable. So Tom pried his mouth open and poured down the -Pain-killer. Peter sprang a couple of yards in the air, and then -delivered a war-whoop and set off round and round the room, banging -against furniture, upsetting flower-pots, and making general havoc. -Next he rose on his hind feet and pranced around, in a frenzy of -enjoyment, with his head over his shoulder and his voice proclaiming -his unappeasable happiness. Then he went tearing around the house again -spreading chaos and destruction in his path. Aunt Polly entered in time -to see him throw a few double summersets, deliver a final mighty -hurrah, and sail through the open window, carrying the rest of the -flower-pots with him. The old lady stood petrified with astonishment, -peering over her glasses; Tom lay on the floor expiring with laughter. - -"Tom, what on earth ails that cat?" - -"I don't know, aunt," gasped the boy. - -"Why, I never see anything like it. What did make him act so?" - -"Deed I don't know, Aunt Polly; cats always act so when they're having -a good time." - -"They do, do they?" There was something in the tone that made Tom -apprehensive. - -"Yes'm. That is, I believe they do." - -"You DO?" - -"Yes'm." - -The old lady was bending down, Tom watching, with interest emphasized -by anxiety. Too late he divined her "drift." The handle of the telltale -teaspoon was visible under the bed-valance. Aunt Polly took it, held it -up. Tom winced, and dropped his eyes. Aunt Polly raised him by the -usual handle--his ear--and cracked his head soundly with her thimble. - -"Now, sir, what did you want to treat that poor dumb beast so, for?" - -"I done it out of pity for him--because he hadn't any aunt." - -"Hadn't any aunt!--you numskull. What has that got to do with it?" - -"Heaps. Because if he'd had one she'd a burnt him out herself! She'd a -roasted his bowels out of him 'thout any more feeling than if he was a -human!" - -Aunt Polly felt a sudden pang of remorse. This was putting the thing -in a new light; what was cruelty to a cat MIGHT be cruelty to a boy, -too. She began to soften; she felt sorry. Her eyes watered a little, -and she put her hand on Tom's head and said gently: - -"I was meaning for the best, Tom. And, Tom, it DID do you good." - -Tom looked up in her face with just a perceptible twinkle peeping -through his gravity. - -"I know you was meaning for the best, aunty, and so was I with Peter. -It done HIM good, too. I never see him get around so since--" - -"Oh, go 'long with you, Tom, before you aggravate me again. And you -try and see if you can't be a good boy, for once, and you needn't take -any more medicine." - -Tom reached school ahead of time. It was noticed that this strange -thing had been occurring every day latterly. And now, as usual of late, -he hung about the gate of the schoolyard instead of playing with his -comrades. He was sick, he said, and he looked it. He tried to seem to -be looking everywhere but whither he really was looking--down the road. -Presently Jeff Thatcher hove in sight, and Tom's face lighted; he gazed -a moment, and then turned sorrowfully away. When Jeff arrived, Tom -accosted him; and "led up" warily to opportunities for remark about -Becky, but the giddy lad never could see the bait. Tom watched and -watched, hoping whenever a frisking frock came in sight, and hating the -owner of it as soon as he saw she was not the right one. At last frocks -ceased to appear, and he dropped hopelessly into the dumps; he entered -the empty schoolhouse and sat down to suffer. Then one more frock -passed in at the gate, and Tom's heart gave a great bound. The next -instant he was out, and "going on" like an Indian; yelling, laughing, -chasing boys, jumping over the fence at risk of life and limb, throwing -handsprings, standing on his head--doing all the heroic things he could -conceive of, and keeping a furtive eye out, all the while, to see if -Becky Thatcher was noticing. But she seemed to be unconscious of it -all; she never looked. Could it be possible that she was not aware that -he was there? He carried his exploits to her immediate vicinity; came -war-whooping around, snatched a boy's cap, hurled it to the roof of the -schoolhouse, broke through a group of boys, tumbling them in every -direction, and fell sprawling, himself, under Becky's nose, almost -upsetting her--and she turned, with her nose in the air, and he heard -her say: "Mf! some people think they're mighty smart--always showing -off!" - -Tom's cheeks burned. He gathered himself up and sneaked off, crushed -and crestfallen. - - - -CHAPTER XIII - -TOM'S mind was made up now. He was gloomy and desperate. He was a -forsaken, friendless boy, he said; nobody loved him; when they found -out what they had driven him to, perhaps they would be sorry; he had -tried to do right and get along, but they would not let him; since -nothing would do them but to be rid of him, let it be so; and let them -blame HIM for the consequences--why shouldn't they? What right had the -friendless to complain? Yes, they had forced him to it at last: he -would lead a life of crime. There was no choice. - -By this time he was far down Meadow Lane, and the bell for school to -"take up" tinkled faintly upon his ear. He sobbed, now, to think he -should never, never hear that old familiar sound any more--it was very -hard, but it was forced on him; since he was driven out into the cold -world, he must submit--but he forgave them. Then the sobs came thick -and fast. - -Just at this point he met his soul's sworn comrade, Joe Harper ---hard-eyed, and with evidently a great and dismal purpose in his heart. -Plainly here were "two souls with but a single thought." Tom, wiping -his eyes with his sleeve, began to blubber out something about a -resolution to escape from hard usage and lack of sympathy at home by -roaming abroad into the great world never to return; and ended by -hoping that Joe would not forget him. - -But it transpired that this was a request which Joe had just been -going to make of Tom, and had come to hunt him up for that purpose. His -mother had whipped him for drinking some cream which he had never -tasted and knew nothing about; it was plain that she was tired of him -and wished him to go; if she felt that way, there was nothing for him -to do but succumb; he hoped she would be happy, and never regret having -driven her poor boy out into the unfeeling world to suffer and die. - -As the two boys walked sorrowing along, they made a new compact to -stand by each other and be brothers and never separate till death -relieved them of their troubles. Then they began to lay their plans. -Joe was for being a hermit, and living on crusts in a remote cave, and -dying, some time, of cold and want and grief; but after listening to -Tom, he conceded that there were some conspicuous advantages about a -life of crime, and so he consented to be a pirate. - -Three miles below St. Petersburg, at a point where the Mississippi -River was a trifle over a mile wide, there was a long, narrow, wooded -island, with a shallow bar at the head of it, and this offered well as -a rendezvous. It was not inhabited; it lay far over toward the further -shore, abreast a dense and almost wholly unpeopled forest. So Jackson's -Island was chosen. Who were to be the subjects of their piracies was a -matter that did not occur to them. Then they hunted up Huckleberry -Finn, and he joined them promptly, for all careers were one to him; he -was indifferent. They presently separated to meet at a lonely spot on -the river-bank two miles above the village at the favorite hour--which -was midnight. There was a small log raft there which they meant to -capture. Each would bring hooks and lines, and such provision as he -could steal in the most dark and mysterious way--as became outlaws. And -before the afternoon was done, they had all managed to enjoy the sweet -glory of spreading the fact that pretty soon the town would "hear -something." All who got this vague hint were cautioned to "be mum and -wait." - -About midnight Tom arrived with a boiled ham and a few trifles, -and stopped in a dense undergrowth on a small bluff overlooking the -meeting-place. It was starlight, and very still. The mighty river lay -like an ocean at rest. Tom listened a moment, but no sound disturbed the -quiet. Then he gave a low, distinct whistle. It was answered from under -the bluff. Tom whistled twice more; these signals were answered in the -same way. Then a guarded voice said: - -"Who goes there?" - -"Tom Sawyer, the Black Avenger of the Spanish Main. Name your names." - -"Huck Finn the Red-Handed, and Joe Harper the Terror of the Seas." Tom -had furnished these titles, from his favorite literature. - -"'Tis well. Give the countersign." - -Two hoarse whispers delivered the same awful word simultaneously to -the brooding night: - -"BLOOD!" - -Then Tom tumbled his ham over the bluff and let himself down after it, -tearing both skin and clothes to some extent in the effort. There was -an easy, comfortable path along the shore under the bluff, but it -lacked the advantages of difficulty and danger so valued by a pirate. - -The Terror of the Seas had brought a side of bacon, and had about worn -himself out with getting it there. Finn the Red-Handed had stolen a -skillet and a quantity of half-cured leaf tobacco, and had also brought -a few corn-cobs to make pipes with. But none of the pirates smoked or -"chewed" but himself. The Black Avenger of the Spanish Main said it -would never do to start without some fire. That was a wise thought; -matches were hardly known there in that day. They saw a fire -smouldering upon a great raft a hundred yards above, and they went -stealthily thither and helped themselves to a chunk. They made an -imposing adventure of it, saying, "Hist!" every now and then, and -suddenly halting with finger on lip; moving with hands on imaginary -dagger-hilts; and giving orders in dismal whispers that if "the foe" -stirred, to "let him have it to the hilt," because "dead men tell no -tales." They knew well enough that the raftsmen were all down at the -village laying in stores or having a spree, but still that was no -excuse for their conducting this thing in an unpiratical way. - -They shoved off, presently, Tom in command, Huck at the after oar and -Joe at the forward. Tom stood amidships, gloomy-browed, and with folded -arms, and gave his orders in a low, stern whisper: - -"Luff, and bring her to the wind!" - -"Aye-aye, sir!" - -"Steady, steady-y-y-y!" - -"Steady it is, sir!" - -"Let her go off a point!" - -"Point it is, sir!" - -As the boys steadily and monotonously drove the raft toward mid-stream -it was no doubt understood that these orders were given only for -"style," and were not intended to mean anything in particular. - -"What sail's she carrying?" - -"Courses, tops'ls, and flying-jib, sir." - -"Send the r'yals up! Lay out aloft, there, half a dozen of ye ---foretopmaststuns'l! Lively, now!" - -"Aye-aye, sir!" - -"Shake out that maintogalans'l! Sheets and braces! NOW my hearties!" - -"Aye-aye, sir!" - -"Hellum-a-lee--hard a port! Stand by to meet her when she comes! Port, -port! NOW, men! With a will! Stead-y-y-y!" - -"Steady it is, sir!" - -The raft drew beyond the middle of the river; the boys pointed her -head right, and then lay on their oars. The river was not high, so -there was not more than a two or three mile current. Hardly a word was -said during the next three-quarters of an hour. Now the raft was -passing before the distant town. Two or three glimmering lights showed -where it lay, peacefully sleeping, beyond the vague vast sweep of -star-gemmed water, unconscious of the tremendous event that was happening. -The Black Avenger stood still with folded arms, "looking his last" upon -the scene of his former joys and his later sufferings, and wishing -"she" could see him now, abroad on the wild sea, facing peril and death -with dauntless heart, going to his doom with a grim smile on his lips. -It was but a small strain on his imagination to remove Jackson's Island -beyond eyeshot of the village, and so he "looked his last" with a -broken and satisfied heart. The other pirates were looking their last, -too; and they all looked so long that they came near letting the -current drift them out of the range of the island. But they discovered -the danger in time, and made shift to avert it. About two o'clock in -the morning the raft grounded on the bar two hundred yards above the -head of the island, and they waded back and forth until they had landed -their freight. Part of the little raft's belongings consisted of an old -sail, and this they spread over a nook in the bushes for a tent to -shelter their provisions; but they themselves would sleep in the open -air in good weather, as became outlaws. - -They built a fire against the side of a great log twenty or thirty -steps within the sombre depths of the forest, and then cooked some -bacon in the frying-pan for supper, and used up half of the corn "pone" -stock they had brought. It seemed glorious sport to be feasting in that -wild, free way in the virgin forest of an unexplored and uninhabited -island, far from the haunts of men, and they said they never would -return to civilization. The climbing fire lit up their faces and threw -its ruddy glare upon the pillared tree-trunks of their forest temple, -and upon the varnished foliage and festooning vines. - -When the last crisp slice of bacon was gone, and the last allowance of -corn pone devoured, the boys stretched themselves out on the grass, -filled with contentment. They could have found a cooler place, but they -would not deny themselves such a romantic feature as the roasting -camp-fire. - -"AIN'T it gay?" said Joe. - -"It's NUTS!" said Tom. "What would the boys say if they could see us?" - -"Say? Well, they'd just die to be here--hey, Hucky!" - -"I reckon so," said Huckleberry; "anyways, I'm suited. I don't want -nothing better'n this. I don't ever get enough to eat, gen'ally--and -here they can't come and pick at a feller and bullyrag him so." - -"It's just the life for me," said Tom. "You don't have to get up, -mornings, and you don't have to go to school, and wash, and all that -blame foolishness. You see a pirate don't have to do ANYTHING, Joe, -when he's ashore, but a hermit HE has to be praying considerable, and -then he don't have any fun, anyway, all by himself that way." - -"Oh yes, that's so," said Joe, "but I hadn't thought much about it, -you know. I'd a good deal rather be a pirate, now that I've tried it." - -"You see," said Tom, "people don't go much on hermits, nowadays, like -they used to in old times, but a pirate's always respected. And a -hermit's got to sleep on the hardest place he can find, and put -sackcloth and ashes on his head, and stand out in the rain, and--" - -"What does he put sackcloth and ashes on his head for?" inquired Huck. - -"I dono. But they've GOT to do it. Hermits always do. You'd have to do -that if you was a hermit." - -"Dern'd if I would," said Huck. - -"Well, what would you do?" - -"I dono. But I wouldn't do that." - -"Why, Huck, you'd HAVE to. How'd you get around it?" - -"Why, I just wouldn't stand it. I'd run away." - -"Run away! Well, you WOULD be a nice old slouch of a hermit. You'd be -a disgrace." - -The Red-Handed made no response, being better employed. He had -finished gouging out a cob, and now he fitted a weed stem to it, loaded -it with tobacco, and was pressing a coal to the charge and blowing a -cloud of fragrant smoke--he was in the full bloom of luxurious -contentment. The other pirates envied him this majestic vice, and -secretly resolved to acquire it shortly. Presently Huck said: - -"What does pirates have to do?" - -Tom said: - -"Oh, they have just a bully time--take ships and burn them, and get -the money and bury it in awful places in their island where there's -ghosts and things to watch it, and kill everybody in the ships--make -'em walk a plank." - -"And they carry the women to the island," said Joe; "they don't kill -the women." - -"No," assented Tom, "they don't kill the women--they're too noble. And -the women's always beautiful, too. - -"And don't they wear the bulliest clothes! Oh no! All gold and silver -and di'monds," said Joe, with enthusiasm. - -"Who?" said Huck. - -"Why, the pirates." - -Huck scanned his own clothing forlornly. - -"I reckon I ain't dressed fitten for a pirate," said he, with a -regretful pathos in his voice; "but I ain't got none but these." - -But the other boys told him the fine clothes would come fast enough, -after they should have begun their adventures. They made him understand -that his poor rags would do to begin with, though it was customary for -wealthy pirates to start with a proper wardrobe. - -Gradually their talk died out and drowsiness began to steal upon the -eyelids of the little waifs. The pipe dropped from the fingers of the -Red-Handed, and he slept the sleep of the conscience-free and the -weary. The Terror of the Seas and the Black Avenger of the Spanish Main -had more difficulty in getting to sleep. They said their prayers -inwardly, and lying down, since there was nobody there with authority -to make them kneel and recite aloud; in truth, they had a mind not to -say them at all, but they were afraid to proceed to such lengths as -that, lest they might call down a sudden and special thunderbolt from -heaven. Then at once they reached and hovered upon the imminent verge -of sleep--but an intruder came, now, that would not "down." It was -conscience. They began to feel a vague fear that they had been doing -wrong to run away; and next they thought of the stolen meat, and then -the real torture came. They tried to argue it away by reminding -conscience that they had purloined sweetmeats and apples scores of -times; but conscience was not to be appeased by such thin -plausibilities; it seemed to them, in the end, that there was no -getting around the stubborn fact that taking sweetmeats was only -"hooking," while taking bacon and hams and such valuables was plain -simple stealing--and there was a command against that in the Bible. So -they inwardly resolved that so long as they remained in the business, -their piracies should not again be sullied with the crime of stealing. -Then conscience granted a truce, and these curiously inconsistent -pirates fell peacefully to sleep. - - - -CHAPTER XIV - -WHEN Tom awoke in the morning, he wondered where he was. He sat up and -rubbed his eyes and looked around. Then he comprehended. It was the -cool gray dawn, and there was a delicious sense of repose and peace in -the deep pervading calm and silence of the woods. Not a leaf stirred; -not a sound obtruded upon great Nature's meditation. Beaded dewdrops -stood upon the leaves and grasses. A white layer of ashes covered the -fire, and a thin blue breath of smoke rose straight into the air. Joe -and Huck still slept. - -Now, far away in the woods a bird called; another answered; presently -the hammering of a woodpecker was heard. Gradually the cool dim gray of -the morning whitened, and as gradually sounds multiplied and life -manifested itself. The marvel of Nature shaking off sleep and going to -work unfolded itself to the musing boy. A little green worm came -crawling over a dewy leaf, lifting two-thirds of his body into the air -from time to time and "sniffing around," then proceeding again--for he -was measuring, Tom said; and when the worm approached him, of its own -accord, he sat as still as a stone, with his hopes rising and falling, -by turns, as the creature still came toward him or seemed inclined to -go elsewhere; and when at last it considered a painful moment with its -curved body in the air and then came decisively down upon Tom's leg and -began a journey over him, his whole heart was glad--for that meant that -he was going to have a new suit of clothes--without the shadow of a -doubt a gaudy piratical uniform. Now a procession of ants appeared, -from nowhere in particular, and went about their labors; one struggled -manfully by with a dead spider five times as big as itself in its arms, -and lugged it straight up a tree-trunk. A brown spotted lady-bug -climbed the dizzy height of a grass blade, and Tom bent down close to -it and said, "Lady-bug, lady-bug, fly away home, your house is on fire, -your children's alone," and she took wing and went off to see about it ---which did not surprise the boy, for he knew of old that this insect was -credulous about conflagrations, and he had practised upon its -simplicity more than once. A tumblebug came next, heaving sturdily at -its ball, and Tom touched the creature, to see it shut its legs against -its body and pretend to be dead. The birds were fairly rioting by this -time. A catbird, the Northern mocker, lit in a tree over Tom's head, -and trilled out her imitations of her neighbors in a rapture of -enjoyment; then a shrill jay swept down, a flash of blue flame, and -stopped on a twig almost within the boy's reach, cocked his head to one -side and eyed the strangers with a consuming curiosity; a gray squirrel -and a big fellow of the "fox" kind came skurrying along, sitting up at -intervals to inspect and chatter at the boys, for the wild things had -probably never seen a human being before and scarcely knew whether to -be afraid or not. All Nature was wide awake and stirring, now; long -lances of sunlight pierced down through the dense foliage far and near, -and a few butterflies came fluttering upon the scene. - -Tom stirred up the other pirates and they all clattered away with a -shout, and in a minute or two were stripped and chasing after and -tumbling over each other in the shallow limpid water of the white -sandbar. They felt no longing for the little village sleeping in the -distance beyond the majestic waste of water. A vagrant current or a -slight rise in the river had carried off their raft, but this only -gratified them, since its going was something like burning the bridge -between them and civilization. - -They came back to camp wonderfully refreshed, glad-hearted, and -ravenous; and they soon had the camp-fire blazing up again. Huck found -a spring of clear cold water close by, and the boys made cups of broad -oak or hickory leaves, and felt that water, sweetened with such a -wildwood charm as that, would be a good enough substitute for coffee. -While Joe was slicing bacon for breakfast, Tom and Huck asked him to -hold on a minute; they stepped to a promising nook in the river-bank -and threw in their lines; almost immediately they had reward. Joe had -not had time to get impatient before they were back again with some -handsome bass, a couple of sun-perch and a small catfish--provisions -enough for quite a family. They fried the fish with the bacon, and were -astonished; for no fish had ever seemed so delicious before. They did -not know that the quicker a fresh-water fish is on the fire after he is -caught the better he is; and they reflected little upon what a sauce -open-air sleeping, open-air exercise, bathing, and a large ingredient -of hunger make, too. - -They lay around in the shade, after breakfast, while Huck had a smoke, -and then went off through the woods on an exploring expedition. They -tramped gayly along, over decaying logs, through tangled underbrush, -among solemn monarchs of the forest, hung from their crowns to the -ground with a drooping regalia of grape-vines. Now and then they came -upon snug nooks carpeted with grass and jeweled with flowers. - -They found plenty of things to be delighted with, but nothing to be -astonished at. They discovered that the island was about three miles -long and a quarter of a mile wide, and that the shore it lay closest to -was only separated from it by a narrow channel hardly two hundred yards -wide. They took a swim about every hour, so it was close upon the -middle of the afternoon when they got back to camp. They were too -hungry to stop to fish, but they fared sumptuously upon cold ham, and -then threw themselves down in the shade to talk. But the talk soon -began to drag, and then died. The stillness, the solemnity that brooded -in the woods, and the sense of loneliness, began to tell upon the -spirits of the boys. They fell to thinking. A sort of undefined longing -crept upon them. This took dim shape, presently--it was budding -homesickness. Even Finn the Red-Handed was dreaming of his doorsteps -and empty hogsheads. But they were all ashamed of their weakness, and -none was brave enough to speak his thought. - -For some time, now, the boys had been dully conscious of a peculiar -sound in the distance, just as one sometimes is of the ticking of a -clock which he takes no distinct note of. But now this mysterious sound -became more pronounced, and forced a recognition. The boys started, -glanced at each other, and then each assumed a listening attitude. -There was a long silence, profound and unbroken; then a deep, sullen -boom came floating down out of the distance. - -"What is it!" exclaimed Joe, under his breath. - -"I wonder," said Tom in a whisper. - -"'Tain't thunder," said Huckleberry, in an awed tone, "becuz thunder--" - -"Hark!" said Tom. "Listen--don't talk." - -They waited a time that seemed an age, and then the same muffled boom -troubled the solemn hush. - -"Let's go and see." - -They sprang to their feet and hurried to the shore toward the town. -They parted the bushes on the bank and peered out over the water. The -little steam ferryboat was about a mile below the village, drifting -with the current. Her broad deck seemed crowded with people. There were -a great many skiffs rowing about or floating with the stream in the -neighborhood of the ferryboat, but the boys could not determine what -the men in them were doing. Presently a great jet of white smoke burst -from the ferryboat's side, and as it expanded and rose in a lazy cloud, -that same dull throb of sound was borne to the listeners again. - -"I know now!" exclaimed Tom; "somebody's drownded!" - -"That's it!" said Huck; "they done that last summer, when Bill Turner -got drownded; they shoot a cannon over the water, and that makes him -come up to the top. Yes, and they take loaves of bread and put -quicksilver in 'em and set 'em afloat, and wherever there's anybody -that's drownded, they'll float right there and stop." - -"Yes, I've heard about that," said Joe. "I wonder what makes the bread -do that." - -"Oh, it ain't the bread, so much," said Tom; "I reckon it's mostly -what they SAY over it before they start it out." - -"But they don't say anything over it," said Huck. "I've seen 'em and -they don't." - -"Well, that's funny," said Tom. "But maybe they say it to themselves. -Of COURSE they do. Anybody might know that." - -The other boys agreed that there was reason in what Tom said, because -an ignorant lump of bread, uninstructed by an incantation, could not be -expected to act very intelligently when set upon an errand of such -gravity. - -"By jings, I wish I was over there, now," said Joe. - -"I do too" said Huck "I'd give heaps to know who it is." - -The boys still listened and watched. Presently a revealing thought -flashed through Tom's mind, and he exclaimed: - -"Boys, I know who's drownded--it's us!" - -They felt like heroes in an instant. Here was a gorgeous triumph; they -were missed; they were mourned; hearts were breaking on their account; -tears were being shed; accusing memories of unkindness to these poor -lost lads were rising up, and unavailing regrets and remorse were being -indulged; and best of all, the departed were the talk of the whole -town, and the envy of all the boys, as far as this dazzling notoriety -was concerned. This was fine. It was worth while to be a pirate, after -all. - -As twilight drew on, the ferryboat went back to her accustomed -business and the skiffs disappeared. The pirates returned to camp. They -were jubilant with vanity over their new grandeur and the illustrious -trouble they were making. They caught fish, cooked supper and ate it, -and then fell to guessing at what the village was thinking and saying -about them; and the pictures they drew of the public distress on their -account were gratifying to look upon--from their point of view. But -when the shadows of night closed them in, they gradually ceased to -talk, and sat gazing into the fire, with their minds evidently -wandering elsewhere. The excitement was gone, now, and Tom and Joe -could not keep back thoughts of certain persons at home who were not -enjoying this fine frolic as much as they were. Misgivings came; they -grew troubled and unhappy; a sigh or two escaped, unawares. By and by -Joe timidly ventured upon a roundabout "feeler" as to how the others -might look upon a return to civilization--not right now, but-- - -Tom withered him with derision! Huck, being uncommitted as yet, joined -in with Tom, and the waverer quickly "explained," and was glad to get -out of the scrape with as little taint of chicken-hearted homesickness -clinging to his garments as he could. Mutiny was effectually laid to -rest for the moment. - -As the night deepened, Huck began to nod, and presently to snore. Joe -followed next. Tom lay upon his elbow motionless, for some time, -watching the two intently. At last he got up cautiously, on his knees, -and went searching among the grass and the flickering reflections flung -by the camp-fire. He picked up and inspected several large -semi-cylinders of the thin white bark of a sycamore, and finally chose -two which seemed to suit him. Then he knelt by the fire and painfully -wrote something upon each of these with his "red keel"; one he rolled up -and put in his jacket pocket, and the other he put in Joe's hat and -removed it to a little distance from the owner. And he also put into the -hat certain schoolboy treasures of almost inestimable value--among them -a lump of chalk, an India-rubber ball, three fishhooks, and one of that -kind of marbles known as a "sure 'nough crystal." Then he tiptoed his -way cautiously among the trees till he felt that he was out of hearing, -and straightway broke into a keen run in the direction of the sandbar. - - - -CHAPTER XV - -A FEW minutes later Tom was in the shoal water of the bar, wading -toward the Illinois shore. Before the depth reached his middle he was -half-way over; the current would permit no more wading, now, so he -struck out confidently to swim the remaining hundred yards. He swam -quartering upstream, but still was swept downward rather faster than he -had expected. However, he reached the shore finally, and drifted along -till he found a low place and drew himself out. He put his hand on his -jacket pocket, found his piece of bark safe, and then struck through -the woods, following the shore, with streaming garments. Shortly before -ten o'clock he came out into an open place opposite the village, and -saw the ferryboat lying in the shadow of the trees and the high bank. -Everything was quiet under the blinking stars. He crept down the bank, -watching with all his eyes, slipped into the water, swam three or four -strokes and climbed into the skiff that did "yawl" duty at the boat's -stern. He laid himself down under the thwarts and waited, panting. - -Presently the cracked bell tapped and a voice gave the order to "cast -off." A minute or two later the skiff's head was standing high up, -against the boat's swell, and the voyage was begun. Tom felt happy in -his success, for he knew it was the boat's last trip for the night. At -the end of a long twelve or fifteen minutes the wheels stopped, and Tom -slipped overboard and swam ashore in the dusk, landing fifty yards -downstream, out of danger of possible stragglers. - -He flew along unfrequented alleys, and shortly found himself at his -aunt's back fence. He climbed over, approached the "ell," and looked in -at the sitting-room window, for a light was burning there. There sat -Aunt Polly, Sid, Mary, and Joe Harper's mother, grouped together, -talking. They were by the bed, and the bed was between them and the -door. Tom went to the door and began to softly lift the latch; then he -pressed gently and the door yielded a crack; he continued pushing -cautiously, and quaking every time it creaked, till he judged he might -squeeze through on his knees; so he put his head through and began, -warily. - -"What makes the candle blow so?" said Aunt Polly. Tom hurried up. -"Why, that door's open, I believe. Why, of course it is. No end of -strange things now. Go 'long and shut it, Sid." - -Tom disappeared under the bed just in time. He lay and "breathed" -himself for a time, and then crept to where he could almost touch his -aunt's foot. - -"But as I was saying," said Aunt Polly, "he warn't BAD, so to say ---only mischEEvous. Only just giddy, and harum-scarum, you know. He -warn't any more responsible than a colt. HE never meant any harm, and -he was the best-hearted boy that ever was"--and she began to cry. - -"It was just so with my Joe--always full of his devilment, and up to -every kind of mischief, but he was just as unselfish and kind as he -could be--and laws bless me, to think I went and whipped him for taking -that cream, never once recollecting that I throwed it out myself -because it was sour, and I never to see him again in this world, never, -never, never, poor abused boy!" And Mrs. Harper sobbed as if her heart -would break. - -"I hope Tom's better off where he is," said Sid, "but if he'd been -better in some ways--" - -"SID!" Tom felt the glare of the old lady's eye, though he could not -see it. "Not a word against my Tom, now that he's gone! God'll take -care of HIM--never you trouble YOURself, sir! Oh, Mrs. Harper, I don't -know how to give him up! I don't know how to give him up! He was such a -comfort to me, although he tormented my old heart out of me, 'most." - -"The Lord giveth and the Lord hath taken away--Blessed be the name of -the Lord! But it's so hard--Oh, it's so hard! Only last Saturday my -Joe busted a firecracker right under my nose and I knocked him -sprawling. Little did I know then, how soon--Oh, if it was to do over -again I'd hug him and bless him for it." - -"Yes, yes, yes, I know just how you feel, Mrs. Harper, I know just -exactly how you feel. No longer ago than yesterday noon, my Tom took -and filled the cat full of Pain-killer, and I did think the cretur -would tear the house down. And God forgive me, I cracked Tom's head -with my thimble, poor boy, poor dead boy. But he's out of all his -troubles now. And the last words I ever heard him say was to reproach--" - -But this memory was too much for the old lady, and she broke entirely -down. Tom was snuffling, now, himself--and more in pity of himself than -anybody else. He could hear Mary crying, and putting in a kindly word -for him from time to time. He began to have a nobler opinion of himself -than ever before. Still, he was sufficiently touched by his aunt's -grief to long to rush out from under the bed and overwhelm her with -joy--and the theatrical gorgeousness of the thing appealed strongly to -his nature, too, but he resisted and lay still. - -He went on listening, and gathered by odds and ends that it was -conjectured at first that the boys had got drowned while taking a swim; -then the small raft had been missed; next, certain boys said the -missing lads had promised that the village should "hear something" -soon; the wise-heads had "put this and that together" and decided that -the lads had gone off on that raft and would turn up at the next town -below, presently; but toward noon the raft had been found, lodged -against the Missouri shore some five or six miles below the village ---and then hope perished; they must be drowned, else hunger would have -driven them home by nightfall if not sooner. It was believed that the -search for the bodies had been a fruitless effort merely because the -drowning must have occurred in mid-channel, since the boys, being good -swimmers, would otherwise have escaped to shore. This was Wednesday -night. If the bodies continued missing until Sunday, all hope would be -given over, and the funerals would be preached on that morning. Tom -shuddered. - -Mrs. Harper gave a sobbing good-night and turned to go. Then with a -mutual impulse the two bereaved women flung themselves into each -other's arms and had a good, consoling cry, and then parted. Aunt Polly -was tender far beyond her wont, in her good-night to Sid and Mary. Sid -snuffled a bit and Mary went off crying with all her heart. - -Aunt Polly knelt down and prayed for Tom so touchingly, so -appealingly, and with such measureless love in her words and her old -trembling voice, that he was weltering in tears again, long before she -was through. - -He had to keep still long after she went to bed, for she kept making -broken-hearted ejaculations from time to time, tossing unrestfully, and -turning over. But at last she was still, only moaning a little in her -sleep. Now the boy stole out, rose gradually by the bedside, shaded the -candle-light with his hand, and stood regarding her. His heart was full -of pity for her. He took out his sycamore scroll and placed it by the -candle. But something occurred to him, and he lingered considering. His -face lighted with a happy solution of his thought; he put the bark -hastily in his pocket. Then he bent over and kissed the faded lips, and -straightway made his stealthy exit, latching the door behind him. - -He threaded his way back to the ferry landing, found nobody at large -there, and walked boldly on board the boat, for he knew she was -tenantless except that there was a watchman, who always turned in and -slept like a graven image. He untied the skiff at the stern, slipped -into it, and was soon rowing cautiously upstream. When he had pulled a -mile above the village, he started quartering across and bent himself -stoutly to his work. He hit the landing on the other side neatly, for -this was a familiar bit of work to him. He was moved to capture the -skiff, arguing that it might be considered a ship and therefore -legitimate prey for a pirate, but he knew a thorough search would be -made for it and that might end in revelations. So he stepped ashore and -entered the woods. - -He sat down and took a long rest, torturing himself meanwhile to keep -awake, and then started warily down the home-stretch. The night was far -spent. It was broad daylight before he found himself fairly abreast the -island bar. He rested again until the sun was well up and gilding the -great river with its splendor, and then he plunged into the stream. A -little later he paused, dripping, upon the threshold of the camp, and -heard Joe say: - -"No, Tom's true-blue, Huck, and he'll come back. He won't desert. He -knows that would be a disgrace to a pirate, and Tom's too proud for -that sort of thing. He's up to something or other. Now I wonder what?" - -"Well, the things is ours, anyway, ain't they?" - -"Pretty near, but not yet, Huck. The writing says they are if he ain't -back here to breakfast." - -"Which he is!" exclaimed Tom, with fine dramatic effect, stepping -grandly into camp. - -A sumptuous breakfast of bacon and fish was shortly provided, and as -the boys set to work upon it, Tom recounted (and adorned) his -adventures. They were a vain and boastful company of heroes when the -tale was done. Then Tom hid himself away in a shady nook to sleep till -noon, and the other pirates got ready to fish and explore. - - - -CHAPTER XVI - -AFTER dinner all the gang turned out to hunt for turtle eggs on the -bar. They went about poking sticks into the sand, and when they found a -soft place they went down on their knees and dug with their hands. -Sometimes they would take fifty or sixty eggs out of one hole. They -were perfectly round white things a trifle smaller than an English -walnut. They had a famous fried-egg feast that night, and another on -Friday morning. - -After breakfast they went whooping and prancing out on the bar, and -chased each other round and round, shedding clothes as they went, until -they were naked, and then continued the frolic far away up the shoal -water of the bar, against the stiff current, which latter tripped their -legs from under them from time to time and greatly increased the fun. -And now and then they stooped in a group and splashed water in each -other's faces with their palms, gradually approaching each other, with -averted faces to avoid the strangling sprays, and finally gripping and -struggling till the best man ducked his neighbor, and then they all -went under in a tangle of white legs and arms and came up blowing, -sputtering, laughing, and gasping for breath at one and the same time. - -When they were well exhausted, they would run out and sprawl on the -dry, hot sand, and lie there and cover themselves up with it, and by -and by break for the water again and go through the original -performance once more. Finally it occurred to them that their naked -skin represented flesh-colored "tights" very fairly; so they drew a -ring in the sand and had a circus--with three clowns in it, for none -would yield this proudest post to his neighbor. - -Next they got their marbles and played "knucks" and "ring-taw" and -"keeps" till that amusement grew stale. Then Joe and Huck had another -swim, but Tom would not venture, because he found that in kicking off -his trousers he had kicked his string of rattlesnake rattles off his -ankle, and he wondered how he had escaped cramp so long without the -protection of this mysterious charm. He did not venture again until he -had found it, and by that time the other boys were tired and ready to -rest. They gradually wandered apart, dropped into the "dumps," and fell -to gazing longingly across the wide river to where the village lay -drowsing in the sun. Tom found himself writing "BECKY" in the sand with -his big toe; he scratched it out, and was angry with himself for his -weakness. But he wrote it again, nevertheless; he could not help it. He -erased it once more and then took himself out of temptation by driving -the other boys together and joining them. - -But Joe's spirits had gone down almost beyond resurrection. He was so -homesick that he could hardly endure the misery of it. The tears lay -very near the surface. Huck was melancholy, too. Tom was downhearted, -but tried hard not to show it. He had a secret which he was not ready -to tell, yet, but if this mutinous depression was not broken up soon, -he would have to bring it out. He said, with a great show of -cheerfulness: - -"I bet there's been pirates on this island before, boys. We'll explore -it again. They've hid treasures here somewhere. How'd you feel to light -on a rotten chest full of gold and silver--hey?" - -But it roused only faint enthusiasm, which faded out, with no reply. -Tom tried one or two other seductions; but they failed, too. It was -discouraging work. Joe sat poking up the sand with a stick and looking -very gloomy. Finally he said: - -"Oh, boys, let's give it up. I want to go home. It's so lonesome." - -"Oh no, Joe, you'll feel better by and by," said Tom. "Just think of -the fishing that's here." - -"I don't care for fishing. I want to go home." - -"But, Joe, there ain't such another swimming-place anywhere." - -"Swimming's no good. I don't seem to care for it, somehow, when there -ain't anybody to say I sha'n't go in. I mean to go home." - -"Oh, shucks! Baby! You want to see your mother, I reckon." - -"Yes, I DO want to see my mother--and you would, too, if you had one. -I ain't any more baby than you are." And Joe snuffled a little. - -"Well, we'll let the cry-baby go home to his mother, won't we, Huck? -Poor thing--does it want to see its mother? And so it shall. You like -it here, don't you, Huck? We'll stay, won't we?" - -Huck said, "Y-e-s"--without any heart in it. - -"I'll never speak to you again as long as I live," said Joe, rising. -"There now!" And he moved moodily away and began to dress himself. - -"Who cares!" said Tom. "Nobody wants you to. Go 'long home and get -laughed at. Oh, you're a nice pirate. Huck and me ain't cry-babies. -We'll stay, won't we, Huck? Let him go if he wants to. I reckon we can -get along without him, per'aps." - -But Tom was uneasy, nevertheless, and was alarmed to see Joe go -sullenly on with his dressing. And then it was discomforting to see -Huck eying Joe's preparations so wistfully, and keeping up such an -ominous silence. Presently, without a parting word, Joe began to wade -off toward the Illinois shore. Tom's heart began to sink. He glanced at -Huck. Huck could not bear the look, and dropped his eyes. Then he said: - -"I want to go, too, Tom. It was getting so lonesome anyway, and now -it'll be worse. Let's us go, too, Tom." - -"I won't! You can all go, if you want to. I mean to stay." - -"Tom, I better go." - -"Well, go 'long--who's hendering you." - -Huck began to pick up his scattered clothes. He said: - -"Tom, I wisht you'd come, too. Now you think it over. We'll wait for -you when we get to shore." - -"Well, you'll wait a blame long time, that's all." - -Huck started sorrowfully away, and Tom stood looking after him, with a -strong desire tugging at his heart to yield his pride and go along too. -He hoped the boys would stop, but they still waded slowly on. It -suddenly dawned on Tom that it was become very lonely and still. He -made one final struggle with his pride, and then darted after his -comrades, yelling: - -"Wait! Wait! I want to tell you something!" - -They presently stopped and turned around. When he got to where they -were, he began unfolding his secret, and they listened moodily till at -last they saw the "point" he was driving at, and then they set up a -war-whoop of applause and said it was "splendid!" and said if he had -told them at first, they wouldn't have started away. He made a plausible -excuse; but his real reason had been the fear that not even the secret -would keep them with him any very great length of time, and so he had -meant to hold it in reserve as a last seduction. - -The lads came gayly back and went at their sports again with a will, -chattering all the time about Tom's stupendous plan and admiring the -genius of it. After a dainty egg and fish dinner, Tom said he wanted to -learn to smoke, now. Joe caught at the idea and said he would like to -try, too. So Huck made pipes and filled them. These novices had never -smoked anything before but cigars made of grape-vine, and they "bit" -the tongue, and were not considered manly anyway. - -Now they stretched themselves out on their elbows and began to puff, -charily, and with slender confidence. The smoke had an unpleasant -taste, and they gagged a little, but Tom said: - -"Why, it's just as easy! If I'd a knowed this was all, I'd a learnt -long ago." - -"So would I," said Joe. "It's just nothing." - -"Why, many a time I've looked at people smoking, and thought well I -wish I could do that; but I never thought I could," said Tom. - -"That's just the way with me, hain't it, Huck? You've heard me talk -just that way--haven't you, Huck? I'll leave it to Huck if I haven't." - -"Yes--heaps of times," said Huck. - -"Well, I have too," said Tom; "oh, hundreds of times. Once down by the -slaughter-house. Don't you remember, Huck? Bob Tanner was there, and -Johnny Miller, and Jeff Thatcher, when I said it. Don't you remember, -Huck, 'bout me saying that?" - -"Yes, that's so," said Huck. "That was the day after I lost a white -alley. No, 'twas the day before." - -"There--I told you so," said Tom. "Huck recollects it." - -"I bleeve I could smoke this pipe all day," said Joe. "I don't feel -sick." - -"Neither do I," said Tom. "I could smoke it all day. But I bet you -Jeff Thatcher couldn't." - -"Jeff Thatcher! Why, he'd keel over just with two draws. Just let him -try it once. HE'D see!" - -"I bet he would. And Johnny Miller--I wish could see Johnny Miller -tackle it once." - -"Oh, don't I!" said Joe. "Why, I bet you Johnny Miller couldn't any -more do this than nothing. Just one little snifter would fetch HIM." - -"'Deed it would, Joe. Say--I wish the boys could see us now." - -"So do I." - -"Say--boys, don't say anything about it, and some time when they're -around, I'll come up to you and say, 'Joe, got a pipe? I want a smoke.' -And you'll say, kind of careless like, as if it warn't anything, you'll -say, 'Yes, I got my OLD pipe, and another one, but my tobacker ain't -very good.' And I'll say, 'Oh, that's all right, if it's STRONG -enough.' And then you'll out with the pipes, and we'll light up just as -ca'm, and then just see 'em look!" - -"By jings, that'll be gay, Tom! I wish it was NOW!" - -"So do I! And when we tell 'em we learned when we was off pirating, -won't they wish they'd been along?" - -"Oh, I reckon not! I'll just BET they will!" - -So the talk ran on. But presently it began to flag a trifle, and grow -disjointed. The silences widened; the expectoration marvellously -increased. Every pore inside the boys' cheeks became a spouting -fountain; they could scarcely bail out the cellars under their tongues -fast enough to prevent an inundation; little overflowings down their -throats occurred in spite of all they could do, and sudden retchings -followed every time. Both boys were looking very pale and miserable, -now. Joe's pipe dropped from his nerveless fingers. Tom's followed. -Both fountains were going furiously and both pumps bailing with might -and main. Joe said feebly: - -"I've lost my knife. I reckon I better go and find it." - -Tom said, with quivering lips and halting utterance: - -"I'll help you. You go over that way and I'll hunt around by the -spring. No, you needn't come, Huck--we can find it." - -So Huck sat down again, and waited an hour. Then he found it lonesome, -and went to find his comrades. They were wide apart in the woods, both -very pale, both fast asleep. But something informed him that if they -had had any trouble they had got rid of it. - -They were not talkative at supper that night. They had a humble look, -and when Huck prepared his pipe after the meal and was going to prepare -theirs, they said no, they were not feeling very well--something they -ate at dinner had disagreed with them. - -About midnight Joe awoke, and called the boys. There was a brooding -oppressiveness in the air that seemed to bode something. The boys -huddled themselves together and sought the friendly companionship of -the fire, though the dull dead heat of the breathless atmosphere was -stifling. They sat still, intent and waiting. The solemn hush -continued. Beyond the light of the fire everything was swallowed up in -the blackness of darkness. Presently there came a quivering glow that -vaguely revealed the foliage for a moment and then vanished. By and by -another came, a little stronger. Then another. Then a faint moan came -sighing through the branches of the forest and the boys felt a fleeting -breath upon their cheeks, and shuddered with the fancy that the Spirit -of the Night had gone by. There was a pause. Now a weird flash turned -night into day and showed every little grass-blade, separate and -distinct, that grew about their feet. And it showed three white, -startled faces, too. A deep peal of thunder went rolling and tumbling -down the heavens and lost itself in sullen rumblings in the distance. A -sweep of chilly air passed by, rustling all the leaves and snowing the -flaky ashes broadcast about the fire. Another fierce glare lit up the -forest and an instant crash followed that seemed to rend the tree-tops -right over the boys' heads. They clung together in terror, in the thick -gloom that followed. A few big rain-drops fell pattering upon the -leaves. - -"Quick! boys, go for the tent!" exclaimed Tom. - -They sprang away, stumbling over roots and among vines in the dark, no -two plunging in the same direction. A furious blast roared through the -trees, making everything sing as it went. One blinding flash after -another came, and peal on peal of deafening thunder. And now a -drenching rain poured down and the rising hurricane drove it in sheets -along the ground. The boys cried out to each other, but the roaring -wind and the booming thunder-blasts drowned their voices utterly. -However, one by one they straggled in at last and took shelter under -the tent, cold, scared, and streaming with water; but to have company -in misery seemed something to be grateful for. They could not talk, the -old sail flapped so furiously, even if the other noises would have -allowed them. The tempest rose higher and higher, and presently the -sail tore loose from its fastenings and went winging away on the blast. -The boys seized each others' hands and fled, with many tumblings and -bruises, to the shelter of a great oak that stood upon the river-bank. -Now the battle was at its highest. Under the ceaseless conflagration of -lightning that flamed in the skies, everything below stood out in -clean-cut and shadowless distinctness: the bending trees, the billowy -river, white with foam, the driving spray of spume-flakes, the dim -outlines of the high bluffs on the other side, glimpsed through the -drifting cloud-rack and the slanting veil of rain. Every little while -some giant tree yielded the fight and fell crashing through the younger -growth; and the unflagging thunder-peals came now in ear-splitting -explosive bursts, keen and sharp, and unspeakably appalling. The storm -culminated in one matchless effort that seemed likely to tear the island -to pieces, burn it up, drown it to the tree-tops, blow it away, and -deafen every creature in it, all at one and the same moment. It was a -wild night for homeless young heads to be out in. - -But at last the battle was done, and the forces retired with weaker -and weaker threatenings and grumblings, and peace resumed her sway. The -boys went back to camp, a good deal awed; but they found there was -still something to be thankful for, because the great sycamore, the -shelter of their beds, was a ruin, now, blasted by the lightnings, and -they were not under it when the catastrophe happened. - -Everything in camp was drenched, the camp-fire as well; for they were -but heedless lads, like their generation, and had made no provision -against rain. Here was matter for dismay, for they were soaked through -and chilled. They were eloquent in their distress; but they presently -discovered that the fire had eaten so far up under the great log it had -been built against (where it curved upward and separated itself from -the ground), that a handbreadth or so of it had escaped wetting; so -they patiently wrought until, with shreds and bark gathered from the -under sides of sheltered logs, they coaxed the fire to burn again. Then -they piled on great dead boughs till they had a roaring furnace, and -were glad-hearted once more. They dried their boiled ham and had a -feast, and after that they sat by the fire and expanded and glorified -their midnight adventure until morning, for there was not a dry spot to -sleep on, anywhere around. - -As the sun began to steal in upon the boys, drowsiness came over them, -and they went out on the sandbar and lay down to sleep. They got -scorched out by and by, and drearily set about getting breakfast. After -the meal they felt rusty, and stiff-jointed, and a little homesick once -more. Tom saw the signs, and fell to cheering up the pirates as well as -he could. But they cared nothing for marbles, or circus, or swimming, -or anything. He reminded them of the imposing secret, and raised a ray -of cheer. While it lasted, he got them interested in a new device. This -was to knock off being pirates, for a while, and be Indians for a -change. They were attracted by this idea; so it was not long before -they were stripped, and striped from head to heel with black mud, like -so many zebras--all of them chiefs, of course--and then they went -tearing through the woods to attack an English settlement. - -By and by they separated into three hostile tribes, and darted upon -each other from ambush with dreadful war-whoops, and killed and scalped -each other by thousands. It was a gory day. Consequently it was an -extremely satisfactory one. - -They assembled in camp toward supper-time, hungry and happy; but now a -difficulty arose--hostile Indians could not break the bread of -hospitality together without first making peace, and this was a simple -impossibility without smoking a pipe of peace. There was no other -process that ever they had heard of. Two of the savages almost wished -they had remained pirates. However, there was no other way; so with -such show of cheerfulness as they could muster they called for the pipe -and took their whiff as it passed, in due form. - -And behold, they were glad they had gone into savagery, for they had -gained something; they found that they could now smoke a little without -having to go and hunt for a lost knife; they did not get sick enough to -be seriously uncomfortable. They were not likely to fool away this high -promise for lack of effort. No, they practised cautiously, after -supper, with right fair success, and so they spent a jubilant evening. -They were prouder and happier in their new acquirement than they would -have been in the scalping and skinning of the Six Nations. We will -leave them to smoke and chatter and brag, since we have no further use -for them at present. - - - -CHAPTER XVII - -BUT there was no hilarity in the little town that same tranquil -Saturday afternoon. The Harpers, and Aunt Polly's family, were being -put into mourning, with great grief and many tears. An unusual quiet -possessed the village, although it was ordinarily quiet enough, in all -conscience. The villagers conducted their concerns with an absent air, -and talked little; but they sighed often. The Saturday holiday seemed a -burden to the children. They had no heart in their sports, and -gradually gave them up. - -In the afternoon Becky Thatcher found herself moping about the -deserted schoolhouse yard, and feeling very melancholy. But she found -nothing there to comfort her. She soliloquized: - -"Oh, if I only had a brass andiron-knob again! But I haven't got -anything now to remember him by." And she choked back a little sob. - -Presently she stopped, and said to herself: - -"It was right here. Oh, if it was to do over again, I wouldn't say -that--I wouldn't say it for the whole world. But he's gone now; I'll -never, never, never see him any more." - -This thought broke her down, and she wandered away, with tears rolling -down her cheeks. Then quite a group of boys and girls--playmates of -Tom's and Joe's--came by, and stood looking over the paling fence and -talking in reverent tones of how Tom did so-and-so the last time they -saw him, and how Joe said this and that small trifle (pregnant with -awful prophecy, as they could easily see now!)--and each speaker -pointed out the exact spot where the lost lads stood at the time, and -then added something like "and I was a-standing just so--just as I am -now, and as if you was him--I was as close as that--and he smiled, just -this way--and then something seemed to go all over me, like--awful, you -know--and I never thought what it meant, of course, but I can see now!" - -Then there was a dispute about who saw the dead boys last in life, and -many claimed that dismal distinction, and offered evidences, more or -less tampered with by the witness; and when it was ultimately decided -who DID see the departed last, and exchanged the last words with them, -the lucky parties took upon themselves a sort of sacred importance, and -were gaped at and envied by all the rest. One poor chap, who had no -other grandeur to offer, said with tolerably manifest pride in the -remembrance: - -"Well, Tom Sawyer he licked me once." - -But that bid for glory was a failure. Most of the boys could say that, -and so that cheapened the distinction too much. The group loitered -away, still recalling memories of the lost heroes, in awed voices. - -When the Sunday-school hour was finished, the next morning, the bell -began to toll, instead of ringing in the usual way. It was a very still -Sabbath, and the mournful sound seemed in keeping with the musing hush -that lay upon nature. The villagers began to gather, loitering a moment -in the vestibule to converse in whispers about the sad event. But there -was no whispering in the house; only the funereal rustling of dresses -as the women gathered to their seats disturbed the silence there. None -could remember when the little church had been so full before. There -was finally a waiting pause, an expectant dumbness, and then Aunt Polly -entered, followed by Sid and Mary, and they by the Harper family, all -in deep black, and the whole congregation, the old minister as well, -rose reverently and stood until the mourners were seated in the front -pew. There was another communing silence, broken at intervals by -muffled sobs, and then the minister spread his hands abroad and prayed. -A moving hymn was sung, and the text followed: "I am the Resurrection -and the Life." - -As the service proceeded, the clergyman drew such pictures of the -graces, the winning ways, and the rare promise of the lost lads that -every soul there, thinking he recognized these pictures, felt a pang in -remembering that he had persistently blinded himself to them always -before, and had as persistently seen only faults and flaws in the poor -boys. The minister related many a touching incident in the lives of the -departed, too, which illustrated their sweet, generous natures, and the -people could easily see, now, how noble and beautiful those episodes -were, and remembered with grief that at the time they occurred they had -seemed rank rascalities, well deserving of the cowhide. The -congregation became more and more moved, as the pathetic tale went on, -till at last the whole company broke down and joined the weeping -mourners in a chorus of anguished sobs, the preacher himself giving way -to his feelings, and crying in the pulpit. - -There was a rustle in the gallery, which nobody noticed; a moment -later the church door creaked; the minister raised his streaming eyes -above his handkerchief, and stood transfixed! First one and then -another pair of eyes followed the minister's, and then almost with one -impulse the congregation rose and stared while the three dead boys came -marching up the aisle, Tom in the lead, Joe next, and Huck, a ruin of -drooping rags, sneaking sheepishly in the rear! They had been hid in -the unused gallery listening to their own funeral sermon! - -Aunt Polly, Mary, and the Harpers threw themselves upon their restored -ones, smothered them with kisses and poured out thanksgivings, while -poor Huck stood abashed and uncomfortable, not knowing exactly what to -do or where to hide from so many unwelcoming eyes. He wavered, and -started to slink away, but Tom seized him and said: - -"Aunt Polly, it ain't fair. Somebody's got to be glad to see Huck." - -"And so they shall. I'm glad to see him, poor motherless thing!" And -the loving attentions Aunt Polly lavished upon him were the one thing -capable of making him more uncomfortable than he was before. - -Suddenly the minister shouted at the top of his voice: "Praise God -from whom all blessings flow--SING!--and put your hearts in it!" - -And they did. Old Hundred swelled up with a triumphant burst, and -while it shook the rafters Tom Sawyer the Pirate looked around upon the -envying juveniles about him and confessed in his heart that this was -the proudest moment of his life. - -As the "sold" congregation trooped out they said they would almost be -willing to be made ridiculous again to hear Old Hundred sung like that -once more. - -Tom got more cuffs and kisses that day--according to Aunt Polly's -varying moods--than he had earned before in a year; and he hardly knew -which expressed the most gratefulness to God and affection for himself. - - - -CHAPTER XVIII - -THAT was Tom's great secret--the scheme to return home with his -brother pirates and attend their own funerals. They had paddled over to -the Missouri shore on a log, at dusk on Saturday, landing five or six -miles below the village; they had slept in the woods at the edge of the -town till nearly daylight, and had then crept through back lanes and -alleys and finished their sleep in the gallery of the church among a -chaos of invalided benches. - -At breakfast, Monday morning, Aunt Polly and Mary were very loving to -Tom, and very attentive to his wants. There was an unusual amount of -talk. In the course of it Aunt Polly said: - -"Well, I don't say it wasn't a fine joke, Tom, to keep everybody -suffering 'most a week so you boys had a good time, but it is a pity -you could be so hard-hearted as to let me suffer so. If you could come -over on a log to go to your funeral, you could have come over and give -me a hint some way that you warn't dead, but only run off." - -"Yes, you could have done that, Tom," said Mary; "and I believe you -would if you had thought of it." - -"Would you, Tom?" said Aunt Polly, her face lighting wistfully. "Say, -now, would you, if you'd thought of it?" - -"I--well, I don't know. 'Twould 'a' spoiled everything." - -"Tom, I hoped you loved me that much," said Aunt Polly, with a grieved -tone that discomforted the boy. "It would have been something if you'd -cared enough to THINK of it, even if you didn't DO it." - -"Now, auntie, that ain't any harm," pleaded Mary; "it's only Tom's -giddy way--he is always in such a rush that he never thinks of -anything." - -"More's the pity. Sid would have thought. And Sid would have come and -DONE it, too. Tom, you'll look back, some day, when it's too late, and -wish you'd cared a little more for me when it would have cost you so -little." - -"Now, auntie, you know I do care for you," said Tom. - -"I'd know it better if you acted more like it." - -"I wish now I'd thought," said Tom, with a repentant tone; "but I -dreamt about you, anyway. That's something, ain't it?" - -"It ain't much--a cat does that much--but it's better than nothing. -What did you dream?" - -"Why, Wednesday night I dreamt that you was sitting over there by the -bed, and Sid was sitting by the woodbox, and Mary next to him." - -"Well, so we did. So we always do. I'm glad your dreams could take -even that much trouble about us." - -"And I dreamt that Joe Harper's mother was here." - -"Why, she was here! Did you dream any more?" - -"Oh, lots. But it's so dim, now." - -"Well, try to recollect--can't you?" - -"Somehow it seems to me that the wind--the wind blowed the--the--" - -"Try harder, Tom! The wind did blow something. Come!" - -Tom pressed his fingers on his forehead an anxious minute, and then -said: - -"I've got it now! I've got it now! It blowed the candle!" - -"Mercy on us! Go on, Tom--go on!" - -"And it seems to me that you said, 'Why, I believe that that door--'" - -"Go ON, Tom!" - -"Just let me study a moment--just a moment. Oh, yes--you said you -believed the door was open." - -"As I'm sitting here, I did! Didn't I, Mary! Go on!" - -"And then--and then--well I won't be certain, but it seems like as if -you made Sid go and--and--" - -"Well? Well? What did I make him do, Tom? What did I make him do?" - -"You made him--you--Oh, you made him shut it." - -"Well, for the land's sake! I never heard the beat of that in all my -days! Don't tell ME there ain't anything in dreams, any more. Sereny -Harper shall know of this before I'm an hour older. I'd like to see her -get around THIS with her rubbage 'bout superstition. Go on, Tom!" - -"Oh, it's all getting just as bright as day, now. Next you said I -warn't BAD, only mischeevous and harum-scarum, and not any more -responsible than--than--I think it was a colt, or something." - -"And so it was! Well, goodness gracious! Go on, Tom!" - -"And then you began to cry." - -"So I did. So I did. Not the first time, neither. And then--" - -"Then Mrs. Harper she began to cry, and said Joe was just the same, -and she wished she hadn't whipped him for taking cream when she'd -throwed it out her own self--" - -"Tom! The sperrit was upon you! You was a prophesying--that's what you -was doing! Land alive, go on, Tom!" - -"Then Sid he said--he said--" - -"I don't think I said anything," said Sid. - -"Yes you did, Sid," said Mary. - -"Shut your heads and let Tom go on! What did he say, Tom?" - -"He said--I THINK he said he hoped I was better off where I was gone -to, but if I'd been better sometimes--" - -"THERE, d'you hear that! It was his very words!" - -"And you shut him up sharp." - -"I lay I did! There must 'a' been an angel there. There WAS an angel -there, somewheres!" - -"And Mrs. Harper told about Joe scaring her with a firecracker, and -you told about Peter and the Painkiller--" - -"Just as true as I live!" - -"And then there was a whole lot of talk 'bout dragging the river for -us, and 'bout having the funeral Sunday, and then you and old Miss -Harper hugged and cried, and she went." - -"It happened just so! It happened just so, as sure as I'm a-sitting in -these very tracks. Tom, you couldn't told it more like if you'd 'a' -seen it! And then what? Go on, Tom!" - -"Then I thought you prayed for me--and I could see you and hear every -word you said. And you went to bed, and I was so sorry that I took and -wrote on a piece of sycamore bark, 'We ain't dead--we are only off -being pirates,' and put it on the table by the candle; and then you -looked so good, laying there asleep, that I thought I went and leaned -over and kissed you on the lips." - -"Did you, Tom, DID you! I just forgive you everything for that!" And -she seized the boy in a crushing embrace that made him feel like the -guiltiest of villains. - -"It was very kind, even though it was only a--dream," Sid soliloquized -just audibly. - -"Shut up, Sid! A body does just the same in a dream as he'd do if he -was awake. Here's a big Milum apple I've been saving for you, Tom, if -you was ever found again--now go 'long to school. I'm thankful to the -good God and Father of us all I've got you back, that's long-suffering -and merciful to them that believe on Him and keep His word, though -goodness knows I'm unworthy of it, but if only the worthy ones got His -blessings and had His hand to help them over the rough places, there's -few enough would smile here or ever enter into His rest when the long -night comes. Go 'long Sid, Mary, Tom--take yourselves off--you've -hendered me long enough." - -The children left for school, and the old lady to call on Mrs. Harper -and vanquish her realism with Tom's marvellous dream. Sid had better -judgment than to utter the thought that was in his mind as he left the -house. It was this: "Pretty thin--as long a dream as that, without any -mistakes in it!" - -What a hero Tom was become, now! He did not go skipping and prancing, -but moved with a dignified swagger as became a pirate who felt that the -public eye was on him. And indeed it was; he tried not to seem to see -the looks or hear the remarks as he passed along, but they were food -and drink to him. Smaller boys than himself flocked at his heels, as -proud to be seen with him, and tolerated by him, as if he had been the -drummer at the head of a procession or the elephant leading a menagerie -into town. Boys of his own size pretended not to know he had been away -at all; but they were consuming with envy, nevertheless. They would -have given anything to have that swarthy suntanned skin of his, and his -glittering notoriety; and Tom would not have parted with either for a -circus. - -At school the children made so much of him and of Joe, and delivered -such eloquent admiration from their eyes, that the two heroes were not -long in becoming insufferably "stuck-up." They began to tell their -adventures to hungry listeners--but they only began; it was not a thing -likely to have an end, with imaginations like theirs to furnish -material. And finally, when they got out their pipes and went serenely -puffing around, the very summit of glory was reached. - -Tom decided that he could be independent of Becky Thatcher now. Glory -was sufficient. He would live for glory. Now that he was distinguished, -maybe she would be wanting to "make up." Well, let her--she should see -that he could be as indifferent as some other people. Presently she -arrived. Tom pretended not to see her. He moved away and joined a group -of boys and girls and began to talk. Soon he observed that she was -tripping gayly back and forth with flushed face and dancing eyes, -pretending to be busy chasing schoolmates, and screaming with laughter -when she made a capture; but he noticed that she always made her -captures in his vicinity, and that she seemed to cast a conscious eye -in his direction at such times, too. It gratified all the vicious -vanity that was in him; and so, instead of winning him, it only "set -him up" the more and made him the more diligent to avoid betraying that -he knew she was about. Presently she gave over skylarking, and moved -irresolutely about, sighing once or twice and glancing furtively and -wistfully toward Tom. Then she observed that now Tom was talking more -particularly to Amy Lawrence than to any one else. She felt a sharp -pang and grew disturbed and uneasy at once. She tried to go away, but -her feet were treacherous, and carried her to the group instead. She -said to a girl almost at Tom's elbow--with sham vivacity: - -"Why, Mary Austin! you bad girl, why didn't you come to Sunday-school?" - -"I did come--didn't you see me?" - -"Why, no! Did you? Where did you sit?" - -"I was in Miss Peters' class, where I always go. I saw YOU." - -"Did you? Why, it's funny I didn't see you. I wanted to tell you about -the picnic." - -"Oh, that's jolly. Who's going to give it?" - -"My ma's going to let me have one." - -"Oh, goody; I hope she'll let ME come." - -"Well, she will. The picnic's for me. She'll let anybody come that I -want, and I want you." - -"That's ever so nice. When is it going to be?" - -"By and by. Maybe about vacation." - -"Oh, won't it be fun! You going to have all the girls and boys?" - -"Yes, every one that's friends to me--or wants to be"; and she glanced -ever so furtively at Tom, but he talked right along to Amy Lawrence -about the terrible storm on the island, and how the lightning tore the -great sycamore tree "all to flinders" while he was "standing within -three feet of it." - -"Oh, may I come?" said Grace Miller. - -"Yes." - -"And me?" said Sally Rogers. - -"Yes." - -"And me, too?" said Susy Harper. "And Joe?" - -"Yes." - -And so on, with clapping of joyful hands till all the group had begged -for invitations but Tom and Amy. Then Tom turned coolly away, still -talking, and took Amy with him. Becky's lips trembled and the tears -came to her eyes; she hid these signs with a forced gayety and went on -chattering, but the life had gone out of the picnic, now, and out of -everything else; she got away as soon as she could and hid herself and -had what her sex call "a good cry." Then she sat moody, with wounded -pride, till the bell rang. She roused up, now, with a vindictive cast -in her eye, and gave her plaited tails a shake and said she knew what -SHE'D do. - -At recess Tom continued his flirtation with Amy with jubilant -self-satisfaction. And he kept drifting about to find Becky and lacerate -her with the performance. At last he spied her, but there was a sudden -falling of his mercury. She was sitting cosily on a little bench behind -the schoolhouse looking at a picture-book with Alfred Temple--and so -absorbed were they, and their heads so close together over the book, -that they did not seem to be conscious of anything in the world besides. -Jealousy ran red-hot through Tom's veins. He began to hate himself for -throwing away the chance Becky had offered for a reconciliation. He -called himself a fool, and all the hard names he could think of. He -wanted to cry with vexation. Amy chatted happily along, as they walked, -for her heart was singing, but Tom's tongue had lost its function. He -did not hear what Amy was saying, and whenever she paused expectantly he -could only stammer an awkward assent, which was as often misplaced as -otherwise. He kept drifting to the rear of the schoolhouse, again and -again, to sear his eyeballs with the hateful spectacle there. He could -not help it. And it maddened him to see, as he thought he saw, that -Becky Thatcher never once suspected that he was even in the land of the -living. But she did see, nevertheless; and she knew she was winning her -fight, too, and was glad to see him suffer as she had suffered. - -Amy's happy prattle became intolerable. Tom hinted at things he had to -attend to; things that must be done; and time was fleeting. But in -vain--the girl chirped on. Tom thought, "Oh, hang her, ain't I ever -going to get rid of her?" At last he must be attending to those -things--and she said artlessly that she would be "around" when school -let out. And he hastened away, hating her for it. - -"Any other boy!" Tom thought, grating his teeth. "Any boy in the whole -town but that Saint Louis smarty that thinks he dresses so fine and is -aristocracy! Oh, all right, I licked you the first day you ever saw -this town, mister, and I'll lick you again! You just wait till I catch -you out! I'll just take and--" - -And he went through the motions of thrashing an imaginary boy ---pummelling the air, and kicking and gouging. "Oh, you do, do you? You -holler 'nough, do you? Now, then, let that learn you!" And so the -imaginary flogging was finished to his satisfaction. - -Tom fled home at noon. His conscience could not endure any more of -Amy's grateful happiness, and his jealousy could bear no more of the -other distress. Becky resumed her picture inspections with Alfred, but -as the minutes dragged along and no Tom came to suffer, her triumph -began to cloud and she lost interest; gravity and absent-mindedness -followed, and then melancholy; two or three times she pricked up her -ear at a footstep, but it was a false hope; no Tom came. At last she -grew entirely miserable and wished she hadn't carried it so far. When -poor Alfred, seeing that he was losing her, he did not know how, kept -exclaiming: "Oh, here's a jolly one! look at this!" she lost patience -at last, and said, "Oh, don't bother me! I don't care for them!" and -burst into tears, and got up and walked away. - -Alfred dropped alongside and was going to try to comfort her, but she -said: - -"Go away and leave me alone, can't you! I hate you!" - -So the boy halted, wondering what he could have done--for she had said -she would look at pictures all through the nooning--and she walked on, -crying. Then Alfred went musing into the deserted schoolhouse. He was -humiliated and angry. He easily guessed his way to the truth--the girl -had simply made a convenience of him to vent her spite upon Tom Sawyer. -He was far from hating Tom the less when this thought occurred to him. -He wished there was some way to get that boy into trouble without much -risk to himself. Tom's spelling-book fell under his eye. Here was his -opportunity. He gratefully opened to the lesson for the afternoon and -poured ink upon the page. - -Becky, glancing in at a window behind him at the moment, saw the act, -and moved on, without discovering herself. She started homeward, now, -intending to find Tom and tell him; Tom would be thankful and their -troubles would be healed. Before she was half way home, however, she -had changed her mind. The thought of Tom's treatment of her when she -was talking about her picnic came scorching back and filled her with -shame. She resolved to let him get whipped on the damaged -spelling-book's account, and to hate him forever, into the bargain. - - - -CHAPTER XIX - -TOM arrived at home in a dreary mood, and the first thing his aunt -said to him showed him that he had brought his sorrows to an -unpromising market: - -"Tom, I've a notion to skin you alive!" - -"Auntie, what have I done?" - -"Well, you've done enough. Here I go over to Sereny Harper, like an -old softy, expecting I'm going to make her believe all that rubbage -about that dream, when lo and behold you she'd found out from Joe that -you was over here and heard all the talk we had that night. Tom, I -don't know what is to become of a boy that will act like that. It makes -me feel so bad to think you could let me go to Sereny Harper and make -such a fool of myself and never say a word." - -This was a new aspect of the thing. His smartness of the morning had -seemed to Tom a good joke before, and very ingenious. It merely looked -mean and shabby now. He hung his head and could not think of anything -to say for a moment. Then he said: - -"Auntie, I wish I hadn't done it--but I didn't think." - -"Oh, child, you never think. You never think of anything but your own -selfishness. You could think to come all the way over here from -Jackson's Island in the night to laugh at our troubles, and you could -think to fool me with a lie about a dream; but you couldn't ever think -to pity us and save us from sorrow." - -"Auntie, I know now it was mean, but I didn't mean to be mean. I -didn't, honest. And besides, I didn't come over here to laugh at you -that night." - -"What did you come for, then?" - -"It was to tell you not to be uneasy about us, because we hadn't got -drownded." - -"Tom, Tom, I would be the thankfullest soul in this world if I could -believe you ever had as good a thought as that, but you know you never -did--and I know it, Tom." - -"Indeed and 'deed I did, auntie--I wish I may never stir if I didn't." - -"Oh, Tom, don't lie--don't do it. It only makes things a hundred times -worse." - -"It ain't a lie, auntie; it's the truth. I wanted to keep you from -grieving--that was all that made me come." - -"I'd give the whole world to believe that--it would cover up a power -of sins, Tom. I'd 'most be glad you'd run off and acted so bad. But it -ain't reasonable; because, why didn't you tell me, child?" - -"Why, you see, when you got to talking about the funeral, I just got -all full of the idea of our coming and hiding in the church, and I -couldn't somehow bear to spoil it. So I just put the bark back in my -pocket and kept mum." - -"What bark?" - -"The bark I had wrote on to tell you we'd gone pirating. I wish, now, -you'd waked up when I kissed you--I do, honest." - -The hard lines in his aunt's face relaxed and a sudden tenderness -dawned in her eyes. - -"DID you kiss me, Tom?" - -"Why, yes, I did." - -"Are you sure you did, Tom?" - -"Why, yes, I did, auntie--certain sure." - -"What did you kiss me for, Tom?" - -"Because I loved you so, and you laid there moaning and I was so sorry." - -The words sounded like truth. The old lady could not hide a tremor in -her voice when she said: - -"Kiss me again, Tom!--and be off with you to school, now, and don't -bother me any more." - -The moment he was gone, she ran to a closet and got out the ruin of a -jacket which Tom had gone pirating in. Then she stopped, with it in her -hand, and said to herself: - -"No, I don't dare. Poor boy, I reckon he's lied about it--but it's a -blessed, blessed lie, there's such a comfort come from it. I hope the -Lord--I KNOW the Lord will forgive him, because it was such -goodheartedness in him to tell it. But I don't want to find out it's a -lie. I won't look." - -She put the jacket away, and stood by musing a minute. Twice she put -out her hand to take the garment again, and twice she refrained. Once -more she ventured, and this time she fortified herself with the -thought: "It's a good lie--it's a good lie--I won't let it grieve me." -So she sought the jacket pocket. A moment later she was reading Tom's -piece of bark through flowing tears and saying: "I could forgive the -boy, now, if he'd committed a million sins!" - - - -CHAPTER XX - -THERE was something about Aunt Polly's manner, when she kissed Tom, -that swept away his low spirits and made him lighthearted and happy -again. He started to school and had the luck of coming upon Becky -Thatcher at the head of Meadow Lane. His mood always determined his -manner. Without a moment's hesitation he ran to her and said: - -"I acted mighty mean to-day, Becky, and I'm so sorry. I won't ever, -ever do that way again, as long as ever I live--please make up, won't -you?" - -The girl stopped and looked him scornfully in the face: - -"I'll thank you to keep yourself TO yourself, Mr. Thomas Sawyer. I'll -never speak to you again." - -She tossed her head and passed on. Tom was so stunned that he had not -even presence of mind enough to say "Who cares, Miss Smarty?" until the -right time to say it had gone by. So he said nothing. But he was in a -fine rage, nevertheless. He moped into the schoolyard wishing she were -a boy, and imagining how he would trounce her if she were. He presently -encountered her and delivered a stinging remark as he passed. She -hurled one in return, and the angry breach was complete. It seemed to -Becky, in her hot resentment, that she could hardly wait for school to -"take in," she was so impatient to see Tom flogged for the injured -spelling-book. If she had had any lingering notion of exposing Alfred -Temple, Tom's offensive fling had driven it entirely away. - -Poor girl, she did not know how fast she was nearing trouble herself. -The master, Mr. Dobbins, had reached middle age with an unsatisfied -ambition. The darling of his desires was, to be a doctor, but poverty -had decreed that he should be nothing higher than a village -schoolmaster. Every day he took a mysterious book out of his desk and -absorbed himself in it at times when no classes were reciting. He kept -that book under lock and key. There was not an urchin in school but was -perishing to have a glimpse of it, but the chance never came. Every boy -and girl had a theory about the nature of that book; but no two -theories were alike, and there was no way of getting at the facts in -the case. Now, as Becky was passing by the desk, which stood near the -door, she noticed that the key was in the lock! It was a precious -moment. She glanced around; found herself alone, and the next instant -she had the book in her hands. The title-page--Professor Somebody's -ANATOMY--carried no information to her mind; so she began to turn the -leaves. She came at once upon a handsomely engraved and colored -frontispiece--a human figure, stark naked. At that moment a shadow fell -on the page and Tom Sawyer stepped in at the door and caught a glimpse -of the picture. Becky snatched at the book to close it, and had the -hard luck to tear the pictured page half down the middle. She thrust -the volume into the desk, turned the key, and burst out crying with -shame and vexation. - -"Tom Sawyer, you are just as mean as you can be, to sneak up on a -person and look at what they're looking at." - -"How could I know you was looking at anything?" - -"You ought to be ashamed of yourself, Tom Sawyer; you know you're -going to tell on me, and oh, what shall I do, what shall I do! I'll be -whipped, and I never was whipped in school." - -Then she stamped her little foot and said: - -"BE so mean if you want to! I know something that's going to happen. -You just wait and you'll see! Hateful, hateful, hateful!"--and she -flung out of the house with a new explosion of crying. - -Tom stood still, rather flustered by this onslaught. Presently he said -to himself: - -"What a curious kind of a fool a girl is! Never been licked in school! -Shucks! What's a licking! That's just like a girl--they're so -thin-skinned and chicken-hearted. Well, of course I ain't going to tell -old Dobbins on this little fool, because there's other ways of getting -even on her, that ain't so mean; but what of it? Old Dobbins will ask -who it was tore his book. Nobody'll answer. Then he'll do just the way -he always does--ask first one and then t'other, and when he comes to the -right girl he'll know it, without any telling. Girls' faces always tell -on them. They ain't got any backbone. She'll get licked. Well, it's a -kind of a tight place for Becky Thatcher, because there ain't any way -out of it." Tom conned the thing a moment longer, and then added: "All -right, though; she'd like to see me in just such a fix--let her sweat it -out!" - -Tom joined the mob of skylarking scholars outside. In a few moments -the master arrived and school "took in." Tom did not feel a strong -interest in his studies. Every time he stole a glance at the girls' -side of the room Becky's face troubled him. Considering all things, he -did not want to pity her, and yet it was all he could do to help it. He -could get up no exultation that was really worthy the name. Presently -the spelling-book discovery was made, and Tom's mind was entirely full -of his own matters for a while after that. Becky roused up from her -lethargy of distress and showed good interest in the proceedings. She -did not expect that Tom could get out of his trouble by denying that he -spilt the ink on the book himself; and she was right. The denial only -seemed to make the thing worse for Tom. Becky supposed she would be -glad of that, and she tried to believe she was glad of it, but she -found she was not certain. When the worst came to the worst, she had an -impulse to get up and tell on Alfred Temple, but she made an effort and -forced herself to keep still--because, said she to herself, "he'll tell -about me tearing the picture sure. I wouldn't say a word, not to save -his life!" - -Tom took his whipping and went back to his seat not at all -broken-hearted, for he thought it was possible that he had unknowingly -upset the ink on the spelling-book himself, in some skylarking bout--he -had denied it for form's sake and because it was custom, and had stuck -to the denial from principle. - -A whole hour drifted by, the master sat nodding in his throne, the air -was drowsy with the hum of study. By and by, Mr. Dobbins straightened -himself up, yawned, then unlocked his desk, and reached for his book, -but seemed undecided whether to take it out or leave it. Most of the -pupils glanced up languidly, but there were two among them that watched -his movements with intent eyes. Mr. Dobbins fingered his book absently -for a while, then took it out and settled himself in his chair to read! -Tom shot a glance at Becky. He had seen a hunted and helpless rabbit -look as she did, with a gun levelled at its head. Instantly he forgot -his quarrel with her. Quick--something must be done! done in a flash, -too! But the very imminence of the emergency paralyzed his invention. -Good!--he had an inspiration! He would run and snatch the book, spring -through the door and fly. But his resolution shook for one little -instant, and the chance was lost--the master opened the volume. If Tom -only had the wasted opportunity back again! Too late. There was no help -for Becky now, he said. The next moment the master faced the school. -Every eye sank under his gaze. There was that in it which smote even -the innocent with fear. There was silence while one might count ten ---the master was gathering his wrath. Then he spoke: "Who tore this book?" - -There was not a sound. One could have heard a pin drop. The stillness -continued; the master searched face after face for signs of guilt. - -"Benjamin Rogers, did you tear this book?" - -A denial. Another pause. - -"Joseph Harper, did you?" - -Another denial. Tom's uneasiness grew more and more intense under the -slow torture of these proceedings. The master scanned the ranks of -boys--considered a while, then turned to the girls: - -"Amy Lawrence?" - -A shake of the head. - -"Gracie Miller?" - -The same sign. - -"Susan Harper, did you do this?" - -Another negative. The next girl was Becky Thatcher. Tom was trembling -from head to foot with excitement and a sense of the hopelessness of -the situation. - -"Rebecca Thatcher" [Tom glanced at her face--it was white with terror] ---"did you tear--no, look me in the face" [her hands rose in appeal] ---"did you tear this book?" - -A thought shot like lightning through Tom's brain. He sprang to his -feet and shouted--"I done it!" - -The school stared in perplexity at this incredible folly. Tom stood a -moment, to gather his dismembered faculties; and when he stepped -forward to go to his punishment the surprise, the gratitude, the -adoration that shone upon him out of poor Becky's eyes seemed pay -enough for a hundred floggings. Inspired by the splendor of his own -act, he took without an outcry the most merciless flaying that even Mr. -Dobbins had ever administered; and also received with indifference the -added cruelty of a command to remain two hours after school should be -dismissed--for he knew who would wait for him outside till his -captivity was done, and not count the tedious time as loss, either. - -Tom went to bed that night planning vengeance against Alfred Temple; -for with shame and repentance Becky had told him all, not forgetting -her own treachery; but even the longing for vengeance had to give way, -soon, to pleasanter musings, and he fell asleep at last with Becky's -latest words lingering dreamily in his ear-- - -"Tom, how COULD you be so noble!" - - - -CHAPTER XXI - -VACATION was approaching. The schoolmaster, always severe, grew -severer and more exacting than ever, for he wanted the school to make a -good showing on "Examination" day. His rod and his ferule were seldom -idle now--at least among the smaller pupils. Only the biggest boys, and -young ladies of eighteen and twenty, escaped lashing. Mr. Dobbins' -lashings were very vigorous ones, too; for although he carried, under -his wig, a perfectly bald and shiny head, he had only reached middle -age, and there was no sign of feebleness in his muscle. As the great -day approached, all the tyranny that was in him came to the surface; he -seemed to take a vindictive pleasure in punishing the least -shortcomings. The consequence was, that the smaller boys spent their -days in terror and suffering and their nights in plotting revenge. They -threw away no opportunity to do the master a mischief. But he kept -ahead all the time. The retribution that followed every vengeful -success was so sweeping and majestic that the boys always retired from -the field badly worsted. At last they conspired together and hit upon a -plan that promised a dazzling victory. They swore in the sign-painter's -boy, told him the scheme, and asked his help. He had his own reasons -for being delighted, for the master boarded in his father's family and -had given the boy ample cause to hate him. The master's wife would go -on a visit to the country in a few days, and there would be nothing to -interfere with the plan; the master always prepared himself for great -occasions by getting pretty well fuddled, and the sign-painter's boy -said that when the dominie had reached the proper condition on -Examination Evening he would "manage the thing" while he napped in his -chair; then he would have him awakened at the right time and hurried -away to school. - -In the fulness of time the interesting occasion arrived. At eight in -the evening the schoolhouse was brilliantly lighted, and adorned with -wreaths and festoons of foliage and flowers. The master sat throned in -his great chair upon a raised platform, with his blackboard behind him. -He was looking tolerably mellow. Three rows of benches on each side and -six rows in front of him were occupied by the dignitaries of the town -and by the parents of the pupils. To his left, back of the rows of -citizens, was a spacious temporary platform upon which were seated the -scholars who were to take part in the exercises of the evening; rows of -small boys, washed and dressed to an intolerable state of discomfort; -rows of gawky big boys; snowbanks of girls and young ladies clad in -lawn and muslin and conspicuously conscious of their bare arms, their -grandmothers' ancient trinkets, their bits of pink and blue ribbon and -the flowers in their hair. All the rest of the house was filled with -non-participating scholars. - -The exercises began. A very little boy stood up and sheepishly -recited, "You'd scarce expect one of my age to speak in public on the -stage," etc.--accompanying himself with the painfully exact and -spasmodic gestures which a machine might have used--supposing the -machine to be a trifle out of order. But he got through safely, though -cruelly scared, and got a fine round of applause when he made his -manufactured bow and retired. - -A little shamefaced girl lisped, "Mary had a little lamb," etc., -performed a compassion-inspiring curtsy, got her meed of applause, and -sat down flushed and happy. - -Tom Sawyer stepped forward with conceited confidence and soared into -the unquenchable and indestructible "Give me liberty or give me death" -speech, with fine fury and frantic gesticulation, and broke down in the -middle of it. A ghastly stage-fright seized him, his legs quaked under -him and he was like to choke. True, he had the manifest sympathy of the -house but he had the house's silence, too, which was even worse than -its sympathy. The master frowned, and this completed the disaster. Tom -struggled awhile and then retired, utterly defeated. There was a weak -attempt at applause, but it died early. - -"The Boy Stood on the Burning Deck" followed; also "The Assyrian Came -Down," and other declamatory gems. Then there were reading exercises, -and a spelling fight. The meagre Latin class recited with honor. The -prime feature of the evening was in order, now--original "compositions" -by the young ladies. Each in her turn stepped forward to the edge of -the platform, cleared her throat, held up her manuscript (tied with -dainty ribbon), and proceeded to read, with labored attention to -"expression" and punctuation. The themes were the same that had been -illuminated upon similar occasions by their mothers before them, their -grandmothers, and doubtless all their ancestors in the female line -clear back to the Crusades. "Friendship" was one; "Memories of Other -Days"; "Religion in History"; "Dream Land"; "The Advantages of -Culture"; "Forms of Political Government Compared and Contrasted"; -"Melancholy"; "Filial Love"; "Heart Longings," etc., etc. - -A prevalent feature in these compositions was a nursed and petted -melancholy; another was a wasteful and opulent gush of "fine language"; -another was a tendency to lug in by the ears particularly prized words -and phrases until they were worn entirely out; and a peculiarity that -conspicuously marked and marred them was the inveterate and intolerable -sermon that wagged its crippled tail at the end of each and every one -of them. No matter what the subject might be, a brain-racking effort -was made to squirm it into some aspect or other that the moral and -religious mind could contemplate with edification. The glaring -insincerity of these sermons was not sufficient to compass the -banishment of the fashion from the schools, and it is not sufficient -to-day; it never will be sufficient while the world stands, perhaps. -There is no school in all our land where the young ladies do not feel -obliged to close their compositions with a sermon; and you will find -that the sermon of the most frivolous and the least religious girl in -the school is always the longest and the most relentlessly pious. But -enough of this. Homely truth is unpalatable. - -Let us return to the "Examination." The first composition that was -read was one entitled "Is this, then, Life?" Perhaps the reader can -endure an extract from it: - - "In the common walks of life, with what delightful - emotions does the youthful mind look forward to some - anticipated scene of festivity! Imagination is busy - sketching rose-tinted pictures of joy. In fancy, the - voluptuous votary of fashion sees herself amid the - festive throng, 'the observed of all observers.' Her - graceful form, arrayed in snowy robes, is whirling - through the mazes of the joyous dance; her eye is - brightest, her step is lightest in the gay assembly. - - "In such delicious fancies time quickly glides by, - and the welcome hour arrives for her entrance into - the Elysian world, of which she has had such bright - dreams. How fairy-like does everything appear to - her enchanted vision! Each new scene is more charming - than the last. But after a while she finds that - beneath this goodly exterior, all is vanity, the - flattery which once charmed her soul, now grates - harshly upon her ear; the ball-room has lost its - charms; and with wasted health and imbittered heart, - she turns away with the conviction that earthly - pleasures cannot satisfy the longings of the soul!" - -And so forth and so on. There was a buzz of gratification from time to -time during the reading, accompanied by whispered ejaculations of "How -sweet!" "How eloquent!" "So true!" etc., and after the thing had closed -with a peculiarly afflicting sermon the applause was enthusiastic. - -Then arose a slim, melancholy girl, whose face had the "interesting" -paleness that comes of pills and indigestion, and read a "poem." Two -stanzas of it will do: - - "A MISSOURI MAIDEN'S FAREWELL TO ALABAMA - - "Alabama, good-bye! I love thee well! - But yet for a while do I leave thee now! - Sad, yes, sad thoughts of thee my heart doth swell, - And burning recollections throng my brow! - For I have wandered through thy flowery woods; - Have roamed and read near Tallapoosa's stream; - Have listened to Tallassee's warring floods, - And wooed on Coosa's side Aurora's beam. - - "Yet shame I not to bear an o'er-full heart, - Nor blush to turn behind my tearful eyes; - 'Tis from no stranger land I now must part, - 'Tis to no strangers left I yield these sighs. - Welcome and home were mine within this State, - Whose vales I leave--whose spires fade fast from me - And cold must be mine eyes, and heart, and tete, - When, dear Alabama! they turn cold on thee!" - -There were very few there who knew what "tete" meant, but the poem was -very satisfactory, nevertheless. - -Next appeared a dark-complexioned, black-eyed, black-haired young -lady, who paused an impressive moment, assumed a tragic expression, and -began to read in a measured, solemn tone: - - "A VISION - - "Dark and tempestuous was night. Around the - throne on high not a single star quivered; but - the deep intonations of the heavy thunder - constantly vibrated upon the ear; whilst the - terrific lightning revelled in angry mood - through the cloudy chambers of heaven, seeming - to scorn the power exerted over its terror by - the illustrious Franklin! Even the boisterous - winds unanimously came forth from their mystic - homes, and blustered about as if to enhance by - their aid the wildness of the scene. - - "At such a time, so dark, so dreary, for human - sympathy my very spirit sighed; but instead thereof, - - "'My dearest friend, my counsellor, my comforter - and guide--My joy in grief, my second bliss - in joy,' came to my side. She moved like one of - those bright beings pictured in the sunny walks - of fancy's Eden by the romantic and young, a - queen of beauty unadorned save by her own - transcendent loveliness. So soft was her step, it - failed to make even a sound, and but for the - magical thrill imparted by her genial touch, as - other unobtrusive beauties, she would have glided - away un-perceived--unsought. A strange sadness - rested upon her features, like icy tears upon - the robe of December, as she pointed to the - contending elements without, and bade me contemplate - the two beings presented." - -This nightmare occupied some ten pages of manuscript and wound up with -a sermon so destructive of all hope to non-Presbyterians that it took -the first prize. This composition was considered to be the very finest -effort of the evening. The mayor of the village, in delivering the -prize to the author of it, made a warm speech in which he said that it -was by far the most "eloquent" thing he had ever listened to, and that -Daniel Webster himself might well be proud of it. - -It may be remarked, in passing, that the number of compositions in -which the word "beauteous" was over-fondled, and human experience -referred to as "life's page," was up to the usual average. - -Now the master, mellow almost to the verge of geniality, put his chair -aside, turned his back to the audience, and began to draw a map of -America on the blackboard, to exercise the geography class upon. But he -made a sad business of it with his unsteady hand, and a smothered -titter rippled over the house. He knew what the matter was, and set -himself to right it. He sponged out lines and remade them; but he only -distorted them more than ever, and the tittering was more pronounced. -He threw his entire attention upon his work, now, as if determined not -to be put down by the mirth. He felt that all eyes were fastened upon -him; he imagined he was succeeding, and yet the tittering continued; it -even manifestly increased. And well it might. There was a garret above, -pierced with a scuttle over his head; and down through this scuttle -came a cat, suspended around the haunches by a string; she had a rag -tied about her head and jaws to keep her from mewing; as she slowly -descended she curved upward and clawed at the string, she swung -downward and clawed at the intangible air. The tittering rose higher -and higher--the cat was within six inches of the absorbed teacher's -head--down, down, a little lower, and she grabbed his wig with her -desperate claws, clung to it, and was snatched up into the garret in an -instant with her trophy still in her possession! And how the light did -blaze abroad from the master's bald pate--for the sign-painter's boy -had GILDED it! - -That broke up the meeting. The boys were avenged. Vacation had come. - - NOTE:--The pretended "compositions" quoted in - this chapter are taken without alteration from a - volume entitled "Prose and Poetry, by a Western - Lady"--but they are exactly and precisely after - the schoolgirl pattern, and hence are much - happier than any mere imitations could be. - - - -CHAPTER XXII - -TOM joined the new order of Cadets of Temperance, being attracted by -the showy character of their "regalia." He promised to abstain from -smoking, chewing, and profanity as long as he remained a member. Now he -found out a new thing--namely, that to promise not to do a thing is the -surest way in the world to make a body want to go and do that very -thing. Tom soon found himself tormented with a desire to drink and -swear; the desire grew to be so intense that nothing but the hope of a -chance to display himself in his red sash kept him from withdrawing -from the order. Fourth of July was coming; but he soon gave that up ---gave it up before he had worn his shackles over forty-eight hours--and -fixed his hopes upon old Judge Frazer, justice of the peace, who was -apparently on his deathbed and would have a big public funeral, since -he was so high an official. During three days Tom was deeply concerned -about the Judge's condition and hungry for news of it. Sometimes his -hopes ran high--so high that he would venture to get out his regalia -and practise before the looking-glass. But the Judge had a most -discouraging way of fluctuating. At last he was pronounced upon the -mend--and then convalescent. Tom was disgusted; and felt a sense of -injury, too. He handed in his resignation at once--and that night the -Judge suffered a relapse and died. Tom resolved that he would never -trust a man like that again. - -The funeral was a fine thing. The Cadets paraded in a style calculated -to kill the late member with envy. Tom was a free boy again, however ---there was something in that. He could drink and swear, now--but found -to his surprise that he did not want to. The simple fact that he could, -took the desire away, and the charm of it. - -Tom presently wondered to find that his coveted vacation was beginning -to hang a little heavily on his hands. - -He attempted a diary--but nothing happened during three days, and so -he abandoned it. - -The first of all the negro minstrel shows came to town, and made a -sensation. Tom and Joe Harper got up a band of performers and were -happy for two days. - -Even the Glorious Fourth was in some sense a failure, for it rained -hard, there was no procession in consequence, and the greatest man in -the world (as Tom supposed), Mr. Benton, an actual United States -Senator, proved an overwhelming disappointment--for he was not -twenty-five feet high, nor even anywhere in the neighborhood of it. - -A circus came. The boys played circus for three days afterward in -tents made of rag carpeting--admission, three pins for boys, two for -girls--and then circusing was abandoned. - -A phrenologist and a mesmerizer came--and went again and left the -village duller and drearier than ever. - -There were some boys-and-girls' parties, but they were so few and so -delightful that they only made the aching voids between ache the harder. - -Becky Thatcher was gone to her Constantinople home to stay with her -parents during vacation--so there was no bright side to life anywhere. - -The dreadful secret of the murder was a chronic misery. It was a very -cancer for permanency and pain. - -Then came the measles. - -During two long weeks Tom lay a prisoner, dead to the world and its -happenings. He was very ill, he was interested in nothing. When he got -upon his feet at last and moved feebly down-town, a melancholy change -had come over everything and every creature. There had been a -"revival," and everybody had "got religion," not only the adults, but -even the boys and girls. Tom went about, hoping against hope for the -sight of one blessed sinful face, but disappointment crossed him -everywhere. He found Joe Harper studying a Testament, and turned sadly -away from the depressing spectacle. He sought Ben Rogers, and found him -visiting the poor with a basket of tracts. He hunted up Jim Hollis, who -called his attention to the precious blessing of his late measles as a -warning. Every boy he encountered added another ton to his depression; -and when, in desperation, he flew for refuge at last to the bosom of -Huckleberry Finn and was received with a Scriptural quotation, his -heart broke and he crept home and to bed realizing that he alone of all -the town was lost, forever and forever. - -And that night there came on a terrific storm, with driving rain, -awful claps of thunder and blinding sheets of lightning. He covered his -head with the bedclothes and waited in a horror of suspense for his -doom; for he had not the shadow of a doubt that all this hubbub was -about him. He believed he had taxed the forbearance of the powers above -to the extremity of endurance and that this was the result. It might -have seemed to him a waste of pomp and ammunition to kill a bug with a -battery of artillery, but there seemed nothing incongruous about the -getting up such an expensive thunderstorm as this to knock the turf -from under an insect like himself. - -By and by the tempest spent itself and died without accomplishing its -object. The boy's first impulse was to be grateful, and reform. His -second was to wait--for there might not be any more storms. - -The next day the doctors were back; Tom had relapsed. The three weeks -he spent on his back this time seemed an entire age. When he got abroad -at last he was hardly grateful that he had been spared, remembering how -lonely was his estate, how companionless and forlorn he was. He drifted -listlessly down the street and found Jim Hollis acting as judge in a -juvenile court that was trying a cat for murder, in the presence of her -victim, a bird. He found Joe Harper and Huck Finn up an alley eating a -stolen melon. Poor lads! they--like Tom--had suffered a relapse. - - - -CHAPTER XXIII - -AT last the sleepy atmosphere was stirred--and vigorously: the murder -trial came on in the court. It became the absorbing topic of village -talk immediately. Tom could not get away from it. Every reference to -the murder sent a shudder to his heart, for his troubled conscience and -fears almost persuaded him that these remarks were put forth in his -hearing as "feelers"; he did not see how he could be suspected of -knowing anything about the murder, but still he could not be -comfortable in the midst of this gossip. It kept him in a cold shiver -all the time. He took Huck to a lonely place to have a talk with him. -It would be some relief to unseal his tongue for a little while; to -divide his burden of distress with another sufferer. Moreover, he -wanted to assure himself that Huck had remained discreet. - -"Huck, have you ever told anybody about--that?" - -"'Bout what?" - -"You know what." - -"Oh--'course I haven't." - -"Never a word?" - -"Never a solitary word, so help me. What makes you ask?" - -"Well, I was afeard." - -"Why, Tom Sawyer, we wouldn't be alive two days if that got found out. -YOU know that." - -Tom felt more comfortable. After a pause: - -"Huck, they couldn't anybody get you to tell, could they?" - -"Get me to tell? Why, if I wanted that half-breed devil to drownd me -they could get me to tell. They ain't no different way." - -"Well, that's all right, then. I reckon we're safe as long as we keep -mum. But let's swear again, anyway. It's more surer." - -"I'm agreed." - -So they swore again with dread solemnities. - -"What is the talk around, Huck? I've heard a power of it." - -"Talk? Well, it's just Muff Potter, Muff Potter, Muff Potter all the -time. It keeps me in a sweat, constant, so's I want to hide som'ers." - -"That's just the same way they go on round me. I reckon he's a goner. -Don't you feel sorry for him, sometimes?" - -"Most always--most always. He ain't no account; but then he hain't -ever done anything to hurt anybody. Just fishes a little, to get money -to get drunk on--and loafs around considerable; but lord, we all do -that--leastways most of us--preachers and such like. But he's kind of -good--he give me half a fish, once, when there warn't enough for two; -and lots of times he's kind of stood by me when I was out of luck." - -"Well, he's mended kites for me, Huck, and knitted hooks on to my -line. I wish we could get him out of there." - -"My! we couldn't get him out, Tom. And besides, 'twouldn't do any -good; they'd ketch him again." - -"Yes--so they would. But I hate to hear 'em abuse him so like the -dickens when he never done--that." - -"I do too, Tom. Lord, I hear 'em say he's the bloodiest looking -villain in this country, and they wonder he wasn't ever hung before." - -"Yes, they talk like that, all the time. I've heard 'em say that if he -was to get free they'd lynch him." - -"And they'd do it, too." - -The boys had a long talk, but it brought them little comfort. As the -twilight drew on, they found themselves hanging about the neighborhood -of the little isolated jail, perhaps with an undefined hope that -something would happen that might clear away their difficulties. But -nothing happened; there seemed to be no angels or fairies interested in -this luckless captive. - -The boys did as they had often done before--went to the cell grating -and gave Potter some tobacco and matches. He was on the ground floor -and there were no guards. - -His gratitude for their gifts had always smote their consciences -before--it cut deeper than ever, this time. They felt cowardly and -treacherous to the last degree when Potter said: - -"You've been mighty good to me, boys--better'n anybody else in this -town. And I don't forget it, I don't. Often I says to myself, says I, -'I used to mend all the boys' kites and things, and show 'em where the -good fishin' places was, and befriend 'em what I could, and now they've -all forgot old Muff when he's in trouble; but Tom don't, and Huck -don't--THEY don't forget him, says I, 'and I don't forget them.' Well, -boys, I done an awful thing--drunk and crazy at the time--that's the -only way I account for it--and now I got to swing for it, and it's -right. Right, and BEST, too, I reckon--hope so, anyway. Well, we won't -talk about that. I don't want to make YOU feel bad; you've befriended -me. But what I want to say, is, don't YOU ever get drunk--then you won't -ever get here. Stand a litter furder west--so--that's it; it's a prime -comfort to see faces that's friendly when a body's in such a muck of -trouble, and there don't none come here but yourn. Good friendly -faces--good friendly faces. Git up on one another's backs and let me -touch 'em. That's it. Shake hands--yourn'll come through the bars, but -mine's too big. Little hands, and weak--but they've helped Muff Potter -a power, and they'd help him more if they could." - -Tom went home miserable, and his dreams that night were full of -horrors. The next day and the day after, he hung about the court-room, -drawn by an almost irresistible impulse to go in, but forcing himself -to stay out. Huck was having the same experience. They studiously -avoided each other. Each wandered away, from time to time, but the same -dismal fascination always brought them back presently. Tom kept his -ears open when idlers sauntered out of the court-room, but invariably -heard distressing news--the toils were closing more and more -relentlessly around poor Potter. At the end of the second day the -village talk was to the effect that Injun Joe's evidence stood firm and -unshaken, and that there was not the slightest question as to what the -jury's verdict would be. - -Tom was out late, that night, and came to bed through the window. He -was in a tremendous state of excitement. It was hours before he got to -sleep. All the village flocked to the court-house the next morning, for -this was to be the great day. Both sexes were about equally represented -in the packed audience. After a long wait the jury filed in and took -their places; shortly afterward, Potter, pale and haggard, timid and -hopeless, was brought in, with chains upon him, and seated where all -the curious eyes could stare at him; no less conspicuous was Injun Joe, -stolid as ever. There was another pause, and then the judge arrived and -the sheriff proclaimed the opening of the court. The usual whisperings -among the lawyers and gathering together of papers followed. These -details and accompanying delays worked up an atmosphere of preparation -that was as impressive as it was fascinating. - -Now a witness was called who testified that he found Muff Potter -washing in the brook, at an early hour of the morning that the murder -was discovered, and that he immediately sneaked away. After some -further questioning, counsel for the prosecution said: - -"Take the witness." - -The prisoner raised his eyes for a moment, but dropped them again when -his own counsel said: - -"I have no questions to ask him." - -The next witness proved the finding of the knife near the corpse. -Counsel for the prosecution said: - -"Take the witness." - -"I have no questions to ask him," Potter's lawyer replied. - -A third witness swore he had often seen the knife in Potter's -possession. - -"Take the witness." - -Counsel for Potter declined to question him. The faces of the audience -began to betray annoyance. Did this attorney mean to throw away his -client's life without an effort? - -Several witnesses deposed concerning Potter's guilty behavior when -brought to the scene of the murder. They were allowed to leave the -stand without being cross-questioned. - -Every detail of the damaging circumstances that occurred in the -graveyard upon that morning which all present remembered so well was -brought out by credible witnesses, but none of them were cross-examined -by Potter's lawyer. The perplexity and dissatisfaction of the house -expressed itself in murmurs and provoked a reproof from the bench. -Counsel for the prosecution now said: - -"By the oaths of citizens whose simple word is above suspicion, we -have fastened this awful crime, beyond all possibility of question, -upon the unhappy prisoner at the bar. We rest our case here." - -A groan escaped from poor Potter, and he put his face in his hands and -rocked his body softly to and fro, while a painful silence reigned in -the court-room. Many men were moved, and many women's compassion -testified itself in tears. Counsel for the defence rose and said: - -"Your honor, in our remarks at the opening of this trial, we -foreshadowed our purpose to prove that our client did this fearful deed -while under the influence of a blind and irresponsible delirium -produced by drink. We have changed our mind. We shall not offer that -plea." [Then to the clerk:] "Call Thomas Sawyer!" - -A puzzled amazement awoke in every face in the house, not even -excepting Potter's. Every eye fastened itself with wondering interest -upon Tom as he rose and took his place upon the stand. The boy looked -wild enough, for he was badly scared. The oath was administered. - -"Thomas Sawyer, where were you on the seventeenth of June, about the -hour of midnight?" - -Tom glanced at Injun Joe's iron face and his tongue failed him. The -audience listened breathless, but the words refused to come. After a -few moments, however, the boy got a little of his strength back, and -managed to put enough of it into his voice to make part of the house -hear: - -"In the graveyard!" - -"A little bit louder, please. Don't be afraid. You were--" - -"In the graveyard." - -A contemptuous smile flitted across Injun Joe's face. - -"Were you anywhere near Horse Williams' grave?" - -"Yes, sir." - -"Speak up--just a trifle louder. How near were you?" - -"Near as I am to you." - -"Were you hidden, or not?" - -"I was hid." - -"Where?" - -"Behind the elms that's on the edge of the grave." - -Injun Joe gave a barely perceptible start. - -"Any one with you?" - -"Yes, sir. I went there with--" - -"Wait--wait a moment. Never mind mentioning your companion's name. We -will produce him at the proper time. Did you carry anything there with -you." - -Tom hesitated and looked confused. - -"Speak out, my boy--don't be diffident. The truth is always -respectable. What did you take there?" - -"Only a--a--dead cat." - -There was a ripple of mirth, which the court checked. - -"We will produce the skeleton of that cat. Now, my boy, tell us -everything that occurred--tell it in your own way--don't skip anything, -and don't be afraid." - -Tom began--hesitatingly at first, but as he warmed to his subject his -words flowed more and more easily; in a little while every sound ceased -but his own voice; every eye fixed itself upon him; with parted lips -and bated breath the audience hung upon his words, taking no note of -time, rapt in the ghastly fascinations of the tale. The strain upon -pent emotion reached its climax when the boy said: - -"--and as the doctor fetched the board around and Muff Potter fell, -Injun Joe jumped with the knife and--" - -Crash! Quick as lightning the half-breed sprang for a window, tore his -way through all opposers, and was gone! - - - -CHAPTER XXIV - -TOM was a glittering hero once more--the pet of the old, the envy of -the young. His name even went into immortal print, for the village -paper magnified him. There were some that believed he would be -President, yet, if he escaped hanging. - -As usual, the fickle, unreasoning world took Muff Potter to its bosom -and fondled him as lavishly as it had abused him before. But that sort -of conduct is to the world's credit; therefore it is not well to find -fault with it. - -Tom's days were days of splendor and exultation to him, but his nights -were seasons of horror. Injun Joe infested all his dreams, and always -with doom in his eye. Hardly any temptation could persuade the boy to -stir abroad after nightfall. Poor Huck was in the same state of -wretchedness and terror, for Tom had told the whole story to the lawyer -the night before the great day of the trial, and Huck was sore afraid -that his share in the business might leak out, yet, notwithstanding -Injun Joe's flight had saved him the suffering of testifying in court. -The poor fellow had got the attorney to promise secrecy, but what of -that? Since Tom's harassed conscience had managed to drive him to the -lawyer's house by night and wring a dread tale from lips that had been -sealed with the dismalest and most formidable of oaths, Huck's -confidence in the human race was well-nigh obliterated. - -Daily Muff Potter's gratitude made Tom glad he had spoken; but nightly -he wished he had sealed up his tongue. - -Half the time Tom was afraid Injun Joe would never be captured; the -other half he was afraid he would be. He felt sure he never could draw -a safe breath again until that man was dead and he had seen the corpse. - -Rewards had been offered, the country had been scoured, but no Injun -Joe was found. One of those omniscient and awe-inspiring marvels, a -detective, came up from St. Louis, moused around, shook his head, -looked wise, and made that sort of astounding success which members of -that craft usually achieve. That is to say, he "found a clew." But you -can't hang a "clew" for murder, and so after that detective had got -through and gone home, Tom felt just as insecure as he was before. - -The slow days drifted on, and each left behind it a slightly lightened -weight of apprehension. - - - -CHAPTER XXV - -THERE comes a time in every rightly-constructed boy's life when he has -a raging desire to go somewhere and dig for hidden treasure. This -desire suddenly came upon Tom one day. He sallied out to find Joe -Harper, but failed of success. Next he sought Ben Rogers; he had gone -fishing. Presently he stumbled upon Huck Finn the Red-Handed. Huck -would answer. Tom took him to a private place and opened the matter to -him confidentially. Huck was willing. Huck was always willing to take a -hand in any enterprise that offered entertainment and required no -capital, for he had a troublesome superabundance of that sort of time -which is not money. "Where'll we dig?" said Huck. - -"Oh, most anywhere." - -"Why, is it hid all around?" - -"No, indeed it ain't. It's hid in mighty particular places, Huck ---sometimes on islands, sometimes in rotten chests under the end of a -limb of an old dead tree, just where the shadow falls at midnight; but -mostly under the floor in ha'nted houses." - -"Who hides it?" - -"Why, robbers, of course--who'd you reckon? Sunday-school -sup'rintendents?" - -"I don't know. If 'twas mine I wouldn't hide it; I'd spend it and have -a good time." - -"So would I. But robbers don't do that way. They always hide it and -leave it there." - -"Don't they come after it any more?" - -"No, they think they will, but they generally forget the marks, or -else they die. Anyway, it lays there a long time and gets rusty; and by -and by somebody finds an old yellow paper that tells how to find the -marks--a paper that's got to be ciphered over about a week because it's -mostly signs and hy'roglyphics." - -"Hyro--which?" - -"Hy'roglyphics--pictures and things, you know, that don't seem to mean -anything." - -"Have you got one of them papers, Tom?" - -"No." - -"Well then, how you going to find the marks?" - -"I don't want any marks. They always bury it under a ha'nted house or -on an island, or under a dead tree that's got one limb sticking out. -Well, we've tried Jackson's Island a little, and we can try it again -some time; and there's the old ha'nted house up the Still-House branch, -and there's lots of dead-limb trees--dead loads of 'em." - -"Is it under all of them?" - -"How you talk! No!" - -"Then how you going to know which one to go for?" - -"Go for all of 'em!" - -"Why, Tom, it'll take all summer." - -"Well, what of that? Suppose you find a brass pot with a hundred -dollars in it, all rusty and gray, or rotten chest full of di'monds. -How's that?" - -Huck's eyes glowed. - -"That's bully. Plenty bully enough for me. Just you gimme the hundred -dollars and I don't want no di'monds." - -"All right. But I bet you I ain't going to throw off on di'monds. Some -of 'em's worth twenty dollars apiece--there ain't any, hardly, but's -worth six bits or a dollar." - -"No! Is that so?" - -"Cert'nly--anybody'll tell you so. Hain't you ever seen one, Huck?" - -"Not as I remember." - -"Oh, kings have slathers of them." - -"Well, I don' know no kings, Tom." - -"I reckon you don't. But if you was to go to Europe you'd see a raft -of 'em hopping around." - -"Do they hop?" - -"Hop?--your granny! No!" - -"Well, what did you say they did, for?" - -"Shucks, I only meant you'd SEE 'em--not hopping, of course--what do -they want to hop for?--but I mean you'd just see 'em--scattered around, -you know, in a kind of a general way. Like that old humpbacked Richard." - -"Richard? What's his other name?" - -"He didn't have any other name. Kings don't have any but a given name." - -"No?" - -"But they don't." - -"Well, if they like it, Tom, all right; but I don't want to be a king -and have only just a given name, like a nigger. But say--where you -going to dig first?" - -"Well, I don't know. S'pose we tackle that old dead-limb tree on the -hill t'other side of Still-House branch?" - -"I'm agreed." - -So they got a crippled pick and a shovel, and set out on their -three-mile tramp. They arrived hot and panting, and threw themselves -down in the shade of a neighboring elm to rest and have a smoke. - -"I like this," said Tom. - -"So do I." - -"Say, Huck, if we find a treasure here, what you going to do with your -share?" - -"Well, I'll have pie and a glass of soda every day, and I'll go to -every circus that comes along. I bet I'll have a gay time." - -"Well, ain't you going to save any of it?" - -"Save it? What for?" - -"Why, so as to have something to live on, by and by." - -"Oh, that ain't any use. Pap would come back to thish-yer town some -day and get his claws on it if I didn't hurry up, and I tell you he'd -clean it out pretty quick. What you going to do with yourn, Tom?" - -"I'm going to buy a new drum, and a sure-'nough sword, and a red -necktie and a bull pup, and get married." - -"Married!" - -"That's it." - -"Tom, you--why, you ain't in your right mind." - -"Wait--you'll see." - -"Well, that's the foolishest thing you could do. Look at pap and my -mother. Fight! Why, they used to fight all the time. I remember, mighty -well." - -"That ain't anything. The girl I'm going to marry won't fight." - -"Tom, I reckon they're all alike. They'll all comb a body. Now you -better think 'bout this awhile. I tell you you better. What's the name -of the gal?" - -"It ain't a gal at all--it's a girl." - -"It's all the same, I reckon; some says gal, some says girl--both's -right, like enough. Anyway, what's her name, Tom?" - -"I'll tell you some time--not now." - -"All right--that'll do. Only if you get married I'll be more lonesomer -than ever." - -"No you won't. You'll come and live with me. Now stir out of this and -we'll go to digging." - -They worked and sweated for half an hour. No result. They toiled -another half-hour. Still no result. Huck said: - -"Do they always bury it as deep as this?" - -"Sometimes--not always. Not generally. I reckon we haven't got the -right place." - -So they chose a new spot and began again. The labor dragged a little, -but still they made progress. They pegged away in silence for some -time. Finally Huck leaned on his shovel, swabbed the beaded drops from -his brow with his sleeve, and said: - -"Where you going to dig next, after we get this one?" - -"I reckon maybe we'll tackle the old tree that's over yonder on -Cardiff Hill back of the widow's." - -"I reckon that'll be a good one. But won't the widow take it away from -us, Tom? It's on her land." - -"SHE take it away! Maybe she'd like to try it once. Whoever finds one -of these hid treasures, it belongs to him. It don't make any difference -whose land it's on." - -That was satisfactory. The work went on. By and by Huck said: - -"Blame it, we must be in the wrong place again. What do you think?" - -"It is mighty curious, Huck. I don't understand it. Sometimes witches -interfere. I reckon maybe that's what's the trouble now." - -"Shucks! Witches ain't got no power in the daytime." - -"Well, that's so. I didn't think of that. Oh, I know what the matter -is! What a blamed lot of fools we are! You got to find out where the -shadow of the limb falls at midnight, and that's where you dig!" - -"Then consound it, we've fooled away all this work for nothing. Now -hang it all, we got to come back in the night. It's an awful long way. -Can you get out?" - -"I bet I will. We've got to do it to-night, too, because if somebody -sees these holes they'll know in a minute what's here and they'll go -for it." - -"Well, I'll come around and maow to-night." - -"All right. Let's hide the tools in the bushes." - -The boys were there that night, about the appointed time. They sat in -the shadow waiting. It was a lonely place, and an hour made solemn by -old traditions. Spirits whispered in the rustling leaves, ghosts lurked -in the murky nooks, the deep baying of a hound floated up out of the -distance, an owl answered with his sepulchral note. The boys were -subdued by these solemnities, and talked little. By and by they judged -that twelve had come; they marked where the shadow fell, and began to -dig. Their hopes commenced to rise. Their interest grew stronger, and -their industry kept pace with it. The hole deepened and still deepened, -but every time their hearts jumped to hear the pick strike upon -something, they only suffered a new disappointment. It was only a stone -or a chunk. At last Tom said: - -"It ain't any use, Huck, we're wrong again." - -"Well, but we CAN'T be wrong. We spotted the shadder to a dot." - -"I know it, but then there's another thing." - -"What's that?". - -"Why, we only guessed at the time. Like enough it was too late or too -early." - -Huck dropped his shovel. - -"That's it," said he. "That's the very trouble. We got to give this -one up. We can't ever tell the right time, and besides this kind of -thing's too awful, here this time of night with witches and ghosts -a-fluttering around so. I feel as if something's behind me all the time; -and I'm afeard to turn around, becuz maybe there's others in front -a-waiting for a chance. I been creeping all over, ever since I got here." - -"Well, I've been pretty much so, too, Huck. They most always put in a -dead man when they bury a treasure under a tree, to look out for it." - -"Lordy!" - -"Yes, they do. I've always heard that." - -"Tom, I don't like to fool around much where there's dead people. A -body's bound to get into trouble with 'em, sure." - -"I don't like to stir 'em up, either. S'pose this one here was to -stick his skull out and say something!" - -"Don't Tom! It's awful." - -"Well, it just is. Huck, I don't feel comfortable a bit." - -"Say, Tom, let's give this place up, and try somewheres else." - -"All right, I reckon we better." - -"What'll it be?" - -Tom considered awhile; and then said: - -"The ha'nted house. That's it!" - -"Blame it, I don't like ha'nted houses, Tom. Why, they're a dern sight -worse'n dead people. Dead people might talk, maybe, but they don't come -sliding around in a shroud, when you ain't noticing, and peep over your -shoulder all of a sudden and grit their teeth, the way a ghost does. I -couldn't stand such a thing as that, Tom--nobody could." - -"Yes, but, Huck, ghosts don't travel around only at night. They won't -hender us from digging there in the daytime." - -"Well, that's so. But you know mighty well people don't go about that -ha'nted house in the day nor the night." - -"Well, that's mostly because they don't like to go where a man's been -murdered, anyway--but nothing's ever been seen around that house except -in the night--just some blue lights slipping by the windows--no regular -ghosts." - -"Well, where you see one of them blue lights flickering around, Tom, -you can bet there's a ghost mighty close behind it. It stands to -reason. Becuz you know that they don't anybody but ghosts use 'em." - -"Yes, that's so. But anyway they don't come around in the daytime, so -what's the use of our being afeard?" - -"Well, all right. We'll tackle the ha'nted house if you say so--but I -reckon it's taking chances." - -They had started down the hill by this time. There in the middle of -the moonlit valley below them stood the "ha'nted" house, utterly -isolated, its fences gone long ago, rank weeds smothering the very -doorsteps, the chimney crumbled to ruin, the window-sashes vacant, a -corner of the roof caved in. The boys gazed awhile, half expecting to -see a blue light flit past a window; then talking in a low tone, as -befitted the time and the circumstances, they struck far off to the -right, to give the haunted house a wide berth, and took their way -homeward through the woods that adorned the rearward side of Cardiff -Hill. - - - -CHAPTER XXVI - -ABOUT noon the next day the boys arrived at the dead tree; they had -come for their tools. Tom was impatient to go to the haunted house; -Huck was measurably so, also--but suddenly said: - -"Lookyhere, Tom, do you know what day it is?" - -Tom mentally ran over the days of the week, and then quickly lifted -his eyes with a startled look in them-- - -"My! I never once thought of it, Huck!" - -"Well, I didn't neither, but all at once it popped onto me that it was -Friday." - -"Blame it, a body can't be too careful, Huck. We might 'a' got into an -awful scrape, tackling such a thing on a Friday." - -"MIGHT! Better say we WOULD! There's some lucky days, maybe, but -Friday ain't." - -"Any fool knows that. I don't reckon YOU was the first that found it -out, Huck." - -"Well, I never said I was, did I? And Friday ain't all, neither. I had -a rotten bad dream last night--dreampt about rats." - -"No! Sure sign of trouble. Did they fight?" - -"No." - -"Well, that's good, Huck. When they don't fight it's only a sign that -there's trouble around, you know. All we got to do is to look mighty -sharp and keep out of it. We'll drop this thing for to-day, and play. -Do you know Robin Hood, Huck?" - -"No. Who's Robin Hood?" - -"Why, he was one of the greatest men that was ever in England--and the -best. He was a robber." - -"Cracky, I wisht I was. Who did he rob?" - -"Only sheriffs and bishops and rich people and kings, and such like. -But he never bothered the poor. He loved 'em. He always divided up with -'em perfectly square." - -"Well, he must 'a' been a brick." - -"I bet you he was, Huck. Oh, he was the noblest man that ever was. -They ain't any such men now, I can tell you. He could lick any man in -England, with one hand tied behind him; and he could take his yew bow -and plug a ten-cent piece every time, a mile and a half." - -"What's a YEW bow?" - -"I don't know. It's some kind of a bow, of course. And if he hit that -dime only on the edge he would set down and cry--and curse. But we'll -play Robin Hood--it's nobby fun. I'll learn you." - -"I'm agreed." - -So they played Robin Hood all the afternoon, now and then casting a -yearning eye down upon the haunted house and passing a remark about the -morrow's prospects and possibilities there. As the sun began to sink -into the west they took their way homeward athwart the long shadows of -the trees and soon were buried from sight in the forests of Cardiff -Hill. - -On Saturday, shortly after noon, the boys were at the dead tree again. -They had a smoke and a chat in the shade, and then dug a little in -their last hole, not with great hope, but merely because Tom said there -were so many cases where people had given up a treasure after getting -down within six inches of it, and then somebody else had come along and -turned it up with a single thrust of a shovel. The thing failed this -time, however, so the boys shouldered their tools and went away feeling -that they had not trifled with fortune, but had fulfilled all the -requirements that belong to the business of treasure-hunting. - -When they reached the haunted house there was something so weird and -grisly about the dead silence that reigned there under the baking sun, -and something so depressing about the loneliness and desolation of the -place, that they were afraid, for a moment, to venture in. Then they -crept to the door and took a trembling peep. They saw a weed-grown, -floorless room, unplastered, an ancient fireplace, vacant windows, a -ruinous staircase; and here, there, and everywhere hung ragged and -abandoned cobwebs. They presently entered, softly, with quickened -pulses, talking in whispers, ears alert to catch the slightest sound, -and muscles tense and ready for instant retreat. - -In a little while familiarity modified their fears and they gave the -place a critical and interested examination, rather admiring their own -boldness, and wondering at it, too. Next they wanted to look up-stairs. -This was something like cutting off retreat, but they got to daring -each other, and of course there could be but one result--they threw -their tools into a corner and made the ascent. Up there were the same -signs of decay. In one corner they found a closet that promised -mystery, but the promise was a fraud--there was nothing in it. Their -courage was up now and well in hand. They were about to go down and -begin work when-- - -"Sh!" said Tom. - -"What is it?" whispered Huck, blanching with fright. - -"Sh!... There!... Hear it?" - -"Yes!... Oh, my! Let's run!" - -"Keep still! Don't you budge! They're coming right toward the door." - -The boys stretched themselves upon the floor with their eyes to -knot-holes in the planking, and lay waiting, in a misery of fear. - -"They've stopped.... No--coming.... Here they are. Don't whisper -another word, Huck. My goodness, I wish I was out of this!" - -Two men entered. Each boy said to himself: "There's the old deaf and -dumb Spaniard that's been about town once or twice lately--never saw -t'other man before." - -"T'other" was a ragged, unkempt creature, with nothing very pleasant -in his face. The Spaniard was wrapped in a serape; he had bushy white -whiskers; long white hair flowed from under his sombrero, and he wore -green goggles. When they came in, "t'other" was talking in a low voice; -they sat down on the ground, facing the door, with their backs to the -wall, and the speaker continued his remarks. His manner became less -guarded and his words more distinct as he proceeded: - -"No," said he, "I've thought it all over, and I don't like it. It's -dangerous." - -"Dangerous!" grunted the "deaf and dumb" Spaniard--to the vast -surprise of the boys. "Milksop!" - -This voice made the boys gasp and quake. It was Injun Joe's! There was -silence for some time. Then Joe said: - -"What's any more dangerous than that job up yonder--but nothing's come -of it." - -"That's different. Away up the river so, and not another house about. -'Twon't ever be known that we tried, anyway, long as we didn't succeed." - -"Well, what's more dangerous than coming here in the daytime!--anybody -would suspicion us that saw us." - -"I know that. But there warn't any other place as handy after that -fool of a job. I want to quit this shanty. I wanted to yesterday, only -it warn't any use trying to stir out of here, with those infernal boys -playing over there on the hill right in full view." - -"Those infernal boys" quaked again under the inspiration of this -remark, and thought how lucky it was that they had remembered it was -Friday and concluded to wait a day. They wished in their hearts they -had waited a year. - -The two men got out some food and made a luncheon. After a long and -thoughtful silence, Injun Joe said: - -"Look here, lad--you go back up the river where you belong. Wait there -till you hear from me. I'll take the chances on dropping into this town -just once more, for a look. We'll do that 'dangerous' job after I've -spied around a little and think things look well for it. Then for -Texas! We'll leg it together!" - -This was satisfactory. Both men presently fell to yawning, and Injun -Joe said: - -"I'm dead for sleep! It's your turn to watch." - -He curled down in the weeds and soon began to snore. His comrade -stirred him once or twice and he became quiet. Presently the watcher -began to nod; his head drooped lower and lower, both men began to snore -now. - -The boys drew a long, grateful breath. Tom whispered: - -"Now's our chance--come!" - -Huck said: - -"I can't--I'd die if they was to wake." - -Tom urged--Huck held back. At last Tom rose slowly and softly, and -started alone. But the first step he made wrung such a hideous creak -from the crazy floor that he sank down almost dead with fright. He -never made a second attempt. The boys lay there counting the dragging -moments till it seemed to them that time must be done and eternity -growing gray; and then they were grateful to note that at last the sun -was setting. - -Now one snore ceased. Injun Joe sat up, stared around--smiled grimly -upon his comrade, whose head was drooping upon his knees--stirred him -up with his foot and said: - -"Here! YOU'RE a watchman, ain't you! All right, though--nothing's -happened." - -"My! have I been asleep?" - -"Oh, partly, partly. Nearly time for us to be moving, pard. What'll we -do with what little swag we've got left?" - -"I don't know--leave it here as we've always done, I reckon. No use to -take it away till we start south. Six hundred and fifty in silver's -something to carry." - -"Well--all right--it won't matter to come here once more." - -"No--but I'd say come in the night as we used to do--it's better." - -"Yes: but look here; it may be a good while before I get the right -chance at that job; accidents might happen; 'tain't in such a very good -place; we'll just regularly bury it--and bury it deep." - -"Good idea," said the comrade, who walked across the room, knelt down, -raised one of the rearward hearth-stones and took out a bag that -jingled pleasantly. He subtracted from it twenty or thirty dollars for -himself and as much for Injun Joe, and passed the bag to the latter, -who was on his knees in the corner, now, digging with his bowie-knife. - -The boys forgot all their fears, all their miseries in an instant. -With gloating eyes they watched every movement. Luck!--the splendor of -it was beyond all imagination! Six hundred dollars was money enough to -make half a dozen boys rich! Here was treasure-hunting under the -happiest auspices--there would not be any bothersome uncertainty as to -where to dig. They nudged each other every moment--eloquent nudges and -easily understood, for they simply meant--"Oh, but ain't you glad NOW -we're here!" - -Joe's knife struck upon something. - -"Hello!" said he. - -"What is it?" said his comrade. - -"Half-rotten plank--no, it's a box, I believe. Here--bear a hand and -we'll see what it's here for. Never mind, I've broke a hole." - -He reached his hand in and drew it out-- - -"Man, it's money!" - -The two men examined the handful of coins. They were gold. The boys -above were as excited as themselves, and as delighted. - -Joe's comrade said: - -"We'll make quick work of this. There's an old rusty pick over amongst -the weeds in the corner the other side of the fireplace--I saw it a -minute ago." - -He ran and brought the boys' pick and shovel. Injun Joe took the pick, -looked it over critically, shook his head, muttered something to -himself, and then began to use it. The box was soon unearthed. It was -not very large; it was iron bound and had been very strong before the -slow years had injured it. The men contemplated the treasure awhile in -blissful silence. - -"Pard, there's thousands of dollars here," said Injun Joe. - -"'Twas always said that Murrel's gang used to be around here one -summer," the stranger observed. - -"I know it," said Injun Joe; "and this looks like it, I should say." - -"Now you won't need to do that job." - -The half-breed frowned. Said he: - -"You don't know me. Least you don't know all about that thing. 'Tain't -robbery altogether--it's REVENGE!" and a wicked light flamed in his -eyes. "I'll need your help in it. When it's finished--then Texas. Go -home to your Nance and your kids, and stand by till you hear from me." - -"Well--if you say so; what'll we do with this--bury it again?" - -"Yes. [Ravishing delight overhead.] NO! by the great Sachem, no! -[Profound distress overhead.] I'd nearly forgot. That pick had fresh -earth on it! [The boys were sick with terror in a moment.] What -business has a pick and a shovel here? What business with fresh earth -on them? Who brought them here--and where are they gone? Have you heard -anybody?--seen anybody? What! bury it again and leave them to come and -see the ground disturbed? Not exactly--not exactly. We'll take it to my -den." - -"Why, of course! Might have thought of that before. You mean Number -One?" - -"No--Number Two--under the cross. The other place is bad--too common." - -"All right. It's nearly dark enough to start." - -Injun Joe got up and went about from window to window cautiously -peeping out. Presently he said: - -"Who could have brought those tools here? Do you reckon they can be -up-stairs?" - -The boys' breath forsook them. Injun Joe put his hand on his knife, -halted a moment, undecided, and then turned toward the stairway. The -boys thought of the closet, but their strength was gone. The steps came -creaking up the stairs--the intolerable distress of the situation woke -the stricken resolution of the lads--they were about to spring for the -closet, when there was a crash of rotten timbers and Injun Joe landed -on the ground amid the debris of the ruined stairway. He gathered -himself up cursing, and his comrade said: - -"Now what's the use of all that? If it's anybody, and they're up -there, let them STAY there--who cares? If they want to jump down, now, -and get into trouble, who objects? It will be dark in fifteen minutes ---and then let them follow us if they want to. I'm willing. In my -opinion, whoever hove those things in here caught a sight of us and -took us for ghosts or devils or something. I'll bet they're running -yet." - -Joe grumbled awhile; then he agreed with his friend that what daylight -was left ought to be economized in getting things ready for leaving. -Shortly afterward they slipped out of the house in the deepening -twilight, and moved toward the river with their precious box. - -Tom and Huck rose up, weak but vastly relieved, and stared after them -through the chinks between the logs of the house. Follow? Not they. -They were content to reach ground again without broken necks, and take -the townward track over the hill. They did not talk much. They were too -much absorbed in hating themselves--hating the ill luck that made them -take the spade and the pick there. But for that, Injun Joe never would -have suspected. He would have hidden the silver with the gold to wait -there till his "revenge" was satisfied, and then he would have had the -misfortune to find that money turn up missing. Bitter, bitter luck that -the tools were ever brought there! - -They resolved to keep a lookout for that Spaniard when he should come -to town spying out for chances to do his revengeful job, and follow him -to "Number Two," wherever that might be. Then a ghastly thought -occurred to Tom. - -"Revenge? What if he means US, Huck!" - -"Oh, don't!" said Huck, nearly fainting. - -They talked it all over, and as they entered town they agreed to -believe that he might possibly mean somebody else--at least that he -might at least mean nobody but Tom, since only Tom had testified. - -Very, very small comfort it was to Tom to be alone in danger! Company -would be a palpable improvement, he thought. - - - -CHAPTER XXVII - -THE adventure of the day mightily tormented Tom's dreams that night. -Four times he had his hands on that rich treasure and four times it -wasted to nothingness in his fingers as sleep forsook him and -wakefulness brought back the hard reality of his misfortune. As he lay -in the early morning recalling the incidents of his great adventure, he -noticed that they seemed curiously subdued and far away--somewhat as if -they had happened in another world, or in a time long gone by. Then it -occurred to him that the great adventure itself must be a dream! There -was one very strong argument in favor of this idea--namely, that the -quantity of coin he had seen was too vast to be real. He had never seen -as much as fifty dollars in one mass before, and he was like all boys -of his age and station in life, in that he imagined that all references -to "hundreds" and "thousands" were mere fanciful forms of speech, and -that no such sums really existed in the world. He never had supposed -for a moment that so large a sum as a hundred dollars was to be found -in actual money in any one's possession. If his notions of hidden -treasure had been analyzed, they would have been found to consist of a -handful of real dimes and a bushel of vague, splendid, ungraspable -dollars. - -But the incidents of his adventure grew sensibly sharper and clearer -under the attrition of thinking them over, and so he presently found -himself leaning to the impression that the thing might not have been a -dream, after all. This uncertainty must be swept away. He would snatch -a hurried breakfast and go and find Huck. Huck was sitting on the -gunwale of a flatboat, listlessly dangling his feet in the water and -looking very melancholy. Tom concluded to let Huck lead up to the -subject. If he did not do it, then the adventure would be proved to -have been only a dream. - -"Hello, Huck!" - -"Hello, yourself." - -Silence, for a minute. - -"Tom, if we'd 'a' left the blame tools at the dead tree, we'd 'a' got -the money. Oh, ain't it awful!" - -"'Tain't a dream, then, 'tain't a dream! Somehow I most wish it was. -Dog'd if I don't, Huck." - -"What ain't a dream?" - -"Oh, that thing yesterday. I been half thinking it was." - -"Dream! If them stairs hadn't broke down you'd 'a' seen how much dream -it was! I've had dreams enough all night--with that patch-eyed Spanish -devil going for me all through 'em--rot him!" - -"No, not rot him. FIND him! Track the money!" - -"Tom, we'll never find him. A feller don't have only one chance for -such a pile--and that one's lost. I'd feel mighty shaky if I was to see -him, anyway." - -"Well, so'd I; but I'd like to see him, anyway--and track him out--to -his Number Two." - -"Number Two--yes, that's it. I been thinking 'bout that. But I can't -make nothing out of it. What do you reckon it is?" - -"I dono. It's too deep. Say, Huck--maybe it's the number of a house!" - -"Goody!... No, Tom, that ain't it. If it is, it ain't in this -one-horse town. They ain't no numbers here." - -"Well, that's so. Lemme think a minute. Here--it's the number of a -room--in a tavern, you know!" - -"Oh, that's the trick! They ain't only two taverns. We can find out -quick." - -"You stay here, Huck, till I come." - -Tom was off at once. He did not care to have Huck's company in public -places. He was gone half an hour. He found that in the best tavern, No. -2 had long been occupied by a young lawyer, and was still so occupied. -In the less ostentatious house, No. 2 was a mystery. The -tavern-keeper's young son said it was kept locked all the time, and he -never saw anybody go into it or come out of it except at night; he did -not know any particular reason for this state of things; had had some -little curiosity, but it was rather feeble; had made the most of the -mystery by entertaining himself with the idea that that room was -"ha'nted"; had noticed that there was a light in there the night before. - -"That's what I've found out, Huck. I reckon that's the very No. 2 -we're after." - -"I reckon it is, Tom. Now what you going to do?" - -"Lemme think." - -Tom thought a long time. Then he said: - -"I'll tell you. The back door of that No. 2 is the door that comes out -into that little close alley between the tavern and the old rattle trap -of a brick store. Now you get hold of all the door-keys you can find, -and I'll nip all of auntie's, and the first dark night we'll go there -and try 'em. And mind you, keep a lookout for Injun Joe, because he -said he was going to drop into town and spy around once more for a -chance to get his revenge. If you see him, you just follow him; and if -he don't go to that No. 2, that ain't the place." - -"Lordy, I don't want to foller him by myself!" - -"Why, it'll be night, sure. He mightn't ever see you--and if he did, -maybe he'd never think anything." - -"Well, if it's pretty dark I reckon I'll track him. I dono--I dono. -I'll try." - -"You bet I'll follow him, if it's dark, Huck. Why, he might 'a' found -out he couldn't get his revenge, and be going right after that money." - -"It's so, Tom, it's so. I'll foller him; I will, by jingoes!" - -"Now you're TALKING! Don't you ever weaken, Huck, and I won't." - - - -CHAPTER XXVIII - -THAT night Tom and Huck were ready for their adventure. They hung -about the neighborhood of the tavern until after nine, one watching the -alley at a distance and the other the tavern door. Nobody entered the -alley or left it; nobody resembling the Spaniard entered or left the -tavern door. The night promised to be a fair one; so Tom went home with -the understanding that if a considerable degree of darkness came on, -Huck was to come and "maow," whereupon he would slip out and try the -keys. But the night remained clear, and Huck closed his watch and -retired to bed in an empty sugar hogshead about twelve. - -Tuesday the boys had the same ill luck. Also Wednesday. But Thursday -night promised better. Tom slipped out in good season with his aunt's -old tin lantern, and a large towel to blindfold it with. He hid the -lantern in Huck's sugar hogshead and the watch began. An hour before -midnight the tavern closed up and its lights (the only ones -thereabouts) were put out. No Spaniard had been seen. Nobody had -entered or left the alley. Everything was auspicious. The blackness of -darkness reigned, the perfect stillness was interrupted only by -occasional mutterings of distant thunder. - -Tom got his lantern, lit it in the hogshead, wrapped it closely in the -towel, and the two adventurers crept in the gloom toward the tavern. -Huck stood sentry and Tom felt his way into the alley. Then there was a -season of waiting anxiety that weighed upon Huck's spirits like a -mountain. He began to wish he could see a flash from the lantern--it -would frighten him, but it would at least tell him that Tom was alive -yet. It seemed hours since Tom had disappeared. Surely he must have -fainted; maybe he was dead; maybe his heart had burst under terror and -excitement. In his uneasiness Huck found himself drawing closer and -closer to the alley; fearing all sorts of dreadful things, and -momentarily expecting some catastrophe to happen that would take away -his breath. There was not much to take away, for he seemed only able to -inhale it by thimblefuls, and his heart would soon wear itself out, the -way it was beating. Suddenly there was a flash of light and Tom came -tearing by him: "Run!" said he; "run, for your life!" - -He needn't have repeated it; once was enough; Huck was making thirty -or forty miles an hour before the repetition was uttered. The boys -never stopped till they reached the shed of a deserted slaughter-house -at the lower end of the village. Just as they got within its shelter -the storm burst and the rain poured down. As soon as Tom got his breath -he said: - -"Huck, it was awful! I tried two of the keys, just as soft as I could; -but they seemed to make such a power of racket that I couldn't hardly -get my breath I was so scared. They wouldn't turn in the lock, either. -Well, without noticing what I was doing, I took hold of the knob, and -open comes the door! It warn't locked! I hopped in, and shook off the -towel, and, GREAT CAESAR'S GHOST!" - -"What!--what'd you see, Tom?" - -"Huck, I most stepped onto Injun Joe's hand!" - -"No!" - -"Yes! He was lying there, sound asleep on the floor, with his old -patch on his eye and his arms spread out." - -"Lordy, what did you do? Did he wake up?" - -"No, never budged. Drunk, I reckon. I just grabbed that towel and -started!" - -"I'd never 'a' thought of the towel, I bet!" - -"Well, I would. My aunt would make me mighty sick if I lost it." - -"Say, Tom, did you see that box?" - -"Huck, I didn't wait to look around. I didn't see the box, I didn't -see the cross. I didn't see anything but a bottle and a tin cup on the -floor by Injun Joe; yes, I saw two barrels and lots more bottles in the -room. Don't you see, now, what's the matter with that ha'nted room?" - -"How?" - -"Why, it's ha'nted with whiskey! Maybe ALL the Temperance Taverns have -got a ha'nted room, hey, Huck?" - -"Well, I reckon maybe that's so. Who'd 'a' thought such a thing? But -say, Tom, now's a mighty good time to get that box, if Injun Joe's -drunk." - -"It is, that! You try it!" - -Huck shuddered. - -"Well, no--I reckon not." - -"And I reckon not, Huck. Only one bottle alongside of Injun Joe ain't -enough. If there'd been three, he'd be drunk enough and I'd do it." - -There was a long pause for reflection, and then Tom said: - -"Lookyhere, Huck, less not try that thing any more till we know Injun -Joe's not in there. It's too scary. Now, if we watch every night, we'll -be dead sure to see him go out, some time or other, and then we'll -snatch that box quicker'n lightning." - -"Well, I'm agreed. I'll watch the whole night long, and I'll do it -every night, too, if you'll do the other part of the job." - -"All right, I will. All you got to do is to trot up Hooper Street a -block and maow--and if I'm asleep, you throw some gravel at the window -and that'll fetch me." - -"Agreed, and good as wheat!" - -"Now, Huck, the storm's over, and I'll go home. It'll begin to be -daylight in a couple of hours. You go back and watch that long, will -you?" - -"I said I would, Tom, and I will. I'll ha'nt that tavern every night -for a year! I'll sleep all day and I'll stand watch all night." - -"That's all right. Now, where you going to sleep?" - -"In Ben Rogers' hayloft. He lets me, and so does his pap's nigger man, -Uncle Jake. I tote water for Uncle Jake whenever he wants me to, and -any time I ask him he gives me a little something to eat if he can -spare it. That's a mighty good nigger, Tom. He likes me, becuz I don't -ever act as if I was above him. Sometime I've set right down and eat -WITH him. But you needn't tell that. A body's got to do things when -he's awful hungry he wouldn't want to do as a steady thing." - -"Well, if I don't want you in the daytime, I'll let you sleep. I won't -come bothering around. Any time you see something's up, in the night, -just skip right around and maow." - - - -CHAPTER XXIX - -THE first thing Tom heard on Friday morning was a glad piece of news ---Judge Thatcher's family had come back to town the night before. Both -Injun Joe and the treasure sunk into secondary importance for a moment, -and Becky took the chief place in the boy's interest. He saw her and -they had an exhausting good time playing "hi-spy" and "gully-keeper" -with a crowd of their school-mates. The day was completed and crowned -in a peculiarly satisfactory way: Becky teased her mother to appoint -the next day for the long-promised and long-delayed picnic, and she -consented. The child's delight was boundless; and Tom's not more -moderate. The invitations were sent out before sunset, and straightway -the young folks of the village were thrown into a fever of preparation -and pleasurable anticipation. Tom's excitement enabled him to keep -awake until a pretty late hour, and he had good hopes of hearing Huck's -"maow," and of having his treasure to astonish Becky and the picnickers -with, next day; but he was disappointed. No signal came that night. - -Morning came, eventually, and by ten or eleven o'clock a giddy and -rollicking company were gathered at Judge Thatcher's, and everything -was ready for a start. It was not the custom for elderly people to mar -the picnics with their presence. The children were considered safe -enough under the wings of a few young ladies of eighteen and a few -young gentlemen of twenty-three or thereabouts. The old steam ferryboat -was chartered for the occasion; presently the gay throng filed up the -main street laden with provision-baskets. Sid was sick and had to miss -the fun; Mary remained at home to entertain him. The last thing Mrs. -Thatcher said to Becky, was: - -"You'll not get back till late. Perhaps you'd better stay all night -with some of the girls that live near the ferry-landing, child." - -"Then I'll stay with Susy Harper, mamma." - -"Very well. And mind and behave yourself and don't be any trouble." - -Presently, as they tripped along, Tom said to Becky: - -"Say--I'll tell you what we'll do. 'Stead of going to Joe Harper's -we'll climb right up the hill and stop at the Widow Douglas'. She'll -have ice-cream! She has it most every day--dead loads of it. And she'll -be awful glad to have us." - -"Oh, that will be fun!" - -Then Becky reflected a moment and said: - -"But what will mamma say?" - -"How'll she ever know?" - -The girl turned the idea over in her mind, and said reluctantly: - -"I reckon it's wrong--but--" - -"But shucks! Your mother won't know, and so what's the harm? All she -wants is that you'll be safe; and I bet you she'd 'a' said go there if -she'd 'a' thought of it. I know she would!" - -The Widow Douglas' splendid hospitality was a tempting bait. It and -Tom's persuasions presently carried the day. So it was decided to say -nothing anybody about the night's programme. Presently it occurred to -Tom that maybe Huck might come this very night and give the signal. The -thought took a deal of the spirit out of his anticipations. Still he -could not bear to give up the fun at Widow Douglas'. And why should he -give it up, he reasoned--the signal did not come the night before, so -why should it be any more likely to come to-night? The sure fun of the -evening outweighed the uncertain treasure; and, boy-like, he determined -to yield to the stronger inclination and not allow himself to think of -the box of money another time that day. - -Three miles below town the ferryboat stopped at the mouth of a woody -hollow and tied up. The crowd swarmed ashore and soon the forest -distances and craggy heights echoed far and near with shoutings and -laughter. All the different ways of getting hot and tired were gone -through with, and by-and-by the rovers straggled back to camp fortified -with responsible appetites, and then the destruction of the good things -began. After the feast there was a refreshing season of rest and chat -in the shade of spreading oaks. By-and-by somebody shouted: - -"Who's ready for the cave?" - -Everybody was. Bundles of candles were procured, and straightway there -was a general scamper up the hill. The mouth of the cave was up the -hillside--an opening shaped like a letter A. Its massive oaken door -stood unbarred. Within was a small chamber, chilly as an ice-house, and -walled by Nature with solid limestone that was dewy with a cold sweat. -It was romantic and mysterious to stand here in the deep gloom and look -out upon the green valley shining in the sun. But the impressiveness of -the situation quickly wore off, and the romping began again. The moment -a candle was lighted there was a general rush upon the owner of it; a -struggle and a gallant defence followed, but the candle was soon -knocked down or blown out, and then there was a glad clamor of laughter -and a new chase. But all things have an end. By-and-by the procession -went filing down the steep descent of the main avenue, the flickering -rank of lights dimly revealing the lofty walls of rock almost to their -point of junction sixty feet overhead. This main avenue was not more -than eight or ten feet wide. Every few steps other lofty and still -narrower crevices branched from it on either hand--for McDougal's cave -was but a vast labyrinth of crooked aisles that ran into each other and -out again and led nowhere. It was said that one might wander days and -nights together through its intricate tangle of rifts and chasms, and -never find the end of the cave; and that he might go down, and down, -and still down, into the earth, and it was just the same--labyrinth -under labyrinth, and no end to any of them. No man "knew" the cave. -That was an impossible thing. Most of the young men knew a portion of -it, and it was not customary to venture much beyond this known portion. -Tom Sawyer knew as much of the cave as any one. - -The procession moved along the main avenue some three-quarters of a -mile, and then groups and couples began to slip aside into branch -avenues, fly along the dismal corridors, and take each other by -surprise at points where the corridors joined again. Parties were able -to elude each other for the space of half an hour without going beyond -the "known" ground. - -By-and-by, one group after another came straggling back to the mouth -of the cave, panting, hilarious, smeared from head to foot with tallow -drippings, daubed with clay, and entirely delighted with the success of -the day. Then they were astonished to find that they had been taking no -note of time and that night was about at hand. The clanging bell had -been calling for half an hour. However, this sort of close to the day's -adventures was romantic and therefore satisfactory. When the ferryboat -with her wild freight pushed into the stream, nobody cared sixpence for -the wasted time but the captain of the craft. - -Huck was already upon his watch when the ferryboat's lights went -glinting past the wharf. He heard no noise on board, for the young -people were as subdued and still as people usually are who are nearly -tired to death. He wondered what boat it was, and why she did not stop -at the wharf--and then he dropped her out of his mind and put his -attention upon his business. The night was growing cloudy and dark. Ten -o'clock came, and the noise of vehicles ceased, scattered lights began -to wink out, all straggling foot-passengers disappeared, the village -betook itself to its slumbers and left the small watcher alone with the -silence and the ghosts. Eleven o'clock came, and the tavern lights were -put out; darkness everywhere, now. Huck waited what seemed a weary long -time, but nothing happened. His faith was weakening. Was there any use? -Was there really any use? Why not give it up and turn in? - -A noise fell upon his ear. He was all attention in an instant. The -alley door closed softly. He sprang to the corner of the brick store. -The next moment two men brushed by him, and one seemed to have -something under his arm. It must be that box! So they were going to -remove the treasure. Why call Tom now? It would be absurd--the men -would get away with the box and never be found again. No, he would -stick to their wake and follow them; he would trust to the darkness for -security from discovery. So communing with himself, Huck stepped out -and glided along behind the men, cat-like, with bare feet, allowing -them to keep just far enough ahead not to be invisible. - -They moved up the river street three blocks, then turned to the left -up a cross-street. They went straight ahead, then, until they came to -the path that led up Cardiff Hill; this they took. They passed by the -old Welshman's house, half-way up the hill, without hesitating, and -still climbed upward. Good, thought Huck, they will bury it in the old -quarry. But they never stopped at the quarry. They passed on, up the -summit. They plunged into the narrow path between the tall sumach -bushes, and were at once hidden in the gloom. Huck closed up and -shortened his distance, now, for they would never be able to see him. -He trotted along awhile; then slackened his pace, fearing he was -gaining too fast; moved on a piece, then stopped altogether; listened; -no sound; none, save that he seemed to hear the beating of his own -heart. The hooting of an owl came over the hill--ominous sound! But no -footsteps. Heavens, was everything lost! He was about to spring with -winged feet, when a man cleared his throat not four feet from him! -Huck's heart shot into his throat, but he swallowed it again; and then -he stood there shaking as if a dozen agues had taken charge of him at -once, and so weak that he thought he must surely fall to the ground. He -knew where he was. He knew he was within five steps of the stile -leading into Widow Douglas' grounds. Very well, he thought, let them -bury it there; it won't be hard to find. - -Now there was a voice--a very low voice--Injun Joe's: - -"Damn her, maybe she's got company--there's lights, late as it is." - -"I can't see any." - -This was that stranger's voice--the stranger of the haunted house. A -deadly chill went to Huck's heart--this, then, was the "revenge" job! -His thought was, to fly. Then he remembered that the Widow Douglas had -been kind to him more than once, and maybe these men were going to -murder her. He wished he dared venture to warn her; but he knew he -didn't dare--they might come and catch him. He thought all this and -more in the moment that elapsed between the stranger's remark and Injun -Joe's next--which was-- - -"Because the bush is in your way. Now--this way--now you see, don't -you?" - -"Yes. Well, there IS company there, I reckon. Better give it up." - -"Give it up, and I just leaving this country forever! Give it up and -maybe never have another chance. I tell you again, as I've told you -before, I don't care for her swag--you may have it. But her husband was -rough on me--many times he was rough on me--and mainly he was the -justice of the peace that jugged me for a vagrant. And that ain't all. -It ain't a millionth part of it! He had me HORSEWHIPPED!--horsewhipped -in front of the jail, like a nigger!--with all the town looking on! -HORSEWHIPPED!--do you understand? He took advantage of me and died. But -I'll take it out of HER." - -"Oh, don't kill her! Don't do that!" - -"Kill? Who said anything about killing? I would kill HIM if he was -here; but not her. When you want to get revenge on a woman you don't -kill her--bosh! you go for her looks. You slit her nostrils--you notch -her ears like a sow!" - -"By God, that's--" - -"Keep your opinion to yourself! It will be safest for you. I'll tie -her to the bed. If she bleeds to death, is that my fault? I'll not cry, -if she does. My friend, you'll help me in this thing--for MY sake ---that's why you're here--I mightn't be able alone. If you flinch, I'll -kill you. Do you understand that? And if I have to kill you, I'll kill -her--and then I reckon nobody'll ever know much about who done this -business." - -"Well, if it's got to be done, let's get at it. The quicker the -better--I'm all in a shiver." - -"Do it NOW? And company there? Look here--I'll get suspicious of you, -first thing you know. No--we'll wait till the lights are out--there's -no hurry." - -Huck felt that a silence was going to ensue--a thing still more awful -than any amount of murderous talk; so he held his breath and stepped -gingerly back; planted his foot carefully and firmly, after balancing, -one-legged, in a precarious way and almost toppling over, first on one -side and then on the other. He took another step back, with the same -elaboration and the same risks; then another and another, and--a twig -snapped under his foot! His breath stopped and he listened. There was -no sound--the stillness was perfect. His gratitude was measureless. Now -he turned in his tracks, between the walls of sumach bushes--turned -himself as carefully as if he were a ship--and then stepped quickly but -cautiously along. When he emerged at the quarry he felt secure, and so -he picked up his nimble heels and flew. Down, down he sped, till he -reached the Welshman's. He banged at the door, and presently the heads -of the old man and his two stalwart sons were thrust from windows. - -"What's the row there? Who's banging? What do you want?" - -"Let me in--quick! I'll tell everything." - -"Why, who are you?" - -"Huckleberry Finn--quick, let me in!" - -"Huckleberry Finn, indeed! It ain't a name to open many doors, I -judge! But let him in, lads, and let's see what's the trouble." - -"Please don't ever tell I told you," were Huck's first words when he -got in. "Please don't--I'd be killed, sure--but the widow's been good -friends to me sometimes, and I want to tell--I WILL tell if you'll -promise you won't ever say it was me." - -"By George, he HAS got something to tell, or he wouldn't act so!" -exclaimed the old man; "out with it and nobody here'll ever tell, lad." - -Three minutes later the old man and his sons, well armed, were up the -hill, and just entering the sumach path on tiptoe, their weapons in -their hands. Huck accompanied them no further. He hid behind a great -bowlder and fell to listening. There was a lagging, anxious silence, -and then all of a sudden there was an explosion of firearms and a cry. - -Huck waited for no particulars. He sprang away and sped down the hill -as fast as his legs could carry him. - - - -CHAPTER XXX - -AS the earliest suspicion of dawn appeared on Sunday morning, Huck -came groping up the hill and rapped gently at the old Welshman's door. -The inmates were asleep, but it was a sleep that was set on a -hair-trigger, on account of the exciting episode of the night. A call -came from a window: - -"Who's there!" - -Huck's scared voice answered in a low tone: - -"Please let me in! It's only Huck Finn!" - -"It's a name that can open this door night or day, lad!--and welcome!" - -These were strange words to the vagabond boy's ears, and the -pleasantest he had ever heard. He could not recollect that the closing -word had ever been applied in his case before. The door was quickly -unlocked, and he entered. Huck was given a seat and the old man and his -brace of tall sons speedily dressed themselves. - -"Now, my boy, I hope you're good and hungry, because breakfast will be -ready as soon as the sun's up, and we'll have a piping hot one, too ---make yourself easy about that! I and the boys hoped you'd turn up and -stop here last night." - -"I was awful scared," said Huck, "and I run. I took out when the -pistols went off, and I didn't stop for three mile. I've come now becuz -I wanted to know about it, you know; and I come before daylight becuz I -didn't want to run across them devils, even if they was dead." - -"Well, poor chap, you do look as if you'd had a hard night of it--but -there's a bed here for you when you've had your breakfast. No, they -ain't dead, lad--we are sorry enough for that. You see we knew right -where to put our hands on them, by your description; so we crept along -on tiptoe till we got within fifteen feet of them--dark as a cellar -that sumach path was--and just then I found I was going to sneeze. It -was the meanest kind of luck! I tried to keep it back, but no use ---'twas bound to come, and it did come! I was in the lead with my pistol -raised, and when the sneeze started those scoundrels a-rustling to get -out of the path, I sung out, 'Fire boys!' and blazed away at the place -where the rustling was. So did the boys. But they were off in a jiffy, -those villains, and we after them, down through the woods. I judge we -never touched them. They fired a shot apiece as they started, but their -bullets whizzed by and didn't do us any harm. As soon as we lost the -sound of their feet we quit chasing, and went down and stirred up the -constables. They got a posse together, and went off to guard the river -bank, and as soon as it is light the sheriff and a gang are going to -beat up the woods. My boys will be with them presently. I wish we had -some sort of description of those rascals--'twould help a good deal. -But you couldn't see what they were like, in the dark, lad, I suppose?" - -"Oh yes; I saw them down-town and follered them." - -"Splendid! Describe them--describe them, my boy!" - -"One's the old deaf and dumb Spaniard that's ben around here once or -twice, and t'other's a mean-looking, ragged--" - -"That's enough, lad, we know the men! Happened on them in the woods -back of the widow's one day, and they slunk away. Off with you, boys, -and tell the sheriff--get your breakfast to-morrow morning!" - -The Welshman's sons departed at once. As they were leaving the room -Huck sprang up and exclaimed: - -"Oh, please don't tell ANYbody it was me that blowed on them! Oh, -please!" - -"All right if you say it, Huck, but you ought to have the credit of -what you did." - -"Oh no, no! Please don't tell!" - -When the young men were gone, the old Welshman said: - -"They won't tell--and I won't. But why don't you want it known?" - -Huck would not explain, further than to say that he already knew too -much about one of those men and would not have the man know that he -knew anything against him for the whole world--he would be killed for -knowing it, sure. - -The old man promised secrecy once more, and said: - -"How did you come to follow these fellows, lad? Were they looking -suspicious?" - -Huck was silent while he framed a duly cautious reply. Then he said: - -"Well, you see, I'm a kind of a hard lot,--least everybody says so, -and I don't see nothing agin it--and sometimes I can't sleep much, on -account of thinking about it and sort of trying to strike out a new way -of doing. That was the way of it last night. I couldn't sleep, and so I -come along up-street 'bout midnight, a-turning it all over, and when I -got to that old shackly brick store by the Temperance Tavern, I backed -up agin the wall to have another think. Well, just then along comes -these two chaps slipping along close by me, with something under their -arm, and I reckoned they'd stole it. One was a-smoking, and t'other one -wanted a light; so they stopped right before me and the cigars lit up -their faces and I see that the big one was the deaf and dumb Spaniard, -by his white whiskers and the patch on his eye, and t'other one was a -rusty, ragged-looking devil." - -"Could you see the rags by the light of the cigars?" - -This staggered Huck for a moment. Then he said: - -"Well, I don't know--but somehow it seems as if I did." - -"Then they went on, and you--" - -"Follered 'em--yes. That was it. I wanted to see what was up--they -sneaked along so. I dogged 'em to the widder's stile, and stood in the -dark and heard the ragged one beg for the widder, and the Spaniard -swear he'd spile her looks just as I told you and your two--" - -"What! The DEAF AND DUMB man said all that!" - -Huck had made another terrible mistake! He was trying his best to keep -the old man from getting the faintest hint of who the Spaniard might -be, and yet his tongue seemed determined to get him into trouble in -spite of all he could do. He made several efforts to creep out of his -scrape, but the old man's eye was upon him and he made blunder after -blunder. Presently the Welshman said: - -"My boy, don't be afraid of me. I wouldn't hurt a hair of your head -for all the world. No--I'd protect you--I'd protect you. This Spaniard -is not deaf and dumb; you've let that slip without intending it; you -can't cover that up now. You know something about that Spaniard that -you want to keep dark. Now trust me--tell me what it is, and trust me ---I won't betray you." - -Huck looked into the old man's honest eyes a moment, then bent over -and whispered in his ear: - -"'Tain't a Spaniard--it's Injun Joe!" - -The Welshman almost jumped out of his chair. In a moment he said: - -"It's all plain enough, now. When you talked about notching ears and -slitting noses I judged that that was your own embellishment, because -white men don't take that sort of revenge. But an Injun! That's a -different matter altogether." - -During breakfast the talk went on, and in the course of it the old man -said that the last thing which he and his sons had done, before going -to bed, was to get a lantern and examine the stile and its vicinity for -marks of blood. They found none, but captured a bulky bundle of-- - -"Of WHAT?" - -If the words had been lightning they could not have leaped with a more -stunning suddenness from Huck's blanched lips. His eyes were staring -wide, now, and his breath suspended--waiting for the answer. The -Welshman started--stared in return--three seconds--five seconds--ten ---then replied: - -"Of burglar's tools. Why, what's the MATTER with you?" - -Huck sank back, panting gently, but deeply, unutterably grateful. The -Welshman eyed him gravely, curiously--and presently said: - -"Yes, burglar's tools. That appears to relieve you a good deal. But -what did give you that turn? What were YOU expecting we'd found?" - -Huck was in a close place--the inquiring eye was upon him--he would -have given anything for material for a plausible answer--nothing -suggested itself--the inquiring eye was boring deeper and deeper--a -senseless reply offered--there was no time to weigh it, so at a venture -he uttered it--feebly: - -"Sunday-school books, maybe." - -Poor Huck was too distressed to smile, but the old man laughed loud -and joyously, shook up the details of his anatomy from head to foot, -and ended by saying that such a laugh was money in a-man's pocket, -because it cut down the doctor's bill like everything. Then he added: - -"Poor old chap, you're white and jaded--you ain't well a bit--no -wonder you're a little flighty and off your balance. But you'll come -out of it. Rest and sleep will fetch you out all right, I hope." - -Huck was irritated to think he had been such a goose and betrayed such -a suspicious excitement, for he had dropped the idea that the parcel -brought from the tavern was the treasure, as soon as he had heard the -talk at the widow's stile. He had only thought it was not the treasure, -however--he had not known that it wasn't--and so the suggestion of a -captured bundle was too much for his self-possession. But on the whole -he felt glad the little episode had happened, for now he knew beyond -all question that that bundle was not THE bundle, and so his mind was -at rest and exceedingly comfortable. In fact, everything seemed to be -drifting just in the right direction, now; the treasure must be still -in No. 2, the men would be captured and jailed that day, and he and Tom -could seize the gold that night without any trouble or any fear of -interruption. - -Just as breakfast was completed there was a knock at the door. Huck -jumped for a hiding-place, for he had no mind to be connected even -remotely with the late event. The Welshman admitted several ladies and -gentlemen, among them the Widow Douglas, and noticed that groups of -citizens were climbing up the hill--to stare at the stile. So the news -had spread. The Welshman had to tell the story of the night to the -visitors. The widow's gratitude for her preservation was outspoken. - -"Don't say a word about it, madam. There's another that you're more -beholden to than you are to me and my boys, maybe, but he don't allow -me to tell his name. We wouldn't have been there but for him." - -Of course this excited a curiosity so vast that it almost belittled -the main matter--but the Welshman allowed it to eat into the vitals of -his visitors, and through them be transmitted to the whole town, for he -refused to part with his secret. When all else had been learned, the -widow said: - -"I went to sleep reading in bed and slept straight through all that -noise. Why didn't you come and wake me?" - -"We judged it warn't worth while. Those fellows warn't likely to come -again--they hadn't any tools left to work with, and what was the use of -waking you up and scaring you to death? My three negro men stood guard -at your house all the rest of the night. They've just come back." - -More visitors came, and the story had to be told and retold for a -couple of hours more. - -There was no Sabbath-school during day-school vacation, but everybody -was early at church. The stirring event was well canvassed. News came -that not a sign of the two villains had been yet discovered. When the -sermon was finished, Judge Thatcher's wife dropped alongside of Mrs. -Harper as she moved down the aisle with the crowd and said: - -"Is my Becky going to sleep all day? I just expected she would be -tired to death." - -"Your Becky?" - -"Yes," with a startled look--"didn't she stay with you last night?" - -"Why, no." - -Mrs. Thatcher turned pale, and sank into a pew, just as Aunt Polly, -talking briskly with a friend, passed by. Aunt Polly said: - -"Good-morning, Mrs. Thatcher. Good-morning, Mrs. Harper. I've got a -boy that's turned up missing. I reckon my Tom stayed at your house last -night--one of you. And now he's afraid to come to church. I've got to -settle with him." - -Mrs. Thatcher shook her head feebly and turned paler than ever. - -"He didn't stay with us," said Mrs. Harper, beginning to look uneasy. -A marked anxiety came into Aunt Polly's face. - -"Joe Harper, have you seen my Tom this morning?" - -"No'm." - -"When did you see him last?" - -Joe tried to remember, but was not sure he could say. The people had -stopped moving out of church. Whispers passed along, and a boding -uneasiness took possession of every countenance. Children were -anxiously questioned, and young teachers. They all said they had not -noticed whether Tom and Becky were on board the ferryboat on the -homeward trip; it was dark; no one thought of inquiring if any one was -missing. One young man finally blurted out his fear that they were -still in the cave! Mrs. Thatcher swooned away. Aunt Polly fell to -crying and wringing her hands. - -The alarm swept from lip to lip, from group to group, from street to -street, and within five minutes the bells were wildly clanging and the -whole town was up! The Cardiff Hill episode sank into instant -insignificance, the burglars were forgotten, horses were saddled, -skiffs were manned, the ferryboat ordered out, and before the horror -was half an hour old, two hundred men were pouring down highroad and -river toward the cave. - -All the long afternoon the village seemed empty and dead. Many women -visited Aunt Polly and Mrs. Thatcher and tried to comfort them. They -cried with them, too, and that was still better than words. All the -tedious night the town waited for news; but when the morning dawned at -last, all the word that came was, "Send more candles--and send food." -Mrs. Thatcher was almost crazed; and Aunt Polly, also. Judge Thatcher -sent messages of hope and encouragement from the cave, but they -conveyed no real cheer. - -The old Welshman came home toward daylight, spattered with -candle-grease, smeared with clay, and almost worn out. He found Huck -still in the bed that had been provided for him, and delirious with -fever. The physicians were all at the cave, so the Widow Douglas came -and took charge of the patient. She said she would do her best by him, -because, whether he was good, bad, or indifferent, he was the Lord's, -and nothing that was the Lord's was a thing to be neglected. The -Welshman said Huck had good spots in him, and the widow said: - -"You can depend on it. That's the Lord's mark. He don't leave it off. -He never does. Puts it somewhere on every creature that comes from his -hands." - -Early in the forenoon parties of jaded men began to straggle into the -village, but the strongest of the citizens continued searching. All the -news that could be gained was that remotenesses of the cavern were -being ransacked that had never been visited before; that every corner -and crevice was going to be thoroughly searched; that wherever one -wandered through the maze of passages, lights were to be seen flitting -hither and thither in the distance, and shoutings and pistol-shots sent -their hollow reverberations to the ear down the sombre aisles. In one -place, far from the section usually traversed by tourists, the names -"BECKY & TOM" had been found traced upon the rocky wall with -candle-smoke, and near at hand a grease-soiled bit of ribbon. Mrs. -Thatcher recognized the ribbon and cried over it. She said it was the -last relic she should ever have of her child; and that no other memorial -of her could ever be so precious, because this one parted latest from -the living body before the awful death came. Some said that now and -then, in the cave, a far-away speck of light would glimmer, and then a -glorious shout would burst forth and a score of men go trooping down the -echoing aisle--and then a sickening disappointment always followed; the -children were not there; it was only a searcher's light. - -Three dreadful days and nights dragged their tedious hours along, and -the village sank into a hopeless stupor. No one had heart for anything. -The accidental discovery, just made, that the proprietor of the -Temperance Tavern kept liquor on his premises, scarcely fluttered the -public pulse, tremendous as the fact was. In a lucid interval, Huck -feebly led up to the subject of taverns, and finally asked--dimly -dreading the worst--if anything had been discovered at the Temperance -Tavern since he had been ill. - -"Yes," said the widow. - -Huck started up in bed, wild-eyed: - -"What? What was it?" - -"Liquor!--and the place has been shut up. Lie down, child--what a turn -you did give me!" - -"Only tell me just one thing--only just one--please! Was it Tom Sawyer -that found it?" - -The widow burst into tears. "Hush, hush, child, hush! I've told you -before, you must NOT talk. You are very, very sick!" - -Then nothing but liquor had been found; there would have been a great -powwow if it had been the gold. So the treasure was gone forever--gone -forever! But what could she be crying about? Curious that she should -cry. - -These thoughts worked their dim way through Huck's mind, and under the -weariness they gave him he fell asleep. The widow said to herself: - -"There--he's asleep, poor wreck. Tom Sawyer find it! Pity but somebody -could find Tom Sawyer! Ah, there ain't many left, now, that's got hope -enough, or strength enough, either, to go on searching." - - - -CHAPTER XXXI - -NOW to return to Tom and Becky's share in the picnic. They tripped -along the murky aisles with the rest of the company, visiting the -familiar wonders of the cave--wonders dubbed with rather -over-descriptive names, such as "The Drawing-Room," "The Cathedral," -"Aladdin's Palace," and so on. Presently the hide-and-seek frolicking -began, and Tom and Becky engaged in it with zeal until the exertion -began to grow a trifle wearisome; then they wandered down a sinuous -avenue holding their candles aloft and reading the tangled web-work of -names, dates, post-office addresses, and mottoes with which the rocky -walls had been frescoed (in candle-smoke). Still drifting along and -talking, they scarcely noticed that they were now in a part of the cave -whose walls were not frescoed. They smoked their own names under an -overhanging shelf and moved on. Presently they came to a place where a -little stream of water, trickling over a ledge and carrying a limestone -sediment with it, had, in the slow-dragging ages, formed a laced and -ruffled Niagara in gleaming and imperishable stone. Tom squeezed his -small body behind it in order to illuminate it for Becky's -gratification. He found that it curtained a sort of steep natural -stairway which was enclosed between narrow walls, and at once the -ambition to be a discoverer seized him. Becky responded to his call, -and they made a smoke-mark for future guidance, and started upon their -quest. They wound this way and that, far down into the secret depths of -the cave, made another mark, and branched off in search of novelties to -tell the upper world about. In one place they found a spacious cavern, -from whose ceiling depended a multitude of shining stalactites of the -length and circumference of a man's leg; they walked all about it, -wondering and admiring, and presently left it by one of the numerous -passages that opened into it. This shortly brought them to a bewitching -spring, whose basin was incrusted with a frostwork of glittering -crystals; it was in the midst of a cavern whose walls were supported by -many fantastic pillars which had been formed by the joining of great -stalactites and stalagmites together, the result of the ceaseless -water-drip of centuries. Under the roof vast knots of bats had packed -themselves together, thousands in a bunch; the lights disturbed the -creatures and they came flocking down by hundreds, squeaking and -darting furiously at the candles. Tom knew their ways and the danger of -this sort of conduct. He seized Becky's hand and hurried her into the -first corridor that offered; and none too soon, for a bat struck -Becky's light out with its wing while she was passing out of the -cavern. The bats chased the children a good distance; but the fugitives -plunged into every new passage that offered, and at last got rid of the -perilous things. Tom found a subterranean lake, shortly, which -stretched its dim length away until its shape was lost in the shadows. -He wanted to explore its borders, but concluded that it would be best -to sit down and rest awhile, first. Now, for the first time, the deep -stillness of the place laid a clammy hand upon the spirits of the -children. Becky said: - -"Why, I didn't notice, but it seems ever so long since I heard any of -the others." - -"Come to think, Becky, we are away down below them--and I don't know -how far away north, or south, or east, or whichever it is. We couldn't -hear them here." - -Becky grew apprehensive. - -"I wonder how long we've been down here, Tom? We better start back." - -"Yes, I reckon we better. P'raps we better." - -"Can you find the way, Tom? It's all a mixed-up crookedness to me." - -"I reckon I could find it--but then the bats. If they put our candles -out it will be an awful fix. Let's try some other way, so as not to go -through there." - -"Well. But I hope we won't get lost. It would be so awful!" and the -girl shuddered at the thought of the dreadful possibilities. - -They started through a corridor, and traversed it in silence a long -way, glancing at each new opening, to see if there was anything -familiar about the look of it; but they were all strange. Every time -Tom made an examination, Becky would watch his face for an encouraging -sign, and he would say cheerily: - -"Oh, it's all right. This ain't the one, but we'll come to it right -away!" - -But he felt less and less hopeful with each failure, and presently -began to turn off into diverging avenues at sheer random, in desperate -hope of finding the one that was wanted. He still said it was "all -right," but there was such a leaden dread at his heart that the words -had lost their ring and sounded just as if he had said, "All is lost!" -Becky clung to his side in an anguish of fear, and tried hard to keep -back the tears, but they would come. At last she said: - -"Oh, Tom, never mind the bats, let's go back that way! We seem to get -worse and worse off all the time." - -"Listen!" said he. - -Profound silence; silence so deep that even their breathings were -conspicuous in the hush. Tom shouted. The call went echoing down the -empty aisles and died out in the distance in a faint sound that -resembled a ripple of mocking laughter. - -"Oh, don't do it again, Tom, it is too horrid," said Becky. - -"It is horrid, but I better, Becky; they might hear us, you know," and -he shouted again. - -The "might" was even a chillier horror than the ghostly laughter, it -so confessed a perishing hope. The children stood still and listened; -but there was no result. Tom turned upon the back track at once, and -hurried his steps. It was but a little while before a certain -indecision in his manner revealed another fearful fact to Becky--he -could not find his way back! - -"Oh, Tom, you didn't make any marks!" - -"Becky, I was such a fool! Such a fool! I never thought we might want -to come back! No--I can't find the way. It's all mixed up." - -"Tom, Tom, we're lost! we're lost! We never can get out of this awful -place! Oh, why DID we ever leave the others!" - -She sank to the ground and burst into such a frenzy of crying that Tom -was appalled with the idea that she might die, or lose her reason. He -sat down by her and put his arms around her; she buried her face in his -bosom, she clung to him, she poured out her terrors, her unavailing -regrets, and the far echoes turned them all to jeering laughter. Tom -begged her to pluck up hope again, and she said she could not. He fell -to blaming and abusing himself for getting her into this miserable -situation; this had a better effect. She said she would try to hope -again, she would get up and follow wherever he might lead if only he -would not talk like that any more. For he was no more to blame than -she, she said. - -So they moved on again--aimlessly--simply at random--all they could do -was to move, keep moving. For a little while, hope made a show of -reviving--not with any reason to back it, but only because it is its -nature to revive when the spring has not been taken out of it by age -and familiarity with failure. - -By-and-by Tom took Becky's candle and blew it out. This economy meant -so much! Words were not needed. Becky understood, and her hope died -again. She knew that Tom had a whole candle and three or four pieces in -his pockets--yet he must economize. - -By-and-by, fatigue began to assert its claims; the children tried to -pay attention, for it was dreadful to think of sitting down when time -was grown to be so precious, moving, in some direction, in any -direction, was at least progress and might bear fruit; but to sit down -was to invite death and shorten its pursuit. - -At last Becky's frail limbs refused to carry her farther. She sat -down. Tom rested with her, and they talked of home, and the friends -there, and the comfortable beds and, above all, the light! Becky cried, -and Tom tried to think of some way of comforting her, but all his -encouragements were grown threadbare with use, and sounded like -sarcasms. Fatigue bore so heavily upon Becky that she drowsed off to -sleep. Tom was grateful. He sat looking into her drawn face and saw it -grow smooth and natural under the influence of pleasant dreams; and -by-and-by a smile dawned and rested there. The peaceful face reflected -somewhat of peace and healing into his own spirit, and his thoughts -wandered away to bygone times and dreamy memories. While he was deep in -his musings, Becky woke up with a breezy little laugh--but it was -stricken dead upon her lips, and a groan followed it. - -"Oh, how COULD I sleep! I wish I never, never had waked! No! No, I -don't, Tom! Don't look so! I won't say it again." - -"I'm glad you've slept, Becky; you'll feel rested, now, and we'll find -the way out." - -"We can try, Tom; but I've seen such a beautiful country in my dream. -I reckon we are going there." - -"Maybe not, maybe not. Cheer up, Becky, and let's go on trying." - -They rose up and wandered along, hand in hand and hopeless. They tried -to estimate how long they had been in the cave, but all they knew was -that it seemed days and weeks, and yet it was plain that this could not -be, for their candles were not gone yet. A long time after this--they -could not tell how long--Tom said they must go softly and listen for -dripping water--they must find a spring. They found one presently, and -Tom said it was time to rest again. Both were cruelly tired, yet Becky -said she thought she could go a little farther. She was surprised to -hear Tom dissent. She could not understand it. They sat down, and Tom -fastened his candle to the wall in front of them with some clay. -Thought was soon busy; nothing was said for some time. Then Becky broke -the silence: - -"Tom, I am so hungry!" - -Tom took something out of his pocket. - -"Do you remember this?" said he. - -Becky almost smiled. - -"It's our wedding-cake, Tom." - -"Yes--I wish it was as big as a barrel, for it's all we've got." - -"I saved it from the picnic for us to dream on, Tom, the way grown-up -people do with wedding-cake--but it'll be our--" - -She dropped the sentence where it was. Tom divided the cake and Becky -ate with good appetite, while Tom nibbled at his moiety. There was -abundance of cold water to finish the feast with. By-and-by Becky -suggested that they move on again. Tom was silent a moment. Then he -said: - -"Becky, can you bear it if I tell you something?" - -Becky's face paled, but she thought she could. - -"Well, then, Becky, we must stay here, where there's water to drink. -That little piece is our last candle!" - -Becky gave loose to tears and wailings. Tom did what he could to -comfort her, but with little effect. At length Becky said: - -"Tom!" - -"Well, Becky?" - -"They'll miss us and hunt for us!" - -"Yes, they will! Certainly they will!" - -"Maybe they're hunting for us now, Tom." - -"Why, I reckon maybe they are. I hope they are." - -"When would they miss us, Tom?" - -"When they get back to the boat, I reckon." - -"Tom, it might be dark then--would they notice we hadn't come?" - -"I don't know. But anyway, your mother would miss you as soon as they -got home." - -A frightened look in Becky's face brought Tom to his senses and he saw -that he had made a blunder. Becky was not to have gone home that night! -The children became silent and thoughtful. In a moment a new burst of -grief from Becky showed Tom that the thing in his mind had struck hers -also--that the Sabbath morning might be half spent before Mrs. Thatcher -discovered that Becky was not at Mrs. Harper's. - -The children fastened their eyes upon their bit of candle and watched -it melt slowly and pitilessly away; saw the half inch of wick stand -alone at last; saw the feeble flame rise and fall, climb the thin -column of smoke, linger at its top a moment, and then--the horror of -utter darkness reigned! - -How long afterward it was that Becky came to a slow consciousness that -she was crying in Tom's arms, neither could tell. All that they knew -was, that after what seemed a mighty stretch of time, both awoke out of -a dead stupor of sleep and resumed their miseries once more. Tom said -it might be Sunday, now--maybe Monday. He tried to get Becky to talk, -but her sorrows were too oppressive, all her hopes were gone. Tom said -that they must have been missed long ago, and no doubt the search was -going on. He would shout and maybe some one would come. He tried it; -but in the darkness the distant echoes sounded so hideously that he -tried it no more. - -The hours wasted away, and hunger came to torment the captives again. -A portion of Tom's half of the cake was left; they divided and ate it. -But they seemed hungrier than before. The poor morsel of food only -whetted desire. - -By-and-by Tom said: - -"SH! Did you hear that?" - -Both held their breath and listened. There was a sound like the -faintest, far-off shout. Instantly Tom answered it, and leading Becky -by the hand, started groping down the corridor in its direction. -Presently he listened again; again the sound was heard, and apparently -a little nearer. - -"It's them!" said Tom; "they're coming! Come along, Becky--we're all -right now!" - -The joy of the prisoners was almost overwhelming. Their speed was -slow, however, because pitfalls were somewhat common, and had to be -guarded against. They shortly came to one and had to stop. It might be -three feet deep, it might be a hundred--there was no passing it at any -rate. Tom got down on his breast and reached as far down as he could. -No bottom. They must stay there and wait until the searchers came. They -listened; evidently the distant shoutings were growing more distant! a -moment or two more and they had gone altogether. The heart-sinking -misery of it! Tom whooped until he was hoarse, but it was of no use. He -talked hopefully to Becky; but an age of anxious waiting passed and no -sounds came again. - -The children groped their way back to the spring. The weary time -dragged on; they slept again, and awoke famished and woe-stricken. Tom -believed it must be Tuesday by this time. - -Now an idea struck him. There were some side passages near at hand. It -would be better to explore some of these than bear the weight of the -heavy time in idleness. He took a kite-line from his pocket, tied it to -a projection, and he and Becky started, Tom in the lead, unwinding the -line as he groped along. At the end of twenty steps the corridor ended -in a "jumping-off place." Tom got down on his knees and felt below, and -then as far around the corner as he could reach with his hands -conveniently; he made an effort to stretch yet a little farther to the -right, and at that moment, not twenty yards away, a human hand, holding -a candle, appeared from behind a rock! Tom lifted up a glorious shout, -and instantly that hand was followed by the body it belonged to--Injun -Joe's! Tom was paralyzed; he could not move. He was vastly gratified -the next moment, to see the "Spaniard" take to his heels and get -himself out of sight. Tom wondered that Joe had not recognized his -voice and come over and killed him for testifying in court. But the -echoes must have disguised the voice. Without doubt, that was it, he -reasoned. Tom's fright weakened every muscle in his body. He said to -himself that if he had strength enough to get back to the spring he -would stay there, and nothing should tempt him to run the risk of -meeting Injun Joe again. He was careful to keep from Becky what it was -he had seen. He told her he had only shouted "for luck." - -But hunger and wretchedness rise superior to fears in the long run. -Another tedious wait at the spring and another long sleep brought -changes. The children awoke tortured with a raging hunger. Tom believed -that it must be Wednesday or Thursday or even Friday or Saturday, now, -and that the search had been given over. He proposed to explore another -passage. He felt willing to risk Injun Joe and all other terrors. But -Becky was very weak. She had sunk into a dreary apathy and would not be -roused. She said she would wait, now, where she was, and die--it would -not be long. She told Tom to go with the kite-line and explore if he -chose; but she implored him to come back every little while and speak -to her; and she made him promise that when the awful time came, he -would stay by her and hold her hand until all was over. - -Tom kissed her, with a choking sensation in his throat, and made a -show of being confident of finding the searchers or an escape from the -cave; then he took the kite-line in his hand and went groping down one -of the passages on his hands and knees, distressed with hunger and sick -with bodings of coming doom. - - - -CHAPTER XXXII - -TUESDAY afternoon came, and waned to the twilight. The village of St. -Petersburg still mourned. The lost children had not been found. Public -prayers had been offered up for them, and many and many a private -prayer that had the petitioner's whole heart in it; but still no good -news came from the cave. The majority of the searchers had given up the -quest and gone back to their daily avocations, saying that it was plain -the children could never be found. Mrs. Thatcher was very ill, and a -great part of the time delirious. People said it was heartbreaking to -hear her call her child, and raise her head and listen a whole minute -at a time, then lay it wearily down again with a moan. Aunt Polly had -drooped into a settled melancholy, and her gray hair had grown almost -white. The village went to its rest on Tuesday night, sad and forlorn. - -Away in the middle of the night a wild peal burst from the village -bells, and in a moment the streets were swarming with frantic half-clad -people, who shouted, "Turn out! turn out! they're found! they're -found!" Tin pans and horns were added to the din, the population massed -itself and moved toward the river, met the children coming in an open -carriage drawn by shouting citizens, thronged around it, joined its -homeward march, and swept magnificently up the main street roaring -huzzah after huzzah! - -The village was illuminated; nobody went to bed again; it was the -greatest night the little town had ever seen. During the first half-hour -a procession of villagers filed through Judge Thatcher's house, seized -the saved ones and kissed them, squeezed Mrs. Thatcher's hand, tried to -speak but couldn't--and drifted out raining tears all over the place. - -Aunt Polly's happiness was complete, and Mrs. Thatcher's nearly so. It -would be complete, however, as soon as the messenger dispatched with -the great news to the cave should get the word to her husband. Tom lay -upon a sofa with an eager auditory about him and told the history of -the wonderful adventure, putting in many striking additions to adorn it -withal; and closed with a description of how he left Becky and went on -an exploring expedition; how he followed two avenues as far as his -kite-line would reach; how he followed a third to the fullest stretch of -the kite-line, and was about to turn back when he glimpsed a far-off -speck that looked like daylight; dropped the line and groped toward it, -pushed his head and shoulders through a small hole, and saw the broad -Mississippi rolling by! And if it had only happened to be night he would -not have seen that speck of daylight and would not have explored that -passage any more! He told how he went back for Becky and broke the good -news and she told him not to fret her with such stuff, for she was -tired, and knew she was going to die, and wanted to. He described how he -labored with her and convinced her; and how she almost died for joy when -she had groped to where she actually saw the blue speck of daylight; how -he pushed his way out at the hole and then helped her out; how they sat -there and cried for gladness; how some men came along in a skiff and Tom -hailed them and told them their situation and their famished condition; -how the men didn't believe the wild tale at first, "because," said they, -"you are five miles down the river below the valley the cave is in" ---then took them aboard, rowed to a house, gave them supper, made them -rest till two or three hours after dark and then brought them home. - -Before day-dawn, Judge Thatcher and the handful of searchers with him -were tracked out, in the cave, by the twine clews they had strung -behind them, and informed of the great news. - -Three days and nights of toil and hunger in the cave were not to be -shaken off at once, as Tom and Becky soon discovered. They were -bedridden all of Wednesday and Thursday, and seemed to grow more and -more tired and worn, all the time. Tom got about, a little, on -Thursday, was down-town Friday, and nearly as whole as ever Saturday; -but Becky did not leave her room until Sunday, and then she looked as -if she had passed through a wasting illness. - -Tom learned of Huck's sickness and went to see him on Friday, but -could not be admitted to the bedroom; neither could he on Saturday or -Sunday. He was admitted daily after that, but was warned to keep still -about his adventure and introduce no exciting topic. The Widow Douglas -stayed by to see that he obeyed. At home Tom learned of the Cardiff -Hill event; also that the "ragged man's" body had eventually been found -in the river near the ferry-landing; he had been drowned while trying -to escape, perhaps. - -About a fortnight after Tom's rescue from the cave, he started off to -visit Huck, who had grown plenty strong enough, now, to hear exciting -talk, and Tom had some that would interest him, he thought. Judge -Thatcher's house was on Tom's way, and he stopped to see Becky. The -Judge and some friends set Tom to talking, and some one asked him -ironically if he wouldn't like to go to the cave again. Tom said he -thought he wouldn't mind it. The Judge said: - -"Well, there are others just like you, Tom, I've not the least doubt. -But we have taken care of that. Nobody will get lost in that cave any -more." - -"Why?" - -"Because I had its big door sheathed with boiler iron two weeks ago, -and triple-locked--and I've got the keys." - -Tom turned as white as a sheet. - -"What's the matter, boy! Here, run, somebody! Fetch a glass of water!" - -The water was brought and thrown into Tom's face. - -"Ah, now you're all right. What was the matter with you, Tom?" - -"Oh, Judge, Injun Joe's in the cave!" - - - -CHAPTER XXXIII - -WITHIN a few minutes the news had spread, and a dozen skiff-loads of -men were on their way to McDougal's cave, and the ferryboat, well -filled with passengers, soon followed. Tom Sawyer was in the skiff that -bore Judge Thatcher. - -When the cave door was unlocked, a sorrowful sight presented itself in -the dim twilight of the place. Injun Joe lay stretched upon the ground, -dead, with his face close to the crack of the door, as if his longing -eyes had been fixed, to the latest moment, upon the light and the cheer -of the free world outside. Tom was touched, for he knew by his own -experience how this wretch had suffered. His pity was moved, but -nevertheless he felt an abounding sense of relief and security, now, -which revealed to him in a degree which he had not fully appreciated -before how vast a weight of dread had been lying upon him since the day -he lifted his voice against this bloody-minded outcast. - -Injun Joe's bowie-knife lay close by, its blade broken in two. The -great foundation-beam of the door had been chipped and hacked through, -with tedious labor; useless labor, too, it was, for the native rock -formed a sill outside it, and upon that stubborn material the knife had -wrought no effect; the only damage done was to the knife itself. But if -there had been no stony obstruction there the labor would have been -useless still, for if the beam had been wholly cut away Injun Joe could -not have squeezed his body under the door, and he knew it. So he had -only hacked that place in order to be doing something--in order to pass -the weary time--in order to employ his tortured faculties. Ordinarily -one could find half a dozen bits of candle stuck around in the crevices -of this vestibule, left there by tourists; but there were none now. The -prisoner had searched them out and eaten them. He had also contrived to -catch a few bats, and these, also, he had eaten, leaving only their -claws. The poor unfortunate had starved to death. In one place, near at -hand, a stalagmite had been slowly growing up from the ground for ages, -builded by the water-drip from a stalactite overhead. The captive had -broken off the stalagmite, and upon the stump had placed a stone, -wherein he had scooped a shallow hollow to catch the precious drop -that fell once in every three minutes with the dreary regularity of a -clock-tick--a dessertspoonful once in four and twenty hours. That drop -was falling when the Pyramids were new; when Troy fell; when the -foundations of Rome were laid; when Christ was crucified; when the -Conqueror created the British empire; when Columbus sailed; when the -massacre at Lexington was "news." It is falling now; it will still be -falling when all these things shall have sunk down the afternoon of -history, and the twilight of tradition, and been swallowed up in the -thick night of oblivion. Has everything a purpose and a mission? Did -this drop fall patiently during five thousand years to be ready for -this flitting human insect's need? and has it another important object -to accomplish ten thousand years to come? No matter. It is many and -many a year since the hapless half-breed scooped out the stone to catch -the priceless drops, but to this day the tourist stares longest at that -pathetic stone and that slow-dropping water when he comes to see the -wonders of McDougal's cave. Injun Joe's cup stands first in the list of -the cavern's marvels; even "Aladdin's Palace" cannot rival it. - -Injun Joe was buried near the mouth of the cave; and people flocked -there in boats and wagons from the towns and from all the farms and -hamlets for seven miles around; they brought their children, and all -sorts of provisions, and confessed that they had had almost as -satisfactory a time at the funeral as they could have had at the -hanging. - -This funeral stopped the further growth of one thing--the petition to -the governor for Injun Joe's pardon. The petition had been largely -signed; many tearful and eloquent meetings had been held, and a -committee of sappy women been appointed to go in deep mourning and wail -around the governor, and implore him to be a merciful ass and trample -his duty under foot. Injun Joe was believed to have killed five -citizens of the village, but what of that? If he had been Satan himself -there would have been plenty of weaklings ready to scribble their names -to a pardon-petition, and drip a tear on it from their permanently -impaired and leaky water-works. - -The morning after the funeral Tom took Huck to a private place to have -an important talk. Huck had learned all about Tom's adventure from the -Welshman and the Widow Douglas, by this time, but Tom said he reckoned -there was one thing they had not told him; that thing was what he -wanted to talk about now. Huck's face saddened. He said: - -"I know what it is. You got into No. 2 and never found anything but -whiskey. Nobody told me it was you; but I just knowed it must 'a' ben -you, soon as I heard 'bout that whiskey business; and I knowed you -hadn't got the money becuz you'd 'a' got at me some way or other and -told me even if you was mum to everybody else. Tom, something's always -told me we'd never get holt of that swag." - -"Why, Huck, I never told on that tavern-keeper. YOU know his tavern -was all right the Saturday I went to the picnic. Don't you remember you -was to watch there that night?" - -"Oh yes! Why, it seems 'bout a year ago. It was that very night that I -follered Injun Joe to the widder's." - -"YOU followed him?" - -"Yes--but you keep mum. I reckon Injun Joe's left friends behind him, -and I don't want 'em souring on me and doing me mean tricks. If it -hadn't ben for me he'd be down in Texas now, all right." - -Then Huck told his entire adventure in confidence to Tom, who had only -heard of the Welshman's part of it before. - -"Well," said Huck, presently, coming back to the main question, -"whoever nipped the whiskey in No. 2, nipped the money, too, I reckon ---anyways it's a goner for us, Tom." - -"Huck, that money wasn't ever in No. 2!" - -"What!" Huck searched his comrade's face keenly. "Tom, have you got on -the track of that money again?" - -"Huck, it's in the cave!" - -Huck's eyes blazed. - -"Say it again, Tom." - -"The money's in the cave!" - -"Tom--honest injun, now--is it fun, or earnest?" - -"Earnest, Huck--just as earnest as ever I was in my life. Will you go -in there with me and help get it out?" - -"I bet I will! I will if it's where we can blaze our way to it and not -get lost." - -"Huck, we can do that without the least little bit of trouble in the -world." - -"Good as wheat! What makes you think the money's--" - -"Huck, you just wait till we get in there. If we don't find it I'll -agree to give you my drum and every thing I've got in the world. I -will, by jings." - -"All right--it's a whiz. When do you say?" - -"Right now, if you say it. Are you strong enough?" - -"Is it far in the cave? I ben on my pins a little, three or four days, -now, but I can't walk more'n a mile, Tom--least I don't think I could." - -"It's about five mile into there the way anybody but me would go, -Huck, but there's a mighty short cut that they don't anybody but me -know about. Huck, I'll take you right to it in a skiff. I'll float the -skiff down there, and I'll pull it back again all by myself. You -needn't ever turn your hand over." - -"Less start right off, Tom." - -"All right. We want some bread and meat, and our pipes, and a little -bag or two, and two or three kite-strings, and some of these -new-fangled things they call lucifer matches. I tell you, many's -the time I wished I had some when I was in there before." - -A trifle after noon the boys borrowed a small skiff from a citizen who -was absent, and got under way at once. When they were several miles -below "Cave Hollow," Tom said: - -"Now you see this bluff here looks all alike all the way down from the -cave hollow--no houses, no wood-yards, bushes all alike. But do you see -that white place up yonder where there's been a landslide? Well, that's -one of my marks. We'll get ashore, now." - -They landed. - -"Now, Huck, where we're a-standing you could touch that hole I got out -of with a fishing-pole. See if you can find it." - -Huck searched all the place about, and found nothing. Tom proudly -marched into a thick clump of sumach bushes and said: - -"Here you are! Look at it, Huck; it's the snuggest hole in this -country. You just keep mum about it. All along I've been wanting to be -a robber, but I knew I'd got to have a thing like this, and where to -run across it was the bother. We've got it now, and we'll keep it -quiet, only we'll let Joe Harper and Ben Rogers in--because of course -there's got to be a Gang, or else there wouldn't be any style about it. -Tom Sawyer's Gang--it sounds splendid, don't it, Huck?" - -"Well, it just does, Tom. And who'll we rob?" - -"Oh, most anybody. Waylay people--that's mostly the way." - -"And kill them?" - -"No, not always. Hive them in the cave till they raise a ransom." - -"What's a ransom?" - -"Money. You make them raise all they can, off'n their friends; and -after you've kept them a year, if it ain't raised then you kill them. -That's the general way. Only you don't kill the women. You shut up the -women, but you don't kill them. They're always beautiful and rich, and -awfully scared. You take their watches and things, but you always take -your hat off and talk polite. They ain't anybody as polite as robbers ---you'll see that in any book. Well, the women get to loving you, and -after they've been in the cave a week or two weeks they stop crying and -after that you couldn't get them to leave. If you drove them out they'd -turn right around and come back. It's so in all the books." - -"Why, it's real bully, Tom. I believe it's better'n to be a pirate." - -"Yes, it's better in some ways, because it's close to home and -circuses and all that." - -By this time everything was ready and the boys entered the hole, Tom -in the lead. They toiled their way to the farther end of the tunnel, -then made their spliced kite-strings fast and moved on. A few steps -brought them to the spring, and Tom felt a shudder quiver all through -him. He showed Huck the fragment of candle-wick perched on a lump of -clay against the wall, and described how he and Becky had watched the -flame struggle and expire. - -The boys began to quiet down to whispers, now, for the stillness and -gloom of the place oppressed their spirits. They went on, and presently -entered and followed Tom's other corridor until they reached the -"jumping-off place." The candles revealed the fact that it was not -really a precipice, but only a steep clay hill twenty or thirty feet -high. Tom whispered: - -"Now I'll show you something, Huck." - -He held his candle aloft and said: - -"Look as far around the corner as you can. Do you see that? There--on -the big rock over yonder--done with candle-smoke." - -"Tom, it's a CROSS!" - -"NOW where's your Number Two? 'UNDER THE CROSS,' hey? Right yonder's -where I saw Injun Joe poke up his candle, Huck!" - -Huck stared at the mystic sign awhile, and then said with a shaky voice: - -"Tom, less git out of here!" - -"What! and leave the treasure?" - -"Yes--leave it. Injun Joe's ghost is round about there, certain." - -"No it ain't, Huck, no it ain't. It would ha'nt the place where he -died--away out at the mouth of the cave--five mile from here." - -"No, Tom, it wouldn't. It would hang round the money. I know the ways -of ghosts, and so do you." - -Tom began to fear that Huck was right. Misgivings gathered in his -mind. But presently an idea occurred to him-- - -"Lookyhere, Huck, what fools we're making of ourselves! Injun Joe's -ghost ain't a going to come around where there's a cross!" - -The point was well taken. It had its effect. - -"Tom, I didn't think of that. But that's so. It's luck for us, that -cross is. I reckon we'll climb down there and have a hunt for that box." - -Tom went first, cutting rude steps in the clay hill as he descended. -Huck followed. Four avenues opened out of the small cavern which the -great rock stood in. The boys examined three of them with no result. -They found a small recess in the one nearest the base of the rock, with -a pallet of blankets spread down in it; also an old suspender, some -bacon rind, and the well-gnawed bones of two or three fowls. But there -was no money-box. The lads searched and researched this place, but in -vain. Tom said: - -"He said UNDER the cross. Well, this comes nearest to being under the -cross. It can't be under the rock itself, because that sets solid on -the ground." - -They searched everywhere once more, and then sat down discouraged. -Huck could suggest nothing. By-and-by Tom said: - -"Lookyhere, Huck, there's footprints and some candle-grease on the -clay about one side of this rock, but not on the other sides. Now, -what's that for? I bet you the money IS under the rock. I'm going to -dig in the clay." - -"That ain't no bad notion, Tom!" said Huck with animation. - -Tom's "real Barlow" was out at once, and he had not dug four inches -before he struck wood. - -"Hey, Huck!--you hear that?" - -Huck began to dig and scratch now. Some boards were soon uncovered and -removed. They had concealed a natural chasm which led under the rock. -Tom got into this and held his candle as far under the rock as he -could, but said he could not see to the end of the rift. He proposed to -explore. He stooped and passed under; the narrow way descended -gradually. He followed its winding course, first to the right, then to -the left, Huck at his heels. Tom turned a short curve, by-and-by, and -exclaimed: - -"My goodness, Huck, lookyhere!" - -It was the treasure-box, sure enough, occupying a snug little cavern, -along with an empty powder-keg, a couple of guns in leather cases, two -or three pairs of old moccasins, a leather belt, and some other rubbish -well soaked with the water-drip. - -"Got it at last!" said Huck, ploughing among the tarnished coins with -his hand. "My, but we're rich, Tom!" - -"Huck, I always reckoned we'd get it. It's just too good to believe, -but we HAVE got it, sure! Say--let's not fool around here. Let's snake -it out. Lemme see if I can lift the box." - -It weighed about fifty pounds. Tom could lift it, after an awkward -fashion, but could not carry it conveniently. - -"I thought so," he said; "THEY carried it like it was heavy, that day -at the ha'nted house. I noticed that. I reckon I was right to think of -fetching the little bags along." - -The money was soon in the bags and the boys took it up to the cross -rock. - -"Now less fetch the guns and things," said Huck. - -"No, Huck--leave them there. They're just the tricks to have when we -go to robbing. We'll keep them there all the time, and we'll hold our -orgies there, too. It's an awful snug place for orgies." - -"What orgies?" - -"I dono. But robbers always have orgies, and of course we've got to -have them, too. Come along, Huck, we've been in here a long time. It's -getting late, I reckon. I'm hungry, too. We'll eat and smoke when we -get to the skiff." - -They presently emerged into the clump of sumach bushes, looked warily -out, found the coast clear, and were soon lunching and smoking in the -skiff. As the sun dipped toward the horizon they pushed out and got -under way. Tom skimmed up the shore through the long twilight, chatting -cheerily with Huck, and landed shortly after dark. - -"Now, Huck," said Tom, "we'll hide the money in the loft of the -widow's woodshed, and I'll come up in the morning and we'll count it -and divide, and then we'll hunt up a place out in the woods for it -where it will be safe. Just you lay quiet here and watch the stuff till -I run and hook Benny Taylor's little wagon; I won't be gone a minute." - -He disappeared, and presently returned with the wagon, put the two -small sacks into it, threw some old rags on top of them, and started -off, dragging his cargo behind him. When the boys reached the -Welshman's house, they stopped to rest. Just as they were about to move -on, the Welshman stepped out and said: - -"Hallo, who's that?" - -"Huck and Tom Sawyer." - -"Good! Come along with me, boys, you are keeping everybody waiting. -Here--hurry up, trot ahead--I'll haul the wagon for you. Why, it's not -as light as it might be. Got bricks in it?--or old metal?" - -"Old metal," said Tom. - -"I judged so; the boys in this town will take more trouble and fool -away more time hunting up six bits' worth of old iron to sell to the -foundry than they would to make twice the money at regular work. But -that's human nature--hurry along, hurry along!" - -The boys wanted to know what the hurry was about. - -"Never mind; you'll see, when we get to the Widow Douglas'." - -Huck said with some apprehension--for he was long used to being -falsely accused: - -"Mr. Jones, we haven't been doing nothing." - -The Welshman laughed. - -"Well, I don't know, Huck, my boy. I don't know about that. Ain't you -and the widow good friends?" - -"Yes. Well, she's ben good friends to me, anyway." - -"All right, then. What do you want to be afraid for?" - -This question was not entirely answered in Huck's slow mind before he -found himself pushed, along with Tom, into Mrs. Douglas' drawing-room. -Mr. Jones left the wagon near the door and followed. - -The place was grandly lighted, and everybody that was of any -consequence in the village was there. The Thatchers were there, the -Harpers, the Rogerses, Aunt Polly, Sid, Mary, the minister, the editor, -and a great many more, and all dressed in their best. The widow -received the boys as heartily as any one could well receive two such -looking beings. They were covered with clay and candle-grease. Aunt -Polly blushed crimson with humiliation, and frowned and shook her head -at Tom. Nobody suffered half as much as the two boys did, however. Mr. -Jones said: - -"Tom wasn't at home, yet, so I gave him up; but I stumbled on him and -Huck right at my door, and so I just brought them along in a hurry." - -"And you did just right," said the widow. "Come with me, boys." - -She took them to a bedchamber and said: - -"Now wash and dress yourselves. Here are two new suits of clothes ---shirts, socks, everything complete. They're Huck's--no, no thanks, -Huck--Mr. Jones bought one and I the other. But they'll fit both of you. -Get into them. We'll wait--come down when you are slicked up enough." - -Then she left. - - - -CHAPTER XXXIV - -HUCK said: "Tom, we can slope, if we can find a rope. The window ain't -high from the ground." - -"Shucks! what do you want to slope for?" - -"Well, I ain't used to that kind of a crowd. I can't stand it. I ain't -going down there, Tom." - -"Oh, bother! It ain't anything. I don't mind it a bit. I'll take care -of you." - -Sid appeared. - -"Tom," said he, "auntie has been waiting for you all the afternoon. -Mary got your Sunday clothes ready, and everybody's been fretting about -you. Say--ain't this grease and clay, on your clothes?" - -"Now, Mr. Siddy, you jist 'tend to your own business. What's all this -blow-out about, anyway?" - -"It's one of the widow's parties that she's always having. This time -it's for the Welshman and his sons, on account of that scrape they -helped her out of the other night. And say--I can tell you something, -if you want to know." - -"Well, what?" - -"Why, old Mr. Jones is going to try to spring something on the people -here to-night, but I overheard him tell auntie to-day about it, as a -secret, but I reckon it's not much of a secret now. Everybody knows ---the widow, too, for all she tries to let on she don't. Mr. Jones was -bound Huck should be here--couldn't get along with his grand secret -without Huck, you know!" - -"Secret about what, Sid?" - -"About Huck tracking the robbers to the widow's. I reckon Mr. Jones -was going to make a grand time over his surprise, but I bet you it will -drop pretty flat." - -Sid chuckled in a very contented and satisfied way. - -"Sid, was it you that told?" - -"Oh, never mind who it was. SOMEBODY told--that's enough." - -"Sid, there's only one person in this town mean enough to do that, and -that's you. If you had been in Huck's place you'd 'a' sneaked down the -hill and never told anybody on the robbers. You can't do any but mean -things, and you can't bear to see anybody praised for doing good ones. -There--no thanks, as the widow says"--and Tom cuffed Sid's ears and -helped him to the door with several kicks. "Now go and tell auntie if -you dare--and to-morrow you'll catch it!" - -Some minutes later the widow's guests were at the supper-table, and a -dozen children were propped up at little side-tables in the same room, -after the fashion of that country and that day. At the proper time Mr. -Jones made his little speech, in which he thanked the widow for the -honor she was doing himself and his sons, but said that there was -another person whose modesty-- - -And so forth and so on. He sprung his secret about Huck's share in the -adventure in the finest dramatic manner he was master of, but the -surprise it occasioned was largely counterfeit and not as clamorous and -effusive as it might have been under happier circumstances. However, -the widow made a pretty fair show of astonishment, and heaped so many -compliments and so much gratitude upon Huck that he almost forgot the -nearly intolerable discomfort of his new clothes in the entirely -intolerable discomfort of being set up as a target for everybody's gaze -and everybody's laudations. - -The widow said she meant to give Huck a home under her roof and have -him educated; and that when she could spare the money she would start -him in business in a modest way. Tom's chance was come. He said: - -"Huck don't need it. Huck's rich." - -Nothing but a heavy strain upon the good manners of the company kept -back the due and proper complimentary laugh at this pleasant joke. But -the silence was a little awkward. Tom broke it: - -"Huck's got money. Maybe you don't believe it, but he's got lots of -it. Oh, you needn't smile--I reckon I can show you. You just wait a -minute." - -Tom ran out of doors. The company looked at each other with a -perplexed interest--and inquiringly at Huck, who was tongue-tied. - -"Sid, what ails Tom?" said Aunt Polly. "He--well, there ain't ever any -making of that boy out. I never--" - -Tom entered, struggling with the weight of his sacks, and Aunt Polly -did not finish her sentence. Tom poured the mass of yellow coin upon -the table and said: - -"There--what did I tell you? Half of it's Huck's and half of it's mine!" - -The spectacle took the general breath away. All gazed, nobody spoke -for a moment. Then there was a unanimous call for an explanation. Tom -said he could furnish it, and he did. The tale was long, but brimful of -interest. There was scarcely an interruption from any one to break the -charm of its flow. When he had finished, Mr. Jones said: - -"I thought I had fixed up a little surprise for this occasion, but it -don't amount to anything now. This one makes it sing mighty small, I'm -willing to allow." - -The money was counted. The sum amounted to a little over twelve -thousand dollars. It was more than any one present had ever seen at one -time before, though several persons were there who were worth -considerably more than that in property. - - - -CHAPTER XXXV - -THE reader may rest satisfied that Tom's and Huck's windfall made a -mighty stir in the poor little village of St. Petersburg. So vast a -sum, all in actual cash, seemed next to incredible. It was talked -about, gloated over, glorified, until the reason of many of the -citizens tottered under the strain of the unhealthy excitement. Every -"haunted" house in St. Petersburg and the neighboring villages was -dissected, plank by plank, and its foundations dug up and ransacked for -hidden treasure--and not by boys, but men--pretty grave, unromantic -men, too, some of them. Wherever Tom and Huck appeared they were -courted, admired, stared at. The boys were not able to remember that -their remarks had possessed weight before; but now their sayings were -treasured and repeated; everything they did seemed somehow to be -regarded as remarkable; they had evidently lost the power of doing and -saying commonplace things; moreover, their past history was raked up -and discovered to bear marks of conspicuous originality. The village -paper published biographical sketches of the boys. - -The Widow Douglas put Huck's money out at six per cent., and Judge -Thatcher did the same with Tom's at Aunt Polly's request. Each lad had -an income, now, that was simply prodigious--a dollar for every week-day -in the year and half of the Sundays. It was just what the minister got ---no, it was what he was promised--he generally couldn't collect it. A -dollar and a quarter a week would board, lodge, and school a boy in -those old simple days--and clothe him and wash him, too, for that -matter. - -Judge Thatcher had conceived a great opinion of Tom. He said that no -commonplace boy would ever have got his daughter out of the cave. When -Becky told her father, in strict confidence, how Tom had taken her -whipping at school, the Judge was visibly moved; and when she pleaded -grace for the mighty lie which Tom had told in order to shift that -whipping from her shoulders to his own, the Judge said with a fine -outburst that it was a noble, a generous, a magnanimous lie--a lie that -was worthy to hold up its head and march down through history breast to -breast with George Washington's lauded Truth about the hatchet! Becky -thought her father had never looked so tall and so superb as when he -walked the floor and stamped his foot and said that. She went straight -off and told Tom about it. - -Judge Thatcher hoped to see Tom a great lawyer or a great soldier some -day. He said he meant to look to it that Tom should be admitted to the -National Military Academy and afterward trained in the best law school -in the country, in order that he might be ready for either career or -both. - -Huck Finn's wealth and the fact that he was now under the Widow -Douglas' protection introduced him into society--no, dragged him into -it, hurled him into it--and his sufferings were almost more than he -could bear. The widow's servants kept him clean and neat, combed and -brushed, and they bedded him nightly in unsympathetic sheets that had -not one little spot or stain which he could press to his heart and know -for a friend. He had to eat with a knife and fork; he had to use -napkin, cup, and plate; he had to learn his book, he had to go to -church; he had to talk so properly that speech was become insipid in -his mouth; whithersoever he turned, the bars and shackles of -civilization shut him in and bound him hand and foot. - -He bravely bore his miseries three weeks, and then one day turned up -missing. For forty-eight hours the widow hunted for him everywhere in -great distress. The public were profoundly concerned; they searched -high and low, they dragged the river for his body. Early the third -morning Tom Sawyer wisely went poking among some old empty hogsheads -down behind the abandoned slaughter-house, and in one of them he found -the refugee. Huck had slept there; he had just breakfasted upon some -stolen odds and ends of food, and was lying off, now, in comfort, with -his pipe. He was unkempt, uncombed, and clad in the same old ruin of -rags that had made him picturesque in the days when he was free and -happy. Tom routed him out, told him the trouble he had been causing, -and urged him to go home. Huck's face lost its tranquil content, and -took a melancholy cast. He said: - -"Don't talk about it, Tom. I've tried it, and it don't work; it don't -work, Tom. It ain't for me; I ain't used to it. The widder's good to -me, and friendly; but I can't stand them ways. She makes me get up just -at the same time every morning; she makes me wash, they comb me all to -thunder; she won't let me sleep in the woodshed; I got to wear them -blamed clothes that just smothers me, Tom; they don't seem to any air -git through 'em, somehow; and they're so rotten nice that I can't set -down, nor lay down, nor roll around anywher's; I hain't slid on a -cellar-door for--well, it 'pears to be years; I got to go to church and -sweat and sweat--I hate them ornery sermons! I can't ketch a fly in -there, I can't chaw. I got to wear shoes all Sunday. The widder eats by -a bell; she goes to bed by a bell; she gits up by a bell--everything's -so awful reg'lar a body can't stand it." - -"Well, everybody does that way, Huck." - -"Tom, it don't make no difference. I ain't everybody, and I can't -STAND it. It's awful to be tied up so. And grub comes too easy--I don't -take no interest in vittles, that way. I got to ask to go a-fishing; I -got to ask to go in a-swimming--dern'd if I hain't got to ask to do -everything. Well, I'd got to talk so nice it wasn't no comfort--I'd got -to go up in the attic and rip out awhile, every day, to git a taste in -my mouth, or I'd a died, Tom. The widder wouldn't let me smoke; she -wouldn't let me yell, she wouldn't let me gape, nor stretch, nor -scratch, before folks--" [Then with a spasm of special irritation and -injury]--"And dad fetch it, she prayed all the time! I never see such a -woman! I HAD to shove, Tom--I just had to. And besides, that school's -going to open, and I'd a had to go to it--well, I wouldn't stand THAT, -Tom. Looky here, Tom, being rich ain't what it's cracked up to be. It's -just worry and worry, and sweat and sweat, and a-wishing you was dead -all the time. Now these clothes suits me, and this bar'l suits me, and -I ain't ever going to shake 'em any more. Tom, I wouldn't ever got into -all this trouble if it hadn't 'a' ben for that money; now you just take -my sheer of it along with your'n, and gimme a ten-center sometimes--not -many times, becuz I don't give a dern for a thing 'thout it's tollable -hard to git--and you go and beg off for me with the widder." - -"Oh, Huck, you know I can't do that. 'Tain't fair; and besides if -you'll try this thing just a while longer you'll come to like it." - -"Like it! Yes--the way I'd like a hot stove if I was to set on it long -enough. No, Tom, I won't be rich, and I won't live in them cussed -smothery houses. I like the woods, and the river, and hogsheads, and -I'll stick to 'em, too. Blame it all! just as we'd got guns, and a -cave, and all just fixed to rob, here this dern foolishness has got to -come up and spile it all!" - -Tom saw his opportunity-- - -"Lookyhere, Huck, being rich ain't going to keep me back from turning -robber." - -"No! Oh, good-licks; are you in real dead-wood earnest, Tom?" - -"Just as dead earnest as I'm sitting here. But Huck, we can't let you -into the gang if you ain't respectable, you know." - -Huck's joy was quenched. - -"Can't let me in, Tom? Didn't you let me go for a pirate?" - -"Yes, but that's different. A robber is more high-toned than what a -pirate is--as a general thing. In most countries they're awful high up -in the nobility--dukes and such." - -"Now, Tom, hain't you always ben friendly to me? You wouldn't shet me -out, would you, Tom? You wouldn't do that, now, WOULD you, Tom?" - -"Huck, I wouldn't want to, and I DON'T want to--but what would people -say? Why, they'd say, 'Mph! Tom Sawyer's Gang! pretty low characters in -it!' They'd mean you, Huck. You wouldn't like that, and I wouldn't." - -Huck was silent for some time, engaged in a mental struggle. Finally -he said: - -"Well, I'll go back to the widder for a month and tackle it and see if -I can come to stand it, if you'll let me b'long to the gang, Tom." - -"All right, Huck, it's a whiz! Come along, old chap, and I'll ask the -widow to let up on you a little, Huck." - -"Will you, Tom--now will you? That's good. If she'll let up on some of -the roughest things, I'll smoke private and cuss private, and crowd -through or bust. When you going to start the gang and turn robbers?" - -"Oh, right off. We'll get the boys together and have the initiation -to-night, maybe." - -"Have the which?" - -"Have the initiation." - -"What's that?" - -"It's to swear to stand by one another, and never tell the gang's -secrets, even if you're chopped all to flinders, and kill anybody and -all his family that hurts one of the gang." - -"That's gay--that's mighty gay, Tom, I tell you." - -"Well, I bet it is. And all that swearing's got to be done at -midnight, in the lonesomest, awfulest place you can find--a ha'nted -house is the best, but they're all ripped up now." - -"Well, midnight's good, anyway, Tom." - -"Yes, so it is. And you've got to swear on a coffin, and sign it with -blood." - -"Now, that's something LIKE! Why, it's a million times bullier than -pirating. I'll stick to the widder till I rot, Tom; and if I git to be -a reg'lar ripper of a robber, and everybody talking 'bout it, I reckon -she'll be proud she snaked me in out of the wet." - - - -CONCLUSION - -SO endeth this chronicle. It being strictly a history of a BOY, it -must stop here; the story could not go much further without becoming -the history of a MAN. When one writes a novel about grown people, he -knows exactly where to stop--that is, with a marriage; but when he -writes of juveniles, he must stop where he best can. - -Most of the characters that perform in this book still live, and are -prosperous and happy. Some day it may seem worth while to take up the -story of the younger ones again and see what sort of men and women they -turned out to be; therefore it will be wisest not to reveal any of that -part of their lives at present. diff --git a/libgo/go/compress/zlib/reader.go b/libgo/go/compress/zlib/reader.go index 2efa1930354..a195b380d8d 100644 --- a/libgo/go/compress/zlib/reader.go +++ b/libgo/go/compress/zlib/reader.go @@ -51,7 +51,7 @@ type reader struct { scratch [4]byte } -// Resetter resets a ReadCloser returned by NewReader or NewReaderDict to +// Resetter resets a ReadCloser returned by NewReader or NewReaderDict // to switch to a new underlying Reader. This permits reusing a ReadCloser // instead of allocating a new one. type Resetter interface { diff --git a/libgo/go/compress/zlib/writer.go b/libgo/go/compress/zlib/writer.go index a7b219467ee..9986e3834d4 100644 --- a/libgo/go/compress/zlib/writer.go +++ b/libgo/go/compress/zlib/writer.go @@ -6,6 +6,7 @@ package zlib import ( "compress/flate" + "encoding/binary" "fmt" "hash" "hash/adler32" @@ -120,11 +121,7 @@ func (z *Writer) writeHeader() (err error) { } if z.dict != nil { // The next four bytes are the Adler-32 checksum of the dictionary. - checksum := adler32.Checksum(z.dict) - z.scratch[0] = uint8(checksum >> 24) - z.scratch[1] = uint8(checksum >> 16) - z.scratch[2] = uint8(checksum >> 8) - z.scratch[3] = uint8(checksum >> 0) + binary.BigEndian.PutUint32(z.scratch[:], adler32.Checksum(z.dict)) if _, err = z.w.Write(z.scratch[0:4]); err != nil { return err } @@ -190,10 +187,7 @@ func (z *Writer) Close() error { } checksum := z.digest.Sum32() // ZLIB (RFC 1950) is big-endian, unlike GZIP (RFC 1952). - z.scratch[0] = uint8(checksum >> 24) - z.scratch[1] = uint8(checksum >> 16) - z.scratch[2] = uint8(checksum >> 8) - z.scratch[3] = uint8(checksum >> 0) + binary.BigEndian.PutUint32(z.scratch[:], checksum) _, z.err = z.w.Write(z.scratch[0:4]) return z.err } diff --git a/libgo/go/container/heap/heap.go b/libgo/go/container/heap/heap.go index 67b5efcac7e..2e09da8613a 100644 --- a/libgo/go/container/heap/heap.go +++ b/libgo/go/container/heap/heap.go @@ -38,7 +38,7 @@ type Interface interface { // Init establishes the heap invariants required by the other routines in this package. // Init is idempotent with respect to the heap invariants // and may be called whenever the heap invariants may have been invalidated. -// Its complexity is O(n) where n = h.Len(). +// The complexity is O(n) where n = h.Len(). func Init(h Interface) { // heapify n := h.Len() @@ -47,18 +47,16 @@ func Init(h Interface) { } } -// Push pushes the element x onto the heap. The complexity is -// O(log(n)) where n = h.Len(). -// +// Push pushes the element x onto the heap. +// The complexity is O(log n) where n = h.Len(). func Push(h Interface, x interface{}) { h.Push(x) up(h, h.Len()-1) } -// Pop removes the minimum element (according to Less) from the heap -// and returns it. The complexity is O(log(n)) where n = h.Len(). -// It is equivalent to Remove(h, 0). -// +// Pop removes and returns the minimum element (according to Less) from the heap. +// The complexity is O(log n) where n = h.Len(). +// Pop is equivalent to Remove(h, 0). func Pop(h Interface) interface{} { n := h.Len() - 1 h.Swap(0, n) @@ -66,9 +64,8 @@ func Pop(h Interface) interface{} { return h.Pop() } -// Remove removes the element at index i from the heap. -// The complexity is O(log(n)) where n = h.Len(). -// +// Remove removes and returns the element at index i from the heap. +// The complexity is O(log n) where n = h.Len(). func Remove(h Interface, i int) interface{} { n := h.Len() - 1 if n != i { @@ -83,7 +80,7 @@ func Remove(h Interface, i int) interface{} { // Fix re-establishes the heap ordering after the element at index i has changed its value. // Changing the value of the element at index i and then calling Fix is equivalent to, // but less expensive than, calling Remove(h, i) followed by a Push of the new value. -// The complexity is O(log(n)) where n = h.Len(). +// The complexity is O(log n) where n = h.Len(). func Fix(h Interface, i int) { if !down(h, i, h.Len()) { up(h, i) diff --git a/libgo/go/container/list/list.go b/libgo/go/container/list/list.go index dc4260e1316..b8b599aabb1 100644 --- a/libgo/go/container/list/list.go +++ b/libgo/go/container/list/list.go @@ -116,6 +116,23 @@ func (l *List) remove(e *Element) *Element { return e } +// move moves e to next to at and returns e. +func (l *List) move(e, at *Element) *Element { + if e == at { + return e + } + e.prev.next = e.next + e.next.prev = e.prev + + n := at.next + at.next = e + e.prev = at + e.next = n + n.prev = e + + return e +} + // Remove removes e from l if e is an element of list l. // It returns the element value e.Value. // The element must not be nil. @@ -170,7 +187,7 @@ func (l *List) MoveToFront(e *Element) { return } // see comment in List.Remove about initialization of l - l.insert(l.remove(e), &l.root) + l.move(e, &l.root) } // MoveToBack moves element e to the back of list l. @@ -181,7 +198,7 @@ func (l *List) MoveToBack(e *Element) { return } // see comment in List.Remove about initialization of l - l.insert(l.remove(e), l.root.prev) + l.move(e, l.root.prev) } // MoveBefore moves element e to its new position before mark. @@ -191,7 +208,7 @@ func (l *List) MoveBefore(e, mark *Element) { if e.list != l || e == mark || mark.list != l { return } - l.insert(l.remove(e), mark.prev) + l.move(e, mark.prev) } // MoveAfter moves element e to its new position after mark. @@ -201,7 +218,7 @@ func (l *List) MoveAfter(e, mark *Element) { if e.list != l || e == mark || mark.list != l { return } - l.insert(l.remove(e), mark) + l.move(e, mark) } // PushBackList inserts a copy of an other list at the back of list l. diff --git a/libgo/go/context/context.go b/libgo/go/context/context.go index 1b4fa41b8cc..21a40d59477 100644 --- a/libgo/go/context/context.go +++ b/libgo/go/context/context.go @@ -210,8 +210,7 @@ func Background() Context { // TODO returns a non-nil, empty Context. Code should use context.TODO when // it's unclear which Context to use or it is not yet available (because the // surrounding function has not yet been extended to accept a Context -// parameter). TODO is recognized by static analysis tools that determine -// whether Contexts are propagated correctly in a program. +// parameter). func TODO() Context { return todo } @@ -394,7 +393,7 @@ func WithDeadline(parent Context, d time.Time) (Context, CancelFunc) { dur := time.Until(d) if dur <= 0 { c.cancel(true, DeadlineExceeded) // deadline has already passed - return c, func() { c.cancel(true, Canceled) } + return c, func() { c.cancel(false, Canceled) } } c.mu.Lock() defer c.mu.Unlock() diff --git a/libgo/go/crypto/aes/aes_test.go b/libgo/go/crypto/aes/aes_test.go index bedc2da9465..1e8bac4bb5f 100644 --- a/libgo/go/crypto/aes/aes_test.go +++ b/libgo/go/crypto/aes/aes_test.go @@ -231,12 +231,10 @@ L: continue L } } - if dec != nil { - for j, v := range dec { - if v != tt.dec[j] { - t.Errorf("key %d: dec[%d] = %#x, want %#x", i, j, v, tt.dec[j]) - continue L - } + for j, v := range dec { + if v != tt.dec[j] { + t.Errorf("key %d: dec[%d] = %#x, want %#x", i, j, v, tt.dec[j]) + continue L } } } diff --git a/libgo/go/crypto/aes/block.go b/libgo/go/crypto/aes/block.go index 8647019d580..40bd0d335d3 100644 --- a/libgo/go/crypto/aes/block.go +++ b/libgo/go/crypto/aes/block.go @@ -36,14 +36,17 @@ package aes +import ( + "encoding/binary" +) + // Encrypt one block from src into dst, using the expanded key xk. func encryptBlockGo(xk []uint32, dst, src []byte) { - var s0, s1, s2, s3, t0, t1, t2, t3 uint32 - - s0 = uint32(src[0])<<24 | uint32(src[1])<<16 | uint32(src[2])<<8 | uint32(src[3]) - s1 = uint32(src[4])<<24 | uint32(src[5])<<16 | uint32(src[6])<<8 | uint32(src[7]) - s2 = uint32(src[8])<<24 | uint32(src[9])<<16 | uint32(src[10])<<8 | uint32(src[11]) - s3 = uint32(src[12])<<24 | uint32(src[13])<<16 | uint32(src[14])<<8 | uint32(src[15]) + _ = src[15] // early bounds check + s0 := binary.BigEndian.Uint32(src[0:4]) + s1 := binary.BigEndian.Uint32(src[4:8]) + s2 := binary.BigEndian.Uint32(src[8:12]) + s3 := binary.BigEndian.Uint32(src[12:16]) // First round just XORs input with key. s0 ^= xk[0] @@ -55,6 +58,7 @@ func encryptBlockGo(xk []uint32, dst, src []byte) { // Number of rounds is set by length of expanded key. nr := len(xk)/4 - 2 // - 2: one above, one more below k := 4 + var t0, t1, t2, t3 uint32 for r := 0; r < nr; r++ { t0 = xk[k+0] ^ te0[uint8(s0>>24)] ^ te1[uint8(s1>>16)] ^ te2[uint8(s2>>8)] ^ te3[uint8(s3)] t1 = xk[k+1] ^ te0[uint8(s1>>24)] ^ te1[uint8(s2>>16)] ^ te2[uint8(s3>>8)] ^ te3[uint8(s0)] @@ -75,20 +79,20 @@ func encryptBlockGo(xk []uint32, dst, src []byte) { s2 ^= xk[k+2] s3 ^= xk[k+3] - dst[0], dst[1], dst[2], dst[3] = byte(s0>>24), byte(s0>>16), byte(s0>>8), byte(s0) - dst[4], dst[5], dst[6], dst[7] = byte(s1>>24), byte(s1>>16), byte(s1>>8), byte(s1) - dst[8], dst[9], dst[10], dst[11] = byte(s2>>24), byte(s2>>16), byte(s2>>8), byte(s2) - dst[12], dst[13], dst[14], dst[15] = byte(s3>>24), byte(s3>>16), byte(s3>>8), byte(s3) + _ = dst[15] // early bounds check + binary.BigEndian.PutUint32(dst[0:4], s0) + binary.BigEndian.PutUint32(dst[4:8], s1) + binary.BigEndian.PutUint32(dst[8:12], s2) + binary.BigEndian.PutUint32(dst[12:16], s3) } // Decrypt one block from src into dst, using the expanded key xk. func decryptBlockGo(xk []uint32, dst, src []byte) { - var s0, s1, s2, s3, t0, t1, t2, t3 uint32 - - s0 = uint32(src[0])<<24 | uint32(src[1])<<16 | uint32(src[2])<<8 | uint32(src[3]) - s1 = uint32(src[4])<<24 | uint32(src[5])<<16 | uint32(src[6])<<8 | uint32(src[7]) - s2 = uint32(src[8])<<24 | uint32(src[9])<<16 | uint32(src[10])<<8 | uint32(src[11]) - s3 = uint32(src[12])<<24 | uint32(src[13])<<16 | uint32(src[14])<<8 | uint32(src[15]) + _ = src[15] // early bounds check + s0 := binary.BigEndian.Uint32(src[0:4]) + s1 := binary.BigEndian.Uint32(src[4:8]) + s2 := binary.BigEndian.Uint32(src[8:12]) + s3 := binary.BigEndian.Uint32(src[12:16]) // First round just XORs input with key. s0 ^= xk[0] @@ -100,6 +104,7 @@ func decryptBlockGo(xk []uint32, dst, src []byte) { // Number of rounds is set by length of expanded key. nr := len(xk)/4 - 2 // - 2: one above, one more below k := 4 + var t0, t1, t2, t3 uint32 for r := 0; r < nr; r++ { t0 = xk[k+0] ^ td0[uint8(s0>>24)] ^ td1[uint8(s3>>16)] ^ td2[uint8(s2>>8)] ^ td3[uint8(s1)] t1 = xk[k+1] ^ td0[uint8(s1>>24)] ^ td1[uint8(s0>>16)] ^ td2[uint8(s3>>8)] ^ td3[uint8(s2)] @@ -120,10 +125,11 @@ func decryptBlockGo(xk []uint32, dst, src []byte) { s2 ^= xk[k+2] s3 ^= xk[k+3] - dst[0], dst[1], dst[2], dst[3] = byte(s0>>24), byte(s0>>16), byte(s0>>8), byte(s0) - dst[4], dst[5], dst[6], dst[7] = byte(s1>>24), byte(s1>>16), byte(s1>>8), byte(s1) - dst[8], dst[9], dst[10], dst[11] = byte(s2>>24), byte(s2>>16), byte(s2>>8), byte(s2) - dst[12], dst[13], dst[14], dst[15] = byte(s3>>24), byte(s3>>16), byte(s3>>8), byte(s3) + _ = dst[15] // early bounds check + binary.BigEndian.PutUint32(dst[0:4], s0) + binary.BigEndian.PutUint32(dst[4:8], s1) + binary.BigEndian.PutUint32(dst[8:12], s2) + binary.BigEndian.PutUint32(dst[12:16], s3) } // Apply sbox0 to each byte in w. @@ -144,7 +150,7 @@ func expandKeyGo(key []byte, enc, dec []uint32) { var i int nk := len(key) / 4 for i = 0; i < nk; i++ { - enc[i] = uint32(key[4*i])<<24 | uint32(key[4*i+1])<<16 | uint32(key[4*i+2])<<8 | uint32(key[4*i+3]) + enc[i] = binary.BigEndian.Uint32(key[4*i:]) } for ; i < len(enc); i++ { t := enc[i-1] diff --git a/libgo/go/crypto/aes/ctr_s390x.go b/libgo/go/crypto/aes/ctr_s390x.go index a3c43a326bb..aed493de814 100644 --- a/libgo/go/crypto/aes/ctr_s390x.go +++ b/libgo/go/crypto/aes/ctr_s390x.go @@ -9,7 +9,7 @@ package aes import ( "crypto/cipher" "crypto/internal/subtle" - "unsafe" + "encoding/binary" ) // Assert that aesCipherAsm implements the ctrAble interface. @@ -40,8 +40,8 @@ func (c *aesCipherAsm) NewCTR(iv []byte) cipher.Stream { } var ac aesctr ac.block = c - ac.ctr[0] = *(*uint64)(unsafe.Pointer((&iv[0]))) // high bits - ac.ctr[1] = *(*uint64)(unsafe.Pointer((&iv[8]))) // low bits + ac.ctr[0] = binary.BigEndian.Uint64(iv[0:]) // high bits + ac.ctr[1] = binary.BigEndian.Uint64(iv[8:]) // low bits ac.buffer = ac.storage[:0] return &ac } @@ -50,10 +50,10 @@ func (c *aesctr) refill() { // Fill up the buffer with an incrementing count. c.buffer = c.storage[:streamBufferSize] c0, c1 := c.ctr[0], c.ctr[1] - for i := 0; i < streamBufferSize; i += BlockSize { - b0 := (*uint64)(unsafe.Pointer(&c.buffer[i])) - b1 := (*uint64)(unsafe.Pointer(&c.buffer[i+BlockSize/2])) - *b0, *b1 = c0, c1 + for i := 0; i < streamBufferSize; i += 16 { + binary.BigEndian.PutUint64(c.buffer[i+0:], c0) + binary.BigEndian.PutUint64(c.buffer[i+8:], c1) + // Increment in big endian: c0 is high, c1 is low. c1++ if c1 == 0 { diff --git a/libgo/go/crypto/aes/gcm_s390x.go b/libgo/go/crypto/aes/gcm_s390x.go index 18b0e82158d..bd1f9a0781d 100644 --- a/libgo/go/crypto/aes/gcm_s390x.go +++ b/libgo/go/crypto/aes/gcm_s390x.go @@ -10,6 +10,7 @@ import ( "crypto/cipher" subtleoverlap "crypto/internal/subtle" "crypto/subtle" + "encoding/binary" "errors" "internal/cpu" ) @@ -24,35 +25,15 @@ type gcmCount [16]byte // inc increments the rightmost 32-bits of the count value by 1. func (x *gcmCount) inc() { - // The compiler should optimize this to a 32-bit addition. - n := uint32(x[15]) | uint32(x[14])<<8 | uint32(x[13])<<16 | uint32(x[12])<<24 - n += 1 - x[12] = byte(n >> 24) - x[13] = byte(n >> 16) - x[14] = byte(n >> 8) - x[15] = byte(n) + binary.BigEndian.PutUint32(x[len(x)-4:], binary.BigEndian.Uint32(x[len(x)-4:])+1) } // gcmLengths writes len0 || len1 as big-endian values to a 16-byte array. func gcmLengths(len0, len1 uint64) [16]byte { - return [16]byte{ - byte(len0 >> 56), - byte(len0 >> 48), - byte(len0 >> 40), - byte(len0 >> 32), - byte(len0 >> 24), - byte(len0 >> 16), - byte(len0 >> 8), - byte(len0), - byte(len1 >> 56), - byte(len1 >> 48), - byte(len1 >> 40), - byte(len1 >> 32), - byte(len1 >> 24), - byte(len1 >> 16), - byte(len1 >> 8), - byte(len1), - } + v := [16]byte{} + binary.BigEndian.PutUint64(v[0:], len0) + binary.BigEndian.PutUint64(v[8:], len1) + return v } // gcmHashKey represents the 16-byte hash key required by the GHASH algorithm. diff --git a/libgo/go/crypto/cipher/benchmark_test.go b/libgo/go/crypto/cipher/benchmark_test.go index 1a3f1bdfaca..90d0cd71385 100644 --- a/libgo/go/crypto/cipher/benchmark_test.go +++ b/libgo/go/crypto/cipher/benchmark_test.go @@ -81,70 +81,49 @@ func BenchmarkAESGCMOpen8K(b *testing.B) { benchmarkAESGCMOpen(b, make([]byte, 8*1024)) } -// If we test exactly 1K blocks, we would generate exact multiples of -// the cipher's block size, and the cipher stream fragments would -// always be wordsize aligned, whereas non-aligned is a more typical -// use-case. -const almost1K = 1024 - 5 - -func BenchmarkAESCFBEncrypt1K(b *testing.B) { - buf := make([]byte, almost1K) +func benchmarkAESStream(b *testing.B, mode func(cipher.Block, []byte) cipher.Stream, buf []byte) { b.SetBytes(int64(len(buf))) var key [16]byte var iv [16]byte aes, _ := aes.NewCipher(key[:]) - ctr := cipher.NewCFBEncrypter(aes, iv[:]) + stream := mode(aes, iv[:]) b.ResetTimer() for i := 0; i < b.N; i++ { - ctr.XORKeyStream(buf, buf) + stream.XORKeyStream(buf, buf) } } -func BenchmarkAESCFBDecrypt1K(b *testing.B) { - buf := make([]byte, almost1K) - b.SetBytes(int64(len(buf))) - - var key [16]byte - var iv [16]byte - aes, _ := aes.NewCipher(key[:]) - ctr := cipher.NewCFBDecrypter(aes, iv[:]) +// If we test exactly 1K blocks, we would generate exact multiples of +// the cipher's block size, and the cipher stream fragments would +// always be wordsize aligned, whereas non-aligned is a more typical +// use-case. +const almost1K = 1024 - 5 +const almost8K = 8*1024 - 5 - b.ResetTimer() - for i := 0; i < b.N; i++ { - ctr.XORKeyStream(buf, buf) - } +func BenchmarkAESCFBEncrypt1K(b *testing.B) { + benchmarkAESStream(b, cipher.NewCFBEncrypter, make([]byte, almost1K)) } -func BenchmarkAESOFB1K(b *testing.B) { - buf := make([]byte, almost1K) - b.SetBytes(int64(len(buf))) +func BenchmarkAESCFBDecrypt1K(b *testing.B) { + benchmarkAESStream(b, cipher.NewCFBDecrypter, make([]byte, almost1K)) +} - var key [16]byte - var iv [16]byte - aes, _ := aes.NewCipher(key[:]) - ctr := cipher.NewOFB(aes, iv[:]) +func BenchmarkAESCFBDecrypt8K(b *testing.B) { + benchmarkAESStream(b, cipher.NewCFBDecrypter, make([]byte, almost8K)) +} - b.ResetTimer() - for i := 0; i < b.N; i++ { - ctr.XORKeyStream(buf, buf) - } +func BenchmarkAESOFB1K(b *testing.B) { + benchmarkAESStream(b, cipher.NewOFB, make([]byte, almost1K)) } func BenchmarkAESCTR1K(b *testing.B) { - buf := make([]byte, almost1K) - b.SetBytes(int64(len(buf))) - - var key [16]byte - var iv [16]byte - aes, _ := aes.NewCipher(key[:]) - ctr := cipher.NewCTR(aes, iv[:]) + benchmarkAESStream(b, cipher.NewCTR, make([]byte, almost1K)) +} - b.ResetTimer() - for i := 0; i < b.N; i++ { - ctr.XORKeyStream(buf, buf) - } +func BenchmarkAESCTR8K(b *testing.B) { + benchmarkAESStream(b, cipher.NewCTR, make([]byte, almost8K)) } func BenchmarkAESCBCEncrypt1K(b *testing.B) { diff --git a/libgo/go/crypto/cipher/example_test.go b/libgo/go/crypto/cipher/example_test.go index 6e050a9c0da..9c32d6a934f 100644 --- a/libgo/go/crypto/cipher/example_test.go +++ b/libgo/go/crypto/cipher/example_test.go @@ -5,6 +5,7 @@ package cipher_test import ( + "bytes" "crypto/aes" "crypto/cipher" "crypto/rand" @@ -298,11 +299,8 @@ func ExampleStreamReader() { // package like bcrypt or scrypt. key, _ := hex.DecodeString("6368616e676520746869732070617373") - inFile, err := os.Open("encrypted-file") - if err != nil { - panic(err) - } - defer inFile.Close() + encrypted, _ := hex.DecodeString("cf0495cc6f75dafc23948538e79904a9") + bReader := bytes.NewReader(encrypted) block, err := aes.NewCipher(key) if err != nil { @@ -314,15 +312,9 @@ func ExampleStreamReader() { var iv [aes.BlockSize]byte stream := cipher.NewOFB(block, iv[:]) - outFile, err := os.OpenFile("decrypted-file", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) - if err != nil { - panic(err) - } - defer outFile.Close() - - reader := &cipher.StreamReader{S: stream, R: inFile} - // Copy the input file to the output file, decrypting as we go. - if _, err := io.Copy(outFile, reader); err != nil { + reader := &cipher.StreamReader{S: stream, R: bReader} + // Copy the input to the output stream, decrypting as we go. + if _, err := io.Copy(os.Stdout, reader); err != nil { panic(err) } @@ -330,6 +322,8 @@ func ExampleStreamReader() { // authentication of the encrypted data. If you were actually to use // StreamReader in this manner, an attacker could flip arbitrary bits in // the output. + + // Output: some secret text } func ExampleStreamWriter() { @@ -339,11 +333,7 @@ func ExampleStreamWriter() { // package like bcrypt or scrypt. key, _ := hex.DecodeString("6368616e676520746869732070617373") - inFile, err := os.Open("plaintext-file") - if err != nil { - panic(err) - } - defer inFile.Close() + bReader := bytes.NewReader([]byte("some secret text")) block, err := aes.NewCipher(key) if err != nil { @@ -355,15 +345,11 @@ func ExampleStreamWriter() { var iv [aes.BlockSize]byte stream := cipher.NewOFB(block, iv[:]) - outFile, err := os.OpenFile("encrypted-file", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) - if err != nil { - panic(err) - } - defer outFile.Close() + var out bytes.Buffer - writer := &cipher.StreamWriter{S: stream, W: outFile} - // Copy the input file to the output file, encrypting as we go. - if _, err := io.Copy(writer, inFile); err != nil { + writer := &cipher.StreamWriter{S: stream, W: &out} + // Copy the input to the output buffer, encrypting as we go. + if _, err := io.Copy(writer, bReader); err != nil { panic(err) } @@ -371,4 +357,7 @@ func ExampleStreamWriter() { // authentication of the encrypted data. If you were actually to use // StreamReader in this manner, an attacker could flip arbitrary bits in // the decrypted result. + + fmt.Printf("%x\n", out.Bytes()) + // Output: cf0495cc6f75dafc23948538e79904a9 } diff --git a/libgo/go/crypto/cipher/export_test.go b/libgo/go/crypto/cipher/export_test.go new file mode 100644 index 00000000000..cf8007ab491 --- /dev/null +++ b/libgo/go/crypto/cipher/export_test.go @@ -0,0 +1,8 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package cipher + +// Export internal functions for testing. +var XorBytes = xorBytes diff --git a/libgo/go/crypto/cipher/gcm.go b/libgo/go/crypto/cipher/gcm.go index 6321e9e82d3..73d78550f89 100644 --- a/libgo/go/crypto/cipher/gcm.go +++ b/libgo/go/crypto/cipher/gcm.go @@ -7,6 +7,7 @@ package cipher import ( subtleoverlap "crypto/internal/subtle" "crypto/subtle" + "encoding/binary" "errors" ) @@ -53,8 +54,8 @@ type gcmAble interface { } // gcmFieldElement represents a value in GF(2¹²⁸). In order to reflect the GCM -// standard and make getUint64 suitable for marshaling these values, the bits -// are stored backwards. For example: +// standard and make binary.BigEndian suitable for marshaling these values, the +// bits are stored in big endian order. For example: // the coefficient of x⁰ can be obtained by v.low >> 63. // the coefficient of x⁶³ can be obtained by v.low & 1. // the coefficient of x⁶⁴ can be obtained by v.high >> 63. @@ -130,8 +131,8 @@ func newGCMWithNonceAndTagSize(cipher Block, nonceSize, tagSize int) (AEAD, erro // would expect, say, 4*key to be in index 4 of the table but due to // this bit ordering it will actually be in index 0010 (base 2) = 2. x := gcmFieldElement{ - getUint64(key[:8]), - getUint64(key[8:]), + binary.BigEndian.Uint64(key[:8]), + binary.BigEndian.Uint64(key[8:]), } g.productTable[reverseBits(1)] = x @@ -316,8 +317,8 @@ func (g *gcm) mul(y *gcmFieldElement) { // Horner's rule. There must be a multiple of gcmBlockSize bytes in blocks. func (g *gcm) updateBlocks(y *gcmFieldElement, blocks []byte) { for len(blocks) > 0 { - y.low ^= getUint64(blocks) - y.high ^= getUint64(blocks[8:]) + y.low ^= binary.BigEndian.Uint64(blocks) + y.high ^= binary.BigEndian.Uint64(blocks[8:]) g.mul(y) blocks = blocks[gcmBlockSize:] } @@ -339,12 +340,8 @@ func (g *gcm) update(y *gcmFieldElement, data []byte) { // gcmInc32 treats the final four bytes of counterBlock as a big-endian value // and increments it. func gcmInc32(counterBlock *[16]byte) { - for i := gcmBlockSize - 1; i >= gcmBlockSize-4; i-- { - counterBlock[i]++ - if counterBlock[i] != 0 { - break - } - } + ctr := counterBlock[len(counterBlock)-4:] + binary.BigEndian.PutUint32(ctr, binary.BigEndian.Uint32(ctr)+1) } // sliceForAppend takes a slice and a requested number of bytes. It returns a @@ -400,8 +397,8 @@ func (g *gcm) deriveCounter(counter *[gcmBlockSize]byte, nonce []byte) { g.update(&y, nonce) y.high ^= uint64(len(nonce)) * 8 g.mul(&y) - putUint64(counter[:8], y.low) - putUint64(counter[8:], y.high) + binary.BigEndian.PutUint64(counter[:8], y.low) + binary.BigEndian.PutUint64(counter[8:], y.high) } } @@ -417,33 +414,8 @@ func (g *gcm) auth(out, ciphertext, additionalData []byte, tagMask *[gcmTagSize] g.mul(&y) - putUint64(out, y.low) - putUint64(out[8:], y.high) + binary.BigEndian.PutUint64(out, y.low) + binary.BigEndian.PutUint64(out[8:], y.high) xorWords(out, out, tagMask[:]) } - -func getUint64(data []byte) uint64 { - _ = data[7] // bounds check hint to compiler; see golang.org/issue/14808 - r := uint64(data[0])<<56 | - uint64(data[1])<<48 | - uint64(data[2])<<40 | - uint64(data[3])<<32 | - uint64(data[4])<<24 | - uint64(data[5])<<16 | - uint64(data[6])<<8 | - uint64(data[7]) - return r -} - -func putUint64(out []byte, v uint64) { - _ = out[7] // bounds check hint to compiler; see golang.org/issue/14808 - out[0] = byte(v >> 56) - out[1] = byte(v >> 48) - out[2] = byte(v >> 40) - out[3] = byte(v >> 32) - out[4] = byte(v >> 24) - out[5] = byte(v >> 16) - out[6] = byte(v >> 8) - out[7] = byte(v) -} diff --git a/libgo/go/crypto/cipher/xor_amd64.go b/libgo/go/crypto/cipher/xor_amd64.go new file mode 100644 index 00000000000..2e1e26a1372 --- /dev/null +++ b/libgo/go/crypto/cipher/xor_amd64.go @@ -0,0 +1,29 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +package cipher + +// xorBytes xors the bytes in a and b. The destination should have enough +// space, otherwise xorBytes will panic. Returns the number of bytes xor'd. +func xorBytes(dst, a, b []byte) int { + n := len(a) + if len(b) < n { + n = len(b) + } + if n == 0 { + return 0 + } + _ = dst[n-1] + xorBytesSSE2(&dst[0], &a[0], &b[0], n) // amd64 must have SSE2 + return n +} + +func xorWords(dst, a, b []byte) { + xorBytes(dst, a, b) +} + +//go:noescape +func xorBytesSSE2(dst, a, b *byte, n int) diff --git a/libgo/go/crypto/cipher/xor.go b/libgo/go/crypto/cipher/xor_generic.go similarity index 74% rename from libgo/go/crypto/cipher/xor.go rename to libgo/go/crypto/cipher/xor_generic.go index 5b26eace09d..86abbb744ae 100644 --- a/libgo/go/crypto/cipher/xor.go +++ b/libgo/go/crypto/cipher/xor_generic.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// -build !amd64,!ppc64,!ppc64le + package cipher import ( @@ -9,12 +11,9 @@ import ( "unsafe" ) -const wordSize = int(unsafe.Sizeof(uintptr(0))) -const supportsUnaligned = runtime.GOARCH == "386" || runtime.GOARCH == "amd64" || runtime.GOARCH == "ppc64" || runtime.GOARCH == "ppc64le" || runtime.GOARCH == "s390x" - -// fastXORBytes xors in bulk. It only works on architectures that -// support unaligned read/writes. -func fastXORBytes(dst, a, b []byte) int { +// xorBytes xors the bytes in a and b. The destination should have enough +// space, otherwise xorBytes will panic. Returns the number of bytes xor'd. +func xorBytes(dst, a, b []byte) int { n := len(a) if len(b) < n { n = len(b) @@ -22,6 +21,28 @@ func fastXORBytes(dst, a, b []byte) int { if n == 0 { return 0 } + + switch { + case supportsUnaligned: + fastXORBytes(dst, a, b, n) + default: + // TODO(hanwen): if (dst, a, b) have common alignment + // we could still try fastXORBytes. It is not clear + // how often this happens, and it's only worth it if + // the block encryption itself is hardware + // accelerated. + safeXORBytes(dst, a, b, n) + } + return n +} + +const wordSize = int(unsafe.Sizeof(uintptr(0))) +const supportsUnaligned = runtime.GOARCH == "386" || runtime.GOARCH == "ppc64" || runtime.GOARCH == "ppc64le" || runtime.GOARCH == "s390x" + +// fastXORBytes xors in bulk. It only works on architectures that +// support unaligned read/writes. +// n needs to be smaller or equal than the length of a and b. +func fastXORBytes(dst, a, b []byte, n int) { // Assert dst has enough space _ = dst[n-1] @@ -38,34 +59,13 @@ func fastXORBytes(dst, a, b []byte) int { for i := (n - n%wordSize); i < n; i++ { dst[i] = a[i] ^ b[i] } - - return n } -func safeXORBytes(dst, a, b []byte) int { - n := len(a) - if len(b) < n { - n = len(b) - } +// n needs to be smaller or equal than the length of a and b. +func safeXORBytes(dst, a, b []byte, n int) { for i := 0; i < n; i++ { dst[i] = a[i] ^ b[i] } - return n -} - -// xorBytes xors the bytes in a and b. The destination should have enough -// space, otherwise xorBytes will panic. Returns the number of bytes xor'd. -func xorBytes(dst, a, b []byte) int { - if supportsUnaligned { - return fastXORBytes(dst, a, b) - } else { - // TODO(hanwen): if (dst, a, b) have common alignment - // we could still try fastXORBytes. It is not clear - // how often this happens, and it's only worth it if - // the block encryption itself is hardware - // accelerated. - return safeXORBytes(dst, a, b) - } } // fastXORWords XORs multiples of 4 or 8 bytes (depending on architecture.) @@ -80,10 +80,12 @@ func fastXORWords(dst, a, b []byte) { } } +// fastXORWords XORs multiples of 4 or 8 bytes (depending on architecture.) +// The slice arguments a and b are assumed to be of equal length. func xorWords(dst, a, b []byte) { if supportsUnaligned { fastXORWords(dst, a, b) } else { - safeXORBytes(dst, a, b) + safeXORBytes(dst, a, b, len(b)) } } diff --git a/libgo/go/crypto/cipher/xor_ppc64x.go b/libgo/go/crypto/cipher/xor_ppc64x.go new file mode 100644 index 00000000000..e7d67f423d5 --- /dev/null +++ b/libgo/go/crypto/cipher/xor_ppc64x.go @@ -0,0 +1,30 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore +// +build ppc64 ppc64le + +package cipher + +// xorBytes xors the bytes in a and b. The destination should have enough +// space, otherwise xorBytes will panic. Returns the number of bytes xor'd. +func xorBytes(dst, a, b []byte) int { + n := len(a) + if len(b) < n { + n = len(b) + } + if n == 0 { + return 0 + } + _ = dst[n-1] + xorBytesVSX(&dst[0], &a[0], &b[0], n) + return n +} + +func xorWords(dst, a, b []byte) { + xorBytes(dst, a, b) +} + +//go:noescape +func xorBytesVSX(dst, a, b *byte, n int) diff --git a/libgo/go/crypto/cipher/xor_test.go b/libgo/go/crypto/cipher/xor_test.go index d9187eb7263..24877efc367 100644 --- a/libgo/go/crypto/cipher/xor_test.go +++ b/libgo/go/crypto/cipher/xor_test.go @@ -2,27 +2,71 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package cipher +package cipher_test import ( "bytes" + "crypto/cipher" + "crypto/rand" + "fmt" + "io" "testing" ) func TestXOR(t *testing.T) { - for alignP := 0; alignP < 2; alignP++ { - for alignQ := 0; alignQ < 2; alignQ++ { - for alignD := 0; alignD < 2; alignD++ { - p := make([]byte, 1024)[alignP:] - q := make([]byte, 1024)[alignQ:] - d1 := make([]byte, 1024+alignD)[alignD:] - d2 := make([]byte, 1024+alignD)[alignD:] - xorBytes(d1, p, q) - safeXORBytes(d2, p, q) - if !bytes.Equal(d1, d2) { - t.Error("not equal") + for j := 1; j <= 1024; j++ { + for alignP := 0; alignP < 2; alignP++ { + for alignQ := 0; alignQ < 2; alignQ++ { + for alignD := 0; alignD < 2; alignD++ { + p := make([]byte, j)[alignP:] + q := make([]byte, j)[alignQ:] + d1 := make([]byte, j+alignD)[alignD:] + d2 := make([]byte, j+alignD)[alignD:] + if _, err := io.ReadFull(rand.Reader, p); err != nil { + t.Fatal(err) + } + if _, err := io.ReadFull(rand.Reader, q); err != nil { + t.Fatal(err) + } + cipher.XorBytes(d1, p, q) + n := min(p, q) + for i := 0; i < n; i++ { + d2[i] = p[i] ^ q[i] + } + if !bytes.Equal(d1, d2) { + t.Logf("p: %#v", p) + t.Logf("q: %#v", q) + t.Logf("expect: %#v", d2) + t.Logf("result: %#v", d1) + t.Fatal("not equal") + } } } } } } + +func min(a, b []byte) int { + n := len(a) + if len(b) < n { + n = len(b) + } + return n +} + +func BenchmarkXORBytes(b *testing.B) { + dst := make([]byte, 1<<15) + data0 := make([]byte, 1<<15) + data1 := make([]byte, 1<<15) + sizes := []int64{1 << 3, 1 << 7, 1 << 11, 1 << 15} + for _, size := range sizes { + b.Run(fmt.Sprintf("%dBytes", size), func(b *testing.B) { + s0 := data0[:size] + s1 := data1[:size] + b.SetBytes(int64(size)) + for i := 0; i < b.N; i++ { + cipher.XorBytes(dst, s0, s1) + } + }) + } +} diff --git a/libgo/go/crypto/ecdsa/ecdsa.go b/libgo/go/crypto/ecdsa/ecdsa.go index 2bab14cbb9e..e059f181c7e 100644 --- a/libgo/go/crypto/ecdsa/ecdsa.go +++ b/libgo/go/crypto/ecdsa/ecdsa.go @@ -12,7 +12,7 @@ package ecdsa // References: // [NSA]: Suite B implementer's guide to FIPS 186-3, -// http://www.nsa.gov/ia/_files/ecdsa.pdf +// https://apps.nsa.gov/iaarchive/library/ia-guidance/ia-solutions-for-classified/algorithm-guidance/suite-b-implementers-guide-to-fips-186-3-ecdsa.cfm // [SECG]: SECG, SEC1 // http://www.secg.org/sec1-v2.pdf diff --git a/libgo/go/crypto/elliptic/p256_s390x.go b/libgo/go/crypto/elliptic/p256_s390x.go index 43e19e93274..40c0929cd0e 100644 --- a/libgo/go/crypto/elliptic/p256_s390x.go +++ b/libgo/go/crypto/elliptic/p256_s390x.go @@ -9,7 +9,14 @@ package elliptic import ( "crypto/subtle" + "internal/cpu" "math/big" + "unsafe" +) + +const ( + offsetS390xHasVX = unsafe.Offsetof(cpu.S390X.HasVX) + offsetS390xHasVE1 = unsafe.Offsetof(cpu.S390X.HasVE1) ) type p256CurveFast struct { @@ -27,14 +34,26 @@ var ( p256PreFast *[37][64]p256Point ) -// hasVectorFacility reports whether the machine has the z/Architecture -// vector facility installed and enabled. -func hasVectorFacility() bool +//go:noescape +func p256MulInternalTrampolineSetup() + +//go:noescape +func p256SqrInternalTrampolineSetup() + +//go:noescape +func p256MulInternalVX() + +//go:noescape +func p256MulInternalVMSL() -var hasVX = hasVectorFacility() +//go:noescape +func p256SqrInternalVX() + +//go:noescape +func p256SqrInternalVMSL() func initP256Arch() { - if hasVX { + if cpu.S390X.HasVX { p256 = p256CurveFast{p256Params} initTable() return @@ -52,12 +71,15 @@ func (curve p256CurveFast) Params() *CurveParams { // Functions implemented in p256_asm_s390x.s // Montgomery multiplication modulo P256 // +//go:noescape +func p256SqrAsm(res, in1 []byte) + //go:noescape func p256MulAsm(res, in1, in2 []byte) // Montgomery square modulo P256 func p256Sqr(res, in []byte) { - p256MulAsm(res, in, in) + p256SqrAsm(res, in) } // Montgomery multiplication by 1 diff --git a/libgo/go/crypto/hmac/hmac.go b/libgo/go/crypto/hmac/hmac.go index c8c0617c47f..801ece67ae4 100644 --- a/libgo/go/crypto/hmac/hmac.go +++ b/libgo/go/crypto/hmac/hmac.go @@ -11,8 +11,8 @@ The receiver verifies the hash by recomputing it using the same key. Receivers should be careful to use Equal to compare MACs in order to avoid timing side-channels: - // CheckMAC reports whether messageMAC is a valid HMAC tag for message. - func CheckMAC(message, messageMAC, key []byte) bool { + // ValidMAC reports whether messageMAC is a valid HMAC tag for message. + func ValidMAC(message, messageMAC, key []byte) bool { mac := hmac.New(sha256.New, key) mac.Write(message) expectedMAC := mac.Sum(nil) diff --git a/libgo/go/crypto/md5/gen.go b/libgo/go/crypto/md5/gen.go index a815dc29f6a..a11f22059fa 100644 --- a/libgo/go/crypto/md5/gen.go +++ b/libgo/go/crypto/md5/gen.go @@ -7,10 +7,7 @@ // This program generates md5block.go // Invoke as // -// go run gen.go [-full] -output md5block.go -// -// The -full flag causes the generated code to do a full -// (16x) unrolling instead of a 4x unrolling. +// go run gen.go -output md5block.go package main @@ -56,13 +53,14 @@ type Data struct { Table2 []uint32 Table3 []uint32 Table4 []uint32 - Full bool } var funcs = template.FuncMap{ "dup": dup, "relabel": relabel, "rotate": rotate, + "idx": idx, + "seq": seq, } func dup(count int, x []int) []int { @@ -74,7 +72,7 @@ func dup(count int, x []int) []int { } func relabel(s string) string { - return strings.NewReplacer("a", data.a, "b", data.b, "c", data.c, "d", data.d).Replace(s) + return strings.NewReplacer("arg0", data.a, "arg1", data.b, "arg2", data.c, "arg3", data.d).Replace(s) } func rotate() string { @@ -82,8 +80,27 @@ func rotate() string { return "" // no output } -func init() { - flag.BoolVar(&data.Full, "full", false, "complete unrolling") +func idx(round, index int) int { + v := 0 + switch round { + case 1: + v = index + case 2: + v = (1 + 5*index) & 15 + case 3: + v = (5 + 3*index) & 15 + case 4: + v = (7 * index) & 15 + } + return v +} + +func seq(i int) []int { + s := make([]int, i) + for i := range s { + s[i] = i + } + return s } var data = Data{ @@ -179,152 +196,64 @@ var program = `// Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Code generated by go run gen.go{{if .Full}} -full{{end}} -output md5block.go; DO NOT EDIT. +// Code generated by go run gen.go -output md5block.go; DO NOT EDIT. package md5 import ( - "unsafe" - "runtime" + "encoding/binary" + "math/bits" ) -{{if not .Full}} - var t1 = [...]uint32{ - {{range .Table1}}{{printf "\t%#x,\n" .}}{{end}} - } - - var t2 = [...]uint32{ - {{range .Table2}}{{printf "\t%#x,\n" .}}{{end}} - } - - var t3 = [...]uint32{ - {{range .Table3}}{{printf "\t%#x,\n" .}}{{end}} - } - - var t4 = [...]uint32{ - {{range .Table4}}{{printf "\t%#x,\n" .}}{{end}} - } -{{end}} - -const x86 = runtime.GOARCH == "amd64" || runtime.GOARCH == "386" - -var littleEndian bool +func blockGeneric(dig *digest, p []byte) { + // load state + a, b, c, d := dig.s[0], dig.s[1], dig.s[2], dig.s[3] -func init() { - x := uint32(0x04030201) - y := [4]byte{0x1, 0x2, 0x3, 0x4} - littleEndian = *(*[4]byte)(unsafe.Pointer(&x)) == y -} + for i := 0; i <= len(p)-BlockSize; i += BlockSize { + // eliminate bounds checks on p + q := p[i:] + q = q[:BlockSize:BlockSize] -func blockGeneric(dig *digest, p []byte) { - a := dig.s[0] - b := dig.s[1] - c := dig.s[2] - d := dig.s[3] - var X *[16]uint32 - var xbuf [16]uint32 - for len(p) >= chunk { + // save current state aa, bb, cc, dd := a, b, c, d - // This is a constant condition - it is not evaluated on each iteration. - if x86 { - // MD5 was designed so that x86 processors can just iterate - // over the block data directly as uint32s, and we generate - // less code and run 1.3x faster if we take advantage of that. - // My apologies. - X = (*[16]uint32)(unsafe.Pointer(&p[0])) - } else if littleEndian && uintptr(unsafe.Pointer(&p[0]))&(unsafe.Alignof(uint32(0))-1) == 0 { - X = (*[16]uint32)(unsafe.Pointer(&p[0])) - } else { - X = &xbuf - j := 0 - for i := 0; i < 16; i++ { - X[i&15] = uint32(p[j]) | uint32(p[j+1])<<8 | uint32(p[j+2])<<16 | uint32(p[j+3])<<24 - j += 4 - } - } + // load input block + {{range $i := seq 16 -}} + {{printf "x%x := binary.LittleEndian.Uint32(q[4*%#x:])" $i $i}} + {{end}} - {{if .Full}} - // Round 1. - {{range $i, $s := dup 4 .Shift1}} - {{index $.Table1 $i | printf "a += (((c^d)&b)^d) + X[%d] + %d" $i | relabel}} - {{printf "a = a<<%d | a>>(32-%d) + b" $s $s | relabel}} - {{rotate}} - {{end}} - - // Round 2. - {{range $i, $s := dup 4 .Shift2}} - {{index $.Table2 $i | printf "a += (((b^c)&d)^c) + X[(1+5*%d)&15] + %d" $i | relabel}} - {{printf "a = a<<%d | a>>(32-%d) + b" $s $s | relabel}} - {{rotate}} - {{end}} - - // Round 3. - {{range $i, $s := dup 4 .Shift3}} - {{index $.Table3 $i | printf "a += (b^c^d) + X[(5+3*%d)&15] + %d" $i | relabel}} - {{printf "a = a<<%d | a>>(32-%d) + b" $s $s | relabel}} - {{rotate}} - {{end}} - - // Round 4. - {{range $i, $s := dup 4 .Shift4}} - {{index $.Table4 $i | printf "a += (c^(b|^d)) + X[(7*%d)&15] + %d" $i | relabel}} - {{printf "a = a<<%d | a>>(32-%d) + b" $s $s | relabel}} - {{rotate}} - {{end}} - {{else}} - // Round 1. - for i := uint(0); i < 16; { - {{range $s := .Shift1}} - {{printf "a += (((c^d)&b)^d) + X[i&15] + t1[i&15]" | relabel}} - {{printf "a = a<<%d | a>>(32-%d) + b" $s $s | relabel}} - i++ - {{rotate}} - {{end}} - } + // round 1 + {{range $i, $s := dup 4 .Shift1 -}} + {{printf "arg0 = arg1 + bits.RotateLeft32((((arg2^arg3)&arg1)^arg3)+arg0+x%x+%#08x, %d)" (idx 1 $i) (index $.Table1 $i) $s | relabel}} + {{rotate -}} + {{end}} - // Round 2. - for i := uint(0); i < 16; { - {{range $s := .Shift2}} - {{printf "a += (((b^c)&d)^c) + X[(1+5*i)&15] + t2[i&15]" | relabel}} - {{printf "a = a<<%d | a>>(32-%d) + b" $s $s | relabel}} - i++ - {{rotate}} - {{end}} - } + // round 2 + {{range $i, $s := dup 4 .Shift2 -}} + {{printf "arg0 = arg1 + bits.RotateLeft32((((arg1^arg2)&arg3)^arg2)+arg0+x%x+%#08x, %d)" (idx 2 $i) (index $.Table2 $i) $s | relabel}} + {{rotate -}} + {{end}} - // Round 3. - for i := uint(0); i < 16; { - {{range $s := .Shift3}} - {{printf "a += (b^c^d) + X[(5+3*i)&15] + t3[i&15]" | relabel}} - {{printf "a = a<<%d | a>>(32-%d) + b" $s $s | relabel}} - i++ - {{rotate}} - {{end}} - } + // round 3 + {{range $i, $s := dup 4 .Shift3 -}} + {{printf "arg0 = arg1 + bits.RotateLeft32((arg1^arg2^arg3)+arg0+x%x+%#08x, %d)" (idx 3 $i) (index $.Table3 $i) $s | relabel}} + {{rotate -}} + {{end}} - // Round 4. - for i := uint(0); i < 16; { - {{range $s := .Shift4}} - {{printf "a += (c^(b|^d)) + X[(7*i)&15] + t4[i&15]" | relabel}} - {{printf "a = a<<%d | a>>(32-%d) + b" $s $s | relabel}} - i++ - {{rotate}} - {{end}} - } + // round 4 + {{range $i, $s := dup 4 .Shift4 -}} + {{printf "arg0 = arg1 + bits.RotateLeft32((arg2^(arg1|^arg3))+arg0+x%x+%#08x, %d)" (idx 4 $i) (index $.Table4 $i) $s | relabel}} + {{rotate -}} {{end}} + // add saved state a += aa b += bb c += cc d += dd - - p = p[chunk:] } - dig.s[0] = a - dig.s[1] = b - dig.s[2] = c - dig.s[3] = d + // save state + dig.s[0], dig.s[1], dig.s[2], dig.s[3] = a, b, c, d } ` diff --git a/libgo/go/crypto/md5/md5.go b/libgo/go/crypto/md5/md5.go index 88d914d22ce..01157840475 100644 --- a/libgo/go/crypto/md5/md5.go +++ b/libgo/go/crypto/md5/md5.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:generate go run gen.go -full -output md5block.go +//go:generate go run gen.go -output md5block.go // Package md5 implements the MD5 hash algorithm as defined in RFC 1321. // @@ -12,6 +12,7 @@ package md5 import ( "crypto" + "encoding/binary" "errors" "hash" ) @@ -27,7 +28,6 @@ const Size = 16 const BlockSize = 64 const ( - chunk = 64 init0 = 0x67452301 init1 = 0xEFCDAB89 init2 = 0x98BADCFE @@ -37,7 +37,7 @@ const ( // digest represents the partial evaluation of a checksum. type digest struct { s [4]uint32 - x [chunk]byte + x [BlockSize]byte nx int len uint64 } @@ -53,7 +53,7 @@ func (d *digest) Reset() { const ( magic = "md5\x01" - marshaledSize = len(magic) + 4*4 + chunk + 8 + marshaledSize = len(magic) + 4*4 + BlockSize + 8 ) func (d *digest) MarshalBinary() ([]byte, error) { @@ -83,45 +83,28 @@ func (d *digest) UnmarshalBinary(b []byte) error { b, d.s[3] = consumeUint32(b) b = b[copy(d.x[:], b):] b, d.len = consumeUint64(b) - d.nx = int(d.len) % chunk + d.nx = int(d.len % BlockSize) return nil } func appendUint64(b []byte, x uint64) []byte { - a := [8]byte{ - byte(x >> 56), - byte(x >> 48), - byte(x >> 40), - byte(x >> 32), - byte(x >> 24), - byte(x >> 16), - byte(x >> 8), - byte(x), - } + var a [8]byte + binary.BigEndian.PutUint64(a[:], x) return append(b, a[:]...) } func appendUint32(b []byte, x uint32) []byte { - a := [4]byte{ - byte(x >> 24), - byte(x >> 16), - byte(x >> 8), - byte(x), - } + var a [4]byte + binary.BigEndian.PutUint32(a[:], x) return append(b, a[:]...) } func consumeUint64(b []byte) ([]byte, uint64) { - _ = b[7] - x := uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 | - uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56 - return b[8:], x + return b[8:], binary.BigEndian.Uint64(b[0:8]) } func consumeUint32(b []byte) ([]byte, uint32) { - _ = b[3] - x := uint32(b[3]) | uint32(b[2])<<8 | uint32(b[1])<<16 | uint32(b[0])<<24 - return b[4:], x + return b[4:], binary.BigEndian.Uint32(b[0:4]) } // New returns a new hash.Hash computing the MD5 checksum. The Hash also @@ -138,20 +121,31 @@ func (d *digest) Size() int { return Size } func (d *digest) BlockSize() int { return BlockSize } func (d *digest) Write(p []byte) (nn int, err error) { + // Note that we currently call block or blockGeneric + // directly (guarded using haveAsm) because this allows + // escape analysis to see that p and d don't escape. nn = len(p) d.len += uint64(nn) if d.nx > 0 { n := copy(d.x[d.nx:], p) d.nx += n - if d.nx == chunk { - block(d, d.x[:]) + if d.nx == BlockSize { + if haveAsm { + block(d, d.x[:]) + } else { + blockGeneric(d, d.x[:]) + } d.nx = 0 } p = p[n:] } - if len(p) >= chunk { - n := len(p) &^ (chunk - 1) - block(d, p[:n]) + if len(p) >= BlockSize { + n := len(p) &^ (BlockSize - 1) + if haveAsm { + block(d, p[:n]) + } else { + blockGeneric(d, p[:n]) + } p = p[n:] } if len(p) > 0 { @@ -168,35 +162,27 @@ func (d *digest) Sum(in []byte) []byte { } func (d *digest) checkSum() [Size]byte { - // Padding. Add a 1 bit and 0 bits until 56 bytes mod 64. - len := d.len - var tmp [64]byte - tmp[0] = 0x80 - if len%64 < 56 { - d.Write(tmp[0 : 56-len%64]) - } else { - d.Write(tmp[0 : 64+56-len%64]) - } - - // Length in bits. - len <<= 3 - for i := uint(0); i < 8; i++ { - tmp[i] = byte(len >> (8 * i)) - } - d.Write(tmp[0:8]) - + // Append 0x80 to the end of the message and then append zeros + // until the length is a multiple of 56 bytes. Finally append + // 8 bytes representing the message length in bits. + // + // 1 byte end marker :: 0-63 padding bytes :: 8 byte length + tmp := [1 + 63 + 8]byte{0x80} + pad := (55 - d.len) % 64 // calculate number of padding bytes + binary.LittleEndian.PutUint64(tmp[1+pad:], d.len<<3) // append length in bits + d.Write(tmp[:1+pad+8]) + + // The previous write ensures that a whole number of + // blocks (i.e. a multiple of 64 bytes) have been hashed. if d.nx != 0 { panic("d.nx != 0") } var digest [Size]byte - for i, s := range d.s { - digest[i*4] = byte(s) - digest[i*4+1] = byte(s >> 8) - digest[i*4+2] = byte(s >> 16) - digest[i*4+3] = byte(s >> 24) - } - + binary.LittleEndian.PutUint32(digest[0:], d.s[0]) + binary.LittleEndian.PutUint32(digest[4:], d.s[1]) + binary.LittleEndian.PutUint32(digest[8:], d.s[2]) + binary.LittleEndian.PutUint32(digest[12:], d.s[3]) return digest } diff --git a/libgo/go/crypto/md5/md5_test.go b/libgo/go/crypto/md5/md5_test.go index 64a62e47305..34c7f541c57 100644 --- a/libgo/go/crypto/md5/md5_test.go +++ b/libgo/go/crypto/md5/md5_test.go @@ -9,6 +9,7 @@ import ( "crypto/rand" "encoding" "fmt" + "hash" "io" "testing" "unsafe" @@ -153,6 +154,63 @@ func TestBlockGeneric(t *testing.T) { } } +// Tests for unmarshaling hashes that have hashed a large amount of data +// The initial hash generation is omitted from the test, because it takes a long time. +// The test contains some already-generated states, and their expected sums +// Tests a problem that is outlined in Github issue #29541 +// The problem is triggered when an amount of data has been hashed for which +// the data length has a 1 in the 32nd bit. When casted to int, this changes +// the sign of the value, and causes the modulus operation to return a +// different result. +type unmarshalTest struct { + state string + sum string +} + +var largeUnmarshalTests = []unmarshalTest{ + // Data length: 7_102_415_735 + unmarshalTest{ + state: "md5\x01\xa5\xf7\xf0=\xd6S\x85\xd9M\n}\xc3\u0601\x89\xe7@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuv\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xa7VCw", + sum: "cddefcf74ffec709a0b45a6a987564d5", + }, + // Data length: 6_565_544_823 + unmarshalTest{ + state: "md5\x01{\xda\x1a\xc7\xc9'?\x83EX\xe0\x88q\xfeG\x18@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuv\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x87VCw", + sum: "fd9f41874ab240698e7bc9c3ae70c8e4", + }, +} + +func safeSum(h hash.Hash) (sum []byte, err error) { + defer func() { + if r := recover(); r != nil { + err = fmt.Errorf("sum panic: %v", r) + } + }() + + return h.Sum(nil), nil +} + +func TestLargeHashes(t *testing.T) { + for i, test := range largeUnmarshalTests { + + h := New() + if err := h.(encoding.BinaryUnmarshaler).UnmarshalBinary([]byte(test.state)); err != nil { + t.Errorf("test %d could not unmarshal: %v", i, err) + continue + } + + sum, err := safeSum(h) + if err != nil { + t.Errorf("test %d could not sum: %v", i, err) + continue + } + + if fmt.Sprintf("%x", sum) != test.sum { + t.Errorf("test %d sum mismatch: expect %s got %x", i, test.sum, sum) + } + } +} + var bench = New() var buf = make([]byte, 8192+1) var sum = make([]byte, bench.Size()) diff --git a/libgo/go/crypto/md5/md5block.go b/libgo/go/crypto/md5/md5block.go index 8ac32ffeb78..4ff289e860f 100644 --- a/libgo/go/crypto/md5/md5block.go +++ b/libgo/go/crypto/md5/md5block.go @@ -2,263 +2,124 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Code generated by go run gen.go -full -output md5block.go; DO NOT EDIT. +// Code generated by go run gen.go -output md5block.go; DO NOT EDIT. package md5 import ( - "runtime" - "unsafe" + "encoding/binary" + "math/bits" ) -const x86 = runtime.GOARCH == "amd64" || runtime.GOARCH == "386" - -var littleEndian bool - -func init() { - x := uint32(0x04030201) - y := [4]byte{0x1, 0x2, 0x3, 0x4} - littleEndian = *(*[4]byte)(unsafe.Pointer(&x)) == y -} - func blockGeneric(dig *digest, p []byte) { - a := dig.s[0] - b := dig.s[1] - c := dig.s[2] - d := dig.s[3] - var X *[16]uint32 - var xbuf [16]uint32 - for len(p) >= chunk { - aa, bb, cc, dd := a, b, c, d - - // This is a constant condition - it is not evaluated on each iteration. - if x86 { - // MD5 was designed so that x86 processors can just iterate - // over the block data directly as uint32s, and we generate - // less code and run 1.3x faster if we take advantage of that. - // My apologies. - X = (*[16]uint32)(unsafe.Pointer(&p[0])) - } else if littleEndian && uintptr(unsafe.Pointer(&p[0]))&(unsafe.Alignof(uint32(0))-1) == 0 { - X = (*[16]uint32)(unsafe.Pointer(&p[0])) - } else { - X = &xbuf - j := 0 - for i := 0; i < 16; i++ { - X[i&15] = uint32(p[j]) | uint32(p[j+1])<<8 | uint32(p[j+2])<<16 | uint32(p[j+3])<<24 - j += 4 - } - } - - // Round 1. - - a += (((c ^ d) & b) ^ d) + X[0] + 3614090360 - a = a<<7 | a>>(32-7) + b - - d += (((b ^ c) & a) ^ c) + X[1] + 3905402710 - d = d<<12 | d>>(32-12) + a - - c += (((a ^ b) & d) ^ b) + X[2] + 606105819 - c = c<<17 | c>>(32-17) + d - - b += (((d ^ a) & c) ^ a) + X[3] + 3250441966 - b = b<<22 | b>>(32-22) + c - - a += (((c ^ d) & b) ^ d) + X[4] + 4118548399 - a = a<<7 | a>>(32-7) + b - - d += (((b ^ c) & a) ^ c) + X[5] + 1200080426 - d = d<<12 | d>>(32-12) + a - - c += (((a ^ b) & d) ^ b) + X[6] + 2821735955 - c = c<<17 | c>>(32-17) + d - - b += (((d ^ a) & c) ^ a) + X[7] + 4249261313 - b = b<<22 | b>>(32-22) + c - - a += (((c ^ d) & b) ^ d) + X[8] + 1770035416 - a = a<<7 | a>>(32-7) + b - - d += (((b ^ c) & a) ^ c) + X[9] + 2336552879 - d = d<<12 | d>>(32-12) + a - - c += (((a ^ b) & d) ^ b) + X[10] + 4294925233 - c = c<<17 | c>>(32-17) + d - - b += (((d ^ a) & c) ^ a) + X[11] + 2304563134 - b = b<<22 | b>>(32-22) + c - - a += (((c ^ d) & b) ^ d) + X[12] + 1804603682 - a = a<<7 | a>>(32-7) + b - - d += (((b ^ c) & a) ^ c) + X[13] + 4254626195 - d = d<<12 | d>>(32-12) + a - - c += (((a ^ b) & d) ^ b) + X[14] + 2792965006 - c = c<<17 | c>>(32-17) + d - - b += (((d ^ a) & c) ^ a) + X[15] + 1236535329 - b = b<<22 | b>>(32-22) + c - - // Round 2. - - a += (((b ^ c) & d) ^ c) + X[(1+5*0)&15] + 4129170786 - a = a<<5 | a>>(32-5) + b - - d += (((a ^ b) & c) ^ b) + X[(1+5*1)&15] + 3225465664 - d = d<<9 | d>>(32-9) + a - - c += (((d ^ a) & b) ^ a) + X[(1+5*2)&15] + 643717713 - c = c<<14 | c>>(32-14) + d - - b += (((c ^ d) & a) ^ d) + X[(1+5*3)&15] + 3921069994 - b = b<<20 | b>>(32-20) + c - - a += (((b ^ c) & d) ^ c) + X[(1+5*4)&15] + 3593408605 - a = a<<5 | a>>(32-5) + b - - d += (((a ^ b) & c) ^ b) + X[(1+5*5)&15] + 38016083 - d = d<<9 | d>>(32-9) + a - - c += (((d ^ a) & b) ^ a) + X[(1+5*6)&15] + 3634488961 - c = c<<14 | c>>(32-14) + d - - b += (((c ^ d) & a) ^ d) + X[(1+5*7)&15] + 3889429448 - b = b<<20 | b>>(32-20) + c - - a += (((b ^ c) & d) ^ c) + X[(1+5*8)&15] + 568446438 - a = a<<5 | a>>(32-5) + b - - d += (((a ^ b) & c) ^ b) + X[(1+5*9)&15] + 3275163606 - d = d<<9 | d>>(32-9) + a - - c += (((d ^ a) & b) ^ a) + X[(1+5*10)&15] + 4107603335 - c = c<<14 | c>>(32-14) + d - - b += (((c ^ d) & a) ^ d) + X[(1+5*11)&15] + 1163531501 - b = b<<20 | b>>(32-20) + c - - a += (((b ^ c) & d) ^ c) + X[(1+5*12)&15] + 2850285829 - a = a<<5 | a>>(32-5) + b + // load state + a, b, c, d := dig.s[0], dig.s[1], dig.s[2], dig.s[3] - d += (((a ^ b) & c) ^ b) + X[(1+5*13)&15] + 4243563512 - d = d<<9 | d>>(32-9) + a + for i := 0; i <= len(p)-BlockSize; i += BlockSize { + // eliminate bounds checks on p + q := p[i:] + q = q[:BlockSize:BlockSize] - c += (((d ^ a) & b) ^ a) + X[(1+5*14)&15] + 1735328473 - c = c<<14 | c>>(32-14) + d - - b += (((c ^ d) & a) ^ d) + X[(1+5*15)&15] + 2368359562 - b = b<<20 | b>>(32-20) + c - - // Round 3. - - a += (b ^ c ^ d) + X[(5+3*0)&15] + 4294588738 - a = a<<4 | a>>(32-4) + b - - d += (a ^ b ^ c) + X[(5+3*1)&15] + 2272392833 - d = d<<11 | d>>(32-11) + a - - c += (d ^ a ^ b) + X[(5+3*2)&15] + 1839030562 - c = c<<16 | c>>(32-16) + d - - b += (c ^ d ^ a) + X[(5+3*3)&15] + 4259657740 - b = b<<23 | b>>(32-23) + c - - a += (b ^ c ^ d) + X[(5+3*4)&15] + 2763975236 - a = a<<4 | a>>(32-4) + b - - d += (a ^ b ^ c) + X[(5+3*5)&15] + 1272893353 - d = d<<11 | d>>(32-11) + a - - c += (d ^ a ^ b) + X[(5+3*6)&15] + 4139469664 - c = c<<16 | c>>(32-16) + d - - b += (c ^ d ^ a) + X[(5+3*7)&15] + 3200236656 - b = b<<23 | b>>(32-23) + c - - a += (b ^ c ^ d) + X[(5+3*8)&15] + 681279174 - a = a<<4 | a>>(32-4) + b - - d += (a ^ b ^ c) + X[(5+3*9)&15] + 3936430074 - d = d<<11 | d>>(32-11) + a - - c += (d ^ a ^ b) + X[(5+3*10)&15] + 3572445317 - c = c<<16 | c>>(32-16) + d - - b += (c ^ d ^ a) + X[(5+3*11)&15] + 76029189 - b = b<<23 | b>>(32-23) + c - - a += (b ^ c ^ d) + X[(5+3*12)&15] + 3654602809 - a = a<<4 | a>>(32-4) + b - - d += (a ^ b ^ c) + X[(5+3*13)&15] + 3873151461 - d = d<<11 | d>>(32-11) + a - - c += (d ^ a ^ b) + X[(5+3*14)&15] + 530742520 - c = c<<16 | c>>(32-16) + d - - b += (c ^ d ^ a) + X[(5+3*15)&15] + 3299628645 - b = b<<23 | b>>(32-23) + c - - // Round 4. - - a += (c ^ (b | ^d)) + X[(7*0)&15] + 4096336452 - a = a<<6 | a>>(32-6) + b - - d += (b ^ (a | ^c)) + X[(7*1)&15] + 1126891415 - d = d<<10 | d>>(32-10) + a - - c += (a ^ (d | ^b)) + X[(7*2)&15] + 2878612391 - c = c<<15 | c>>(32-15) + d - - b += (d ^ (c | ^a)) + X[(7*3)&15] + 4237533241 - b = b<<21 | b>>(32-21) + c - - a += (c ^ (b | ^d)) + X[(7*4)&15] + 1700485571 - a = a<<6 | a>>(32-6) + b - - d += (b ^ (a | ^c)) + X[(7*5)&15] + 2399980690 - d = d<<10 | d>>(32-10) + a - - c += (a ^ (d | ^b)) + X[(7*6)&15] + 4293915773 - c = c<<15 | c>>(32-15) + d - - b += (d ^ (c | ^a)) + X[(7*7)&15] + 2240044497 - b = b<<21 | b>>(32-21) + c - - a += (c ^ (b | ^d)) + X[(7*8)&15] + 1873313359 - a = a<<6 | a>>(32-6) + b - - d += (b ^ (a | ^c)) + X[(7*9)&15] + 4264355552 - d = d<<10 | d>>(32-10) + a - - c += (a ^ (d | ^b)) + X[(7*10)&15] + 2734768916 - c = c<<15 | c>>(32-15) + d - - b += (d ^ (c | ^a)) + X[(7*11)&15] + 1309151649 - b = b<<21 | b>>(32-21) + c - - a += (c ^ (b | ^d)) + X[(7*12)&15] + 4149444226 - a = a<<6 | a>>(32-6) + b - - d += (b ^ (a | ^c)) + X[(7*13)&15] + 3174756917 - d = d<<10 | d>>(32-10) + a - - c += (a ^ (d | ^b)) + X[(7*14)&15] + 718787259 - c = c<<15 | c>>(32-15) + d - - b += (d ^ (c | ^a)) + X[(7*15)&15] + 3951481745 - b = b<<21 | b>>(32-21) + c + // save current state + aa, bb, cc, dd := a, b, c, d + // load input block + x0 := binary.LittleEndian.Uint32(q[4*0x0:]) + x1 := binary.LittleEndian.Uint32(q[4*0x1:]) + x2 := binary.LittleEndian.Uint32(q[4*0x2:]) + x3 := binary.LittleEndian.Uint32(q[4*0x3:]) + x4 := binary.LittleEndian.Uint32(q[4*0x4:]) + x5 := binary.LittleEndian.Uint32(q[4*0x5:]) + x6 := binary.LittleEndian.Uint32(q[4*0x6:]) + x7 := binary.LittleEndian.Uint32(q[4*0x7:]) + x8 := binary.LittleEndian.Uint32(q[4*0x8:]) + x9 := binary.LittleEndian.Uint32(q[4*0x9:]) + xa := binary.LittleEndian.Uint32(q[4*0xa:]) + xb := binary.LittleEndian.Uint32(q[4*0xb:]) + xc := binary.LittleEndian.Uint32(q[4*0xc:]) + xd := binary.LittleEndian.Uint32(q[4*0xd:]) + xe := binary.LittleEndian.Uint32(q[4*0xe:]) + xf := binary.LittleEndian.Uint32(q[4*0xf:]) + + // round 1 + a = b + bits.RotateLeft32((((c^d)&b)^d)+a+x0+0xd76aa478, 7) + d = a + bits.RotateLeft32((((b^c)&a)^c)+d+x1+0xe8c7b756, 12) + c = d + bits.RotateLeft32((((a^b)&d)^b)+c+x2+0x242070db, 17) + b = c + bits.RotateLeft32((((d^a)&c)^a)+b+x3+0xc1bdceee, 22) + a = b + bits.RotateLeft32((((c^d)&b)^d)+a+x4+0xf57c0faf, 7) + d = a + bits.RotateLeft32((((b^c)&a)^c)+d+x5+0x4787c62a, 12) + c = d + bits.RotateLeft32((((a^b)&d)^b)+c+x6+0xa8304613, 17) + b = c + bits.RotateLeft32((((d^a)&c)^a)+b+x7+0xfd469501, 22) + a = b + bits.RotateLeft32((((c^d)&b)^d)+a+x8+0x698098d8, 7) + d = a + bits.RotateLeft32((((b^c)&a)^c)+d+x9+0x8b44f7af, 12) + c = d + bits.RotateLeft32((((a^b)&d)^b)+c+xa+0xffff5bb1, 17) + b = c + bits.RotateLeft32((((d^a)&c)^a)+b+xb+0x895cd7be, 22) + a = b + bits.RotateLeft32((((c^d)&b)^d)+a+xc+0x6b901122, 7) + d = a + bits.RotateLeft32((((b^c)&a)^c)+d+xd+0xfd987193, 12) + c = d + bits.RotateLeft32((((a^b)&d)^b)+c+xe+0xa679438e, 17) + b = c + bits.RotateLeft32((((d^a)&c)^a)+b+xf+0x49b40821, 22) + + // round 2 + a = b + bits.RotateLeft32((((b^c)&d)^c)+a+x1+0xf61e2562, 5) + d = a + bits.RotateLeft32((((a^b)&c)^b)+d+x6+0xc040b340, 9) + c = d + bits.RotateLeft32((((d^a)&b)^a)+c+xb+0x265e5a51, 14) + b = c + bits.RotateLeft32((((c^d)&a)^d)+b+x0+0xe9b6c7aa, 20) + a = b + bits.RotateLeft32((((b^c)&d)^c)+a+x5+0xd62f105d, 5) + d = a + bits.RotateLeft32((((a^b)&c)^b)+d+xa+0x02441453, 9) + c = d + bits.RotateLeft32((((d^a)&b)^a)+c+xf+0xd8a1e681, 14) + b = c + bits.RotateLeft32((((c^d)&a)^d)+b+x4+0xe7d3fbc8, 20) + a = b + bits.RotateLeft32((((b^c)&d)^c)+a+x9+0x21e1cde6, 5) + d = a + bits.RotateLeft32((((a^b)&c)^b)+d+xe+0xc33707d6, 9) + c = d + bits.RotateLeft32((((d^a)&b)^a)+c+x3+0xf4d50d87, 14) + b = c + bits.RotateLeft32((((c^d)&a)^d)+b+x8+0x455a14ed, 20) + a = b + bits.RotateLeft32((((b^c)&d)^c)+a+xd+0xa9e3e905, 5) + d = a + bits.RotateLeft32((((a^b)&c)^b)+d+x2+0xfcefa3f8, 9) + c = d + bits.RotateLeft32((((d^a)&b)^a)+c+x7+0x676f02d9, 14) + b = c + bits.RotateLeft32((((c^d)&a)^d)+b+xc+0x8d2a4c8a, 20) + + // round 3 + a = b + bits.RotateLeft32((b^c^d)+a+x5+0xfffa3942, 4) + d = a + bits.RotateLeft32((a^b^c)+d+x8+0x8771f681, 11) + c = d + bits.RotateLeft32((d^a^b)+c+xb+0x6d9d6122, 16) + b = c + bits.RotateLeft32((c^d^a)+b+xe+0xfde5380c, 23) + a = b + bits.RotateLeft32((b^c^d)+a+x1+0xa4beea44, 4) + d = a + bits.RotateLeft32((a^b^c)+d+x4+0x4bdecfa9, 11) + c = d + bits.RotateLeft32((d^a^b)+c+x7+0xf6bb4b60, 16) + b = c + bits.RotateLeft32((c^d^a)+b+xa+0xbebfbc70, 23) + a = b + bits.RotateLeft32((b^c^d)+a+xd+0x289b7ec6, 4) + d = a + bits.RotateLeft32((a^b^c)+d+x0+0xeaa127fa, 11) + c = d + bits.RotateLeft32((d^a^b)+c+x3+0xd4ef3085, 16) + b = c + bits.RotateLeft32((c^d^a)+b+x6+0x04881d05, 23) + a = b + bits.RotateLeft32((b^c^d)+a+x9+0xd9d4d039, 4) + d = a + bits.RotateLeft32((a^b^c)+d+xc+0xe6db99e5, 11) + c = d + bits.RotateLeft32((d^a^b)+c+xf+0x1fa27cf8, 16) + b = c + bits.RotateLeft32((c^d^a)+b+x2+0xc4ac5665, 23) + + // round 4 + a = b + bits.RotateLeft32((c^(b|^d))+a+x0+0xf4292244, 6) + d = a + bits.RotateLeft32((b^(a|^c))+d+x7+0x432aff97, 10) + c = d + bits.RotateLeft32((a^(d|^b))+c+xe+0xab9423a7, 15) + b = c + bits.RotateLeft32((d^(c|^a))+b+x5+0xfc93a039, 21) + a = b + bits.RotateLeft32((c^(b|^d))+a+xc+0x655b59c3, 6) + d = a + bits.RotateLeft32((b^(a|^c))+d+x3+0x8f0ccc92, 10) + c = d + bits.RotateLeft32((a^(d|^b))+c+xa+0xffeff47d, 15) + b = c + bits.RotateLeft32((d^(c|^a))+b+x1+0x85845dd1, 21) + a = b + bits.RotateLeft32((c^(b|^d))+a+x8+0x6fa87e4f, 6) + d = a + bits.RotateLeft32((b^(a|^c))+d+xf+0xfe2ce6e0, 10) + c = d + bits.RotateLeft32((a^(d|^b))+c+x6+0xa3014314, 15) + b = c + bits.RotateLeft32((d^(c|^a))+b+xd+0x4e0811a1, 21) + a = b + bits.RotateLeft32((c^(b|^d))+a+x4+0xf7537e82, 6) + d = a + bits.RotateLeft32((b^(a|^c))+d+xb+0xbd3af235, 10) + c = d + bits.RotateLeft32((a^(d|^b))+c+x2+0x2ad7d2bb, 15) + b = c + bits.RotateLeft32((d^(c|^a))+b+x9+0xeb86d391, 21) + + // add saved state a += aa b += bb c += cc d += dd - - p = p[chunk:] } - dig.s[0] = a - dig.s[1] = b - dig.s[2] = c - dig.s[3] = d + // save state + dig.s[0], dig.s[1], dig.s[2], dig.s[3] = a, b, c, d } diff --git a/libgo/go/crypto/md5/md5block_decl.go b/libgo/go/crypto/md5/md5block_decl.go index 5f9d7aba487..761398f38e9 100644 --- a/libgo/go/crypto/md5/md5block_decl.go +++ b/libgo/go/crypto/md5/md5block_decl.go @@ -3,10 +3,12 @@ // license that can be found in the LICENSE file. // +build ignore -// -build amd64 amd64p32 386 arm ppc64le s390x arm64 +// +build amd64 amd64p32 386 arm ppc64le ppc64 s390x arm64 package md5 +const haveAsm = true + //go:noescape func block(dig *digest, p []byte) diff --git a/libgo/go/crypto/md5/md5block_generic.go b/libgo/go/crypto/md5/md5block_generic.go index c580bc6d094..69c4456a4bd 100644 --- a/libgo/go/crypto/md5/md5block_generic.go +++ b/libgo/go/crypto/md5/md5block_generic.go @@ -2,8 +2,10 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// -build !amd64,!amd64p32,!386,!arm,!ppc64le,!s390x,!arm64 +// -build !amd64,!amd64p32,!386,!arm,!ppc64le,!ppc64,!s390x,!arm64 package md5 +const haveAsm = false + var block = blockGeneric diff --git a/libgo/go/crypto/rand/rand.go b/libgo/go/crypto/rand/rand.go index b8df8a37117..a5ccd19de32 100644 --- a/libgo/go/crypto/rand/rand.go +++ b/libgo/go/crypto/rand/rand.go @@ -11,7 +11,7 @@ import "io" // Reader is a global, shared instance of a cryptographically // secure random number generator. // -// On Linux, Reader uses getrandom(2) if available, /dev/urandom otherwise. +// On Linux and FreeBSD, Reader uses getrandom(2) if available, /dev/urandom otherwise. // On OpenBSD, Reader uses getentropy(2). // On other Unix-like systems, Reader reads from /dev/urandom. // On Windows systems, Reader uses the CryptGenRandom API. @@ -23,3 +23,7 @@ var Reader io.Reader func Read(b []byte) (n int, err error) { return io.ReadFull(Reader, b) } + +func warnBlocked() { + println("crypto/rand: blocked for 60 seconds waiting to read random data from the kernel") +} diff --git a/libgo/go/crypto/rand/rand_batched.go b/libgo/go/crypto/rand/rand_batched.go new file mode 100644 index 00000000000..60267fd4bc2 --- /dev/null +++ b/libgo/go/crypto/rand/rand_batched.go @@ -0,0 +1,42 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build linux freebsd + +package rand + +import ( + "internal/syscall/unix" +) + +// maxGetRandomRead is platform dependent. +func init() { + altGetRandom = batched(getRandomBatch, maxGetRandomRead) +} + +// batched returns a function that calls f to populate a []byte by chunking it +// into subslices of, at most, readMax bytes. +func batched(f func([]byte) bool, readMax int) func([]byte) bool { + return func(buf []byte) bool { + for len(buf) > readMax { + if !f(buf[:readMax]) { + return false + } + buf = buf[readMax:] + } + return len(buf) == 0 || f(buf) + } +} + +// If the kernel is too old to support the getrandom syscall(), +// unix.GetRandom will immediately return ENOSYS and we will then fall back to +// reading from /dev/urandom in rand_unix.go. unix.GetRandom caches the ENOSYS +// result so we only suffer the syscall overhead once in this case. +// If the kernel supports the getrandom() syscall, unix.GetRandom will block +// until the kernel has sufficient randomness (as we don't use GRND_NONBLOCK). +// In this case, unix.GetRandom will not return an error. +func getRandomBatch(p []byte) (ok bool) { + n, err := unix.GetRandom(p, 0) + return n == len(p) && err == nil +} diff --git a/libgo/go/crypto/rand/rand_linux_test.go b/libgo/go/crypto/rand/rand_batched_test.go similarity index 97% rename from libgo/go/crypto/rand/rand_linux_test.go rename to libgo/go/crypto/rand/rand_batched_test.go index 77b7b6ebd7a..837db83f770 100644 --- a/libgo/go/crypto/rand/rand_linux_test.go +++ b/libgo/go/crypto/rand/rand_batched_test.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build linux freebsd + package rand import ( diff --git a/libgo/go/crypto/rand/rand_freebsd.go b/libgo/go/crypto/rand/rand_freebsd.go new file mode 100644 index 00000000000..75f683c386d --- /dev/null +++ b/libgo/go/crypto/rand/rand_freebsd.go @@ -0,0 +1,9 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package rand + +// maxGetRandomRead is the maximum number of bytes to ask for in one call to the +// getrandom() syscall. In FreeBSD at most 256 bytes will be returned per call. +const maxGetRandomRead = 1 << 8 diff --git a/libgo/go/crypto/rand/rand_linux.go b/libgo/go/crypto/rand/rand_linux.go index dbd038cc582..26b93c54d28 100644 --- a/libgo/go/crypto/rand/rand_linux.go +++ b/libgo/go/crypto/rand/rand_linux.go @@ -4,14 +4,6 @@ package rand -import ( - "internal/syscall/unix" -) - -func init() { - altGetRandom = batched(getRandomLinux, maxGetRandomRead) -} - // maxGetRandomRead is the maximum number of bytes to ask for in one call to the // getrandom() syscall. In linux at most 2^25-1 bytes will be returned per call. // From the manpage @@ -20,29 +12,3 @@ func init() { // is returned by a single call to getrandom() on systems where int // has a size of 32 bits. const maxGetRandomRead = (1 << 25) - 1 - -// batched returns a function that calls f to populate a []byte by chunking it -// into subslices of, at most, readMax bytes. -func batched(f func([]byte) bool, readMax int) func([]byte) bool { - return func(buf []byte) bool { - for len(buf) > readMax { - if !f(buf[:readMax]) { - return false - } - buf = buf[readMax:] - } - return len(buf) == 0 || f(buf) - } -} - -// If the kernel is too old (before 3.17) to support the getrandom syscall(), -// unix.GetRandom will immediately return ENOSYS and we will then fall back to -// reading from /dev/urandom in rand_unix.go. unix.GetRandom caches the ENOSYS -// result so we only suffer the syscall overhead once in this case. -// If the kernel supports the getrandom() syscall, unix.GetRandom will block -// until the kernel has sufficient randomness (as we don't use GRND_NONBLOCK). -// In this case, unix.GetRandom will not return an error. -func getRandomLinux(p []byte) (ok bool) { - n, err := unix.GetRandom(p, 0) - return n == len(p) && err == nil -} diff --git a/libgo/go/crypto/rand/rand_unix.go b/libgo/go/crypto/rand/rand_unix.go index ec474d36ccf..f3091f51c5f 100644 --- a/libgo/go/crypto/rand/rand_unix.go +++ b/libgo/go/crypto/rand/rand_unix.go @@ -13,10 +13,12 @@ import ( "bufio" "crypto/aes" "crypto/cipher" + "encoding/binary" "io" "os" "runtime" "sync" + "sync/atomic" "time" ) @@ -38,6 +40,7 @@ type devReader struct { name string f io.Reader mu sync.Mutex + used int32 // atomic; whether this devReader has been used } // altGetRandom if non-nil specifies an OS-specific function to get @@ -45,6 +48,12 @@ type devReader struct { var altGetRandom func([]byte) (ok bool) func (r *devReader) Read(b []byte) (n int, err error) { + if atomic.CompareAndSwapInt32(&r.used, 0, 1) { + // First use of randomness. Start timer to warn about + // being blocked on entropy not being available. + t := time.AfterFunc(60*time.Second, warnBlocked) + defer t.Stop() + } if altGetRandom != nil && r.name == urandomDevice && altGetRandom(b) { return len(b), nil } @@ -137,14 +146,7 @@ func (r *reader) Read(b []byte) (n int, err error) { // dst = encrypt(t^seed) // seed = encrypt(t^dst) ns := time.Now().UnixNano() - r.time[0] = byte(ns >> 56) - r.time[1] = byte(ns >> 48) - r.time[2] = byte(ns >> 40) - r.time[3] = byte(ns >> 32) - r.time[4] = byte(ns >> 24) - r.time[5] = byte(ns >> 16) - r.time[6] = byte(ns >> 8) - r.time[7] = byte(ns) + binary.BigEndian.PutUint64(r.time[:], uint64(ns)) r.cipher.Encrypt(r.time[0:], r.time[0:]) for i := 0; i < aes.BlockSize; i++ { r.dst[i] = r.time[i] ^ r.seed[i] diff --git a/libgo/go/crypto/rand/rand_windows.go b/libgo/go/crypto/rand/rand_windows.go index 4d7511a8400..78a4ed6d67b 100644 --- a/libgo/go/crypto/rand/rand_windows.go +++ b/libgo/go/crypto/rand/rand_windows.go @@ -10,7 +10,9 @@ package rand import ( "os" "sync" + "sync/atomic" "syscall" + "time" ) // Implemented by using Windows CryptoAPI 2.0. @@ -19,11 +21,18 @@ func init() { Reader = &rngReader{} } // A rngReader satisfies reads by reading from the Windows CryptGenRandom API. type rngReader struct { + used int32 // atomic; whether this rngReader has been used prov syscall.Handle mu sync.Mutex } func (r *rngReader) Read(b []byte) (n int, err error) { + if atomic.CompareAndSwapInt32(&r.used, 0, 1) { + // First use of randomness. Start timer to warn about + // being blocked on entropy not being available. + t := time.AfterFunc(60*time.Second, warnBlocked) + defer t.Stop() + } r.mu.Lock() if r.prov == 0 { const provType = syscall.PROV_RSA_FULL diff --git a/libgo/go/crypto/rc4/rc4.go b/libgo/go/crypto/rc4/rc4.go index c445bb078f2..d5e6ebcd712 100644 --- a/libgo/go/crypto/rc4/rc4.go +++ b/libgo/go/crypto/rc4/rc4.go @@ -54,12 +54,9 @@ func (c *Cipher) Reset() { c.i, c.j = 0, 0 } -// xorKeyStreamGeneric sets dst to the result of XORing src with the -// key stream. Dst and src must overlap entirely or not at all. -// -// This is the pure Go version. rc4_{amd64,386,arm}* contain assembly -// implementations. This is here for tests and to prevent bitrot. -func (c *Cipher) xorKeyStreamGeneric(dst, src []byte) { +// XORKeyStream sets dst to the result of XORing src with the key stream. +// Dst and src must overlap entirely or not at all. +func (c *Cipher) XORKeyStream(dst, src []byte) { if len(src) == 0 { return } diff --git a/libgo/go/crypto/rc4/rc4_asm.go b/libgo/go/crypto/rc4/rc4_asm.go deleted file mode 100644 index ce2162df603..00000000000 --- a/libgo/go/crypto/rc4/rc4_asm.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +build amd64 amd64p32 arm,!nacl 386 - -package rc4 - -import "crypto/internal/subtle" - -func xorKeyStream(dst, src *byte, n int, state *[256]uint32, i, j *uint8) - -// XORKeyStream sets dst to the result of XORing src with the key stream. -// Dst and src must overlap entirely or not at all. -func (c *Cipher) XORKeyStream(dst, src []byte) { - if len(src) == 0 { - return - } - if len(dst) < len(src) { - panic("crypto/cipher: output smaller than input") - } - if subtle.InexactOverlap(dst[:len(src)], src) { - panic("crypto/cipher: invalid buffer overlap") - } - xorKeyStream(&dst[0], &src[0], len(src), &c.s, &c.i, &c.j) -} diff --git a/libgo/go/crypto/rc4/rc4_ref.go b/libgo/go/crypto/rc4/rc4_ref.go deleted file mode 100644 index d20dbb14a38..00000000000 --- a/libgo/go/crypto/rc4/rc4_ref.go +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// -build !amd64,!amd64p32,!arm,!386 arm,nacl - -package rc4 - -// XORKeyStream sets dst to the result of XORing src with the key stream. -// Dst and src must overlap entirely or not at all. -func (c *Cipher) XORKeyStream(dst, src []byte) { - c.xorKeyStreamGeneric(dst, src) -} diff --git a/libgo/go/crypto/rc4/rc4_test.go b/libgo/go/crypto/rc4/rc4_test.go index 1fc08b85934..e7356aa45de 100644 --- a/libgo/go/crypto/rc4/rc4_test.go +++ b/libgo/go/crypto/rc4/rc4_test.go @@ -117,30 +117,19 @@ func TestGolden(t *testing.T) { } func TestBlock(t *testing.T) { - testBlock(t, (*Cipher).XORKeyStream) -} - -// Test the pure Go version. -// Because we have assembly for amd64, 386, and arm, this prevents -// bitrot of the reference implementations. -func TestBlockGeneric(t *testing.T) { - testBlock(t, (*Cipher).xorKeyStreamGeneric) -} - -func testBlock(t *testing.T, xor func(c *Cipher, dst, src []byte)) { c1a, _ := NewCipher(golden[0].key) c1b, _ := NewCipher(golden[1].key) data1 := make([]byte, 1<<20) for i := range data1 { - xor(c1a, data1[i:i+1], data1[i:i+1]) - xor(c1b, data1[i:i+1], data1[i:i+1]) + c1a.XORKeyStream(data1[i:i+1], data1[i:i+1]) + c1b.XORKeyStream(data1[i:i+1], data1[i:i+1]) } c2a, _ := NewCipher(golden[0].key) c2b, _ := NewCipher(golden[1].key) data2 := make([]byte, 1<<20) - xor(c2a, data2, data2) - xor(c2b, data2, data2) + c2a.XORKeyStream(data2, data2) + c2b.XORKeyStream(data2, data2) if !bytes.Equal(data1, data2) { t.Fatalf("bad block") diff --git a/libgo/go/crypto/rsa/pss_test.go b/libgo/go/crypto/rsa/pss_test.go index cae24e58c67..dfa8d8bb5ad 100644 --- a/libgo/go/crypto/rsa/pss_test.go +++ b/libgo/go/crypto/rsa/pss_test.go @@ -103,7 +103,7 @@ func TestPSSGolden(t *testing.T) { switch { case len(line) == 0: if len(partialValue) > 0 { - values <- strings.Replace(partialValue, " ", "", -1) + values <- strings.ReplaceAll(partialValue, " ", "") partialValue = "" lastWasValue = true } diff --git a/libgo/go/crypto/sha1/sha1.go b/libgo/go/crypto/sha1/sha1.go index db70b7d09aa..8c48042b1ce 100644 --- a/libgo/go/crypto/sha1/sha1.go +++ b/libgo/go/crypto/sha1/sha1.go @@ -75,7 +75,7 @@ func (d *digest) UnmarshalBinary(b []byte) error { b, d.h[4] = consumeUint32(b) b = b[copy(d.x[:], b):] b, d.len = consumeUint64(b) - d.nx = int(d.len) % chunk + d.nx = int(d.len % chunk) return nil } diff --git a/libgo/go/crypto/sha1/sha1_test.go b/libgo/go/crypto/sha1/sha1_test.go index 4f229262adb..c047204bf31 100644 --- a/libgo/go/crypto/sha1/sha1_test.go +++ b/libgo/go/crypto/sha1/sha1_test.go @@ -11,6 +11,7 @@ import ( "crypto/rand" "encoding" "fmt" + "hash" "io" "testing" ) @@ -152,6 +153,63 @@ func TestBlockGeneric(t *testing.T) { } } +// Tests for unmarshaling hashes that have hashed a large amount of data +// The initial hash generation is omitted from the test, because it takes a long time. +// The test contains some already-generated states, and their expected sums +// Tests a problem that is outlined in Github issue #29543 +// The problem is triggered when an amount of data has been hashed for which +// the data length has a 1 in the 32nd bit. When casted to int, this changes +// the sign of the value, and causes the modulus operation to return a +// different result. +type unmarshalTest struct { + state string + sum string +} + +var largeUnmarshalTests = []unmarshalTest{ + // Data length: 7_102_415_735 + unmarshalTest{ + state: "sha\x01\x13\xbc\xfe\x83\x8c\xbd\xdfP\x1f\xd8ڿ<\x9eji8t\xe1\xa5@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuv\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xa7VCw", + sum: "bc6245c9959cc33e1c2592e5c9ea9b5d0431246c", + }, + // Data length: 6_565_544_823 + unmarshalTest{ + state: "sha\x01m;\x16\xa6R\xbe@\xa9nĈ\xf9S\x03\x00B\xc2\xdcv\xcf@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuv\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x87VCw", + sum: "8f2d1c0e4271768f35feb918bfe21ea1387a2072", + }, +} + +func safeSum(h hash.Hash) (sum []byte, err error) { + defer func() { + if r := recover(); r != nil { + err = fmt.Errorf("sum panic: %v", r) + } + }() + + return h.Sum(nil), nil +} + +func TestLargeHashes(t *testing.T) { + for i, test := range largeUnmarshalTests { + + h := New() + if err := h.(encoding.BinaryUnmarshaler).UnmarshalBinary([]byte(test.state)); err != nil { + t.Errorf("test %d could not unmarshal: %v", i, err) + continue + } + + sum, err := safeSum(h) + if err != nil { + t.Errorf("test %d could not sum: %v", i, err) + continue + } + + if fmt.Sprintf("%x", sum) != test.sum { + t.Errorf("test %d sum mismatch: expect %s got %x", i, test.sum, sum) + } + } +} + var bench = New() var buf = make([]byte, 8192) diff --git a/libgo/go/crypto/sha1/sha1block_arm64.go b/libgo/go/crypto/sha1/sha1block_arm64.go index 9e944392165..c5bd0041d8c 100644 --- a/libgo/go/crypto/sha1/sha1block_arm64.go +++ b/libgo/go/crypto/sha1/sha1block_arm64.go @@ -15,13 +15,11 @@ var k = []uint32{ 0xCA62C1D6, } -var hasSHA1 = cpu.ARM64.HasSHA1 - //go:noescape func sha1block(h []uint32, p []byte, k []uint32) func block(dig *digest, p []byte) { - if !hasSHA1 { + if !cpu.ARM64.HasSHA1 { blockGeneric(dig, p) } else { h := dig.h[:] diff --git a/libgo/go/crypto/sha256/sha256.go b/libgo/go/crypto/sha256/sha256.go index 1389de27277..3fd446f94b6 100644 --- a/libgo/go/crypto/sha256/sha256.go +++ b/libgo/go/crypto/sha256/sha256.go @@ -100,7 +100,7 @@ func (d *digest) UnmarshalBinary(b []byte) error { b, d.h[7] = consumeUint32(b) b = b[copy(d.x[:], b):] b, d.len = consumeUint64(b) - d.nx = int(d.len) % chunk + d.nx = int(d.len % chunk) return nil } diff --git a/libgo/go/crypto/sha256/sha256_test.go b/libgo/go/crypto/sha256/sha256_test.go index cd402864e52..a6061907535 100644 --- a/libgo/go/crypto/sha256/sha256_test.go +++ b/libgo/go/crypto/sha256/sha256_test.go @@ -226,6 +226,69 @@ func TestBlockGeneric(t *testing.T) { } } +// Tests for unmarshaling hashes that have hashed a large amount of data +// The initial hash generation is omitted from the test, because it takes a long time. +// The test contains some already-generated states, and their expected sums +// Tests a problem that is outlined in Github issue #29517 +// The problem is triggered when an amount of data has been hashed for which +// the data length has a 1 in the 32nd bit. When casted to int, this changes +// the sign of the value, and causes the modulus operation to return a +// different result. +type unmarshalTest struct { + state string + sum string +} + +var largeUnmarshalTests = []unmarshalTest{ + // Data length: 7_115_087_207 + unmarshalTest{ + state: "sha\x03yX\xaf\xb7\x04*\x8f\xaa\x9bx\xc5#\x1f\xeb\x94\xfdz1\xaf\xfbk֗\n\xc93\xcf\x02\v.\xa5\xe4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xa8\x17\x9dg", + sum: "f5e06371f0c115e9968455c8e48a318aba548b9f15676fa41de123f7d1c99c55", + }, + + // Data length: 7_070_038_086 + unmarshalTest{ + state: "sha\x03$\x933u\nV\v\xe2\xf7:0!ʳ\xa4\x13\xd3 6\xdcBB\xb5\x19\xcd=\xc1h\xee=\xb4\x9c@ABCDE\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xa5h8F", + sum: "a280b08df5eba060fcd0eb3d29320bbc038afb95781661f91bbfd0a6fc9fdd6e", + }, + + // Data length: 6_464_878_887 + unmarshalTest{ + state: "sha\x03\x9f\x12\x87G\xf2\xdf<\x82\xa0\x11/*W\x02&IKWlh\x03\x95\xb1\xab\f\n\xf6Ze\xf9\x1d\x1b\x00\x01\x02\x03\x04\x05\x06\a\b\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x81V9'", + sum: "d2fffb762f105ab71e2d70069346c44c38c4fe183aad8cfcf5a76397c0457806", + }, +} + +func safeSum(h hash.Hash) (sum []byte, err error) { + defer func() { + if r := recover(); r != nil { + err = fmt.Errorf("sum panic: %v", r) + } + }() + + return h.Sum(nil), nil +} +func TestLargeHashes(t *testing.T) { + for i, test := range largeUnmarshalTests { + + h := New() + if err := h.(encoding.BinaryUnmarshaler).UnmarshalBinary([]byte(test.state)); err != nil { + t.Errorf("test %d could not unmarshal: %v", i, err) + continue + } + + sum, err := safeSum(h) + if err != nil { + t.Errorf("test %d could not sum: %v", i, err) + continue + } + + if fmt.Sprintf("%x", sum) != test.sum { + t.Errorf("test %d sum mismatch: expect %s got %x", i, test.sum, sum) + } + } +} + var bench = New() var buf = make([]byte, 8192) diff --git a/libgo/go/crypto/sha256/sha256block_arm64.go b/libgo/go/crypto/sha256/sha256block_arm64.go index df0aeeed84a..d8f3437f7d8 100644 --- a/libgo/go/crypto/sha256/sha256block_arm64.go +++ b/libgo/go/crypto/sha256/sha256block_arm64.go @@ -10,13 +10,11 @@ import "internal/cpu" var k = _K -var hasSHA2 = cpu.ARM64.HasSHA2 - //go:noescape func sha256block(h []uint32, p []byte, k []uint32) func block(dig *digest, p []byte) { - if !hasSHA2 { + if !cpu.ARM64.HasSHA2 { blockGeneric(dig, p) } else { h := dig.h[:] diff --git a/libgo/go/crypto/sha512/sha512.go b/libgo/go/crypto/sha512/sha512.go index 24fde7dce70..c685319480c 100644 --- a/libgo/go/crypto/sha512/sha512.go +++ b/libgo/go/crypto/sha512/sha512.go @@ -191,7 +191,7 @@ func (d *digest) UnmarshalBinary(b []byte) error { b, d.h[7] = consumeUint64(b) b = b[copy(d.x[:], b):] b, d.len = consumeUint64(b) - d.nx = int(d.len) % chunk + d.nx = int(d.len % chunk) return nil } diff --git a/libgo/go/crypto/sha512/sha512_test.go b/libgo/go/crypto/sha512/sha512_test.go index 4423cf5f189..96a1aa69a4f 100644 --- a/libgo/go/crypto/sha512/sha512_test.go +++ b/libgo/go/crypto/sha512/sha512_test.go @@ -11,6 +11,7 @@ import ( "crypto/rand" "encoding" "encoding/hex" + "fmt" "hash" "io" "testing" @@ -831,6 +832,62 @@ func TestBlockGeneric(t *testing.T) { } } +// Tests for unmarshaling hashes that have hashed a large amount of data +// The initial hash generation is omitted from the test, because it takes a long time. +// The test contains some already-generated states, and their expected sums +// Tests a problem that is outlined in Github issue #29541 +// The problem is triggered when an amount of data has been hashed for which +// the data length has a 1 in the 32nd bit. When casted to int, this changes +// the sign of the value, and causes the modulus operation to return a +// different result. +type unmarshalTest struct { + state string + sum string +} + +var largeUnmarshalTests = []unmarshalTest{ + // Data length: 6_565_544_823 + unmarshalTest{ + state: "sha\aηe\x0f\x0f\xe1r]#\aoJ!.{5B\xe4\x140\x91\xdd\x00a\xe1\xb3E&\xb9\xbb\aJ\x9f^\x9f\x03ͺD\x96H\x80\xb0X\x9d\xdeʸ\f\xf7:\xd5\xe6'\xb9\x93f\xddA\xf0~\xe1\x02\x14\x00\x01\x02\x03\x04\x05\x06\a\b\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuv\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x87VCw", + sum: "12d612357a1dbc74a28883dff79b83e7d2b881ae40d7a67fd7305490bc8a641cd1ce9ece598192080d6e9ac7e75d5988567a58a9812991299eb99a04ecb69523", + }, + unmarshalTest{ + state: "sha\a2\xd2\xdc\xf5\xd7\xe2\xf9\x97\xaa\xe7}Fϱ\xbc\x8e\xbf\x12h\x83Z\xa1\xc7\xf5p>bfS T\xea\xee\x1e\xa6Z\x9c\xa4ڶ\u0086\bn\xe47\x8fsGs3\xe0\xda\\\x9dqZ\xa5\xf6\xd0kM\xa1\xf2\x00\x01\x02\x03\x04\x05\x06\a\b\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuv\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xa7VCw", + sum: "94a04b9a901254cd94ca0313557e4be3ab1ca86e920c1f3efdc22d361e9ae12be66bc6d6dc5db79a0a4aa6eca6f293c1e9095bbae127ae405f6c325478343299", + }, +} + +func safeSum(h hash.Hash) (sum []byte, err error) { + defer func() { + if r := recover(); r != nil { + err = fmt.Errorf("sum panic: %v", r) + } + }() + + return h.Sum(nil), nil +} + +func TestLargeHashes(t *testing.T) { + for i, test := range largeUnmarshalTests { + + h := New() + if err := h.(encoding.BinaryUnmarshaler).UnmarshalBinary([]byte(test.state)); err != nil { + t.Errorf("test %d could not unmarshal: %v", i, err) + continue + } + + sum, err := safeSum(h) + if err != nil { + t.Errorf("test %d could not sum: %v", i, err) + continue + } + + if fmt.Sprintf("%x", sum) != test.sum { + t.Errorf("test %d sum mismatch: expect %s got %x", i, test.sum, sum) + } + } +} + var bench = New() var buf = make([]byte, 8192) diff --git a/libgo/go/crypto/tls/alert.go b/libgo/go/crypto/tls/alert.go index 49298682574..24199a735a8 100644 --- a/libgo/go/crypto/tls/alert.go +++ b/libgo/go/crypto/tls/alert.go @@ -38,6 +38,8 @@ const ( alertInappropriateFallback alert = 86 alertUserCanceled alert = 90 alertNoRenegotiation alert = 100 + alertMissingExtension alert = 109 + alertUnsupportedExtension alert = 110 alertNoApplicationProtocol alert = 120 ) @@ -65,6 +67,8 @@ var alertText = map[alert]string{ alertInappropriateFallback: "inappropriate fallback", alertUserCanceled: "user canceled", alertNoRenegotiation: "no renegotiation", + alertMissingExtension: "missing extension", + alertUnsupportedExtension: "unsupported extension", alertNoApplicationProtocol: "no application protocol", } diff --git a/libgo/go/crypto/tls/auth.go b/libgo/go/crypto/tls/auth.go index 88face4cdee..6fe97185050 100644 --- a/libgo/go/crypto/tls/auth.go +++ b/libgo/go/crypto/tls/auth.go @@ -7,10 +7,13 @@ package tls import ( "crypto" "crypto/ecdsa" + "crypto/elliptic" "crypto/rsa" "encoding/asn1" "errors" "fmt" + "hash" + "io" ) // pickSignatureAlgorithm selects a signature algorithm that is compatible with @@ -23,10 +26,9 @@ import ( func pickSignatureAlgorithm(pubkey crypto.PublicKey, peerSigAlgs, ourSigAlgs []SignatureScheme, tlsVersion uint16) (sigAlg SignatureScheme, sigType uint8, hashFunc crypto.Hash, err error) { if tlsVersion < VersionTLS12 || len(peerSigAlgs) == 0 { // For TLS 1.1 and before, the signature algorithm could not be - // negotiated and the hash is fixed based on the signature type. - // For TLS 1.2, if the client didn't send signature_algorithms - // extension then we can assume that it supports SHA1. See - // https://tools.ietf.org/html/rfc5246#section-7.4.1.4.1 + // negotiated and the hash is fixed based on the signature type. For TLS + // 1.2, if the client didn't send signature_algorithms extension then we + // can assume that it supports SHA1. See RFC 5246, Section 7.4.1.4.1. switch pubkey.(type) { case *rsa.PublicKey: if tlsVersion < VersionTLS12 { @@ -44,7 +46,7 @@ func pickSignatureAlgorithm(pubkey crypto.PublicKey, peerSigAlgs, ourSigAlgs []S if !isSupportedSignatureAlgorithm(sigAlg, ourSigAlgs) { continue } - hashAlg, err := lookupTLSHash(sigAlg) + hashAlg, err := hashFromSignatureScheme(sigAlg) if err != nil { panic("tls: supported signature algorithm has an unknown hash function") } @@ -106,3 +108,114 @@ func verifyHandshakeSignature(sigType uint8, pubkey crypto.PublicKey, hashFunc c } return nil } + +const ( + serverSignatureContext = "TLS 1.3, server CertificateVerify\x00" + clientSignatureContext = "TLS 1.3, client CertificateVerify\x00" +) + +var signaturePadding = []byte{ + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, +} + +// writeSignedMessage writes the content to be signed by certificate keys in TLS +// 1.3 to sigHash. See RFC 8446, Section 4.4.3. +func writeSignedMessage(sigHash io.Writer, context string, transcript hash.Hash) { + sigHash.Write(signaturePadding) + io.WriteString(sigHash, context) + sigHash.Write(transcript.Sum(nil)) +} + +// signatureSchemesForCertificate returns the list of supported SignatureSchemes +// for a given certificate, based on the public key and the protocol version. It +// does not support the crypto.Decrypter interface, so shouldn't be used on the +// server side in TLS 1.2 and earlier. +func signatureSchemesForCertificate(version uint16, cert *Certificate) []SignatureScheme { + priv, ok := cert.PrivateKey.(crypto.Signer) + if !ok { + return nil + } + + switch pub := priv.Public().(type) { + case *ecdsa.PublicKey: + if version != VersionTLS13 { + // In TLS 1.2 and earlier, ECDSA algorithms are not + // constrained to a single curve. + return []SignatureScheme{ + ECDSAWithP256AndSHA256, + ECDSAWithP384AndSHA384, + ECDSAWithP521AndSHA512, + ECDSAWithSHA1, + } + } + switch pub.Curve { + case elliptic.P256(): + return []SignatureScheme{ECDSAWithP256AndSHA256} + case elliptic.P384(): + return []SignatureScheme{ECDSAWithP384AndSHA384} + case elliptic.P521(): + return []SignatureScheme{ECDSAWithP521AndSHA512} + default: + return nil + } + case *rsa.PublicKey: + if version != VersionTLS13 { + return []SignatureScheme{ + PSSWithSHA256, + PSSWithSHA384, + PSSWithSHA512, + PKCS1WithSHA256, + PKCS1WithSHA384, + PKCS1WithSHA512, + PKCS1WithSHA1, + } + } + // RSA keys with RSA-PSS OID are not supported by crypto/x509. + return []SignatureScheme{ + PSSWithSHA256, + PSSWithSHA384, + PSSWithSHA512, + } + default: + return nil + } +} + +// unsupportedCertificateError returns a helpful error for certificates with +// an unsupported private key. +func unsupportedCertificateError(cert *Certificate) error { + switch cert.PrivateKey.(type) { + case rsa.PrivateKey, ecdsa.PrivateKey: + return fmt.Errorf("tls: unsupported certificate: private key is %T, expected *%T", + cert.PrivateKey, cert.PrivateKey) + } + + signer, ok := cert.PrivateKey.(crypto.Signer) + if !ok { + return fmt.Errorf("tls: certificate private key (%T) does not implement crypto.Signer", + cert.PrivateKey) + } + + switch pub := signer.Public().(type) { + case *ecdsa.PublicKey: + switch pub.Curve { + case elliptic.P256(): + case elliptic.P384(): + case elliptic.P521(): + default: + return fmt.Errorf("tls: unsupported certificate curve (%s)", pub.Curve.Params().Name) + } + case *rsa.PublicKey: + default: + return fmt.Errorf("tls: unsupported certificate key (%T)", pub) + } + + return fmt.Errorf("tls: internal error: unsupported key (%T)", cert.PrivateKey) +} diff --git a/libgo/go/crypto/tls/cipher_suites.go b/libgo/go/crypto/tls/cipher_suites.go index 3c8dc4b2d29..ecb4db290a0 100644 --- a/libgo/go/crypto/tls/cipher_suites.go +++ b/libgo/go/crypto/tls/cipher_suites.go @@ -5,6 +5,7 @@ package tls import ( + "crypto" "crypto/aes" "crypto/cipher" "crypto/des" @@ -14,8 +15,7 @@ import ( "crypto/sha256" "crypto/x509" "hash" - - "golang_org/x/crypto/chacha20poly1305" + "internal/x/crypto/chacha20poly1305" ) // a keyAgreement implements the client and server side of a TLS key agreement @@ -59,8 +59,7 @@ const ( suiteDefaultOff ) -// A cipherSuite is a specific combination of key agreement, cipher and MAC -// function. All cipher suites currently assume RSA key agreement. +// A cipherSuite is a specific combination of key agreement, cipher and MAC function. type cipherSuite struct { id uint16 // the lengths, in bytes, of the key material needed for each component. @@ -72,7 +71,7 @@ type cipherSuite struct { flags int cipher func(key, iv []byte, isRead bool) interface{} mac func(version uint16, macKey []byte) macFunction - aead func(key, fixedNonce []byte) cipher.AEAD + aead func(key, fixedNonce []byte) aead } var cipherSuites = []*cipherSuite{ @@ -104,6 +103,21 @@ var cipherSuites = []*cipherSuite{ {TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, 16, 20, 0, ecdheECDSAKA, suiteECDHE | suiteECDSA | suiteDefaultOff, cipherRC4, macSHA1, nil}, } +// A cipherSuiteTLS13 defines only the pair of the AEAD algorithm and hash +// algorithm to be used with HKDF. See RFC 8446, Appendix B.4. +type cipherSuiteTLS13 struct { + id uint16 + keyLen int + aead func(key, fixedNonce []byte) aead + hash crypto.Hash +} + +var cipherSuitesTLS13 = []*cipherSuiteTLS13{ + {TLS_AES_128_GCM_SHA256, 16, aeadAESGCMTLS13, crypto.SHA256}, + {TLS_CHACHA20_POLY1305_SHA256, 32, aeadChaCha20Poly1305, crypto.SHA256}, + {TLS_AES_256_GCM_SHA384, 32, aeadAESGCMTLS13, crypto.SHA384}, +} + func cipherRC4(key, iv []byte, isRead bool) interface{} { cipher, _ := rc4.NewCipher(key) return cipher @@ -135,59 +149,68 @@ func macSHA1(version uint16, key []byte) macFunction { copy(mac.key, key) return mac } - return tls10MAC{hmac.New(newConstantTimeHash(sha1.New), key)} + return tls10MAC{h: hmac.New(newConstantTimeHash(sha1.New), key)} } // macSHA256 returns a SHA-256 based MAC. These are only supported in TLS 1.2 // so the given version is ignored. func macSHA256(version uint16, key []byte) macFunction { - return tls10MAC{hmac.New(sha256.New, key)} + return tls10MAC{h: hmac.New(sha256.New, key)} } type macFunction interface { + // Size returns the length of the MAC. Size() int - MAC(digestBuf, seq, header, data, extra []byte) []byte + // MAC appends the MAC of (seq, header, data) to out. The extra data is fed + // into the MAC after obtaining the result to normalize timing. The result + // is only valid until the next invocation of MAC as the buffer is reused. + MAC(seq, header, data, extra []byte) []byte } type aead interface { cipher.AEAD - // explicitIVLen returns the number of bytes used by the explicit nonce - // that is included in the record. This is eight for older AEADs and + // explicitNonceLen returns the number of bytes of explicit nonce + // included in each record. This is eight for older AEADs and // zero for modern ones. explicitNonceLen() int } -// fixedNonceAEAD wraps an AEAD and prefixes a fixed portion of the nonce to +const ( + aeadNonceLength = 12 + noncePrefixLength = 4 +) + +// prefixNonceAEAD wraps an AEAD and prefixes a fixed portion of the nonce to // each call. -type fixedNonceAEAD struct { +type prefixNonceAEAD struct { // nonce contains the fixed part of the nonce in the first four bytes. - nonce [12]byte + nonce [aeadNonceLength]byte aead cipher.AEAD } -func (f *fixedNonceAEAD) NonceSize() int { return 8 } -func (f *fixedNonceAEAD) Overhead() int { return f.aead.Overhead() } -func (f *fixedNonceAEAD) explicitNonceLen() int { return 8 } +func (f *prefixNonceAEAD) NonceSize() int { return aeadNonceLength - noncePrefixLength } +func (f *prefixNonceAEAD) Overhead() int { return f.aead.Overhead() } +func (f *prefixNonceAEAD) explicitNonceLen() int { return f.NonceSize() } -func (f *fixedNonceAEAD) Seal(out, nonce, plaintext, additionalData []byte) []byte { +func (f *prefixNonceAEAD) Seal(out, nonce, plaintext, additionalData []byte) []byte { copy(f.nonce[4:], nonce) return f.aead.Seal(out, f.nonce[:], plaintext, additionalData) } -func (f *fixedNonceAEAD) Open(out, nonce, plaintext, additionalData []byte) ([]byte, error) { +func (f *prefixNonceAEAD) Open(out, nonce, ciphertext, additionalData []byte) ([]byte, error) { copy(f.nonce[4:], nonce) - return f.aead.Open(out, f.nonce[:], plaintext, additionalData) + return f.aead.Open(out, f.nonce[:], ciphertext, additionalData) } // xoredNonceAEAD wraps an AEAD by XORing in a fixed pattern to the nonce // before each call. type xorNonceAEAD struct { - nonceMask [12]byte + nonceMask [aeadNonceLength]byte aead cipher.AEAD } -func (f *xorNonceAEAD) NonceSize() int { return 8 } +func (f *xorNonceAEAD) NonceSize() int { return 8 } // 64-bit sequence number func (f *xorNonceAEAD) Overhead() int { return f.aead.Overhead() } func (f *xorNonceAEAD) explicitNonceLen() int { return 0 } @@ -203,11 +226,11 @@ func (f *xorNonceAEAD) Seal(out, nonce, plaintext, additionalData []byte) []byte return result } -func (f *xorNonceAEAD) Open(out, nonce, plaintext, additionalData []byte) ([]byte, error) { +func (f *xorNonceAEAD) Open(out, nonce, ciphertext, additionalData []byte) ([]byte, error) { for i, b := range nonce { f.nonceMask[4+i] ^= b } - result, err := f.aead.Open(out, f.nonceMask[:], plaintext, additionalData) + result, err := f.aead.Open(out, f.nonceMask[:], ciphertext, additionalData) for i, b := range nonce { f.nonceMask[4+i] ^= b } @@ -215,7 +238,28 @@ func (f *xorNonceAEAD) Open(out, nonce, plaintext, additionalData []byte) ([]byt return result, err } -func aeadAESGCM(key, fixedNonce []byte) cipher.AEAD { +func aeadAESGCM(key, noncePrefix []byte) aead { + if len(noncePrefix) != noncePrefixLength { + panic("tls: internal error: wrong nonce length") + } + aes, err := aes.NewCipher(key) + if err != nil { + panic(err) + } + aead, err := cipher.NewGCM(aes) + if err != nil { + panic(err) + } + + ret := &prefixNonceAEAD{aead: aead} + copy(ret.nonce[:], noncePrefix) + return ret +} + +func aeadAESGCMTLS13(key, nonceMask []byte) aead { + if len(nonceMask) != aeadNonceLength { + panic("tls: internal error: wrong nonce length") + } aes, err := aes.NewCipher(key) if err != nil { panic(err) @@ -225,19 +269,22 @@ func aeadAESGCM(key, fixedNonce []byte) cipher.AEAD { panic(err) } - ret := &fixedNonceAEAD{aead: aead} - copy(ret.nonce[:], fixedNonce) + ret := &xorNonceAEAD{aead: aead} + copy(ret.nonceMask[:], nonceMask) return ret } -func aeadChaCha20Poly1305(key, fixedNonce []byte) cipher.AEAD { +func aeadChaCha20Poly1305(key, nonceMask []byte) aead { + if len(nonceMask) != aeadNonceLength { + panic("tls: internal error: wrong nonce length") + } aead, err := chacha20poly1305.New(key) if err != nil { panic(err) } ret := &xorNonceAEAD{aead: aead} - copy(ret.nonceMask[:], fixedNonce) + copy(ret.nonceMask[:], nonceMask) return ret } @@ -246,6 +293,7 @@ func aeadChaCha20Poly1305(key, fixedNonce []byte) cipher.AEAD { type ssl30MAC struct { h hash.Hash key []byte + buf []byte } func (s ssl30MAC) Size() int { @@ -258,7 +306,7 @@ var ssl30Pad2 = [48]byte{0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0 // MAC does not offer constant timing guarantees for SSL v3.0, since it's deemed // useless considering the similar, protocol-level POODLE vulnerability. -func (s ssl30MAC) MAC(digestBuf, seq, header, data, extra []byte) []byte { +func (s ssl30MAC) MAC(seq, header, data, extra []byte) []byte { padLength := 48 if s.h.Size() == 20 { padLength = 40 @@ -271,13 +319,13 @@ func (s ssl30MAC) MAC(digestBuf, seq, header, data, extra []byte) []byte { s.h.Write(header[:1]) s.h.Write(header[3:5]) s.h.Write(data) - digestBuf = s.h.Sum(digestBuf[:0]) + s.buf = s.h.Sum(s.buf[:0]) s.h.Reset() s.h.Write(s.key) s.h.Write(ssl30Pad2[:padLength]) - s.h.Write(digestBuf) - return s.h.Sum(digestBuf[:0]) + s.h.Write(s.buf) + return s.h.Sum(s.buf[:0]) } type constantTimeHash interface { @@ -303,9 +351,10 @@ func newConstantTimeHash(h func() hash.Hash) func() hash.Hash { } } -// tls10MAC implements the TLS 1.0 MAC function. RFC 2246, section 6.2.3. +// tls10MAC implements the TLS 1.0 MAC function. RFC 2246, Section 6.2.3. type tls10MAC struct { - h hash.Hash + h hash.Hash + buf []byte } func (s tls10MAC) Size() int { @@ -315,12 +364,12 @@ func (s tls10MAC) Size() int { // MAC is guaranteed to take constant time, as long as // len(seq)+len(header)+len(data)+len(extra) is constant. extra is not fed into // the MAC, but is only provided to make the timing profile constant. -func (s tls10MAC) MAC(digestBuf, seq, header, data, extra []byte) []byte { +func (s tls10MAC) MAC(seq, header, data, extra []byte) []byte { s.h.Reset() s.h.Write(seq) s.h.Write(header) s.h.Write(data) - res := s.h.Sum(digestBuf[:0]) + res := s.h.Sum(s.buf[:0]) if extra != nil { s.h.Write(extra) } @@ -350,12 +399,34 @@ func ecdheRSAKA(version uint16) keyAgreement { func mutualCipherSuite(have []uint16, want uint16) *cipherSuite { for _, id := range have { if id == want { - for _, suite := range cipherSuites { - if suite.id == want { - return suite - } - } - return nil + return cipherSuiteByID(id) + } + } + return nil +} + +func cipherSuiteByID(id uint16) *cipherSuite { + for _, cipherSuite := range cipherSuites { + if cipherSuite.id == id { + return cipherSuite + } + } + return nil +} + +func mutualCipherSuiteTLS13(have []uint16, want uint16) *cipherSuiteTLS13 { + for _, id := range have { + if id == want { + return cipherSuiteTLS13ByID(id) + } + } + return nil +} + +func cipherSuiteTLS13ByID(id uint16) *cipherSuiteTLS13 { + for _, cipherSuite := range cipherSuitesTLS13 { + if cipherSuite.id == id { + return cipherSuite } } return nil @@ -366,6 +437,7 @@ func mutualCipherSuite(have []uint16, want uint16) *cipherSuite { // // Taken from https://www.iana.org/assignments/tls-parameters/tls-parameters.xml const ( + // TLS 1.0 - 1.2 cipher suites. TLS_RSA_WITH_RC4_128_SHA uint16 = 0x0005 TLS_RSA_WITH_3DES_EDE_CBC_SHA uint16 = 0x000a TLS_RSA_WITH_AES_128_CBC_SHA uint16 = 0x002f @@ -389,8 +461,12 @@ const ( TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305 uint16 = 0xcca8 TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 uint16 = 0xcca9 + // TLS 1.3 cipher suites. + TLS_AES_128_GCM_SHA256 uint16 = 0x1301 + TLS_AES_256_GCM_SHA384 uint16 = 0x1302 + TLS_CHACHA20_POLY1305_SHA256 uint16 = 0x1303 + // TLS_FALLBACK_SCSV isn't a standard cipher suite but an indicator - // that the client is doing version fallback. See - // https://tools.ietf.org/html/rfc7507. + // that the client is doing version fallback. See RFC 7507. TLS_FALLBACK_SCSV uint16 = 0x5600 ) diff --git a/libgo/go/crypto/tls/common.go b/libgo/go/crypto/tls/common.go index 7b627fc0253..0bc40ccf0b5 100644 --- a/libgo/go/crypto/tls/common.go +++ b/libgo/go/crypto/tls/common.go @@ -26,17 +26,16 @@ const ( VersionTLS10 = 0x0301 VersionTLS11 = 0x0302 VersionTLS12 = 0x0303 + VersionTLS13 = 0x0304 ) const ( - maxPlaintext = 16384 // maximum plaintext payload length - maxCiphertext = 16384 + 2048 // maximum ciphertext payload length - recordHeaderLen = 5 // record header length - maxHandshake = 65536 // maximum handshake we support (protocol max is 16 MB) - maxWarnAlertCount = 5 // maximum number of consecutive warning alerts - - minVersion = VersionTLS10 - maxVersion = VersionTLS12 + maxPlaintext = 16384 // maximum plaintext payload length + maxCiphertext = 16384 + 2048 // maximum ciphertext payload length + maxCiphertextTLS13 = 16384 + 256 // maximum ciphertext length in TLS 1.3 + recordHeaderLen = 5 // record header length + maxHandshake = 65536 // maximum handshake we support (protocol max is 16 MB) + maxUselessRecords = 16 // maximum number of consecutive non-advancing records ) // TLS record types. @@ -51,19 +50,23 @@ const ( // TLS handshake message types. const ( - typeHelloRequest uint8 = 0 - typeClientHello uint8 = 1 - typeServerHello uint8 = 2 - typeNewSessionTicket uint8 = 4 - typeCertificate uint8 = 11 - typeServerKeyExchange uint8 = 12 - typeCertificateRequest uint8 = 13 - typeServerHelloDone uint8 = 14 - typeCertificateVerify uint8 = 15 - typeClientKeyExchange uint8 = 16 - typeFinished uint8 = 20 - typeCertificateStatus uint8 = 22 - typeNextProtocol uint8 = 67 // Not IANA assigned + typeHelloRequest uint8 = 0 + typeClientHello uint8 = 1 + typeServerHello uint8 = 2 + typeNewSessionTicket uint8 = 4 + typeEndOfEarlyData uint8 = 5 + typeEncryptedExtensions uint8 = 8 + typeCertificate uint8 = 11 + typeServerKeyExchange uint8 = 12 + typeCertificateRequest uint8 = 13 + typeServerHelloDone uint8 = 14 + typeCertificateVerify uint8 = 15 + typeClientKeyExchange uint8 = 16 + typeFinished uint8 = 20 + typeCertificateStatus uint8 = 22 + typeKeyUpdate uint8 = 24 + typeNextProtocol uint8 = 67 // Not IANA assigned + typeMessageHash uint8 = 254 // synthetic message ) // TLS compression types. @@ -73,16 +76,24 @@ const ( // TLS extension numbers const ( - extensionServerName uint16 = 0 - extensionStatusRequest uint16 = 5 - extensionSupportedCurves uint16 = 10 - extensionSupportedPoints uint16 = 11 - extensionSignatureAlgorithms uint16 = 13 - extensionALPN uint16 = 16 - extensionSCT uint16 = 18 // https://tools.ietf.org/html/rfc6962#section-6 - extensionSessionTicket uint16 = 35 - extensionNextProtoNeg uint16 = 13172 // not IANA assigned - extensionRenegotiationInfo uint16 = 0xff01 + extensionServerName uint16 = 0 + extensionStatusRequest uint16 = 5 + extensionSupportedCurves uint16 = 10 // supported_groups in TLS 1.3, see RFC 8446, Section 4.2.7 + extensionSupportedPoints uint16 = 11 + extensionSignatureAlgorithms uint16 = 13 + extensionALPN uint16 = 16 + extensionSCT uint16 = 18 + extensionSessionTicket uint16 = 35 + extensionPreSharedKey uint16 = 41 + extensionEarlyData uint16 = 42 + extensionSupportedVersions uint16 = 43 + extensionCookie uint16 = 44 + extensionPSKModes uint16 = 45 + extensionCertificateAuthorities uint16 = 47 + extensionSignatureAlgorithmsCert uint16 = 50 + extensionKeyShare uint16 = 51 + extensionNextProtoNeg uint16 = 13172 // not IANA assigned + extensionRenegotiationInfo uint16 = 0xff01 ) // TLS signaling cipher suite values @@ -91,7 +102,10 @@ const ( ) // CurveID is the type of a TLS identifier for an elliptic curve. See -// https://www.iana.org/assignments/tls-parameters/tls-parameters.xml#tls-parameters-8 +// https://www.iana.org/assignments/tls-parameters/tls-parameters.xml#tls-parameters-8. +// +// In TLS 1.3, this type is called NamedGroup, but at this time this library +// only supports Elliptic Curve based groups. See RFC 8446, Section 4.2.7. type CurveID uint16 const ( @@ -101,6 +115,25 @@ const ( X25519 CurveID = 29 ) +// TLS 1.3 Key Share. See RFC 8446, Section 4.2.8. +type keyShare struct { + group CurveID + data []byte +} + +// TLS 1.3 PSK Key Exchange Modes. See RFC 8446, Section 4.2.9. +const ( + pskModePlain uint8 = 0 + pskModeDHE uint8 = 1 +) + +// TLS 1.3 PSK Identity. Can be a Session Ticket, or a reference to a saved +// session. See RFC 8446, Section 4.2.11. +type pskIdentity struct { + label []byte + obfuscatedTicketAge uint32 +} + // TLS Elliptic Curve Point Formats // https://www.iana.org/assignments/tls-parameters/tls-parameters.xml#tls-parameters-9 const ( @@ -114,21 +147,12 @@ const ( // Certificate types (for certificateRequestMsg) const ( - certTypeRSASign = 1 // A certificate containing an RSA key - certTypeDSSSign = 2 // A certificate containing a DSA key - certTypeRSAFixedDH = 3 // A certificate containing a static DH key - certTypeDSSFixedDH = 4 // A certificate containing a static DH key - - // See RFC 4492 sections 3 and 5.5. - certTypeECDSASign = 64 // A certificate containing an ECDSA-capable public key, signed with ECDSA. - certTypeRSAFixedECDH = 65 // A certificate containing an ECDH-capable public key, signed with RSA. - certTypeECDSAFixedECDH = 66 // A certificate containing an ECDH-capable public key, signed with ECDSA. - - // Rest of these are reserved by the TLS spec + certTypeRSASign = 1 + certTypeECDSASign = 64 // RFC 4492, Section 5.5 ) // Signature algorithms (for internal signaling use). Starting at 16 to avoid overlap with -// TLS 1.2 codepoints (RFC 5246, section A.4.1), with which these have nothing to do. +// TLS 1.2 codepoints (RFC 5246, Appendix A.4.1), with which these have nothing to do. const ( signaturePKCS1v15 uint8 = iota + 16 signatureECDSA @@ -140,6 +164,9 @@ const ( // CertificateRequest. The two fields are merged to match with TLS 1.3. // Note that in TLS 1.2, the ECDSA algorithms are not constrained to P-256, etc. var supportedSignatureAlgorithms = []SignatureScheme{ + PSSWithSHA256, + PSSWithSHA384, + PSSWithSHA512, PKCS1WithSHA256, ECDSAWithP256AndSHA256, PKCS1WithSHA384, @@ -150,6 +177,23 @@ var supportedSignatureAlgorithms = []SignatureScheme{ ECDSAWithSHA1, } +// helloRetryRequestRandom is set as the Random value of a ServerHello +// to signal that the message is actually a HelloRetryRequest. +var helloRetryRequestRandom = []byte{ // See RFC 8446, Section 4.1.3. + 0xCF, 0x21, 0xAD, 0x74, 0xE5, 0x9A, 0x61, 0x11, + 0xBE, 0x1D, 0x8C, 0x02, 0x1E, 0x65, 0xB8, 0x91, + 0xC2, 0xA2, 0x11, 0x16, 0x7A, 0xBB, 0x8C, 0x5E, + 0x07, 0x9E, 0x09, 0xE2, 0xC8, 0xA8, 0x33, 0x9C, +} + +const ( + // downgradeCanaryTLS12 or downgradeCanaryTLS11 is embedded in the server + // random as a downgrade protection if the server would be capable of + // negotiating a higher version. See RFC 8446, Section 4.1.3. + downgradeCanaryTLS12 = "DOWNGRD\x01" + downgradeCanaryTLS11 = "DOWNGRD\x00" +) + // ConnectionState records basic TLS details about the connection. type ConnectionState struct { Version uint16 // TLS version used by the connection (e.g. VersionTLS12) @@ -161,8 +205,8 @@ type ConnectionState struct { ServerName string // server name requested by client, if any (server side only) PeerCertificates []*x509.Certificate // certificate chain presented by remote peer VerifiedChains [][]*x509.Certificate // verified chains built from PeerCertificates - SignedCertificateTimestamps [][]byte // SCTs from the server, if any - OCSPResponse []byte // stapled OCSP response from server, if any + SignedCertificateTimestamps [][]byte // SCTs from the peer, if any + OCSPResponse []byte // stapled OCSP response from peer, if any // ekm is a closure exposed via ExportKeyingMaterial. ekm func(label string, context []byte, length int) ([]byte, error) @@ -172,14 +216,14 @@ type ConnectionState struct { // because resumption does not include enough context (see // https://mitls.org/pages/attacks/3SHAKE#channelbindings). This will // change in future versions of Go once the TLS master-secret fix has - // been standardized and implemented. + // been standardized and implemented. It is not defined in TLS 1.3. TLSUnique []byte } // ExportKeyingMaterial returns length bytes of exported key material in a new -// slice as defined in https://tools.ietf.org/html/rfc5705. If context is nil, -// it is not used as part of the seed. If the connection was set to allow -// renegotiation via Config.Renegotiation, this function will return an error. +// slice as defined in RFC 5705. If context is nil, it is not used as part of +// the seed. If the connection was set to allow renegotiation via +// Config.Renegotiation, this function will return an error. func (cs *ConnectionState) ExportKeyingMaterial(label string, context []byte, length int) ([]byte, error) { return cs.ekm(label, context, length) } @@ -196,50 +240,74 @@ const ( RequireAndVerifyClientCert ) +// requiresClientCert reports whether the ClientAuthType requires a client +// certificate to be provided. +func requiresClientCert(c ClientAuthType) bool { + switch c { + case RequireAnyClientCert, RequireAndVerifyClientCert: + return true + default: + return false + } +} + // ClientSessionState contains the state needed by clients to resume TLS // sessions. type ClientSessionState struct { sessionTicket []uint8 // Encrypted ticket used for session resumption with server vers uint16 // SSL/TLS version negotiated for the session cipherSuite uint16 // Ciphersuite negotiated for the session - masterSecret []byte // MasterSecret generated by client on a full handshake + masterSecret []byte // Full handshake MasterSecret, or TLS 1.3 resumption_master_secret serverCertificates []*x509.Certificate // Certificate chain presented by the server verifiedChains [][]*x509.Certificate // Certificate chains we built for verification + receivedAt time.Time // When the session ticket was received from the server + + // TLS 1.3 fields. + nonce []byte // Ticket nonce sent by the server, to derive PSK + useBy time.Time // Expiration of the ticket lifetime as set by the server + ageAdd uint32 // Random obfuscation factor for sending the ticket age } // ClientSessionCache is a cache of ClientSessionState objects that can be used // by a client to resume a TLS session with a given server. ClientSessionCache // implementations should expect to be called concurrently from different -// goroutines. Only ticket-based resumption is supported, not SessionID-based -// resumption. +// goroutines. Up to TLS 1.2, only ticket-based resumption is supported, not +// SessionID-based resumption. In TLS 1.3 they were merged into PSK modes, which +// are supported via this interface. type ClientSessionCache interface { // Get searches for a ClientSessionState associated with the given key. // On return, ok is true if one was found. Get(sessionKey string) (session *ClientSessionState, ok bool) - // Put adds the ClientSessionState to the cache with the given key. + // Put adds the ClientSessionState to the cache with the given key. It might + // get called multiple times in a connection if a TLS 1.3 server provides + // more than one session ticket. If called with a nil *ClientSessionState, + // it should remove the cache entry. Put(sessionKey string, cs *ClientSessionState) } // SignatureScheme identifies a signature algorithm supported by TLS. See -// https://tools.ietf.org/html/draft-ietf-tls-tls13-18#section-4.2.3. +// RFC 8446, Section 4.2.3. type SignatureScheme uint16 const ( - PKCS1WithSHA1 SignatureScheme = 0x0201 + // RSASSA-PKCS1-v1_5 algorithms. PKCS1WithSHA256 SignatureScheme = 0x0401 PKCS1WithSHA384 SignatureScheme = 0x0501 PKCS1WithSHA512 SignatureScheme = 0x0601 + // RSASSA-PSS algorithms with public key OID rsaEncryption. PSSWithSHA256 SignatureScheme = 0x0804 PSSWithSHA384 SignatureScheme = 0x0805 PSSWithSHA512 SignatureScheme = 0x0806 + // ECDSA algorithms. Only constrained to a specific curve in TLS 1.3. ECDSAWithP256AndSHA256 SignatureScheme = 0x0403 ECDSAWithP384AndSHA384 SignatureScheme = 0x0503 ECDSAWithP521AndSHA512 SignatureScheme = 0x0603 // Legacy signature and hash algorithms for TLS 1.2. + PKCS1WithSHA1 SignatureScheme = 0x0201 ECDSAWithSHA1 SignatureScheme = 0x0203 ) @@ -252,32 +320,27 @@ type ClientHelloInfo struct { // ServerName indicates the name of the server requested by the client // in order to support virtual hosting. ServerName is only set if the - // client is using SNI (see - // https://tools.ietf.org/html/rfc4366#section-3.1). + // client is using SNI (see RFC 4366, Section 3.1). ServerName string // SupportedCurves lists the elliptic curves supported by the client. // SupportedCurves is set only if the Supported Elliptic Curves - // Extension is being used (see - // https://tools.ietf.org/html/rfc4492#section-5.1.1). + // Extension is being used (see RFC 4492, Section 5.1.1). SupportedCurves []CurveID // SupportedPoints lists the point formats supported by the client. // SupportedPoints is set only if the Supported Point Formats Extension - // is being used (see - // https://tools.ietf.org/html/rfc4492#section-5.1.2). + // is being used (see RFC 4492, Section 5.1.2). SupportedPoints []uint8 // SignatureSchemes lists the signature and hash schemes that the client // is willing to verify. SignatureSchemes is set only if the Signature - // Algorithms Extension is being used (see - // https://tools.ietf.org/html/rfc5246#section-7.4.1.4.1). + // Algorithms Extension is being used (see RFC 5246, Section 7.4.1.4.1). SignatureSchemes []SignatureScheme // SupportedProtos lists the application protocols supported by the client. // SupportedProtos is set only if the Application-Layer Protocol - // Negotiation Extension is being used (see - // https://tools.ietf.org/html/rfc7301#section-3.1). + // Negotiation Extension is being used (see RFC 7301, Section 3.1). // // Servers can select a protocol by setting Config.NextProtos in a // GetConfigForClient return value. @@ -322,6 +385,8 @@ type CertificateRequestInfo struct { // handshake and application data flow is not permitted so renegotiation can // only be used with protocols that synchronise with the renegotiation, such as // HTTPS. +// +// Renegotiation is not defined in TLS 1.3. type RenegotiationSupport int const ( @@ -429,7 +494,8 @@ type Config struct { // If RootCAs is nil, TLS uses the host's root CA set. RootCAs *x509.CertPool - // NextProtos is a list of supported, application level protocols. + // NextProtos is a list of supported application level protocols, in + // order of preference. NextProtos []string // ServerName is used to verify the hostname on the returned @@ -465,19 +531,19 @@ type Config struct { // the order of elements in CipherSuites, is used. PreferServerCipherSuites bool - // SessionTicketsDisabled may be set to true to disable session ticket - // (resumption) support. Note that on clients, session ticket support is + // SessionTicketsDisabled may be set to true to disable session ticket and + // PSK (resumption) support. Note that on clients, session ticket support is // also disabled if ClientSessionCache is nil. SessionTicketsDisabled bool - // SessionTicketKey is used by TLS servers to provide session - // resumption. See RFC 5077. If zero, it will be filled with - // random data before the first server handshake. + // SessionTicketKey is used by TLS servers to provide session resumption. + // See RFC 5077 and the PSK mode of RFC 8446. If zero, it will be filled + // with random data before the first server handshake. // // If multiple servers are terminating connections for the same host // they should all have the same SessionTicketKey. If the // SessionTicketKey leaks, previously recorded and future TLS - // connections using that key are compromised. + // connections using that key might be compromised. SessionTicketKey [32]byte // ClientSessionCache is a cache of ClientSessionState entries for TLS @@ -490,12 +556,13 @@ type Config struct { // MaxVersion contains the maximum SSL/TLS version that is acceptable. // If zero, then the maximum version supported by this package is used, - // which is currently TLS 1.2. + // which is currently TLS 1.3. MaxVersion uint16 // CurvePreferences contains the elliptic curves that will be used in // an ECDHE handshake, in preference order. If empty, the default will - // be used. + // be used. The client will use the first preference as the type for + // its key share in TLS 1.3. This may change in the future. CurvePreferences []CurveID // DynamicRecordSizingDisabled disables adaptive sizing of TLS records. @@ -551,6 +618,10 @@ func ticketKeyFromBytes(b [32]byte) (key ticketKey) { return key } +// maxSessionTicketLifetime is the maximum allowed lifetime of a TLS 1.3 session +// ticket, and the lifetime we set for tickets we send. +const maxSessionTicketLifetime = 7 * 24 * time.Hour + // Clone returns a shallow clone of c. It is safe to clone a Config that is // being used concurrently by a TLS client or server. func (c *Config) Clone() *Config { @@ -680,18 +751,52 @@ func (c *Config) cipherSuites() []uint16 { return s } -func (c *Config) minVersion() uint16 { - if c == nil || c.MinVersion == 0 { - return minVersion +var supportedVersions = []uint16{ + VersionTLS13, + VersionTLS12, + VersionTLS11, + VersionTLS10, + VersionSSL30, +} + +func (c *Config) supportedVersions(isClient bool) []uint16 { + versions := make([]uint16, 0, len(supportedVersions)) + for _, v := range supportedVersions { + if c != nil && c.MinVersion != 0 && v < c.MinVersion { + continue + } + if c != nil && c.MaxVersion != 0 && v > c.MaxVersion { + continue + } + // TLS 1.0 is the minimum version supported as a client. + if isClient && v < VersionTLS10 { + continue + } + versions = append(versions, v) + } + return versions +} + +func (c *Config) maxSupportedVersion(isClient bool) uint16 { + supportedVersions := c.supportedVersions(isClient) + if len(supportedVersions) == 0 { + return 0 } - return c.MinVersion + return supportedVersions[0] } -func (c *Config) maxVersion() uint16 { - if c == nil || c.MaxVersion == 0 { - return maxVersion +// supportedVersionsFromMax returns a list of supported versions derived from a +// legacy maximum version value. Note that only versions supported by this +// library are returned. Any newer peer will use supportedVersions anyway. +func supportedVersionsFromMax(maxVersion uint16) []uint16 { + versions := make([]uint16, 0, len(supportedVersions)) + for _, v := range supportedVersions { + if v > maxVersion { + continue + } + versions = append(versions, v) } - return c.MaxVersion + return versions } var defaultCurvePreferences = []CurveID{X25519, CurveP256, CurveP384, CurveP521} @@ -704,18 +809,17 @@ func (c *Config) curvePreferences() []CurveID { } // mutualVersion returns the protocol version to use given the advertised -// version of the peer. -func (c *Config) mutualVersion(vers uint16) (uint16, bool) { - minVersion := c.minVersion() - maxVersion := c.maxVersion() - - if vers < minVersion { - return 0, false - } - if vers > maxVersion { - vers = maxVersion +// versions of the peer. Priority is given to the peer preference order. +func (c *Config) mutualVersion(isClient bool, peerVersions []uint16) (uint16, bool) { + supportedVersions := c.supportedVersions(isClient) + for _, peerVersion := range peerVersions { + for _, v := range supportedVersions { + if v == peerVersion { + return v, true + } + } } - return vers, true + return 0, false } // getCertificate returns the best certificate for the given ClientHelloInfo, @@ -769,9 +873,13 @@ func (c *Config) BuildNameToCertificate() { c.NameToCertificate = make(map[string]*Certificate) for i := range c.Certificates { cert := &c.Certificates[i] - x509Cert, err := x509.ParseCertificate(cert.Certificate[0]) - if err != nil { - continue + x509Cert := cert.Leaf + if x509Cert == nil { + var err error + x509Cert, err = x509.ParseCertificate(cert.Certificate[0]) + if err != nil { + continue + } } if len(x509Cert.Subject.CommonName) > 0 { c.NameToCertificate[x509Cert.Subject.CommonName] = cert @@ -782,14 +890,20 @@ func (c *Config) BuildNameToCertificate() { } } -// writeKeyLog logs client random and master secret if logging was enabled by -// setting c.KeyLogWriter. -func (c *Config) writeKeyLog(clientRandom, masterSecret []byte) error { +const ( + keyLogLabelTLS12 = "CLIENT_RANDOM" + keyLogLabelClientHandshake = "CLIENT_HANDSHAKE_TRAFFIC_SECRET" + keyLogLabelServerHandshake = "SERVER_HANDSHAKE_TRAFFIC_SECRET" + keyLogLabelClientTraffic = "CLIENT_TRAFFIC_SECRET_0" + keyLogLabelServerTraffic = "SERVER_TRAFFIC_SECRET_0" +) + +func (c *Config) writeKeyLog(label string, clientRandom, secret []byte) error { if c.KeyLogWriter == nil { return nil } - logLine := []byte(fmt.Sprintf("CLIENT_RANDOM %x %x\n", clientRandom, masterSecret)) + logLine := []byte(fmt.Sprintf("%s %x %x\n", label, clientRandom, secret)) writerMutex.Lock() _, err := c.KeyLogWriter.Write(logLine) @@ -805,11 +919,10 @@ var writerMutex sync.Mutex // A Certificate is a chain of one or more certificates, leaf first. type Certificate struct { Certificate [][]byte - // PrivateKey contains the private key corresponding to the public key - // in Leaf. For a server, this must implement crypto.Signer and/or - // crypto.Decrypter, with an RSA or ECDSA PublicKey. For a client - // (performing client authentication), this must be a crypto.Signer - // with an RSA or ECDSA PublicKey. + // PrivateKey contains the private key corresponding to the public key in + // Leaf. This must implement crypto.Signer with an RSA or ECDSA PublicKey. + // For a server up to TLS 1.2, it can also implement crypto.Decrypter with + // an RSA PublicKey. PrivateKey crypto.PrivateKey // OCSPStaple contains an optional OCSP response which will be served // to clients that request it. @@ -860,15 +973,21 @@ func NewLRUClientSessionCache(capacity int) ClientSessionCache { } } -// Put adds the provided (sessionKey, cs) pair to the cache. +// Put adds the provided (sessionKey, cs) pair to the cache. If cs is nil, the entry +// corresponding to sessionKey is removed from the cache instead. func (c *lruSessionCache) Put(sessionKey string, cs *ClientSessionState) { c.Lock() defer c.Unlock() if elem, ok := c.m[sessionKey]; ok { - entry := elem.Value.(*lruSessionCacheEntry) - entry.state = cs - c.q.MoveToFront(elem) + if cs == nil { + c.q.Remove(elem) + delete(c.m, sessionKey) + } else { + entry := elem.Value.(*lruSessionCacheEntry) + entry.state = cs + c.q.MoveToFront(elem) + } return } @@ -914,8 +1033,9 @@ func defaultConfig() *Config { } var ( - once sync.Once - varDefaultCipherSuites []uint16 + once sync.Once + varDefaultCipherSuites []uint16 + varDefaultCipherSuitesTLS13 []uint16 ) func defaultCipherSuites() []uint16 { @@ -923,19 +1043,24 @@ func defaultCipherSuites() []uint16 { return varDefaultCipherSuites } +func defaultCipherSuitesTLS13() []uint16 { + once.Do(initDefaultCipherSuites) + return varDefaultCipherSuitesTLS13 +} + func initDefaultCipherSuites() { var topCipherSuites []uint16 // Check the cpu flags for each platform that has optimized GCM implementations. - // Worst case, these variables will just all be false - hasGCMAsmAMD64 := cpu.X86.HasAES && cpu.X86.HasPCLMULQDQ - - hasGCMAsmARM64 := cpu.ARM64.HasAES && cpu.ARM64.HasPMULL + // Worst case, these variables will just all be false. + var ( + hasGCMAsmAMD64 = cpu.X86.HasAES && cpu.X86.HasPCLMULQDQ + hasGCMAsmARM64 = cpu.ARM64.HasAES && cpu.ARM64.HasPMULL + // Keep in sync with crypto/aes/cipher_s390x.go. + hasGCMAsmS390X = cpu.S390X.HasAES && cpu.S390X.HasAESCBC && cpu.S390X.HasAESCTR && (cpu.S390X.HasGHASH || cpu.S390X.HasAESGCM) - // Keep in sync with crypto/aes/cipher_s390x.go. - hasGCMAsmS390X := cpu.S390X.HasAES && cpu.S390X.HasAESCBC && cpu.S390X.HasAESCTR && (cpu.S390X.HasGHASH || cpu.S390X.HasAESGCM) - - hasGCMAsm := hasGCMAsmAMD64 || hasGCMAsmARM64 || hasGCMAsmS390X + hasGCMAsm = hasGCMAsmAMD64 || hasGCMAsmARM64 || hasGCMAsmS390X + ) if hasGCMAsm { // If AES-GCM hardware is provided then prioritise AES-GCM @@ -948,6 +1073,11 @@ func initDefaultCipherSuites() { TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, } + varDefaultCipherSuitesTLS13 = []uint16{ + TLS_AES_128_GCM_SHA256, + TLS_CHACHA20_POLY1305_SHA256, + TLS_AES_256_GCM_SHA384, + } } else { // Without AES-GCM hardware, we put the ChaCha20-Poly1305 // cipher suites first. @@ -959,6 +1089,11 @@ func initDefaultCipherSuites() { TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, } + varDefaultCipherSuitesTLS13 = []uint16{ + TLS_CHACHA20_POLY1305_SHA256, + TLS_AES_128_GCM_SHA256, + TLS_AES_256_GCM_SHA384, + } } varDefaultCipherSuites = make([]uint16, 0, len(cipherSuites)) diff --git a/libgo/go/crypto/tls/conn.go b/libgo/go/crypto/tls/conn.go index 6e27e695bd8..f61d43203fd 100644 --- a/libgo/go/crypto/tls/conn.go +++ b/libgo/go/crypto/tls/conn.go @@ -57,6 +57,9 @@ type Conn struct { secureRenegotiation bool // ekm is a closure for exporting keying material. ekm func(label string, context []byte, length int) ([]byte, error) + // resumptionSecret is the resumption_master_secret for handling + // NewSessionTicket messages. nil if config.SessionTicketsDisabled. + resumptionSecret []byte // clientFinishedIsFirst is true if the client sent the first Finished // message during the most recent handshake. This is recorded because @@ -82,9 +85,10 @@ type Conn struct { // input/output in, out halfConn - rawInput *block // raw input, right off the wire - input *block // application data waiting to be read + rawInput bytes.Buffer // raw input, starting with a record header + input bytes.Reader // application data waiting to be read, from rawInput.Next hand bytes.Buffer // handshake data waiting to be read + outBuf []byte // scratch buffer used by out.encrypt buffering bool // whether records are buffered in sendBuf sendBuf []byte // a buffer of records waiting to be sent @@ -93,9 +97,10 @@ type Conn struct { bytesSent int64 packetsSent int64 - // warnCount counts the number of consecutive warning alerts received - // by Conn.readRecord. Protected by in.Mutex. - warnCount int + // retryCount counts the number of consecutive non-advancing records + // received by Conn.readRecord. That is, records that neither advance the + // handshake, nor deliver application data. Protected by in.Mutex. + retryCount int // activeCall is an atomic int32; the low bit is whether Close has // been called. the rest of the bits are the number of goroutines @@ -149,14 +154,12 @@ type halfConn struct { cipher interface{} // cipher algorithm mac macFunction seq [8]byte // 64-bit sequence number - bfree *block // list of free blocks additionalData [13]byte // to avoid allocs; interface method args escape nextCipher interface{} // next encryption state nextMac macFunction // next MAC algorithm - // used to save allocating a new buffer for each MAC. - inDigestBuf, outDigestBuf []byte + trafficSecret []byte // current TLS 1.3 traffic secret } func (hc *halfConn) setErrorLocked(err error) error { @@ -175,7 +178,7 @@ func (hc *halfConn) prepareCipherSpec(version uint16, cipher interface{}, mac ma // changeCipherSpec changes the encryption and MAC states // to the ones previously passed to prepareCipherSpec. func (hc *halfConn) changeCipherSpec() error { - if hc.nextCipher == nil { + if hc.nextCipher == nil || hc.version == VersionTLS13 { return alertInternalError } hc.cipher = hc.nextCipher @@ -188,6 +191,15 @@ func (hc *halfConn) changeCipherSpec() error { return nil } +func (hc *halfConn) setTrafficSecret(suite *cipherSuiteTLS13, secret []byte) { + hc.trafficSecret = secret + key, iv := suite.trafficKey(secret) + hc.cipher = suite.aead(key, iv) + for i := range hc.seq { + hc.seq[i] = 0 + } +} + // incSeq increments the sequence number. func (hc *halfConn) incSeq() { for i := 7; i >= 0; i-- { @@ -203,9 +215,33 @@ func (hc *halfConn) incSeq() { panic("TLS: sequence number wraparound") } +// explicitNonceLen returns the number of bytes of explicit nonce or IV included +// in each record. Explicit nonces are present only in CBC modes after TLS 1.0 +// and in certain AEAD modes in TLS 1.2. +func (hc *halfConn) explicitNonceLen() int { + if hc.cipher == nil { + return 0 + } + + switch c := hc.cipher.(type) { + case cipher.Stream: + return 0 + case aead: + return c.explicitNonceLen() + case cbcMode: + // TLS 1.1 introduced a per-record explicit IV to fix the BEAST attack. + if hc.version >= VersionTLS11 { + return c.BlockSize() + } + return 0 + default: + panic("unknown cipher type") + } +} + // extractPadding returns, in constant time, the length of the padding to remove // from the end of payload. It also returns a byte which is equal to 255 if the -// padding was valid and 0 otherwise. See RFC 2246, section 6.2.3.2 +// padding was valid and 0 otherwise. See RFC 2246, Section 6.2.3.2. func extractPadding(payload []byte) (toRemove int, good byte) { if len(payload) < 1 { return 0, 0 @@ -268,377 +304,335 @@ type cbcMode interface { SetIV([]byte) } -// decrypt checks and strips the mac and decrypts the data in b. Returns a -// success boolean, the number of bytes to skip from the start of the record in -// order to get the application payload, and an optional alert value. -func (hc *halfConn) decrypt(b *block) (ok bool, prefixLen int, alertValue alert) { - // pull out payload - payload := b.data[recordHeaderLen:] +// decrypt authenticates and decrypts the record if protection is active at +// this stage. The returned plaintext might overlap with the input. +func (hc *halfConn) decrypt(record []byte) ([]byte, recordType, error) { + var plaintext []byte + typ := recordType(record[0]) + payload := record[recordHeaderLen:] - macSize := 0 - if hc.mac != nil { - macSize = hc.mac.Size() + // In TLS 1.3, change_cipher_spec messages are to be ignored without being + // decrypted. See RFC 8446, Appendix D.4. + if hc.version == VersionTLS13 && typ == recordTypeChangeCipherSpec { + return payload, typ, nil } paddingGood := byte(255) paddingLen := 0 - explicitIVLen := 0 - // decrypt + explicitNonceLen := hc.explicitNonceLen() + if hc.cipher != nil { switch c := hc.cipher.(type) { case cipher.Stream: c.XORKeyStream(payload, payload) case aead: - explicitIVLen = c.explicitNonceLen() - if len(payload) < explicitIVLen { - return false, 0, alertBadRecordMAC + if len(payload) < explicitNonceLen { + return nil, 0, alertBadRecordMAC } - nonce := payload[:explicitIVLen] - payload = payload[explicitIVLen:] - + nonce := payload[:explicitNonceLen] if len(nonce) == 0 { nonce = hc.seq[:] } + payload = payload[explicitNonceLen:] + + additionalData := hc.additionalData[:] + if hc.version == VersionTLS13 { + additionalData = record[:recordHeaderLen] + } else { + copy(additionalData, hc.seq[:]) + copy(additionalData[8:], record[:3]) + n := len(payload) - c.Overhead() + additionalData[11] = byte(n >> 8) + additionalData[12] = byte(n) + } - copy(hc.additionalData[:], hc.seq[:]) - copy(hc.additionalData[8:], b.data[:3]) - n := len(payload) - c.Overhead() - hc.additionalData[11] = byte(n >> 8) - hc.additionalData[12] = byte(n) var err error - payload, err = c.Open(payload[:0], nonce, payload, hc.additionalData[:]) + plaintext, err = c.Open(payload[:0], nonce, payload, additionalData) if err != nil { - return false, 0, alertBadRecordMAC + return nil, 0, alertBadRecordMAC } - b.resize(recordHeaderLen + explicitIVLen + len(payload)) case cbcMode: blockSize := c.BlockSize() - if hc.version >= VersionTLS11 { - explicitIVLen = blockSize + minPayload := explicitNonceLen + roundUp(hc.mac.Size()+1, blockSize) + if len(payload)%blockSize != 0 || len(payload) < minPayload { + return nil, 0, alertBadRecordMAC } - if len(payload)%blockSize != 0 || len(payload) < roundUp(explicitIVLen+macSize+1, blockSize) { - return false, 0, alertBadRecordMAC - } - - if explicitIVLen > 0 { - c.SetIV(payload[:explicitIVLen]) - payload = payload[explicitIVLen:] + if explicitNonceLen > 0 { + c.SetIV(payload[:explicitNonceLen]) + payload = payload[explicitNonceLen:] } c.CryptBlocks(payload, payload) + + // In a limited attempt to protect against CBC padding oracles like + // Lucky13, the data past paddingLen (which is secret) is passed to + // the MAC function as extra data, to be fed into the HMAC after + // computing the digest. This makes the MAC roughly constant time as + // long as the digest computation is constant time and does not + // affect the subsequent write, modulo cache effects. if hc.version == VersionSSL30 { paddingLen, paddingGood = extractPaddingSSL30(payload) } else { paddingLen, paddingGood = extractPadding(payload) - - // To protect against CBC padding oracles like Lucky13, the data - // past paddingLen (which is secret) is passed to the MAC - // function as extra data, to be fed into the HMAC after - // computing the digest. This makes the MAC constant time as - // long as the digest computation is constant time and does not - // affect the subsequent write. } default: panic("unknown cipher type") } + + if hc.version == VersionTLS13 { + if typ != recordTypeApplicationData { + return nil, 0, alertUnexpectedMessage + } + if len(plaintext) > maxPlaintext+1 { + return nil, 0, alertRecordOverflow + } + // Remove padding and find the ContentType scanning from the end. + for i := len(plaintext) - 1; i >= 0; i-- { + if plaintext[i] != 0 { + typ = recordType(plaintext[i]) + plaintext = plaintext[:i] + break + } + if i == 0 { + return nil, 0, alertUnexpectedMessage + } + } + } + } else { + plaintext = payload } - // check, strip mac if hc.mac != nil { + macSize := hc.mac.Size() if len(payload) < macSize { - return false, 0, alertBadRecordMAC + return nil, 0, alertBadRecordMAC } - // strip mac off payload, b.data n := len(payload) - macSize - paddingLen n = subtle.ConstantTimeSelect(int(uint32(n)>>31), 0, n) // if n < 0 { n = 0 } - b.data[3] = byte(n >> 8) - b.data[4] = byte(n) + record[3] = byte(n >> 8) + record[4] = byte(n) remoteMAC := payload[n : n+macSize] - localMAC := hc.mac.MAC(hc.inDigestBuf, hc.seq[0:], b.data[:recordHeaderLen], payload[:n], payload[n+macSize:]) + localMAC := hc.mac.MAC(hc.seq[0:], record[:recordHeaderLen], payload[:n], payload[n+macSize:]) if subtle.ConstantTimeCompare(localMAC, remoteMAC) != 1 || paddingGood != 255 { - return false, 0, alertBadRecordMAC + return nil, 0, alertBadRecordMAC } - hc.inDigestBuf = localMAC - b.resize(recordHeaderLen + explicitIVLen + n) + plaintext = payload[:n] } - hc.incSeq() - return true, recordHeaderLen + explicitIVLen, 0 + hc.incSeq() + return plaintext, typ, nil } -// padToBlockSize calculates the needed padding block, if any, for a payload. -// On exit, prefix aliases payload and extends to the end of the last full -// block of payload. finalBlock is a fresh slice which contains the contents of -// any suffix of payload as well as the needed padding to make finalBlock a -// full block. -func padToBlockSize(payload []byte, blockSize int) (prefix, finalBlock []byte) { - overrun := len(payload) % blockSize - paddingLen := blockSize - overrun - prefix = payload[:len(payload)-overrun] - finalBlock = make([]byte, blockSize) - copy(finalBlock, payload[len(payload)-overrun:]) - for i := overrun; i < blockSize; i++ { - finalBlock[i] = byte(paddingLen - 1) +// sliceForAppend extends the input slice by n bytes. head is the full extended +// slice, while tail is the appended part. If the original slice has sufficient +// capacity no allocation is performed. +func sliceForAppend(in []byte, n int) (head, tail []byte) { + if total := len(in) + n; cap(in) >= total { + head = in[:total] + } else { + head = make([]byte, total) + copy(head, in) } + tail = head[len(in):] return } -// encrypt encrypts and macs the data in b. -func (hc *halfConn) encrypt(b *block, explicitIVLen int) (bool, alert) { - // mac - if hc.mac != nil { - mac := hc.mac.MAC(hc.outDigestBuf, hc.seq[0:], b.data[:recordHeaderLen], b.data[recordHeaderLen+explicitIVLen:], nil) - - n := len(b.data) - b.resize(n + len(mac)) - copy(b.data[n:], mac) - hc.outDigestBuf = mac - } - - payload := b.data[recordHeaderLen:] - - // encrypt - if hc.cipher != nil { - switch c := hc.cipher.(type) { - case cipher.Stream: - c.XORKeyStream(payload, payload) - case aead: - payloadLen := len(b.data) - recordHeaderLen - explicitIVLen - b.resize(len(b.data) + c.Overhead()) - nonce := b.data[recordHeaderLen : recordHeaderLen+explicitIVLen] - if len(nonce) == 0 { - nonce = hc.seq[:] - } - payload := b.data[recordHeaderLen+explicitIVLen:] - payload = payload[:payloadLen] - - copy(hc.additionalData[:], hc.seq[:]) - copy(hc.additionalData[8:], b.data[:3]) - hc.additionalData[11] = byte(payloadLen >> 8) - hc.additionalData[12] = byte(payloadLen) - - c.Seal(payload[:0], nonce, payload, hc.additionalData[:]) - case cbcMode: - blockSize := c.BlockSize() - if explicitIVLen > 0 { - c.SetIV(payload[:explicitIVLen]) - payload = payload[explicitIVLen:] +// encrypt encrypts payload, adding the appropriate nonce and/or MAC, and +// appends it to record, which contains the record header. +func (hc *halfConn) encrypt(record, payload []byte, rand io.Reader) ([]byte, error) { + if hc.cipher == nil { + return append(record, payload...), nil + } + + var explicitNonce []byte + if explicitNonceLen := hc.explicitNonceLen(); explicitNonceLen > 0 { + record, explicitNonce = sliceForAppend(record, explicitNonceLen) + if _, isCBC := hc.cipher.(cbcMode); !isCBC && explicitNonceLen < 16 { + // The AES-GCM construction in TLS has an explicit nonce so that the + // nonce can be random. However, the nonce is only 8 bytes which is + // too small for a secure, random nonce. Therefore we use the + // sequence number as the nonce. The 3DES-CBC construction also has + // an 8 bytes nonce but its nonces must be unpredictable (see RFC + // 5246, Appendix F.3), forcing us to use randomness. That's not + // 3DES' biggest problem anyway because the birthday bound on block + // collision is reached first due to its simlarly small block size + // (see the Sweet32 attack). + copy(explicitNonce, hc.seq[:]) + } else { + if _, err := io.ReadFull(rand, explicitNonce); err != nil { + return nil, err } - prefix, finalBlock := padToBlockSize(payload, blockSize) - b.resize(recordHeaderLen + explicitIVLen + len(prefix) + len(finalBlock)) - c.CryptBlocks(b.data[recordHeaderLen+explicitIVLen:], prefix) - c.CryptBlocks(b.data[recordHeaderLen+explicitIVLen+len(prefix):], finalBlock) - default: - panic("unknown cipher type") } } - // update length to include MAC and any block padding needed. - n := len(b.data) - recordHeaderLen - b.data[3] = byte(n >> 8) - b.data[4] = byte(n) - hc.incSeq() - - return true, 0 -} + var mac []byte + if hc.mac != nil { + mac = hc.mac.MAC(hc.seq[:], record[:recordHeaderLen], payload, nil) + } + + var dst []byte + switch c := hc.cipher.(type) { + case cipher.Stream: + record, dst = sliceForAppend(record, len(payload)+len(mac)) + c.XORKeyStream(dst[:len(payload)], payload) + c.XORKeyStream(dst[len(payload):], mac) + case aead: + nonce := explicitNonce + if len(nonce) == 0 { + nonce = hc.seq[:] + } -// A block is a simple data buffer. -type block struct { - data []byte - off int // index for Read - link *block -} + if hc.version == VersionTLS13 { + record = append(record, payload...) -// resize resizes block to be n bytes, growing if necessary. -func (b *block) resize(n int) { - if n > cap(b.data) { - b.reserve(n) - } - b.data = b.data[0:n] -} - -// reserve makes sure that block contains a capacity of at least n bytes. -func (b *block) reserve(n int) { - if cap(b.data) >= n { - return - } - m := cap(b.data) - if m == 0 { - m = 1024 - } - for m < n { - m *= 2 - } - data := make([]byte, len(b.data), m) - copy(data, b.data) - b.data = data -} + // Encrypt the actual ContentType and replace the plaintext one. + record = append(record, record[0]) + record[0] = byte(recordTypeApplicationData) -// readFromUntil reads from r into b until b contains at least n bytes -// or else returns an error. -func (b *block) readFromUntil(r io.Reader, n int) error { - // quick case - if len(b.data) >= n { - return nil - } + n := len(payload) + 1 + c.Overhead() + record[3] = byte(n >> 8) + record[4] = byte(n) - // read until have enough. - b.reserve(n) - for { - m, err := r.Read(b.data[len(b.data):cap(b.data)]) - b.data = b.data[0 : len(b.data)+m] - if len(b.data) >= n { - // TODO(bradfitz,agl): slightly suspicious - // that we're throwing away r.Read's err here. - break + record = c.Seal(record[:recordHeaderLen], + nonce, record[recordHeaderLen:], record[:recordHeaderLen]) + } else { + copy(hc.additionalData[:], hc.seq[:]) + copy(hc.additionalData[8:], record) + record = c.Seal(record, nonce, payload, hc.additionalData[:]) } - if err != nil { - return err + case cbcMode: + blockSize := c.BlockSize() + plaintextLen := len(payload) + len(mac) + paddingLen := blockSize - plaintextLen%blockSize + record, dst = sliceForAppend(record, plaintextLen+paddingLen) + copy(dst, payload) + copy(dst[len(payload):], mac) + for i := plaintextLen; i < len(dst); i++ { + dst[i] = byte(paddingLen - 1) } + if len(explicitNonce) > 0 { + c.SetIV(explicitNonce) + } + c.CryptBlocks(dst, dst) + default: + panic("unknown cipher type") } - return nil -} - -func (b *block) Read(p []byte) (n int, err error) { - n = copy(p, b.data[b.off:]) - b.off += n - return -} - -// newBlock allocates a new block, from hc's free list if possible. -func (hc *halfConn) newBlock() *block { - b := hc.bfree - if b == nil { - return new(block) - } - hc.bfree = b.link - b.link = nil - b.resize(0) - return b -} -// freeBlock returns a block to hc's free list. -// The protocol is such that each side only has a block or two on -// its free list at a time, so there's no need to worry about -// trimming the list, etc. -func (hc *halfConn) freeBlock(b *block) { - b.link = hc.bfree - hc.bfree = b -} + // Update length to include nonce, MAC and any block padding needed. + n := len(record) - recordHeaderLen + record[3] = byte(n >> 8) + record[4] = byte(n) + hc.incSeq() -// splitBlock splits a block after the first n bytes, -// returning a block with those n bytes and a -// block with the remainder. the latter may be nil. -func (hc *halfConn) splitBlock(b *block, n int) (*block, *block) { - if len(b.data) <= n { - return b, nil - } - bb := hc.newBlock() - bb.resize(len(b.data) - n) - copy(bb.data, b.data[n:]) - b.data = b.data[0:n] - return b, bb + return record, nil } -// RecordHeaderError results when a TLS record header is invalid. +// RecordHeaderError is returned when a TLS record header is invalid. type RecordHeaderError struct { // Msg contains a human readable string that describes the error. Msg string // RecordHeader contains the five bytes of TLS record header that // triggered the error. RecordHeader [5]byte + // Conn provides the underlying net.Conn in the case that a client + // sent an initial handshake that didn't look like TLS. + // It is nil if there's already been a handshake or a TLS alert has + // been written to the connection. + Conn net.Conn } func (e RecordHeaderError) Error() string { return "tls: " + e.Msg } -func (c *Conn) newRecordHeaderError(msg string) (err RecordHeaderError) { +func (c *Conn) newRecordHeaderError(conn net.Conn, msg string) (err RecordHeaderError) { err.Msg = msg - copy(err.RecordHeader[:], c.rawInput.data) + err.Conn = conn + copy(err.RecordHeader[:], c.rawInput.Bytes()) return err } -// readRecord reads the next TLS record from the connection -// and updates the record layer state. -func (c *Conn) readRecord(want recordType) error { - // Caller must be in sync with connection: - // handshake data if handshake not yet completed, - // else application data. - switch want { - default: - c.sendAlert(alertInternalError) - return c.in.setErrorLocked(errors.New("tls: unknown record type requested")) - case recordTypeHandshake, recordTypeChangeCipherSpec: - if c.handshakeComplete() { - c.sendAlert(alertInternalError) - return c.in.setErrorLocked(errors.New("tls: handshake or ChangeCipherSpec requested while not in handshake")) - } - case recordTypeApplicationData: - if !c.handshakeComplete() { - c.sendAlert(alertInternalError) - return c.in.setErrorLocked(errors.New("tls: application data record requested while in handshake")) - } - } +func (c *Conn) readRecord() error { + return c.readRecordOrCCS(false) +} -Again: - if c.rawInput == nil { - c.rawInput = c.in.newBlock() - } - b := c.rawInput +func (c *Conn) readChangeCipherSpec() error { + return c.readRecordOrCCS(true) +} + +// readRecordOrCCS reads one or more TLS records from the connection and +// updates the record layer state. Some invariants: +// * c.in must be locked +// * c.input must be empty +// During the handshake one and only one of the following will happen: +// - c.hand grows +// - c.in.changeCipherSpec is called +// - an error is returned +// After the handshake one and only one of the following will happen: +// - c.hand grows +// - c.input is set +// - an error is returned +func (c *Conn) readRecordOrCCS(expectChangeCipherSpec bool) error { + if c.in.err != nil { + return c.in.err + } + handshakeComplete := c.handshakeComplete() + + // This function modifies c.rawInput, which owns the c.input memory. + if c.input.Len() != 0 { + return c.in.setErrorLocked(errors.New("tls: internal error: attempted to read record with pending application data")) + } + c.input.Reset(nil) // Read header, payload. - if err := b.readFromUntil(c.conn, recordHeaderLen); err != nil { - // RFC suggests that EOF without an alertCloseNotify is - // an error, but popular web sites seem to do this, - // so we can't make it an error. - // if err == io.EOF { - // err = io.ErrUnexpectedEOF - // } + if err := c.readFromUntil(c.conn, recordHeaderLen); err != nil { + // RFC 8446, Section 6.1 suggests that EOF without an alertCloseNotify + // is an error, but popular web sites seem to do this, so we accept it + // if and only if at the record boundary. + if err == io.ErrUnexpectedEOF && c.rawInput.Len() == 0 { + err = io.EOF + } if e, ok := err.(net.Error); !ok || !e.Temporary() { c.in.setErrorLocked(err) } return err } - typ := recordType(b.data[0]) + hdr := c.rawInput.Bytes()[:recordHeaderLen] + typ := recordType(hdr[0]) // No valid TLS record has a type of 0x80, however SSLv2 handshakes // start with a uint16 length where the MSB is set and the first record // is always < 256 bytes long. Therefore typ == 0x80 strongly suggests // an SSLv2 client. - if want == recordTypeHandshake && typ == 0x80 { + if !handshakeComplete && typ == 0x80 { c.sendAlert(alertProtocolVersion) - return c.in.setErrorLocked(c.newRecordHeaderError("unsupported SSLv2 handshake received")) + return c.in.setErrorLocked(c.newRecordHeaderError(nil, "unsupported SSLv2 handshake received")) } - vers := uint16(b.data[1])<<8 | uint16(b.data[2]) - n := int(b.data[3])<<8 | int(b.data[4]) - if c.haveVers && vers != c.vers { + vers := uint16(hdr[1])<<8 | uint16(hdr[2]) + n := int(hdr[3])<<8 | int(hdr[4]) + if c.haveVers && c.vers != VersionTLS13 && vers != c.vers { c.sendAlert(alertProtocolVersion) msg := fmt.Sprintf("received record with version %x when expecting version %x", vers, c.vers) - return c.in.setErrorLocked(c.newRecordHeaderError(msg)) - } - if n > maxCiphertext { - c.sendAlert(alertRecordOverflow) - msg := fmt.Sprintf("oversized record received with length %d", n) - return c.in.setErrorLocked(c.newRecordHeaderError(msg)) + return c.in.setErrorLocked(c.newRecordHeaderError(nil, msg)) } if !c.haveVers { // First message, be extra suspicious: this might not be a TLS // client. Bail out before reading a full 'body', if possible. // The current max version is 3.3 so if the version is >= 16.0, // it's probably not real. - if (typ != recordTypeAlert && typ != want) || vers >= 0x1000 { - c.sendAlert(alertUnexpectedMessage) - return c.in.setErrorLocked(c.newRecordHeaderError("first record does not look like a TLS handshake")) + if (typ != recordTypeAlert && typ != recordTypeHandshake) || vers >= 0x1000 { + return c.in.setErrorLocked(c.newRecordHeaderError(c.conn, "first record does not look like a TLS handshake")) } } - if err := b.readFromUntil(c.conn, recordHeaderLen+n); err != nil { - if err == io.EOF { - err = io.ErrUnexpectedEOF - } + if c.vers == VersionTLS13 && n > maxCiphertextTLS13 || n > maxCiphertext { + c.sendAlert(alertRecordOverflow) + msg := fmt.Sprintf("oversized record received with length %d", n) + return c.in.setErrorLocked(c.newRecordHeaderError(nil, msg)) + } + if err := c.readFromUntil(c.conn, recordHeaderLen+n); err != nil { if e, ok := err.(net.Error); !ok || !e.Temporary() { c.in.setErrorLocked(err) } @@ -646,91 +640,148 @@ Again: } // Process message. - b, c.rawInput = c.in.splitBlock(b, recordHeaderLen+n) - ok, off, alertValue := c.in.decrypt(b) - if !ok { - c.in.freeBlock(b) - return c.in.setErrorLocked(c.sendAlert(alertValue)) + record := c.rawInput.Next(recordHeaderLen + n) + data, typ, err := c.in.decrypt(record) + if err != nil { + return c.in.setErrorLocked(c.sendAlert(err.(alert))) } - b.off = off - data := b.data[b.off:] if len(data) > maxPlaintext { - err := c.sendAlert(alertRecordOverflow) - c.in.freeBlock(b) - return c.in.setErrorLocked(err) + return c.in.setErrorLocked(c.sendAlert(alertRecordOverflow)) } - if typ != recordTypeAlert && len(data) > 0 { - // this is a valid non-alert message: reset the count of alerts - c.warnCount = 0 + // Application Data messages are always protected. + if c.in.cipher == nil && typ == recordTypeApplicationData { + return c.in.setErrorLocked(c.sendAlert(alertUnexpectedMessage)) + } + + if typ != recordTypeAlert && typ != recordTypeChangeCipherSpec && len(data) > 0 { + // This is a state-advancing message: reset the retry count. + c.retryCount = 0 + } + + // Handshake messages MUST NOT be interleaved with other record types in TLS 1.3. + if c.vers == VersionTLS13 && typ != recordTypeHandshake && c.hand.Len() > 0 { + return c.in.setErrorLocked(c.sendAlert(alertUnexpectedMessage)) } switch typ { default: - c.in.setErrorLocked(c.sendAlert(alertUnexpectedMessage)) + return c.in.setErrorLocked(c.sendAlert(alertUnexpectedMessage)) case recordTypeAlert: if len(data) != 2 { - c.in.setErrorLocked(c.sendAlert(alertUnexpectedMessage)) - break + return c.in.setErrorLocked(c.sendAlert(alertUnexpectedMessage)) } if alert(data[1]) == alertCloseNotify { - c.in.setErrorLocked(io.EOF) - break + return c.in.setErrorLocked(io.EOF) + } + if c.vers == VersionTLS13 { + return c.in.setErrorLocked(&net.OpError{Op: "remote error", Err: alert(data[1])}) } switch data[0] { case alertLevelWarning: - // drop on the floor - c.in.freeBlock(b) - - c.warnCount++ - if c.warnCount > maxWarnAlertCount { - c.sendAlert(alertUnexpectedMessage) - return c.in.setErrorLocked(errors.New("tls: too many warn alerts")) - } - - goto Again + // Drop the record on the floor and retry. + return c.retryReadRecord(expectChangeCipherSpec) case alertLevelError: - c.in.setErrorLocked(&net.OpError{Op: "remote error", Err: alert(data[1])}) + return c.in.setErrorLocked(&net.OpError{Op: "remote error", Err: alert(data[1])}) default: - c.in.setErrorLocked(c.sendAlert(alertUnexpectedMessage)) + return c.in.setErrorLocked(c.sendAlert(alertUnexpectedMessage)) } case recordTypeChangeCipherSpec: - if typ != want || len(data) != 1 || data[0] != 1 { - c.in.setErrorLocked(c.sendAlert(alertUnexpectedMessage)) - break + if len(data) != 1 || data[0] != 1 { + return c.in.setErrorLocked(c.sendAlert(alertDecodeError)) } - // Handshake messages are not allowed to fragment across the CCS + // Handshake messages are not allowed to fragment across the CCS. if c.hand.Len() > 0 { - c.in.setErrorLocked(c.sendAlert(alertUnexpectedMessage)) - break + return c.in.setErrorLocked(c.sendAlert(alertUnexpectedMessage)) } - err := c.in.changeCipherSpec() - if err != nil { - c.in.setErrorLocked(c.sendAlert(err.(alert))) + // In TLS 1.3, change_cipher_spec records are ignored until the + // Finished. See RFC 8446, Appendix D.4. Note that according to Section + // 5, a server can send a ChangeCipherSpec before its ServerHello, when + // c.vers is still unset. That's not useful though and suspicious if the + // server then selects a lower protocol version, so don't allow that. + if c.vers == VersionTLS13 { + return c.retryReadRecord(expectChangeCipherSpec) + } + if !expectChangeCipherSpec { + return c.in.setErrorLocked(c.sendAlert(alertUnexpectedMessage)) + } + if err := c.in.changeCipherSpec(); err != nil { + return c.in.setErrorLocked(c.sendAlert(err.(alert))) } case recordTypeApplicationData: - if typ != want { - c.in.setErrorLocked(c.sendAlert(alertUnexpectedMessage)) - break + if !handshakeComplete || expectChangeCipherSpec { + return c.in.setErrorLocked(c.sendAlert(alertUnexpectedMessage)) + } + // Some OpenSSL servers send empty records in order to randomize the + // CBC IV. Ignore a limited number of empty records. + if len(data) == 0 { + return c.retryReadRecord(expectChangeCipherSpec) } - c.input = b - b = nil + // Note that data is owned by c.rawInput, following the Next call above, + // to avoid copying the plaintext. This is safe because c.rawInput is + // not read from or written to until c.input is drained. + c.input.Reset(data) case recordTypeHandshake: - // TODO(rsc): Should at least pick off connection close. - if typ != want && !(c.isClient && c.config.Renegotiation != RenegotiateNever) { - return c.in.setErrorLocked(c.sendAlert(alertNoRenegotiation)) + if len(data) == 0 || expectChangeCipherSpec { + return c.in.setErrorLocked(c.sendAlert(alertUnexpectedMessage)) } c.hand.Write(data) } - if b != nil { - c.in.freeBlock(b) + return nil +} + +// retryReadRecord recurses into readRecordOrCCS to drop a non-advancing record, like +// a warning alert, empty application_data, or a change_cipher_spec in TLS 1.3. +func (c *Conn) retryReadRecord(expectChangeCipherSpec bool) error { + c.retryCount++ + if c.retryCount > maxUselessRecords { + c.sendAlert(alertUnexpectedMessage) + return c.in.setErrorLocked(errors.New("tls: too many ignored records")) + } + return c.readRecordOrCCS(expectChangeCipherSpec) +} + +// atLeastReader reads from R, stopping with EOF once at least N bytes have been +// read. It is different from an io.LimitedReader in that it doesn't cut short +// the last Read call, and in that it considers an early EOF an error. +type atLeastReader struct { + R io.Reader + N int64 +} + +func (r *atLeastReader) Read(p []byte) (int, error) { + if r.N <= 0 { + return 0, io.EOF + } + n, err := r.R.Read(p) + r.N -= int64(n) // won't underflow unless len(p) >= n > 9223372036854775809 + if r.N > 0 && err == io.EOF { + return n, io.ErrUnexpectedEOF + } + if r.N <= 0 && err == nil { + return n, io.EOF + } + return n, err +} + +// readFromUntil reads from r into c.rawInput until c.rawInput contains +// at least n bytes or else returns an error. +func (c *Conn) readFromUntil(r io.Reader, n int) error { + if c.rawInput.Len() >= n { + return nil } - return c.in.err + needs := n - c.rawInput.Len() + // There might be extra input waiting on the wire. Make a best effort + // attempt to fetch it so that it can be used in (*Conn).Read to + // "predict" closeNotify alerts. + c.rawInput.Grow(needs + bytes.MinRead) + _, err := c.rawInput.ReadFrom(&atLeastReader{r, int64(needs)}) + return err } // sendAlert sends a TLS alert message. @@ -789,7 +840,7 @@ const ( // // In the interests of simplicity and determinism, this code does not attempt // to reset the record size once the connection is idle, however. -func (c *Conn) maxPayloadSizeForWrite(typ recordType, explicitIVLen int) int { +func (c *Conn) maxPayloadSizeForWrite(typ recordType) int { if c.config.DynamicRecordSizingDisabled || typ != recordTypeApplicationData { return maxPlaintext } @@ -799,16 +850,11 @@ func (c *Conn) maxPayloadSizeForWrite(typ recordType, explicitIVLen int) int { } // Subtract TLS overheads to get the maximum payload size. - macSize := 0 - if c.out.mac != nil { - macSize = c.out.mac.Size() - } - - payloadBytes := tcpMSSEstimate - recordHeaderLen - explicitIVLen + payloadBytes := tcpMSSEstimate - recordHeaderLen - c.out.explicitNonceLen() if c.out.cipher != nil { switch ciph := c.out.cipher.(type) { case cipher.Stream: - payloadBytes -= macSize + payloadBytes -= c.out.mac.Size() case cipher.AEAD: payloadBytes -= ciph.Overhead() case cbcMode: @@ -818,11 +864,14 @@ func (c *Conn) maxPayloadSizeForWrite(typ recordType, explicitIVLen int) int { payloadBytes = (payloadBytes & ^(blockSize - 1)) - 1 // The MAC is appended before padding so affects the // payload size directly. - payloadBytes -= macSize + payloadBytes -= c.out.mac.Size() default: panic("unknown cipher type") } } + if c.vers == VersionTLS13 { + payloadBytes-- // encrypted ContentType + } // Allow packet growth in arithmetic progression up to max. pkt := c.packetsSent @@ -864,70 +913,43 @@ func (c *Conn) flush() (int, error) { // writeRecordLocked writes a TLS record with the given type and payload to the // connection and updates the record layer state. func (c *Conn) writeRecordLocked(typ recordType, data []byte) (int, error) { - b := c.out.newBlock() - defer c.out.freeBlock(b) - var n int for len(data) > 0 { - explicitIVLen := 0 - explicitIVIsSeq := false - - var cbc cbcMode - if c.out.version >= VersionTLS11 { - var ok bool - if cbc, ok = c.out.cipher.(cbcMode); ok { - explicitIVLen = cbc.BlockSize() - } - } - if explicitIVLen == 0 { - if c, ok := c.out.cipher.(aead); ok { - explicitIVLen = c.explicitNonceLen() - - // The AES-GCM construction in TLS has an - // explicit nonce so that the nonce can be - // random. However, the nonce is only 8 bytes - // which is too small for a secure, random - // nonce. Therefore we use the sequence number - // as the nonce. - explicitIVIsSeq = explicitIVLen > 0 - } - } m := len(data) - if maxPayload := c.maxPayloadSizeForWrite(typ, explicitIVLen); m > maxPayload { + if maxPayload := c.maxPayloadSizeForWrite(typ); m > maxPayload { m = maxPayload } - b.resize(recordHeaderLen + explicitIVLen + m) - b.data[0] = byte(typ) + + _, c.outBuf = sliceForAppend(c.outBuf[:0], recordHeaderLen) + c.outBuf[0] = byte(typ) vers := c.vers if vers == 0 { // Some TLS servers fail if the record version is // greater than TLS 1.0 for the initial ClientHello. vers = VersionTLS10 + } else if vers == VersionTLS13 { + // TLS 1.3 froze the record layer version to 1.2. + // See RFC 8446, Section 5.1. + vers = VersionTLS12 } - b.data[1] = byte(vers >> 8) - b.data[2] = byte(vers) - b.data[3] = byte(m >> 8) - b.data[4] = byte(m) - if explicitIVLen > 0 { - explicitIV := b.data[recordHeaderLen : recordHeaderLen+explicitIVLen] - if explicitIVIsSeq { - copy(explicitIV, c.out.seq[:]) - } else { - if _, err := io.ReadFull(c.config.rand(), explicitIV); err != nil { - return n, err - } - } + c.outBuf[1] = byte(vers >> 8) + c.outBuf[2] = byte(vers) + c.outBuf[3] = byte(m >> 8) + c.outBuf[4] = byte(m) + + var err error + c.outBuf, err = c.out.encrypt(c.outBuf, data[:m], c.config.rand()) + if err != nil { + return n, err } - copy(b.data[recordHeaderLen+explicitIVLen:], data) - c.out.encrypt(b, explicitIVLen) - if _, err := c.write(b.data); err != nil { + if _, err := c.write(c.outBuf); err != nil { return n, err } n += m data = data[m:] } - if typ == recordTypeChangeCipherSpec { + if typ == recordTypeChangeCipherSpec && c.vers != VersionTLS13 { if err := c.out.changeCipherSpec(); err != nil { return n, c.sendAlertLocked(err.(alert)) } @@ -949,10 +971,7 @@ func (c *Conn) writeRecord(typ recordType, data []byte) (int, error) { // the record layer. func (c *Conn) readHandshake() (interface{}, error) { for c.hand.Len() < 4 { - if err := c.in.err; err != nil { - return nil, err - } - if err := c.readRecord(recordTypeHandshake); err != nil { + if err := c.readRecord(); err != nil { return nil, err } } @@ -964,10 +983,7 @@ func (c *Conn) readHandshake() (interface{}, error) { return nil, c.in.setErrorLocked(fmt.Errorf("tls: handshake message of length %d bytes exceeds maximum of %d bytes", n, maxHandshake)) } for c.hand.Len() < 4+n { - if err := c.in.err; err != nil { - return nil, err - } - if err := c.readRecord(recordTypeHandshake); err != nil { + if err := c.readRecord(); err != nil { return nil, err } } @@ -981,12 +997,24 @@ func (c *Conn) readHandshake() (interface{}, error) { case typeServerHello: m = new(serverHelloMsg) case typeNewSessionTicket: - m = new(newSessionTicketMsg) + if c.vers == VersionTLS13 { + m = new(newSessionTicketMsgTLS13) + } else { + m = new(newSessionTicketMsg) + } case typeCertificate: - m = new(certificateMsg) + if c.vers == VersionTLS13 { + m = new(certificateMsgTLS13) + } else { + m = new(certificateMsg) + } case typeCertificateRequest: - m = &certificateRequestMsg{ - hasSignatureAndHash: c.vers >= VersionTLS12, + if c.vers == VersionTLS13 { + m = new(certificateRequestMsgTLS13) + } else { + m = &certificateRequestMsg{ + hasSignatureAlgorithm: c.vers >= VersionTLS12, + } } case typeCertificateStatus: m = new(certificateStatusMsg) @@ -998,12 +1026,18 @@ func (c *Conn) readHandshake() (interface{}, error) { m = new(clientKeyExchangeMsg) case typeCertificateVerify: m = &certificateVerifyMsg{ - hasSignatureAndHash: c.vers >= VersionTLS12, + hasSignatureAlgorithm: c.vers >= VersionTLS12, } case typeNextProtocol: m = new(nextProtoMsg) case typeFinished: m = new(finishedMsg) + case typeEncryptedExtensions: + m = new(encryptedExtensionsMsg) + case typeEndOfEarlyData: + m = new(endOfEarlyDataMsg) + case typeKeyUpdate: + m = new(keyUpdateMsg) default: return nil, c.in.setErrorLocked(c.sendAlert(alertUnexpectedMessage)) } @@ -1083,15 +1117,19 @@ func (c *Conn) Write(b []byte) (int, error) { // handleRenegotiation processes a HelloRequest handshake message. func (c *Conn) handleRenegotiation() error { + if c.vers == VersionTLS13 { + return errors.New("tls: internal error: unexpected renegotiation") + } + msg, err := c.readHandshake() if err != nil { return err } - _, ok := msg.(*helloRequestMsg) + helloReq, ok := msg.(*helloRequestMsg) if !ok { c.sendAlert(alertUnexpectedMessage) - return alertUnexpectedMessage + return unexpectedMessageError(helloReq, msg) } if !c.isClient { @@ -1122,73 +1160,106 @@ func (c *Conn) handleRenegotiation() error { return c.handshakeErr } +// handlePostHandshakeMessage processes a handshake message arrived after the +// handshake is complete. Up to TLS 1.2, it indicates the start of a renegotiation. +func (c *Conn) handlePostHandshakeMessage() error { + if c.vers != VersionTLS13 { + return c.handleRenegotiation() + } + + msg, err := c.readHandshake() + if err != nil { + return err + } + + c.retryCount++ + if c.retryCount > maxUselessRecords { + c.sendAlert(alertUnexpectedMessage) + return c.in.setErrorLocked(errors.New("tls: too many non-advancing records")) + } + + switch msg := msg.(type) { + case *newSessionTicketMsgTLS13: + return c.handleNewSessionTicket(msg) + case *keyUpdateMsg: + return c.handleKeyUpdate(msg) + default: + c.sendAlert(alertUnexpectedMessage) + return fmt.Errorf("tls: received unexpected handshake message of type %T", msg) + } +} + +func (c *Conn) handleKeyUpdate(keyUpdate *keyUpdateMsg) error { + cipherSuite := cipherSuiteTLS13ByID(c.cipherSuite) + if cipherSuite == nil { + return c.in.setErrorLocked(c.sendAlert(alertInternalError)) + } + + newSecret := cipherSuite.nextTrafficSecret(c.in.trafficSecret) + c.in.setTrafficSecret(cipherSuite, newSecret) + + if keyUpdate.updateRequested { + c.out.Lock() + defer c.out.Unlock() + + msg := &keyUpdateMsg{} + _, err := c.writeRecordLocked(recordTypeHandshake, msg.marshal()) + if err != nil { + // Surface the error at the next write. + c.out.setErrorLocked(err) + return nil + } + + newSecret := cipherSuite.nextTrafficSecret(c.out.trafficSecret) + c.out.setTrafficSecret(cipherSuite, newSecret) + } + + return nil +} + // Read can be made to time out and return a net.Error with Timeout() == true // after a fixed time limit; see SetDeadline and SetReadDeadline. -func (c *Conn) Read(b []byte) (n int, err error) { - if err = c.Handshake(); err != nil { - return +func (c *Conn) Read(b []byte) (int, error) { + if err := c.Handshake(); err != nil { + return 0, err } if len(b) == 0 { // Put this after Handshake, in case people were calling // Read(nil) for the side effect of the Handshake. - return + return 0, nil } c.in.Lock() defer c.in.Unlock() - // Some OpenSSL servers send empty records in order to randomize the - // CBC IV. So this loop ignores a limited number of empty records. - const maxConsecutiveEmptyRecords = 100 - for emptyRecordCount := 0; emptyRecordCount <= maxConsecutiveEmptyRecords; emptyRecordCount++ { - for c.input == nil && c.in.err == nil { - if err := c.readRecord(recordTypeApplicationData); err != nil { - // Soft error, like EAGAIN - return 0, err - } - if c.hand.Len() > 0 { - // We received handshake bytes, indicating the - // start of a renegotiation. - if err := c.handleRenegotiation(); err != nil { - return 0, err - } - } - } - if err := c.in.err; err != nil { + for c.input.Len() == 0 { + if err := c.readRecord(); err != nil { return 0, err } - - n, err = c.input.Read(b) - if c.input.off >= len(c.input.data) { - c.in.freeBlock(c.input) - c.input = nil - } - - // If a close-notify alert is waiting, read it so that - // we can return (n, EOF) instead of (n, nil), to signal - // to the HTTP response reading goroutine that the - // connection is now closed. This eliminates a race - // where the HTTP response reading goroutine would - // otherwise not observe the EOF until its next read, - // by which time a client goroutine might have already - // tried to reuse the HTTP connection for a new - // request. - // See https://codereview.appspot.com/76400046 - // and https://golang.org/issue/3514 - if ri := c.rawInput; ri != nil && - n != 0 && err == nil && - c.input == nil && len(ri.data) > 0 && recordType(ri.data[0]) == recordTypeAlert { - if recErr := c.readRecord(recordTypeApplicationData); recErr != nil { - err = recErr // will be io.EOF on closeNotify + for c.hand.Len() > 0 { + if err := c.handlePostHandshakeMessage(); err != nil { + return 0, err } } + } - if n != 0 || err != nil { - return n, err + n, _ := c.input.Read(b) + + // If a close-notify alert is waiting, read it so that we can return (n, + // EOF) instead of (n, nil), to signal to the HTTP response reading + // goroutine that the connection is now closed. This eliminates a race + // where the HTTP response reading goroutine would otherwise not observe + // the EOF until its next read, by which time a client goroutine might + // have already tried to reuse the HTTP connection for a new request. + // See https://golang.org/cl/76400046 and https://golang.org/issue/3514 + if n != 0 && c.input.Len() == 0 && c.rawInput.Len() > 0 && + recordType(c.rawInput.Bytes()[0]) == recordTypeAlert { + if err := c.readRecord(); err != nil { + return n, err // will be io.EOF on closeNotify } } - return 0, io.ErrNoProgress + return n, nil } // Close closes the connection. @@ -1282,7 +1353,7 @@ func (c *Conn) Handshake() error { } if c.handshakeErr == nil && !c.handshakeComplete() { - panic("handshake should have had a result.") + c.handshakeErr = errors.New("tls: internal error: handshake should have had a result") } return c.handshakeErr @@ -1307,7 +1378,7 @@ func (c *Conn) ConnectionState() ConnectionState { state.VerifiedChains = c.verifiedChains state.SignedCertificateTimestamps = c.scts state.OCSPResponse = c.ocspResponse - if !c.didResume { + if !c.didResume && c.vers != VersionTLS13 { if c.clientFinishedIsFirst { state.TLSUnique = c.clientFinished[:] } else { diff --git a/libgo/go/crypto/tls/conn_test.go b/libgo/go/crypto/tls/conn_test.go index 5c7f7ce2bb7..76cef7174b9 100644 --- a/libgo/go/crypto/tls/conn_test.go +++ b/libgo/go/crypto/tls/conn_test.go @@ -134,12 +134,13 @@ func TestCertificateSelection(t *testing.T) { // Run with multiple crypto configs to test the logic for computing TLS record overheads. func runDynamicRecordSizingTest(t *testing.T, config *Config) { - clientConn, serverConn := net.Pipe() + clientConn, serverConn := localPipe(t) serverConfig := config.Clone() serverConfig.DynamicRecordSizingDisabled = false tlsConn := Server(serverConn, serverConfig) + handshakeDone := make(chan struct{}) recordSizesChan := make(chan []int, 1) go func() { // This goroutine performs a TLS handshake over clientConn and @@ -153,6 +154,7 @@ func runDynamicRecordSizingTest(t *testing.T, config *Config) { t.Errorf("Error from client handshake: %v", err) return } + close(handshakeDone) var recordHeader [recordHeaderLen]byte var record []byte @@ -179,11 +181,7 @@ func runDynamicRecordSizingTest(t *testing.T, config *Config) { return } - // The last record will be a close_notify alert, which - // we don't wish to record. - if recordType(recordHeader[0]) == recordTypeApplicationData { - recordSizes = append(recordSizes, recordHeaderLen+length) - } + recordSizes = append(recordSizes, recordHeaderLen+length) } recordSizesChan <- recordSizes @@ -192,6 +190,7 @@ func runDynamicRecordSizingTest(t *testing.T, config *Config) { if err := tlsConn.Handshake(); err != nil { t.Fatalf("Error from server handshake: %s", err) } + <-handshakeDone // The server writes these plaintexts in order. plaintext := bytes.Join([][]byte{ @@ -212,8 +211,9 @@ func runDynamicRecordSizingTest(t *testing.T, config *Config) { t.Fatalf("Client encountered an error") } - // Drop the size of last record, which is likely to be truncated. - recordSizes = recordSizes[:len(recordSizes)-1] + // Drop the size of the second to last record, which is likely to be + // truncated, and the last record, which is a close_notify alert. + recordSizes = recordSizes[:len(recordSizes)-2] // recordSizes should contain a series of records smaller than // tcpMSSEstimate followed by some larger than maxPlaintext. @@ -238,22 +238,30 @@ func runDynamicRecordSizingTest(t *testing.T, config *Config) { func TestDynamicRecordSizingWithStreamCipher(t *testing.T) { config := testConfig.Clone() + config.MaxVersion = VersionTLS12 config.CipherSuites = []uint16{TLS_RSA_WITH_RC4_128_SHA} runDynamicRecordSizingTest(t, config) } func TestDynamicRecordSizingWithCBC(t *testing.T) { config := testConfig.Clone() + config.MaxVersion = VersionTLS12 config.CipherSuites = []uint16{TLS_RSA_WITH_AES_256_CBC_SHA} runDynamicRecordSizingTest(t, config) } func TestDynamicRecordSizingWithAEAD(t *testing.T) { config := testConfig.Clone() + config.MaxVersion = VersionTLS12 config.CipherSuites = []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256} runDynamicRecordSizingTest(t, config) } +func TestDynamicRecordSizingWithTLSv13(t *testing.T) { + config := testConfig.Clone() + runDynamicRecordSizingTest(t, config) +} + // hairpinConn is a net.Conn that makes a “hairpin” call when closed, back into // the tls.Conn which is calling it. type hairpinConn struct { @@ -269,7 +277,7 @@ func (conn *hairpinConn) Close() error { func TestHairpinInClose(t *testing.T) { // This tests that the underlying net.Conn can call back into the // tls.Conn when being closed without deadlocking. - client, server := net.Pipe() + client, server := localPipe(t) defer server.Close() defer client.Close() diff --git a/libgo/go/crypto/tls/handshake_client.go b/libgo/go/crypto/tls/handshake_client.go index 32fdc6d6eb1..ca74989f6ed 100644 --- a/libgo/go/crypto/tls/handshake_client.go +++ b/libgo/go/crypto/tls/handshake_client.go @@ -18,6 +18,7 @@ import ( "strconv" "strings" "sync/atomic" + "time" ) type clientHandshakeState struct { @@ -30,28 +31,42 @@ type clientHandshakeState struct { session *ClientSessionState } -func makeClientHello(config *Config) (*clientHelloMsg, error) { +func (c *Conn) makeClientHello() (*clientHelloMsg, ecdheParameters, error) { + config := c.config if len(config.ServerName) == 0 && !config.InsecureSkipVerify { - return nil, errors.New("tls: either ServerName or InsecureSkipVerify must be specified in the tls.Config") + return nil, nil, errors.New("tls: either ServerName or InsecureSkipVerify must be specified in the tls.Config") } nextProtosLength := 0 for _, proto := range config.NextProtos { if l := len(proto); l == 0 || l > 255 { - return nil, errors.New("tls: invalid NextProtos value") + return nil, nil, errors.New("tls: invalid NextProtos value") } else { nextProtosLength += 1 + l } } - if nextProtosLength > 0xffff { - return nil, errors.New("tls: NextProtos values too large") + return nil, nil, errors.New("tls: NextProtos values too large") + } + + supportedVersions := config.supportedVersions(true) + if len(supportedVersions) == 0 { + return nil, nil, errors.New("tls: no supported versions satisfy MinVersion and MaxVersion") + } + + clientHelloVersion := supportedVersions[0] + // The version at the beginning of the ClientHello was capped at TLS 1.2 + // for compatibility reasons. The supported_versions extension is used + // to negotiate versions now. See RFC 8446, Section 4.2.1. + if clientHelloVersion > VersionTLS12 { + clientHelloVersion = VersionTLS12 } hello := &clientHelloMsg{ - vers: config.maxVersion(), + vers: clientHelloVersion, compressionMethods: []uint8{compressionNone}, random: make([]byte, 32), + sessionId: make([]byte, 32), ocspStapling: true, scts: true, serverName: hostnameInSNI(config.ServerName), @@ -60,7 +75,13 @@ func makeClientHello(config *Config) (*clientHelloMsg, error) { nextProtoNeg: len(config.NextProtos) > 0, secureRenegotiationSupported: true, alpnProtocols: config.NextProtos, + supportedVersions: supportedVersions, } + + if c.handshakes > 0 { + hello.secureRenegotiation = c.clientFinished[:] + } + possibleCipherSuites := config.cipherSuites() hello.cipherSuites = make([]uint16, 0, len(possibleCipherSuites)) @@ -82,17 +103,39 @@ NextCipherSuite: _, err := io.ReadFull(config.rand(), hello.random) if err != nil { - return nil, errors.New("tls: short read from Rand: " + err.Error()) + return nil, nil, errors.New("tls: short read from Rand: " + err.Error()) + } + + // A random session ID is used to detect when the server accepted a ticket + // and is resuming a session (see RFC 5077). In TLS 1.3, it's always set as + // a compatibility measure (see RFC 8446, Section 4.1.2). + if _, err := io.ReadFull(config.rand(), hello.sessionId); err != nil { + return nil, nil, errors.New("tls: short read from Rand: " + err.Error()) } if hello.vers >= VersionTLS12 { hello.supportedSignatureAlgorithms = supportedSignatureAlgorithms } - return hello, nil + var params ecdheParameters + if hello.supportedVersions[0] == VersionTLS13 { + hello.cipherSuites = append(hello.cipherSuites, defaultCipherSuitesTLS13()...) + + curveID := config.curvePreferences()[0] + if _, ok := curveForCurveID(curveID); curveID != X25519 && !ok { + return nil, nil, errors.New("tls: CurvePreferences includes unsupported curve") + } + params, err = generateECDHEParameters(config.rand(), curveID) + if err != nil { + return nil, nil, err + } + hello.keyShares = []keyShare{{group: curveID, data: params.PublicKey()}} + } + + return hello, params, nil } -func (c *Conn) clientHandshake() error { +func (c *Conn) clientHandshake() (err error) { if c.config == nil { c.config = defaultConfig() } @@ -101,112 +144,221 @@ func (c *Conn) clientHandshake() error { // need to be reset. c.didResume = false - hello, err := makeClientHello(c.config) + hello, ecdheParams, err := c.makeClientHello() if err != nil { return err } - if c.handshakes > 0 { - hello.secureRenegotiation = c.clientFinished[:] + cacheKey, session, earlySecret, binderKey := c.loadSession(hello) + if cacheKey != "" && session != nil { + defer func() { + // If we got a handshake failure when resuming a session, throw away + // the session ticket. See RFC 5077, Section 3.2. + // + // RFC 8446 makes no mention of dropping tickets on failure, but it + // does require servers to abort on invalid binders, so we need to + // delete tickets to recover from a corrupted PSK. + if err != nil { + c.config.ClientSessionCache.Put(cacheKey, nil) + } + }() } - var session *ClientSessionState - var cacheKey string - sessionCache := c.config.ClientSessionCache - if c.config.SessionTicketsDisabled { - sessionCache = nil + if _, err := c.writeRecord(recordTypeHandshake, hello.marshal()); err != nil { + return err } - if sessionCache != nil { - hello.ticketSupported = true + msg, err := c.readHandshake() + if err != nil { + return err } - // Session resumption is not allowed if renegotiating because - // renegotiation is primarily used to allow a client to send a client - // certificate, which would be skipped if session resumption occurred. - if sessionCache != nil && c.handshakes == 0 { - // Try to resume a previously negotiated TLS session, if - // available. - cacheKey = clientSessionCacheKey(c.conn.RemoteAddr(), c.config) - candidateSession, ok := sessionCache.Get(cacheKey) - if ok { - // Check that the ciphersuite/version used for the - // previous session are still valid. - cipherSuiteOk := false - for _, id := range hello.cipherSuites { - if id == candidateSession.cipherSuite { - cipherSuiteOk = true - break - } - } + serverHello, ok := msg.(*serverHelloMsg) + if !ok { + c.sendAlert(alertUnexpectedMessage) + return unexpectedMessageError(serverHello, msg) + } - versOk := candidateSession.vers >= c.config.minVersion() && - candidateSession.vers <= c.config.maxVersion() - if versOk && cipherSuiteOk { - session = candidateSession - } - } + if err := c.pickTLSVersion(serverHello); err != nil { + return err } - if session != nil { - hello.sessionTicket = session.sessionTicket - // A random session ID is used to detect when the - // server accepted the ticket and is resuming a session - // (see RFC 5077). - hello.sessionId = make([]byte, 16) - if _, err := io.ReadFull(c.config.rand(), hello.sessionId); err != nil { - return errors.New("tls: short read from Rand: " + err.Error()) + if c.vers == VersionTLS13 { + hs := &clientHandshakeStateTLS13{ + c: c, + serverHello: serverHello, + hello: hello, + ecdheParams: ecdheParams, + session: session, + earlySecret: earlySecret, + binderKey: binderKey, } + + // In TLS 1.3, session tickets are delivered after the handshake. + return hs.handshake() } hs := &clientHandshakeState{ - c: c, - hello: hello, - session: session, + c: c, + serverHello: serverHello, + hello: hello, + session: session, } - if err = hs.handshake(); err != nil { + if err := hs.handshake(); err != nil { return err } // If we had a successful handshake and hs.session is different from - // the one already cached - cache a new one - if sessionCache != nil && hs.session != nil && session != hs.session { - sessionCache.Put(cacheKey, hs.session) + // the one already cached - cache a new one. + if cacheKey != "" && hs.session != nil && session != hs.session { + c.config.ClientSessionCache.Put(cacheKey, hs.session) } return nil } -// Does the handshake, either a full one or resumes old session. -// Requires hs.c, hs.hello, and, optionally, hs.session to be set. -func (hs *clientHandshakeState) handshake() error { - c := hs.c +func (c *Conn) loadSession(hello *clientHelloMsg) (cacheKey string, + session *ClientSessionState, earlySecret, binderKey []byte) { + if c.config.SessionTicketsDisabled || c.config.ClientSessionCache == nil { + return "", nil, nil, nil + } - // send ClientHello - if _, err := c.writeRecord(recordTypeHandshake, hs.hello.marshal()); err != nil { - return err + hello.ticketSupported = true + + if hello.supportedVersions[0] == VersionTLS13 { + // Require DHE on resumption as it guarantees forward secrecy against + // compromise of the session ticket key. See RFC 8446, Section 4.2.9. + hello.pskModes = []uint8{pskModeDHE} } - msg, err := c.readHandshake() - if err != nil { - return err + // Session resumption is not allowed if renegotiating because + // renegotiation is primarily used to allow a client to send a client + // certificate, which would be skipped if session resumption occurred. + if c.handshakes != 0 { + return "", nil, nil, nil } - var ok bool - if hs.serverHello, ok = msg.(*serverHelloMsg); !ok { - c.sendAlert(alertUnexpectedMessage) - return unexpectedMessageError(hs.serverHello, msg) + // Try to resume a previously negotiated TLS session, if available. + cacheKey = clientSessionCacheKey(c.conn.RemoteAddr(), c.config) + session, ok := c.config.ClientSessionCache.Get(cacheKey) + if !ok || session == nil { + return cacheKey, nil, nil, nil } - if err = hs.pickTLSVersion(); err != nil { - return err + // Check that version used for the previous session is still valid. + versOk := false + for _, v := range hello.supportedVersions { + if v == session.vers { + versOk = true + break + } + } + if !versOk { + return cacheKey, nil, nil, nil } - if err = hs.pickCipherSuite(); err != nil { - return err + // Check that the cached server certificate is not expired, and that it's + // valid for the ServerName. This should be ensured by the cache key, but + // protect the application from a faulty ClientSessionCache implementation. + if !c.config.InsecureSkipVerify { + if len(session.verifiedChains) == 0 { + // The original connection had InsecureSkipVerify, while this doesn't. + return cacheKey, nil, nil, nil + } + serverCert := session.serverCertificates[0] + if c.config.time().After(serverCert.NotAfter) { + // Expired certificate, delete the entry. + c.config.ClientSessionCache.Put(cacheKey, nil) + return cacheKey, nil, nil, nil + } + if err := serverCert.VerifyHostname(c.config.ServerName); err != nil { + return cacheKey, nil, nil, nil + } } + if session.vers != VersionTLS13 { + // In TLS 1.2 the cipher suite must match the resumed session. Ensure we + // are still offering it. + if mutualCipherSuite(hello.cipherSuites, session.cipherSuite) == nil { + return cacheKey, nil, nil, nil + } + + hello.sessionTicket = session.sessionTicket + return + } + + // Check that the session ticket is not expired. + if c.config.time().After(session.useBy) { + c.config.ClientSessionCache.Put(cacheKey, nil) + return cacheKey, nil, nil, nil + } + + // In TLS 1.3 the KDF hash must match the resumed session. Ensure we + // offer at least one cipher suite with that hash. + cipherSuite := cipherSuiteTLS13ByID(session.cipherSuite) + if cipherSuite == nil { + return cacheKey, nil, nil, nil + } + cipherSuiteOk := false + for _, offeredID := range hello.cipherSuites { + offeredSuite := cipherSuiteTLS13ByID(offeredID) + if offeredSuite != nil && offeredSuite.hash == cipherSuite.hash { + cipherSuiteOk = true + break + } + } + if !cipherSuiteOk { + return cacheKey, nil, nil, nil + } + + // Set the pre_shared_key extension. See RFC 8446, Section 4.2.11.1. + ticketAge := uint32(c.config.time().Sub(session.receivedAt) / time.Millisecond) + identity := pskIdentity{ + label: session.sessionTicket, + obfuscatedTicketAge: ticketAge + session.ageAdd, + } + hello.pskIdentities = []pskIdentity{identity} + hello.pskBinders = [][]byte{make([]byte, cipherSuite.hash.Size())} + + // Compute the PSK binders. See RFC 8446, Section 4.2.11.2. + psk := cipherSuite.expandLabel(session.masterSecret, "resumption", + session.nonce, cipherSuite.hash.Size()) + earlySecret = cipherSuite.extract(psk, nil) + binderKey = cipherSuite.deriveSecret(earlySecret, resumptionBinderLabel, nil) + transcript := cipherSuite.hash.New() + transcript.Write(hello.marshalWithoutBinders()) + pskBinders := [][]byte{cipherSuite.finishedHash(binderKey, transcript)} + hello.updateBinders(pskBinders) + + return +} + +func (c *Conn) pickTLSVersion(serverHello *serverHelloMsg) error { + peerVersion := serverHello.vers + if serverHello.supportedVersion != 0 { + peerVersion = serverHello.supportedVersion + } + + vers, ok := c.config.mutualVersion(true, []uint16{peerVersion}) + if !ok { + c.sendAlert(alertProtocolVersion) + return fmt.Errorf("tls: server selected unsupported protocol version %x", peerVersion) + } + + c.vers = vers + c.haveVers = true + c.in.version = vers + c.out.version = vers + + return nil +} + +// Does the handshake, either a full one or resumes old session. Requires hs.c, +// hs.hello, hs.serverHello, and, optionally, hs.session to be set. +func (hs *clientHandshakeState) handshake() error { + c := hs.c + isResume, err := hs.processServerHello() if err != nil { return err @@ -272,20 +424,6 @@ func (hs *clientHandshakeState) handshake() error { return nil } -func (hs *clientHandshakeState) pickTLSVersion() error { - vers, ok := hs.c.config.mutualVersion(hs.serverHello.vers) - if !ok || vers < VersionTLS10 { - // TLS 1.0 is the minimum version supported as a client. - hs.c.sendAlert(alertProtocolVersion) - return fmt.Errorf("tls: server selected unsupported protocol version %x", hs.serverHello.vers) - } - - hs.c.vers = vers - hs.c.haveVers = true - - return nil -} - func (hs *clientHandshakeState) pickCipherSuite() error { if hs.suite = mutualCipherSuite(hs.hello.cipherSuites, hs.serverHello.cipherSuite); hs.suite == nil { hs.c.sendAlert(alertHandshakeFailure) @@ -313,53 +451,9 @@ func (hs *clientHandshakeState) doFullHandshake() error { if c.handshakes == 0 { // If this is the first handshake on a connection, process and // (optionally) verify the server's certificates. - certs := make([]*x509.Certificate, len(certMsg.certificates)) - for i, asn1Data := range certMsg.certificates { - cert, err := x509.ParseCertificate(asn1Data) - if err != nil { - c.sendAlert(alertBadCertificate) - return errors.New("tls: failed to parse certificate from server: " + err.Error()) - } - certs[i] = cert - } - - if !c.config.InsecureSkipVerify { - opts := x509.VerifyOptions{ - Roots: c.config.RootCAs, - CurrentTime: c.config.time(), - DNSName: c.config.ServerName, - Intermediates: x509.NewCertPool(), - } - - for i, cert := range certs { - if i == 0 { - continue - } - opts.Intermediates.AddCert(cert) - } - c.verifiedChains, err = certs[0].Verify(opts) - if err != nil { - c.sendAlert(alertBadCertificate) - return err - } - } - - if c.config.VerifyPeerCertificate != nil { - if err := c.config.VerifyPeerCertificate(certMsg.certificates, c.verifiedChains); err != nil { - c.sendAlert(alertBadCertificate) - return err - } - } - - switch certs[0].PublicKey.(type) { - case *rsa.PublicKey, *ecdsa.PublicKey: - break - default: - c.sendAlert(alertUnsupportedCertificate) - return fmt.Errorf("tls: server's certificate contains an unsupported type of public key: %T", certs[0].PublicKey) + if err := c.verifyServerCertificate(certMsg.certificates); err != nil { + return err } - - c.peerCertificates = certs } else { // This is a renegotiation handshake. We require that the // server's identity (i.e. leaf certificate) is unchanged and @@ -393,9 +487,7 @@ func (hs *clientHandshakeState) doFullHandshake() error { } hs.finishedHash.Write(cs.marshal()) - if cs.statusType == statusTypeOCSP { - c.ocspResponse = cs.response - } + c.ocspResponse = cs.response msg, err = c.readHandshake() if err != nil { @@ -427,7 +519,8 @@ func (hs *clientHandshakeState) doFullHandshake() error { certRequested = true hs.finishedHash.Write(certReq.marshal()) - if chainToSend, err = hs.getCertificate(certReq); err != nil { + cri := certificateRequestInfoFromMsg(certReq) + if chainToSend, err = c.getClientCertificate(cri); err != nil { c.sendAlert(alertInternalError) return err } @@ -471,7 +564,7 @@ func (hs *clientHandshakeState) doFullHandshake() error { if chainToSend != nil && len(chainToSend.Certificate) > 0 { certVerify := &certificateVerifyMsg{ - hasSignatureAndHash: c.vers >= VersionTLS12, + hasSignatureAlgorithm: c.vers >= VersionTLS12, } key, ok := chainToSend.PrivateKey.(crypto.Signer) @@ -486,7 +579,7 @@ func (hs *clientHandshakeState) doFullHandshake() error { return err } // SignatureAndHashAlgorithm was introduced in TLS 1.2. - if certVerify.hasSignatureAndHash { + if certVerify.hasSignatureAlgorithm { certVerify.signatureAlgorithm = signatureAlgorithm } digest, err := hs.finishedHash.hashForClientCertificate(sigType, hashFunc, hs.masterSecret) @@ -511,7 +604,7 @@ func (hs *clientHandshakeState) doFullHandshake() error { } hs.masterSecret = masterFromPreMasterSecret(c.vers, hs.suite, preMasterSecret, hs.hello.random, hs.serverHello.random) - if err := c.config.writeKeyLog(hs.hello.random, hs.masterSecret); err != nil { + if err := c.config.writeKeyLog(keyLogLabelTLS12, hs.hello.random, hs.masterSecret); err != nil { c.sendAlert(alertInternalError) return errors.New("tls: failed to write to key log: " + err.Error()) } @@ -553,6 +646,10 @@ func (hs *clientHandshakeState) serverResumedSession() bool { func (hs *clientHandshakeState) processServerHello() (bool, error) { c := hs.c + if err := hs.pickCipherSuite(); err != nil { + return false, err + } + if hs.serverHello.compressionMethod != compressionNone { c.sendAlert(alertUnexpectedMessage) return false, errors.New("tls: server selected unsupported compression format") @@ -626,9 +723,8 @@ func (hs *clientHandshakeState) processServerHello() (bool, error) { func (hs *clientHandshakeState) readFinished(out []byte) error { c := hs.c - c.readRecord(recordTypeChangeCipherSpec) - if c.in.err != nil { - return c.in.err + if err := c.readChangeCipherSpec(); err != nil { + return err } msg, err := c.readHandshake() @@ -676,6 +772,7 @@ func (hs *clientHandshakeState) readSessionTicket() error { masterSecret: hs.masterSecret, serverCertificates: c.peerCertificates, verifiedChains: c.verifiedChains, + receivedAt: c.config.time(), } return nil @@ -710,22 +807,72 @@ func (hs *clientHandshakeState) sendFinished(out []byte) error { return nil } +// verifyServerCertificate parses and verifies the provided chain, setting +// c.verifiedChains and c.peerCertificates or sending the appropriate alert. +func (c *Conn) verifyServerCertificate(certificates [][]byte) error { + certs := make([]*x509.Certificate, len(certificates)) + for i, asn1Data := range certificates { + cert, err := x509.ParseCertificate(asn1Data) + if err != nil { + c.sendAlert(alertBadCertificate) + return errors.New("tls: failed to parse certificate from server: " + err.Error()) + } + certs[i] = cert + } + + if !c.config.InsecureSkipVerify { + opts := x509.VerifyOptions{ + Roots: c.config.RootCAs, + CurrentTime: c.config.time(), + DNSName: c.config.ServerName, + Intermediates: x509.NewCertPool(), + } + + for i, cert := range certs { + if i == 0 { + continue + } + opts.Intermediates.AddCert(cert) + } + var err error + c.verifiedChains, err = certs[0].Verify(opts) + if err != nil { + c.sendAlert(alertBadCertificate) + return err + } + } + + if c.config.VerifyPeerCertificate != nil { + if err := c.config.VerifyPeerCertificate(certificates, c.verifiedChains); err != nil { + c.sendAlert(alertBadCertificate) + return err + } + } + + switch certs[0].PublicKey.(type) { + case *rsa.PublicKey, *ecdsa.PublicKey: + break + default: + c.sendAlert(alertUnsupportedCertificate) + return fmt.Errorf("tls: server's certificate contains an unsupported type of public key: %T", certs[0].PublicKey) + } + + c.peerCertificates = certs + + return nil +} + // tls11SignatureSchemes contains the signature schemes that we synthesise for // a TLS <= 1.1 connection, based on the supported certificate types. -var tls11SignatureSchemes = []SignatureScheme{ECDSAWithP256AndSHA256, ECDSAWithP384AndSHA384, ECDSAWithP521AndSHA512, PKCS1WithSHA256, PKCS1WithSHA384, PKCS1WithSHA512, PKCS1WithSHA1} - -const ( - // tls11SignatureSchemesNumECDSA is the number of initial elements of - // tls11SignatureSchemes that use ECDSA. - tls11SignatureSchemesNumECDSA = 3 - // tls11SignatureSchemesNumRSA is the number of trailing elements of - // tls11SignatureSchemes that use RSA. - tls11SignatureSchemesNumRSA = 4 +var ( + tls11SignatureSchemes = []SignatureScheme{ECDSAWithP256AndSHA256, ECDSAWithP384AndSHA384, ECDSAWithP521AndSHA512, PKCS1WithSHA256, PKCS1WithSHA384, PKCS1WithSHA512, PKCS1WithSHA1} + tls11SignatureSchemesECDSA = tls11SignatureSchemes[:3] + tls11SignatureSchemesRSA = tls11SignatureSchemes[3:] ) -func (hs *clientHandshakeState) getCertificate(certReq *certificateRequestMsg) (*Certificate, error) { - c := hs.c - +// certificateRequestInfoFromMsg generates a CertificateRequestInfo from a TLS +// <= 1.2 CertificateRequest, making an effort to fill in missing information. +func certificateRequestInfoFromMsg(certReq *certificateRequestMsg) *CertificateRequestInfo { var rsaAvail, ecdsaAvail bool for _, certType := range certReq.certificateTypes { switch certType { @@ -736,77 +883,84 @@ func (hs *clientHandshakeState) getCertificate(certReq *certificateRequestMsg) ( } } - if c.config.GetClientCertificate != nil { - var signatureSchemes []SignatureScheme - - if !certReq.hasSignatureAndHash { - // Prior to TLS 1.2, the signature schemes were not - // included in the certificate request message. In this - // case we use a plausible list based on the acceptable - // certificate types. - signatureSchemes = tls11SignatureSchemes - if !ecdsaAvail { - signatureSchemes = signatureSchemes[tls11SignatureSchemesNumECDSA:] + cri := &CertificateRequestInfo{ + AcceptableCAs: certReq.certificateAuthorities, + } + + if !certReq.hasSignatureAlgorithm { + // Prior to TLS 1.2, the signature schemes were not + // included in the certificate request message. In this + // case we use a plausible list based on the acceptable + // certificate types. + switch { + case rsaAvail && ecdsaAvail: + cri.SignatureSchemes = tls11SignatureSchemes + case rsaAvail: + cri.SignatureSchemes = tls11SignatureSchemesRSA + case ecdsaAvail: + cri.SignatureSchemes = tls11SignatureSchemesECDSA + } + return cri + } + + // In TLS 1.2, the signature schemes apply to both the certificate chain and + // the leaf key, while the certificate types only apply to the leaf key. + // See RFC 5246, Section 7.4.4 (where it calls this "somewhat complicated"). + // Filter the signature schemes based on the certificate type. + cri.SignatureSchemes = make([]SignatureScheme, 0, len(certReq.supportedSignatureAlgorithms)) + for _, sigScheme := range certReq.supportedSignatureAlgorithms { + switch signatureFromSignatureScheme(sigScheme) { + case signatureECDSA: + if ecdsaAvail { + cri.SignatureSchemes = append(cri.SignatureSchemes, sigScheme) } - if !rsaAvail { - signatureSchemes = signatureSchemes[:len(signatureSchemes)-tls11SignatureSchemesNumRSA] + case signatureRSAPSS, signaturePKCS1v15: + if rsaAvail { + cri.SignatureSchemes = append(cri.SignatureSchemes, sigScheme) } - } else { - signatureSchemes = certReq.supportedSignatureAlgorithms } - - return c.config.GetClientCertificate(&CertificateRequestInfo{ - AcceptableCAs: certReq.certificateAuthorities, - SignatureSchemes: signatureSchemes, - }) } - // RFC 4346 on the certificateAuthorities field: A list of the - // distinguished names of acceptable certificate authorities. - // These distinguished names may specify a desired - // distinguished name for a root CA or for a subordinate CA; - // thus, this message can be used to describe both known roots - // and a desired authorization space. If the - // certificate_authorities list is empty then the client MAY - // send any certificate of the appropriate - // ClientCertificateType, unless there is some external - // arrangement to the contrary. + return cri +} + +func (c *Conn) getClientCertificate(cri *CertificateRequestInfo) (*Certificate, error) { + if c.config.GetClientCertificate != nil { + return c.config.GetClientCertificate(cri) + } // We need to search our list of client certs for one // where SignatureAlgorithm is acceptable to the server and the - // Issuer is in certReq.certificateAuthorities -findCert: + // Issuer is in AcceptableCAs. for i, chain := range c.config.Certificates { - if !rsaAvail && !ecdsaAvail { + sigOK := false + for _, alg := range signatureSchemesForCertificate(c.vers, &chain) { + if isSupportedSignatureAlgorithm(alg, cri.SignatureSchemes) { + sigOK = true + break + } + } + if !sigOK { continue } + if len(cri.AcceptableCAs) == 0 { + return &chain, nil + } + for j, cert := range chain.Certificate { x509Cert := chain.Leaf - // parse the certificate if this isn't the leaf - // node, or if chain.Leaf was nil + // Parse the certificate if this isn't the leaf node, or if + // chain.Leaf was nil. if j != 0 || x509Cert == nil { var err error if x509Cert, err = x509.ParseCertificate(cert); err != nil { c.sendAlert(alertInternalError) - return nil, errors.New("tls: failed to parse client certificate #" + strconv.Itoa(i) + ": " + err.Error()) + return nil, errors.New("tls: failed to parse configured certificate chain #" + strconv.Itoa(i) + ": " + err.Error()) } } - switch { - case rsaAvail && x509Cert.PublicKeyAlgorithm == x509.RSA: - case ecdsaAvail && x509Cert.PublicKeyAlgorithm == x509.ECDSA: - default: - continue findCert - } - - if len(certReq.certificateAuthorities) == 0 { - // they gave us an empty list, so just take the - // first cert from c.config.Certificates - return &chain, nil - } - - for _, ca := range certReq.certificateAuthorities { + for _, ca := range cri.AcceptableCAs { if bytes.Equal(x509Cert.RawIssuer, ca) { return &chain, nil } @@ -845,7 +999,7 @@ func mutualProtocol(protos, preferenceProtos []string) (string, bool) { // hostnameInSNI converts name into an approriate hostname for SNI. // Literal IP addresses and absolute FQDNs are not permitted as SNI values. -// See https://tools.ietf.org/html/rfc6066#section-3. +// See RFC 6066, Section 3. func hostnameInSNI(name string) string { host := name if len(host) > 0 && host[0] == '[' && host[len(host)-1] == ']' { diff --git a/libgo/go/crypto/tls/handshake_client_test.go b/libgo/go/crypto/tls/handshake_client_test.go index 1f1c93d102c..ececd7b04d0 100644 --- a/libgo/go/crypto/tls/handshake_client_test.go +++ b/libgo/go/crypto/tls/handshake_client_test.go @@ -22,11 +22,22 @@ import ( "path/filepath" "strconv" "strings" - "sync" "testing" "time" ) +func init() { + // TLS 1.3 cipher suites preferences are not configurable and change based + // on the architecture. Force them to the version with AES accelleration for + // test consistency. + once.Do(initDefaultCipherSuites) + varDefaultCipherSuitesTLS13 = []uint16{ + TLS_AES_128_GCM_SHA256, + TLS_CHACHA20_POLY1305_SHA256, + TLS_AES_256_GCM_SHA384, + } +} + // Note: see comment in handshake_test.go for details of how the reference // tests work. @@ -42,6 +53,10 @@ const ( // opensslSendBanner causes OpenSSL to send the contents of // opensslSentinel on the connection. opensslSendSentinel + + // opensslKeyUpdate causes OpenSSL to send send a key update message to the + // client and request one back. + opensslKeyUpdate ) const opensslSentinel = "SENTINEL\n" @@ -53,6 +68,8 @@ func (i opensslInput) Read(buf []byte) (n int, err error) { switch event { case opensslRenegotiate: return copy(buf, []byte("R\n")), nil + case opensslKeyUpdate: + return copy(buf, []byte("K\n")), nil case opensslSendSentinel: return copy(buf, []byte(opensslSentinel)), nil default: @@ -63,23 +80,28 @@ func (i opensslInput) Read(buf []byte) (n int, err error) { return 0, io.EOF } -// opensslOutputSink is an io.Writer that receives the stdout and stderr from -// an `openssl` process and sends a value to handshakeComplete when it sees a -// log message from a completed server handshake. +// opensslOutputSink is an io.Writer that receives the stdout and stderr from an +// `openssl` process and sends a value to handshakeComplete or readKeyUpdate +// when certain messages are seen. type opensslOutputSink struct { handshakeComplete chan struct{} + readKeyUpdate chan struct{} all []byte line []byte } func newOpensslOutputSink() *opensslOutputSink { - return &opensslOutputSink{make(chan struct{}), nil, nil} + return &opensslOutputSink{make(chan struct{}), make(chan struct{}), nil, nil} } // opensslEndOfHandshake is a message that the “openssl s_server” tool will // print when a handshake completes if run with “-state”. const opensslEndOfHandshake = "SSL_accept:SSLv3/TLS write finished" +// opensslReadKeyUpdate is a message that the “openssl s_server” tool will +// print when a KeyUpdate message is received if run with “-state”. +const opensslReadKeyUpdate = "SSL_accept:TLSv1.3 read client key update" + func (o *opensslOutputSink) Write(data []byte) (n int, err error) { o.line = append(o.line, data...) o.all = append(o.all, data...) @@ -93,15 +115,17 @@ func (o *opensslOutputSink) Write(data []byte) (n int, err error) { if bytes.Equal([]byte(opensslEndOfHandshake), o.line[:i]) { o.handshakeComplete <- struct{}{} } + if bytes.Equal([]byte(opensslReadKeyUpdate), o.line[:i]) { + o.readKeyUpdate <- struct{}{} + } o.line = o.line[i+1:] } return len(data), nil } -func (o *opensslOutputSink) WriteTo(w io.Writer) (int64, error) { - n, err := w.Write(o.all) - return int64(n), err +func (o *opensslOutputSink) String() string { + return string(o.all) } // clientTest represents a test of the TLS client handshake against a reference @@ -110,9 +134,9 @@ type clientTest struct { // name is a freeform string identifying the test and the file in which // the expected results will be stored. name string - // command, if not empty, contains a series of arguments for the + // args, if not empty, contains a series of arguments for the // command to run for the reference server. - command []string + args []string // config, if not nil, contains a custom Config to use for this test. config *Config // cert, if not empty, contains a DER-encoded certificate for the @@ -139,9 +163,11 @@ type clientTest struct { // arising from renegotiation. It can map expected errors to nil to // ignore them. checkRenegotiationError func(renegotiationNum int, err error) error + // sendKeyUpdate will cause the server to send a KeyUpdate message. + sendKeyUpdate bool } -var defaultServerCommand = []string{"openssl", "s_server"} +var serverCommand = []string{"openssl", "s_server", "-no_ticket", "-num_tickets", "0"} // connFromCommand starts the reference server process, connects to it and // returns a recordingConn for the connection. The stdin return value is an @@ -179,15 +205,12 @@ func (test *clientTest) connFromCommand() (conn *recordingConn, child *exec.Cmd, var pemOut bytes.Buffer pem.Encode(&pemOut, &pem.Block{Type: pemType + " PRIVATE KEY", Bytes: derBytes}) - keyPath := tempFile(string(pemOut.Bytes())) + keyPath := tempFile(pemOut.String()) defer os.Remove(keyPath) var command []string - if len(test.command) > 0 { - command = append(command, test.command...) - } else { - command = append(command, defaultServerCommand...) - } + command = append(command, serverCommand...) + command = append(command, test.args...) command = append(command, "-cert", certPath, "-certform", "DER", "-key", keyPath) // serverPort contains the port that OpenSSL will listen on. OpenSSL // can't take "0" as an argument here so we have to pick a number and @@ -210,7 +233,7 @@ func (test *clientTest) connFromCommand() (conn *recordingConn, child *exec.Cmd, command = append(command, "-serverinfo", serverInfoPath) } - if test.numRenegotiations > 0 { + if test.numRenegotiations > 0 || test.sendKeyUpdate { found := false for _, flag := range command[1:] { if flag == "-state" { @@ -220,7 +243,7 @@ func (test *clientTest) connFromCommand() (conn *recordingConn, child *exec.Cmd, } if !found { - panic("-state flag missing to OpenSSL. You need this if testing renegotiation") + panic("-state flag missing to OpenSSL, you need this if testing renegotiation or KeyUpdate") } } @@ -251,9 +274,9 @@ func (test *clientTest) connFromCommand() (conn *recordingConn, child *exec.Cmd, } if err != nil { close(stdin) - out.WriteTo(os.Stdout) cmd.Process.Kill() - return nil, nil, nil, nil, cmd.Wait() + err = fmt.Errorf("error connecting to the OpenSSL server: %v (%v)\n\n%s", err, cmd.Wait(), out) + return nil, nil, nil, nil, err } record := &recordingConn{ @@ -292,20 +315,28 @@ func (test *clientTest) run(t *testing.T, write bool) { t.Fatalf("Failed to start subcommand: %s", err) } clientConn = recordingConn + defer func() { + if t.Failed() { + t.Logf("OpenSSL output:\n\n%s", stdout.all) + } + }() } else { - clientConn, serverConn = net.Pipe() + clientConn, serverConn = localPipe(t) } - config := test.config - if config == nil { - config = testConfig - } - client := Client(clientConn, config) - doneChan := make(chan bool) + defer func() { + clientConn.Close() + <-doneChan + }() go func() { - defer func() { doneChan <- true }() - defer clientConn.Close() + defer close(doneChan) + + config := test.config + if config == nil { + config = testConfig + } + client := Client(clientConn, config) defer client.Close() if _, err := client.Write([]byte("hello\n")); err != nil { @@ -335,7 +366,7 @@ func (test *clientTest) run(t *testing.T, write bool) { signalChan := make(chan struct{}) go func() { - defer func() { signalChan <- struct{}{} }() + defer close(signalChan) buf := make([]byte, 256) n, err := client.Read(buf) @@ -370,11 +401,59 @@ func (test *clientTest) run(t *testing.T, write bool) { <-signalChan } + if test.sendKeyUpdate { + if write { + <-stdout.handshakeComplete + stdin <- opensslKeyUpdate + } + + doneRead := make(chan struct{}) + + go func() { + defer close(doneRead) + + buf := make([]byte, 256) + n, err := client.Read(buf) + + if err != nil { + t.Errorf("Client.Read failed after KeyUpdate: %s", err) + return + } + + buf = buf[:n] + if !bytes.Equal([]byte(opensslSentinel), buf) { + t.Errorf("Client.Read returned %q, but wanted %q", string(buf), opensslSentinel) + } + }() + + if write { + // There's no real reason to wait for the client KeyUpdate to + // send data with the new server keys, except that s_server + // drops writes if they are sent at the wrong time. + <-stdout.readKeyUpdate + stdin <- opensslSendSentinel + } + <-doneRead + + if _, err := client.Write([]byte("hello again\n")); err != nil { + t.Errorf("Client.Write failed: %s", err) + return + } + } + if test.validate != nil { if err := test.validate(client.ConnectionState()); err != nil { t.Errorf("validate callback returned error: %s", err) } } + + // If the server sent us an alert after our last flight, give it a + // chance to arrive. + if write && test.renegotiationExpectedToFail == 0 { + if err := peekError(client); err != nil { + t.Errorf("final Read returned an error: %s", err) + } + } }() if !write { @@ -384,22 +463,26 @@ func (test *clientTest) run(t *testing.T, write bool) { } for i, b := range flows { if i%2 == 1 { + serverConn.SetWriteDeadline(time.Now().Add(1 * time.Minute)) serverConn.Write(b) continue } bb := make([]byte, len(b)) + serverConn.SetReadDeadline(time.Now().Add(1 * time.Minute)) _, err := io.ReadFull(serverConn, bb) if err != nil { - t.Fatalf("%s #%d: %s", test.name, i, err) + t.Fatalf("%s, flow %d: %s", test.name, i+1, err) } if !bytes.Equal(b, bb) { - t.Fatalf("%s #%d: mismatch on read: got:%x want:%x", test.name, i, bb, b) + t.Fatalf("%s, flow %d: mismatch on read: got:%x want:%x", test.name, i+1, bb, b) } } - serverConn.Close() } <-doneChan + if !write { + serverConn.Close() + } if write { path := test.dataPath() @@ -413,60 +496,65 @@ func (test *clientTest) run(t *testing.T, write bool) { childProcess.Process.Kill() childProcess.Wait() if len(recordingConn.flows) < 3 { - os.Stdout.Write(childProcess.Stdout.(*opensslOutputSink).all) t.Fatalf("Client connection didn't work") } recordingConn.WriteTo(out) - fmt.Printf("Wrote %s\n", path) + t.Logf("Wrote %s\n", path) } } -var ( - didParMu sync.Mutex - didPar = map[*testing.T]bool{} -) - -// setParallel calls t.Parallel once. If you call it twice, it would -// panic. -func setParallel(t *testing.T) { - didParMu.Lock() - v := didPar[t] - didPar[t] = true - didParMu.Unlock() - if !v { - t.Parallel() +// peekError does a read with a short timeout to check if the next read would +// cause an error, for example if there is an alert waiting on the wire. +func peekError(conn net.Conn) error { + conn.SetReadDeadline(time.Now().Add(100 * time.Millisecond)) + if n, err := conn.Read(make([]byte, 1)); n != 0 { + return errors.New("unexpectedly read data") + } else if err != nil { + if netErr, ok := err.(net.Error); !ok || !netErr.Timeout() { + return err + } } + return nil } -func runClientTestForVersion(t *testing.T, template *clientTest, prefix, option string) { - setParallel(t) +func runClientTestForVersion(t *testing.T, template *clientTest, version, option string) { + t.Run(version, func(t *testing.T) { + // Make a deep copy of the template before going parallel. + test := *template + if template.config != nil { + test.config = template.config.Clone() + } - test := *template - test.name = prefix + test.name - if len(test.command) == 0 { - test.command = defaultClientCommand - } - test.command = append([]string(nil), test.command...) - test.command = append(test.command, option) - test.run(t, *update) + if !*update { + t.Parallel() + } + + test.name = version + "-" + test.name + test.args = append([]string{option}, test.args...) + test.run(t, *update) + }) } func runClientTestTLS10(t *testing.T, template *clientTest) { - runClientTestForVersion(t, template, "TLSv10-", "-tls1") + runClientTestForVersion(t, template, "TLSv10", "-tls1") } func runClientTestTLS11(t *testing.T, template *clientTest) { - runClientTestForVersion(t, template, "TLSv11-", "-tls1_1") + runClientTestForVersion(t, template, "TLSv11", "-tls1_1") } func runClientTestTLS12(t *testing.T, template *clientTest) { - runClientTestForVersion(t, template, "TLSv12-", "-tls1_2") + runClientTestForVersion(t, template, "TLSv12", "-tls1_2") +} + +func runClientTestTLS13(t *testing.T, template *clientTest) { + runClientTestForVersion(t, template, "TLSv13", "-tls1_3") } func TestHandshakeClientRSARC4(t *testing.T) { test := &clientTest{ - name: "RSA-RC4", - command: []string{"openssl", "s_server", "-cipher", "RC4-SHA"}, + name: "RSA-RC4", + args: []string{"-cipher", "RC4-SHA"}, } runClientTestTLS10(t, test) runClientTestTLS11(t, test) @@ -475,24 +563,24 @@ func TestHandshakeClientRSARC4(t *testing.T) { func TestHandshakeClientRSAAES128GCM(t *testing.T) { test := &clientTest{ - name: "AES128-GCM-SHA256", - command: []string{"openssl", "s_server", "-cipher", "AES128-GCM-SHA256"}, + name: "AES128-GCM-SHA256", + args: []string{"-cipher", "AES128-GCM-SHA256"}, } runClientTestTLS12(t, test) } func TestHandshakeClientRSAAES256GCM(t *testing.T) { test := &clientTest{ - name: "AES256-GCM-SHA384", - command: []string{"openssl", "s_server", "-cipher", "AES256-GCM-SHA384"}, + name: "AES256-GCM-SHA384", + args: []string{"-cipher", "AES256-GCM-SHA384"}, } runClientTestTLS12(t, test) } func TestHandshakeClientECDHERSAAES(t *testing.T) { test := &clientTest{ - name: "ECDHE-RSA-AES", - command: []string{"openssl", "s_server", "-cipher", "ECDHE-RSA-AES128-SHA"}, + name: "ECDHE-RSA-AES", + args: []string{"-cipher", "ECDHE-RSA-AES128-SHA"}, } runClientTestTLS10(t, test) runClientTestTLS11(t, test) @@ -501,10 +589,10 @@ func TestHandshakeClientECDHERSAAES(t *testing.T) { func TestHandshakeClientECDHEECDSAAES(t *testing.T) { test := &clientTest{ - name: "ECDHE-ECDSA-AES", - command: []string{"openssl", "s_server", "-cipher", "ECDHE-ECDSA-AES128-SHA"}, - cert: testECDSACertificate, - key: testECDSAPrivateKey, + name: "ECDHE-ECDSA-AES", + args: []string{"-cipher", "ECDHE-ECDSA-AES128-SHA"}, + cert: testECDSACertificate, + key: testECDSAPrivateKey, } runClientTestTLS10(t, test) runClientTestTLS11(t, test) @@ -513,46 +601,46 @@ func TestHandshakeClientECDHEECDSAAES(t *testing.T) { func TestHandshakeClientECDHEECDSAAESGCM(t *testing.T) { test := &clientTest{ - name: "ECDHE-ECDSA-AES-GCM", - command: []string{"openssl", "s_server", "-cipher", "ECDHE-ECDSA-AES128-GCM-SHA256"}, - cert: testECDSACertificate, - key: testECDSAPrivateKey, + name: "ECDHE-ECDSA-AES-GCM", + args: []string{"-cipher", "ECDHE-ECDSA-AES128-GCM-SHA256"}, + cert: testECDSACertificate, + key: testECDSAPrivateKey, } runClientTestTLS12(t, test) } func TestHandshakeClientAES256GCMSHA384(t *testing.T) { test := &clientTest{ - name: "ECDHE-ECDSA-AES256-GCM-SHA384", - command: []string{"openssl", "s_server", "-cipher", "ECDHE-ECDSA-AES256-GCM-SHA384"}, - cert: testECDSACertificate, - key: testECDSAPrivateKey, + name: "ECDHE-ECDSA-AES256-GCM-SHA384", + args: []string{"-cipher", "ECDHE-ECDSA-AES256-GCM-SHA384"}, + cert: testECDSACertificate, + key: testECDSAPrivateKey, } runClientTestTLS12(t, test) } func TestHandshakeClientAES128CBCSHA256(t *testing.T) { test := &clientTest{ - name: "AES128-SHA256", - command: []string{"openssl", "s_server", "-cipher", "AES128-SHA256"}, + name: "AES128-SHA256", + args: []string{"-cipher", "AES128-SHA256"}, } runClientTestTLS12(t, test) } func TestHandshakeClientECDHERSAAES128CBCSHA256(t *testing.T) { test := &clientTest{ - name: "ECDHE-RSA-AES128-SHA256", - command: []string{"openssl", "s_server", "-cipher", "ECDHE-RSA-AES128-SHA256"}, + name: "ECDHE-RSA-AES128-SHA256", + args: []string{"-cipher", "ECDHE-RSA-AES128-SHA256"}, } runClientTestTLS12(t, test) } func TestHandshakeClientECDHEECDSAAES128CBCSHA256(t *testing.T) { test := &clientTest{ - name: "ECDHE-ECDSA-AES128-SHA256", - command: []string{"openssl", "s_server", "-cipher", "ECDHE-ECDSA-AES128-SHA256"}, - cert: testECDSACertificate, - key: testECDSAPrivateKey, + name: "ECDHE-ECDSA-AES128-SHA256", + args: []string{"-cipher", "ECDHE-ECDSA-AES128-SHA256"}, + cert: testECDSACertificate, + key: testECDSAPrivateKey, } runClientTestTLS12(t, test) } @@ -562,12 +650,40 @@ func TestHandshakeClientX25519(t *testing.T) { config.CurvePreferences = []CurveID{X25519} test := &clientTest{ - name: "X25519-ECDHE-RSA-AES-GCM", - command: []string{"openssl", "s_server", "-cipher", "ECDHE-RSA-AES128-GCM-SHA256"}, - config: config, + name: "X25519-ECDHE", + args: []string{"-cipher", "ECDHE-RSA-AES128-GCM-SHA256", "-curves", "X25519"}, + config: config, } runClientTestTLS12(t, test) + runClientTestTLS13(t, test) +} + +func TestHandshakeClientP256(t *testing.T) { + config := testConfig.Clone() + config.CurvePreferences = []CurveID{CurveP256} + + test := &clientTest{ + name: "P256-ECDHE", + args: []string{"-cipher", "ECDHE-RSA-AES128-GCM-SHA256", "-curves", "P-256"}, + config: config, + } + + runClientTestTLS12(t, test) + runClientTestTLS13(t, test) +} + +func TestHandshakeClientHelloRetryRequest(t *testing.T) { + config := testConfig.Clone() + config.CurvePreferences = []CurveID{X25519, CurveP256} + + test := &clientTest{ + name: "HelloRetryRequest", + args: []string{"-cipher", "ECDHE-RSA-AES128-GCM-SHA256", "-curves", "P-256"}, + config: config, + } + + runClientTestTLS13(t, test) } func TestHandshakeClientECDHERSAChaCha20(t *testing.T) { @@ -575,9 +691,9 @@ func TestHandshakeClientECDHERSAChaCha20(t *testing.T) { config.CipherSuites = []uint16{TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305} test := &clientTest{ - name: "ECDHE-RSA-CHACHA20-POLY1305", - command: []string{"openssl", "s_server", "-cipher", "ECDHE-RSA-CHACHA20-POLY1305"}, - config: config, + name: "ECDHE-RSA-CHACHA20-POLY1305", + args: []string{"-cipher", "ECDHE-RSA-CHACHA20-POLY1305"}, + config: config, } runClientTestTLS12(t, test) @@ -588,47 +704,79 @@ func TestHandshakeClientECDHEECDSAChaCha20(t *testing.T) { config.CipherSuites = []uint16{TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305} test := &clientTest{ - name: "ECDHE-ECDSA-CHACHA20-POLY1305", - command: []string{"openssl", "s_server", "-cipher", "ECDHE-ECDSA-CHACHA20-POLY1305"}, - config: config, - cert: testECDSACertificate, - key: testECDSAPrivateKey, + name: "ECDHE-ECDSA-CHACHA20-POLY1305", + args: []string{"-cipher", "ECDHE-ECDSA-CHACHA20-POLY1305"}, + config: config, + cert: testECDSACertificate, + key: testECDSAPrivateKey, } runClientTestTLS12(t, test) } +func TestHandshakeClientAES128SHA256(t *testing.T) { + test := &clientTest{ + name: "AES128-SHA256", + args: []string{"-ciphersuites", "TLS_AES_128_GCM_SHA256"}, + } + runClientTestTLS13(t, test) +} +func TestHandshakeClientAES256SHA384(t *testing.T) { + test := &clientTest{ + name: "AES256-SHA384", + args: []string{"-ciphersuites", "TLS_AES_256_GCM_SHA384"}, + } + runClientTestTLS13(t, test) +} +func TestHandshakeClientCHACHA20SHA256(t *testing.T) { + test := &clientTest{ + name: "CHACHA20-SHA256", + args: []string{"-ciphersuites", "TLS_CHACHA20_POLY1305_SHA256"}, + } + runClientTestTLS13(t, test) +} + +func TestHandshakeClientECDSATLS13(t *testing.T) { + test := &clientTest{ + name: "ECDSA", + cert: testECDSACertificate, + key: testECDSAPrivateKey, + } + runClientTestTLS13(t, test) +} + func TestHandshakeClientCertRSA(t *testing.T) { config := testConfig.Clone() cert, _ := X509KeyPair([]byte(clientCertificatePEM), []byte(clientKeyPEM)) config.Certificates = []Certificate{cert} test := &clientTest{ - name: "ClientCert-RSA-RSA", - command: []string{"openssl", "s_server", "-cipher", "AES128", "-verify", "1"}, - config: config, + name: "ClientCert-RSA-RSA", + args: []string{"-cipher", "AES128", "-Verify", "1"}, + config: config, } runClientTestTLS10(t, test) runClientTestTLS12(t, test) test = &clientTest{ - name: "ClientCert-RSA-ECDSA", - command: []string{"openssl", "s_server", "-cipher", "ECDHE-ECDSA-AES128-SHA", "-verify", "1"}, - config: config, - cert: testECDSACertificate, - key: testECDSAPrivateKey, + name: "ClientCert-RSA-ECDSA", + args: []string{"-cipher", "ECDHE-ECDSA-AES128-SHA", "-Verify", "1"}, + config: config, + cert: testECDSACertificate, + key: testECDSAPrivateKey, } runClientTestTLS10(t, test) runClientTestTLS12(t, test) + runClientTestTLS13(t, test) test = &clientTest{ - name: "ClientCert-RSA-AES256-GCM-SHA384", - command: []string{"openssl", "s_server", "-cipher", "ECDHE-RSA-AES256-GCM-SHA384", "-verify", "1"}, - config: config, - cert: testRSACertificate, - key: testRSAPrivateKey, + name: "ClientCert-RSA-AES256-GCM-SHA384", + args: []string{"-cipher", "ECDHE-RSA-AES256-GCM-SHA384", "-Verify", "1"}, + config: config, + cert: testRSACertificate, + key: testRSAPrivateKey, } runClientTestTLS12(t, test) @@ -640,28 +788,90 @@ func TestHandshakeClientCertECDSA(t *testing.T) { config.Certificates = []Certificate{cert} test := &clientTest{ - name: "ClientCert-ECDSA-RSA", - command: []string{"openssl", "s_server", "-cipher", "AES128", "-verify", "1"}, - config: config, + name: "ClientCert-ECDSA-RSA", + args: []string{"-cipher", "AES128", "-Verify", "1"}, + config: config, } runClientTestTLS10(t, test) runClientTestTLS12(t, test) + runClientTestTLS13(t, test) test = &clientTest{ - name: "ClientCert-ECDSA-ECDSA", - command: []string{"openssl", "s_server", "-cipher", "ECDHE-ECDSA-AES128-SHA", "-verify", "1"}, - config: config, - cert: testECDSACertificate, - key: testECDSAPrivateKey, + name: "ClientCert-ECDSA-ECDSA", + args: []string{"-cipher", "ECDHE-ECDSA-AES128-SHA", "-Verify", "1"}, + config: config, + cert: testECDSACertificate, + key: testECDSAPrivateKey, } runClientTestTLS10(t, test) runClientTestTLS12(t, test) } -func TestClientResumption(t *testing.T) { +// TestHandshakeClientCertRSAPSS tests a few separate things: +// * that our client can serve a PSS-signed certificate +// * that our client can validate a PSS-signed certificate +// * that our client can use rsa_pss_rsae_sha256 in its CertificateVerify +// * that our client can accpet rsa_pss_rsae_sha256 in the server CertificateVerify +func TestHandshakeClientCertRSAPSS(t *testing.T) { + issuer, err := x509.ParseCertificate(testRSAPSSCertificate) + if err != nil { + panic(err) + } + rootCAs := x509.NewCertPool() + rootCAs.AddCert(issuer) + + config := testConfig.Clone() + cert, _ := X509KeyPair([]byte(clientCertificatePEM), []byte(clientKeyPEM)) + config.Certificates = []Certificate{cert} + config.RootCAs = rootCAs + + test := &clientTest{ + name: "ClientCert-RSA-RSAPSS", + args: []string{"-cipher", "AES128", "-Verify", "1", "-client_sigalgs", + "rsa_pss_rsae_sha256", "-sigalgs", "rsa_pss_rsae_sha256"}, + config: config, + cert: testRSAPSSCertificate, + key: testRSAPrivateKey, + } + + runClientTestTLS12(t, test) + runClientTestTLS13(t, test) +} + +func TestHandshakeClientCertRSAPKCS1v15(t *testing.T) { + config := testConfig.Clone() + cert, _ := X509KeyPair([]byte(clientCertificatePEM), []byte(clientKeyPEM)) + config.Certificates = []Certificate{cert} + + test := &clientTest{ + name: "ClientCert-RSA-RSAPKCS1v15", + args: []string{"-cipher", "AES128", "-Verify", "1", "-client_sigalgs", + "rsa_pkcs1_sha256", "-sigalgs", "rsa_pkcs1_sha256"}, + config: config, + } + + runClientTestTLS12(t, test) +} + +func TestClientKeyUpdate(t *testing.T) { + test := &clientTest{ + name: "KeyUpdate", + args: []string{"-state"}, + sendKeyUpdate: true, + } + runClientTestTLS13(t, test) +} + +func TestResumption(t *testing.T) { + t.Run("TLSv12", func(t *testing.T) { testResumption(t, VersionTLS12) }) + t.Run("TLSv13", func(t *testing.T) { testResumption(t, VersionTLS13) }) +} + +func testResumption(t *testing.T, version uint16) { serverConfig := &Config{ + MaxVersion: version, CipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA, TLS_ECDHE_RSA_WITH_RC4_128_SHA}, Certificates: testConfig.Certificates, } @@ -675,6 +885,7 @@ func TestClientResumption(t *testing.T) { rootCAs.AddCert(issuer) clientConfig := &Config{ + MaxVersion: version, CipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA}, ClientSessionCache: NewLRUClientSessionCache(32), RootCAs: rootCAs, @@ -682,7 +893,7 @@ func TestClientResumption(t *testing.T) { } testResumeState := func(test string, didResume bool) { - _, hs, err := testHandshake(clientConfig, serverConfig) + _, hs, err := testHandshake(t, clientConfig, serverConfig) if err != nil { t.Fatalf("%s: handshake failed: %s", test, err) } @@ -697,6 +908,13 @@ func TestClientResumption(t *testing.T) { getTicket := func() []byte { return clientConfig.ClientSessionCache.(*lruSessionCache).q.Front().Value.(*lruSessionCacheEntry).state.sessionTicket } + deleteTicket := func() { + ticketKey := clientConfig.ClientSessionCache.(*lruSessionCache).q.Front().Value.(*lruSessionCacheEntry).sessionKey + clientConfig.ClientSessionCache.Put(ticketKey, nil) + } + corruptTicket := func() { + clientConfig.ClientSessionCache.(*lruSessionCache).q.Front().Value.(*lruSessionCacheEntry).state.masterSecret[0] ^= 0xff + } randomKey := func() [32]byte { var k [32]byte if _, err := io.ReadFull(serverConfig.rand(), k[:]); err != nil { @@ -708,9 +926,12 @@ func TestClientResumption(t *testing.T) { testResumeState("Handshake", false) ticket := getTicket() testResumeState("Resume", true) - if !bytes.Equal(ticket, getTicket()) { + if !bytes.Equal(ticket, getTicket()) && version != VersionTLS13 { t.Fatal("first ticket doesn't match ticket after resumption") } + if bytes.Equal(ticket, getTicket()) && version == VersionTLS13 { + t.Fatal("ticket didn't change after resumption") + } key1 := randomKey() serverConfig.SetSessionTicketKeys([][32]byte{key1}) @@ -730,6 +951,7 @@ func TestClientResumption(t *testing.T) { // Reset serverConfig to ensure that calling SetSessionTicketKeys // before the serverConfig is used works. serverConfig = &Config{ + MaxVersion: version, CipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA, TLS_ECDHE_RSA_WITH_RC4_128_SHA}, Certificates: testConfig.Certificates, } @@ -737,9 +959,35 @@ func TestClientResumption(t *testing.T) { testResumeState("FreshConfig", true) - clientConfig.CipherSuites = []uint16{TLS_ECDHE_RSA_WITH_RC4_128_SHA} - testResumeState("DifferentCipherSuite", false) - testResumeState("DifferentCipherSuiteRecovers", true) + // In TLS 1.3, cross-cipher suite resumption is allowed as long as the KDF + // hash matches. Also, Config.CipherSuites does not apply to TLS 1.3. + if version != VersionTLS13 { + clientConfig.CipherSuites = []uint16{TLS_ECDHE_RSA_WITH_RC4_128_SHA} + testResumeState("DifferentCipherSuite", false) + testResumeState("DifferentCipherSuiteRecovers", true) + } + + deleteTicket() + testResumeState("WithoutSessionTicket", false) + + // Session resumption should work when using client certificates + deleteTicket() + serverConfig.ClientCAs = rootCAs + serverConfig.ClientAuth = RequireAndVerifyClientCert + clientConfig.Certificates = serverConfig.Certificates + testResumeState("InitialHandshake", false) + testResumeState("WithClientCertificates", true) + serverConfig.ClientAuth = NoClientCert + + // Tickets should be removed from the session cache on TLS handshake + // failure, and the client should recover from a corrupted PSK + testResumeState("FetchTicketToCorrupt", false) + corruptTicket() + _, _, err = testHandshake(t, clientConfig, serverConfig) + if err == nil { + t.Fatalf("handshake did not fail with a corrupted client secret") + } + testResumeState("AfterHandshakeFailure", false) clientConfig.ClientSessionCache = nil testResumeState("WithoutSessionCache", false) @@ -784,23 +1032,36 @@ func TestLRUClientSessionCache(t *testing.T) { t.Fatalf("session cache failed update for key 0") } - // Adding a nil entry is valid. + // Calling Put with a nil entry deletes the key. cache.Put(keys[0], nil) - if s, ok := cache.Get(keys[0]); !ok || s != nil { - t.Fatalf("failed to add nil entry to cache") + if _, ok := cache.Get(keys[0]); ok { + t.Fatalf("session cache failed to delete key 0") + } + + // Delete entry 2. LRU should keep 4 and 5 + cache.Put(keys[2], nil) + if _, ok := cache.Get(keys[2]); ok { + t.Fatalf("session cache failed to delete key 4") + } + for i := 4; i < 6; i++ { + if s, ok := cache.Get(keys[i]); !ok || s != &cs[i] { + t.Fatalf("session cache should not have deleted key: %s", keys[i]) + } } } -func TestKeyLog(t *testing.T) { +func TestKeyLogTLS12(t *testing.T) { var serverBuf, clientBuf bytes.Buffer clientConfig := testConfig.Clone() clientConfig.KeyLogWriter = &clientBuf + clientConfig.MaxVersion = VersionTLS12 serverConfig := testConfig.Clone() serverConfig.KeyLogWriter = &serverBuf + serverConfig.MaxVersion = VersionTLS12 - c, s := net.Pipe() + c, s := localPipe(t) done := make(chan bool) go func() { @@ -838,8 +1099,49 @@ func TestKeyLog(t *testing.T) { } } - checkKeylogLine("client", string(clientBuf.Bytes())) - checkKeylogLine("server", string(serverBuf.Bytes())) + checkKeylogLine("client", clientBuf.String()) + checkKeylogLine("server", serverBuf.String()) +} + +func TestKeyLogTLS13(t *testing.T) { + var serverBuf, clientBuf bytes.Buffer + + clientConfig := testConfig.Clone() + clientConfig.KeyLogWriter = &clientBuf + + serverConfig := testConfig.Clone() + serverConfig.KeyLogWriter = &serverBuf + + c, s := localPipe(t) + done := make(chan bool) + + go func() { + defer close(done) + + if err := Server(s, serverConfig).Handshake(); err != nil { + t.Errorf("server: %s", err) + return + } + s.Close() + }() + + if err := Client(c, clientConfig).Handshake(); err != nil { + t.Fatalf("client: %s", err) + } + + c.Close() + <-done + + checkKeylogLines := func(side, loggedLines string) { + loggedLines = strings.TrimSpace(loggedLines) + lines := strings.Split(loggedLines, "\n") + if len(lines) != 4 { + t.Errorf("Expected the %s to log 4 lines, got %d", side, len(lines)) + } + } + + checkKeylogLines("client", clientBuf.String()) + checkKeylogLines("server", serverBuf.String()) } func TestHandshakeClientALPNMatch(t *testing.T) { @@ -850,8 +1152,8 @@ func TestHandshakeClientALPNMatch(t *testing.T) { name: "ALPN", // Note that this needs OpenSSL 1.0.2 because that is the first // version that supports the -alpn flag. - command: []string{"openssl", "s_server", "-alpn", "proto1,proto2"}, - config: config, + args: []string{"-alpn", "proto1,proto2"}, + config: config, validate: func(state ConnectionState) error { // The server's preferences should override the client. if state.NegotiatedProtocol != "proto1" { @@ -861,6 +1163,7 @@ func TestHandshakeClientALPNMatch(t *testing.T) { }, } runClientTestTLS12(t, test) + runClientTestTLS13(t, test) } // sctsBase64 contains data from `openssl s_client -serverinfo 18 -connect ritter.vg:443` @@ -874,11 +1177,10 @@ func TestHandshakClientSCTs(t *testing.T) { t.Fatal(err) } + // Note that this needs OpenSSL 1.0.2 because that is the first + // version that supports the -serverinfo flag. test := &clientTest{ - name: "SCT", - // Note that this needs OpenSSL 1.0.2 because that is the first - // version that supports the -serverinfo flag. - command: []string{"openssl", "s_server"}, + name: "SCT", config: config, extensions: [][]byte{scts}, validate: func(state ConnectionState) error { @@ -899,13 +1201,16 @@ func TestHandshakClientSCTs(t *testing.T) { }, } runClientTestTLS12(t, test) + + // TLS 1.3 moved SCTs to the Certificate extensions and -serverinfo only + // supports ServerHello extensions. } func TestRenegotiationRejected(t *testing.T) { config := testConfig.Clone() test := &clientTest{ name: "RenegotiationRejected", - command: []string{"openssl", "s_server", "-state"}, + args: []string{"-state"}, config: config, numRenegotiations: 1, renegotiationExpectedToFail: 1, @@ -919,7 +1224,6 @@ func TestRenegotiationRejected(t *testing.T) { return nil }, } - runClientTestTLS12(t, test) } @@ -929,7 +1233,7 @@ func TestRenegotiateOnce(t *testing.T) { test := &clientTest{ name: "RenegotiateOnce", - command: []string{"openssl", "s_server", "-state"}, + args: []string{"-state"}, config: config, numRenegotiations: 1, } @@ -943,7 +1247,7 @@ func TestRenegotiateTwice(t *testing.T) { test := &clientTest{ name: "RenegotiateTwice", - command: []string{"openssl", "s_server", "-state"}, + args: []string{"-state"}, config: config, numRenegotiations: 2, } @@ -957,7 +1261,7 @@ func TestRenegotiateTwiceRejected(t *testing.T) { test := &clientTest{ name: "RenegotiateTwiceRejected", - command: []string{"openssl", "s_server", "-state"}, + args: []string{"-state"}, config: config, numRenegotiations: 2, renegotiationExpectedToFail: 2, @@ -981,9 +1285,8 @@ func TestRenegotiateTwiceRejected(t *testing.T) { func TestHandshakeClientExportKeyingMaterial(t *testing.T) { test := &clientTest{ - name: "ExportKeyingMaterial", - command: []string{"openssl", "s_server"}, - config: testConfig.Clone(), + name: "ExportKeyingMaterial", + config: testConfig.Clone(), validate: func(state ConnectionState) error { if km, err := state.ExportKeyingMaterial("test", nil, 42); err != nil { return fmt.Errorf("ExportKeyingMaterial failed: %v", err) @@ -995,6 +1298,7 @@ func TestHandshakeClientExportKeyingMaterial(t *testing.T) { } runClientTestTLS10(t, test) runClientTestTLS12(t, test) + runClientTestTLS13(t, test) } var hostnameInSNITests = []struct { @@ -1021,7 +1325,7 @@ var hostnameInSNITests = []struct { func TestHostnameInSNI(t *testing.T) { for _, tt := range hostnameInSNITests { - c, s := net.Pipe() + c, s := localPipe(t) go func(host string) { Client(c, &Config{ServerName: host, InsecureSkipVerify: true}).Handshake() @@ -1059,7 +1363,7 @@ func TestServerSelectingUnconfiguredCipherSuite(t *testing.T) { // This checks that the server can't select a cipher suite that the // client didn't offer. See #13174. - c, s := net.Pipe() + c, s := localPipe(t) errChan := make(chan error, 1) go func() { @@ -1106,6 +1410,11 @@ func TestServerSelectingUnconfiguredCipherSuite(t *testing.T) { } func TestVerifyPeerCertificate(t *testing.T) { + t.Run("TLSv12", func(t *testing.T) { testVerifyPeerCertificate(t, VersionTLS12) }) + t.Run("TLSv13", func(t *testing.T) { testVerifyPeerCertificate(t, VersionTLS13) }) +} + +func testVerifyPeerCertificate(t *testing.T, version uint16) { issuer, err := x509.ParseCertificate(testRSACertificateIssuer) if err != nil { panic(err) @@ -1228,7 +1537,7 @@ func TestVerifyPeerCertificate(t *testing.T) { } for i, test := range tests { - c, s := net.Pipe() + c, s := localPipe(t) done := make(chan error) var clientCalled, serverCalled bool @@ -1239,6 +1548,7 @@ func TestVerifyPeerCertificate(t *testing.T) { config.ClientAuth = RequireAndVerifyClientCert config.ClientCAs = rootCAs config.Time = now + config.MaxVersion = version test.configureServer(config, &serverCalled) err = Server(s, config).Handshake() @@ -1250,6 +1560,7 @@ func TestVerifyPeerCertificate(t *testing.T) { config.ServerName = "example.golang" config.RootCAs = rootCAs config.Time = now + config.MaxVersion = version test.configureClient(config, &clientCalled) clientErr := Client(c, config).Handshake() c.Close() @@ -1287,7 +1598,7 @@ func (b *brokenConn) Write(data []byte) (int, error) { func TestFailedWrite(t *testing.T) { // Test that a write error during the handshake is returned. for _, breakAfter := range []int{0, 1} { - c, s := net.Pipe() + c, s := localPipe(t) done := make(chan bool) go func() { @@ -1321,14 +1632,21 @@ func (wcc *writeCountingConn) Write(data []byte) (int, error) { } func TestBuffering(t *testing.T) { - c, s := net.Pipe() + t.Run("TLSv12", func(t *testing.T) { testBuffering(t, VersionTLS12) }) + t.Run("TLSv13", func(t *testing.T) { testBuffering(t, VersionTLS13) }) +} + +func testBuffering(t *testing.T, version uint16) { + c, s := localPipe(t) done := make(chan bool) clientWCC := &writeCountingConn{Conn: c} serverWCC := &writeCountingConn{Conn: s} go func() { - Server(serverWCC, testConfig).Handshake() + config := testConfig.Clone() + config.MaxVersion = version + Server(serverWCC, config).Handshake() serverWCC.Close() done <- true }() @@ -1340,17 +1658,26 @@ func TestBuffering(t *testing.T) { clientWCC.Close() <-done - if n := clientWCC.numWrites; n != 2 { - t.Errorf("expected client handshake to complete with only two writes, but saw %d", n) + var expectedClient, expectedServer int + if version == VersionTLS13 { + expectedClient = 2 + expectedServer = 1 + } else { + expectedClient = 2 + expectedServer = 2 + } + + if n := clientWCC.numWrites; n != expectedClient { + t.Errorf("expected client handshake to complete with %d writes, but saw %d", expectedClient, n) } - if n := serverWCC.numWrites; n != 2 { - t.Errorf("expected server handshake to complete with only two writes, but saw %d", n) + if n := serverWCC.numWrites; n != expectedServer { + t.Errorf("expected server handshake to complete with %d writes, but saw %d", expectedServer, n) } } func TestAlertFlushing(t *testing.T) { - c, s := net.Pipe() + c, s := localPipe(t) done := make(chan bool) clientWCC := &writeCountingConn{Conn: c} @@ -1377,17 +1704,13 @@ func TestAlertFlushing(t *testing.T) { t.Fatal("client unexpectedly returned no error") } - const expectedError = "remote error: tls: handshake failure" + const expectedError = "remote error: tls: internal error" if e := err.Error(); !strings.Contains(e, expectedError) { t.Fatalf("expected to find %q in error but error was %q", expectedError, e) } clientWCC.Close() <-done - if n := clientWCC.numWrites; n != 1 { - t.Errorf("expected client handshake to complete with one write, but saw %d", n) - } - if n := serverWCC.numWrites; n != 1 { t.Errorf("expected server handshake to complete with one write, but saw %d", n) } @@ -1399,7 +1722,7 @@ func TestHandshakeRace(t *testing.T) { // order to provide some evidence that there are no races or deadlocks // in the handshake locking. for i := 0; i < 32; i++ { - c, s := net.Pipe() + c, s := localPipe(t) go func() { server := Server(s, testConfig) @@ -1430,7 +1753,7 @@ func TestHandshakeRace(t *testing.T) { go func() { <-startRead var reply [1]byte - if n, err := client.Read(reply[:]); err != nil || n != 1 { + if _, err := io.ReadFull(client, reply[:]); err != nil { panic(err) } c.Close() @@ -1448,13 +1771,6 @@ func TestHandshakeRace(t *testing.T) { } } -func TestTLS11SignatureSchemes(t *testing.T) { - expected := tls11SignatureSchemesNumECDSA + tls11SignatureSchemesNumRSA - if expected != len(tls11SignatureSchemes) { - t.Errorf("expected to find %d TLS 1.1 signature schemes, but found %d", expected, len(tls11SignatureSchemes)) - } -} - var getClientCertificateTests = []struct { setup func(*Config, *Config) expectedClientError string @@ -1537,6 +1853,11 @@ var getClientCertificateTests = []struct { } func TestGetClientCertificate(t *testing.T) { + t.Run("TLSv12", func(t *testing.T) { testGetClientCertificate(t, VersionTLS12) }) + t.Run("TLSv13", func(t *testing.T) { testGetClientCertificate(t, VersionTLS13) }) +} + +func testGetClientCertificate(t *testing.T, version uint16) { issuer, err := x509.ParseCertificate(testRSACertificateIssuer) if err != nil { panic(err) @@ -1549,8 +1870,10 @@ func TestGetClientCertificate(t *testing.T) { serverConfig.RootCAs.AddCert(issuer) serverConfig.ClientCAs = serverConfig.RootCAs serverConfig.Time = func() time.Time { return time.Unix(1476984729, 0) } + serverConfig.MaxVersion = version clientConfig := testConfig.Clone() + clientConfig.MaxVersion = version test.setup(clientConfig, serverConfig) @@ -1559,7 +1882,7 @@ func TestGetClientCertificate(t *testing.T) { err error } - c, s := net.Pipe() + c, s := localPipe(t) done := make(chan serverResult) go func() { @@ -1598,9 +1921,9 @@ func TestGetClientCertificate(t *testing.T) { } func TestRSAPSSKeyError(t *testing.T) { - // crypto/tls does not support the rsa_pss_pss_xxx SignatureSchemes. If support for + // crypto/tls does not support the rsa_pss_pss_* SignatureSchemes. If support for // public keys with OID RSASSA-PSS is added to crypto/x509, they will be misused with - // the rsa_pss_rsae_xxx SignatureSchemes. Assert that RSASSA-PSS certificates don't + // the rsa_pss_rsae_* SignatureSchemes. Assert that RSASSA-PSS certificates don't // parse, or that they don't carry *rsa.PublicKey keys. b, _ := pem.Decode([]byte(` -----BEGIN CERTIFICATE----- @@ -1632,23 +1955,23 @@ RwBA9Xk1KBNF return } if _, ok := cert.PublicKey.(*rsa.PublicKey); ok { - t.Error("A RSA-PSS certificate was parsed like a PKCS1 one, and it will be mistakenly used with rsa_pss_rsae_xxx signature algorithms") + t.Error("A RSASSA-PSS certificate was parsed like a PKCS#1 v1.5 one, and it will be mistakenly used with rsa_pss_rsae_* signature algorithms") } } func TestCloseClientConnectionOnIdleServer(t *testing.T) { - clientConn, serverConn := net.Pipe() + clientConn, serverConn := localPipe(t) client := Client(clientConn, testConfig.Clone()) go func() { var b [1]byte serverConn.Read(b[:]) client.Close() }() - client.SetWriteDeadline(time.Now().Add(time.Second)) + client.SetWriteDeadline(time.Now().Add(time.Minute)) err := client.Handshake() if err != nil { - if !strings.Contains(err.Error(), "read/write on closed pipe") { - t.Errorf("Error expected containing 'read/write on closed pipe' but got '%s'", err.Error()) + if err, ok := err.(net.Error); ok && err.Timeout() { + t.Errorf("Expected a closed network connection error but got '%s'", err.Error()) } } else { t.Errorf("Error expected, but no error returned") diff --git a/libgo/go/crypto/tls/handshake_client_tls13.go b/libgo/go/crypto/tls/handshake_client_tls13.go new file mode 100644 index 00000000000..85715b721c0 --- /dev/null +++ b/libgo/go/crypto/tls/handshake_client_tls13.go @@ -0,0 +1,673 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package tls + +import ( + "bytes" + "crypto" + "crypto/hmac" + "crypto/rsa" + "errors" + "hash" + "sync/atomic" + "time" +) + +type clientHandshakeStateTLS13 struct { + c *Conn + serverHello *serverHelloMsg + hello *clientHelloMsg + ecdheParams ecdheParameters + + session *ClientSessionState + earlySecret []byte + binderKey []byte + + certReq *certificateRequestMsgTLS13 + usingPSK bool + sentDummyCCS bool + suite *cipherSuiteTLS13 + transcript hash.Hash + masterSecret []byte + trafficSecret []byte // client_application_traffic_secret_0 +} + +// handshake requires hs.c, hs.hello, hs.serverHello, hs.ecdheParams, and, +// optionally, hs.session, hs.earlySecret and hs.binderKey to be set. +func (hs *clientHandshakeStateTLS13) handshake() error { + c := hs.c + + // The server must not select TLS 1.3 in a renegotiation. See RFC 8446, + // sections 4.1.2 and 4.1.3. + if c.handshakes > 0 { + c.sendAlert(alertProtocolVersion) + return errors.New("tls: server selected TLS 1.3 in a renegotiation") + } + + // Consistency check on the presence of a keyShare and its parameters. + if hs.ecdheParams == nil || len(hs.hello.keyShares) != 1 { + return c.sendAlert(alertInternalError) + } + + if err := hs.checkServerHelloOrHRR(); err != nil { + return err + } + + hs.transcript = hs.suite.hash.New() + hs.transcript.Write(hs.hello.marshal()) + + if bytes.Equal(hs.serverHello.random, helloRetryRequestRandom) { + if err := hs.sendDummyChangeCipherSpec(); err != nil { + return err + } + if err := hs.processHelloRetryRequest(); err != nil { + return err + } + } + + hs.transcript.Write(hs.serverHello.marshal()) + + c.buffering = true + if err := hs.processServerHello(); err != nil { + return err + } + if err := hs.sendDummyChangeCipherSpec(); err != nil { + return err + } + if err := hs.establishHandshakeKeys(); err != nil { + return err + } + if err := hs.readServerParameters(); err != nil { + return err + } + if err := hs.readServerCertificate(); err != nil { + return err + } + if err := hs.readServerFinished(); err != nil { + return err + } + if err := hs.sendClientCertificate(); err != nil { + return err + } + if err := hs.sendClientFinished(); err != nil { + return err + } + if _, err := c.flush(); err != nil { + return err + } + + atomic.StoreUint32(&c.handshakeStatus, 1) + + return nil +} + +// checkServerHelloOrHRR does validity checks that apply to both ServerHello and +// HelloRetryRequest messages. It sets hs.suite. +func (hs *clientHandshakeStateTLS13) checkServerHelloOrHRR() error { + c := hs.c + + if hs.serverHello.supportedVersion == 0 { + c.sendAlert(alertMissingExtension) + return errors.New("tls: server selected TLS 1.3 using the legacy version field") + } + + if hs.serverHello.supportedVersion != VersionTLS13 { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: server selected an invalid version after a HelloRetryRequest") + } + + if hs.serverHello.vers != VersionTLS12 { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: server sent an incorrect legacy version") + } + + if hs.serverHello.nextProtoNeg || + len(hs.serverHello.nextProtos) != 0 || + hs.serverHello.ocspStapling || + hs.serverHello.ticketSupported || + hs.serverHello.secureRenegotiationSupported || + len(hs.serverHello.secureRenegotiation) != 0 || + len(hs.serverHello.alpnProtocol) != 0 || + len(hs.serverHello.scts) != 0 { + c.sendAlert(alertUnsupportedExtension) + return errors.New("tls: server sent a ServerHello extension forbidden in TLS 1.3") + } + + if !bytes.Equal(hs.hello.sessionId, hs.serverHello.sessionId) { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: server did not echo the legacy session ID") + } + + if hs.serverHello.compressionMethod != compressionNone { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: server selected unsupported compression format") + } + + selectedSuite := mutualCipherSuiteTLS13(hs.hello.cipherSuites, hs.serverHello.cipherSuite) + if hs.suite != nil && selectedSuite != hs.suite { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: server changed cipher suite after a HelloRetryRequest") + } + if selectedSuite == nil { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: server chose an unconfigured cipher suite") + } + hs.suite = selectedSuite + c.cipherSuite = hs.suite.id + + return nil +} + +// sendDummyChangeCipherSpec sends a ChangeCipherSpec record for compatibility +// with middleboxes that didn't implement TLS correctly. See RFC 8446, Appendix D.4. +func (hs *clientHandshakeStateTLS13) sendDummyChangeCipherSpec() error { + if hs.sentDummyCCS { + return nil + } + hs.sentDummyCCS = true + + _, err := hs.c.writeRecord(recordTypeChangeCipherSpec, []byte{1}) + return err +} + +// processHelloRetryRequest handles the HRR in hs.serverHello, modifies and +// resends hs.hello, and reads the new ServerHello into hs.serverHello. +func (hs *clientHandshakeStateTLS13) processHelloRetryRequest() error { + c := hs.c + + // The first ClientHello gets double-hashed into the transcript upon a + // HelloRetryRequest. See RFC 8446, Section 4.4.1. + chHash := hs.transcript.Sum(nil) + hs.transcript.Reset() + hs.transcript.Write([]byte{typeMessageHash, 0, 0, uint8(len(chHash))}) + hs.transcript.Write(chHash) + hs.transcript.Write(hs.serverHello.marshal()) + + if hs.serverHello.serverShare.group != 0 { + c.sendAlert(alertDecodeError) + return errors.New("tls: received malformed key_share extension") + } + + curveID := hs.serverHello.selectedGroup + if curveID == 0 { + c.sendAlert(alertMissingExtension) + return errors.New("tls: received HelloRetryRequest without selected group") + } + curveOK := false + for _, id := range hs.hello.supportedCurves { + if id == curveID { + curveOK = true + break + } + } + if !curveOK { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: server selected unsupported group") + } + if hs.ecdheParams.CurveID() == curveID { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: server sent an unnecessary HelloRetryRequest message") + } + if _, ok := curveForCurveID(curveID); curveID != X25519 && !ok { + c.sendAlert(alertInternalError) + return errors.New("tls: CurvePreferences includes unsupported curve") + } + params, err := generateECDHEParameters(c.config.rand(), curveID) + if err != nil { + c.sendAlert(alertInternalError) + return err + } + hs.ecdheParams = params + hs.hello.keyShares = []keyShare{{group: curveID, data: params.PublicKey()}} + + hs.hello.cookie = hs.serverHello.cookie + + hs.hello.raw = nil + if len(hs.hello.pskIdentities) > 0 { + pskSuite := cipherSuiteTLS13ByID(hs.session.cipherSuite) + if pskSuite == nil { + return c.sendAlert(alertInternalError) + } + if pskSuite.hash == hs.suite.hash { + // Update binders and obfuscated_ticket_age. + ticketAge := uint32(c.config.time().Sub(hs.session.receivedAt) / time.Millisecond) + hs.hello.pskIdentities[0].obfuscatedTicketAge = ticketAge + hs.session.ageAdd + + transcript := hs.suite.hash.New() + transcript.Write([]byte{typeMessageHash, 0, 0, uint8(len(chHash))}) + transcript.Write(chHash) + transcript.Write(hs.serverHello.marshal()) + transcript.Write(hs.hello.marshalWithoutBinders()) + pskBinders := [][]byte{hs.suite.finishedHash(hs.binderKey, transcript)} + hs.hello.updateBinders(pskBinders) + } else { + // Server selected a cipher suite incompatible with the PSK. + hs.hello.pskIdentities = nil + hs.hello.pskBinders = nil + } + } + + hs.transcript.Write(hs.hello.marshal()) + if _, err := c.writeRecord(recordTypeHandshake, hs.hello.marshal()); err != nil { + return err + } + + msg, err := c.readHandshake() + if err != nil { + return err + } + + serverHello, ok := msg.(*serverHelloMsg) + if !ok { + c.sendAlert(alertUnexpectedMessage) + return unexpectedMessageError(serverHello, msg) + } + hs.serverHello = serverHello + + if err := hs.checkServerHelloOrHRR(); err != nil { + return err + } + + return nil +} + +func (hs *clientHandshakeStateTLS13) processServerHello() error { + c := hs.c + + if bytes.Equal(hs.serverHello.random, helloRetryRequestRandom) { + c.sendAlert(alertUnexpectedMessage) + return errors.New("tls: server sent two HelloRetryRequest messages") + } + + if len(hs.serverHello.cookie) != 0 { + c.sendAlert(alertUnsupportedExtension) + return errors.New("tls: server sent a cookie in a normal ServerHello") + } + + if hs.serverHello.selectedGroup != 0 { + c.sendAlert(alertDecodeError) + return errors.New("tls: malformed key_share extension") + } + + if hs.serverHello.serverShare.group == 0 { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: server did not send a key share") + } + if hs.serverHello.serverShare.group != hs.ecdheParams.CurveID() { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: server selected unsupported group") + } + + if !hs.serverHello.selectedIdentityPresent { + return nil + } + + if int(hs.serverHello.selectedIdentity) >= len(hs.hello.pskIdentities) { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: server selected an invalid PSK") + } + + if len(hs.hello.pskIdentities) != 1 || hs.session == nil { + return c.sendAlert(alertInternalError) + } + pskSuite := cipherSuiteTLS13ByID(hs.session.cipherSuite) + if pskSuite == nil { + return c.sendAlert(alertInternalError) + } + if pskSuite.hash != hs.suite.hash { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: server selected an invalid PSK and cipher suite pair") + } + + hs.usingPSK = true + c.didResume = true + c.peerCertificates = hs.session.serverCertificates + c.verifiedChains = hs.session.verifiedChains + return nil +} + +func (hs *clientHandshakeStateTLS13) establishHandshakeKeys() error { + c := hs.c + + sharedKey := hs.ecdheParams.SharedKey(hs.serverHello.serverShare.data) + if sharedKey == nil { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: invalid server key share") + } + + earlySecret := hs.earlySecret + if !hs.usingPSK { + earlySecret = hs.suite.extract(nil, nil) + } + handshakeSecret := hs.suite.extract(sharedKey, + hs.suite.deriveSecret(earlySecret, "derived", nil)) + + clientSecret := hs.suite.deriveSecret(handshakeSecret, + clientHandshakeTrafficLabel, hs.transcript) + c.out.setTrafficSecret(hs.suite, clientSecret) + serverSecret := hs.suite.deriveSecret(handshakeSecret, + serverHandshakeTrafficLabel, hs.transcript) + c.in.setTrafficSecret(hs.suite, serverSecret) + + err := c.config.writeKeyLog(keyLogLabelClientHandshake, hs.hello.random, clientSecret) + if err != nil { + c.sendAlert(alertInternalError) + return err + } + err = c.config.writeKeyLog(keyLogLabelServerHandshake, hs.hello.random, serverSecret) + if err != nil { + c.sendAlert(alertInternalError) + return err + } + + hs.masterSecret = hs.suite.extract(nil, + hs.suite.deriveSecret(handshakeSecret, "derived", nil)) + + return nil +} + +func (hs *clientHandshakeStateTLS13) readServerParameters() error { + c := hs.c + + msg, err := c.readHandshake() + if err != nil { + return err + } + + encryptedExtensions, ok := msg.(*encryptedExtensionsMsg) + if !ok { + c.sendAlert(alertUnexpectedMessage) + return unexpectedMessageError(encryptedExtensions, msg) + } + hs.transcript.Write(encryptedExtensions.marshal()) + + if len(encryptedExtensions.alpnProtocol) != 0 && len(hs.hello.alpnProtocols) == 0 { + c.sendAlert(alertUnsupportedExtension) + return errors.New("tls: server advertised unrequested ALPN extension") + } + c.clientProtocol = encryptedExtensions.alpnProtocol + + return nil +} + +func (hs *clientHandshakeStateTLS13) readServerCertificate() error { + c := hs.c + + // Either a PSK or a certificate is always used, but not both. + // See RFC 8446, Section 4.1.1. + if hs.usingPSK { + return nil + } + + msg, err := c.readHandshake() + if err != nil { + return err + } + + certReq, ok := msg.(*certificateRequestMsgTLS13) + if ok { + hs.transcript.Write(certReq.marshal()) + + hs.certReq = certReq + + msg, err = c.readHandshake() + if err != nil { + return err + } + } + + certMsg, ok := msg.(*certificateMsgTLS13) + if !ok { + c.sendAlert(alertUnexpectedMessage) + return unexpectedMessageError(certMsg, msg) + } + if len(certMsg.certificate.Certificate) == 0 { + c.sendAlert(alertDecodeError) + return errors.New("tls: received empty certificates message") + } + hs.transcript.Write(certMsg.marshal()) + + c.scts = certMsg.certificate.SignedCertificateTimestamps + c.ocspResponse = certMsg.certificate.OCSPStaple + + if err := c.verifyServerCertificate(certMsg.certificate.Certificate); err != nil { + return err + } + + msg, err = c.readHandshake() + if err != nil { + return err + } + + certVerify, ok := msg.(*certificateVerifyMsg) + if !ok { + c.sendAlert(alertUnexpectedMessage) + return unexpectedMessageError(certVerify, msg) + } + + // See RFC 8446, Section 4.4.3. + if !isSupportedSignatureAlgorithm(certVerify.signatureAlgorithm, supportedSignatureAlgorithms) { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: invalid certificate signature algorithm") + } + sigType := signatureFromSignatureScheme(certVerify.signatureAlgorithm) + sigHash, err := hashFromSignatureScheme(certVerify.signatureAlgorithm) + if sigType == 0 || err != nil { + c.sendAlert(alertInternalError) + return err + } + if sigType == signaturePKCS1v15 || sigHash == crypto.SHA1 { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: invalid certificate signature algorithm") + } + h := sigHash.New() + writeSignedMessage(h, serverSignatureContext, hs.transcript) + if err := verifyHandshakeSignature(sigType, c.peerCertificates[0].PublicKey, + sigHash, h.Sum(nil), certVerify.signature); err != nil { + c.sendAlert(alertDecryptError) + return errors.New("tls: invalid certificate signature") + } + + hs.transcript.Write(certVerify.marshal()) + + return nil +} + +func (hs *clientHandshakeStateTLS13) readServerFinished() error { + c := hs.c + + msg, err := c.readHandshake() + if err != nil { + return err + } + + finished, ok := msg.(*finishedMsg) + if !ok { + c.sendAlert(alertUnexpectedMessage) + return unexpectedMessageError(finished, msg) + } + + expectedMAC := hs.suite.finishedHash(c.in.trafficSecret, hs.transcript) + if !hmac.Equal(expectedMAC, finished.verifyData) { + c.sendAlert(alertDecryptError) + return errors.New("tls: invalid server finished hash") + } + + hs.transcript.Write(finished.marshal()) + + // Derive secrets that take context through the server Finished. + + hs.trafficSecret = hs.suite.deriveSecret(hs.masterSecret, + clientApplicationTrafficLabel, hs.transcript) + serverSecret := hs.suite.deriveSecret(hs.masterSecret, + serverApplicationTrafficLabel, hs.transcript) + c.in.setTrafficSecret(hs.suite, serverSecret) + + err = c.config.writeKeyLog(keyLogLabelClientTraffic, hs.hello.random, hs.trafficSecret) + if err != nil { + c.sendAlert(alertInternalError) + return err + } + err = c.config.writeKeyLog(keyLogLabelServerTraffic, hs.hello.random, serverSecret) + if err != nil { + c.sendAlert(alertInternalError) + return err + } + + c.ekm = hs.suite.exportKeyingMaterial(hs.masterSecret, hs.transcript) + + return nil +} + +func (hs *clientHandshakeStateTLS13) sendClientCertificate() error { + c := hs.c + + if hs.certReq == nil { + return nil + } + + cert, err := c.getClientCertificate(&CertificateRequestInfo{ + AcceptableCAs: hs.certReq.certificateAuthorities, + SignatureSchemes: hs.certReq.supportedSignatureAlgorithms, + }) + if err != nil { + return err + } + + certMsg := new(certificateMsgTLS13) + + certMsg.certificate = *cert + certMsg.scts = hs.certReq.scts && len(cert.SignedCertificateTimestamps) > 0 + certMsg.ocspStapling = hs.certReq.ocspStapling && len(cert.OCSPStaple) > 0 + + hs.transcript.Write(certMsg.marshal()) + if _, err := c.writeRecord(recordTypeHandshake, certMsg.marshal()); err != nil { + return err + } + + // If we sent an empty certificate message, skip the CertificateVerify. + if len(cert.Certificate) == 0 { + return nil + } + + certVerifyMsg := new(certificateVerifyMsg) + certVerifyMsg.hasSignatureAlgorithm = true + + supportedAlgs := signatureSchemesForCertificate(c.vers, cert) + if supportedAlgs == nil { + c.sendAlert(alertInternalError) + return unsupportedCertificateError(cert) + } + // Pick signature scheme in server preference order, as the client + // preference order is not configurable. + for _, preferredAlg := range hs.certReq.supportedSignatureAlgorithms { + if isSupportedSignatureAlgorithm(preferredAlg, supportedAlgs) { + certVerifyMsg.signatureAlgorithm = preferredAlg + break + } + } + if certVerifyMsg.signatureAlgorithm == 0 { + // getClientCertificate returned a certificate incompatible with the + // CertificateRequestInfo supported signature algorithms. + c.sendAlert(alertHandshakeFailure) + return errors.New("tls: server doesn't support selected certificate") + } + + sigType := signatureFromSignatureScheme(certVerifyMsg.signatureAlgorithm) + sigHash, err := hashFromSignatureScheme(certVerifyMsg.signatureAlgorithm) + if sigType == 0 || err != nil { + return c.sendAlert(alertInternalError) + } + h := sigHash.New() + writeSignedMessage(h, clientSignatureContext, hs.transcript) + + signOpts := crypto.SignerOpts(sigHash) + if sigType == signatureRSAPSS { + signOpts = &rsa.PSSOptions{SaltLength: rsa.PSSSaltLengthEqualsHash, Hash: sigHash} + } + sig, err := cert.PrivateKey.(crypto.Signer).Sign(c.config.rand(), h.Sum(nil), signOpts) + if err != nil { + c.sendAlert(alertInternalError) + return errors.New("tls: failed to sign handshake: " + err.Error()) + } + certVerifyMsg.signature = sig + + hs.transcript.Write(certVerifyMsg.marshal()) + if _, err := c.writeRecord(recordTypeHandshake, certVerifyMsg.marshal()); err != nil { + return err + } + + return nil +} + +func (hs *clientHandshakeStateTLS13) sendClientFinished() error { + c := hs.c + + finished := &finishedMsg{ + verifyData: hs.suite.finishedHash(c.out.trafficSecret, hs.transcript), + } + + hs.transcript.Write(finished.marshal()) + if _, err := c.writeRecord(recordTypeHandshake, finished.marshal()); err != nil { + return err + } + + c.out.setTrafficSecret(hs.suite, hs.trafficSecret) + + if !c.config.SessionTicketsDisabled && c.config.ClientSessionCache != nil { + c.resumptionSecret = hs.suite.deriveSecret(hs.masterSecret, + resumptionLabel, hs.transcript) + } + + return nil +} + +func (c *Conn) handleNewSessionTicket(msg *newSessionTicketMsgTLS13) error { + if !c.isClient { + c.sendAlert(alertUnexpectedMessage) + return errors.New("tls: received new session ticket from a client") + } + + if c.config.SessionTicketsDisabled || c.config.ClientSessionCache == nil { + return nil + } + + // See RFC 8446, Section 4.6.1. + if msg.lifetime == 0 { + return nil + } + lifetime := time.Duration(msg.lifetime) * time.Second + if lifetime > maxSessionTicketLifetime { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: received a session ticket with invalid lifetime") + } + + cipherSuite := cipherSuiteTLS13ByID(c.cipherSuite) + if cipherSuite == nil || c.resumptionSecret == nil { + return c.sendAlert(alertInternalError) + } + + // Save the resumption_master_secret and nonce instead of deriving the PSK + // to do the least amount of work on NewSessionTicket messages before we + // know if the ticket will be used. Forward secrecy of resumed connections + // is guaranteed by the requirement for pskModeDHE. + session := &ClientSessionState{ + sessionTicket: msg.label, + vers: c.vers, + cipherSuite: c.cipherSuite, + masterSecret: c.resumptionSecret, + serverCertificates: c.peerCertificates, + verifiedChains: c.verifiedChains, + receivedAt: c.config.time(), + nonce: msg.nonce, + useBy: c.config.time().Add(lifetime), + ageAdd: msg.ageAdd, + } + + cacheKey := clientSessionCacheKey(c.conn.RemoteAddr(), c.config) + c.config.ClientSessionCache.Put(cacheKey, session) + + return nil +} diff --git a/libgo/go/crypto/tls/handshake_messages.go b/libgo/go/crypto/tls/handshake_messages.go index a5bf10efb8c..c0e049b16f0 100644 --- a/libgo/go/crypto/tls/handshake_messages.go +++ b/libgo/go/crypto/tls/handshake_messages.go @@ -5,55 +5,93 @@ package tls import ( - "bytes" + "fmt" + "internal/x/crypto/cryptobyte" "strings" ) -type clientHelloMsg struct { - raw []byte - vers uint16 - random []byte - sessionId []byte - cipherSuites []uint16 - compressionMethods []uint8 - nextProtoNeg bool - serverName string - ocspStapling bool - scts bool - supportedCurves []CurveID - supportedPoints []uint8 - ticketSupported bool - sessionTicket []uint8 - supportedSignatureAlgorithms []SignatureScheme - secureRenegotiation []byte - secureRenegotiationSupported bool - alpnProtocols []string +// The marshalingFunction type is an adapter to allow the use of ordinary +// functions as cryptobyte.MarshalingValue. +type marshalingFunction func(b *cryptobyte.Builder) error + +func (f marshalingFunction) Marshal(b *cryptobyte.Builder) error { + return f(b) +} + +// addBytesWithLength appends a sequence of bytes to the cryptobyte.Builder. If +// the length of the sequence is not the value specified, it produces an error. +func addBytesWithLength(b *cryptobyte.Builder, v []byte, n int) { + b.AddValue(marshalingFunction(func(b *cryptobyte.Builder) error { + if len(v) != n { + return fmt.Errorf("invalid value length: expected %d, got %d", n, len(v)) + } + b.AddBytes(v) + return nil + })) } -func (m *clientHelloMsg) equal(i interface{}) bool { - m1, ok := i.(*clientHelloMsg) - if !ok { +// addUint64 appends a big-endian, 64-bit value to the cryptobyte.Builder. +func addUint64(b *cryptobyte.Builder, v uint64) { + b.AddUint32(uint32(v >> 32)) + b.AddUint32(uint32(v)) +} + +// readUint64 decodes a big-endian, 64-bit value into out and advances over it. +// It reports whether the read was successful. +func readUint64(s *cryptobyte.String, out *uint64) bool { + var hi, lo uint32 + if !s.ReadUint32(&hi) || !s.ReadUint32(&lo) { return false } + *out = uint64(hi)<<32 | uint64(lo) + return true +} - return bytes.Equal(m.raw, m1.raw) && - m.vers == m1.vers && - bytes.Equal(m.random, m1.random) && - bytes.Equal(m.sessionId, m1.sessionId) && - eqUint16s(m.cipherSuites, m1.cipherSuites) && - bytes.Equal(m.compressionMethods, m1.compressionMethods) && - m.nextProtoNeg == m1.nextProtoNeg && - m.serverName == m1.serverName && - m.ocspStapling == m1.ocspStapling && - m.scts == m1.scts && - eqCurveIDs(m.supportedCurves, m1.supportedCurves) && - bytes.Equal(m.supportedPoints, m1.supportedPoints) && - m.ticketSupported == m1.ticketSupported && - bytes.Equal(m.sessionTicket, m1.sessionTicket) && - eqSignatureAlgorithms(m.supportedSignatureAlgorithms, m1.supportedSignatureAlgorithms) && - m.secureRenegotiationSupported == m1.secureRenegotiationSupported && - bytes.Equal(m.secureRenegotiation, m1.secureRenegotiation) && - eqStrings(m.alpnProtocols, m1.alpnProtocols) +// readUint8LengthPrefixed acts like s.ReadUint8LengthPrefixed, but targets a +// []byte instead of a cryptobyte.String. +func readUint8LengthPrefixed(s *cryptobyte.String, out *[]byte) bool { + return s.ReadUint8LengthPrefixed((*cryptobyte.String)(out)) +} + +// readUint16LengthPrefixed acts like s.ReadUint16LengthPrefixed, but targets a +// []byte instead of a cryptobyte.String. +func readUint16LengthPrefixed(s *cryptobyte.String, out *[]byte) bool { + return s.ReadUint16LengthPrefixed((*cryptobyte.String)(out)) +} + +// readUint24LengthPrefixed acts like s.ReadUint24LengthPrefixed, but targets a +// []byte instead of a cryptobyte.String. +func readUint24LengthPrefixed(s *cryptobyte.String, out *[]byte) bool { + return s.ReadUint24LengthPrefixed((*cryptobyte.String)(out)) +} + +type clientHelloMsg struct { + raw []byte + vers uint16 + random []byte + sessionId []byte + cipherSuites []uint16 + compressionMethods []uint8 + nextProtoNeg bool + serverName string + ocspStapling bool + supportedCurves []CurveID + supportedPoints []uint8 + ticketSupported bool + sessionTicket []uint8 + supportedSignatureAlgorithms []SignatureScheme + supportedSignatureAlgorithmsCert []SignatureScheme + secureRenegotiationSupported bool + secureRenegotiation []byte + alpnProtocols []string + scts bool + supportedVersions []uint16 + cookie []byte + keyShares []keyShare + earlyData bool + pskModes []uint8 + pskIdentities []pskIdentity + pskBinders [][]byte } func (m *clientHelloMsg) marshal() []byte { @@ -61,443 +99,499 @@ func (m *clientHelloMsg) marshal() []byte { return m.raw } - length := 2 + 32 + 1 + len(m.sessionId) + 2 + len(m.cipherSuites)*2 + 1 + len(m.compressionMethods) - numExtensions := 0 - extensionsLength := 0 - if m.nextProtoNeg { - numExtensions++ - } - if m.ocspStapling { - extensionsLength += 1 + 2 + 2 - numExtensions++ - } - if len(m.serverName) > 0 { - extensionsLength += 5 + len(m.serverName) - numExtensions++ - } - if len(m.supportedCurves) > 0 { - extensionsLength += 2 + 2*len(m.supportedCurves) - numExtensions++ - } - if len(m.supportedPoints) > 0 { - extensionsLength += 1 + len(m.supportedPoints) - numExtensions++ - } - if m.ticketSupported { - extensionsLength += len(m.sessionTicket) - numExtensions++ - } - if len(m.supportedSignatureAlgorithms) > 0 { - extensionsLength += 2 + 2*len(m.supportedSignatureAlgorithms) - numExtensions++ - } - if m.secureRenegotiationSupported { - extensionsLength += 1 + len(m.secureRenegotiation) - numExtensions++ - } - if len(m.alpnProtocols) > 0 { - extensionsLength += 2 - for _, s := range m.alpnProtocols { - if l := len(s); l == 0 || l > 255 { - panic("invalid ALPN protocol") + var b cryptobyte.Builder + b.AddUint8(typeClientHello) + b.AddUint24LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint16(m.vers) + addBytesWithLength(b, m.random, 32) + b.AddUint8LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(m.sessionId) + }) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + for _, suite := range m.cipherSuites { + b.AddUint16(suite) + } + }) + b.AddUint8LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(m.compressionMethods) + }) + + // If extensions aren't present, omit them. + var extensionsPresent bool + bWithoutExtensions := *b + + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + if m.nextProtoNeg { + // draft-agl-tls-nextprotoneg-04 + b.AddUint16(extensionNextProtoNeg) + b.AddUint16(0) // empty extension_data + } + if len(m.serverName) > 0 { + // RFC 6066, Section 3 + b.AddUint16(extensionServerName) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint8(0) // name_type = host_name + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes([]byte(m.serverName)) + }) + }) + }) + } + if m.ocspStapling { + // RFC 4366, Section 3.6 + b.AddUint16(extensionStatusRequest) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint8(1) // status_type = ocsp + b.AddUint16(0) // empty responder_id_list + b.AddUint16(0) // empty request_extensions + }) + } + if len(m.supportedCurves) > 0 { + // RFC 4492, sections 5.1.1 and RFC 8446, Section 4.2.7 + b.AddUint16(extensionSupportedCurves) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + for _, curve := range m.supportedCurves { + b.AddUint16(uint16(curve)) + } + }) + }) + } + if len(m.supportedPoints) > 0 { + // RFC 4492, Section 5.1.2 + b.AddUint16(extensionSupportedPoints) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint8LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(m.supportedPoints) + }) + }) + } + if m.ticketSupported { + // RFC 5077, Section 3.2 + b.AddUint16(extensionSessionTicket) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(m.sessionTicket) + }) + } + if len(m.supportedSignatureAlgorithms) > 0 { + // RFC 5246, Section 7.4.1.4.1 + b.AddUint16(extensionSignatureAlgorithms) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + for _, sigAlgo := range m.supportedSignatureAlgorithms { + b.AddUint16(uint16(sigAlgo)) + } + }) + }) + } + if len(m.supportedSignatureAlgorithmsCert) > 0 { + // RFC 8446, Section 4.2.3 + b.AddUint16(extensionSignatureAlgorithmsCert) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + for _, sigAlgo := range m.supportedSignatureAlgorithmsCert { + b.AddUint16(uint16(sigAlgo)) + } + }) + }) + } + if m.secureRenegotiationSupported { + // RFC 5746, Section 3.2 + b.AddUint16(extensionRenegotiationInfo) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint8LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(m.secureRenegotiation) + }) + }) + } + if len(m.alpnProtocols) > 0 { + // RFC 7301, Section 3.1 + b.AddUint16(extensionALPN) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + for _, proto := range m.alpnProtocols { + b.AddUint8LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes([]byte(proto)) + }) + } + }) + }) + } + if m.scts { + // RFC 6962, Section 3.3.1 + b.AddUint16(extensionSCT) + b.AddUint16(0) // empty extension_data + } + if len(m.supportedVersions) > 0 { + // RFC 8446, Section 4.2.1 + b.AddUint16(extensionSupportedVersions) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint8LengthPrefixed(func(b *cryptobyte.Builder) { + for _, vers := range m.supportedVersions { + b.AddUint16(vers) + } + }) + }) + } + if len(m.cookie) > 0 { + // RFC 8446, Section 4.2.2 + b.AddUint16(extensionCookie) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(m.cookie) + }) + }) + } + if len(m.keyShares) > 0 { + // RFC 8446, Section 4.2.8 + b.AddUint16(extensionKeyShare) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + for _, ks := range m.keyShares { + b.AddUint16(uint16(ks.group)) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(ks.data) + }) + } + }) + }) + } + if m.earlyData { + // RFC 8446, Section 4.2.10 + b.AddUint16(extensionEarlyData) + b.AddUint16(0) // empty extension_data + } + if len(m.pskModes) > 0 { + // RFC 8446, Section 4.2.9 + b.AddUint16(extensionPSKModes) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint8LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(m.pskModes) + }) + }) + } + if len(m.pskIdentities) > 0 { // pre_shared_key must be the last extension + // RFC 8446, Section 4.2.11 + b.AddUint16(extensionPreSharedKey) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + for _, psk := range m.pskIdentities { + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(psk.label) + }) + b.AddUint32(psk.obfuscatedTicketAge) + } + }) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + for _, binder := range m.pskBinders { + b.AddUint8LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(binder) + }) + } + }) + }) } - extensionsLength++ - extensionsLength += len(s) - } - numExtensions++ - } - if m.scts { - numExtensions++ - } - if numExtensions > 0 { - extensionsLength += 4 * numExtensions - length += 2 + extensionsLength - } - x := make([]byte, 4+length) - x[0] = typeClientHello - x[1] = uint8(length >> 16) - x[2] = uint8(length >> 8) - x[3] = uint8(length) - x[4] = uint8(m.vers >> 8) - x[5] = uint8(m.vers) - copy(x[6:38], m.random) - x[38] = uint8(len(m.sessionId)) - copy(x[39:39+len(m.sessionId)], m.sessionId) - y := x[39+len(m.sessionId):] - y[0] = uint8(len(m.cipherSuites) >> 7) - y[1] = uint8(len(m.cipherSuites) << 1) - for i, suite := range m.cipherSuites { - y[2+i*2] = uint8(suite >> 8) - y[3+i*2] = uint8(suite) - } - z := y[2+len(m.cipherSuites)*2:] - z[0] = uint8(len(m.compressionMethods)) - copy(z[1:], m.compressionMethods) - - z = z[1+len(m.compressionMethods):] - if numExtensions > 0 { - z[0] = byte(extensionsLength >> 8) - z[1] = byte(extensionsLength) - z = z[2:] - } - if m.nextProtoNeg { - z[0] = byte(extensionNextProtoNeg >> 8) - z[1] = byte(extensionNextProtoNeg & 0xff) - // The length is always 0 - z = z[4:] - } - if len(m.serverName) > 0 { - z[0] = byte(extensionServerName >> 8) - z[1] = byte(extensionServerName & 0xff) - l := len(m.serverName) + 5 - z[2] = byte(l >> 8) - z[3] = byte(l) - z = z[4:] - - // RFC 3546, section 3.1 - // - // struct { - // NameType name_type; - // select (name_type) { - // case host_name: HostName; - // } name; - // } ServerName; - // - // enum { - // host_name(0), (255) - // } NameType; - // - // opaque HostName<1..2^16-1>; - // - // struct { - // ServerName server_name_list<1..2^16-1> - // } ServerNameList; - - z[0] = byte((len(m.serverName) + 3) >> 8) - z[1] = byte(len(m.serverName) + 3) - z[3] = byte(len(m.serverName) >> 8) - z[4] = byte(len(m.serverName)) - copy(z[5:], []byte(m.serverName)) - z = z[l:] - } - if m.ocspStapling { - // RFC 4366, section 3.6 - z[0] = byte(extensionStatusRequest >> 8) - z[1] = byte(extensionStatusRequest) - z[2] = 0 - z[3] = 5 - z[4] = 1 // OCSP type - // Two zero valued uint16s for the two lengths. - z = z[9:] - } - if len(m.supportedCurves) > 0 { - // https://tools.ietf.org/html/rfc4492#section-5.5.1 - z[0] = byte(extensionSupportedCurves >> 8) - z[1] = byte(extensionSupportedCurves) - l := 2 + 2*len(m.supportedCurves) - z[2] = byte(l >> 8) - z[3] = byte(l) - l -= 2 - z[4] = byte(l >> 8) - z[5] = byte(l) - z = z[6:] - for _, curve := range m.supportedCurves { - z[0] = byte(curve >> 8) - z[1] = byte(curve) - z = z[2:] + extensionsPresent = len(b.BytesOrPanic()) > 2 + }) + + if !extensionsPresent { + *b = bWithoutExtensions } + }) + + m.raw = b.BytesOrPanic() + return m.raw +} + +// marshalWithoutBinders returns the ClientHello through the +// PreSharedKeyExtension.identities field, according to RFC 8446, Section +// 4.2.11.2. Note that m.pskBinders must be set to slices of the correct length. +func (m *clientHelloMsg) marshalWithoutBinders() []byte { + bindersLen := 2 // uint16 length prefix + for _, binder := range m.pskBinders { + bindersLen += 1 // uint8 length prefix + bindersLen += len(binder) } - if len(m.supportedPoints) > 0 { - // https://tools.ietf.org/html/rfc4492#section-5.5.2 - z[0] = byte(extensionSupportedPoints >> 8) - z[1] = byte(extensionSupportedPoints) - l := 1 + len(m.supportedPoints) - z[2] = byte(l >> 8) - z[3] = byte(l) - l-- - z[4] = byte(l) - z = z[5:] - for _, pointFormat := range m.supportedPoints { - z[0] = pointFormat - z = z[1:] - } + + fullMessage := m.marshal() + return fullMessage[:len(fullMessage)-bindersLen] +} + +// updateBinders updates the m.pskBinders field, if necessary updating the +// cached marshalled representation. The supplied binders must have the same +// length as the current m.pskBinders. +func (m *clientHelloMsg) updateBinders(pskBinders [][]byte) { + if len(pskBinders) != len(m.pskBinders) { + panic("tls: internal error: pskBinders length mismatch") } - if m.ticketSupported { - // https://tools.ietf.org/html/rfc5077#section-3.2 - z[0] = byte(extensionSessionTicket >> 8) - z[1] = byte(extensionSessionTicket) - l := len(m.sessionTicket) - z[2] = byte(l >> 8) - z[3] = byte(l) - z = z[4:] - copy(z, m.sessionTicket) - z = z[len(m.sessionTicket):] - } - if len(m.supportedSignatureAlgorithms) > 0 { - // https://tools.ietf.org/html/rfc5246#section-7.4.1.4.1 - z[0] = byte(extensionSignatureAlgorithms >> 8) - z[1] = byte(extensionSignatureAlgorithms) - l := 2 + 2*len(m.supportedSignatureAlgorithms) - z[2] = byte(l >> 8) - z[3] = byte(l) - z = z[4:] - - l -= 2 - z[0] = byte(l >> 8) - z[1] = byte(l) - z = z[2:] - for _, sigAlgo := range m.supportedSignatureAlgorithms { - z[0] = byte(sigAlgo >> 8) - z[1] = byte(sigAlgo) - z = z[2:] + for i := range m.pskBinders { + if len(pskBinders[i]) != len(m.pskBinders[i]) { + panic("tls: internal error: pskBinders length mismatch") } } - if m.secureRenegotiationSupported { - z[0] = byte(extensionRenegotiationInfo >> 8) - z[1] = byte(extensionRenegotiationInfo & 0xff) - z[2] = 0 - z[3] = byte(len(m.secureRenegotiation) + 1) - z[4] = byte(len(m.secureRenegotiation)) - z = z[5:] - copy(z, m.secureRenegotiation) - z = z[len(m.secureRenegotiation):] - } - if len(m.alpnProtocols) > 0 { - z[0] = byte(extensionALPN >> 8) - z[1] = byte(extensionALPN & 0xff) - lengths := z[2:] - z = z[6:] - - stringsLength := 0 - for _, s := range m.alpnProtocols { - l := len(s) - z[0] = byte(l) - copy(z[1:], s) - z = z[1+l:] - stringsLength += 1 + l + m.pskBinders = pskBinders + if m.raw != nil { + lenWithoutBinders := len(m.marshalWithoutBinders()) + // TODO(filippo): replace with NewFixedBuilder once CL 148882 is imported. + b := cryptobyte.NewBuilder(m.raw[:lenWithoutBinders]) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + for _, binder := range m.pskBinders { + b.AddUint8LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(binder) + }) + } + }) + if len(b.BytesOrPanic()) != len(m.raw) { + panic("tls: internal error: failed to update binders") } - - lengths[2] = byte(stringsLength >> 8) - lengths[3] = byte(stringsLength) - stringsLength += 2 - lengths[0] = byte(stringsLength >> 8) - lengths[1] = byte(stringsLength) - } - if m.scts { - // https://tools.ietf.org/html/rfc6962#section-3.3.1 - z[0] = byte(extensionSCT >> 8) - z[1] = byte(extensionSCT) - // zero uint16 for the zero-length extension_data - z = z[4:] } - - m.raw = x - - return x } func (m *clientHelloMsg) unmarshal(data []byte) bool { - if len(data) < 42 { - return false - } - m.raw = data - m.vers = uint16(data[4])<<8 | uint16(data[5]) - m.random = data[6:38] - sessionIdLen := int(data[38]) - if sessionIdLen > 32 || len(data) < 39+sessionIdLen { - return false - } - m.sessionId = data[39 : 39+sessionIdLen] - data = data[39+sessionIdLen:] - if len(data) < 2 { + *m = clientHelloMsg{raw: data} + s := cryptobyte.String(data) + + if !s.Skip(4) || // message type and uint24 length field + !s.ReadUint16(&m.vers) || !s.ReadBytes(&m.random, 32) || + !readUint8LengthPrefixed(&s, &m.sessionId) { return false } - // cipherSuiteLen is the number of bytes of cipher suite numbers. Since - // they are uint16s, the number must be even. - cipherSuiteLen := int(data[0])<<8 | int(data[1]) - if cipherSuiteLen%2 == 1 || len(data) < 2+cipherSuiteLen { + + var cipherSuites cryptobyte.String + if !s.ReadUint16LengthPrefixed(&cipherSuites) { return false } - numCipherSuites := cipherSuiteLen / 2 - m.cipherSuites = make([]uint16, numCipherSuites) - for i := 0; i < numCipherSuites; i++ { - m.cipherSuites[i] = uint16(data[2+2*i])<<8 | uint16(data[3+2*i]) - if m.cipherSuites[i] == scsvRenegotiation { + m.cipherSuites = []uint16{} + m.secureRenegotiationSupported = false + for !cipherSuites.Empty() { + var suite uint16 + if !cipherSuites.ReadUint16(&suite) { + return false + } + if suite == scsvRenegotiation { m.secureRenegotiationSupported = true } + m.cipherSuites = append(m.cipherSuites, suite) } - data = data[2+cipherSuiteLen:] - if len(data) < 1 { - return false - } - compressionMethodsLen := int(data[0]) - if len(data) < 1+compressionMethodsLen { + + if !readUint8LengthPrefixed(&s, &m.compressionMethods) { return false } - m.compressionMethods = data[1 : 1+compressionMethodsLen] - - data = data[1+compressionMethodsLen:] - m.nextProtoNeg = false - m.serverName = "" - m.ocspStapling = false - m.ticketSupported = false - m.sessionTicket = nil - m.supportedSignatureAlgorithms = nil - m.alpnProtocols = nil - m.scts = false - - if len(data) == 0 { + if s.Empty() { // ClientHello is optionally followed by extension data return true } - if len(data) < 2 { - return false - } - extensionsLength := int(data[0])<<8 | int(data[1]) - data = data[2:] - if extensionsLength != len(data) { + var extensions cryptobyte.String + if !s.ReadUint16LengthPrefixed(&extensions) || !s.Empty() { return false } - for len(data) != 0 { - if len(data) < 4 { - return false - } - extension := uint16(data[0])<<8 | uint16(data[1]) - length := int(data[2])<<8 | int(data[3]) - data = data[4:] - if len(data) < length { + for !extensions.Empty() { + var extension uint16 + var extData cryptobyte.String + if !extensions.ReadUint16(&extension) || + !extensions.ReadUint16LengthPrefixed(&extData) { return false } switch extension { case extensionServerName: - d := data[:length] - if len(d) < 2 { - return false - } - namesLen := int(d[0])<<8 | int(d[1]) - d = d[2:] - if len(d) != namesLen { + // RFC 6066, Section 3 + var nameList cryptobyte.String + if !extData.ReadUint16LengthPrefixed(&nameList) || nameList.Empty() { return false } - for len(d) > 0 { - if len(d) < 3 { + for !nameList.Empty() { + var nameType uint8 + var serverName cryptobyte.String + if !nameList.ReadUint8(&nameType) || + !nameList.ReadUint16LengthPrefixed(&serverName) || + serverName.Empty() { return false } - nameType := d[0] - nameLen := int(d[1])<<8 | int(d[2]) - d = d[3:] - if len(d) < nameLen { + if nameType != 0 { + continue + } + if len(m.serverName) != 0 { + // Multiple names of the same name_type are prohibited. return false } - if nameType == 0 { - m.serverName = string(d[:nameLen]) - // An SNI value may not include a - // trailing dot. See - // https://tools.ietf.org/html/rfc6066#section-3. - if strings.HasSuffix(m.serverName, ".") { - return false - } - break + m.serverName = string(serverName) + // An SNI value may not include a trailing dot. + if strings.HasSuffix(m.serverName, ".") { + return false } - d = d[nameLen:] } case extensionNextProtoNeg: - if length > 0 { - return false - } + // draft-agl-tls-nextprotoneg-04 m.nextProtoNeg = true case extensionStatusRequest: - m.ocspStapling = length > 0 && data[0] == statusTypeOCSP - case extensionSupportedCurves: - // https://tools.ietf.org/html/rfc4492#section-5.5.1 - if length < 2 { + // RFC 4366, Section 3.6 + var statusType uint8 + var ignored cryptobyte.String + if !extData.ReadUint8(&statusType) || + !extData.ReadUint16LengthPrefixed(&ignored) || + !extData.ReadUint16LengthPrefixed(&ignored) { return false } - l := int(data[0])<<8 | int(data[1]) - if l%2 == 1 || length != l+2 { + m.ocspStapling = statusType == statusTypeOCSP + case extensionSupportedCurves: + // RFC 4492, sections 5.1.1 and RFC 8446, Section 4.2.7 + var curves cryptobyte.String + if !extData.ReadUint16LengthPrefixed(&curves) || curves.Empty() { return false } - numCurves := l / 2 - m.supportedCurves = make([]CurveID, numCurves) - d := data[2:] - for i := 0; i < numCurves; i++ { - m.supportedCurves[i] = CurveID(d[0])<<8 | CurveID(d[1]) - d = d[2:] + for !curves.Empty() { + var curve uint16 + if !curves.ReadUint16(&curve) { + return false + } + m.supportedCurves = append(m.supportedCurves, CurveID(curve)) } case extensionSupportedPoints: - // https://tools.ietf.org/html/rfc4492#section-5.5.2 - if length < 1 { - return false - } - l := int(data[0]) - if length != l+1 { + // RFC 4492, Section 5.1.2 + if !readUint8LengthPrefixed(&extData, &m.supportedPoints) || + len(m.supportedPoints) == 0 { return false } - m.supportedPoints = make([]uint8, l) - copy(m.supportedPoints, data[1:]) case extensionSessionTicket: - // https://tools.ietf.org/html/rfc5077#section-3.2 + // RFC 5077, Section 3.2 m.ticketSupported = true - m.sessionTicket = data[:length] + extData.ReadBytes(&m.sessionTicket, len(extData)) case extensionSignatureAlgorithms: - // https://tools.ietf.org/html/rfc5246#section-7.4.1.4.1 - if length < 2 || length&1 != 0 { + // RFC 5246, Section 7.4.1.4.1 + var sigAndAlgs cryptobyte.String + if !extData.ReadUint16LengthPrefixed(&sigAndAlgs) || sigAndAlgs.Empty() { return false } - l := int(data[0])<<8 | int(data[1]) - if l != length-2 { + for !sigAndAlgs.Empty() { + var sigAndAlg uint16 + if !sigAndAlgs.ReadUint16(&sigAndAlg) { + return false + } + m.supportedSignatureAlgorithms = append( + m.supportedSignatureAlgorithms, SignatureScheme(sigAndAlg)) + } + case extensionSignatureAlgorithmsCert: + // RFC 8446, Section 4.2.3 + var sigAndAlgs cryptobyte.String + if !extData.ReadUint16LengthPrefixed(&sigAndAlgs) || sigAndAlgs.Empty() { return false } - n := l / 2 - d := data[2:] - m.supportedSignatureAlgorithms = make([]SignatureScheme, n) - for i := range m.supportedSignatureAlgorithms { - m.supportedSignatureAlgorithms[i] = SignatureScheme(d[0])<<8 | SignatureScheme(d[1]) - d = d[2:] + for !sigAndAlgs.Empty() { + var sigAndAlg uint16 + if !sigAndAlgs.ReadUint16(&sigAndAlg) { + return false + } + m.supportedSignatureAlgorithmsCert = append( + m.supportedSignatureAlgorithmsCert, SignatureScheme(sigAndAlg)) } case extensionRenegotiationInfo: - if length == 0 { - return false - } - d := data[:length] - l := int(d[0]) - d = d[1:] - if l != len(d) { + // RFC 5746, Section 3.2 + if !readUint8LengthPrefixed(&extData, &m.secureRenegotiation) { return false } - - m.secureRenegotiation = d m.secureRenegotiationSupported = true case extensionALPN: - if length < 2 { + // RFC 7301, Section 3.1 + var protoList cryptobyte.String + if !extData.ReadUint16LengthPrefixed(&protoList) || protoList.Empty() { return false } - l := int(data[0])<<8 | int(data[1]) - if l != length-2 { - return false - } - d := data[2:length] - for len(d) != 0 { - stringLen := int(d[0]) - d = d[1:] - if stringLen == 0 || stringLen > len(d) { + for !protoList.Empty() { + var proto cryptobyte.String + if !protoList.ReadUint8LengthPrefixed(&proto) || proto.Empty() { return false } - m.alpnProtocols = append(m.alpnProtocols, string(d[:stringLen])) - d = d[stringLen:] + m.alpnProtocols = append(m.alpnProtocols, string(proto)) } case extensionSCT: + // RFC 6962, Section 3.3.1 m.scts = true - if length != 0 { + case extensionSupportedVersions: + // RFC 8446, Section 4.2.1 + var versList cryptobyte.String + if !extData.ReadUint8LengthPrefixed(&versList) || versList.Empty() { return false } + for !versList.Empty() { + var vers uint16 + if !versList.ReadUint16(&vers) { + return false + } + m.supportedVersions = append(m.supportedVersions, vers) + } + case extensionCookie: + // RFC 8446, Section 4.2.2 + if !readUint16LengthPrefixed(&extData, &m.cookie) || + len(m.cookie) == 0 { + return false + } + case extensionKeyShare: + // RFC 8446, Section 4.2.8 + var clientShares cryptobyte.String + if !extData.ReadUint16LengthPrefixed(&clientShares) { + return false + } + for !clientShares.Empty() { + var ks keyShare + if !clientShares.ReadUint16((*uint16)(&ks.group)) || + !readUint16LengthPrefixed(&clientShares, &ks.data) || + len(ks.data) == 0 { + return false + } + m.keyShares = append(m.keyShares, ks) + } + case extensionEarlyData: + // RFC 8446, Section 4.2.10 + m.earlyData = true + case extensionPSKModes: + // RFC 8446, Section 4.2.9 + if !readUint8LengthPrefixed(&extData, &m.pskModes) { + return false + } + case extensionPreSharedKey: + // RFC 8446, Section 4.2.11 + if !extensions.Empty() { + return false // pre_shared_key must be the last extension + } + var identities cryptobyte.String + if !extData.ReadUint16LengthPrefixed(&identities) || identities.Empty() { + return false + } + for !identities.Empty() { + var psk pskIdentity + if !readUint16LengthPrefixed(&identities, &psk.label) || + !identities.ReadUint32(&psk.obfuscatedTicketAge) || + len(psk.label) == 0 { + return false + } + m.pskIdentities = append(m.pskIdentities, psk) + } + var binders cryptobyte.String + if !extData.ReadUint16LengthPrefixed(&binders) || binders.Empty() { + return false + } + for !binders.Empty() { + var binder []byte + if !readUint8LengthPrefixed(&binders, &binder) || + len(binder) == 0 { + return false + } + m.pskBinders = append(m.pskBinders, binder) + } + default: + // Ignore unknown extensions. + continue + } + + if !extData.Empty() { + return false } - data = data[length:] } return true @@ -513,322 +607,609 @@ type serverHelloMsg struct { nextProtoNeg bool nextProtos []string ocspStapling bool - scts [][]byte ticketSupported bool - secureRenegotiation []byte secureRenegotiationSupported bool + secureRenegotiation []byte alpnProtocol string + scts [][]byte + supportedVersion uint16 + serverShare keyShare + selectedIdentityPresent bool + selectedIdentity uint16 + + // HelloRetryRequest extensions + cookie []byte + selectedGroup CurveID } -func (m *serverHelloMsg) equal(i interface{}) bool { - m1, ok := i.(*serverHelloMsg) - if !ok { +func (m *serverHelloMsg) marshal() []byte { + if m.raw != nil { + return m.raw + } + + var b cryptobyte.Builder + b.AddUint8(typeServerHello) + b.AddUint24LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint16(m.vers) + addBytesWithLength(b, m.random, 32) + b.AddUint8LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(m.sessionId) + }) + b.AddUint16(m.cipherSuite) + b.AddUint8(m.compressionMethod) + + // If extensions aren't present, omit them. + var extensionsPresent bool + bWithoutExtensions := *b + + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + if m.nextProtoNeg { + b.AddUint16(extensionNextProtoNeg) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + for _, proto := range m.nextProtos { + b.AddUint8LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes([]byte(proto)) + }) + } + }) + } + if m.ocspStapling { + b.AddUint16(extensionStatusRequest) + b.AddUint16(0) // empty extension_data + } + if m.ticketSupported { + b.AddUint16(extensionSessionTicket) + b.AddUint16(0) // empty extension_data + } + if m.secureRenegotiationSupported { + b.AddUint16(extensionRenegotiationInfo) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint8LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(m.secureRenegotiation) + }) + }) + } + if len(m.alpnProtocol) > 0 { + b.AddUint16(extensionALPN) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint8LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes([]byte(m.alpnProtocol)) + }) + }) + }) + } + if len(m.scts) > 0 { + b.AddUint16(extensionSCT) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + for _, sct := range m.scts { + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(sct) + }) + } + }) + }) + } + if m.supportedVersion != 0 { + b.AddUint16(extensionSupportedVersions) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint16(m.supportedVersion) + }) + } + if m.serverShare.group != 0 { + b.AddUint16(extensionKeyShare) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint16(uint16(m.serverShare.group)) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(m.serverShare.data) + }) + }) + } + if m.selectedIdentityPresent { + b.AddUint16(extensionPreSharedKey) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint16(m.selectedIdentity) + }) + } + + if len(m.cookie) > 0 { + b.AddUint16(extensionCookie) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(m.cookie) + }) + }) + } + if m.selectedGroup != 0 { + b.AddUint16(extensionKeyShare) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint16(uint16(m.selectedGroup)) + }) + } + + extensionsPresent = len(b.BytesOrPanic()) > 2 + }) + + if !extensionsPresent { + *b = bWithoutExtensions + } + }) + + m.raw = b.BytesOrPanic() + return m.raw +} + +func (m *serverHelloMsg) unmarshal(data []byte) bool { + *m = serverHelloMsg{raw: data} + s := cryptobyte.String(data) + + if !s.Skip(4) || // message type and uint24 length field + !s.ReadUint16(&m.vers) || !s.ReadBytes(&m.random, 32) || + !readUint8LengthPrefixed(&s, &m.sessionId) || + !s.ReadUint16(&m.cipherSuite) || + !s.ReadUint8(&m.compressionMethod) { return false } - if len(m.scts) != len(m1.scts) { + if s.Empty() { + // ServerHello is optionally followed by extension data + return true + } + + var extensions cryptobyte.String + if !s.ReadUint16LengthPrefixed(&extensions) || !s.Empty() { return false } - for i, sct := range m.scts { - if !bytes.Equal(sct, m1.scts[i]) { + + for !extensions.Empty() { + var extension uint16 + var extData cryptobyte.String + if !extensions.ReadUint16(&extension) || + !extensions.ReadUint16LengthPrefixed(&extData) { + return false + } + + switch extension { + case extensionNextProtoNeg: + m.nextProtoNeg = true + for !extData.Empty() { + var proto cryptobyte.String + if !extData.ReadUint8LengthPrefixed(&proto) || + proto.Empty() { + return false + } + m.nextProtos = append(m.nextProtos, string(proto)) + } + case extensionStatusRequest: + m.ocspStapling = true + case extensionSessionTicket: + m.ticketSupported = true + case extensionRenegotiationInfo: + if !readUint8LengthPrefixed(&extData, &m.secureRenegotiation) { + return false + } + m.secureRenegotiationSupported = true + case extensionALPN: + var protoList cryptobyte.String + if !extData.ReadUint16LengthPrefixed(&protoList) || protoList.Empty() { + return false + } + var proto cryptobyte.String + if !protoList.ReadUint8LengthPrefixed(&proto) || + proto.Empty() || !protoList.Empty() { + return false + } + m.alpnProtocol = string(proto) + case extensionSCT: + var sctList cryptobyte.String + if !extData.ReadUint16LengthPrefixed(&sctList) || sctList.Empty() { + return false + } + for !sctList.Empty() { + var sct []byte + if !readUint16LengthPrefixed(&sctList, &sct) || + len(sct) == 0 { + return false + } + m.scts = append(m.scts, sct) + } + case extensionSupportedVersions: + if !extData.ReadUint16(&m.supportedVersion) { + return false + } + case extensionCookie: + if !readUint16LengthPrefixed(&extData, &m.cookie) || + len(m.cookie) == 0 { + return false + } + case extensionKeyShare: + // This extension has different formats in SH and HRR, accept either + // and let the handshake logic decide. See RFC 8446, Section 4.2.8. + if len(extData) == 2 { + if !extData.ReadUint16((*uint16)(&m.selectedGroup)) { + return false + } + } else { + if !extData.ReadUint16((*uint16)(&m.serverShare.group)) || + !readUint16LengthPrefixed(&extData, &m.serverShare.data) { + return false + } + } + case extensionPreSharedKey: + m.selectedIdentityPresent = true + if !extData.ReadUint16(&m.selectedIdentity) { + return false + } + default: + // Ignore unknown extensions. + continue + } + + if !extData.Empty() { return false } } - return bytes.Equal(m.raw, m1.raw) && - m.vers == m1.vers && - bytes.Equal(m.random, m1.random) && - bytes.Equal(m.sessionId, m1.sessionId) && - m.cipherSuite == m1.cipherSuite && - m.compressionMethod == m1.compressionMethod && - m.nextProtoNeg == m1.nextProtoNeg && - eqStrings(m.nextProtos, m1.nextProtos) && - m.ocspStapling == m1.ocspStapling && - m.ticketSupported == m1.ticketSupported && - m.secureRenegotiationSupported == m1.secureRenegotiationSupported && - bytes.Equal(m.secureRenegotiation, m1.secureRenegotiation) && - m.alpnProtocol == m1.alpnProtocol + return true +} + +type encryptedExtensionsMsg struct { + raw []byte + alpnProtocol string } -func (m *serverHelloMsg) marshal() []byte { +func (m *encryptedExtensionsMsg) marshal() []byte { if m.raw != nil { return m.raw } - length := 38 + len(m.sessionId) - numExtensions := 0 - extensionsLength := 0 + var b cryptobyte.Builder + b.AddUint8(typeEncryptedExtensions) + b.AddUint24LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + if len(m.alpnProtocol) > 0 { + b.AddUint16(extensionALPN) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint8LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes([]byte(m.alpnProtocol)) + }) + }) + }) + } + }) + }) + + m.raw = b.BytesOrPanic() + return m.raw +} - nextProtoLen := 0 - if m.nextProtoNeg { - numExtensions++ - for _, v := range m.nextProtos { - nextProtoLen += len(v) - } - nextProtoLen += len(m.nextProtos) - extensionsLength += nextProtoLen - } - if m.ocspStapling { - numExtensions++ +func (m *encryptedExtensionsMsg) unmarshal(data []byte) bool { + *m = encryptedExtensionsMsg{raw: data} + s := cryptobyte.String(data) + + var extensions cryptobyte.String + if !s.Skip(4) || // message type and uint24 length field + !s.ReadUint16LengthPrefixed(&extensions) || !s.Empty() { + return false } - if m.ticketSupported { - numExtensions++ + + for !extensions.Empty() { + var extension uint16 + var extData cryptobyte.String + if !extensions.ReadUint16(&extension) || + !extensions.ReadUint16LengthPrefixed(&extData) { + return false + } + + switch extension { + case extensionALPN: + var protoList cryptobyte.String + if !extData.ReadUint16LengthPrefixed(&protoList) || protoList.Empty() { + return false + } + var proto cryptobyte.String + if !protoList.ReadUint8LengthPrefixed(&proto) || + proto.Empty() || !protoList.Empty() { + return false + } + m.alpnProtocol = string(proto) + default: + // Ignore unknown extensions. + continue + } + + if !extData.Empty() { + return false + } } - if m.secureRenegotiationSupported { - extensionsLength += 1 + len(m.secureRenegotiation) - numExtensions++ + + return true +} + +type endOfEarlyDataMsg struct{} + +func (m *endOfEarlyDataMsg) marshal() []byte { + x := make([]byte, 4) + x[0] = typeEndOfEarlyData + return x +} + +func (m *endOfEarlyDataMsg) unmarshal(data []byte) bool { + return len(data) == 4 +} + +type keyUpdateMsg struct { + raw []byte + updateRequested bool +} + +func (m *keyUpdateMsg) marshal() []byte { + if m.raw != nil { + return m.raw } - if alpnLen := len(m.alpnProtocol); alpnLen > 0 { - if alpnLen >= 256 { - panic("invalid ALPN protocol") + + var b cryptobyte.Builder + b.AddUint8(typeKeyUpdate) + b.AddUint24LengthPrefixed(func(b *cryptobyte.Builder) { + if m.updateRequested { + b.AddUint8(1) + } else { + b.AddUint8(0) } - extensionsLength += 2 + 1 + alpnLen - numExtensions++ + }) + + m.raw = b.BytesOrPanic() + return m.raw +} + +func (m *keyUpdateMsg) unmarshal(data []byte) bool { + m.raw = data + s := cryptobyte.String(data) + + var updateRequested uint8 + if !s.Skip(4) || // message type and uint24 length field + !s.ReadUint8(&updateRequested) || !s.Empty() { + return false } - sctLen := 0 - if len(m.scts) > 0 { - for _, sct := range m.scts { - sctLen += len(sct) + 2 - } - extensionsLength += 2 + sctLen - numExtensions++ + switch updateRequested { + case 0: + m.updateRequested = false + case 1: + m.updateRequested = true + default: + return false } + return true +} - if numExtensions > 0 { - extensionsLength += 4 * numExtensions - length += 2 + extensionsLength +type newSessionTicketMsgTLS13 struct { + raw []byte + lifetime uint32 + ageAdd uint32 + nonce []byte + label []byte + maxEarlyData uint32 +} + +func (m *newSessionTicketMsgTLS13) marshal() []byte { + if m.raw != nil { + return m.raw } - x := make([]byte, 4+length) - x[0] = typeServerHello - x[1] = uint8(length >> 16) - x[2] = uint8(length >> 8) - x[3] = uint8(length) - x[4] = uint8(m.vers >> 8) - x[5] = uint8(m.vers) - copy(x[6:38], m.random) - x[38] = uint8(len(m.sessionId)) - copy(x[39:39+len(m.sessionId)], m.sessionId) - z := x[39+len(m.sessionId):] - z[0] = uint8(m.cipherSuite >> 8) - z[1] = uint8(m.cipherSuite) - z[2] = m.compressionMethod - - z = z[3:] - if numExtensions > 0 { - z[0] = byte(extensionsLength >> 8) - z[1] = byte(extensionsLength) - z = z[2:] - } - if m.nextProtoNeg { - z[0] = byte(extensionNextProtoNeg >> 8) - z[1] = byte(extensionNextProtoNeg & 0xff) - z[2] = byte(nextProtoLen >> 8) - z[3] = byte(nextProtoLen) - z = z[4:] - - for _, v := range m.nextProtos { - l := len(v) - if l > 255 { - l = 255 - } - z[0] = byte(l) - copy(z[1:], []byte(v[0:l])) - z = z[1+l:] - } + var b cryptobyte.Builder + b.AddUint8(typeNewSessionTicket) + b.AddUint24LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint32(m.lifetime) + b.AddUint32(m.ageAdd) + b.AddUint8LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(m.nonce) + }) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(m.label) + }) + + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + if m.maxEarlyData > 0 { + b.AddUint16(extensionEarlyData) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint32(m.maxEarlyData) + }) + } + }) + }) + + m.raw = b.BytesOrPanic() + return m.raw +} + +func (m *newSessionTicketMsgTLS13) unmarshal(data []byte) bool { + *m = newSessionTicketMsgTLS13{raw: data} + s := cryptobyte.String(data) + + var extensions cryptobyte.String + if !s.Skip(4) || // message type and uint24 length field + !s.ReadUint32(&m.lifetime) || + !s.ReadUint32(&m.ageAdd) || + !readUint8LengthPrefixed(&s, &m.nonce) || + !readUint16LengthPrefixed(&s, &m.label) || + !s.ReadUint16LengthPrefixed(&extensions) || + !s.Empty() { + return false } - if m.ocspStapling { - z[0] = byte(extensionStatusRequest >> 8) - z[1] = byte(extensionStatusRequest) - z = z[4:] - } - if m.ticketSupported { - z[0] = byte(extensionSessionTicket >> 8) - z[1] = byte(extensionSessionTicket) - z = z[4:] - } - if m.secureRenegotiationSupported { - z[0] = byte(extensionRenegotiationInfo >> 8) - z[1] = byte(extensionRenegotiationInfo & 0xff) - z[2] = 0 - z[3] = byte(len(m.secureRenegotiation) + 1) - z[4] = byte(len(m.secureRenegotiation)) - z = z[5:] - copy(z, m.secureRenegotiation) - z = z[len(m.secureRenegotiation):] - } - if alpnLen := len(m.alpnProtocol); alpnLen > 0 { - z[0] = byte(extensionALPN >> 8) - z[1] = byte(extensionALPN & 0xff) - l := 2 + 1 + alpnLen - z[2] = byte(l >> 8) - z[3] = byte(l) - l -= 2 - z[4] = byte(l >> 8) - z[5] = byte(l) - l -= 1 - z[6] = byte(l) - copy(z[7:], []byte(m.alpnProtocol)) - z = z[7+alpnLen:] - } - if sctLen > 0 { - z[0] = byte(extensionSCT >> 8) - z[1] = byte(extensionSCT) - l := sctLen + 2 - z[2] = byte(l >> 8) - z[3] = byte(l) - z[4] = byte(sctLen >> 8) - z[5] = byte(sctLen) - - z = z[6:] - for _, sct := range m.scts { - z[0] = byte(len(sct) >> 8) - z[1] = byte(len(sct)) - copy(z[2:], sct) - z = z[len(sct)+2:] + + for !extensions.Empty() { + var extension uint16 + var extData cryptobyte.String + if !extensions.ReadUint16(&extension) || + !extensions.ReadUint16LengthPrefixed(&extData) { + return false + } + + switch extension { + case extensionEarlyData: + if !extData.ReadUint32(&m.maxEarlyData) { + return false + } + default: + // Ignore unknown extensions. + continue + } + + if !extData.Empty() { + return false } } - m.raw = x + return true +} - return x +type certificateRequestMsgTLS13 struct { + raw []byte + ocspStapling bool + scts bool + supportedSignatureAlgorithms []SignatureScheme + supportedSignatureAlgorithmsCert []SignatureScheme + certificateAuthorities [][]byte } -func (m *serverHelloMsg) unmarshal(data []byte) bool { - if len(data) < 42 { - return false - } - m.raw = data - m.vers = uint16(data[4])<<8 | uint16(data[5]) - m.random = data[6:38] - sessionIdLen := int(data[38]) - if sessionIdLen > 32 || len(data) < 39+sessionIdLen { - return false - } - m.sessionId = data[39 : 39+sessionIdLen] - data = data[39+sessionIdLen:] - if len(data) < 3 { - return false +func (m *certificateRequestMsgTLS13) marshal() []byte { + if m.raw != nil { + return m.raw } - m.cipherSuite = uint16(data[0])<<8 | uint16(data[1]) - m.compressionMethod = data[2] - data = data[3:] - m.nextProtoNeg = false - m.nextProtos = nil - m.ocspStapling = false - m.scts = nil - m.ticketSupported = false - m.alpnProtocol = "" + var b cryptobyte.Builder + b.AddUint8(typeCertificateRequest) + b.AddUint24LengthPrefixed(func(b *cryptobyte.Builder) { + // certificate_request_context (SHALL be zero length unless used for + // post-handshake authentication) + b.AddUint8(0) - if len(data) == 0 { - // ServerHello is optionally followed by extension data - return true - } - if len(data) < 2 { - return false - } + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + if m.ocspStapling { + b.AddUint16(extensionStatusRequest) + b.AddUint16(0) // empty extension_data + } + if m.scts { + // RFC 8446, Section 4.4.2.1 makes no mention of + // signed_certificate_timestamp in CertificateRequest, but + // "Extensions in the Certificate message from the client MUST + // correspond to extensions in the CertificateRequest message + // from the server." and it appears in the table in Section 4.2. + b.AddUint16(extensionSCT) + b.AddUint16(0) // empty extension_data + } + if len(m.supportedSignatureAlgorithms) > 0 { + b.AddUint16(extensionSignatureAlgorithms) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + for _, sigAlgo := range m.supportedSignatureAlgorithms { + b.AddUint16(uint16(sigAlgo)) + } + }) + }) + } + if len(m.supportedSignatureAlgorithmsCert) > 0 { + b.AddUint16(extensionSignatureAlgorithmsCert) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + for _, sigAlgo := range m.supportedSignatureAlgorithmsCert { + b.AddUint16(uint16(sigAlgo)) + } + }) + }) + } + if len(m.certificateAuthorities) > 0 { + b.AddUint16(extensionCertificateAuthorities) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + for _, ca := range m.certificateAuthorities { + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(ca) + }) + } + }) + }) + } + }) + }) - extensionsLength := int(data[0])<<8 | int(data[1]) - data = data[2:] - if len(data) != extensionsLength { + m.raw = b.BytesOrPanic() + return m.raw +} + +func (m *certificateRequestMsgTLS13) unmarshal(data []byte) bool { + *m = certificateRequestMsgTLS13{raw: data} + s := cryptobyte.String(data) + + var context, extensions cryptobyte.String + if !s.Skip(4) || // message type and uint24 length field + !s.ReadUint8LengthPrefixed(&context) || !context.Empty() || + !s.ReadUint16LengthPrefixed(&extensions) || + !s.Empty() { return false } - for len(data) != 0 { - if len(data) < 4 { - return false - } - extension := uint16(data[0])<<8 | uint16(data[1]) - length := int(data[2])<<8 | int(data[3]) - data = data[4:] - if len(data) < length { + for !extensions.Empty() { + var extension uint16 + var extData cryptobyte.String + if !extensions.ReadUint16(&extension) || + !extensions.ReadUint16LengthPrefixed(&extData) { return false } switch extension { - case extensionNextProtoNeg: - m.nextProtoNeg = true - d := data[:length] - for len(d) > 0 { - l := int(d[0]) - d = d[1:] - if l == 0 || l > len(d) { - return false - } - m.nextProtos = append(m.nextProtos, string(d[:l])) - d = d[l:] - } case extensionStatusRequest: - if length > 0 { - return false - } m.ocspStapling = true - case extensionSessionTicket: - if length > 0 { - return false - } - m.ticketSupported = true - case extensionRenegotiationInfo: - if length == 0 { - return false - } - d := data[:length] - l := int(d[0]) - d = d[1:] - if l != len(d) { - return false - } - - m.secureRenegotiation = d - m.secureRenegotiationSupported = true - case extensionALPN: - d := data[:length] - if len(d) < 3 { - return false - } - l := int(d[0])<<8 | int(d[1]) - if l != len(d)-2 { + case extensionSCT: + m.scts = true + case extensionSignatureAlgorithms: + var sigAndAlgs cryptobyte.String + if !extData.ReadUint16LengthPrefixed(&sigAndAlgs) || sigAndAlgs.Empty() { return false } - d = d[2:] - l = int(d[0]) - if l != len(d)-1 { - return false + for !sigAndAlgs.Empty() { + var sigAndAlg uint16 + if !sigAndAlgs.ReadUint16(&sigAndAlg) { + return false + } + m.supportedSignatureAlgorithms = append( + m.supportedSignatureAlgorithms, SignatureScheme(sigAndAlg)) } - d = d[1:] - if len(d) == 0 { - // ALPN protocols must not be empty. + case extensionSignatureAlgorithmsCert: + var sigAndAlgs cryptobyte.String + if !extData.ReadUint16LengthPrefixed(&sigAndAlgs) || sigAndAlgs.Empty() { return false } - m.alpnProtocol = string(d) - case extensionSCT: - d := data[:length] - - if len(d) < 2 { - return false + for !sigAndAlgs.Empty() { + var sigAndAlg uint16 + if !sigAndAlgs.ReadUint16(&sigAndAlg) { + return false + } + m.supportedSignatureAlgorithmsCert = append( + m.supportedSignatureAlgorithmsCert, SignatureScheme(sigAndAlg)) } - l := int(d[0])<<8 | int(d[1]) - d = d[2:] - if len(d) != l || l == 0 { + case extensionCertificateAuthorities: + var auths cryptobyte.String + if !extData.ReadUint16LengthPrefixed(&auths) || auths.Empty() { return false } - - m.scts = make([][]byte, 0, 3) - for len(d) != 0 { - if len(d) < 2 { - return false - } - sctLen := int(d[0])<<8 | int(d[1]) - d = d[2:] - if sctLen == 0 || len(d) < sctLen { + for !auths.Empty() { + var ca []byte + if !readUint16LengthPrefixed(&auths, &ca) || len(ca) == 0 { return false } - m.scts = append(m.scts, d[:sctLen]) - d = d[sctLen:] + m.certificateAuthorities = append(m.certificateAuthorities, ca) } + default: + // Ignore unknown extensions. + continue + } + + if !extData.Empty() { + return false } - data = data[length:] } return true @@ -839,16 +1220,6 @@ type certificateMsg struct { certificates [][]byte } -func (m *certificateMsg) equal(i interface{}) bool { - m1, ok := i.(*certificateMsg) - if !ok { - return false - } - - return bytes.Equal(m.raw, m1.raw) && - eqByteSlices(m.certificates, m1.certificates) -} - func (m *certificateMsg) marshal() (x []byte) { if m.raw != nil { return m.raw @@ -921,19 +1292,155 @@ func (m *certificateMsg) unmarshal(data []byte) bool { return true } -type serverKeyExchangeMsg struct { - raw []byte - key []byte +type certificateMsgTLS13 struct { + raw []byte + certificate Certificate + ocspStapling bool + scts bool +} + +func (m *certificateMsgTLS13) marshal() []byte { + if m.raw != nil { + return m.raw + } + + var b cryptobyte.Builder + b.AddUint8(typeCertificate) + b.AddUint24LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint8(0) // certificate_request_context + + certificate := m.certificate + if !m.ocspStapling { + certificate.OCSPStaple = nil + } + if !m.scts { + certificate.SignedCertificateTimestamps = nil + } + marshalCertificate(b, certificate) + }) + + m.raw = b.BytesOrPanic() + return m.raw +} + +func marshalCertificate(b *cryptobyte.Builder, certificate Certificate) { + b.AddUint24LengthPrefixed(func(b *cryptobyte.Builder) { + for i, cert := range certificate.Certificate { + b.AddUint24LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(cert) + }) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + if i > 0 { + // This library only supports OCSP and SCT for leaf certificates. + return + } + if certificate.OCSPStaple != nil { + b.AddUint16(extensionStatusRequest) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint8(statusTypeOCSP) + b.AddUint24LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(certificate.OCSPStaple) + }) + }) + } + if certificate.SignedCertificateTimestamps != nil { + b.AddUint16(extensionSCT) + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + for _, sct := range certificate.SignedCertificateTimestamps { + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(sct) + }) + } + }) + }) + } + }) + } + }) +} + +func (m *certificateMsgTLS13) unmarshal(data []byte) bool { + *m = certificateMsgTLS13{raw: data} + s := cryptobyte.String(data) + + var context cryptobyte.String + if !s.Skip(4) || // message type and uint24 length field + !s.ReadUint8LengthPrefixed(&context) || !context.Empty() || + !unmarshalCertificate(&s, &m.certificate) || + !s.Empty() { + return false + } + + m.scts = m.certificate.SignedCertificateTimestamps != nil + m.ocspStapling = m.certificate.OCSPStaple != nil + + return true } -func (m *serverKeyExchangeMsg) equal(i interface{}) bool { - m1, ok := i.(*serverKeyExchangeMsg) - if !ok { +func unmarshalCertificate(s *cryptobyte.String, certificate *Certificate) bool { + var certList cryptobyte.String + if !s.ReadUint24LengthPrefixed(&certList) { return false } + for !certList.Empty() { + var cert []byte + var extensions cryptobyte.String + if !readUint24LengthPrefixed(&certList, &cert) || + !certList.ReadUint16LengthPrefixed(&extensions) { + return false + } + certificate.Certificate = append(certificate.Certificate, cert) + for !extensions.Empty() { + var extension uint16 + var extData cryptobyte.String + if !extensions.ReadUint16(&extension) || + !extensions.ReadUint16LengthPrefixed(&extData) { + return false + } + if len(certificate.Certificate) > 1 { + // This library only supports OCSP and SCT for leaf certificates. + continue + } + + switch extension { + case extensionStatusRequest: + var statusType uint8 + if !extData.ReadUint8(&statusType) || statusType != statusTypeOCSP || + !readUint24LengthPrefixed(&extData, &certificate.OCSPStaple) || + len(certificate.OCSPStaple) == 0 { + return false + } + case extensionSCT: + var sctList cryptobyte.String + if !extData.ReadUint16LengthPrefixed(&sctList) || sctList.Empty() { + return false + } + for !sctList.Empty() { + var sct []byte + if !readUint16LengthPrefixed(&sctList, &sct) || + len(sct) == 0 { + return false + } + certificate.SignedCertificateTimestamps = append( + certificate.SignedCertificateTimestamps, sct) + } + default: + // Ignore unknown extensions. + continue + } + + if !extData.Empty() { + return false + } + } + } + return true +} - return bytes.Equal(m.raw, m1.raw) && - bytes.Equal(m.key, m1.key) +type serverKeyExchangeMsg struct { + raw []byte + key []byte } func (m *serverKeyExchangeMsg) marshal() []byte { @@ -962,20 +1469,8 @@ func (m *serverKeyExchangeMsg) unmarshal(data []byte) bool { } type certificateStatusMsg struct { - raw []byte - statusType uint8 - response []byte -} - -func (m *certificateStatusMsg) equal(i interface{}) bool { - m1, ok := i.(*certificateStatusMsg) - if !ok { - return false - } - - return bytes.Equal(m.raw, m1.raw) && - m.statusType == m1.statusType && - bytes.Equal(m.response, m1.response) + raw []byte + response []byte } func (m *certificateStatusMsg) marshal() []byte { @@ -983,57 +1478,35 @@ func (m *certificateStatusMsg) marshal() []byte { return m.raw } - var x []byte - if m.statusType == statusTypeOCSP { - x = make([]byte, 4+4+len(m.response)) - x[0] = typeCertificateStatus - l := len(m.response) + 4 - x[1] = byte(l >> 16) - x[2] = byte(l >> 8) - x[3] = byte(l) - x[4] = statusTypeOCSP - - l -= 4 - x[5] = byte(l >> 16) - x[6] = byte(l >> 8) - x[7] = byte(l) - copy(x[8:], m.response) - } else { - x = []byte{typeCertificateStatus, 0, 0, 1, m.statusType} - } + var b cryptobyte.Builder + b.AddUint8(typeCertificateStatus) + b.AddUint24LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddUint8(statusTypeOCSP) + b.AddUint24LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(m.response) + }) + }) - m.raw = x - return x + m.raw = b.BytesOrPanic() + return m.raw } func (m *certificateStatusMsg) unmarshal(data []byte) bool { m.raw = data - if len(data) < 5 { - return false - } - m.statusType = data[4] + s := cryptobyte.String(data) - m.response = nil - if m.statusType == statusTypeOCSP { - if len(data) < 8 { - return false - } - respLen := uint32(data[5])<<16 | uint32(data[6])<<8 | uint32(data[7]) - if uint32(len(data)) != 4+4+respLen { - return false - } - m.response = data[8:] + var statusType uint8 + if !s.Skip(4) || // message type and uint24 length field + !s.ReadUint8(&statusType) || statusType != statusTypeOCSP || + !readUint24LengthPrefixed(&s, &m.response) || + len(m.response) == 0 || !s.Empty() { + return false } return true } type serverHelloDoneMsg struct{} -func (m *serverHelloDoneMsg) equal(i interface{}) bool { - _, ok := i.(*serverHelloDoneMsg) - return ok -} - func (m *serverHelloDoneMsg) marshal() []byte { x := make([]byte, 4) x[0] = typeServerHelloDone @@ -1049,16 +1522,6 @@ type clientKeyExchangeMsg struct { ciphertext []byte } -func (m *clientKeyExchangeMsg) equal(i interface{}) bool { - m1, ok := i.(*clientKeyExchangeMsg) - if !ok { - return false - } - - return bytes.Equal(m.raw, m1.raw) && - bytes.Equal(m.ciphertext, m1.ciphertext) -} - func (m *clientKeyExchangeMsg) marshal() []byte { if m.raw != nil { return m.raw @@ -1093,36 +1556,27 @@ type finishedMsg struct { verifyData []byte } -func (m *finishedMsg) equal(i interface{}) bool { - m1, ok := i.(*finishedMsg) - if !ok { - return false - } - - return bytes.Equal(m.raw, m1.raw) && - bytes.Equal(m.verifyData, m1.verifyData) -} - -func (m *finishedMsg) marshal() (x []byte) { +func (m *finishedMsg) marshal() []byte { if m.raw != nil { return m.raw } - x = make([]byte, 4+len(m.verifyData)) - x[0] = typeFinished - x[3] = byte(len(m.verifyData)) - copy(x[4:], m.verifyData) - m.raw = x - return + var b cryptobyte.Builder + b.AddUint8(typeFinished) + b.AddUint24LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(m.verifyData) + }) + + m.raw = b.BytesOrPanic() + return m.raw } func (m *finishedMsg) unmarshal(data []byte) bool { m.raw = data - if len(data) < 4 { - return false - } - m.verifyData = data[4:] - return true + s := cryptobyte.String(data) + return s.Skip(1) && + readUint24LengthPrefixed(&s, &m.verifyData) && + s.Empty() } type nextProtoMsg struct { @@ -1130,16 +1584,6 @@ type nextProtoMsg struct { proto string } -func (m *nextProtoMsg) equal(i interface{}) bool { - m1, ok := i.(*nextProtoMsg) - if !ok { - return false - } - - return bytes.Equal(m.raw, m1.raw) && - m.proto == m1.proto -} - func (m *nextProtoMsg) marshal() []byte { if m.raw != nil { return m.raw @@ -1197,34 +1641,21 @@ func (m *nextProtoMsg) unmarshal(data []byte) bool { type certificateRequestMsg struct { raw []byte - // hasSignatureAndHash indicates whether this message includes a list - // of signature and hash functions. This change was introduced with TLS - // 1.2. - hasSignatureAndHash bool + // hasSignatureAlgorithm indicates whether this message includes a list of + // supported signature algorithms. This change was introduced with TLS 1.2. + hasSignatureAlgorithm bool certificateTypes []byte supportedSignatureAlgorithms []SignatureScheme certificateAuthorities [][]byte } -func (m *certificateRequestMsg) equal(i interface{}) bool { - m1, ok := i.(*certificateRequestMsg) - if !ok { - return false - } - - return bytes.Equal(m.raw, m1.raw) && - bytes.Equal(m.certificateTypes, m1.certificateTypes) && - eqByteSlices(m.certificateAuthorities, m1.certificateAuthorities) && - eqSignatureAlgorithms(m.supportedSignatureAlgorithms, m1.supportedSignatureAlgorithms) -} - func (m *certificateRequestMsg) marshal() (x []byte) { if m.raw != nil { return m.raw } - // See https://tools.ietf.org/html/rfc4346#section-7.4.4 + // See RFC 4346, Section 7.4.4. length := 1 + len(m.certificateTypes) + 2 casLength := 0 for _, ca := range m.certificateAuthorities { @@ -1232,7 +1663,7 @@ func (m *certificateRequestMsg) marshal() (x []byte) { } length += casLength - if m.hasSignatureAndHash { + if m.hasSignatureAlgorithm { length += 2 + 2*len(m.supportedSignatureAlgorithms) } @@ -1247,7 +1678,7 @@ func (m *certificateRequestMsg) marshal() (x []byte) { copy(x[5:], m.certificateTypes) y := x[5+len(m.certificateTypes):] - if m.hasSignatureAndHash { + if m.hasSignatureAlgorithm { n := len(m.supportedSignatureAlgorithms) * 2 y[0] = uint8(n >> 8) y[1] = uint8(n) @@ -1299,7 +1730,7 @@ func (m *certificateRequestMsg) unmarshal(data []byte) bool { data = data[numCertTypes:] - if m.hasSignatureAndHash { + if m.hasSignatureAlgorithm { if len(data) < 2 { return false } @@ -1351,22 +1782,10 @@ func (m *certificateRequestMsg) unmarshal(data []byte) bool { } type certificateVerifyMsg struct { - raw []byte - hasSignatureAndHash bool - signatureAlgorithm SignatureScheme - signature []byte -} - -func (m *certificateVerifyMsg) equal(i interface{}) bool { - m1, ok := i.(*certificateVerifyMsg) - if !ok { - return false - } - - return bytes.Equal(m.raw, m1.raw) && - m.hasSignatureAndHash == m1.hasSignatureAndHash && - m.signatureAlgorithm == m1.signatureAlgorithm && - bytes.Equal(m.signature, m1.signature) + raw []byte + hasSignatureAlgorithm bool // format change introduced in TLS 1.2 + signatureAlgorithm SignatureScheme + signature []byte } func (m *certificateVerifyMsg) marshal() (x []byte) { @@ -1374,62 +1793,34 @@ func (m *certificateVerifyMsg) marshal() (x []byte) { return m.raw } - // See https://tools.ietf.org/html/rfc4346#section-7.4.8 - siglength := len(m.signature) - length := 2 + siglength - if m.hasSignatureAndHash { - length += 2 - } - x = make([]byte, 4+length) - x[0] = typeCertificateVerify - x[1] = uint8(length >> 16) - x[2] = uint8(length >> 8) - x[3] = uint8(length) - y := x[4:] - if m.hasSignatureAndHash { - y[0] = uint8(m.signatureAlgorithm >> 8) - y[1] = uint8(m.signatureAlgorithm) - y = y[2:] - } - y[0] = uint8(siglength >> 8) - y[1] = uint8(siglength) - copy(y[2:], m.signature) - - m.raw = x + var b cryptobyte.Builder + b.AddUint8(typeCertificateVerify) + b.AddUint24LengthPrefixed(func(b *cryptobyte.Builder) { + if m.hasSignatureAlgorithm { + b.AddUint16(uint16(m.signatureAlgorithm)) + } + b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(m.signature) + }) + }) - return + m.raw = b.BytesOrPanic() + return m.raw } func (m *certificateVerifyMsg) unmarshal(data []byte) bool { m.raw = data + s := cryptobyte.String(data) - if len(data) < 6 { - return false - } - - length := uint32(data[1])<<16 | uint32(data[2])<<8 | uint32(data[3]) - if uint32(len(data))-4 != length { - return false - } - - data = data[4:] - if m.hasSignatureAndHash { - m.signatureAlgorithm = SignatureScheme(data[0])<<8 | SignatureScheme(data[1]) - data = data[2:] - } - - if len(data) < 2 { + if !s.Skip(4) { // message type and uint24 length field return false } - siglength := int(data[0])<<8 + int(data[1]) - data = data[2:] - if len(data) != siglength { - return false + if m.hasSignatureAlgorithm { + if !s.ReadUint16((*uint16)(&m.signatureAlgorithm)) { + return false + } } - - m.signature = data - - return true + return readUint16LengthPrefixed(&s, &m.signature) && s.Empty() } type newSessionTicketMsg struct { @@ -1437,22 +1828,12 @@ type newSessionTicketMsg struct { ticket []byte } -func (m *newSessionTicketMsg) equal(i interface{}) bool { - m1, ok := i.(*newSessionTicketMsg) - if !ok { - return false - } - - return bytes.Equal(m.raw, m1.raw) && - bytes.Equal(m.ticket, m1.ticket) -} - func (m *newSessionTicketMsg) marshal() (x []byte) { if m.raw != nil { return m.raw } - // See https://tools.ietf.org/html/rfc5077#section-3.3 + // See RFC 5077, Section 3.3. ticketLen := len(m.ticket) length := 2 + 4 + ticketLen x = make([]byte, 4+length) @@ -1501,63 +1882,3 @@ func (*helloRequestMsg) marshal() []byte { func (*helloRequestMsg) unmarshal(data []byte) bool { return len(data) == 4 } - -func eqUint16s(x, y []uint16) bool { - if len(x) != len(y) { - return false - } - for i, v := range x { - if y[i] != v { - return false - } - } - return true -} - -func eqCurveIDs(x, y []CurveID) bool { - if len(x) != len(y) { - return false - } - for i, v := range x { - if y[i] != v { - return false - } - } - return true -} - -func eqStrings(x, y []string) bool { - if len(x) != len(y) { - return false - } - for i, v := range x { - if y[i] != v { - return false - } - } - return true -} - -func eqByteSlices(x, y [][]byte) bool { - if len(x) != len(y) { - return false - } - for i, v := range x { - if !bytes.Equal(v, y[i]) { - return false - } - } - return true -} - -func eqSignatureAlgorithms(x, y []SignatureScheme) bool { - if len(x) != len(y) { - return false - } - for i, v := range x { - if v != y[i] { - return false - } - } - return true -} diff --git a/libgo/go/crypto/tls/handshake_messages_test.go b/libgo/go/crypto/tls/handshake_messages_test.go index 37eb748eea7..21beb8ef2de 100644 --- a/libgo/go/crypto/tls/handshake_messages_test.go +++ b/libgo/go/crypto/tls/handshake_messages_test.go @@ -11,6 +11,7 @@ import ( "strings" "testing" "testing/quick" + "time" ) var tests = []interface{}{ @@ -20,22 +21,25 @@ var tests = []interface{}{ &certificateMsg{}, &certificateRequestMsg{}, - &certificateVerifyMsg{}, + &certificateVerifyMsg{ + hasSignatureAlgorithm: true, + }, &certificateStatusMsg{}, &clientKeyExchangeMsg{}, &nextProtoMsg{}, &newSessionTicketMsg{}, &sessionState{}, -} - -type testMessage interface { - marshal() []byte - unmarshal([]byte) bool - equal(interface{}) bool + &sessionStateTLS13{}, + &encryptedExtensionsMsg{}, + &endOfEarlyDataMsg{}, + &keyUpdateMsg{}, + &newSessionTicketMsgTLS13{}, + &certificateRequestMsgTLS13{}, + &certificateMsgTLS13{}, } func TestMarshalUnmarshal(t *testing.T) { - rand := rand.New(rand.NewSource(0)) + rand := rand.New(rand.NewSource(time.Now().UnixNano())) for i, iface := range tests { ty := reflect.ValueOf(iface).Type() @@ -51,16 +55,16 @@ func TestMarshalUnmarshal(t *testing.T) { break } - m1 := v.Interface().(testMessage) + m1 := v.Interface().(handshakeMessage) marshaled := m1.marshal() - m2 := iface.(testMessage) + m2 := iface.(handshakeMessage) if !m2.unmarshal(marshaled) { t.Errorf("#%d failed to unmarshal %#v %x", i, m1, marshaled) break } m2.marshal() // to fill any marshal cache in the message - if !m1.equal(m2) { + if !reflect.DeepEqual(m1, m2) { t.Errorf("#%d got:%#v want:%#v %x", i, m2, m1, marshaled) break } @@ -85,7 +89,7 @@ func TestMarshalUnmarshal(t *testing.T) { func TestFuzz(t *testing.T) { rand := rand.New(rand.NewSource(0)) for _, iface := range tests { - m := iface.(testMessage) + m := iface.(handshakeMessage) for j := 0; j < 1000; j++ { len := rand.Intn(100) @@ -136,24 +140,60 @@ func (*clientHelloMsg) Generate(rand *rand.Rand, size int) reflect.Value { m.supportedPoints = randomBytes(rand.Intn(5)+1, rand) m.supportedCurves = make([]CurveID, rand.Intn(5)+1) for i := range m.supportedCurves { - m.supportedCurves[i] = CurveID(rand.Intn(30000)) + m.supportedCurves[i] = CurveID(rand.Intn(30000) + 1) } if rand.Intn(10) > 5 { m.ticketSupported = true if rand.Intn(10) > 5 { m.sessionTicket = randomBytes(rand.Intn(300), rand) + } else { + m.sessionTicket = make([]byte, 0) } } if rand.Intn(10) > 5 { m.supportedSignatureAlgorithms = supportedSignatureAlgorithms } - m.alpnProtocols = make([]string, rand.Intn(5)) - for i := range m.alpnProtocols { - m.alpnProtocols[i] = randomString(rand.Intn(20)+1, rand) + if rand.Intn(10) > 5 { + m.supportedSignatureAlgorithmsCert = supportedSignatureAlgorithms + } + for i := 0; i < rand.Intn(5); i++ { + m.alpnProtocols = append(m.alpnProtocols, randomString(rand.Intn(20)+1, rand)) } if rand.Intn(10) > 5 { m.scts = true } + if rand.Intn(10) > 5 { + m.secureRenegotiationSupported = true + m.secureRenegotiation = randomBytes(rand.Intn(50)+1, rand) + } + for i := 0; i < rand.Intn(5); i++ { + m.supportedVersions = append(m.supportedVersions, uint16(rand.Intn(0xffff)+1)) + } + if rand.Intn(10) > 5 { + m.cookie = randomBytes(rand.Intn(500)+1, rand) + } + for i := 0; i < rand.Intn(5); i++ { + var ks keyShare + ks.group = CurveID(rand.Intn(30000) + 1) + ks.data = randomBytes(rand.Intn(200)+1, rand) + m.keyShares = append(m.keyShares, ks) + } + switch rand.Intn(3) { + case 1: + m.pskModes = []uint8{pskModeDHE} + case 2: + m.pskModes = []uint8{pskModeDHE, pskModePlain} + } + for i := 0; i < rand.Intn(5); i++ { + var psk pskIdentity + psk.obfuscatedTicketAge = uint32(rand.Intn(500000)) + psk.label = randomBytes(rand.Intn(500)+1, rand) + m.pskIdentities = append(m.pskIdentities, psk) + m.pskBinders = append(m.pskBinders, randomBytes(rand.Intn(50)+32, rand)) + } + if rand.Intn(10) > 5 { + m.earlyData = true + } return reflect.ValueOf(m) } @@ -168,11 +208,8 @@ func (*serverHelloMsg) Generate(rand *rand.Rand, size int) reflect.Value { if rand.Intn(10) > 5 { m.nextProtoNeg = true - - n := rand.Intn(10) - m.nextProtos = make([]string, n) - for i := 0; i < n; i++ { - m.nextProtos[i] = randomString(20, rand) + for i := 0; i < rand.Intn(10); i++ { + m.nextProtos = append(m.nextProtos, randomString(20, rand)) } } @@ -182,14 +219,45 @@ func (*serverHelloMsg) Generate(rand *rand.Rand, size int) reflect.Value { if rand.Intn(10) > 5 { m.ticketSupported = true } - m.alpnProtocol = randomString(rand.Intn(32)+1, rand) + if rand.Intn(10) > 5 { + m.alpnProtocol = randomString(rand.Intn(32)+1, rand) + } + + for i := 0; i < rand.Intn(4); i++ { + m.scts = append(m.scts, randomBytes(rand.Intn(500)+1, rand)) + } if rand.Intn(10) > 5 { - numSCTs := rand.Intn(4) - m.scts = make([][]byte, numSCTs) - for i := range m.scts { - m.scts[i] = randomBytes(rand.Intn(500), rand) + m.secureRenegotiationSupported = true + m.secureRenegotiation = randomBytes(rand.Intn(50)+1, rand) + } + if rand.Intn(10) > 5 { + m.supportedVersion = uint16(rand.Intn(0xffff) + 1) + } + if rand.Intn(10) > 5 { + m.cookie = randomBytes(rand.Intn(500)+1, rand) + } + if rand.Intn(10) > 5 { + for i := 0; i < rand.Intn(5); i++ { + m.serverShare.group = CurveID(rand.Intn(30000) + 1) + m.serverShare.data = randomBytes(rand.Intn(200)+1, rand) } + } else if rand.Intn(10) > 5 { + m.selectedGroup = CurveID(rand.Intn(30000) + 1) + } + if rand.Intn(10) > 5 { + m.selectedIdentityPresent = true + m.selectedIdentity = uint16(rand.Intn(0xffff)) + } + + return reflect.ValueOf(m) +} + +func (*encryptedExtensionsMsg) Generate(rand *rand.Rand, size int) reflect.Value { + m := &encryptedExtensionsMsg{} + + if rand.Intn(10) > 5 { + m.alpnProtocol = randomString(rand.Intn(32)+1, rand) } return reflect.ValueOf(m) @@ -208,28 +276,23 @@ func (*certificateMsg) Generate(rand *rand.Rand, size int) reflect.Value { func (*certificateRequestMsg) Generate(rand *rand.Rand, size int) reflect.Value { m := &certificateRequestMsg{} m.certificateTypes = randomBytes(rand.Intn(5)+1, rand) - numCAs := rand.Intn(100) - m.certificateAuthorities = make([][]byte, numCAs) - for i := 0; i < numCAs; i++ { - m.certificateAuthorities[i] = randomBytes(rand.Intn(15)+1, rand) + for i := 0; i < rand.Intn(100); i++ { + m.certificateAuthorities = append(m.certificateAuthorities, randomBytes(rand.Intn(15)+1, rand)) } return reflect.ValueOf(m) } func (*certificateVerifyMsg) Generate(rand *rand.Rand, size int) reflect.Value { m := &certificateVerifyMsg{} + m.hasSignatureAlgorithm = true + m.signatureAlgorithm = SignatureScheme(rand.Intn(30000)) m.signature = randomBytes(rand.Intn(15)+1, rand) return reflect.ValueOf(m) } func (*certificateStatusMsg) Generate(rand *rand.Rand, size int) reflect.Value { m := &certificateStatusMsg{} - if rand.Intn(10) > 5 { - m.statusType = statusTypeOCSP - m.response = randomBytes(rand.Intn(10)+1, rand) - } else { - m.statusType = 42 - } + m.response = randomBytes(rand.Intn(10)+1, rand) return reflect.ValueOf(m) } @@ -270,9 +333,95 @@ func (*sessionState) Generate(rand *rand.Rand, size int) reflect.Value { return reflect.ValueOf(s) } +func (*sessionStateTLS13) Generate(rand *rand.Rand, size int) reflect.Value { + s := &sessionStateTLS13{} + s.cipherSuite = uint16(rand.Intn(10000)) + s.resumptionSecret = randomBytes(rand.Intn(100)+1, rand) + s.createdAt = uint64(rand.Int63()) + for i := 0; i < rand.Intn(2)+1; i++ { + s.certificate.Certificate = append( + s.certificate.Certificate, randomBytes(rand.Intn(500)+1, rand)) + } + if rand.Intn(10) > 5 { + s.certificate.OCSPStaple = randomBytes(rand.Intn(100)+1, rand) + } + if rand.Intn(10) > 5 { + for i := 0; i < rand.Intn(2)+1; i++ { + s.certificate.SignedCertificateTimestamps = append( + s.certificate.SignedCertificateTimestamps, randomBytes(rand.Intn(500)+1, rand)) + } + } + return reflect.ValueOf(s) +} + +func (*endOfEarlyDataMsg) Generate(rand *rand.Rand, size int) reflect.Value { + m := &endOfEarlyDataMsg{} + return reflect.ValueOf(m) +} + +func (*keyUpdateMsg) Generate(rand *rand.Rand, size int) reflect.Value { + m := &keyUpdateMsg{} + m.updateRequested = rand.Intn(10) > 5 + return reflect.ValueOf(m) +} + +func (*newSessionTicketMsgTLS13) Generate(rand *rand.Rand, size int) reflect.Value { + m := &newSessionTicketMsgTLS13{} + m.lifetime = uint32(rand.Intn(500000)) + m.ageAdd = uint32(rand.Intn(500000)) + m.nonce = randomBytes(rand.Intn(100), rand) + m.label = randomBytes(rand.Intn(1000), rand) + if rand.Intn(10) > 5 { + m.maxEarlyData = uint32(rand.Intn(500000)) + } + return reflect.ValueOf(m) +} + +func (*certificateRequestMsgTLS13) Generate(rand *rand.Rand, size int) reflect.Value { + m := &certificateRequestMsgTLS13{} + if rand.Intn(10) > 5 { + m.ocspStapling = true + } + if rand.Intn(10) > 5 { + m.scts = true + } + if rand.Intn(10) > 5 { + m.supportedSignatureAlgorithms = supportedSignatureAlgorithms + } + if rand.Intn(10) > 5 { + m.supportedSignatureAlgorithmsCert = supportedSignatureAlgorithms + } + if rand.Intn(10) > 5 { + m.certificateAuthorities = make([][]byte, 3) + for i := 0; i < 3; i++ { + m.certificateAuthorities[i] = randomBytes(rand.Intn(10)+1, rand) + } + } + return reflect.ValueOf(m) +} + +func (*certificateMsgTLS13) Generate(rand *rand.Rand, size int) reflect.Value { + m := &certificateMsgTLS13{} + for i := 0; i < rand.Intn(2)+1; i++ { + m.certificate.Certificate = append( + m.certificate.Certificate, randomBytes(rand.Intn(500)+1, rand)) + } + if rand.Intn(10) > 5 { + m.ocspStapling = true + m.certificate.OCSPStaple = randomBytes(rand.Intn(100)+1, rand) + } + if rand.Intn(10) > 5 { + m.scts = true + for i := 0; i < rand.Intn(2)+1; i++ { + m.certificate.SignedCertificateTimestamps = append( + m.certificate.SignedCertificateTimestamps, randomBytes(rand.Intn(500)+1, rand)) + } + } + return reflect.ValueOf(m) +} + func TestRejectEmptySCTList(t *testing.T) { - // https://tools.ietf.org/html/rfc6962#section-3.3.1 specifies that - // empty SCT lists are invalid. + // RFC 6962, Section 3.3.1 specifies that empty SCT lists are invalid. var random [32]byte sct := []byte{0x42, 0x42, 0x42, 0x42} diff --git a/libgo/go/crypto/tls/handshake_server.go b/libgo/go/crypto/tls/handshake_server.go index ac491bad390..2745f3313fb 100644 --- a/libgo/go/crypto/tls/handshake_server.go +++ b/libgo/go/crypto/tls/handshake_server.go @@ -19,20 +19,18 @@ import ( // serverHandshakeState contains details of a server handshake in progress. // It's discarded once the handshake has completed. type serverHandshakeState struct { - c *Conn - clientHello *clientHelloMsg - hello *serverHelloMsg - suite *cipherSuite - ellipticOk bool - ecdsaOk bool - rsaDecryptOk bool - rsaSignOk bool - sessionState *sessionState - finishedHash finishedHash - masterSecret []byte - certsFromClient [][]byte - cert *Certificate - cachedClientHelloInfo *ClientHelloInfo + c *Conn + clientHello *clientHelloMsg + hello *serverHelloMsg + suite *cipherSuite + ellipticOk bool + ecdsaOk bool + rsaDecryptOk bool + rsaSignOk bool + sessionState *sessionState + finishedHash finishedHash + masterSecret []byte + cert *Certificate } // serverHandshake performs a TLS handshake as a server. @@ -41,17 +39,36 @@ func (c *Conn) serverHandshake() error { // encrypt the tickets with. c.config.serverInitOnce.Do(func() { c.config.serverInit(nil) }) + clientHello, err := c.readClientHello() + if err != nil { + return err + } + + if c.vers == VersionTLS13 { + hs := serverHandshakeStateTLS13{ + c: c, + clientHello: clientHello, + } + return hs.handshake() + } + hs := serverHandshakeState{ - c: c, + c: c, + clientHello: clientHello, } - isResume, err := hs.readClientHello() - if err != nil { + return hs.handshake() +} + +func (hs *serverHandshakeState) handshake() error { + c := hs.c + + if err := hs.processClientHello(); err != nil { return err } - // For an overview of TLS handshaking, see https://tools.ietf.org/html/rfc5246#section-7.3 + // For an overview of TLS handshaking, see RFC 5246, Section 7.3. c.buffering = true - if isResume { + if hs.checkForResumption() { // The client has included a session ticket and so we do an abbreviated handshake. if err := hs.doResumeHandshake(); err != nil { return err @@ -81,6 +98,9 @@ func (c *Conn) serverHandshake() error { } else { // The client didn't include a session ticket, or it wasn't // valid so we do a full handshake. + if err := hs.pickCipherSuite(); err != nil { + return err + } if err := hs.doFullHandshake(); err != nil { return err } @@ -109,40 +129,50 @@ func (c *Conn) serverHandshake() error { return nil } -// readClientHello reads a ClientHello message from the client and decides -// whether we will perform session resumption. -func (hs *serverHandshakeState) readClientHello() (isResume bool, err error) { - c := hs.c - +// readClientHello reads a ClientHello message and selects the protocol version. +func (c *Conn) readClientHello() (*clientHelloMsg, error) { msg, err := c.readHandshake() if err != nil { - return false, err + return nil, err } - var ok bool - hs.clientHello, ok = msg.(*clientHelloMsg) + clientHello, ok := msg.(*clientHelloMsg) if !ok { c.sendAlert(alertUnexpectedMessage) - return false, unexpectedMessageError(hs.clientHello, msg) + return nil, unexpectedMessageError(clientHello, msg) } if c.config.GetConfigForClient != nil { - if newConfig, err := c.config.GetConfigForClient(hs.clientHelloInfo()); err != nil { + chi := clientHelloInfo(c, clientHello) + if newConfig, err := c.config.GetConfigForClient(chi); err != nil { c.sendAlert(alertInternalError) - return false, err + return nil, err } else if newConfig != nil { newConfig.serverInitOnce.Do(func() { newConfig.serverInit(c.config) }) c.config = newConfig } } - c.vers, ok = c.config.mutualVersion(hs.clientHello.vers) + clientVersions := clientHello.supportedVersions + if len(clientHello.supportedVersions) == 0 { + clientVersions = supportedVersionsFromMax(clientHello.vers) + } + c.vers, ok = c.config.mutualVersion(false, clientVersions) if !ok { c.sendAlert(alertProtocolVersion) - return false, fmt.Errorf("tls: client offered an unsupported, maximum protocol version of %x", hs.clientHello.vers) + return nil, fmt.Errorf("tls: client offered only unsupported versions: %x", clientVersions) } c.haveVers = true + c.in.version = c.vers + c.out.version = c.vers + + return clientHello, nil +} + +func (hs *serverHandshakeState) processClientHello() error { + c := hs.c hs.hello = new(serverHelloMsg) + hs.hello.vers = c.vers supportedCurve := false preferredCurves := c.config.curvePreferences() @@ -176,20 +206,30 @@ Curves: if !foundCompression { c.sendAlert(alertHandshakeFailure) - return false, errors.New("tls: client does not support uncompressed connections") + return errors.New("tls: client does not support uncompressed connections") } - hs.hello.vers = c.vers hs.hello.random = make([]byte, 32) - _, err = io.ReadFull(c.config.rand(), hs.hello.random) + serverRandom := hs.hello.random + // Downgrade protection canaries. See RFC 8446, Section 4.1.3. + maxVers := c.config.maxSupportedVersion(false) + if maxVers >= VersionTLS12 && c.vers < maxVers { + if c.vers == VersionTLS12 { + copy(serverRandom[24:], downgradeCanaryTLS12) + } else { + copy(serverRandom[24:], downgradeCanaryTLS11) + } + serverRandom = serverRandom[:24] + } + _, err := io.ReadFull(c.config.rand(), serverRandom) if err != nil { c.sendAlert(alertInternalError) - return false, err + return err } if len(hs.clientHello.secureRenegotiation) != 0 { c.sendAlert(alertHandshakeFailure) - return false, errors.New("tls: initial handshake had non-empty renegotiation extension") + return errors.New("tls: initial handshake had non-empty renegotiation extension") } hs.hello.secureRenegotiationSupported = hs.clientHello.secureRenegotiationSupported @@ -214,10 +254,10 @@ Curves: } } - hs.cert, err = c.config.getCertificate(hs.clientHelloInfo()) + hs.cert, err = c.config.getCertificate(clientHelloInfo(c, hs.clientHello)) if err != nil { c.sendAlert(alertInternalError) - return false, err + return err } if hs.clientHello.scts { hs.hello.scts = hs.cert.SignedCertificateTimestamps @@ -231,7 +271,7 @@ Curves: hs.rsaSignOk = true default: c.sendAlert(alertInternalError) - return false, fmt.Errorf("tls: unsupported signing key type (%T)", priv.Public()) + return fmt.Errorf("tls: unsupported signing key type (%T)", priv.Public()) } } if priv, ok := hs.cert.PrivateKey.(crypto.Decrypter); ok { @@ -240,13 +280,15 @@ Curves: hs.rsaDecryptOk = true default: c.sendAlert(alertInternalError) - return false, fmt.Errorf("tls: unsupported decryption key type (%T)", priv.Public()) + return fmt.Errorf("tls: unsupported decryption key type (%T)", priv.Public()) } } - if hs.checkForResumption() { - return true, nil - } + return nil +} + +func (hs *serverHandshakeState) pickCipherSuite() error { + c := hs.c var preferenceList, supportedList []uint16 if c.config.PreferServerCipherSuites { @@ -265,22 +307,21 @@ Curves: if hs.suite == nil { c.sendAlert(alertHandshakeFailure) - return false, errors.New("tls: no cipher suite supported by both client and server") + return errors.New("tls: no cipher suite supported by both client and server") } - // See https://tools.ietf.org/html/rfc7507. for _, id := range hs.clientHello.cipherSuites { if id == TLS_FALLBACK_SCSV { - // The client is doing a fallback connection. - if hs.clientHello.vers < c.config.maxVersion() { + // The client is doing a fallback connection. See RFC 7507. + if hs.clientHello.vers < c.config.maxSupportedVersion(false) { c.sendAlert(alertInappropriateFallback) - return false, errors.New("tls: client using inappropriate protocol fallback") + return errors.New("tls: client using inappropriate protocol fallback") } break } } - return false, nil + return nil } // checkForResumption reports whether we should perform resumption on this connection. @@ -291,9 +332,13 @@ func (hs *serverHandshakeState) checkForResumption() bool { return false } - var ok bool - var sessionTicket = append([]uint8{}, hs.clientHello.sessionTicket...) - if hs.sessionState, ok = c.decryptTicket(sessionTicket); !ok { + plaintext, usedOldKey := c.decryptTicket(hs.clientHello.sessionTicket) + if plaintext == nil { + return false + } + hs.sessionState = &sessionState{usedOldKey: usedOldKey} + ok := hs.sessionState.unmarshal(plaintext) + if !ok { return false } @@ -320,7 +365,7 @@ func (hs *serverHandshakeState) checkForResumption() bool { } sessionHasClientCerts := len(hs.sessionState.certificates) != 0 - needClientCerts := c.config.ClientAuth == RequireAnyClientCert || c.config.ClientAuth == RequireAndVerifyClientCert + needClientCerts := requiresClientCert(c.config.ClientAuth) if needClientCerts && !sessionHasClientCerts { return false } @@ -347,10 +392,10 @@ func (hs *serverHandshakeState) doResumeHandshake() error { return err } - if len(hs.sessionState.certificates) > 0 { - if _, err := hs.processCertsFromClient(hs.sessionState.certificates); err != nil { - return err - } + if err := c.processCertsFromClient(Certificate{ + Certificate: hs.sessionState.certificates, + }); err != nil { + return err } hs.masterSecret = hs.sessionState.masterSecret @@ -389,7 +434,6 @@ func (hs *serverHandshakeState) doFullHandshake() error { if hs.hello.ocspStapling { certStatus := new(certificateStatusMsg) - certStatus.statusType = statusTypeOCSP certStatus.response = hs.cert.OCSPStaple hs.finishedHash.Write(certStatus.marshal()) if _, err := c.writeRecord(recordTypeHandshake, certStatus.marshal()); err != nil { @@ -418,7 +462,7 @@ func (hs *serverHandshakeState) doFullHandshake() error { byte(certTypeECDSASign), } if c.vers >= VersionTLS12 { - certReq.hasSignatureAndHash = true + certReq.hasSignatureAlgorithm = true certReq.supportedSignatureAlgorithms = supportedSignatureAlgorithms } @@ -453,29 +497,24 @@ func (hs *serverHandshakeState) doFullHandshake() error { return err } - var ok bool // If we requested a client certificate, then the client must send a // certificate message, even if it's empty. if c.config.ClientAuth >= RequestClientCert { - if certMsg, ok = msg.(*certificateMsg); !ok { + certMsg, ok := msg.(*certificateMsg) + if !ok { c.sendAlert(alertUnexpectedMessage) return unexpectedMessageError(certMsg, msg) } hs.finishedHash.Write(certMsg.marshal()) - if len(certMsg.certificates) == 0 { - // The client didn't actually send a certificate - switch c.config.ClientAuth { - case RequireAnyClientCert, RequireAndVerifyClientCert: - c.sendAlert(alertBadCertificate) - return errors.New("tls: client didn't provide a certificate") - } - } - - pub, err = hs.processCertsFromClient(certMsg.certificates) - if err != nil { + if err := c.processCertsFromClient(Certificate{ + Certificate: certMsg.certificates, + }); err != nil { return err } + if len(certMsg.certificates) != 0 { + pub = c.peerCertificates[0].PublicKey + } msg, err = c.readHandshake() if err != nil { @@ -497,7 +536,7 @@ func (hs *serverHandshakeState) doFullHandshake() error { return err } hs.masterSecret = masterFromPreMasterSecret(c.vers, hs.suite, preMasterSecret, hs.clientHello.random, hs.hello.random) - if err := c.config.writeKeyLog(hs.clientHello.random, hs.masterSecret); err != nil { + if err := c.config.writeKeyLog(keyLogLabelTLS12, hs.clientHello.random, hs.masterSecret); err != nil { c.sendAlert(alertInternalError) return err } @@ -571,9 +610,8 @@ func (hs *serverHandshakeState) establishKeys() error { func (hs *serverHandshakeState) readFinished(out []byte) error { c := hs.c - c.readRecord(recordTypeChangeCipherSpec) - if c.in.err != nil { - return c.in.err + if err := c.readChangeCipherSpec(); err != nil { + return err } if hs.hello.nextProtoNeg { @@ -620,14 +658,18 @@ func (hs *serverHandshakeState) sendSessionTicket() error { c := hs.c m := new(newSessionTicketMsg) - var err error + var certsFromClient [][]byte + for _, cert := range c.peerCertificates { + certsFromClient = append(certsFromClient, cert.Raw) + } state := sessionState{ vers: c.vers, cipherSuite: hs.suite.id, masterSecret: hs.masterSecret, - certificates: hs.certsFromClient, + certificates: certsFromClient, } - m.ticket, err = c.encryptTicket(&state) + var err error + m.ticket, err = c.encryptTicket(state.marshal()) if err != nil { return err } @@ -663,19 +705,22 @@ func (hs *serverHandshakeState) sendFinished(out []byte) error { // processCertsFromClient takes a chain of client certificates either from a // Certificates message or from a sessionState and verifies them. It returns // the public key of the leaf certificate. -func (hs *serverHandshakeState) processCertsFromClient(certificates [][]byte) (crypto.PublicKey, error) { - c := hs.c - - hs.certsFromClient = certificates +func (c *Conn) processCertsFromClient(certificate Certificate) error { + certificates := certificate.Certificate certs := make([]*x509.Certificate, len(certificates)) var err error for i, asn1Data := range certificates { if certs[i], err = x509.ParseCertificate(asn1Data); err != nil { c.sendAlert(alertBadCertificate) - return nil, errors.New("tls: failed to parse client certificate: " + err.Error()) + return errors.New("tls: failed to parse client certificate: " + err.Error()) } } + if len(certs) == 0 && requiresClientCert(c.config.ClientAuth) { + c.sendAlert(alertBadCertificate) + return errors.New("tls: client didn't provide a certificate") + } + if c.config.ClientAuth >= VerifyClientCertIfGiven && len(certs) > 0 { opts := x509.VerifyOptions{ Roots: c.config.ClientCAs, @@ -691,7 +736,7 @@ func (hs *serverHandshakeState) processCertsFromClient(certificates [][]byte) (c chains, err := certs[0].Verify(opts) if err != nil { c.sendAlert(alertBadCertificate) - return nil, errors.New("tls: failed to verify client's certificate: " + err.Error()) + return errors.New("tls: failed to verify client's certificate: " + err.Error()) } c.verifiedChains = chains @@ -700,24 +745,25 @@ func (hs *serverHandshakeState) processCertsFromClient(certificates [][]byte) (c if c.config.VerifyPeerCertificate != nil { if err := c.config.VerifyPeerCertificate(certificates, c.verifiedChains); err != nil { c.sendAlert(alertBadCertificate) - return nil, err + return err } } if len(certs) == 0 { - return nil, nil + return nil } - var pub crypto.PublicKey - switch key := certs[0].PublicKey.(type) { + switch certs[0].PublicKey.(type) { case *ecdsa.PublicKey, *rsa.PublicKey: - pub = key default: c.sendAlert(alertUnsupportedCertificate) - return nil, fmt.Errorf("tls: client's certificate contains an unsupported public key of type %T", certs[0].PublicKey) + return fmt.Errorf("tls: client's certificate contains an unsupported public key of type %T", certs[0].PublicKey) } + c.peerCertificates = certs - return pub, nil + c.ocspResponse = certificate.OCSPStaple + c.scts = certificate.SignedCertificateTimestamps + return nil } // setCipherSuite sets a cipherSuite with the given id as the serverHandshakeState @@ -726,14 +772,7 @@ func (hs *serverHandshakeState) processCertsFromClient(certificates [][]byte) (c func (hs *serverHandshakeState) setCipherSuite(id uint16, supportedCipherSuites []uint16, version uint16) bool { for _, supported := range supportedCipherSuites { if id == supported { - var candidate *cipherSuite - - for _, s := range cipherSuites { - if s.id == id { - candidate = s - break - } - } + candidate := cipherSuiteByID(id) if candidate == nil { continue } @@ -763,31 +802,20 @@ func (hs *serverHandshakeState) setCipherSuite(id uint16, supportedCipherSuites return false } -// suppVersArray is the backing array of ClientHelloInfo.SupportedVersions -var suppVersArray = [...]uint16{VersionTLS12, VersionTLS11, VersionTLS10, VersionSSL30} - -func (hs *serverHandshakeState) clientHelloInfo() *ClientHelloInfo { - if hs.cachedClientHelloInfo != nil { - return hs.cachedClientHelloInfo - } - - var supportedVersions []uint16 - if hs.clientHello.vers > VersionTLS12 { - supportedVersions = suppVersArray[:] - } else if hs.clientHello.vers >= VersionSSL30 { - supportedVersions = suppVersArray[VersionTLS12-hs.clientHello.vers:] +func clientHelloInfo(c *Conn, clientHello *clientHelloMsg) *ClientHelloInfo { + supportedVersions := clientHello.supportedVersions + if len(clientHello.supportedVersions) == 0 { + supportedVersions = supportedVersionsFromMax(clientHello.vers) } - hs.cachedClientHelloInfo = &ClientHelloInfo{ - CipherSuites: hs.clientHello.cipherSuites, - ServerName: hs.clientHello.serverName, - SupportedCurves: hs.clientHello.supportedCurves, - SupportedPoints: hs.clientHello.supportedPoints, - SignatureSchemes: hs.clientHello.supportedSignatureAlgorithms, - SupportedProtos: hs.clientHello.alpnProtocols, + return &ClientHelloInfo{ + CipherSuites: clientHello.cipherSuites, + ServerName: clientHello.serverName, + SupportedCurves: clientHello.supportedCurves, + SupportedPoints: clientHello.supportedPoints, + SignatureSchemes: clientHello.supportedSignatureAlgorithms, + SupportedProtos: clientHello.alpnProtocols, SupportedVersions: supportedVersions, - Conn: hs.c.conn, + Conn: c.conn, } - - return hs.cachedClientHelloInfo } diff --git a/libgo/go/crypto/tls/handshake_server_test.go b/libgo/go/crypto/tls/handshake_server_test.go index c366f47b17c..a6240f2235f 100644 --- a/libgo/go/crypto/tls/handshake_server_test.go +++ b/libgo/go/crypto/tls/handshake_server_test.go @@ -16,6 +16,7 @@ import ( "errors" "fmt" "io" + "io/ioutil" "math/big" "net" "os" @@ -55,7 +56,7 @@ func init() { Certificates: make([]Certificate, 2), InsecureSkipVerify: true, MinVersion: VersionSSL30, - MaxVersion: VersionTLS12, + MaxVersion: VersionTLS13, CipherSuites: allCipherSuites(), } testConfig.Certificates[0].Certificate = [][]byte{testRSACertificate} @@ -63,6 +64,13 @@ func init() { testConfig.Certificates[1].Certificate = [][]byte{testSNICertificate} testConfig.Certificates[1].PrivateKey = testRSAPrivateKey testConfig.BuildNameToCertificate() + if keyFile := os.Getenv("SSLKEYLOGFILE"); keyFile != "" { + f, err := os.OpenFile(keyFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + if err != nil { + panic("failed to open SSLKEYLOGFILE: " + err.Error()) + } + testConfig.KeyLogWriter = f + } } func testClientHello(t *testing.T, serverConfig *Config, m handshakeMessage) { @@ -70,10 +78,7 @@ func testClientHello(t *testing.T, serverConfig *Config, m handshakeMessage) { } func testClientHelloFailure(t *testing.T, serverConfig *Config, m handshakeMessage, expectedSubStr string) { - // Create in-memory network connection, - // send message to server. Should return - // expected error. - c, s := net.Pipe() + c, s := localPipe(t) go func() { cli := Client(c, testConfig) if ch, ok := m.(*clientHelloMsg); ok { @@ -82,17 +87,25 @@ func testClientHelloFailure(t *testing.T, serverConfig *Config, m handshakeMessa cli.writeRecord(recordTypeHandshake, m.marshal()) c.Close() }() + conn := Server(s, serverConfig) + ch, err := conn.readClientHello() hs := serverHandshakeState{ - c: Server(s, serverConfig), + c: conn, + clientHello: ch, + } + if err == nil { + err = hs.processClientHello() + } + if err == nil { + err = hs.pickCipherSuite() } - _, err := hs.readClientHello() s.Close() if len(expectedSubStr) == 0 { if err != nil && err != io.EOF { t.Errorf("Got error: %s; expected to succeed", err) } } else if err == nil || !strings.Contains(err.Error(), expectedSubStr) { - t.Errorf("Got error: %s; expected to match substring '%s'", err, expectedSubStr) + t.Errorf("Got error: %v; expected to match substring '%s'", err, expectedSubStr) } } @@ -104,13 +117,22 @@ var badProtocolVersions = []uint16{0x0000, 0x0005, 0x0100, 0x0105, 0x0200, 0x020 func TestRejectBadProtocolVersion(t *testing.T) { for _, v := range badProtocolVersions { - testClientHelloFailure(t, testConfig, &clientHelloMsg{vers: v}, "unsupported, maximum protocol version") - } + testClientHelloFailure(t, testConfig, &clientHelloMsg{ + vers: v, + random: make([]byte, 32), + }, "unsupported versions") + } + testClientHelloFailure(t, testConfig, &clientHelloMsg{ + vers: VersionTLS12, + supportedVersions: badProtocolVersions, + random: make([]byte, 32), + }, "unsupported versions") } func TestNoSuiteOverlap(t *testing.T) { clientHello := &clientHelloMsg{ vers: VersionTLS10, + random: make([]byte, 32), cipherSuites: []uint16{0xff00}, compressionMethods: []uint8{compressionNone}, } @@ -120,6 +142,7 @@ func TestNoSuiteOverlap(t *testing.T) { func TestNoCompressionOverlap(t *testing.T) { clientHello := &clientHelloMsg{ vers: VersionTLS10, + random: make([]byte, 32), cipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA}, compressionMethods: []uint8{0xff}, } @@ -129,6 +152,7 @@ func TestNoCompressionOverlap(t *testing.T) { func TestNoRC4ByDefault(t *testing.T) { clientHello := &clientHelloMsg{ vers: VersionTLS10, + random: make([]byte, 32), cipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA}, compressionMethods: []uint8{compressionNone}, } @@ -140,7 +164,11 @@ func TestNoRC4ByDefault(t *testing.T) { } func TestRejectSNIWithTrailingDot(t *testing.T) { - testClientHelloFailure(t, testConfig, &clientHelloMsg{vers: VersionTLS12, serverName: "foo.com."}, "unexpected message") + testClientHelloFailure(t, testConfig, &clientHelloMsg{ + vers: VersionTLS12, + random: make([]byte, 32), + serverName: "foo.com.", + }, "unexpected message") } func TestDontSelectECDSAWithRSAKey(t *testing.T) { @@ -148,6 +176,7 @@ func TestDontSelectECDSAWithRSAKey(t *testing.T) { // won't be selected if the server's private key doesn't support it. clientHello := &clientHelloMsg{ vers: VersionTLS10, + random: make([]byte, 32), cipherSuites: []uint16{TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA}, compressionMethods: []uint8{compressionNone}, supportedCurves: []CurveID{CurveP256}, @@ -173,6 +202,7 @@ func TestDontSelectRSAWithECDSAKey(t *testing.T) { // won't be selected if the server's private key doesn't support it. clientHello := &clientHelloMsg{ vers: VersionTLS10, + random: make([]byte, 32), cipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA}, compressionMethods: []uint8{compressionNone}, supportedCurves: []CurveID{CurveP256}, @@ -201,25 +231,26 @@ func TestRenegotiationExtension(t *testing.T) { cipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA}, } - var buf []byte - c, s := net.Pipe() + bufChan := make(chan []byte) + c, s := localPipe(t) go func() { cli := Client(c, testConfig) cli.vers = clientHello.vers cli.writeRecord(recordTypeHandshake, clientHello.marshal()) - buf = make([]byte, 1024) + buf := make([]byte, 1024) n, err := c.Read(buf) if err != nil { t.Errorf("Server read returned error: %s", err) return } - buf = buf[:n] c.Close() + bufChan <- buf[:n] }() Server(s, testConfig).Handshake() + buf := <-bufChan if len(buf) < 5+4 { t.Fatalf("Server returned short message of length %d", len(buf)) @@ -244,11 +275,9 @@ func TestRenegotiationExtension(t *testing.T) { func TestTLS12OnlyCipherSuites(t *testing.T) { // Test that a Server doesn't select a TLS 1.2-only cipher suite when // the client negotiates TLS 1.1. - var zeros [32]byte - clientHello := &clientHelloMsg{ vers: VersionTLS11, - random: zeros[:], + random: make([]byte, 32), cipherSuites: []uint16{ // The Server, by default, will use the client's // preference order. So the GCM cipher suite @@ -262,22 +291,27 @@ func TestTLS12OnlyCipherSuites(t *testing.T) { supportedPoints: []uint8{pointFormatUncompressed}, } - c, s := net.Pipe() - var reply interface{} - var clientErr error + c, s := localPipe(t) + replyChan := make(chan interface{}) go func() { cli := Client(c, testConfig) cli.vers = clientHello.vers cli.writeRecord(recordTypeHandshake, clientHello.marshal()) - reply, clientErr = cli.readHandshake() + reply, err := cli.readHandshake() c.Close() + if err != nil { + replyChan <- err + } else { + replyChan <- reply + } }() config := testConfig.Clone() config.CipherSuites = clientHello.cipherSuites Server(s, config).Handshake() s.Close() - if clientErr != nil { - t.Fatal(clientErr) + reply := <-replyChan + if err, ok := reply.(error); ok { + t.Fatal(err) } serverHello, ok := reply.(*serverHelloMsg) if !ok { @@ -289,7 +323,7 @@ func TestTLS12OnlyCipherSuites(t *testing.T) { } func TestAlertForwarding(t *testing.T) { - c, s := net.Pipe() + c, s := localPipe(t) go func() { Client(c, testConfig).sendAlert(alertUnknownCA) c.Close() @@ -303,7 +337,7 @@ func TestAlertForwarding(t *testing.T) { } func TestClose(t *testing.T) { - c, s := net.Pipe() + c, s := localPipe(t) go c.Close() err := Server(s, testConfig).Handshake() @@ -313,23 +347,43 @@ func TestClose(t *testing.T) { } } -func testHandshake(clientConfig, serverConfig *Config) (serverState, clientState ConnectionState, err error) { - c, s := net.Pipe() - done := make(chan bool) +func testHandshake(t *testing.T, clientConfig, serverConfig *Config) (serverState, clientState ConnectionState, err error) { + c, s := localPipe(t) + errChan := make(chan error) go func() { cli := Client(c, clientConfig) - cli.Handshake() + err := cli.Handshake() + if err != nil { + errChan <- fmt.Errorf("client: %v", err) + c.Close() + return + } + defer cli.Close() clientState = cli.ConnectionState() - c.Close() - done <- true + buf, err := ioutil.ReadAll(cli) + if err != nil { + t.Errorf("failed to call cli.Read: %v", err) + } + if got := string(buf); got != opensslSentinel { + t.Errorf("read %q from TLS connection, but expected %q", got, opensslSentinel) + } + errChan <- nil }() server := Server(s, serverConfig) err = server.Handshake() if err == nil { serverState = server.ConnectionState() + if _, err := io.WriteString(server, opensslSentinel); err != nil { + t.Errorf("failed to call server.Write: %v", err) + } + if err := server.Close(); err != nil { + t.Errorf("failed to call server.Close: %v", err) + } + err = <-errChan + } else { + s.Close() + <-errChan } - s.Close() - <-done return } @@ -341,7 +395,7 @@ func TestVersion(t *testing.T) { clientConfig := &Config{ InsecureSkipVerify: true, } - state, _, err := testHandshake(clientConfig, serverConfig) + state, _, err := testHandshake(t, clientConfig, serverConfig) if err != nil { t.Fatalf("handshake failed: %s", err) } @@ -360,7 +414,7 @@ func TestCipherSuitePreference(t *testing.T) { CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_RC4_128_SHA}, InsecureSkipVerify: true, } - state, _, err := testHandshake(clientConfig, serverConfig) + state, _, err := testHandshake(t, clientConfig, serverConfig) if err != nil { t.Fatalf("handshake failed: %s", err) } @@ -370,7 +424,7 @@ func TestCipherSuitePreference(t *testing.T) { } serverConfig.PreferServerCipherSuites = true - state, _, err = testHandshake(clientConfig, serverConfig) + state, _, err = testHandshake(t, clientConfig, serverConfig) if err != nil { t.Fatalf("handshake failed: %s", err) } @@ -380,6 +434,11 @@ func TestCipherSuitePreference(t *testing.T) { } func TestSCTHandshake(t *testing.T) { + t.Run("TLSv12", func(t *testing.T) { testSCTHandshake(t, VersionTLS12) }) + t.Run("TLSv13", func(t *testing.T) { testSCTHandshake(t, VersionTLS13) }) +} + +func testSCTHandshake(t *testing.T, version uint16) { expected := [][]byte{[]byte("certificate"), []byte("transparency")} serverConfig := &Config{ Certificates: []Certificate{{ @@ -387,11 +446,12 @@ func TestSCTHandshake(t *testing.T) { PrivateKey: testRSAPrivateKey, SignedCertificateTimestamps: expected, }}, + MaxVersion: version, } clientConfig := &Config{ InsecureSkipVerify: true, } - _, state, err := testHandshake(clientConfig, serverConfig) + _, state, err := testHandshake(t, clientConfig, serverConfig) if err != nil { t.Fatalf("handshake failed: %s", err) } @@ -407,6 +467,11 @@ func TestSCTHandshake(t *testing.T) { } func TestCrossVersionResume(t *testing.T) { + t.Run("TLSv12", func(t *testing.T) { testCrossVersionResume(t, VersionTLS12) }) + t.Run("TLSv13", func(t *testing.T) { testCrossVersionResume(t, VersionTLS13) }) +} + +func testCrossVersionResume(t *testing.T, version uint16) { serverConfig := &Config{ CipherSuites: []uint16{TLS_RSA_WITH_AES_128_CBC_SHA}, Certificates: testConfig.Certificates, @@ -420,13 +485,13 @@ func TestCrossVersionResume(t *testing.T) { // Establish a session at TLS 1.1. clientConfig.MaxVersion = VersionTLS11 - _, _, err := testHandshake(clientConfig, serverConfig) + _, _, err := testHandshake(t, clientConfig, serverConfig) if err != nil { t.Fatalf("handshake failed: %s", err) } // The client session cache now contains a TLS 1.1 session. - state, _, err := testHandshake(clientConfig, serverConfig) + state, _, err := testHandshake(t, clientConfig, serverConfig) if err != nil { t.Fatalf("handshake failed: %s", err) } @@ -436,7 +501,7 @@ func TestCrossVersionResume(t *testing.T) { // Test that the server will decline to resume at a lower version. clientConfig.MaxVersion = VersionTLS10 - state, _, err = testHandshake(clientConfig, serverConfig) + state, _, err = testHandshake(t, clientConfig, serverConfig) if err != nil { t.Fatalf("handshake failed: %s", err) } @@ -445,7 +510,7 @@ func TestCrossVersionResume(t *testing.T) { } // The client session cache now contains a TLS 1.0 session. - state, _, err = testHandshake(clientConfig, serverConfig) + state, _, err = testHandshake(t, clientConfig, serverConfig) if err != nil { t.Fatalf("handshake failed: %s", err) } @@ -455,7 +520,7 @@ func TestCrossVersionResume(t *testing.T) { // Test that the server will decline to resume at a higher version. clientConfig.MaxVersion = VersionTLS11 - state, _, err = testHandshake(clientConfig, serverConfig) + state, _, err = testHandshake(t, clientConfig, serverConfig) if err != nil { t.Fatalf("handshake failed: %s", err) } @@ -488,6 +553,9 @@ type serverTest struct { // ConnectionState of the resulting connection. It returns false if the // ConnectionState is unacceptable. validate func(ConnectionState) error + // wait, if true, prevents this subtest from calling t.Parallel. + // If false, runServerTest* returns immediately. + wait bool } var defaultClientCommand = []string{"openssl", "s_client", "-no_ticket"} @@ -540,7 +608,6 @@ func (test *serverTest) connFromCommand() (conn *recordingConn, child *exec.Cmd, } tcpConn = connOrError.(net.Conn) case <-time.After(2 * time.Second): - output.WriteTo(os.Stdout) return nil, nil, errors.New("timed out waiting for connection from child process") } @@ -578,8 +645,13 @@ func (test *serverTest) run(t *testing.T, write bool) { t.Fatalf("Failed to start subcommand: %s", err) } serverConn = recordingConn + defer func() { + if t.Failed() { + t.Logf("OpenSSL output:\n\n%s", childProcess.Stdout) + } + }() } else { - clientConn, serverConn = net.Pipe() + clientConn, serverConn = localPipe(t) } config := test.config if config == nil { @@ -612,10 +684,12 @@ func (test *serverTest) run(t *testing.T, write bool) { } for i, b := range flows { if i%2 == 0 { + clientConn.SetWriteDeadline(time.Now().Add(1 * time.Minute)) clientConn.Write(b) continue } bb := make([]byte, len(b)) + clientConn.SetReadDeadline(time.Now().Add(1 * time.Minute)) n, err := io.ReadFull(clientConn, bb) if err != nil { t.Fatalf("%s #%d: %s\nRead %d, wanted %d, got %x, wanted %x\n", test.name, i+1, err, n, len(bb), bb[:n], b) @@ -655,43 +729,56 @@ func (test *serverTest) run(t *testing.T, write bool) { defer out.Close() recordingConn.Close() if len(recordingConn.flows) < 3 { - childProcess.Stdout.(*bytes.Buffer).WriteTo(os.Stdout) if len(test.expectHandshakeErrorIncluding) == 0 { t.Fatalf("Handshake failed") } } recordingConn.WriteTo(out) - fmt.Printf("Wrote %s\n", path) + t.Logf("Wrote %s\n", path) childProcess.Wait() } } -func runServerTestForVersion(t *testing.T, template *serverTest, prefix, option string) { - setParallel(t) - test := *template - test.name = prefix + test.name - if len(test.command) == 0 { - test.command = defaultClientCommand - } - test.command = append([]string(nil), test.command...) - test.command = append(test.command, option) - test.run(t, *update) +func runServerTestForVersion(t *testing.T, template *serverTest, version, option string) { + t.Run(version, func(t *testing.T) { + // Make a deep copy of the template before going parallel. + test := *template + if template.config != nil { + test.config = template.config.Clone() + } + + if !*update && !template.wait { + t.Parallel() + } + + test.name = version + "-" + test.name + if len(test.command) == 0 { + test.command = defaultClientCommand + } + test.command = append([]string(nil), test.command...) + test.command = append(test.command, option) + test.run(t, *update) + }) } func runServerTestSSLv3(t *testing.T, template *serverTest) { - runServerTestForVersion(t, template, "SSLv3-", "-ssl3") + runServerTestForVersion(t, template, "SSLv3", "-ssl3") } func runServerTestTLS10(t *testing.T, template *serverTest) { - runServerTestForVersion(t, template, "TLSv10-", "-tls1") + runServerTestForVersion(t, template, "TLSv10", "-tls1") } func runServerTestTLS11(t *testing.T, template *serverTest) { - runServerTestForVersion(t, template, "TLSv11-", "-tls1_1") + runServerTestForVersion(t, template, "TLSv11", "-tls1_1") } func runServerTestTLS12(t *testing.T, template *serverTest) { - runServerTestForVersion(t, template, "TLSv12-", "-tls1_2") + runServerTestForVersion(t, template, "TLSv12", "-tls1_2") +} + +func runServerTestTLS13(t *testing.T, template *serverTest) { + runServerTestForVersion(t, template, "TLSv13", "-tls1_3") } func TestHandshakeServerRSARC4(t *testing.T) { @@ -741,6 +828,28 @@ func TestHandshakeServerAES256GCMSHA384(t *testing.T) { runServerTestTLS12(t, test) } +func TestHandshakeServerAES128SHA256(t *testing.T) { + test := &serverTest{ + name: "AES128-SHA256", + command: []string{"openssl", "s_client", "-no_ticket", "-ciphersuites", "TLS_AES_128_GCM_SHA256"}, + } + runServerTestTLS13(t, test) +} +func TestHandshakeServerAES256SHA384(t *testing.T) { + test := &serverTest{ + name: "AES256-SHA384", + command: []string{"openssl", "s_client", "-no_ticket", "-ciphersuites", "TLS_AES_256_GCM_SHA384"}, + } + runServerTestTLS13(t, test) +} +func TestHandshakeServerCHACHA20SHA256(t *testing.T) { + test := &serverTest{ + name: "CHACHA20-SHA256", + command: []string{"openssl", "s_client", "-no_ticket", "-ciphersuites", "TLS_CHACHA20_POLY1305_SHA256"}, + } + runServerTestTLS13(t, test) +} + func TestHandshakeServerECDHEECDSAAES(t *testing.T) { config := testConfig.Clone() config.Certificates = make([]Certificate, 1) @@ -750,11 +859,12 @@ func TestHandshakeServerECDHEECDSAAES(t *testing.T) { test := &serverTest{ name: "ECDHE-ECDSA-AES", - command: []string{"openssl", "s_client", "-no_ticket", "-cipher", "ECDHE-ECDSA-AES256-SHA"}, + command: []string{"openssl", "s_client", "-no_ticket", "-cipher", "ECDHE-ECDSA-AES256-SHA", "-ciphersuites", "TLS_AES_128_GCM_SHA256"}, config: config, } runServerTestTLS10(t, test) runServerTestTLS12(t, test) + runServerTestTLS13(t, test) } func TestHandshakeServerX25519(t *testing.T) { @@ -762,11 +872,37 @@ func TestHandshakeServerX25519(t *testing.T) { config.CurvePreferences = []CurveID{X25519} test := &serverTest{ - name: "X25519-ECDHE-RSA-AES-GCM", - command: []string{"openssl", "s_client", "-no_ticket", "-cipher", "ECDHE-RSA-AES128-GCM-SHA256"}, + name: "X25519", + command: []string{"openssl", "s_client", "-no_ticket", "-cipher", "ECDHE-RSA-AES128-GCM-SHA256", "-curves", "X25519"}, config: config, } runServerTestTLS12(t, test) + runServerTestTLS13(t, test) +} + +func TestHandshakeServerP256(t *testing.T) { + config := testConfig.Clone() + config.CurvePreferences = []CurveID{CurveP256} + + test := &serverTest{ + name: "P256", + command: []string{"openssl", "s_client", "-no_ticket", "-cipher", "ECDHE-RSA-AES128-GCM-SHA256", "-curves", "P-256"}, + config: config, + } + runServerTestTLS12(t, test) + runServerTestTLS13(t, test) +} + +func TestHandshakeServerHelloRetryRequest(t *testing.T) { + config := testConfig.Clone() + config.CurvePreferences = []CurveID{CurveP256} + + test := &serverTest{ + name: "HelloRetryRequest", + command: []string{"openssl", "s_client", "-no_ticket", "-curves", "X25519:P-256"}, + config: config, + } + runServerTestTLS13(t, test) } func TestHandshakeServerALPN(t *testing.T) { @@ -788,6 +924,7 @@ func TestHandshakeServerALPN(t *testing.T) { }, } runServerTestTLS12(t, test) + runServerTestTLS13(t, test) } func TestHandshakeServerALPNNoMatch(t *testing.T) { @@ -810,6 +947,7 @@ func TestHandshakeServerALPNNoMatch(t *testing.T) { }, } runServerTestTLS12(t, test) + runServerTestTLS13(t, test) } // TestHandshakeServerSNI involves a client sending an SNI extension of @@ -832,7 +970,7 @@ func TestHandshakeServerSNIGetCertificate(t *testing.T) { nameToCert := config.NameToCertificate config.NameToCertificate = nil config.GetCertificate = func(clientHello *ClientHelloInfo) (*Certificate, error) { - cert, _ := nameToCert[clientHello.ServerName] + cert := nameToCert[clientHello.ServerName] return cert, nil } test := &serverTest{ @@ -873,6 +1011,7 @@ func TestHandshakeServerSNIGetCertificateError(t *testing.T) { clientHello := &clientHelloMsg{ vers: VersionTLS10, + random: make([]byte, 32), cipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA}, compressionMethods: []uint8{compressionNone}, serverName: "test", @@ -893,6 +1032,7 @@ func TestHandshakeServerEmptyCertificates(t *testing.T) { clientHello := &clientHelloMsg{ vers: VersionTLS10, + random: make([]byte, 32), cipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA}, compressionMethods: []uint8{compressionNone}, } @@ -904,6 +1044,7 @@ func TestHandshakeServerEmptyCertificates(t *testing.T) { clientHello = &clientHelloMsg{ vers: VersionTLS10, + random: make([]byte, 32), cipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA}, compressionMethods: []uint8{compressionNone}, } @@ -941,47 +1082,83 @@ func TestCipherSuiteCertPreferenceECDSA(t *testing.T) { runServerTestTLS12(t, test) } -func TestResumption(t *testing.T) { +func TestServerResumption(t *testing.T) { sessionFilePath := tempFile("") defer os.Remove(sessionFilePath) - test := &serverTest{ + testIssue := &serverTest{ name: "IssueTicket", command: []string{"openssl", "s_client", "-cipher", "AES128-SHA", "-sess_out", sessionFilePath}, + wait: true, } - runServerTestTLS12(t, test) - - test = &serverTest{ + testResume := &serverTest{ name: "Resume", command: []string{"openssl", "s_client", "-cipher", "AES128-SHA", "-sess_in", sessionFilePath}, + validate: func(state ConnectionState) error { + if !state.DidResume { + return errors.New("did not resume") + } + return nil + }, } - runServerTestTLS12(t, test) + + runServerTestTLS12(t, testIssue) + runServerTestTLS12(t, testResume) + + runServerTestTLS13(t, testIssue) + runServerTestTLS13(t, testResume) + + config := testConfig.Clone() + config.CurvePreferences = []CurveID{CurveP256} + + testResumeHRR := &serverTest{ + name: "Resume-HelloRetryRequest", + command: []string{"openssl", "s_client", "-curves", "X25519:P-256", "-sess_in", sessionFilePath}, + config: config, + validate: func(state ConnectionState) error { + if !state.DidResume { + return errors.New("did not resume") + } + return nil + }, + } + + runServerTestTLS13(t, testResumeHRR) } -func TestResumptionDisabled(t *testing.T) { +func TestServerResumptionDisabled(t *testing.T) { sessionFilePath := tempFile("") defer os.Remove(sessionFilePath) config := testConfig.Clone() - test := &serverTest{ + testIssue := &serverTest{ name: "IssueTicketPreDisable", command: []string{"openssl", "s_client", "-cipher", "AES128-SHA", "-sess_out", sessionFilePath}, config: config, + wait: true, } - runServerTestTLS12(t, test) - - config.SessionTicketsDisabled = true - - test = &serverTest{ + testResume := &serverTest{ name: "ResumeDisabled", command: []string{"openssl", "s_client", "-cipher", "AES128-SHA", "-sess_in", sessionFilePath}, config: config, + validate: func(state ConnectionState) error { + if state.DidResume { + return errors.New("resumed with SessionTicketsDisabled") + } + return nil + }, } - runServerTestTLS12(t, test) - // One needs to manually confirm that the handshake in the golden data - // file for ResumeDisabled does not include a resumption handshake. + config.SessionTicketsDisabled = false + runServerTestTLS12(t, testIssue) + config.SessionTicketsDisabled = true + runServerTestTLS12(t, testResume) + + config.SessionTicketsDisabled = false + runServerTestTLS13(t, testIssue) + config.SessionTicketsDisabled = true + runServerTestTLS13(t, testResume) } func TestFallbackSCSV(t *testing.T) { @@ -1014,9 +1191,27 @@ func TestHandshakeServerExportKeyingMaterial(t *testing.T) { } runServerTestTLS10(t, test) runServerTestTLS12(t, test) + runServerTestTLS13(t, test) +} + +func TestHandshakeServerRSAPKCS1v15(t *testing.T) { + test := &serverTest{ + name: "RSA-RSAPKCS1v15", + command: []string{"openssl", "s_client", "-no_ticket", "-sigalgs", "rsa_pkcs1_sha256"}, + } + runServerTestTLS12(t, test) +} + +func TestHandshakeServerRSAPSS(t *testing.T) { + test := &serverTest{ + name: "RSA-RSAPSS", + command: []string{"openssl", "s_client", "-no_ticket", "-sigalgs", "rsa_pss_rsae_sha256"}, + } + runServerTestTLS12(t, test) + runServerTestTLS13(t, test) } -func benchmarkHandshakeServer(b *testing.B, cipherSuite uint16, curve CurveID, cert []byte, key crypto.PrivateKey) { +func benchmarkHandshakeServer(b *testing.B, version uint16, cipherSuite uint16, curve CurveID, cert []byte, key crypto.PrivateKey) { config := testConfig.Clone() config.CipherSuites = []uint16{cipherSuite} config.CurvePreferences = []CurveID{curve} @@ -1025,10 +1220,13 @@ func benchmarkHandshakeServer(b *testing.B, cipherSuite uint16, curve CurveID, c config.Certificates[0].PrivateKey = key config.BuildNameToCertificate() - clientConn, serverConn := net.Pipe() + clientConn, serverConn := localPipe(b) serverConn = &recordingConn{Conn: serverConn} go func() { - client := Client(clientConn, testConfig) + config := testConfig.Clone() + config.MaxVersion = version + config.CurvePreferences = []CurveID{curve} + client := Client(clientConn, config) client.Handshake() }() server := Server(serverConn, config) @@ -1039,7 +1237,7 @@ func benchmarkHandshakeServer(b *testing.B, cipherSuite uint16, curve CurveID, c flows := serverConn.(*recordingConn).flows feeder := make(chan struct{}) - clientConn, serverConn = net.Pipe() + clientConn, serverConn = localPipe(b) go func() { for range feeder { @@ -1051,10 +1249,10 @@ func benchmarkHandshakeServer(b *testing.B, cipherSuite uint16, curve CurveID, c ff := make([]byte, len(f)) n, err := io.ReadFull(clientConn, ff) if err != nil { - b.Fatalf("#%d: %s\nRead %d, wanted %d, got %x, wanted %x\n", i+1, err, n, len(ff), ff[:n], f) + b.Errorf("#%d: %s\nRead %d, wanted %d, got %x, wanted %x\n", i+1, err, n, len(ff), ff[:n], f) } if !bytes.Equal(f, ff) { - b.Fatalf("#%d: mismatch on read: got:%x want:%x", i+1, ff, f) + b.Errorf("#%d: mismatch on read: got:%x want:%x", i+1, ff, f) } } } @@ -1073,34 +1271,54 @@ func benchmarkHandshakeServer(b *testing.B, cipherSuite uint16, curve CurveID, c func BenchmarkHandshakeServer(b *testing.B) { b.Run("RSA", func(b *testing.B) { - benchmarkHandshakeServer(b, TLS_RSA_WITH_AES_128_GCM_SHA256, + benchmarkHandshakeServer(b, VersionTLS12, TLS_RSA_WITH_AES_128_GCM_SHA256, 0, testRSACertificate, testRSAPrivateKey) }) b.Run("ECDHE-P256-RSA", func(b *testing.B) { - benchmarkHandshakeServer(b, TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305, - CurveP256, testRSACertificate, testRSAPrivateKey) + b.Run("TLSv13", func(b *testing.B) { + benchmarkHandshakeServer(b, VersionTLS13, TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305, + CurveP256, testRSACertificate, testRSAPrivateKey) + }) + b.Run("TLSv12", func(b *testing.B) { + benchmarkHandshakeServer(b, VersionTLS12, TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305, + CurveP256, testRSACertificate, testRSAPrivateKey) + }) }) b.Run("ECDHE-P256-ECDSA-P256", func(b *testing.B) { - benchmarkHandshakeServer(b, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, - CurveP256, testP256Certificate, testP256PrivateKey) + b.Run("TLSv13", func(b *testing.B) { + benchmarkHandshakeServer(b, VersionTLS13, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, + CurveP256, testP256Certificate, testP256PrivateKey) + }) + b.Run("TLSv12", func(b *testing.B) { + benchmarkHandshakeServer(b, VersionTLS12, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, + CurveP256, testP256Certificate, testP256PrivateKey) + }) }) b.Run("ECDHE-X25519-ECDSA-P256", func(b *testing.B) { - benchmarkHandshakeServer(b, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, - X25519, testP256Certificate, testP256PrivateKey) + b.Run("TLSv13", func(b *testing.B) { + benchmarkHandshakeServer(b, VersionTLS13, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, + X25519, testP256Certificate, testP256PrivateKey) + }) + b.Run("TLSv12", func(b *testing.B) { + benchmarkHandshakeServer(b, VersionTLS12, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, + X25519, testP256Certificate, testP256PrivateKey) + }) }) b.Run("ECDHE-P521-ECDSA-P521", func(b *testing.B) { if testECDSAPrivateKey.PublicKey.Curve != elliptic.P521() { b.Fatal("test ECDSA key doesn't use curve P-521") } - benchmarkHandshakeServer(b, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, - CurveP521, testECDSACertificate, testECDSAPrivateKey) + b.Run("TLSv13", func(b *testing.B) { + benchmarkHandshakeServer(b, VersionTLS13, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, + CurveP521, testECDSACertificate, testECDSAPrivateKey) + }) + b.Run("TLSv12", func(b *testing.B) { + benchmarkHandshakeServer(b, VersionTLS12, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, + CurveP521, testECDSACertificate, testECDSAPrivateKey) + }) }) } -// clientCertificatePEM and clientKeyPEM were generated with generate_cert.go -// Thus, they have no ExtKeyUsage fields and trigger an error when verification -// is turned on. - const clientCertificatePEM = ` -----BEGIN CERTIFICATE----- MIIB7zCCAVigAwIBAgIQXBnBiWWDVW/cC8m5k5/pvDANBgkqhkiG9w0BAQsFADAS @@ -1161,7 +1379,6 @@ FMBexFe01MNvja5oHt1vzobhfm6ySD6B5U7ixohLZNz1MLvT/2XMW/TdtWo+PtAd -----END EC PRIVATE KEY-----` func TestClientAuth(t *testing.T) { - setParallel(t) var certPath, keyPath, ecdsaCertPath, ecdsaKeyPath string if *update { @@ -1173,6 +1390,8 @@ func TestClientAuth(t *testing.T) { defer os.Remove(ecdsaCertPath) ecdsaKeyPath = tempFile(clientECDSAKeyPEM) defer os.Remove(ecdsaKeyPath) + } else { + t.Parallel() } config := testConfig.Clone() @@ -1184,22 +1403,36 @@ func TestClientAuth(t *testing.T) { config: config, } runServerTestTLS12(t, test) + runServerTestTLS13(t, test) test = &serverTest{ - name: "ClientAuthRequestedAndGiven", - command: []string{"openssl", "s_client", "-no_ticket", "-cipher", "AES128-SHA", "-cert", certPath, "-key", keyPath}, + name: "ClientAuthRequestedAndGiven", + command: []string{"openssl", "s_client", "-no_ticket", "-cipher", "AES128-SHA", + "-cert", certPath, "-key", keyPath, "-sigalgs", "rsa_pss_rsae_sha256"}, config: config, expectedPeerCerts: []string{clientCertificatePEM}, } runServerTestTLS12(t, test) + runServerTestTLS13(t, test) test = &serverTest{ - name: "ClientAuthRequestedAndECDSAGiven", - command: []string{"openssl", "s_client", "-no_ticket", "-cipher", "AES128-SHA", "-cert", ecdsaCertPath, "-key", ecdsaKeyPath}, + name: "ClientAuthRequestedAndECDSAGiven", + command: []string{"openssl", "s_client", "-no_ticket", "-cipher", "AES128-SHA", + "-cert", ecdsaCertPath, "-key", ecdsaKeyPath}, config: config, expectedPeerCerts: []string{clientECDSACertificatePEM}, } runServerTestTLS12(t, test) + runServerTestTLS13(t, test) + + test = &serverTest{ + name: "ClientAuthRequestedAndPKCS1v15Given", + command: []string{"openssl", "s_client", "-no_ticket", "-cipher", "AES128-SHA", + "-cert", certPath, "-key", keyPath, "-sigalgs", "rsa_pkcs1_sha256"}, + config: config, + expectedPeerCerts: []string{clientCertificatePEM}, + } + runServerTestTLS12(t, test) } func TestSNIGivenOnFailure(t *testing.T) { @@ -1207,6 +1440,7 @@ func TestSNIGivenOnFailure(t *testing.T) { clientHello := &clientHelloMsg{ vers: VersionTLS10, + random: make([]byte, 32), cipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA}, compressionMethods: []uint8{compressionNone}, serverName: expectedServerName, @@ -1216,17 +1450,25 @@ func TestSNIGivenOnFailure(t *testing.T) { // Erase the server's cipher suites to ensure the handshake fails. serverConfig.CipherSuites = nil - c, s := net.Pipe() + c, s := localPipe(t) go func() { cli := Client(c, testConfig) cli.vers = clientHello.vers cli.writeRecord(recordTypeHandshake, clientHello.marshal()) c.Close() }() + conn := Server(s, serverConfig) + ch, err := conn.readClientHello() hs := serverHandshakeState{ - c: Server(s, serverConfig), + c: conn, + clientHello: ch, + } + if err == nil { + err = hs.processClientHello() + } + if err == nil { + err = hs.pickCipherSuite() } - _, err := hs.readClientHello() defer s.Close() if err == nil { @@ -1270,11 +1512,11 @@ var getConfigForClientTests = []struct { func(clientHello *ClientHelloInfo) (*Config, error) { config := testConfig.Clone() // Setting a maximum version of TLS 1.1 should cause - // the handshake to fail. + // the handshake to fail, as the client MinVersion is TLS 1.2. config.MaxVersion = VersionTLS11 return config, nil }, - "version 301 when expecting version 302", + "client offered only unsupported versions", nil, }, { @@ -1346,7 +1588,7 @@ func TestGetConfigForClient(t *testing.T) { configReturned = config return config, err } - c, s := net.Pipe() + c, s := localPipe(t) done := make(chan error) go func() { @@ -1393,6 +1635,11 @@ var testRSACertificate = fromHex("3082024b308201b4a003020102020900e8f09d3fe25bea var testRSACertificateIssuer = fromHex("3082021930820182a003020102020900ca5e4e811a965964300d06092a864886f70d01010b0500301f310b3009060355040a1302476f3110300e06035504031307476f20526f6f74301e170d3136303130313030303030305a170d3235303130313030303030305a301f310b3009060355040a1302476f3110300e06035504031307476f20526f6f7430819f300d06092a864886f70d010101050003818d0030818902818100d667b378bb22f34143b6cd2008236abefaf2852adf3ab05e01329e2c14834f5105df3f3073f99dab5442d45ee5f8f57b0111c8cb682fbb719a86944eebfffef3406206d898b8c1b1887797c9c5006547bb8f00e694b7a063f10839f269f2c34fff7a1f4b21fbcd6bfdfb13ac792d1d11f277b5c5b48600992203059f2a8f8cc50203010001a35d305b300e0603551d0f0101ff040403020204301d0603551d250416301406082b0601050507030106082b06010505070302300f0603551d130101ff040530030101ff30190603551d0e041204104813494d137e1631bba301d5acab6e7b300d06092a864886f70d01010b050003818100c1154b4bab5266221f293766ae4138899bd4c5e36b13cee670ceeaa4cbdf4f6679017e2fe649765af545749fe4249418a56bd38a04b81e261f5ce86b8d5c65413156a50d12449554748c59a30c515bc36a59d38bddf51173e899820b282e40aa78c806526fd184fb6b4cf186ec728edffa585440d2b3225325f7ab580e87dd76") +// testRSAPSSCertificate has signatureAlgorithm rsassaPss, and subjectPublicKeyInfo +// algorithm rsaEncryption, for use with the rsa_pss_rsae_* SignatureSchemes. +// See also TestRSAPSSKeyError. testRSAPSSCertificate is self-signed. +var testRSAPSSCertificate = fromHex("308202583082018da003020102021100f29926eb87ea8a0db9fcc247347c11b0304106092a864886f70d01010a3034a00f300d06096086480165030402010500a11c301a06092a864886f70d010108300d06096086480165030402010500a20302012030123110300e060355040a130741636d6520436f301e170d3137313132333136313631305a170d3138313132333136313631305a30123110300e060355040a130741636d6520436f30819f300d06092a864886f70d010101050003818d0030818902818100db467d932e12270648bc062821ab7ec4b6a25dfe1e5245887a3647a5080d92425bc281c0be97799840fb4f6d14fd2b138bc2a52e67d8d4099ed62238b74a0b74732bc234f1d193e596d9747bf3589f6c613cc0b041d4d92b2b2423775b1c3bbd755dce2054cfa163871d1e24c4f31d1a508baab61443ed97a77562f414c852d70203010001a3463044300e0603551d0f0101ff0404030205a030130603551d25040c300a06082b06010505070301300c0603551d130101ff04023000300f0603551d110408300687047f000001304106092a864886f70d01010a3034a00f300d06096086480165030402010500a11c301a06092a864886f70d010108300d06096086480165030402010500a20302012003818100cdac4ef2ce5f8d79881042707f7cbf1b5a8a00ef19154b40151771006cd41626e5496d56da0c1a139fd84695593cb67f87765e18aa03ea067522dd78d2a589b8c92364e12838ce346c6e067b51f1a7e6f4b37ffab13f1411896679d18e880e0ba09e302ac067efca460288e9538122692297ad8093d4f7dd701424d7700a46a1") + var testECDSACertificate = fromHex("3082020030820162020900b8bf2d47a0d2ebf4300906072a8648ce3d04013045310b3009060355040613024155311330110603550408130a536f6d652d53746174653121301f060355040a1318496e7465726e6574205769646769747320507479204c7464301e170d3132313132323135303633325a170d3232313132303135303633325a3045310b3009060355040613024155311330110603550408130a536f6d652d53746174653121301f060355040a1318496e7465726e6574205769646769747320507479204c746430819b301006072a8648ce3d020106052b81040023038186000400c4a1edbe98f90b4873367ec316561122f23d53c33b4d213dcd6b75e6f6b0dc9adf26c1bcb287f072327cb3642f1c90bcea6823107efee325c0483a69e0286dd33700ef0462dd0da09c706283d881d36431aa9e9731bd96b068c09b23de76643f1a5c7fe9120e5858b65f70dd9bd8ead5d7f5d5ccb9b69f30665b669a20e227e5bffe3b300906072a8648ce3d040103818c0030818802420188a24febe245c5487d1bacf5ed989dae4770c05e1bb62fbdf1b64db76140d311a2ceee0b7e927eff769dc33b7ea53fcefa10e259ec472d7cacda4e970e15a06fd00242014dfcbe67139c2d050ebd3fa38c25c13313830d9406bbd4377af6ec7ac9862eddd711697f857c56defb31782be4c7780daecbbe9e4e3624317b6a0f399512078f2a") var testSNICertificate = fromHex("0441883421114c81480804c430820237308201a0a003020102020900e8f09d3fe25beaa6300d06092a864886f70d01010b0500301f310b3009060355040a1302476f3110300e06035504031307476f20526f6f74301e170d3136303130313030303030305a170d3235303130313030303030305a3023310b3009060355040a1302476f311430120603550403130b736e69746573742e636f6d30819f300d06092a864886f70d010101050003818d0030818902818100db467d932e12270648bc062821ab7ec4b6a25dfe1e5245887a3647a5080d92425bc281c0be97799840fb4f6d14fd2b138bc2a52e67d8d4099ed62238b74a0b74732bc234f1d193e596d9747bf3589f6c613cc0b041d4d92b2b2423775b1c3bbd755dce2054cfa163871d1e24c4f31d1a508baab61443ed97a77562f414c852d70203010001a3773075300e0603551d0f0101ff0404030205a0301d0603551d250416301406082b0601050507030106082b06010505070302300c0603551d130101ff0402300030190603551d0e041204109f91161f43433e49a6de6db680d79f60301b0603551d230414301280104813494d137e1631bba301d5acab6e7b300d06092a864886f70d01010b0500038181007beeecff0230dbb2e7a334af65430b7116e09f327c3bbf918107fc9c66cb497493207ae9b4dbb045cb63d605ec1b5dd485bb69124d68fa298dc776699b47632fd6d73cab57042acb26f083c4087459bc5a3bb3ca4d878d7fe31016b7bc9a627438666566e3389bfaeebe6becc9a0093ceed18d0f9ac79d56f3a73f18188988ed") @@ -1423,19 +1670,30 @@ var testECDSAPrivateKey = &ecdsa.PrivateKey{ var testP256PrivateKey, _ = x509.ParseECPrivateKey(fromHex("30770201010420012f3b52bc54c36ba3577ad45034e2e8efe1e6999851284cb848725cfe029991a00a06082a8648ce3d030107a14403420004c02c61c9b16283bbcc14956d886d79b358aa614596975f78cece787146abf74c2d5dc578c0992b4f3c631373479ebf3892efe53d21c4f4f1cc9a11c3536b7f75")) func TestCloseServerConnectionOnIdleClient(t *testing.T) { - clientConn, serverConn := net.Pipe() + clientConn, serverConn := localPipe(t) server := Server(serverConn, testConfig.Clone()) go func() { clientConn.Write([]byte{'0'}) server.Close() }() - server.SetReadDeadline(time.Now().Add(time.Second)) + server.SetReadDeadline(time.Now().Add(time.Minute)) err := server.Handshake() if err != nil { - if !strings.Contains(err.Error(), "read/write on closed pipe") { - t.Errorf("Error expected containing 'read/write on closed pipe' but got '%s'", err.Error()) + if err, ok := err.(net.Error); ok && err.Timeout() { + t.Errorf("Expected a closed network connection error but got '%s'", err.Error()) } } else { t.Errorf("Error expected, but no error returned") } } + +func TestCloneHash(t *testing.T) { + h1 := crypto.SHA256.New() + h1.Write([]byte("test")) + s1 := h1.Sum(nil) + h2 := cloneHash(h1, crypto.SHA256) + s2 := h2.Sum(nil) + if !bytes.Equal(s1, s2) { + t.Error("cloned hash generated a different sum") + } +} diff --git a/libgo/go/crypto/tls/handshake_server_tls13.go b/libgo/go/crypto/tls/handshake_server_tls13.go new file mode 100644 index 00000000000..5f634b36aaf --- /dev/null +++ b/libgo/go/crypto/tls/handshake_server_tls13.go @@ -0,0 +1,854 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package tls + +import ( + "bytes" + "crypto" + "crypto/hmac" + "crypto/rsa" + "errors" + "hash" + "io" + "sync/atomic" + "time" +) + +// maxClientPSKIdentities is the number of client PSK identities the server will +// attempt to validate. It will ignore the rest not to let cheap ClientHello +// messages cause too much work in session ticket decryption attempts. +const maxClientPSKIdentities = 5 + +type serverHandshakeStateTLS13 struct { + c *Conn + clientHello *clientHelloMsg + hello *serverHelloMsg + sentDummyCCS bool + usingPSK bool + suite *cipherSuiteTLS13 + cert *Certificate + sigAlg SignatureScheme + earlySecret []byte + sharedKey []byte + handshakeSecret []byte + masterSecret []byte + trafficSecret []byte // client_application_traffic_secret_0 + transcript hash.Hash + clientFinished []byte +} + +func (hs *serverHandshakeStateTLS13) handshake() error { + c := hs.c + + // For an overview of the TLS 1.3 handshake, see RFC 8446, Section 2. + if err := hs.processClientHello(); err != nil { + return err + } + if err := hs.checkForResumption(); err != nil { + return err + } + if err := hs.pickCertificate(); err != nil { + return err + } + c.buffering = true + if err := hs.sendServerParameters(); err != nil { + return err + } + if err := hs.sendServerCertificate(); err != nil { + return err + } + if err := hs.sendServerFinished(); err != nil { + return err + } + // Note that at this point we could start sending application data without + // waiting for the client's second flight, but the application might not + // expect the lack of replay protection of the ClientHello parameters. + if _, err := c.flush(); err != nil { + return err + } + if err := hs.readClientCertificate(); err != nil { + return err + } + if err := hs.readClientFinished(); err != nil { + return err + } + + atomic.StoreUint32(&c.handshakeStatus, 1) + + return nil +} + +func (hs *serverHandshakeStateTLS13) processClientHello() error { + c := hs.c + + hs.hello = new(serverHelloMsg) + + // TLS 1.3 froze the ServerHello.legacy_version field, and uses + // supported_versions instead. See RFC 8446, sections 4.1.3 and 4.2.1. + hs.hello.vers = VersionTLS12 + hs.hello.supportedVersion = c.vers + + if len(hs.clientHello.supportedVersions) == 0 { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: client used the legacy version field to negotiate TLS 1.3") + } + + // Abort if the client is doing a fallback and landing lower than what we + // support. See RFC 7507, which however does not specify the interaction + // with supported_versions. The only difference is that with + // supported_versions a client has a chance to attempt a [TLS 1.2, TLS 1.4] + // handshake in case TLS 1.3 is broken but 1.2 is not. Alas, in that case, + // it will have to drop the TLS_FALLBACK_SCSV protection if it falls back to + // TLS 1.2, because a TLS 1.3 server would abort here. The situation before + // supported_versions was not better because there was just no way to do a + // TLS 1.4 handshake without risking the server selecting TLS 1.3. + for _, id := range hs.clientHello.cipherSuites { + if id == TLS_FALLBACK_SCSV { + // Use c.vers instead of max(supported_versions) because an attacker + // could defeat this by adding an arbitrary high version otherwise. + if c.vers < c.config.maxSupportedVersion(false) { + c.sendAlert(alertInappropriateFallback) + return errors.New("tls: client using inappropriate protocol fallback") + } + break + } + } + + if len(hs.clientHello.compressionMethods) != 1 || + hs.clientHello.compressionMethods[0] != compressionNone { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: TLS 1.3 client supports illegal compression methods") + } + + hs.hello.random = make([]byte, 32) + if _, err := io.ReadFull(c.config.rand(), hs.hello.random); err != nil { + c.sendAlert(alertInternalError) + return err + } + + if len(hs.clientHello.secureRenegotiation) != 0 { + c.sendAlert(alertHandshakeFailure) + return errors.New("tls: initial handshake had non-empty renegotiation extension") + } + + if hs.clientHello.earlyData { + // See RFC 8446, Section 4.2.10 for the complicated behavior required + // here. The scenario is that a different server at our address offered + // to accept early data in the past, which we can't handle. For now, all + // 0-RTT enabled session tickets need to expire before a Go server can + // replace a server or join a pool. That's the same requirement that + // applies to mixing or replacing with any TLS 1.2 server. + c.sendAlert(alertUnsupportedExtension) + return errors.New("tls: client sent unexpected early data") + } + + hs.hello.sessionId = hs.clientHello.sessionId + hs.hello.compressionMethod = compressionNone + + var preferenceList, supportedList []uint16 + if c.config.PreferServerCipherSuites { + preferenceList = defaultCipherSuitesTLS13() + supportedList = hs.clientHello.cipherSuites + } else { + preferenceList = hs.clientHello.cipherSuites + supportedList = defaultCipherSuitesTLS13() + } + for _, suiteID := range preferenceList { + hs.suite = mutualCipherSuiteTLS13(supportedList, suiteID) + if hs.suite != nil { + break + } + } + if hs.suite == nil { + c.sendAlert(alertHandshakeFailure) + return errors.New("tls: no cipher suite supported by both client and server") + } + c.cipherSuite = hs.suite.id + hs.hello.cipherSuite = hs.suite.id + hs.transcript = hs.suite.hash.New() + + // Pick the ECDHE group in server preference order, but give priority to + // groups with a key share, to avoid a HelloRetryRequest round-trip. + var selectedGroup CurveID + var clientKeyShare *keyShare +GroupSelection: + for _, preferredGroup := range c.config.curvePreferences() { + for _, ks := range hs.clientHello.keyShares { + if ks.group == preferredGroup { + selectedGroup = ks.group + clientKeyShare = &ks + break GroupSelection + } + } + if selectedGroup != 0 { + continue + } + for _, group := range hs.clientHello.supportedCurves { + if group == preferredGroup { + selectedGroup = group + break + } + } + } + if selectedGroup == 0 { + c.sendAlert(alertHandshakeFailure) + return errors.New("tls: no ECDHE curve supported by both client and server") + } + if clientKeyShare == nil { + if err := hs.doHelloRetryRequest(selectedGroup); err != nil { + return err + } + clientKeyShare = &hs.clientHello.keyShares[0] + } + + if _, ok := curveForCurveID(selectedGroup); selectedGroup != X25519 && !ok { + c.sendAlert(alertInternalError) + return errors.New("tls: CurvePreferences includes unsupported curve") + } + params, err := generateECDHEParameters(c.config.rand(), selectedGroup) + if err != nil { + c.sendAlert(alertInternalError) + return err + } + hs.hello.serverShare = keyShare{group: selectedGroup, data: params.PublicKey()} + hs.sharedKey = params.SharedKey(clientKeyShare.data) + if hs.sharedKey == nil { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: invalid client key share") + } + + c.serverName = hs.clientHello.serverName + return nil +} + +func (hs *serverHandshakeStateTLS13) checkForResumption() error { + c := hs.c + + if c.config.SessionTicketsDisabled { + return nil + } + + modeOK := false + for _, mode := range hs.clientHello.pskModes { + if mode == pskModeDHE { + modeOK = true + break + } + } + if !modeOK { + return nil + } + + if len(hs.clientHello.pskIdentities) != len(hs.clientHello.pskBinders) { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: invalid or missing PSK binders") + } + if len(hs.clientHello.pskIdentities) == 0 { + return nil + } + + for i, identity := range hs.clientHello.pskIdentities { + if i >= maxClientPSKIdentities { + break + } + + plaintext, _ := c.decryptTicket(identity.label) + if plaintext == nil { + continue + } + sessionState := new(sessionStateTLS13) + if ok := sessionState.unmarshal(plaintext); !ok { + continue + } + + createdAt := time.Unix(int64(sessionState.createdAt), 0) + if c.config.time().Sub(createdAt) > maxSessionTicketLifetime { + continue + } + + // We don't check the obfuscated ticket age because it's affected by + // clock skew and it's only a freshness signal useful for shrinking the + // window for replay attacks, which don't affect us as we don't do 0-RTT. + + pskSuite := cipherSuiteTLS13ByID(sessionState.cipherSuite) + if pskSuite == nil || pskSuite.hash != hs.suite.hash { + continue + } + + // PSK connections don't re-establish client certificates, but carry + // them over in the session ticket. Ensure the presence of client certs + // in the ticket is consistent with the configured requirements. + sessionHasClientCerts := len(sessionState.certificate.Certificate) != 0 + needClientCerts := requiresClientCert(c.config.ClientAuth) + if needClientCerts && !sessionHasClientCerts { + continue + } + if sessionHasClientCerts && c.config.ClientAuth == NoClientCert { + continue + } + + psk := hs.suite.expandLabel(sessionState.resumptionSecret, "resumption", + nil, hs.suite.hash.Size()) + hs.earlySecret = hs.suite.extract(psk, nil) + binderKey := hs.suite.deriveSecret(hs.earlySecret, resumptionBinderLabel, nil) + // Clone the transcript in case a HelloRetryRequest was recorded. + transcript := cloneHash(hs.transcript, hs.suite.hash) + if transcript == nil { + c.sendAlert(alertInternalError) + return errors.New("tls: internal error: failed to clone hash") + } + transcript.Write(hs.clientHello.marshalWithoutBinders()) + pskBinder := hs.suite.finishedHash(binderKey, transcript) + if !hmac.Equal(hs.clientHello.pskBinders[i], pskBinder) { + c.sendAlert(alertDecryptError) + return errors.New("tls: invalid PSK binder") + } + + if err := c.processCertsFromClient(sessionState.certificate); err != nil { + return err + } + + hs.hello.selectedIdentityPresent = true + hs.hello.selectedIdentity = uint16(i) + hs.usingPSK = true + c.didResume = true + return nil + } + + return nil +} + +// cloneHash uses the encoding.BinaryMarshaler and encoding.BinaryUnmarshaler +// interfaces implemented by standard library hashes to clone the state of in +// to a new instance of h. It returns nil if the operation fails. +func cloneHash(in hash.Hash, h crypto.Hash) hash.Hash { + // Recreate the interface to avoid importing encoding. + type binaryMarshaler interface { + MarshalBinary() (data []byte, err error) + UnmarshalBinary(data []byte) error + } + marshaler, ok := in.(binaryMarshaler) + if !ok { + return nil + } + state, err := marshaler.MarshalBinary() + if err != nil { + return nil + } + out := h.New() + unmarshaler, ok := out.(binaryMarshaler) + if !ok { + return nil + } + if err := unmarshaler.UnmarshalBinary(state); err != nil { + return nil + } + return out +} + +func (hs *serverHandshakeStateTLS13) pickCertificate() error { + c := hs.c + + // Only one of PSK and certificates are used at a time. + if hs.usingPSK { + return nil + } + + // This implements a very simplistic certificate selection strategy for now: + // getCertificate delegates to the application Config.GetCertificate, or + // selects based on the server_name only. If the selected certificate's + // public key does not match the client signature_algorithms, the handshake + // is aborted. No attention is given to signature_algorithms_cert, and it is + // not passed to the application Config.GetCertificate. This will need to + // improve according to RFC 8446, sections 4.4.2.2 and 4.2.3. + certificate, err := c.config.getCertificate(clientHelloInfo(c, hs.clientHello)) + if err != nil { + c.sendAlert(alertInternalError) + return err + } + supportedAlgs := signatureSchemesForCertificate(c.vers, certificate) + if supportedAlgs == nil { + c.sendAlert(alertInternalError) + return unsupportedCertificateError(certificate) + } + // Pick signature scheme in client preference order, as the server + // preference order is not configurable. + for _, preferredAlg := range hs.clientHello.supportedSignatureAlgorithms { + if isSupportedSignatureAlgorithm(preferredAlg, supportedAlgs) { + hs.sigAlg = preferredAlg + break + } + } + if hs.sigAlg == 0 { + // getCertificate returned a certificate incompatible with the + // ClientHello supported signature algorithms. + c.sendAlert(alertHandshakeFailure) + return errors.New("tls: client doesn't support selected certificate") + } + hs.cert = certificate + + return nil +} + +// sendDummyChangeCipherSpec sends a ChangeCipherSpec record for compatibility +// with middleboxes that didn't implement TLS correctly. See RFC 8446, Appendix D.4. +func (hs *serverHandshakeStateTLS13) sendDummyChangeCipherSpec() error { + if hs.sentDummyCCS { + return nil + } + hs.sentDummyCCS = true + + _, err := hs.c.writeRecord(recordTypeChangeCipherSpec, []byte{1}) + return err +} + +func (hs *serverHandshakeStateTLS13) doHelloRetryRequest(selectedGroup CurveID) error { + c := hs.c + + // The first ClientHello gets double-hashed into the transcript upon a + // HelloRetryRequest. See RFC 8446, Section 4.4.1. + hs.transcript.Write(hs.clientHello.marshal()) + chHash := hs.transcript.Sum(nil) + hs.transcript.Reset() + hs.transcript.Write([]byte{typeMessageHash, 0, 0, uint8(len(chHash))}) + hs.transcript.Write(chHash) + + helloRetryRequest := &serverHelloMsg{ + vers: hs.hello.vers, + random: helloRetryRequestRandom, + sessionId: hs.hello.sessionId, + cipherSuite: hs.hello.cipherSuite, + compressionMethod: hs.hello.compressionMethod, + supportedVersion: hs.hello.supportedVersion, + selectedGroup: selectedGroup, + } + + hs.transcript.Write(helloRetryRequest.marshal()) + if _, err := c.writeRecord(recordTypeHandshake, helloRetryRequest.marshal()); err != nil { + return err + } + + if err := hs.sendDummyChangeCipherSpec(); err != nil { + return err + } + + msg, err := c.readHandshake() + if err != nil { + return err + } + + clientHello, ok := msg.(*clientHelloMsg) + if !ok { + c.sendAlert(alertUnexpectedMessage) + return unexpectedMessageError(clientHello, msg) + } + + if len(clientHello.keyShares) != 1 || clientHello.keyShares[0].group != selectedGroup { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: client sent invalid key share in second ClientHello") + } + + if clientHello.earlyData { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: client indicated early data in second ClientHello") + } + + if illegalClientHelloChange(clientHello, hs.clientHello) { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: client illegally modified second ClientHello") + } + + hs.clientHello = clientHello + return nil +} + +// illegalClientHelloChange reports whether the two ClientHello messages are +// different, with the exception of the changes allowed before and after a +// HelloRetryRequest. See RFC 8446, Section 4.1.2. +func illegalClientHelloChange(ch, ch1 *clientHelloMsg) bool { + if len(ch.supportedVersions) != len(ch1.supportedVersions) || + len(ch.cipherSuites) != len(ch1.cipherSuites) || + len(ch.supportedCurves) != len(ch1.supportedCurves) || + len(ch.supportedSignatureAlgorithms) != len(ch1.supportedSignatureAlgorithms) || + len(ch.supportedSignatureAlgorithmsCert) != len(ch1.supportedSignatureAlgorithmsCert) || + len(ch.alpnProtocols) != len(ch1.alpnProtocols) { + return true + } + for i := range ch.supportedVersions { + if ch.supportedVersions[i] != ch1.supportedVersions[i] { + return true + } + } + for i := range ch.cipherSuites { + if ch.cipherSuites[i] != ch1.cipherSuites[i] { + return true + } + } + for i := range ch.supportedCurves { + if ch.supportedCurves[i] != ch1.supportedCurves[i] { + return true + } + } + for i := range ch.supportedSignatureAlgorithms { + if ch.supportedSignatureAlgorithms[i] != ch1.supportedSignatureAlgorithms[i] { + return true + } + } + for i := range ch.supportedSignatureAlgorithmsCert { + if ch.supportedSignatureAlgorithmsCert[i] != ch1.supportedSignatureAlgorithmsCert[i] { + return true + } + } + for i := range ch.alpnProtocols { + if ch.alpnProtocols[i] != ch1.alpnProtocols[i] { + return true + } + } + return ch.vers != ch1.vers || + !bytes.Equal(ch.random, ch1.random) || + !bytes.Equal(ch.sessionId, ch1.sessionId) || + !bytes.Equal(ch.compressionMethods, ch1.compressionMethods) || + ch.nextProtoNeg != ch1.nextProtoNeg || + ch.serverName != ch1.serverName || + ch.ocspStapling != ch1.ocspStapling || + !bytes.Equal(ch.supportedPoints, ch1.supportedPoints) || + ch.ticketSupported != ch1.ticketSupported || + !bytes.Equal(ch.sessionTicket, ch1.sessionTicket) || + ch.secureRenegotiationSupported != ch1.secureRenegotiationSupported || + !bytes.Equal(ch.secureRenegotiation, ch1.secureRenegotiation) || + ch.scts != ch1.scts || + !bytes.Equal(ch.cookie, ch1.cookie) || + !bytes.Equal(ch.pskModes, ch1.pskModes) +} + +func (hs *serverHandshakeStateTLS13) sendServerParameters() error { + c := hs.c + + hs.transcript.Write(hs.clientHello.marshal()) + hs.transcript.Write(hs.hello.marshal()) + if _, err := c.writeRecord(recordTypeHandshake, hs.hello.marshal()); err != nil { + return err + } + + if err := hs.sendDummyChangeCipherSpec(); err != nil { + return err + } + + earlySecret := hs.earlySecret + if earlySecret == nil { + earlySecret = hs.suite.extract(nil, nil) + } + hs.handshakeSecret = hs.suite.extract(hs.sharedKey, + hs.suite.deriveSecret(earlySecret, "derived", nil)) + + clientSecret := hs.suite.deriveSecret(hs.handshakeSecret, + clientHandshakeTrafficLabel, hs.transcript) + c.in.setTrafficSecret(hs.suite, clientSecret) + serverSecret := hs.suite.deriveSecret(hs.handshakeSecret, + serverHandshakeTrafficLabel, hs.transcript) + c.out.setTrafficSecret(hs.suite, serverSecret) + + err := c.config.writeKeyLog(keyLogLabelClientHandshake, hs.clientHello.random, clientSecret) + if err != nil { + c.sendAlert(alertInternalError) + return err + } + err = c.config.writeKeyLog(keyLogLabelServerHandshake, hs.clientHello.random, serverSecret) + if err != nil { + c.sendAlert(alertInternalError) + return err + } + + encryptedExtensions := new(encryptedExtensionsMsg) + + if len(hs.clientHello.alpnProtocols) > 0 { + if selectedProto, fallback := mutualProtocol(hs.clientHello.alpnProtocols, c.config.NextProtos); !fallback { + encryptedExtensions.alpnProtocol = selectedProto + c.clientProtocol = selectedProto + } + } + + hs.transcript.Write(encryptedExtensions.marshal()) + if _, err := c.writeRecord(recordTypeHandshake, encryptedExtensions.marshal()); err != nil { + return err + } + + return nil +} + +func (hs *serverHandshakeStateTLS13) requestClientCert() bool { + return hs.c.config.ClientAuth >= RequestClientCert && !hs.usingPSK +} + +func (hs *serverHandshakeStateTLS13) sendServerCertificate() error { + c := hs.c + + // Only one of PSK and certificates are used at a time. + if hs.usingPSK { + return nil + } + + if hs.requestClientCert() { + // Request a client certificate + certReq := new(certificateRequestMsgTLS13) + certReq.ocspStapling = true + certReq.scts = true + certReq.supportedSignatureAlgorithms = supportedSignatureAlgorithms + if c.config.ClientCAs != nil { + certReq.certificateAuthorities = c.config.ClientCAs.Subjects() + } + + hs.transcript.Write(certReq.marshal()) + if _, err := c.writeRecord(recordTypeHandshake, certReq.marshal()); err != nil { + return err + } + } + + certMsg := new(certificateMsgTLS13) + + certMsg.certificate = *hs.cert + certMsg.scts = hs.clientHello.scts && len(hs.cert.SignedCertificateTimestamps) > 0 + certMsg.ocspStapling = hs.clientHello.ocspStapling && len(hs.cert.OCSPStaple) > 0 + + hs.transcript.Write(certMsg.marshal()) + if _, err := c.writeRecord(recordTypeHandshake, certMsg.marshal()); err != nil { + return err + } + + certVerifyMsg := new(certificateVerifyMsg) + certVerifyMsg.hasSignatureAlgorithm = true + certVerifyMsg.signatureAlgorithm = hs.sigAlg + + sigType := signatureFromSignatureScheme(hs.sigAlg) + sigHash, err := hashFromSignatureScheme(hs.sigAlg) + if sigType == 0 || err != nil { + return c.sendAlert(alertInternalError) + } + h := sigHash.New() + writeSignedMessage(h, serverSignatureContext, hs.transcript) + + signOpts := crypto.SignerOpts(sigHash) + if sigType == signatureRSAPSS { + signOpts = &rsa.PSSOptions{SaltLength: rsa.PSSSaltLengthEqualsHash, Hash: sigHash} + } + sig, err := hs.cert.PrivateKey.(crypto.Signer).Sign(c.config.rand(), h.Sum(nil), signOpts) + if err != nil { + c.sendAlert(alertInternalError) + return errors.New("tls: failed to sign handshake: " + err.Error()) + } + certVerifyMsg.signature = sig + + hs.transcript.Write(certVerifyMsg.marshal()) + if _, err := c.writeRecord(recordTypeHandshake, certVerifyMsg.marshal()); err != nil { + return err + } + + return nil +} + +func (hs *serverHandshakeStateTLS13) sendServerFinished() error { + c := hs.c + + finished := &finishedMsg{ + verifyData: hs.suite.finishedHash(c.out.trafficSecret, hs.transcript), + } + + hs.transcript.Write(finished.marshal()) + if _, err := c.writeRecord(recordTypeHandshake, finished.marshal()); err != nil { + return err + } + + // Derive secrets that take context through the server Finished. + + hs.masterSecret = hs.suite.extract(nil, + hs.suite.deriveSecret(hs.handshakeSecret, "derived", nil)) + + hs.trafficSecret = hs.suite.deriveSecret(hs.masterSecret, + clientApplicationTrafficLabel, hs.transcript) + serverSecret := hs.suite.deriveSecret(hs.masterSecret, + serverApplicationTrafficLabel, hs.transcript) + c.out.setTrafficSecret(hs.suite, serverSecret) + + err := c.config.writeKeyLog(keyLogLabelClientTraffic, hs.clientHello.random, hs.trafficSecret) + if err != nil { + c.sendAlert(alertInternalError) + return err + } + err = c.config.writeKeyLog(keyLogLabelServerTraffic, hs.clientHello.random, serverSecret) + if err != nil { + c.sendAlert(alertInternalError) + return err + } + + c.ekm = hs.suite.exportKeyingMaterial(hs.masterSecret, hs.transcript) + + // If we did not request client certificates, at this point we can + // precompute the client finished and roll the transcript forward to send + // session tickets in our first flight. + if !hs.requestClientCert() { + if err := hs.sendSessionTickets(); err != nil { + return err + } + } + + return nil +} + +func (hs *serverHandshakeStateTLS13) shouldSendSessionTickets() bool { + if hs.c.config.SessionTicketsDisabled { + return false + } + + // Don't send tickets the client wouldn't use. See RFC 8446, Section 4.2.9. + for _, pskMode := range hs.clientHello.pskModes { + if pskMode == pskModeDHE { + return true + } + } + return false +} + +func (hs *serverHandshakeStateTLS13) sendSessionTickets() error { + c := hs.c + + hs.clientFinished = hs.suite.finishedHash(c.in.trafficSecret, hs.transcript) + finishedMsg := &finishedMsg{ + verifyData: hs.clientFinished, + } + hs.transcript.Write(finishedMsg.marshal()) + + if !hs.shouldSendSessionTickets() { + return nil + } + + resumptionSecret := hs.suite.deriveSecret(hs.masterSecret, + resumptionLabel, hs.transcript) + + m := new(newSessionTicketMsgTLS13) + + var certsFromClient [][]byte + for _, cert := range c.peerCertificates { + certsFromClient = append(certsFromClient, cert.Raw) + } + state := sessionStateTLS13{ + cipherSuite: hs.suite.id, + createdAt: uint64(c.config.time().Unix()), + resumptionSecret: resumptionSecret, + certificate: Certificate{ + Certificate: certsFromClient, + OCSPStaple: c.ocspResponse, + SignedCertificateTimestamps: c.scts, + }, + } + var err error + m.label, err = c.encryptTicket(state.marshal()) + if err != nil { + return err + } + m.lifetime = uint32(maxSessionTicketLifetime / time.Second) + + if _, err := c.writeRecord(recordTypeHandshake, m.marshal()); err != nil { + return err + } + + return nil +} + +func (hs *serverHandshakeStateTLS13) readClientCertificate() error { + c := hs.c + + if !hs.requestClientCert() { + return nil + } + + // If we requested a client certificate, then the client must send a + // certificate message. If it's empty, no CertificateVerify is sent. + + msg, err := c.readHandshake() + if err != nil { + return err + } + + certMsg, ok := msg.(*certificateMsgTLS13) + if !ok { + c.sendAlert(alertUnexpectedMessage) + return unexpectedMessageError(certMsg, msg) + } + hs.transcript.Write(certMsg.marshal()) + + if err := c.processCertsFromClient(certMsg.certificate); err != nil { + return err + } + + if len(certMsg.certificate.Certificate) != 0 { + msg, err = c.readHandshake() + if err != nil { + return err + } + + certVerify, ok := msg.(*certificateVerifyMsg) + if !ok { + c.sendAlert(alertUnexpectedMessage) + return unexpectedMessageError(certVerify, msg) + } + + // See RFC 8446, Section 4.4.3. + if !isSupportedSignatureAlgorithm(certVerify.signatureAlgorithm, supportedSignatureAlgorithms) { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: invalid certificate signature algorithm") + } + sigType := signatureFromSignatureScheme(certVerify.signatureAlgorithm) + sigHash, err := hashFromSignatureScheme(certVerify.signatureAlgorithm) + if sigType == 0 || err != nil { + c.sendAlert(alertInternalError) + return err + } + if sigType == signaturePKCS1v15 || sigHash == crypto.SHA1 { + c.sendAlert(alertIllegalParameter) + return errors.New("tls: invalid certificate signature algorithm") + } + h := sigHash.New() + writeSignedMessage(h, clientSignatureContext, hs.transcript) + if err := verifyHandshakeSignature(sigType, c.peerCertificates[0].PublicKey, + sigHash, h.Sum(nil), certVerify.signature); err != nil { + c.sendAlert(alertDecryptError) + return errors.New("tls: invalid certificate signature") + } + + hs.transcript.Write(certVerify.marshal()) + } + + // If we waited until the client certificates to send session tickets, we + // are ready to do it now. + if err := hs.sendSessionTickets(); err != nil { + return err + } + + return nil +} + +func (hs *serverHandshakeStateTLS13) readClientFinished() error { + c := hs.c + + msg, err := c.readHandshake() + if err != nil { + return err + } + + finished, ok := msg.(*finishedMsg) + if !ok { + c.sendAlert(alertUnexpectedMessage) + return unexpectedMessageError(finished, msg) + } + + if !hmac.Equal(hs.clientFinished, finished.verifyData) { + c.sendAlert(alertDecryptError) + return errors.New("tls: invalid client finished hash") + } + + c.in.setTrafficSecret(hs.suite, hs.trafficSecret) + + return nil +} diff --git a/libgo/go/crypto/tls/handshake_test.go b/libgo/go/crypto/tls/handshake_test.go index 4b3fa238f4a..aa072cef059 100644 --- a/libgo/go/crypto/tls/handshake_test.go +++ b/libgo/go/crypto/tls/handshake_test.go @@ -13,6 +13,7 @@ import ( "io" "io/ioutil" "net" + "os" "os/exec" "strconv" "strings" @@ -67,17 +68,17 @@ func testOpenSSLVersion() { } version := string(output) - if strings.HasPrefix(version, "OpenSSL 1.1.0") { + if strings.HasPrefix(version, "OpenSSL 1.1.1") { return } println("***********************************************") println("") - println("You need to build OpenSSL 1.1.0 from source in order") + println("You need to build OpenSSL 1.1.1 from source in order") println("to update the test data.") println("") println("Configure it with:") - println("./Configure enable-weak-ssl-ciphers enable-ssl3 enable-ssl3-method -static linux-x86_64") + println("./Configure enable-weak-ssl-ciphers enable-ssl3 enable-ssl3-method") println("and then add the apps/ directory at the front of your PATH.") println("***********************************************") @@ -224,3 +225,45 @@ func tempFile(contents string) string { file.Close() return path } + +// localListener is set up by TestMain and used by localPipe to create Conn +// pairs like net.Pipe, but connected by an actual buffered TCP connection. +var localListener struct { + sync.Mutex + net.Listener +} + +func localPipe(t testing.TB) (net.Conn, net.Conn) { + localListener.Lock() + defer localListener.Unlock() + c := make(chan net.Conn) + go func() { + conn, err := localListener.Accept() + if err != nil { + t.Errorf("Failed to accept local connection: %v", err) + } + c <- conn + }() + addr := localListener.Addr() + c1, err := net.Dial(addr.Network(), addr.String()) + if err != nil { + t.Fatalf("Failed to dial local connection: %v", err) + } + c2 := <-c + return c1, c2 +} + +func TestMain(m *testing.M) { + l, err := net.Listen("tcp", "127.0.0.1:0") + if err != nil { + l, err = net.Listen("tcp6", "[::1]:0") + } + if err != nil { + fmt.Fprintf(os.Stderr, "Failed to open local listener: %v", err) + os.Exit(1) + } + localListener.Listener = l + exitCode := m.Run() + localListener.Close() + os.Exit(exitCode) +} diff --git a/libgo/go/crypto/tls/key_agreement.go b/libgo/go/crypto/tls/key_agreement.go index 1e77facce07..628e578e483 100644 --- a/libgo/go/crypto/tls/key_agreement.go +++ b/libgo/go/crypto/tls/key_agreement.go @@ -6,16 +6,12 @@ package tls import ( "crypto" - "crypto/elliptic" "crypto/md5" "crypto/rsa" "crypto/sha1" "crypto/x509" "errors" "io" - "math/big" - - "golang_org/x/crypto/curve25519" ) var errClientKeyExchange = errors.New("tls: invalid ClientKeyExchange message") @@ -125,86 +121,54 @@ func hashForServerKeyExchange(sigType uint8, hashFunc crypto.Hash, version uint1 return md5SHA1Hash(slices), nil } -func curveForCurveID(id CurveID) (elliptic.Curve, bool) { - switch id { - case CurveP256: - return elliptic.P256(), true - case CurveP384: - return elliptic.P384(), true - case CurveP521: - return elliptic.P521(), true - default: - return nil, false - } - -} - // ecdheKeyAgreement implements a TLS key agreement where the server // generates an ephemeral EC public/private key pair and signs it. The // pre-master secret is then calculated using ECDH. The signature may // either be ECDSA or RSA. type ecdheKeyAgreement struct { - version uint16 - isRSA bool - privateKey []byte - curveid CurveID - - // publicKey is used to store the peer's public value when X25519 is - // being used. - publicKey []byte - // x and y are used to store the peer's public value when one of the - // NIST curves is being used. - x, y *big.Int + version uint16 + isRSA bool + params ecdheParameters + + // ckx and preMasterSecret are generated in processServerKeyExchange + // and returned in generateClientKeyExchange. + ckx *clientKeyExchangeMsg + preMasterSecret []byte } func (ka *ecdheKeyAgreement) generateServerKeyExchange(config *Config, cert *Certificate, clientHello *clientHelloMsg, hello *serverHelloMsg) (*serverKeyExchangeMsg, error) { preferredCurves := config.curvePreferences() + var curveID CurveID NextCandidate: for _, candidate := range preferredCurves { for _, c := range clientHello.supportedCurves { if candidate == c { - ka.curveid = c + curveID = c break NextCandidate } } } - if ka.curveid == 0 { + if curveID == 0 { return nil, errors.New("tls: no supported elliptic curves offered") } + if _, ok := curveForCurveID(curveID); curveID != X25519 && !ok { + return nil, errors.New("tls: CurvePreferences includes unsupported curve") + } - var ecdhePublic []byte - - if ka.curveid == X25519 { - var scalar, public [32]byte - if _, err := io.ReadFull(config.rand(), scalar[:]); err != nil { - return nil, err - } - - curve25519.ScalarBaseMult(&public, &scalar) - ka.privateKey = scalar[:] - ecdhePublic = public[:] - } else { - curve, ok := curveForCurveID(ka.curveid) - if !ok { - return nil, errors.New("tls: preferredCurves includes unsupported curve") - } - - var x, y *big.Int - var err error - ka.privateKey, x, y, err = elliptic.GenerateKey(curve, config.rand()) - if err != nil { - return nil, err - } - ecdhePublic = elliptic.Marshal(curve, x, y) + params, err := generateECDHEParameters(config.rand(), curveID) + if err != nil { + return nil, err } + ka.params = params - // https://tools.ietf.org/html/rfc4492#section-5.4 + // See RFC 4492, Section 5.4. + ecdhePublic := params.PublicKey() serverECDHParams := make([]byte, 1+2+1+len(ecdhePublic)) serverECDHParams[0] = 3 // named curve - serverECDHParams[1] = byte(ka.curveid >> 8) - serverECDHParams[2] = byte(ka.curveid) + serverECDHParams[1] = byte(curveID >> 8) + serverECDHParams[2] = byte(curveID) serverECDHParams[3] = byte(len(ecdhePublic)) copy(serverECDHParams[4:], ecdhePublic) @@ -260,30 +224,10 @@ func (ka *ecdheKeyAgreement) processClientKeyExchange(config *Config, cert *Cert return nil, errClientKeyExchange } - if ka.curveid == X25519 { - if len(ckx.ciphertext) != 1+32 { - return nil, errClientKeyExchange - } - - var theirPublic, sharedKey, scalar [32]byte - copy(theirPublic[:], ckx.ciphertext[1:]) - copy(scalar[:], ka.privateKey) - curve25519.ScalarMult(&sharedKey, &scalar, &theirPublic) - return sharedKey[:], nil - } - - curve, ok := curveForCurveID(ka.curveid) - if !ok { - panic("internal error") - } - x, y := elliptic.Unmarshal(curve, ckx.ciphertext[1:]) // Unmarshal also checks whether the given point is on the curve - if x == nil { + preMasterSecret := ka.params.SharedKey(ckx.ciphertext[1:]) + if preMasterSecret == nil { return nil, errClientKeyExchange } - x, _ = curve.ScalarMult(x, y, ka.privateKey) - preMasterSecret := make([]byte, (curve.Params().BitSize+7)>>3) - xBytes := x.Bytes() - copy(preMasterSecret[len(preMasterSecret)-len(xBytes):], xBytes) return preMasterSecret, nil } @@ -295,7 +239,7 @@ func (ka *ecdheKeyAgreement) processServerKeyExchange(config *Config, clientHell if skx.key[0] != 3 { // named curve return errors.New("tls: server selected unsupported curve") } - ka.curveid = CurveID(skx.key[1])<<8 | CurveID(skx.key[2]) + curveID := CurveID(skx.key[1])<<8 | CurveID(skx.key[2]) publicLen := int(skx.key[3]) if publicLen+4 > len(skx.key) { @@ -309,22 +253,27 @@ func (ka *ecdheKeyAgreement) processServerKeyExchange(config *Config, clientHell return errServerKeyExchange } - if ka.curveid == X25519 { - if len(publicKey) != 32 { - return errors.New("tls: bad X25519 public value") - } - ka.publicKey = publicKey - } else { - curve, ok := curveForCurveID(ka.curveid) - if !ok { - return errors.New("tls: server selected unsupported curve") - } - ka.x, ka.y = elliptic.Unmarshal(curve, publicKey) // Unmarshal also checks whether the given point is on the curve - if ka.x == nil { - return errServerKeyExchange - } + if _, ok := curveForCurveID(curveID); curveID != X25519 && !ok { + return errors.New("tls: server selected unsupported curve") + } + + params, err := generateECDHEParameters(config.rand(), curveID) + if err != nil { + return err + } + ka.params = params + + ka.preMasterSecret = params.SharedKey(publicKey) + if ka.preMasterSecret == nil { + return errServerKeyExchange } + ourPublicKey := params.PublicKey() + ka.ckx = new(clientKeyExchangeMsg) + ka.ckx.ciphertext = make([]byte, 1+len(ourPublicKey)) + ka.ckx.ciphertext[0] = byte(len(ourPublicKey)) + copy(ka.ckx.ciphertext[1:], ourPublicKey) + var signatureAlgorithm SignatureScheme if ka.version >= VersionTLS12 { // handle SignatureAndHashAlgorithm @@ -356,45 +305,9 @@ func (ka *ecdheKeyAgreement) processServerKeyExchange(config *Config, clientHell } func (ka *ecdheKeyAgreement) generateClientKeyExchange(config *Config, clientHello *clientHelloMsg, cert *x509.Certificate) ([]byte, *clientKeyExchangeMsg, error) { - if ka.curveid == 0 { + if ka.ckx == nil { return nil, nil, errors.New("tls: missing ServerKeyExchange message") } - var serialized, preMasterSecret []byte - - if ka.curveid == X25519 { - var ourPublic, theirPublic, sharedKey, scalar [32]byte - - if _, err := io.ReadFull(config.rand(), scalar[:]); err != nil { - return nil, nil, err - } - - copy(theirPublic[:], ka.publicKey) - curve25519.ScalarBaseMult(&ourPublic, &scalar) - curve25519.ScalarMult(&sharedKey, &scalar, &theirPublic) - serialized = ourPublic[:] - preMasterSecret = sharedKey[:] - } else { - curve, ok := curveForCurveID(ka.curveid) - if !ok { - panic("internal error") - } - priv, mx, my, err := elliptic.GenerateKey(curve, config.rand()) - if err != nil { - return nil, nil, err - } - x, _ := curve.ScalarMult(ka.x, ka.y, priv) - preMasterSecret = make([]byte, (curve.Params().BitSize+7)>>3) - xBytes := x.Bytes() - copy(preMasterSecret[len(preMasterSecret)-len(xBytes):], xBytes) - - serialized = elliptic.Marshal(curve, mx, my) - } - - ckx := new(clientKeyExchangeMsg) - ckx.ciphertext = make([]byte, 1+len(serialized)) - ckx.ciphertext[0] = byte(len(serialized)) - copy(ckx.ciphertext[1:], serialized) - - return preMasterSecret, ckx, nil + return ka.preMasterSecret, ka.ckx, nil } diff --git a/libgo/go/crypto/tls/key_schedule.go b/libgo/go/crypto/tls/key_schedule.go new file mode 100644 index 00000000000..2cfc226d7f6 --- /dev/null +++ b/libgo/go/crypto/tls/key_schedule.go @@ -0,0 +1,200 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package tls + +import ( + "crypto/elliptic" + "crypto/hmac" + "errors" + "hash" + "internal/x/crypto/cryptobyte" + "internal/x/crypto/curve25519" + "internal/x/crypto/hkdf" + "io" + "math/big" +) + +// This file contains the functions necessary to compute the TLS 1.3 key +// schedule. See RFC 8446, Section 7. + +const ( + resumptionBinderLabel = "res binder" + clientHandshakeTrafficLabel = "c hs traffic" + serverHandshakeTrafficLabel = "s hs traffic" + clientApplicationTrafficLabel = "c ap traffic" + serverApplicationTrafficLabel = "s ap traffic" + exporterLabel = "exp master" + resumptionLabel = "res master" + trafficUpdateLabel = "traffic upd" +) + +// expandLabel implements HKDF-Expand-Label from RFC 8446, Section 7.1. +func (c *cipherSuiteTLS13) expandLabel(secret []byte, label string, context []byte, length int) []byte { + var hkdfLabel cryptobyte.Builder + hkdfLabel.AddUint16(uint16(length)) + hkdfLabel.AddUint8LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes([]byte("tls13 ")) + b.AddBytes([]byte(label)) + }) + hkdfLabel.AddUint8LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(context) + }) + out := make([]byte, length) + n, err := hkdf.Expand(c.hash.New, secret, hkdfLabel.BytesOrPanic()).Read(out) + if err != nil || n != length { + panic("tls: HKDF-Expand-Label invocation failed unexpectedly") + } + return out +} + +// deriveSecret implements Derive-Secret from RFC 8446, Section 7.1. +func (c *cipherSuiteTLS13) deriveSecret(secret []byte, label string, transcript hash.Hash) []byte { + if transcript == nil { + transcript = c.hash.New() + } + return c.expandLabel(secret, label, transcript.Sum(nil), c.hash.Size()) +} + +// extract implements HKDF-Extract with the cipher suite hash. +func (c *cipherSuiteTLS13) extract(newSecret, currentSecret []byte) []byte { + if newSecret == nil { + newSecret = make([]byte, c.hash.Size()) + } + return hkdf.Extract(c.hash.New, newSecret, currentSecret) +} + +// nextTrafficSecret generates the next traffic secret, given the current one, +// according to RFC 8446, Section 7.2. +func (c *cipherSuiteTLS13) nextTrafficSecret(trafficSecret []byte) []byte { + return c.expandLabel(trafficSecret, trafficUpdateLabel, nil, c.hash.Size()) +} + +// trafficKey generates traffic keys according to RFC 8446, Section 7.3. +func (c *cipherSuiteTLS13) trafficKey(trafficSecret []byte) (key, iv []byte) { + key = c.expandLabel(trafficSecret, "key", nil, c.keyLen) + iv = c.expandLabel(trafficSecret, "iv", nil, aeadNonceLength) + return +} + +// finishedHash generates the Finished verify_data or PskBinderEntry according +// to RFC 8446, Section 4.4.4. See sections 4.4 and 4.2.11.2 for the baseKey +// selection. +func (c *cipherSuiteTLS13) finishedHash(baseKey []byte, transcript hash.Hash) []byte { + finishedKey := c.expandLabel(baseKey, "finished", nil, c.hash.Size()) + verifyData := hmac.New(c.hash.New, finishedKey) + verifyData.Write(transcript.Sum(nil)) + return verifyData.Sum(nil) +} + +// exportKeyingMaterial implements RFC5705 exporters for TLS 1.3 according to +// RFC 8446, Section 7.5. +func (c *cipherSuiteTLS13) exportKeyingMaterial(masterSecret []byte, transcript hash.Hash) func(string, []byte, int) ([]byte, error) { + expMasterSecret := c.deriveSecret(masterSecret, exporterLabel, transcript) + return func(label string, context []byte, length int) ([]byte, error) { + secret := c.deriveSecret(expMasterSecret, label, nil) + h := c.hash.New() + h.Write(context) + return c.expandLabel(secret, "exporter", h.Sum(nil), length), nil + } +} + +// ecdheParameters implements Diffie-Hellman with either NIST curves or X25519, +// according to RFC 8446, Section 4.2.8.2. +type ecdheParameters interface { + CurveID() CurveID + PublicKey() []byte + SharedKey(peerPublicKey []byte) []byte +} + +func generateECDHEParameters(rand io.Reader, curveID CurveID) (ecdheParameters, error) { + if curveID == X25519 { + p := &x25519Parameters{} + if _, err := io.ReadFull(rand, p.privateKey[:]); err != nil { + return nil, err + } + curve25519.ScalarBaseMult(&p.publicKey, &p.privateKey) + return p, nil + } + + curve, ok := curveForCurveID(curveID) + if !ok { + return nil, errors.New("tls: internal error: unsupported curve") + } + + p := &nistParameters{curveID: curveID} + var err error + p.privateKey, p.x, p.y, err = elliptic.GenerateKey(curve, rand) + if err != nil { + return nil, err + } + return p, nil +} + +func curveForCurveID(id CurveID) (elliptic.Curve, bool) { + switch id { + case CurveP256: + return elliptic.P256(), true + case CurveP384: + return elliptic.P384(), true + case CurveP521: + return elliptic.P521(), true + default: + return nil, false + } +} + +type nistParameters struct { + privateKey []byte + x, y *big.Int // public key + curveID CurveID +} + +func (p *nistParameters) CurveID() CurveID { + return p.curveID +} + +func (p *nistParameters) PublicKey() []byte { + curve, _ := curveForCurveID(p.curveID) + return elliptic.Marshal(curve, p.x, p.y) +} + +func (p *nistParameters) SharedKey(peerPublicKey []byte) []byte { + curve, _ := curveForCurveID(p.curveID) + // Unmarshal also checks whether the given point is on the curve. + x, y := elliptic.Unmarshal(curve, peerPublicKey) + if x == nil { + return nil + } + + xShared, _ := curve.ScalarMult(x, y, p.privateKey) + sharedKey := make([]byte, (curve.Params().BitSize+7)>>3) + xBytes := xShared.Bytes() + copy(sharedKey[len(sharedKey)-len(xBytes):], xBytes) + + return sharedKey +} + +type x25519Parameters struct { + privateKey [32]byte + publicKey [32]byte +} + +func (p *x25519Parameters) CurveID() CurveID { + return X25519 +} + +func (p *x25519Parameters) PublicKey() []byte { + return p.publicKey[:] +} + +func (p *x25519Parameters) SharedKey(peerPublicKey []byte) []byte { + if len(peerPublicKey) != 32 { + return nil + } + var theirPublicKey, sharedKey [32]byte + copy(theirPublicKey[:], peerPublicKey) + curve25519.ScalarMult(&sharedKey, &p.privateKey, &theirPublicKey) + return sharedKey[:] +} diff --git a/libgo/go/crypto/tls/key_schedule_test.go b/libgo/go/crypto/tls/key_schedule_test.go new file mode 100644 index 00000000000..79ff6a62b19 --- /dev/null +++ b/libgo/go/crypto/tls/key_schedule_test.go @@ -0,0 +1,175 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package tls + +import ( + "bytes" + "encoding/hex" + "hash" + "strings" + "testing" + "unicode" +) + +// This file contains tests derived from draft-ietf-tls-tls13-vectors-07. + +func parseVector(v string) []byte { + v = strings.Map(func(c rune) rune { + if unicode.IsSpace(c) { + return -1 + } + return c + }, v) + parts := strings.Split(v, ":") + v = parts[len(parts)-1] + res, err := hex.DecodeString(v) + if err != nil { + panic(err) + } + return res +} + +func TestDeriveSecret(t *testing.T) { + chTranscript := cipherSuitesTLS13[0].hash.New() + chTranscript.Write(parseVector(` + payload (512 octets): 01 00 01 fc 03 03 1b c3 ce b6 bb e3 9c ff + 93 83 55 b5 a5 0a db 6d b2 1b 7a 6a f6 49 d7 b4 bc 41 9d 78 76 + 48 7d 95 00 00 06 13 01 13 03 13 02 01 00 01 cd 00 00 00 0b 00 + 09 00 00 06 73 65 72 76 65 72 ff 01 00 01 00 00 0a 00 14 00 12 + 00 1d 00 17 00 18 00 19 01 00 01 01 01 02 01 03 01 04 00 33 00 + 26 00 24 00 1d 00 20 e4 ff b6 8a c0 5f 8d 96 c9 9d a2 66 98 34 + 6c 6b e1 64 82 ba dd da fe 05 1a 66 b4 f1 8d 66 8f 0b 00 2a 00 + 00 00 2b 00 03 02 03 04 00 0d 00 20 00 1e 04 03 05 03 06 03 02 + 03 08 04 08 05 08 06 04 01 05 01 06 01 02 01 04 02 05 02 06 02 + 02 02 00 2d 00 02 01 01 00 1c 00 02 40 01 00 15 00 57 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 29 00 dd 00 b8 00 b2 2c 03 5d 82 93 59 ee 5f f7 af 4e c9 00 + 00 00 00 26 2a 64 94 dc 48 6d 2c 8a 34 cb 33 fa 90 bf 1b 00 70 + ad 3c 49 88 83 c9 36 7c 09 a2 be 78 5a bc 55 cd 22 60 97 a3 a9 + 82 11 72 83 f8 2a 03 a1 43 ef d3 ff 5d d3 6d 64 e8 61 be 7f d6 + 1d 28 27 db 27 9c ce 14 50 77 d4 54 a3 66 4d 4e 6d a4 d2 9e e0 + 37 25 a6 a4 da fc d0 fc 67 d2 ae a7 05 29 51 3e 3d a2 67 7f a5 + 90 6c 5b 3f 7d 8f 92 f2 28 bd a4 0d da 72 14 70 f9 fb f2 97 b5 + ae a6 17 64 6f ac 5c 03 27 2e 97 07 27 c6 21 a7 91 41 ef 5f 7d + e6 50 5e 5b fb c3 88 e9 33 43 69 40 93 93 4a e4 d3 57 fa d6 aa + cb 00 21 20 3a dd 4f b2 d8 fd f8 22 a0 ca 3c f7 67 8e f5 e8 8d + ae 99 01 41 c5 92 4d 57 bb 6f a3 1b 9e 5f 9d`)) + + type args struct { + secret []byte + label string + transcript hash.Hash + } + tests := []struct { + name string + args args + want []byte + }{ + { + `derive secret for handshake "tls13 derived"`, + args{ + parseVector(`PRK (32 octets): 33 ad 0a 1c 60 7e c0 3b 09 e6 cd 98 93 68 0c e2 + 10 ad f3 00 aa 1f 26 60 e1 b2 2e 10 f1 70 f9 2a`), + "derived", + nil, + }, + parseVector(`expanded (32 octets): 6f 26 15 a1 08 c7 02 c5 67 8f 54 fc 9d ba + b6 97 16 c0 76 18 9c 48 25 0c eb ea c3 57 6c 36 11 ba`), + }, + { + `derive secret "tls13 c e traffic"`, + args{ + parseVector(`PRK (32 octets): 9b 21 88 e9 b2 fc 6d 64 d7 1d c3 29 90 0e 20 bb + 41 91 50 00 f6 78 aa 83 9c bb 79 7c b7 d8 33 2c`), + "c e traffic", + chTranscript, + }, + parseVector(`expanded (32 octets): 3f bb e6 a6 0d eb 66 c3 0a 32 79 5a ba 0e + ff 7e aa 10 10 55 86 e7 be 5c 09 67 8d 63 b6 ca ab 62`), + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + c := cipherSuitesTLS13[0] + if got := c.deriveSecret(tt.args.secret, tt.args.label, tt.args.transcript); !bytes.Equal(got, tt.want) { + t.Errorf("cipherSuiteTLS13.deriveSecret() = % x, want % x", got, tt.want) + } + }) + } +} + +func TestTrafficKey(t *testing.T) { + trafficSecret := parseVector( + `PRK (32 octets): b6 7b 7d 69 0c c1 6c 4e 75 e5 42 13 cb 2d 37 b4 + e9 c9 12 bc de d9 10 5d 42 be fd 59 d3 91 ad 38`) + wantKey := parseVector( + `key expanded (16 octets): 3f ce 51 60 09 c2 17 27 d0 f2 e4 e8 6e + e4 03 bc`) + wantIV := parseVector( + `iv expanded (12 octets): 5d 31 3e b2 67 12 76 ee 13 00 0b 30`) + + c := cipherSuitesTLS13[0] + gotKey, gotIV := c.trafficKey(trafficSecret) + if !bytes.Equal(gotKey, wantKey) { + t.Errorf("cipherSuiteTLS13.trafficKey() gotKey = % x, want % x", gotKey, wantKey) + } + if !bytes.Equal(gotIV, wantIV) { + t.Errorf("cipherSuiteTLS13.trafficKey() gotIV = % x, want % x", gotIV, wantIV) + } +} + +func TestExtract(t *testing.T) { + type args struct { + newSecret []byte + currentSecret []byte + } + tests := []struct { + name string + args args + want []byte + }{ + { + `extract secret "early"`, + args{ + nil, + nil, + }, + parseVector(`secret (32 octets): 33 ad 0a 1c 60 7e c0 3b 09 e6 cd 98 93 68 0c + e2 10 ad f3 00 aa 1f 26 60 e1 b2 2e 10 f1 70 f9 2a`), + }, + { + `extract secret "master"`, + args{ + nil, + parseVector(`salt (32 octets): 43 de 77 e0 c7 77 13 85 9a 94 4d b9 db 25 90 b5 + 31 90 a6 5b 3e e2 e4 f1 2d d7 a0 bb 7c e2 54 b4`), + }, + parseVector(`secret (32 octets): 18 df 06 84 3d 13 a0 8b f2 a4 49 84 4c 5f 8a + 47 80 01 bc 4d 4c 62 79 84 d5 a4 1d a8 d0 40 29 19`), + }, + { + `extract secret "handshake"`, + args{ + parseVector(`IKM (32 octets): 8b d4 05 4f b5 5b 9d 63 fd fb ac f9 f0 4b 9f 0d + 35 e6 d6 3f 53 75 63 ef d4 62 72 90 0f 89 49 2d`), + parseVector(`salt (32 octets): 6f 26 15 a1 08 c7 02 c5 67 8f 54 fc 9d ba b6 97 + 16 c0 76 18 9c 48 25 0c eb ea c3 57 6c 36 11 ba`), + }, + parseVector(`secret (32 octets): 1d c8 26 e9 36 06 aa 6f dc 0a ad c1 2f 74 1b + 01 04 6a a6 b9 9f 69 1e d2 21 a9 f0 ca 04 3f be ac`), + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + c := cipherSuitesTLS13[0] + if got := c.extract(tt.args.newSecret, tt.args.currentSecret); !bytes.Equal(got, tt.want) { + t.Errorf("cipherSuiteTLS13.extract() = % x, want % x", got, tt.want) + } + }) + } +} diff --git a/libgo/go/crypto/tls/prf.go b/libgo/go/crypto/tls/prf.go index a8cf21da15f..5379397c265 100644 --- a/libgo/go/crypto/tls/prf.go +++ b/libgo/go/crypto/tls/prf.go @@ -16,14 +16,14 @@ import ( "hash" ) -// Split a premaster secret in two as specified in RFC 4346, section 5. +// Split a premaster secret in two as specified in RFC 4346, Section 5. func splitPreMasterSecret(secret []byte) (s1, s2 []byte) { s1 = secret[0 : (len(secret)+1)/2] s2 = secret[len(secret)/2:] return } -// pHash implements the P_hash function, as defined in RFC 4346, section 5. +// pHash implements the P_hash function, as defined in RFC 4346, Section 5. func pHash(result, secret, seed []byte, hash func() hash.Hash) { h := hmac.New(hash, secret) h.Write(seed) @@ -44,7 +44,7 @@ func pHash(result, secret, seed []byte, hash func() hash.Hash) { } } -// prf10 implements the TLS 1.0 pseudo-random function, as defined in RFC 2246, section 5. +// prf10 implements the TLS 1.0 pseudo-random function, as defined in RFC 2246, Section 5. func prf10(result, secret, label, seed []byte) { hashSHA1 := sha1.New hashMD5 := md5.New @@ -63,7 +63,7 @@ func prf10(result, secret, label, seed []byte) { } } -// prf12 implements the TLS 1.2 pseudo-random function, as defined in RFC 5246, section 5. +// prf12 implements the TLS 1.2 pseudo-random function, as defined in RFC 5246, Section 5. func prf12(hashFunc func() hash.Hash) func(result, secret, label, seed []byte) { return func(result, secret, label, seed []byte) { labelAndSeed := make([]byte, len(label)+len(seed)) @@ -108,7 +108,6 @@ func prf30(result, secret, label, seed []byte) { } const ( - tlsRandomLength = 32 // Length of a random nonce in TLS 1.1. masterSecretLength = 48 // Length of a master secret in TLS 1.1. finishedVerifyLength = 12 // Length of verify_data in a Finished message. ) @@ -140,7 +139,7 @@ func prfForVersion(version uint16, suite *cipherSuite) func(result, secret, labe } // masterFromPreMasterSecret generates the master secret from the pre-master -// secret. See https://tools.ietf.org/html/rfc5246#section-8.1 +// secret. See RFC 5246, Section 8.1. func masterFromPreMasterSecret(version uint16, suite *cipherSuite, preMasterSecret, clientRandom, serverRandom []byte) []byte { seed := make([]byte, 0, len(clientRandom)+len(serverRandom)) seed = append(seed, clientRandom...) @@ -153,7 +152,7 @@ func masterFromPreMasterSecret(version uint16, suite *cipherSuite, preMasterSecr // keysFromMasterSecret generates the connection keys from the master // secret, given the lengths of the MAC key, cipher key and IV, as defined in -// RFC 2246, section 6.3. +// RFC 2246, Section 6.3. func keysFromMasterSecret(version uint16, suite *cipherSuite, masterSecret, clientRandom, serverRandom []byte, macLen, keyLen, ivLen int) (clientMAC, serverMAC, clientKey, serverKey, clientIV, serverIV []byte) { seed := make([]byte, 0, len(serverRandom)+len(clientRandom)) seed = append(seed, serverRandom...) @@ -176,9 +175,9 @@ func keysFromMasterSecret(version uint16, suite *cipherSuite, masterSecret, clie return } -// lookupTLSHash looks up the corresponding crypto.Hash for a given +// hashFromSignatureScheme returns the corresponding crypto.Hash for a given // hash from a TLS SignatureScheme. -func lookupTLSHash(signatureAlgorithm SignatureScheme) (crypto.Hash, error) { +func hashFromSignatureScheme(signatureAlgorithm SignatureScheme) (crypto.Hash, error) { switch signatureAlgorithm { case PKCS1WithSHA1, ECDSAWithSHA1: return crypto.SHA1, nil @@ -353,8 +352,7 @@ func noExportedKeyingMaterial(label string, context []byte, length int) ([]byte, return nil, errors.New("crypto/tls: ExportKeyingMaterial is unavailable when renegotiation is enabled") } -// ekmFromMasterSecret generates exported keying material as defined in -// https://tools.ietf.org/html/rfc5705. +// ekmFromMasterSecret generates exported keying material as defined in RFC 5705. func ekmFromMasterSecret(version uint16, suite *cipherSuite, masterSecret, clientRandom, serverRandom []byte) func(string, []byte, int) ([]byte, error) { return func(label string, context []byte, length int) ([]byte, error) { switch label { diff --git a/libgo/go/crypto/tls/prf_test.go b/libgo/go/crypto/tls/prf_test.go index f201253f72e..ec54aac12e4 100644 --- a/libgo/go/crypto/tls/prf_test.go +++ b/libgo/go/crypto/tls/prf_test.go @@ -87,20 +87,11 @@ func TestKeysFromPreMasterSecret(t *testing.T) { } } -func cipherSuiteById(id uint16) *cipherSuite { - for _, cipherSuite := range cipherSuites { - if cipherSuite.id == id { - return cipherSuite - } - } - panic("ciphersuite not found") -} - // These test vectors were generated from GnuTLS using `gnutls-cli --insecure -d 9 ` var testKeysFromTests = []testKeysFromTest{ { VersionTLS10, - cipherSuiteById(TLS_RSA_WITH_RC4_128_SHA), + cipherSuiteByID(TLS_RSA_WITH_RC4_128_SHA), "0302cac83ad4b1db3b9ab49ad05957de2a504a634a386fc600889321e1a971f57479466830ac3e6f468e87f5385fa0c5", "4ae66303755184a3917fcb44880605fcc53baa01912b22ed94473fc69cebd558", "4ae663020ec16e6bb5130be918cfcafd4d765979a3136a5d50c593446e4e44db", @@ -116,7 +107,7 @@ var testKeysFromTests = []testKeysFromTest{ }, { VersionTLS10, - cipherSuiteById(TLS_RSA_WITH_RC4_128_SHA), + cipherSuiteByID(TLS_RSA_WITH_RC4_128_SHA), "03023f7527316bc12cbcd69e4b9e8275d62c028f27e65c745cfcddc7ce01bd3570a111378b63848127f1c36e5f9e4890", "4ae66364b5ea56b20ce4e25555aed2d7e67f42788dd03f3fee4adae0459ab106", "4ae66363ab815cbf6a248b87d6b556184e945e9b97fbdf247858b0bdafacfa1c", @@ -132,7 +123,7 @@ var testKeysFromTests = []testKeysFromTest{ }, { VersionTLS10, - cipherSuiteById(TLS_RSA_WITH_RC4_128_SHA), + cipherSuiteByID(TLS_RSA_WITH_RC4_128_SHA), "832d515f1d61eebb2be56ba0ef79879efb9b527504abb386fb4310ed5d0e3b1f220d3bb6b455033a2773e6d8bdf951d278a187482b400d45deb88a5d5a6bb7d6a7a1decc04eb9ef0642876cd4a82d374d3b6ff35f0351dc5d411104de431375355addc39bfb1f6329fb163b0bc298d658338930d07d313cd980a7e3d9196cac1", "4ae663b2ee389c0de147c509d8f18f5052afc4aaf9699efe8cb05ece883d3a5e", "4ae664d503fd4cff50cfc1fb8fc606580f87b0fcdac9554ba0e01d785bdf278e", @@ -148,7 +139,7 @@ var testKeysFromTests = []testKeysFromTest{ }, { VersionSSL30, - cipherSuiteById(TLS_RSA_WITH_RC4_128_SHA), + cipherSuiteByID(TLS_RSA_WITH_RC4_128_SHA), "832d515f1d61eebb2be56ba0ef79879efb9b527504abb386fb4310ed5d0e3b1f220d3bb6b455033a2773e6d8bdf951d278a187482b400d45deb88a5d5a6bb7d6a7a1decc04eb9ef0642876cd4a82d374d3b6ff35f0351dc5d411104de431375355addc39bfb1f6329fb163b0bc298d658338930d07d313cd980a7e3d9196cac1", "4ae663b2ee389c0de147c509d8f18f5052afc4aaf9699efe8cb05ece883d3a5e", "4ae664d503fd4cff50cfc1fb8fc606580f87b0fcdac9554ba0e01d785bdf278e", diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv10-ClientCert-ECDSA-ECDSA b/libgo/go/crypto/tls/testdata/Client-TLSv10-ClientCert-ECDSA-ECDSA index f7b661223f5..009e6585c6a 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv10-ClientCert-ECDSA-ECDSA +++ b/libgo/go/crypto/tls/testdata/Client-TLSv10-ClientCert-ECDSA-ECDSA @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 01 00 59 02 00 00 55 03 01 37 4c 3d 48 47 |....Y...U..7L=HG| -00000010 2c b1 fb 63 1d 94 a6 b7 57 87 72 ec 4d 29 f9 4e |,..c....W.r.M).N| -00000020 81 d1 b6 27 8c 6a 27 c0 d3 c5 32 20 2d 80 95 68 |...'.j'...2 -..h| -00000030 a9 f9 2a 79 af be 9f d3 ce 4f 6a 2c 6b b3 dd 9e |..*y.....Oj,k...| -00000040 62 e2 08 b9 24 a3 fe 23 11 f8 cd ab c0 09 00 00 |b...$..#........| +00000000 16 03 01 00 59 02 00 00 55 03 01 80 87 8d 86 82 |....Y...U.......| +00000010 b7 ab d8 7d 1c b5 86 ca 1c af 7e c0 07 6d 43 3e |...}......~..mC>| +00000020 10 59 aa 08 19 ae d0 b8 a1 f5 23 20 b6 3d 32 8b |.Y........# .=2.| +00000030 f9 52 1a 01 eb 69 35 7c be 2d a9 ca 55 21 f3 b3 |.R...i5|.-..U!..| +00000040 87 89 1e 05 cb cb 5d af 97 84 7e 07 c0 09 00 00 |......]...~.....| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 01 02 0e 0b 00 02 0a 00 02 07 00 02 04 30 82 02 |.............0..| 00000070 00 30 82 01 62 02 09 00 b8 bf 2d 47 a0 d2 eb f4 |.0..b.....-G....| @@ -49,18 +55,18 @@ 00000240 13 83 0d 94 06 bb d4 37 7a f6 ec 7a c9 86 2e dd |.......7z..z....| 00000250 d7 11 69 7f 85 7c 56 de fb 31 78 2b e4 c7 78 0d |..i..|V..1x+..x.| 00000260 ae cb be 9e 4e 36 24 31 7b 6a 0f 39 95 12 07 8f |....N6$1{j.9....| -00000270 2a 16 03 01 00 b5 0c 00 00 b1 03 00 1d 20 14 a7 |*............ ..| -00000280 f5 4f 06 cf f6 92 3d 98 59 e2 36 72 2c 45 ce 98 |.O....=.Y.6r,E..| -00000290 a2 97 c3 3c ba 67 b3 6a fe 0a 2c f7 ae 03 00 8b |...<.g.j..,.....| -000002a0 30 81 88 02 42 00 cd a1 a2 cc 81 c9 7a c5 a9 54 |0...B.......z..T| -000002b0 19 61 0a d3 23 7a cb f8 52 54 16 c3 38 b6 9e f2 |.a..#z..RT..8...| -000002c0 a6 7f 5a 5c e7 3f ae c8 85 c1 01 6f 90 94 c4 e1 |..Z\.?.....o....| -000002d0 c3 56 b3 da 4c 92 9c 11 0f 4d 06 31 3f d9 a4 77 |.V..L....M.1?..w| -000002e0 1e 99 f6 3d ef 5e 06 02 42 01 4c f6 ac 3b 87 7b |...=.^..B.L..;.{| -000002f0 a1 3b 59 28 ab 00 dd 06 e7 9c 8a 8b 0e 50 48 49 |.;Y(.........PHI| -00000300 4d b8 56 34 94 6a 7f 7a 6c 17 b0 2a 29 42 18 aa |M.V4.j.zl..*)B..| -00000310 a6 86 ce e0 d7 77 c1 e0 ea 40 96 50 79 ee e0 3c |.....w...@.Py..<| -00000320 6b 4e c1 07 b3 05 f5 9a 71 aa 9d 16 03 01 00 0a |kN......q.......| +00000270 2a 16 03 01 00 b5 0c 00 00 b1 03 00 1d 20 db cd |*............ ..| +00000280 1a f4 85 72 91 7c ee 8c 5c 02 c7 5b 09 c3 97 5b |...r.|..\..[...[| +00000290 5a 5c 2a af 84 5d 40 e9 2a e6 71 29 85 5d 00 8b |Z\*..]@.*.q).]..| +000002a0 30 81 88 02 42 00 ec 5a 5c b8 29 7d b6 58 15 62 |0...B..Z\.)}.X.b| +000002b0 b4 45 21 84 d6 d8 3a cc b8 c5 ff 79 66 07 57 28 |.E!...:....yf.W(| +000002c0 29 af 1d e3 cf db 1b 23 bb 5a 2f 23 8f 29 ed d4 |)......#.Z/#.)..| +000002d0 6c 3b ab a4 09 76 38 cf 63 bf 74 f9 5b 87 a2 e2 |l;...v8.c.t.[...| +000002e0 b7 1c 03 29 bd c6 1e 02 42 01 65 17 a6 34 04 01 |...)....B.e..4..| +000002f0 f4 f6 57 95 85 44 57 f5 34 02 aa fa 8b 63 57 69 |..W..DW.4....cWi| +00000300 6f e4 23 8a e6 c2 c4 4a b9 ac a9 44 3e c7 bc 47 |o.#....J...D>..G| +00000310 77 ae fe 22 14 5f bc 1c e2 20 ab 3f f6 dd c3 8f |w.."._... .?....| +00000320 ed dd 39 c3 47 01 28 66 33 e6 c6 16 03 01 00 0a |..9.G.(f3.......| 00000330 0d 00 00 06 03 01 02 40 00 00 16 03 01 00 04 0e |.......@........| 00000340 00 00 00 |...| >>> Flow 3 (client to server) @@ -99,30 +105,30 @@ 00000200 e4 fa cc b1 8a ce e2 23 a0 87 f0 e1 67 51 eb 16 |.......#....gQ..| 00000210 03 01 00 25 10 00 00 21 20 2f e5 7d a3 47 cd 62 |...%...! /.}.G.b| 00000220 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 cf |C.(.._.).0......| -00000230 c2 ed 90 99 5f 58 cb 3b 74 16 03 01 00 90 0f 00 |...._X.;t.......| -00000240 00 8c 00 8a 30 81 87 02 41 69 90 2d 22 89 47 af |....0...Ai.-".G.| -00000250 7e ab 99 d8 fc 71 00 e0 03 d8 03 36 2c 9f 5d 59 |~....q.....6,.]Y| -00000260 27 2e c8 88 6f ba 7f 61 5a 86 8e 87 fd 3e 92 23 |'...o..aZ....>.#| -00000270 e3 4e 49 af fe 2b 34 80 63 dd e3 e4 6b ca bd 08 |.NI..+4.c...k...| -00000280 31 c8 54 27 d2 31 75 68 56 5d 02 42 01 1c 80 ed |1.T'.1uhV].B....| -00000290 fc 67 1a e1 cd c0 dc 9d 22 2b 7f 9b 0a 6d 3e 3b |.g......"+...m>;| -000002a0 ac 37 90 20 67 50 a1 e0 16 3c 3c 8c a1 46 2b 81 |.7. gP...<<..F+.| -000002b0 48 b3 c3 c7 57 3b 26 17 51 4e d7 30 08 9c 2e d9 |H...W;&.QN.0....| -000002c0 87 41 93 21 94 fe 47 34 16 a1 e3 dc 68 a7 14 03 |.A.!..G4....h...| -000002d0 01 00 01 01 16 03 01 00 30 68 22 41 51 d1 f0 15 |........0h"AQ...| -000002e0 e5 19 86 95 89 c2 a1 65 23 b2 61 44 fa 7e 07 9e |.......e#.aD.~..| -000002f0 f9 91 4b 17 a5 3b 7c 6e e5 ee bf 06 4c 91 00 f5 |..K..;|n....L...| -00000300 be b7 d5 b5 7c 88 21 0d ae |....|.!..| +00000230 c2 ed 90 99 5f 58 cb 3b 74 16 03 01 00 91 0f 00 |...._X.;t.......| +00000240 00 8d 00 8b 30 81 88 02 42 01 b1 4c 5b 98 0d 02 |....0...B..L[...| +00000250 57 ed 5a 6a ba b2 25 b8 fe ab 0b c2 d2 f7 4f cf |W.Zj..%.......O.| +00000260 05 fd 66 85 85 10 da 84 b5 30 76 92 70 5f 73 5b |..f......0v.p_s[| +00000270 5e c1 ce 1d 3c 88 1d 50 b1 85 f8 66 07 a8 16 6a |^...<..P...f...j| +00000280 f0 d5 61 80 e2 8e 75 dc e2 e1 45 02 42 01 2f 2f |..a...u...E.B.//| +00000290 17 58 50 18 25 9e 99 9c 89 69 aa 55 69 26 6d 88 |.XP.%....i.Ui&m.| +000002a0 8d c9 76 8b d5 40 5e 9d 0b f5 9f 6f dd 93 94 50 |..v..@^....o...P| +000002b0 c0 6e c5 7a 4d 9e fb 64 61 31 88 be fa 0c 11 b8 |.n.zM..da1......| +000002c0 ab 7e 7c 3d bf 4e da de aa aa 19 af 1c 1f 35 14 |.~|=.N........5.| +000002d0 03 01 00 01 01 16 03 01 00 30 58 e2 f6 52 c6 6f |.........0X..R.o| +000002e0 8d ba 2d be 84 8d fd 19 b7 2a e6 c4 b9 47 0d 3b |..-......*...G.;| +000002f0 af a8 8d 91 90 9d ff a1 f0 65 af 8e fe 8a 9b 39 |.........e.....9| +00000300 1c b1 e4 0b e3 c5 9a bf 86 18 |..........| >>> Flow 4 (server to client) -00000000 14 03 01 00 01 01 16 03 01 00 30 22 37 a1 e7 52 |..........0"7..R| -00000010 94 4a e6 d8 e2 0a 96 37 9e 3e f2 a1 96 42 0f c9 |.J.....7.>...B..| -00000020 ba 95 15 27 3e 9c 01 04 0e 41 01 e5 a6 c7 b4 c7 |...'>....A......| -00000030 c6 54 b2 0e 96 52 6c cd 73 11 d3 |.T...Rl.s..| +00000000 14 03 01 00 01 01 16 03 01 00 30 bc 72 19 6f bb |..........0.r.o.| +00000010 a0 79 dd 23 cf 44 0c be 48 9e ef 94 f3 47 fb 03 |.y.#.D..H....G..| +00000020 7d c6 af 0d 35 e2 4d 73 92 42 04 fa 5b 74 be 4d |}...5.Ms.B..[t.M| +00000030 0e 1b bf 3d 4a c9 d9 66 10 02 9f |...=J..f...| >>> Flow 5 (client to server) -00000000 17 03 01 00 20 fa c5 7a 84 51 d8 01 1a bf c9 1c |.... ..z.Q......| -00000010 74 79 18 31 01 37 d3 65 64 34 1b 29 4e 94 d3 51 |ty.1.7.ed4.)N..Q| -00000020 e2 97 dd 9a af 17 03 01 00 20 bc 47 62 6c 06 28 |......... .Gbl.(| -00000030 4d 7d 61 26 0f 06 00 2a a9 cb cf a2 a9 5a 20 2f |M}a&...*.....Z /| -00000040 f5 57 40 06 46 06 cd 31 bb 2c 15 03 01 00 20 53 |.W@.F..1.,.... S| -00000050 b1 0e 13 ba 83 40 ff 9c 2b f2 70 05 29 0f 27 a1 |.....@..+.p.).'.| -00000060 32 98 b6 96 ab d7 2b 0e 70 53 6e 09 d8 82 99 |2.....+.pSn....| +00000000 17 03 01 00 20 96 d0 e8 8d 10 80 14 f0 61 fa a9 |.... ........a..| +00000010 61 f0 52 a9 22 b3 78 66 9d a4 79 6f 77 1e dc 2f |a.R.".xf..yow../| +00000020 0d f7 83 86 58 17 03 01 00 20 f9 91 e6 bf d9 c6 |....X.... ......| +00000030 34 5c 2c a2 94 55 55 74 83 03 58 5f 02 a8 00 da |4\,..UUt..X_....| +00000040 70 22 e8 1d 54 c8 43 17 4e b8 15 03 01 00 20 b1 |p"..T.C.N..... .| +00000050 6f a7 15 cc e5 50 e3 ab 70 14 ed 7f 8d fc 3a ff |o....P..p.....:.| +00000060 6a ea 4f bd b0 58 59 b7 38 36 2c b2 df 3c 4a |j.O..XY.86,..>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 01 00 59 02 00 00 55 03 01 af af 0f 49 f7 |....Y...U.....I.| -00000010 fa 29 30 cb 90 30 b4 70 d2 94 96 db 99 f9 4d 10 |.)0..0.p......M.| -00000020 4c 14 67 a0 2f ac cc e6 7f 89 c2 20 d8 e0 15 ba |L.g./...... ....| -00000030 55 99 b7 20 04 e2 84 e4 5d 97 4b ea 6e d5 6b db |U.. ....].K.n.k.| -00000040 dc 23 2a a1 76 4c fd c0 5f a6 4a e1 c0 13 00 00 |.#*.vL.._.J.....| +00000000 16 03 01 00 59 02 00 00 55 03 01 a1 68 ff ed 89 |....Y...U...h...| +00000010 15 1b 21 de e0 23 e9 b0 ea 6c 1a 10 c7 f2 bb c1 |..!..#...l......| +00000020 c7 7a 76 6c df 17 45 2d 71 8d 6a 20 12 5b 28 d2 |.zvl..E-q.j .[(.| +00000030 94 ed d3 f5 6d 0b 40 2b 6f ec 7d 1f 8b 37 5c da |....m.@+o.}..7\.| +00000040 ae b3 47 fd e5 13 36 c0 2f 50 33 58 c0 13 00 00 |..G...6./P3X....| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 01 02 59 0b 00 02 55 00 02 52 00 02 4f 30 82 02 |..Y...U..R..O0..| 00000070 4b 30 82 01 b4 a0 03 02 01 02 02 09 00 e8 f0 9d |K0..............| @@ -54,17 +60,17 @@ 00000290 77 8d 0c 1c f1 0f a1 d8 40 83 61 c9 4c 72 2b 9d |w.......@.a.Lr+.| 000002a0 ae db 46 06 06 4d f4 c1 b3 3e c0 d1 bd 42 d4 db |..F..M...>...B..| 000002b0 fe 3d 13 60 84 5c 21 d3 3b e9 fa e7 16 03 01 00 |.=.`.\!.;.......| -000002c0 aa 0c 00 00 a6 03 00 1d 20 b7 12 77 ce bd 55 19 |........ ..w..U.| -000002d0 d6 16 92 11 72 ad dc b4 9c fd 7a cd dc 31 53 0f |....r.....z..1S.| -000002e0 bc bf 12 0a 9f 32 c9 e3 09 00 80 6e 49 99 f1 c2 |.....2.....nI...| -000002f0 6c 4e cd c1 bb cc b1 db fd e5 3a 12 c9 94 dd 11 |lN........:.....| -00000300 84 b3 5f 43 15 7c f5 05 a0 13 90 05 0e bb 13 60 |.._C.|.........`| -00000310 c5 ef 30 e6 cb 5d b2 50 10 99 1f 01 13 43 37 e8 |..0..].P.....C7.| -00000320 6c 95 aa ae 3e f6 53 25 92 48 d1 f6 e1 7d 88 0e |l...>.S%.H...}..| -00000330 23 fb ee 72 e8 84 83 6b bc d6 96 3c 1d 62 98 3e |#..r...k...<.b.>| -00000340 89 c7 19 cc cd 08 d3 cb b2 fe 39 51 f0 62 89 71 |..........9Q.b.q| -00000350 d7 83 78 33 0d de f8 81 5a e4 f3 ea 55 e9 58 41 |..x3....Z...U.XA| -00000360 94 b2 1b b9 1f 3b 52 f1 d3 d0 51 16 03 01 00 0a |.....;R...Q.....| +000002c0 aa 0c 00 00 a6 03 00 1d 20 67 3f fc ee e2 3f 93 |........ g?...?.| +000002d0 c9 f9 f3 a2 41 97 86 04 ce f5 e5 6d ac 00 85 64 |....A......m...d| +000002e0 01 83 89 75 5f 27 7c 5f 41 00 80 30 d3 2d ce bc |...u_'|_A..0.-..| +000002f0 9a 45 ea 21 4c 28 9b 36 ba a9 d0 24 c9 1a 1b 3b |.E.!L(.6...$...;| +00000300 6c 2d c3 72 3d d6 09 b2 07 d2 f2 54 b0 02 29 d7 |l-.r=......T..).| +00000310 99 f6 5e ee 71 d9 6f 1d 0a 74 f3 ee 23 79 60 d3 |..^.q.o..t..#y`.| +00000320 fd 14 99 d9 12 bd f7 5b 73 08 24 f2 3e 1f f5 38 |.......[s.$.>..8| +00000330 6a c9 43 72 ea 97 78 b9 48 7b aa 05 b2 9a fc 6a |j.Cr..x.H{.....j| +00000340 1f 4d 01 6a 9f 05 a3 0e 84 1f 09 9d e3 1a 07 6b |.M.j...........k| +00000350 c6 82 5f cc 4a db 33 86 4a 03 50 21 d7 9e ca a1 |.._.J.3.J.P!....| +00000360 9a 4f 52 53 43 67 81 53 3b ed fd 16 03 01 00 0a |.ORSCg.S;.......| 00000370 0d 00 00 06 03 01 02 40 00 00 16 03 01 00 04 0e |.......@........| 00000380 00 00 00 |...| >>> Flow 3 (client to server) @@ -104,29 +110,29 @@ 00000210 03 01 00 25 10 00 00 21 20 2f e5 7d a3 47 cd 62 |...%...! /.}.G.b| 00000220 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 cf |C.(.._.).0......| 00000230 c2 ed 90 99 5f 58 cb 3b 74 16 03 01 00 91 0f 00 |...._X.;t.......| -00000240 00 8d 00 8b 30 81 88 02 42 01 8b 84 b3 ac 64 4e |....0...B.....dN| -00000250 77 d2 47 77 13 2f 45 ec 0b 3f 92 ef 55 cc 78 8e |w.Gw./E..?..U.x.| -00000260 d9 c1 ae 4b c5 6f 01 d0 55 ca 0b 12 cf 3c ac c8 |...K.o..U....<..| -00000270 46 7b 6a c4 22 f3 16 85 1a 2a ea 4f f6 65 1c c9 |F{j."....*.O.e..| -00000280 90 7b d1 c5 9f c8 59 73 43 47 bd 02 42 00 93 a3 |.{....YsCG..B...| -00000290 35 0a 1f 14 de 23 fa 92 a4 d6 5e dc fd c0 85 87 |5....#....^.....| -000002a0 fb 23 12 bd 8e d7 f3 98 33 49 fc 88 92 13 8a 7d |.#......3I.....}| -000002b0 ee 12 e5 d6 b3 ff bf 04 7e 48 ff 83 6b 76 70 b8 |........~H..kvp.| -000002c0 8c 1f f5 44 4b a7 fb 48 81 87 a0 6b 66 45 15 14 |...DK..H...kfE..| -000002d0 03 01 00 01 01 16 03 01 00 30 83 d6 1c 9f e9 ef |.........0......| -000002e0 49 45 e4 97 17 2c af 6f 4e 59 0e 4d 43 69 88 fd |IE...,.oNY.MCi..| -000002f0 3d 99 00 9e 02 3c 33 78 d6 37 6e f9 55 43 ac 16 |=....<3x.7n.UC..| -00000300 2e 14 0e 0e 44 a1 f7 1e fc 09 |....D.....| +00000240 00 8d 00 8b 30 81 88 02 42 00 a6 8c ff 5a 40 01 |....0...B....Z@.| +00000250 bc 1c 28 f7 95 34 93 1b 78 58 34 04 d9 3e 8b 1e |..(..4..xX4..>..| +00000260 bb 2a 3f aa a8 a0 24 38 05 c2 38 4f 8b 55 08 17 |.*?...$8..8O.U..| +00000270 e4 68 9b 9a 6c f1 94 cc 61 52 90 8a 38 6e 76 f5 |.h..l...aR..8nv.| +00000280 0b 59 60 94 67 b5 78 83 93 eb cd 02 42 00 eb 7b |.Y`.g.x.....B..{| +00000290 a4 90 f5 8a 07 ab 80 49 41 48 6e 37 7b e2 f8 b8 |.......IAHn7{...| +000002a0 27 2d 06 2b cf 5a e9 eb 5c 36 a3 de 50 b9 40 b5 |'-.+.Z..\6..P.@.| +000002b0 14 0a 5c a4 ec 8f 2b 0c d4 ca a3 45 db 2a 3a 65 |..\...+....E.*:e| +000002c0 b4 8e c4 a6 d8 e9 f7 c3 48 34 f7 e7 65 b9 90 14 |........H4..e...| +000002d0 03 01 00 01 01 16 03 01 00 30 a3 4b 62 d6 25 40 |.........0.Kb.%@| +000002e0 84 6c 3f 2c d8 fa 69 93 49 4f 4e 75 06 09 0c 1a |.l?,..i.IONu....| +000002f0 01 b9 09 2e 9d 4d 0a f7 57 c0 8b d8 d0 44 5d f4 |.....M..W....D].| +00000300 c1 19 61 a7 a7 36 05 ad 96 92 |..a..6....| >>> Flow 4 (server to client) -00000000 14 03 01 00 01 01 16 03 01 00 30 75 1b 70 70 73 |..........0u.pps| -00000010 c3 2d d5 7a a5 ca 63 b3 b7 b1 57 a8 bc fd 5c 95 |.-.z..c...W...\.| -00000020 ed e7 88 26 b3 9b a6 8d c7 3f 02 70 a7 98 1c 33 |...&.....?.p...3| -00000030 86 67 f7 ca 76 42 53 99 3b 17 ef |.g..vBS.;..| +00000000 14 03 01 00 01 01 16 03 01 00 30 0a 75 fa 5e 6e |..........0.u.^n| +00000010 50 48 e9 b1 67 e2 e1 04 c4 d9 27 63 7a a3 74 9e |PH..g.....'cz.t.| +00000020 0d 70 13 b9 1c b6 f5 e4 43 eb e1 20 86 08 d0 39 |.p......C.. ...9| +00000030 91 5e 72 f7 9b 30 25 db aa 8c 72 |.^r..0%...r| >>> Flow 5 (client to server) -00000000 17 03 01 00 20 61 40 b2 4d fe 8d 3c a1 d2 4b 36 |.... a@.M..<..K6| -00000010 bb 5d 6c 77 65 6e 66 55 57 12 a5 62 9d 56 f6 53 |.]lwenfUW..b.V.S| -00000020 dd a6 38 7c 32 17 03 01 00 20 e5 98 82 47 a0 cc |..8|2.... ...G..| -00000030 a7 02 98 71 01 00 d7 ee 1c 35 16 d6 7a 03 80 95 |...q.....5..z...| -00000040 d0 69 9a e9 bb 4c 9c 0a 92 59 15 03 01 00 20 a2 |.i...L...Y.... .| -00000050 96 8a 21 a9 a4 28 83 f8 fb 3c aa 6e 53 fb 23 7e |..!..(...<.nS.#~| -00000060 a1 08 4f 16 8f 34 02 27 34 e2 c2 71 1e a2 c7 |..O..4.'4..q...| +00000000 17 03 01 00 20 9a f8 b3 97 b0 90 7e c7 2c 15 74 |.... ......~.,.t| +00000010 03 c9 15 5d 95 fa 5c 37 ca 1e 8f 5a 3c af dc 9b |...]..\7...Z<...| +00000020 30 64 41 66 d0 17 03 01 00 20 1f 65 3e 77 1b 39 |0dAf..... .e>w.9| +00000030 c4 b9 de 44 67 a2 1d 73 a8 83 bf dd 4f 50 ad d2 |...Dg..s....OP..| +00000040 67 cf 45 9d 48 19 d8 67 fd 70 15 03 01 00 20 2d |g.E.H..g.p.... -| +00000050 6e d3 18 d1 55 6a 68 88 9d c0 3b a7 2e 93 fe e5 |n...Ujh...;.....| +00000060 f9 6c b9 b4 3e 28 f0 9a 3f f0 67 4f 32 ab 6b |.l..>(..?.gO2.k| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv10-ClientCert-RSA-ECDSA b/libgo/go/crypto/tls/testdata/Client-TLSv10-ClientCert-RSA-ECDSA index 65bc2783347..14ed93ca096 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv10-ClientCert-RSA-ECDSA +++ b/libgo/go/crypto/tls/testdata/Client-TLSv10-ClientCert-RSA-ECDSA @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 01 00 59 02 00 00 55 03 01 3b ff d1 3d 27 |....Y...U..;..='| -00000010 af 29 b4 e8 d8 71 40 08 5c 7b 8b a9 23 8a 70 1a |.)...q@.\{..#.p.| -00000020 c8 a4 19 11 71 7b 92 58 03 af 99 20 c8 18 fc 7d |....q{.X... ...}| -00000030 e6 ed 7b d7 1c 2a 5e d5 5b 22 d9 dc 9e b1 aa 88 |..{..*^.["......| -00000040 0a 9f fb 4a 8a d7 27 d9 65 df 76 3a c0 09 00 00 |...J..'.e.v:....| +00000000 16 03 01 00 59 02 00 00 55 03 01 04 4a 64 8e 4f |....Y...U...Jd.O| +00000010 f1 4e 06 19 e2 cb b8 92 93 7b f5 ec 1b 0e 30 8e |.N.......{....0.| +00000020 1f 89 6c a1 28 e7 87 7f 9e 9e 19 20 cf aa b7 1f |..l.(...... ....| +00000030 77 43 26 3e 15 5e 67 68 0d a6 a3 b1 25 e5 63 27 |wC&>.^gh....%.c'| +00000040 00 f9 59 23 e0 a3 1c d7 49 e9 dc b3 c0 09 00 00 |..Y#....I.......| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 01 02 0e 0b 00 02 0a 00 02 07 00 02 04 30 82 02 |.............0..| 00000070 00 30 82 01 62 02 09 00 b8 bf 2d 47 a0 d2 eb f4 |.0..b.....-G....| @@ -49,18 +55,18 @@ 00000240 13 83 0d 94 06 bb d4 37 7a f6 ec 7a c9 86 2e dd |.......7z..z....| 00000250 d7 11 69 7f 85 7c 56 de fb 31 78 2b e4 c7 78 0d |..i..|V..1x+..x.| 00000260 ae cb be 9e 4e 36 24 31 7b 6a 0f 39 95 12 07 8f |....N6$1{j.9....| -00000270 2a 16 03 01 00 b4 0c 00 00 b0 03 00 1d 20 80 a2 |*............ ..| -00000280 7b 8d 6e 35 2d f1 f5 f3 1b 97 df 4b 1e df a7 bc |{.n5-......K....| -00000290 2d 16 b7 3b bb 2a 97 8e 1f b6 e3 9f 05 76 00 8a |-..;.*.......v..| -000002a0 30 81 87 02 42 01 ca 48 71 d3 b9 18 46 c7 9b e3 |0...B..Hq...F...| -000002b0 e8 af 4c 6c 7d 9a 9b 00 1f b1 cf 90 a6 63 38 b0 |..Ll}........c8.| -000002c0 a3 cb e3 9a a1 ae 79 25 bb 6b 08 d6 b2 4f 32 a8 |......y%.k...O2.| -000002d0 91 bc c8 5a 59 25 ff 00 eb 33 4f b4 e8 d7 97 80 |...ZY%...3O.....| -000002e0 ad 9c 66 a2 73 78 d7 02 41 5e 26 e2 cf d4 cf 8e |..f.sx..A^&.....| -000002f0 40 7f 18 f0 e6 d7 1e 3b 3f f4 ed c6 d5 05 2c 67 |@......;?.....,g| -00000300 0d 73 0f a0 db 03 cb 5c bf c3 a5 c3 02 1f b8 64 |.s.....\.......d| -00000310 6f e7 35 74 ba f1 b8 1b d1 a8 c2 43 c9 b9 83 ba |o.5t.......C....| -00000320 30 2b 0b c0 00 a0 be b1 f1 33 16 03 01 00 0a 0d |0+.......3......| +00000270 2a 16 03 01 00 b4 0c 00 00 b0 03 00 1d 20 6c 3b |*............ l;| +00000280 3f 6b 18 21 57 c4 df bf 3d ac 92 ee bc 99 0b 2f |?k.!W...=....../| +00000290 d5 b3 f5 ff 5f 6c 6b 33 db a9 7c 02 f8 4c 00 8a |...._lk3..|..L..| +000002a0 30 81 87 02 42 00 8e 15 e5 bb dc f5 3d c6 10 d7 |0...B.......=...| +000002b0 67 54 3d 80 b5 6a 4d 69 f1 2c fe 99 bc 32 e1 ab |gT=..jMi.,...2..| +000002c0 42 c0 7d f2 5d e0 d6 22 95 58 25 5e 63 ba f0 9c |B.}.]..".X%^c...| +000002d0 9f 29 91 c9 a9 42 99 ab b0 4f ed a9 42 8e 1f 3a |.)...B...O..B..:| +000002e0 44 34 48 d9 5a dd 9b 02 41 44 21 e1 54 b5 a3 e7 |D4H.Z...AD!.T...| +000002f0 0a 57 45 52 ae 9d b5 fe 45 8a 3f 8b e7 50 e8 01 |.WER....E.?..P..| +00000300 8c 26 27 85 f4 ef 80 30 7e d6 d8 27 4f d5 5e 9d |.&'....0~..'O.^.| +00000310 7b 65 1a c6 5a ab 57 17 3f 6e 5c 66 aa cd 46 bc |{e..Z.W.?n\f..F.| +00000320 5d 32 db a5 48 f8 f8 35 11 8b 16 03 01 00 0a 0d |]2..H..5........| 00000330 00 00 06 03 01 02 40 00 00 16 03 01 00 04 0e 00 |......@.........| 00000340 00 00 |..| >>> Flow 3 (client to server) @@ -99,29 +105,29 @@ 00000200 e5 35 16 03 01 00 25 10 00 00 21 20 2f e5 7d a3 |.5....%...! /.}.| 00000210 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 |G.bC.(.._.).0...| 00000220 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 16 03 01 00 |......._X.;t....| -00000230 86 0f 00 00 82 00 80 35 95 c1 44 9d 66 18 82 91 |.......5..D.f...| -00000240 5b 25 68 80 9c 07 78 c6 ed da 98 25 07 9a c4 08 |[%h...x....%....| -00000250 b3 10 a2 67 b0 5b 0e c2 3d 25 af ea bc e1 5f a7 |...g.[..=%...._.| -00000260 d2 58 e9 a7 0c c8 c4 10 d0 44 a4 a1 a6 07 12 b1 |.X.......D......| -00000270 7f 22 6c 54 4e 97 ad b5 55 a0 58 ed c7 52 7a d6 |."lTN...U.X..Rz.| -00000280 5a 23 4f 6b b2 41 0f 01 2b 97 93 02 6f ce bd 32 |Z#Ok.A..+...o..2| -00000290 12 d3 af 32 09 0c a8 1a 16 58 f3 d8 d6 fe ba 84 |...2.....X......| -000002a0 57 b0 18 5c 86 35 83 54 6e f7 04 21 29 62 1c 76 |W..\.5.Tn..!)b.v| -000002b0 dc 44 03 5c 3a 1a 41 14 03 01 00 01 01 16 03 01 |.D.\:.A.........| -000002c0 00 30 2e 3f d7 4c 32 5f 13 48 47 46 b0 30 c1 00 |.0.?.L2_.HGF.0..| -000002d0 49 5d 6d 58 b6 1c ea f4 f9 1c 48 b9 01 9c 9c 94 |I]mX......H.....| -000002e0 7f 83 5a e7 c3 10 92 ad 9f fa a8 c6 57 49 ae 3a |..Z.........WI.:| -000002f0 3a 2a |:*| +00000230 86 0f 00 00 82 00 80 9a 02 82 fb dd 68 e7 91 9f |............h...| +00000240 83 12 57 35 23 7c de 88 97 07 a3 b2 67 77 0f c1 |..W5#|......gw..| +00000250 bd 33 36 b3 ce fb f7 96 26 91 ab dc 96 26 64 fa |.36.....&....&d.| +00000260 34 66 31 2b fa 6d 52 60 3e fb a3 87 27 a7 7c ac |4f1+.mR`>...'.|.| +00000270 8c 87 ff c5 5e 6f 6f e1 db bf bc 58 3d b3 f6 89 |....^oo....X=...| +00000280 a0 8e 0b 9d 26 74 68 57 ca e9 c2 ab 79 7b 6a dd |....&thW....y{j.| +00000290 c7 89 ef 0d 62 aa 47 7b 67 18 f2 ad 00 98 56 45 |....b.G{g.....VE| +000002a0 12 ca de 6a d1 1a b5 a9 d2 53 ba 3b 90 a6 cf 69 |...j.....S.;...i| +000002b0 12 65 32 c2 95 46 01 14 03 01 00 01 01 16 03 01 |.e2..F..........| +000002c0 00 30 f7 2d b9 19 66 b2 2c 1b 96 08 bc 70 5b f5 |.0.-..f.,....p[.| +000002d0 6d 58 9e 51 fb b5 3c a6 4f 4a fc 52 1f 10 20 c4 |mX.Q..<.OJ.R.. .| +000002e0 3f d6 3c 0e 99 e3 1c b5 21 7f 0d fa 08 ec 17 27 |?.<.....!......'| +000002f0 75 9f |u.| >>> Flow 4 (server to client) -00000000 14 03 01 00 01 01 16 03 01 00 30 29 fc da 17 09 |..........0)....| -00000010 5a 69 1b 4f 2e 4f 40 1d 9e 69 6c 62 ee 8b f9 53 |Zi.O.O@..ilb...S| -00000020 48 6a ae b6 85 df ab f3 89 8d f3 6e df f0 8f 14 |Hj.........n....| -00000030 79 a3 d8 d5 e4 3c 6b dd fb 77 24 |y....>> Flow 5 (client to server) -00000000 17 03 01 00 20 89 6b 03 b2 9d cc f2 6f 8f 27 6c |.... .k.....o.'l| -00000010 d4 49 61 4f 88 c1 6c b6 ef 2e 75 b9 0d d4 06 b0 |.IaO..l...u.....| -00000020 cb 6f 80 70 f6 17 03 01 00 20 ab 92 7f df 5f 38 |.o.p..... ...._8| -00000030 87 d7 7e ff 9c 17 14 cc 41 8d 28 98 7d 6a 59 78 |..~.....A.(.}jYx| -00000040 f0 9f d1 f1 f1 5a 75 27 fa 57 15 03 01 00 20 a3 |.....Zu'.W.... .| -00000050 3b 0c 84 bc d7 5d f6 87 b1 14 bd c4 6e a8 14 ae |;....]......n...| -00000060 e8 fd f2 50 67 b9 fa 6c 86 d8 6d 84 87 5e fe |...Pg..l..m..^.| +00000000 17 03 01 00 20 cd b3 a4 99 da 5d 59 36 6f f8 26 |.... .....]Y6o.&| +00000010 2d b2 4a 47 a1 54 7f b0 b3 df 0d 52 cc 13 7a 8b |-.JG.T.....R..z.| +00000020 a3 6a 8b 1f ee 17 03 01 00 20 d6 ab 8a 3e b3 41 |.j....... ...>.A| +00000030 0a be 61 50 79 19 1a 45 03 c6 b9 b4 84 b2 18 46 |..aPy..E.......F| +00000040 86 1f c3 b7 78 77 fc 7f 4f 30 15 03 01 00 20 2d |....xw..O0.... -| +00000050 c0 f2 71 06 dc 19 9d 88 82 b9 3a 6b be a4 77 98 |..q.......:k..w.| +00000060 87 32 46 54 27 e4 17 47 8a 83 9c 5a 45 6e 6b |.2FT'..G...ZEnk| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv10-ClientCert-RSA-RSA b/libgo/go/crypto/tls/testdata/Client-TLSv10-ClientCert-RSA-RSA index fef2ac07113..c5b33c01fe5 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv10-ClientCert-RSA-RSA +++ b/libgo/go/crypto/tls/testdata/Client-TLSv10-ClientCert-RSA-RSA @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 01 00 59 02 00 00 55 03 01 58 89 71 77 b1 |....Y...U..X.qw.| -00000010 c2 2a 4e e4 5a 4f bb 76 8a b5 9b f3 b1 c6 fc 30 |.*N.ZO.v.......0| -00000020 a8 ca 7e 5c d6 29 41 7d 17 04 5d 20 86 f6 c6 6f |..~\.)A}..] ...o| -00000030 5f 48 2c 43 07 ea d1 b3 81 da 6d 2f 70 aa 4c 2e |_H,C......m/p.L.| -00000040 d4 87 bb 4c 38 c9 67 bc 80 38 d0 c3 c0 13 00 00 |...L8.g..8......| +00000000 16 03 01 00 59 02 00 00 55 03 01 6b 8a f7 68 78 |....Y...U..k..hx| +00000010 f1 ea ad 9b 20 40 42 52 eb fa 55 fb 37 a7 21 22 |.... @BR..U.7.!"| +00000020 71 0d f7 4d 46 bf 38 df 6e 00 e0 20 17 73 28 32 |q..MF.8.n.. .s(2| +00000030 30 3f f4 01 df 70 98 ce 33 d0 c3 8c 0a fd 0a ba |0?...p..3.......| +00000040 6b 56 d7 f9 16 a2 24 0d 07 b1 32 47 c0 13 00 00 |kV....$...2G....| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 01 02 59 0b 00 02 55 00 02 52 00 02 4f 30 82 02 |..Y...U..R..O0..| 00000070 4b 30 82 01 b4 a0 03 02 01 02 02 09 00 e8 f0 9d |K0..............| @@ -54,17 +60,17 @@ 00000290 77 8d 0c 1c f1 0f a1 d8 40 83 61 c9 4c 72 2b 9d |w.......@.a.Lr+.| 000002a0 ae db 46 06 06 4d f4 c1 b3 3e c0 d1 bd 42 d4 db |..F..M...>...B..| 000002b0 fe 3d 13 60 84 5c 21 d3 3b e9 fa e7 16 03 01 00 |.=.`.\!.;.......| -000002c0 aa 0c 00 00 a6 03 00 1d 20 0c 12 68 b0 30 bb 4b |........ ..h.0.K| -000002d0 b0 c2 38 4d fa 65 f1 43 4a f1 47 dc 6e 6d ae 6b |..8M.e.CJ.G.nm.k| -000002e0 35 f5 4a 3c fa bc a6 6e 27 00 80 38 ef 5d 08 06 |5.J<...n'..8.]..| -000002f0 e5 f9 86 86 2e f3 6d b6 d4 12 94 5d 18 6b 11 67 |......m....].k.g| -00000300 17 65 d3 5c 0b fe 09 2d bb ca a6 2d c4 d7 fc b9 |.e.\...-...-....| -00000310 71 c1 4a 38 bb 14 bf dc 1b 4d 61 38 c6 76 3e 24 |q.J8.....Ma8.v>$| -00000320 ff e6 c5 7e f8 5d 5f 80 3d 8a 4e 5f bb 91 b7 c5 |...~.]_.=.N_....| -00000330 59 f8 b7 a1 7b d5 c3 72 57 83 de 52 40 75 1c ec |Y...{..rW..R@u..| -00000340 77 e9 0e a6 3a ad e4 57 ae d4 92 44 40 00 74 fa |w...:..W...D@.t.| -00000350 ae 16 b9 82 0d 9e 2a 43 12 1b a6 bb a1 89 6a 99 |......*C......j.| -00000360 09 80 d1 ad b6 9c 92 01 60 14 bb 16 03 01 00 0a |........`.......| +000002c0 aa 0c 00 00 a6 03 00 1d 20 b1 de e2 91 3f 1f be |........ ....?..| +000002d0 0e 21 49 44 db d1 d3 a7 89 db 61 56 97 bf 4c 73 |.!ID......aV..Ls| +000002e0 7b d3 da 81 a5 cc 0a e3 13 00 80 66 fd 15 8d 8a |{..........f....| +000002f0 a2 f9 8d b9 d9 cb a5 6b 45 7c 11 05 24 6d de e5 |.......kE|..$m..| +00000300 8f 3e 42 ba 3e bd 5a b8 f7 51 c0 b9 55 06 db d7 |.>B.>.Z..Q..U...| +00000310 2d 78 d2 5d 47 2d 52 c9 7b 59 20 73 1a 1d 26 c4 |-x.]G-R.{Y s..&.| +00000320 84 3d 5b 57 5f 1a fd 52 8c 40 87 be 58 58 73 d2 |.=[W_..R.@..XXs.| +00000330 4b 84 9a 6c 96 c0 36 82 95 13 f9 12 74 c3 3b dd |K..l..6.....t.;.| +00000340 27 11 c3 66 fa de 28 b4 c0 d9 6e 65 e0 8a 5e b6 |'..f..(...ne..^.| +00000350 3a a8 52 db 62 89 2b 1d d0 be fb b7 6e 03 bd f7 |:.R.b.+.....n...| +00000360 e3 a5 df c2 b3 5a 16 09 d8 1e df 16 03 01 00 0a |.....Z..........| 00000370 0d 00 00 06 03 01 02 40 00 00 16 03 01 00 04 0e |.......@........| 00000380 00 00 00 |...| >>> Flow 3 (client to server) @@ -103,29 +109,29 @@ 00000200 e5 35 16 03 01 00 25 10 00 00 21 20 2f e5 7d a3 |.5....%...! /.}.| 00000210 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 |G.bC.(.._.).0...| 00000220 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 16 03 01 00 |......._X.;t....| -00000230 86 0f 00 00 82 00 80 1d 64 73 05 fa f9 5e ef eb |........ds...^..| -00000240 c7 1b 07 99 0e d1 52 83 9e 19 ba 62 11 14 0a c2 |......R....b....| -00000250 11 e0 ff 6e 43 03 85 1d ef 73 f8 c2 4d b0 c6 5a |...nC....s..M..Z| -00000260 ba 14 14 1e 95 d1 f8 1a 3f 7f c3 08 f4 86 e6 2c |........?......,| -00000270 43 2f 00 fd d7 e1 4e 07 45 09 19 98 33 ad 6e e2 |C/....N.E...3.n.| -00000280 17 21 3b 8c a4 5e 50 6c 5a a3 75 68 93 a5 ee 42 |.!;..^PlZ.uh...B| -00000290 a9 88 6d c4 4e 9c 3f ce ee e1 a1 9b c4 c6 8e f7 |..m.N.?.........| -000002a0 65 b8 7f 10 a9 5f b8 07 70 8a 4f 89 2c 59 a1 46 |e...._..p.O.,Y.F| -000002b0 f9 a2 05 bc 01 45 7e 14 03 01 00 01 01 16 03 01 |.....E~.........| -000002c0 00 30 43 ec 90 51 04 0a 70 f7 8b a4 15 63 df 1b |.0C..Q..p....c..| -000002d0 70 eb 59 63 d1 54 41 4e 7e 82 e4 fb fe ca 87 6e |p.Yc.TAN~......n| -000002e0 86 2d c6 d2 ee 1c 7b 9e 72 2d d6 d6 12 15 a8 8b |.-....{.r-......| -000002f0 b2 9d |..| +00000230 86 0f 00 00 82 00 80 9c f0 ab 90 83 2a 47 ba 5c |............*G.\| +00000240 37 a4 19 b8 62 b1 01 74 35 4d 1a 62 5e 3f 0b 54 |7...b..t5M.b^?.T| +00000250 5a 6f b7 b5 99 4b b4 84 68 90 46 2b 95 e6 10 77 |Zo...K..h.F+...w| +00000260 bf 68 81 b1 96 11 5c e9 93 a4 d5 78 42 c0 c4 92 |.h....\....xB...| +00000270 cf 4e ce 25 e7 da 7d d9 2c 4d ab 71 2d b5 a7 1c |.N.%..}.,M.q-...| +00000280 5f b5 a3 32 f6 3e 38 79 17 36 45 94 8a e3 f8 1e |_..2.>8y.6E.....| +00000290 9e 95 23 48 0f f6 aa 1b 00 d2 45 85 c7 95 b2 d1 |..#H......E.....| +000002a0 c1 81 e8 31 34 45 bd 28 32 26 a8 d1 23 90 cb 40 |...14E.(2&..#..@| +000002b0 1c ed db eb c3 ec b6 14 03 01 00 01 01 16 03 01 |................| +000002c0 00 30 16 97 3e a2 2a 11 d5 3f 29 f6 5b b8 7a d5 |.0..>.*..?).[.z.| +000002d0 83 24 51 f0 0c c3 79 18 9c 58 b6 f4 2f 70 9f c0 |.$Q...y..X../p..| +000002e0 52 be a0 f0 eb d7 0e de 42 36 14 39 84 fc 84 ed |R.......B6.9....| +000002f0 77 0c |w.| >>> Flow 4 (server to client) -00000000 14 03 01 00 01 01 16 03 01 00 30 d2 8f 01 3c 0e |..........0...<.| -00000010 0d 9e 0d bb 92 0b e8 90 b8 39 53 b8 50 7a b0 c1 |.........9S.Pz..| -00000020 f3 89 3d 5c 1c a0 e8 97 21 c5 30 0f f1 14 11 6b |..=\....!.0....k| -00000030 ec 6e 8f 75 c8 7f 89 dd 3e 19 44 |.n.u....>.D| +00000000 14 03 01 00 01 01 16 03 01 00 30 8a 97 aa 38 29 |..........0...8)| +00000010 a4 7a 25 ae d5 5f 66 17 cb 8e de d3 ac 0f b3 9d |.z%.._f.........| +00000020 ba 61 54 31 cb c8 fc 1f 4c f5 76 b0 7e 7e 74 04 |.aT1....L.v.~~t.| +00000030 8a 2e 45 a8 5f c7 43 d7 d5 f4 7d |..E._.C...}| >>> Flow 5 (client to server) -00000000 17 03 01 00 20 19 f5 38 97 ac a5 5a 25 d4 1e 3a |.... ..8...Z%..:| -00000010 8c e6 89 36 88 80 f9 95 09 b2 f5 1d a8 09 02 b6 |...6............| -00000020 ec aa 8e aa c6 17 03 01 00 20 3e ee df 1b 09 ff |......... >.....| -00000030 88 77 4a da 5c 74 cf 64 3d 92 a0 08 1c 7b 12 db |.wJ.\t.d=....{..| -00000040 72 99 0f d4 4e 20 55 17 1d d3 15 03 01 00 20 19 |r...N U....... .| -00000050 ee bc fc da 0b 15 72 da 43 bc 0b 0a 49 4d 67 63 |......r.C...IMgc| -00000060 3d 04 78 00 c3 9d 66 a5 16 96 68 80 88 27 47 |=.x...f...h..'G| +00000000 17 03 01 00 20 22 4d 00 3f 2a 41 f0 53 06 93 fe |.... "M.?*A.S...| +00000010 aa 79 9b 69 bb d5 9b e5 e4 3b 48 ff e5 ce 7d db |.y.i.....;H...}.| +00000020 d8 e8 e6 e1 04 17 03 01 00 20 e8 01 13 cb f1 1f |......... ......| +00000030 17 68 33 6a ad 74 ae a7 c5 d9 00 ea 0b dc bb 9c |.h3j.t..........| +00000040 5c 5f 49 01 1e 53 74 30 58 e6 15 03 01 00 20 bb |\_I..St0X..... .| +00000050 30 7d c2 43 c3 0d b9 b5 3a 70 14 2c 4a 64 c9 fe |0}.C....:p.,Jd..| +00000060 20 25 a7 0a 01 11 3c 62 ca d6 28 80 ed cd 73 | %....>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 01 00 59 02 00 00 55 03 01 b2 70 62 50 ad |....Y...U...pbP.| -00000010 93 c5 c2 a6 66 60 f0 ed 9a 44 56 1a 9a 9c c0 00 |....f`...DV.....| -00000020 a4 5b 59 ee d5 b5 91 c2 04 c8 7d 20 d3 a3 00 df |.[Y.......} ....| -00000030 93 72 69 c9 d6 dd 3b ba 45 5c d2 7a cc 0e 10 3b |.ri...;.E\.z...;| -00000040 6b 6f eb 6a 7a d3 55 d6 eb e9 0a 8a c0 09 00 00 |ko.jz.U.........| +00000000 16 03 01 00 59 02 00 00 55 03 01 ec 11 a0 ef 24 |....Y...U......$| +00000010 30 9c 83 8c 12 7c 61 a8 39 bd 40 41 22 5c 58 7f |0....|a.9.@A"\X.| +00000020 ca 0c b2 41 66 dc 87 2d f1 4c cc 20 f6 53 42 ce |...Af..-.L. .SB.| +00000030 56 81 58 c1 70 30 37 55 64 f1 28 e4 63 50 e0 f4 |V.X.p07Ud.(.cP..| +00000040 af 7d 01 af 5e 1a 50 19 64 e6 c2 76 c0 09 00 00 |.}..^.P.d..v....| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 01 02 0e 0b 00 02 0a 00 02 07 00 02 04 30 82 02 |.............0..| 00000070 00 30 82 01 62 02 09 00 b8 bf 2d 47 a0 d2 eb f4 |.0..b.....-G....| @@ -49,37 +55,37 @@ 00000240 13 83 0d 94 06 bb d4 37 7a f6 ec 7a c9 86 2e dd |.......7z..z....| 00000250 d7 11 69 7f 85 7c 56 de fb 31 78 2b e4 c7 78 0d |..i..|V..1x+..x.| 00000260 ae cb be 9e 4e 36 24 31 7b 6a 0f 39 95 12 07 8f |....N6$1{j.9....| -00000270 2a 16 03 01 00 b3 0c 00 00 af 03 00 1d 20 a3 a5 |*............ ..| -00000280 47 e6 96 56 75 cb d6 1e b7 1b 3d 23 95 be 97 ac |G..Vu.....=#....| -00000290 03 a5 15 60 c2 ab 91 aa 52 ac e6 e7 f3 16 00 89 |...`....R.......| -000002a0 30 81 86 02 41 73 1b 9c 5b 66 9d b2 a7 74 83 ad |0...As..[f...t..| -000002b0 18 8e 29 ce 37 2f 44 a1 0e dd 80 df 60 3e 0c e1 |..).7/D.....`>..| -000002c0 06 ad e6 1e 2f 31 75 90 f1 22 28 39 d3 af 96 73 |..../1u.."(9...s| -000002d0 52 76 34 9b cd 7c 5d 46 6b 48 30 9a d9 b7 63 23 |Rv4..|]FkH0...c#| -000002e0 f8 7f c2 80 22 55 02 41 6c bb 0c 49 c3 a3 57 a7 |...."U.Al..I..W.| -000002f0 cf 2b 3e 96 a1 53 01 72 d0 5a e4 af 54 8f 23 6c |.+>..S.r.Z..T.#l| -00000300 2d 60 91 f2 4a 93 1f 75 0f cc a4 0a 5c 2d 40 7b |-`..J..u....\-@{| -00000310 11 8c a1 96 fb 2b ad 6f eb 07 78 e5 70 26 37 7b |.....+.o..x.p&7{| -00000320 f4 19 1c d7 98 43 11 be 88 16 03 01 00 04 0e 00 |.....C..........| -00000330 00 00 |..| +00000270 2a 16 03 01 00 b4 0c 00 00 b0 03 00 1d 20 cc 73 |*............ .s| +00000280 bf 89 65 cc cf f2 dc ed df d3 25 9b b2 16 f8 df |..e.......%.....| +00000290 97 56 f6 29 4e 08 17 19 f0 5a 2f 9d e3 57 00 8a |.V.)N....Z/..W..| +000002a0 30 81 87 02 42 01 91 4e d1 9a 13 69 44 6c 79 01 |0...B..N...iDly.| +000002b0 99 bb ac 65 c7 bd 0c c3 d1 4c ed 54 e3 7b ff ef |...e.....L.T.{..| +000002c0 c3 c2 44 ee ec 3b 8d b4 22 98 31 89 07 a7 b7 c9 |..D..;..".1.....| +000002d0 dc 6f 0c e0 78 a9 79 fc 74 20 0b 55 48 16 d7 d6 |.o..x.y.t .UH...| +000002e0 c8 c8 f8 81 67 e2 50 02 41 61 43 bd 1f e1 68 f1 |....g.P.AaC...h.| +000002f0 7c e1 bf 10 3f 58 16 74 5c 98 ee 4c 18 17 bf f0 ||...?X.t\..L....| +00000300 64 d9 9e be c6 d7 73 e8 20 89 b6 4e fa 93 7d 82 |d.....s. ..N..}.| +00000310 7c 78 96 d1 d9 d1 81 1b 66 5f 87 7b a1 20 40 3c ||x......f_.{. @<| +00000320 13 49 e1 73 8e e9 52 e4 f0 46 16 03 01 00 04 0e |.I.s..R..F......| +00000330 00 00 00 |...| >>> Flow 3 (client to server) 00000000 16 03 01 00 25 10 00 00 21 20 2f e5 7d a3 47 cd |....%...! /.}.G.| 00000010 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 |bC.(.._.).0.....| 00000020 cf c2 ed 90 99 5f 58 cb 3b 74 14 03 01 00 01 01 |....._X.;t......| -00000030 16 03 01 00 30 7a cf 24 f7 f6 69 1a ab 34 31 d5 |....0z.$..i..41.| -00000040 af ed 37 9f 1d 8d 3a 6b 72 a3 b0 fc b9 49 fb bc |..7...:kr....I..| -00000050 c5 94 9e 37 ce b0 87 8f ed 52 25 eb 2d 53 b9 39 |...7.....R%.-S.9| -00000060 d2 d3 f0 d6 97 |.....| +00000030 16 03 01 00 30 c6 44 20 88 b8 3b e4 a9 67 ca 54 |....0.D ..;..g.T| +00000040 f6 98 79 0e c5 8d d4 da 71 ce 40 51 59 e9 3f ee |..y.....q.@QY.?.| +00000050 a0 bb 7d 8a 84 4d 0a be 37 37 a8 cc fe bb 5d b6 |..}..M..77....].| +00000060 37 1b a8 a0 04 |7....| >>> Flow 4 (server to client) -00000000 14 03 01 00 01 01 16 03 01 00 30 92 72 cc c3 1f |..........0.r...| -00000010 4b a5 c4 d7 6f d1 17 4b 4e 27 b7 f5 72 fd c2 a0 |K...o..KN'..r...| -00000020 30 cb 4c cf 82 1f 0a 49 3d 23 bc 47 f1 e8 a7 b5 |0.L....I=#.G....| -00000030 c7 6a 92 25 55 3a f0 0f b0 30 74 |.j.%U:...0t| +00000000 14 03 01 00 01 01 16 03 01 00 30 d3 c0 74 ba 22 |..........0..t."| +00000010 e5 c6 8d c6 82 ac f4 63 90 28 73 a4 7a c3 43 ca |.......c.(s.z.C.| +00000020 0d 09 5a 84 70 d6 64 de 4b 06 9b fc b9 a9 3f d8 |..Z.p.d.K.....?.| +00000030 a0 02 67 2b 63 1e 61 91 b7 f9 a2 |..g+c.a....| >>> Flow 5 (client to server) -00000000 17 03 01 00 20 85 49 7a 58 80 e9 59 63 d0 74 a1 |.... .IzX..Yc.t.| -00000010 b7 d9 1b 46 41 5f 51 c0 66 4a 10 e1 ad dd 9f 9a |...FA_Q.fJ......| -00000020 c3 cf 32 77 72 17 03 01 00 20 05 7d 08 38 3d f0 |..2wr.... .}.8=.| -00000030 02 f7 17 71 b7 1c 29 c3 a6 c8 ff 7a 82 36 1e 42 |...q..)....z.6.B| -00000040 00 1e 6c d8 b1 39 22 ec 62 43 15 03 01 00 20 0d |..l..9".bC.... .| -00000050 80 5b da 89 4d 42 ab 95 17 11 0f 9b 79 2f c8 3f |.[..MB......y/.?| -00000060 f2 fd 54 2e ea 4a f9 de fc 5d 7f 75 51 86 e5 |..T..J...].uQ..| +00000000 17 03 01 00 20 b2 55 db d3 41 5d 5c 9b b5 b8 c8 |.... .U..A]\....| +00000010 fd ab 30 74 08 59 22 e3 8c e0 43 d0 63 14 33 f8 |..0t.Y"...C.c.3.| +00000020 00 b6 3d 1e a0 17 03 01 00 20 fa 14 95 a5 e3 a0 |..=...... ......| +00000030 09 04 e1 49 35 c5 ef c1 b4 c5 7d b5 6a c7 13 db |...I5.....}.j...| +00000040 88 2f 4c 65 f8 c4 d5 2a a5 3a 15 03 01 00 20 05 |./Le...*.:.... .| +00000050 21 da 3d 87 62 0c a7 e6 eb aa f6 bd 2f 77 fd a4 |!.=.b......./w..| +00000060 cd 2a ac 22 73 7c 75 60 59 db 0f 8f df 86 73 |.*."s|u`Y.....s| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv10-ECDHE-RSA-AES b/libgo/go/crypto/tls/testdata/Client-TLSv10-ECDHE-RSA-AES index 2cae0876a4e..ccc71f606a1 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv10-ECDHE-RSA-AES +++ b/libgo/go/crypto/tls/testdata/Client-TLSv10-ECDHE-RSA-AES @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 01 00 59 02 00 00 55 03 01 f8 80 7d dd cc |....Y...U....}..| -00000010 ab 8c 66 56 c7 e9 18 88 87 44 39 67 57 91 e8 ee |..fV.....D9gW...| -00000020 3a c0 bc 2e bf 50 54 5e 8d c2 61 20 da b0 2d 85 |:....PT^..a ..-.| -00000030 e2 ed f5 5f 2b af 14 87 e6 26 6b af a4 4a 24 2d |..._+....&k..J$-| -00000040 1a bc 15 96 11 c8 c0 8b e9 0c 27 91 c0 13 00 00 |..........'.....| +00000000 16 03 01 00 59 02 00 00 55 03 01 29 ae 9f 95 df |....Y...U..)....| +00000010 c0 c9 77 0a cc 61 5e f2 7b bb 50 28 95 30 cd 6f |..w..a^.{.P(.0.o| +00000020 7f 23 ca 62 ee 35 20 31 85 6b 77 20 16 82 4f 3a |.#.b.5 1.kw ..O:| +00000030 13 67 6e cc 71 5c f8 7a 4a b2 1f 02 a6 1a a4 2b |.gn.q\.zJ......+| +00000040 32 cd 5a 81 4b 82 a2 e3 7e 67 fa e7 c0 13 00 00 |2.Z.K...~g......| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 01 02 59 0b 00 02 55 00 02 52 00 02 4f 30 82 02 |..Y...U..R..O0..| 00000070 4b 30 82 01 b4 a0 03 02 01 02 02 09 00 e8 f0 9d |K0..............| @@ -54,36 +60,36 @@ 00000290 77 8d 0c 1c f1 0f a1 d8 40 83 61 c9 4c 72 2b 9d |w.......@.a.Lr+.| 000002a0 ae db 46 06 06 4d f4 c1 b3 3e c0 d1 bd 42 d4 db |..F..M...>...B..| 000002b0 fe 3d 13 60 84 5c 21 d3 3b e9 fa e7 16 03 01 00 |.=.`.\!.;.......| -000002c0 aa 0c 00 00 a6 03 00 1d 20 0a d4 a1 84 63 ba 2d |........ ....c.-| -000002d0 23 89 b1 37 eb 97 d3 a7 09 36 3d ac 2a 30 7c f9 |#..7.....6=.*0|.| -000002e0 f6 87 67 86 22 fa f5 f9 06 00 80 c9 ea 8a 76 f2 |..g.".........v.| -000002f0 a5 1b e8 14 2c 2a 2f 2e a0 78 ac 06 9b 48 a8 d9 |....,*/..x...H..| -00000300 03 91 e7 c1 e5 e6 a3 9e 5e 33 73 0a f4 b3 d7 64 |........^3s....d| -00000310 5f 86 d6 36 e5 88 25 90 3c a2 d6 3f d6 07 7a 5c |_..6..%.<..?..z\| -00000320 64 c4 0f ac a9 3e c9 f6 b6 35 2a df a3 a3 79 8f |d....>...5*...y.| -00000330 b3 a6 f4 d8 e4 0a 4f 5f 11 3a 85 9a 0c 48 7b 3b |......O_.:...H{;| -00000340 a2 24 ec c0 44 7e eb b5 f3 f8 52 e6 83 bf 45 91 |.$..D~....R...E.| -00000350 9a 7c a4 e3 29 97 ea 9c 94 28 66 73 45 ed 52 2f |.|..)....(fsE.R/| -00000360 df a8 44 8b a5 0b 7a 31 92 eb 72 16 03 01 00 04 |..D...z1..r.....| +000002c0 aa 0c 00 00 a6 03 00 1d 20 89 38 c8 65 ea 1e 0f |........ .8.e...| +000002d0 6d 85 41 9e c4 f2 51 fd 0f f5 18 7d 60 1b c1 79 |m.A...Q....}`..y| +000002e0 55 dc eb 35 8b 0b 64 9c 1e 00 80 d0 9c 8a 95 1b |U..5..d.........| +000002f0 0b 44 37 fc b7 53 98 05 23 e4 83 40 38 f5 1b 68 |.D7..S..#..@8..h| +00000300 dd 4b eb 46 cf 26 7b 0b 37 89 b2 fd 13 2d 5d cd |.K.F.&{.7....-].| +00000310 c5 16 8f e5 ff c6 51 45 77 c5 59 02 71 2e d6 51 |......QEw.Y.q..Q| +00000320 2a 2b ce 93 52 d9 56 e4 37 25 04 2e 5d 95 3d ea |*+..R.V.7%..].=.| +00000330 40 5e 86 8a ae 51 5a 87 17 00 a6 a1 77 c1 ec 40 |@^...QZ.....w..@| +00000340 88 f9 a5 6f ec 73 b3 3e b6 15 14 a1 5f 9a 85 18 |...o.s.>...._...| +00000350 0b 19 82 2a d7 5a 37 4c 7b 4e 06 f7 86 24 15 25 |...*.Z7L{N...$.%| +00000360 58 95 a0 aa 56 f2 3c 36 18 5d 2f 16 03 01 00 04 |X...V.<6.]/.....| 00000370 0e 00 00 00 |....| >>> Flow 3 (client to server) 00000000 16 03 01 00 25 10 00 00 21 20 2f e5 7d a3 47 cd |....%...! /.}.G.| 00000010 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 |bC.(.._.).0.....| 00000020 cf c2 ed 90 99 5f 58 cb 3b 74 14 03 01 00 01 01 |....._X.;t......| -00000030 16 03 01 00 30 19 34 cf 68 d1 8f ea be 56 24 71 |....0.4.h....V$q| -00000040 e4 ad ad f8 b3 dd 57 43 46 d5 8d f3 1c 0c df 4f |......WCF......O| -00000050 1c af 3b 2a 24 e4 8a 98 b5 b7 61 6f 5f 48 68 20 |..;*$.....ao_Hh | -00000060 b7 6a 9c ee 80 |.j...| +00000030 16 03 01 00 30 85 63 fe 57 56 dc ee 8c e6 66 e0 |....0.c.WV....f.| +00000040 5c 06 37 0c 15 76 a2 51 b8 95 d6 b8 64 a3 dc 70 |\.7..v.Q....d..p| +00000050 e7 2d 70 a8 73 ff fb 11 5a 96 bb 0e 23 b4 0a 5b |.-p.s...Z...#..[| +00000060 5e 6e c0 45 91 |^n.E.| >>> Flow 4 (server to client) -00000000 14 03 01 00 01 01 16 03 01 00 30 fc 42 2b 0f 86 |..........0.B+..| -00000010 73 e1 a1 1a 09 1e 78 7d 61 f1 7c a4 94 14 26 53 |s.....x}a.|...&S| -00000020 de 28 f3 63 63 c3 65 7b e4 fd 10 2d 66 ed f7 dd |.(.cc.e{...-f...| -00000030 f9 9e 13 5c c1 e8 94 6a 32 c0 db |...\...j2..| +00000000 14 03 01 00 01 01 16 03 01 00 30 3b 02 9e ba 9e |..........0;....| +00000010 ae 5c 03 81 ba c4 13 9e a8 0f 29 3c a3 e8 bd 2e |.\........)<....| +00000020 af 2c c7 45 c2 05 b1 03 2c 4b 45 07 5d ad 09 c6 |.,.E....,KE.]...| +00000030 4d 9a fb 72 53 54 d7 a7 59 72 c9 |M..rST..Yr.| >>> Flow 5 (client to server) -00000000 17 03 01 00 20 36 9a 1b 7f 79 a7 ff 31 92 36 5f |.... 6...y..1.6_| -00000010 7c d2 21 69 01 b6 24 da ea b4 b2 42 81 b5 55 94 ||.!i..$....B..U.| -00000020 8e b8 25 83 35 17 03 01 00 20 27 28 1c 8a fa 21 |..%.5.... '(...!| -00000030 57 39 77 57 5b bd ef 05 5b 39 e2 07 1b c9 3c f7 |W9wW[...[9....<.| -00000040 b9 ac be ce 7e 16 87 6d 5b a7 15 03 01 00 20 c0 |....~..m[..... .| -00000050 9b 05 b5 eb ac 65 08 ae 12 c7 18 be 00 a4 d6 30 |.....e.........0| -00000060 15 dd 90 5d d7 25 89 37 be 3d 56 d3 8c a9 3d |...].%.7.=V...=| +00000000 17 03 01 00 20 b4 b4 ad 09 c7 2f ce 80 0b ec 5b |.... ...../....[| +00000010 3f 59 b9 fb 8e 73 fe 23 d6 b0 39 c3 7f a9 61 12 |?Y...s.#..9...a.| +00000020 a7 0f 76 08 f1 17 03 01 00 20 84 c5 c4 22 c8 0c |..v...... ..."..| +00000030 9c c7 04 f9 85 49 fb 8f 0b 49 4e c3 6b b4 5c 62 |.....I...IN.k.\b| +00000040 2a 41 91 41 01 a2 17 43 7c 3d 15 03 01 00 20 e6 |*A.A...C|=.... .| +00000050 5d fa 04 a1 72 9a b3 34 0e 59 e3 0b 8f 3e 6d f7 |]...r..4.Y...>m.| +00000060 cd 85 4e d8 62 27 2c 21 c3 2e c6 64 d2 66 10 |..N.b',!...d.f.| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv10-ExportKeyingMaterial b/libgo/go/crypto/tls/testdata/Client-TLSv10-ExportKeyingMaterial index 571769e125d..a212b07734f 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv10-ExportKeyingMaterial +++ b/libgo/go/crypto/tls/testdata/Client-TLSv10-ExportKeyingMaterial @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 01 00 59 02 00 00 55 03 01 67 4f 02 da 87 |....Y...U..gO...| -00000010 52 30 9a f0 3b e0 63 42 bf 6c 18 58 00 06 70 cf |R0..;.cB.l.X..p.| -00000020 2a 27 5a 00 a7 57 49 fe 03 dd 3b 20 7c 2c 74 00 |*'Z..WI...; |,t.| -00000030 6e b2 35 ca 1b b5 8c 46 f7 78 ab 11 92 43 8c f6 |n.5....F.x...C..| -00000040 97 d3 b8 07 4c 9c 95 2b 08 fe e8 82 c0 13 00 00 |....L..+........| +00000000 16 03 01 00 59 02 00 00 55 03 01 65 28 68 37 bf |....Y...U..e(h7.| +00000010 79 50 5d e6 20 07 ea 1c 6d 46 3b f9 95 a9 97 fa |yP]. ...mF;.....| +00000020 3c 37 87 45 e7 62 f2 e8 44 bb 02 20 e9 e0 63 8e |<7.E.b..D.. ..c.| +00000030 a1 0a cc a4 b3 e6 a9 3b b0 88 c7 af cd d5 73 0a |.......;......s.| +00000040 b4 30 14 cf d9 f5 e0 e8 e2 2e fa 47 c0 13 00 00 |.0.........G....| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 01 02 59 0b 00 02 55 00 02 52 00 02 4f 30 82 02 |..Y...U..R..O0..| 00000070 4b 30 82 01 b4 a0 03 02 01 02 02 09 00 e8 f0 9d |K0..............| @@ -54,36 +60,36 @@ 00000290 77 8d 0c 1c f1 0f a1 d8 40 83 61 c9 4c 72 2b 9d |w.......@.a.Lr+.| 000002a0 ae db 46 06 06 4d f4 c1 b3 3e c0 d1 bd 42 d4 db |..F..M...>...B..| 000002b0 fe 3d 13 60 84 5c 21 d3 3b e9 fa e7 16 03 01 00 |.=.`.\!.;.......| -000002c0 aa 0c 00 00 a6 03 00 1d 20 a0 0e 1d 92 2d b0 a5 |........ ....-..| -000002d0 f0 ab d5 79 a0 bb 12 ff 23 46 bc 27 0d 73 ff 3e |...y....#F.'.s.>| -000002e0 ad 06 d6 57 6b c2 11 76 2d 00 80 77 bf cd 2b cb |...Wk..v-..w..+.| -000002f0 66 c2 fa 30 ed b1 e7 44 79 1b 28 e6 89 62 17 07 |f..0...Dy.(..b..| -00000300 82 c1 5f dc b2 20 4e 42 ed 54 d6 28 3a 2a e3 a3 |.._.. NB.T.(:*..| -00000310 79 06 e3 08 3c c1 3e b9 c6 41 71 2f d0 29 82 36 |y...<.>..Aq/.).6| -00000320 ef 8d 67 c8 77 d0 32 d3 33 5f 77 92 dd 98 bb 03 |..g.w.2.3_w.....| -00000330 cc 0b a6 75 8f 4a 1d f5 6e 1b 06 5b 4a 8b 16 a4 |...u.J..n..[J...| -00000340 c1 ce 11 9d 70 bc 62 7f 58 a5 86 76 91 3d 3a 04 |....p.b.X..v.=:.| -00000350 93 92 89 42 9b a7 7d 9d 75 25 6d 98 f3 e6 68 7e |...B..}.u%m...h~| -00000360 a8 c6 b1 db a7 95 63 39 94 5a 05 16 03 01 00 04 |......c9.Z......| +000002c0 aa 0c 00 00 a6 03 00 1d 20 33 83 7d 9b d5 61 57 |........ 3.}..aW| +000002d0 d1 d3 73 b8 f2 76 f8 31 fd 65 30 5a 6b ab c1 2f |..s..v.1.e0Zk../| +000002e0 0f 38 eb 54 bf 8b 09 a3 5a 00 80 34 a3 a6 86 46 |.8.T....Z..4...F| +000002f0 e5 4d d9 73 23 6a 19 fb f8 77 38 e1 00 74 00 c6 |.M.s#j...w8..t..| +00000300 b2 58 3c 14 a3 7e 57 6d 85 5c 37 4d 82 f1 70 2a |.X<..~Wm.\7M..p*| +00000310 55 c9 e8 89 d1 45 03 e1 ac 84 2e ed 36 1c d5 90 |U....E......6...| +00000320 cf 2d fe a6 9b f0 41 ee 0f 0a 3c 2b bd 18 da a3 |.-....A...<+....| +00000330 f3 21 07 a4 4b 52 1e 3c c4 cf 71 60 c7 05 39 75 |.!..KR.<..q`..9u| +00000340 16 20 f0 6c 18 e8 82 28 3e fc f0 a0 43 6e 77 df |. .l...(>...Cnw.| +00000350 2f fd a1 6a fe 37 9c 67 4e a1 2a 86 23 79 a9 1f |/..j.7.gN.*.#y..| +00000360 4c 9f 2f 04 0c be 27 58 97 57 1d 16 03 01 00 04 |L./...'X.W......| 00000370 0e 00 00 00 |....| >>> Flow 3 (client to server) 00000000 16 03 01 00 25 10 00 00 21 20 2f e5 7d a3 47 cd |....%...! /.}.G.| 00000010 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 |bC.(.._.).0.....| 00000020 cf c2 ed 90 99 5f 58 cb 3b 74 14 03 01 00 01 01 |....._X.;t......| -00000030 16 03 01 00 30 73 ad 46 66 66 e8 bd 44 e4 bf 71 |....0s.Fff..D..q| -00000040 a2 d4 87 e2 4b a3 4a b2 a0 ca ed ac 61 8c 1e 7f |....K.J.....a...| -00000050 68 bf 6f 98 b1 fb 10 1a 5a e6 36 61 91 ac c4 55 |h.o.....Z.6a...U| -00000060 a3 4d 69 66 6e |.Mifn| +00000030 16 03 01 00 30 2a f4 6d db f7 d5 12 3d 3a c0 46 |....0*.m....=:.F| +00000040 cb db 19 82 70 5c 4d 98 f4 42 27 85 eb 90 77 2a |....p\M..B'...w*| +00000050 d7 60 f0 0a 98 a5 da 59 85 ac 65 68 79 91 64 bd |.`.....Y..ehy.d.| +00000060 3a c6 d6 3f 6d |:..?m| >>> Flow 4 (server to client) -00000000 14 03 01 00 01 01 16 03 01 00 30 57 aa 5c d5 dc |..........0W.\..| -00000010 83 4b 23 80 34 4e 36 e8 d6 f3 40 7e ae 12 44 a6 |.K#.4N6...@~..D.| -00000020 c7 48 99 99 0a 85 3c 59 75 32 4e 88 3c 98 a0 23 |.H....>> Flow 5 (client to server) -00000000 17 03 01 00 20 e4 9c f4 fa 6b e8 85 87 6f 20 45 |.... ....k...o E| -00000010 71 d3 e2 9e e3 14 2a 7c 64 e8 11 53 fd 93 c1 4a |q.....*|d..S...J| -00000020 1b 94 f8 48 78 17 03 01 00 20 b9 41 32 1d e8 70 |...Hx.... .A2..p| -00000030 87 5f 2c c6 67 d1 77 3c 30 83 0c 66 35 eb 1d da |._,.g.w<0..f5...| -00000040 6e dd 30 ff 82 05 5f f1 cd e7 15 03 01 00 20 6c |n.0..._....... l| -00000050 47 82 5e 90 5b 84 15 78 05 bd 48 63 d5 46 2f 7e |G.^.[..x..Hc.F/~| -00000060 83 49 ce 3c 0f 04 92 52 5b e7 d5 cf 2c bf 65 |.I.<...R[...,.e| +00000000 17 03 01 00 20 a0 51 37 c8 db c1 c9 03 41 35 7e |.... .Q7.....A5~| +00000010 7c b4 c1 d2 b8 b4 63 e6 ac e7 6d 15 db ef 2d 4e ||.....c...m...-N| +00000020 70 c3 62 51 2c 17 03 01 00 20 55 0e e9 5a 5c 57 |p.bQ,.... U..Z\W| +00000030 fb d9 f9 1b ae c5 ad fc 13 e3 5e 7c 79 c6 f8 92 |..........^|y...| +00000040 9f b9 0e 94 e4 8b d4 cf 75 5c 15 03 01 00 20 bf |........u\.... .| +00000050 76 01 09 a9 b4 1e 54 cd 27 77 35 9e 5c 10 d5 dc |v.....T.'w5.\...| +00000060 3e 6c d6 1c 0b b0 97 b2 27 81 59 92 75 db 90 |>l......'.Y.u..| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv10-RSA-RC4 b/libgo/go/crypto/tls/testdata/Client-TLSv10-RSA-RC4 index 2e10537999b..8a564081880 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv10-RSA-RC4 +++ b/libgo/go/crypto/tls/testdata/Client-TLSv10-RSA-RC4 @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 01 00 51 02 00 00 4d 03 01 ba 66 88 b5 b3 |....Q...M...f...| -00000010 17 e1 9a c1 b6 27 e0 3f 1c 80 73 b6 6c 16 c9 4e |.....'.?..s.l..N| -00000020 33 c4 8c 75 26 46 01 1b 31 dc a3 20 e3 57 4f 91 |3..u&F..1.. .WO.| -00000030 3e 5b 91 cf 75 77 71 66 2f be 84 20 1c 7f 02 dd |>[..uwqf/.. ....| -00000040 8b 63 43 6c 4d 1d a4 7a da 89 35 5a 00 05 00 00 |.cClM..z..5Z....| +00000000 16 03 01 00 51 02 00 00 4d 03 01 d8 84 eb 07 33 |....Q...M......3| +00000010 03 0d 9d c7 6d 90 a7 1f 92 33 6e d0 fc 67 7b 4f |....m....3n..g{O| +00000020 c5 47 84 9c 6b 1d 6d 15 82 0d e2 20 78 95 16 fc |.G..k.m.... x...| +00000030 9a c6 a9 8d 29 d7 5b aa 24 6a 60 48 88 85 f7 b5 |....).[.$j`H....| +00000040 a0 72 f9 c0 ae 3d 01 ae f7 6c b1 3a 00 05 00 00 |.r...=...l.:....| 00000050 05 ff 01 00 01 00 16 03 01 02 59 0b 00 02 55 00 |..........Y...U.| 00000060 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000070 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -64,15 +70,15 @@ 00000060 c5 70 0f 08 83 48 e9 48 ef 6e 50 8b 05 7e e5 84 |.p...H.H.nP..~..| 00000070 25 fa 55 c7 ae 31 02 27 00 ef 3f 98 86 20 12 89 |%.U..1.'..?.. ..| 00000080 91 59 28 b4 f7 d7 af d2 69 61 35 14 03 01 00 01 |.Y(.....ia5.....| -00000090 01 16 03 01 00 24 b6 4b 4c 75 2d d9 8d 1c 85 df |.....$.KLu-.....| -000000a0 f1 8d ff 7a 24 6b 02 3f fa 80 d7 f4 71 76 77 97 |...z$k.?....qvw.| -000000b0 fd b3 59 d7 91 9f 3a e9 ec 3b |..Y...:..;| +00000090 01 16 03 01 00 24 c5 cc 6d 58 66 41 6e 24 3d 77 |.....$..mXfAn$=w| +000000a0 c6 dd b2 2e 39 6f 84 4c e8 32 0b 0b 22 8b 8f d3 |....9o.L.2.."...| +000000b0 e0 fc 8a 0e 88 8f 69 35 88 48 |......i5.H| >>> Flow 4 (server to client) -00000000 14 03 01 00 01 01 16 03 01 00 24 b6 51 7e 95 65 |..........$.Q~.e| -00000010 c5 85 08 c3 31 5c ae 2e e9 9e 6e bb 3d e8 68 c5 |....1\....n.=.h.| -00000020 26 a0 8c 61 a8 96 09 3c ec c7 9a 80 ff a2 5d |&..a...<......]| +00000000 14 03 01 00 01 01 16 03 01 00 24 9c 13 f1 b9 96 |..........$.....| +00000010 4a dc 99 34 51 3e 5f 00 e4 93 94 ee 91 25 9d f2 |J..4Q>_......%..| +00000020 5d f1 8c 7e df b7 4a 42 9c 51 cb c0 83 92 cb |]..~..JB.Q.....| >>> Flow 5 (client to server) -00000000 17 03 01 00 1a 0b 83 3a 24 a0 b4 7f cc 86 6c 4f |.......:$.....lO| -00000010 db 19 1b 09 23 77 a6 91 c6 09 db aa 3c 1a f3 15 |....#w......<...| -00000020 03 01 00 16 80 dc 14 9b a7 ff 08 af 25 5e 67 8c |............%^g.| -00000030 2d 2a 8e c9 bc 17 5a 29 48 99 |-*....Z)H.| +00000000 17 03 01 00 1a 7f 06 af 43 39 09 7b c7 52 fd 67 |........C9.{.R.g| +00000010 cd 4f 44 8f b5 d4 60 db ed dd 7e 10 5e df 1c 15 |.OD...`...~.^...| +00000020 03 01 00 16 7b 2b ee 08 a0 6a c5 64 d8 6d dc 91 |....{+...j.d.m..| +00000030 e8 e0 44 11 23 a9 c8 4c 9d 5b |..D.#..L.[| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv11-ECDHE-ECDSA-AES b/libgo/go/crypto/tls/testdata/Client-TLSv11-ECDHE-ECDSA-AES index 2ef4407b08e..e7a6cf5e086 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv11-ECDHE-ECDSA-AES +++ b/libgo/go/crypto/tls/testdata/Client-TLSv11-ECDHE-ECDSA-AES @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 02 00 59 02 00 00 55 03 02 cd 65 75 71 6d |....Y...U...euqm| -00000010 da bd fe 6b ac ce 01 2f 8e 17 f6 5c 25 37 16 0d |...k.../...\%7..| -00000020 bb 5f 39 e1 c3 14 94 d8 9f 26 02 20 ba 75 d9 3c |._9......&. .u.<| -00000030 2d 56 1f 77 0d 36 52 38 20 44 e2 33 83 4d 93 a0 |-V.w.6R8 D.3.M..| -00000040 fa fe 38 58 d3 1e db 72 ee 14 76 12 c0 09 00 00 |..8X...r..v.....| +00000000 16 03 02 00 59 02 00 00 55 03 02 48 df b9 04 7d |....Y...U..H...}| +00000010 92 50 cb 8f f7 03 8d 34 76 f5 4f 3a a0 d3 8e cc |.P.....4v.O:....| +00000020 2a cd 5d 31 1a 55 d8 08 48 3f d9 20 0c 3b c2 e1 |*.]1.U..H?. .;..| +00000030 8f 94 68 6e e2 31 e4 f9 a6 3d bf 27 84 38 43 95 |..hn.1...=.'.8C.| +00000040 b6 d9 d3 4b fa 0a a2 c6 5a ae 83 bd c0 09 00 00 |...K....Z.......| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 02 02 0e 0b 00 02 0a 00 02 07 00 02 04 30 82 02 |.............0..| 00000070 00 30 82 01 62 02 09 00 b8 bf 2d 47 a0 d2 eb f4 |.0..b.....-G....| @@ -49,39 +55,39 @@ 00000240 13 83 0d 94 06 bb d4 37 7a f6 ec 7a c9 86 2e dd |.......7z..z....| 00000250 d7 11 69 7f 85 7c 56 de fb 31 78 2b e4 c7 78 0d |..i..|V..1x+..x.| 00000260 ae cb be 9e 4e 36 24 31 7b 6a 0f 39 95 12 07 8f |....N6$1{j.9....| -00000270 2a 16 03 02 00 b3 0c 00 00 af 03 00 1d 20 63 d9 |*............ c.| -00000280 4a 4e 6b ef 1c 95 89 ab f8 93 20 46 3f 51 40 a3 |JNk....... F?Q@.| -00000290 2a d5 e7 6b 18 04 01 55 6f d7 3f de 6f 20 00 89 |*..k...Uo.?.o ..| -000002a0 30 81 86 02 41 72 0a a5 28 94 81 35 17 04 6b 6c |0...Ar..(..5..kl| -000002b0 9b 66 0f 31 2e 83 55 bb af 97 87 8b 41 cd eb 2c |.f.1..U.....A..,| -000002c0 d0 71 87 4f d8 80 33 ec d2 57 6e 16 20 7a a7 aa |.q.O..3..Wn. z..| -000002d0 93 9a 14 5b 56 cb df ff b6 bc 5f 98 64 3c e2 cb |...[V....._.d<..| -000002e0 e3 45 0c ac 94 a5 02 41 41 97 c8 5e 64 74 93 ee |.E.....AA..^dt..| -000002f0 2e 56 fb 8a 0b ca f8 e7 5e 80 c7 8c 78 89 37 1b |.V......^...x.7.| -00000300 f2 ff de a0 df 54 9b 58 32 26 c7 cf ad af 5d 06 |.....T.X2&....].| -00000310 d9 7e 0b 96 a0 e0 64 64 e7 f4 04 08 40 b2 d6 a5 |.~....dd....@...| -00000320 bd 75 f4 7c 33 cd 3f 34 02 16 03 02 00 04 0e 00 |.u.|3.?4........| -00000330 00 00 |..| +00000270 2a 16 03 02 00 b4 0c 00 00 b0 03 00 1d 20 1d 08 |*............ ..| +00000280 90 e5 39 31 40 7a 35 73 66 ff 41 e5 02 1f 8d a0 |..91@z5sf.A.....| +00000290 12 e6 14 c8 24 b0 cc 1e 0f ad 4b 1b f9 1a 00 8a |....$.....K.....| +000002a0 30 81 87 02 42 00 bf 9d 0c 38 71 af 56 52 d7 5d |0...B....8q.VR.]| +000002b0 35 98 50 d2 fa 31 29 83 6d 53 9d 2a ef ae 6a 5f |5.P..1).mS.*..j_| +000002c0 4d aa 8b 27 a4 73 51 e7 eb 2d c2 13 54 87 41 23 |M..'.sQ..-..T.A#| +000002d0 98 0b 47 96 ba 50 95 c2 58 ed 23 8e 0b 78 9f cf |..G..P..X.#..x..| +000002e0 6c 61 e6 e5 2b 0e b9 02 41 4b e0 f9 d6 03 cf b4 |la..+...AK......| +000002f0 fa 6f 08 51 b7 3a 2a 60 d0 76 72 c8 28 8e 6e 67 |.o.Q.:*`.vr.(.ng| +00000300 69 42 e3 e0 49 85 e9 cc 6a a0 c4 30 52 3b 3e 46 |iB..I...j..0R;>F| +00000310 a7 a7 2b 95 7f bf 25 6e 54 ea 3c 48 1e 1d 28 96 |..+...%nT.>> Flow 3 (client to server) 00000000 16 03 02 00 25 10 00 00 21 20 2f e5 7d a3 47 cd |....%...! /.}.G.| 00000010 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 |bC.(.._.).0.....| 00000020 cf c2 ed 90 99 5f 58 cb 3b 74 14 03 02 00 01 01 |....._X.;t......| 00000030 16 03 02 00 40 00 00 00 00 00 00 00 00 00 00 00 |....@...........| -00000040 00 00 00 00 00 e8 63 07 7b aa d4 3b ce 03 91 f7 |......c.{..;....| -00000050 4e 28 74 df 52 5f 3e 80 81 30 9d 4e e3 a5 f5 11 |N(t.R_>..0.N....| -00000060 57 80 db 52 1d 4c c4 f3 38 c0 62 3d 84 57 1b 5d |W..R.L..8.b=.W.]| -00000070 1a 51 b3 bb c3 |.Q...| +00000040 00 00 00 00 00 3b 28 96 4f 03 dd 04 4e a3 73 73 |.....;(.O...N.ss| +00000050 48 40 ef e3 4f 9d ab 39 3b db c6 0e fa 7f 0c 18 |H@..O..9;.......| +00000060 f5 94 cd 55 23 2f f5 5c 69 14 bb 0b 49 e3 98 d7 |...U#/.\i...I...| +00000070 c0 db 9e 3a 8b |...:.| >>> Flow 4 (server to client) -00000000 14 03 02 00 01 01 16 03 02 00 40 25 b2 b4 08 64 |..........@%...d| -00000010 e0 09 4f 9a 25 35 7a 29 d8 0f 6d c6 39 3e 9e 17 |..O.%5z)..m.9>..| -00000020 9f bb a2 cc e5 17 5c 76 36 b2 10 13 a2 c5 e9 ba |......\v6.......| -00000030 08 5b f5 ff 8e 64 cc 3a 72 54 22 84 e9 d5 15 8e |.[...d.:rT".....| -00000040 85 44 f4 d3 e2 a8 48 46 32 9d b5 |.D....HF2..| +00000000 14 03 02 00 01 01 16 03 02 00 40 76 98 c8 7d 95 |..........@v..}.| +00000010 ac 40 73 36 c1 49 ae 20 f4 a0 ef 70 59 bf d3 5e |.@s6.I. ...pY..^| +00000020 71 ec 2e f8 c5 ea 9d cc 4d 06 44 e3 aa 46 cd c3 |q.......M.D..F..| +00000030 c9 1b a0 5a 9a 76 ce 3b b5 16 85 33 cf ba 46 08 |...Z.v.;...3..F.| +00000040 b8 c0 a7 da 2a 4d 23 b9 02 cc 3f |....*M#...?| >>> Flow 5 (client to server) 00000000 17 03 02 00 30 00 00 00 00 00 00 00 00 00 00 00 |....0...........| -00000010 00 00 00 00 00 29 6a 84 08 a0 1e eb 43 8e c2 c7 |.....)j.....C...| -00000020 db 45 cc ee 39 0d a7 17 5f da e4 f5 70 d4 10 73 |.E..9..._...p..s| -00000030 40 94 f4 81 4c 15 03 02 00 30 00 00 00 00 00 00 |@...L....0......| -00000040 00 00 00 00 00 00 00 00 00 00 17 41 90 a8 d4 70 |...........A...p| -00000050 c2 5e 89 b6 4e d9 49 83 31 58 c1 ca 59 ec 55 a7 |.^..N.I.1X..Y.U.| -00000060 78 83 63 d0 97 32 a0 78 f5 61 |x.c..2.x.a| +00000010 00 00 00 00 00 03 dd b7 03 45 4d 4c 0a 7a e7 36 |.........EML.z.6| +00000020 a0 93 82 4e 15 73 b1 b8 18 17 35 c6 e1 84 47 4b |...N.s....5...GK| +00000030 8c 3f 5c a2 9d 15 03 02 00 30 00 00 00 00 00 00 |.?\......0......| +00000040 00 00 00 00 00 00 00 00 00 00 c2 f9 0f cb 78 53 |..............xS| +00000050 43 55 f3 fd 8a cc 16 32 19 0b 81 5d 90 a4 31 ff |CU.....2...]..1.| +00000060 58 ea 70 73 92 ad e8 ed 0c e3 |X.ps......| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv11-ECDHE-RSA-AES b/libgo/go/crypto/tls/testdata/Client-TLSv11-ECDHE-RSA-AES index ccf30011207..02175ac954e 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv11-ECDHE-RSA-AES +++ b/libgo/go/crypto/tls/testdata/Client-TLSv11-ECDHE-RSA-AES @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 02 00 59 02 00 00 55 03 02 25 c4 bc bf ab |....Y...U..%....| -00000010 16 38 05 55 b8 78 a8 b6 e4 0c cb 70 f9 72 a9 5f |.8.U.x.....p.r._| -00000020 f3 59 86 32 ca 92 b6 dd 66 83 42 20 e8 b9 6d 35 |.Y.2....f.B ..m5| -00000030 25 ec e2 37 91 f1 9e 8b 0b 7f 15 cf fd 34 16 9e |%..7.........4..| -00000040 ff 44 67 72 df bd 95 75 d3 fd 89 a5 c0 13 00 00 |.Dgr...u........| +00000000 16 03 02 00 59 02 00 00 55 03 02 98 e4 68 fc f9 |....Y...U....h..| +00000010 df 3e 77 31 50 88 fb c7 9c 53 37 20 97 9d 66 e1 |.>w1P....S7 ..f.| +00000020 7f 2b bd 1f 59 2e b4 e1 12 71 0a 20 fe dc fa 3d |.+..Y....q. ...=| +00000030 a5 41 2c 4c 0f 30 73 a8 35 4a 6a 14 1b 6c b6 22 |.A,L.0s.5Jj..l."| +00000040 aa be ae be 7c 53 6d 29 c1 da 0e 6b c0 13 00 00 |....|Sm)...k....| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 02 02 59 0b 00 02 55 00 02 52 00 02 4f 30 82 02 |..Y...U..R..O0..| 00000070 4b 30 82 01 b4 a0 03 02 01 02 02 09 00 e8 f0 9d |K0..............| @@ -54,38 +60,38 @@ 00000290 77 8d 0c 1c f1 0f a1 d8 40 83 61 c9 4c 72 2b 9d |w.......@.a.Lr+.| 000002a0 ae db 46 06 06 4d f4 c1 b3 3e c0 d1 bd 42 d4 db |..F..M...>...B..| 000002b0 fe 3d 13 60 84 5c 21 d3 3b e9 fa e7 16 03 02 00 |.=.`.\!.;.......| -000002c0 aa 0c 00 00 a6 03 00 1d 20 07 e7 bf ce 93 eb a9 |........ .......| -000002d0 c7 5d 78 3f bc 62 d4 d3 88 10 98 5e 6e 90 3e b5 |.]x?.b.....^n.>.| -000002e0 11 cb 3d ed 42 1a d8 ac 2b 00 80 17 fa bd aa a4 |..=.B...+.......| -000002f0 9c 14 78 9f d8 e7 65 3f 1f 54 b8 37 fc 2f a4 61 |..x...e?.T.7./.a| -00000300 aa 47 ce ca 0f 59 f0 22 8c 5a e6 c8 ed 4e aa 91 |.G...Y.".Z...N..| -00000310 c3 ce a8 08 21 7d d7 ef 88 c6 fc 04 6b b2 c8 d6 |....!}......k...| -00000320 f0 3e aa dc 25 8c bd e7 fd 35 ea 44 7f 6d 2f bb |.>..%....5.D.m/.| -00000330 f4 8d a2 39 f9 a1 69 9e 8e bc 08 50 1b 3d fe a9 |...9..i....P.=..| -00000340 91 bd ab 67 2f 7a 71 a2 85 b2 3e ef 3f a5 45 c7 |...g/zq...>.?.E.| -00000350 b1 2c 69 a0 ae 50 f8 12 73 c2 26 6a f0 7d 1f 28 |.,i..P..s.&j.}.(| -00000360 49 1b c0 96 45 d8 e9 19 bd 47 af 16 03 02 00 04 |I...E....G......| +000002c0 aa 0c 00 00 a6 03 00 1d 20 e7 c9 40 dc 8c e7 4a |........ ..@...J| +000002d0 52 c5 47 3d 41 9e 43 75 9a 3e 01 db 85 dd 6e 27 |R.G=A.Cu.>....n'| +000002e0 89 c1 88 3f d3 1b 62 50 6b 00 80 26 d0 b2 dc c7 |...?..bPk..&....| +000002f0 2f 94 03 ff be db bc ee d1 2b 83 29 6e 73 6b 69 |/........+.)nski| +00000300 39 eb a7 38 c3 4b d7 93 1d c7 94 ae 83 1e 70 2c |9..8.K........p,| +00000310 18 bb 82 b6 fe 18 74 a1 33 aa f8 a5 8a 41 c3 b8 |......t.3....A..| +00000320 5d 30 7e 5e cd 05 ef df bf 8a 77 96 1c cb e9 c5 |]0~^......w.....| +00000330 82 0e 79 e0 04 2f ba 0a 63 f5 de 70 b6 ef 09 08 |..y../..c..p....| +00000340 24 36 b6 01 c3 8c d7 3e 54 1b f1 39 08 2e 18 79 |$6.....>T..9...y| +00000350 85 58 73 a2 f4 51 2b 04 1b c5 da b4 47 b0 a8 ca |.Xs..Q+.....G...| +00000360 38 35 75 78 2b 53 97 93 50 01 c3 16 03 02 00 04 |85ux+S..P.......| 00000370 0e 00 00 00 |....| >>> Flow 3 (client to server) 00000000 16 03 02 00 25 10 00 00 21 20 2f e5 7d a3 47 cd |....%...! /.}.G.| 00000010 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 |bC.(.._.).0.....| 00000020 cf c2 ed 90 99 5f 58 cb 3b 74 14 03 02 00 01 01 |....._X.;t......| 00000030 16 03 02 00 40 00 00 00 00 00 00 00 00 00 00 00 |....@...........| -00000040 00 00 00 00 00 f4 1e 67 b5 2c 02 b9 fc 49 44 f1 |.......g.,...ID.| -00000050 85 9f df bd 47 03 f5 68 a4 54 68 ea 13 c8 4c f8 |....G..h.Th...L.| -00000060 81 5e 06 c3 df 2c bb f9 9c a6 99 36 26 60 e0 ac |.^...,.....6&`..| -00000070 5f 82 0a c1 ea |_....| +00000040 00 00 00 00 00 46 e7 d3 6c ca df 1e 98 43 dd fc |.....F..l....C..| +00000050 7c 0e 51 7c 32 0a 76 41 7a c5 19 4a b2 75 e0 43 ||.Q|2.vAz..J.u.C| +00000060 27 7e 84 b3 e2 2b ee fd 6f a5 11 f3 f8 68 e2 b1 |'~...+..o....h..| +00000070 5e 7e ec 3a 89 |^~.:.| >>> Flow 4 (server to client) -00000000 14 03 02 00 01 01 16 03 02 00 40 82 b5 a3 75 27 |..........@...u'| -00000010 3d 41 d0 00 f7 7d 1a e8 97 98 f6 f1 df f7 00 37 |=A...}.........7| -00000020 a7 2e 29 e6 5a 26 ca ef 94 2c 05 06 c4 94 66 01 |..).Z&...,....f.| -00000030 94 65 e3 45 50 7d 7a f4 78 ab 24 f6 9b 84 4b 7d |.e.EP}z.x.$...K}| -00000040 a7 02 9c 32 f7 90 39 ac a6 61 47 |...2..9..aG| +00000000 14 03 02 00 01 01 16 03 02 00 40 a1 8f f2 23 62 |..........@...#b| +00000010 42 71 dd dc d6 8c 5e 3e d7 cf ef 8b b8 26 d4 99 |Bq....^>.....&..| +00000020 d9 4f 58 ac cf eb 5d 56 00 be 20 3e 32 c2 72 2a |.OX...]V.. >2.r*| +00000030 46 6a c4 b6 51 8c 3d c7 b3 e7 28 32 8c b7 f6 4c |Fj..Q.=...(2...L| +00000040 9a 3d 30 56 42 84 25 c7 aa f4 e7 |.=0VB.%....| >>> Flow 5 (client to server) 00000000 17 03 02 00 30 00 00 00 00 00 00 00 00 00 00 00 |....0...........| -00000010 00 00 00 00 00 76 c0 94 ff b2 5a f4 4a 17 47 43 |.....v....Z.J.GC| -00000020 94 d0 b3 7a 77 c0 e6 5d 0e 92 6d 6b 72 b9 d4 58 |...zw..]..mkr..X| -00000030 d3 d5 be 50 95 15 03 02 00 30 00 00 00 00 00 00 |...P.....0......| -00000040 00 00 00 00 00 00 00 00 00 00 25 f0 64 c9 b4 f7 |..........%.d...| -00000050 3c 36 ea e2 df 8c 47 aa 1d a9 ba 5e d0 ce 10 6b |<6....G....^...k| -00000060 a3 4b 08 04 10 60 ce 75 a1 5b |.K...`.u.[| +00000010 00 00 00 00 00 c1 55 65 98 a8 15 c1 80 95 e0 85 |......Ue........| +00000020 c0 0e f5 68 27 b1 f2 27 c2 cc 0e fd 36 15 ed 75 |...h'..'....6..u| +00000030 9f 87 78 ae 3a 15 03 02 00 30 00 00 00 00 00 00 |..x.:....0......| +00000040 00 00 00 00 00 00 00 00 00 00 b1 1a 15 9d f2 93 |................| +00000050 4b 2d 0c 32 9d e6 34 1b 37 bf 89 b2 ca 44 95 16 |K-.2..4.7....D..| +00000060 10 26 bd 47 e9 cb 62 76 1e 72 |.&.G..bv.r| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv11-RSA-RC4 b/libgo/go/crypto/tls/testdata/Client-TLSv11-RSA-RC4 index 0c8ae3518f7..6340eb1bbcc 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv11-RSA-RC4 +++ b/libgo/go/crypto/tls/testdata/Client-TLSv11-RSA-RC4 @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 02 00 51 02 00 00 4d 03 02 17 49 a0 13 8a |....Q...M...I...| -00000010 1d 7a e5 dd dd f3 ba 71 8c 9f b9 16 55 98 4e 56 |.z.....q....U.NV| -00000020 74 da 97 99 09 b7 5a cb 16 17 a8 20 b4 67 96 70 |t.....Z.... .g.p| -00000030 f5 7c 25 f3 5e 47 6b 38 fb 2a 18 67 a7 35 b6 93 |.|%.^Gk8.*.g.5..| -00000040 88 26 c7 da 67 7c d7 d9 4d 23 46 15 00 05 00 00 |.&..g|..M#F.....| +00000000 16 03 02 00 51 02 00 00 4d 03 02 63 10 cc 62 2c |....Q...M..c..b,| +00000010 7c 1f 2a 30 cc 2f fc cf 57 4e b1 a8 48 1a e8 e6 ||.*0./..WN..H...| +00000020 fe 3c ec cd e6 bf b4 0b 90 4f 28 20 f4 f9 6a 6d |.<.......O( ..jm| +00000030 73 cf 9f 86 7e d1 10 ab 7f 48 9c 1e c2 14 1d 18 |s...~....H......| +00000040 cc e8 57 48 65 c5 2e 86 a8 e2 da 4a 00 05 00 00 |..WHe......J....| 00000050 05 ff 01 00 01 00 16 03 02 02 59 0b 00 02 55 00 |..........Y...U.| 00000060 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000070 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -64,15 +70,15 @@ 00000060 c5 70 0f 08 83 48 e9 48 ef 6e 50 8b 05 7e e5 84 |.p...H.H.nP..~..| 00000070 25 fa 55 c7 ae 31 02 27 00 ef 3f 98 86 20 12 89 |%.U..1.'..?.. ..| 00000080 91 59 28 b4 f7 d7 af d2 69 61 35 14 03 02 00 01 |.Y(.....ia5.....| -00000090 01 16 03 02 00 24 57 25 f5 73 5b e7 e4 e5 41 29 |.....$W%.s[...A)| -000000a0 0f 6f c5 92 93 17 17 fe 3f 84 cb 62 c0 69 ef ae |.o......?..b.i..| -000000b0 c4 96 c7 32 76 b9 fb 2a 01 03 |...2v..*..| +00000090 01 16 03 02 00 24 cf ee c8 cd b5 06 a4 5a 3a 3e |.....$.......Z:>| +000000a0 6a 11 9b 40 48 b2 89 95 5c ba 30 59 df 05 63 46 |j..@H...\.0Y..cF| +000000b0 0c 23 54 34 a8 f5 b2 51 1b 3c |.#T4...Q.<| >>> Flow 4 (server to client) -00000000 14 03 02 00 01 01 16 03 02 00 24 74 40 46 d2 01 |..........$t@F..| -00000010 85 de 99 2e 04 b7 c4 a6 50 61 22 01 23 fd 77 be |........Pa".#.w.| -00000020 55 6a 6d 1a 79 17 c7 3d 75 64 99 fc bb 42 a7 |Ujm.y..=ud...B.| +00000000 14 03 02 00 01 01 16 03 02 00 24 5e 7b 1a c0 81 |..........$^{...| +00000010 94 bc 22 87 6f 6a 09 9d ad b4 9c 90 ae 80 4f ed |..".oj........O.| +00000020 3f 6d ac 40 7a 20 0a 9a 7f b2 f9 7d c2 50 7a |?m.@z .....}.Pz| >>> Flow 5 (client to server) -00000000 17 03 02 00 1a d0 cc 3e 2e f5 09 1d 14 b6 ec f4 |.......>........| -00000010 19 64 30 40 eb 86 31 8b 61 fd 94 b5 3a 0c d5 15 |.d0@..1.a...:...| -00000020 03 02 00 16 f2 d9 24 a4 f7 65 0e 26 1e c0 c9 7d |......$..e.&...}| -00000030 5c 57 59 fb 80 fd ab ab 83 e4 |\WY.......| +00000000 17 03 02 00 1a bb f8 a5 2d ef c6 34 c7 1a 1b 87 |........-..4....| +00000010 8c 59 31 72 64 19 a3 d4 ab 40 b3 b9 75 1c 92 15 |.Y1rd....@..u...| +00000020 03 02 00 16 e0 65 24 90 8e 53 9c 2e 48 52 83 ec |.....e$..S..HR..| +00000030 09 b0 92 2b 21 42 c1 ed 45 bb |...+!B..E.| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-AES128-GCM-SHA256 b/libgo/go/crypto/tls/testdata/Client-TLSv12-AES128-GCM-SHA256 index c63e71a4bb0..dde850651ab 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv12-AES128-GCM-SHA256 +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-AES128-GCM-SHA256 @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 03 00 51 02 00 00 4d 03 03 49 4c e7 e2 d1 |....Q...M..IL...| -00000010 f6 48 5a 9c 53 86 a7 b4 43 a2 35 a1 6a cd 40 8d |.HZ.S...C.5.j.@.| -00000020 db 5a 93 d2 66 1a 9e b3 cd ab 8b 20 52 21 cc 8d |.Z..f...... R!..| -00000030 24 23 ed 26 f1 c0 44 17 74 1a ef 01 5c c5 8e 79 |$#.&..D.t...\..y| -00000040 f6 e5 00 e8 b3 71 72 99 a5 2d 4d cf 00 9c 00 00 |.....qr..-M.....| +00000000 16 03 03 00 51 02 00 00 4d 03 03 4c 7d 80 b6 78 |....Q...M..L}..x| +00000010 9f 5c 70 7d fe 4a 0a b2 e3 12 80 14 6d 20 e3 cc |.\p}.J......m ..| +00000020 ec c9 08 8e 44 f6 c2 92 65 90 56 20 86 57 75 b4 |....D...e.V .Wu.| +00000030 3d 5a 00 5f bb 25 f3 21 a9 e2 1e 10 4a 1e 8a 30 |=Z._.%.!....J..0| +00000040 9a 93 b0 87 04 a1 d5 c6 ad 0f c9 fc 00 9c 00 00 |................| 00000050 05 ff 01 00 01 00 16 03 03 02 59 0b 00 02 55 00 |..........Y...U.| 00000060 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000070 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -64,17 +70,17 @@ 00000060 c5 70 0f 08 83 48 e9 48 ef 6e 50 8b 05 7e e5 84 |.p...H.H.nP..~..| 00000070 25 fa 55 c7 ae 31 02 27 00 ef 3f 98 86 20 12 89 |%.U..1.'..?.. ..| 00000080 91 59 28 b4 f7 d7 af d2 69 61 35 14 03 03 00 01 |.Y(.....ia5.....| -00000090 01 16 03 03 00 28 00 00 00 00 00 00 00 00 c5 41 |.....(.........A| -000000a0 79 78 69 d0 e6 8f 11 e0 19 7a a2 51 0f b4 1f 8f |yxi......z.Q....| -000000b0 8a a5 d9 48 1a b8 cd 2f ea e2 04 9b e8 9f |...H.../......| +00000090 01 16 03 03 00 28 00 00 00 00 00 00 00 00 14 74 |.....(.........t| +000000a0 ff 19 e7 d3 2c b4 5e 43 c2 38 d2 53 ca a2 3e f6 |....,.^C.8.S..>.| +000000b0 f0 12 92 0c 68 6f d7 5c 37 ff 8e d7 98 bf |....ho.\7.....| >>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 28 f3 72 0c 34 0f |..........(.r.4.| -00000010 59 fa 8d 0f d1 37 6d 3b 9c e6 41 66 8b 30 4a d0 |Y....7m;..Af.0J.| -00000020 ef 21 f1 42 79 f0 55 0e a1 43 d5 d7 b1 d6 45 aa |.!.By.U..C....E.| -00000030 5a 3a 69 |Z:i| +00000000 14 03 03 00 01 01 16 03 03 00 28 20 60 01 e9 d0 |..........( `...| +00000010 f7 5a 03 c6 6c 6e 37 5e ad e2 2f 93 84 31 88 38 |.Z..ln7^../..1.8| +00000020 da b7 55 4d 3d 0c 8a 6b 7c 57 05 2a ef 6f 24 6b |..UM=..k|W.*.o$k| +00000030 6f 1d d6 |o..| >>> Flow 5 (client to server) -00000000 17 03 03 00 1e 00 00 00 00 00 00 00 01 7d bd ac |.............}..| -00000010 69 1a 3c b3 4d 0f 1b 25 40 95 34 f0 b1 97 60 39 |i.<.M..%@.4...`9| -00000020 93 42 10 15 03 03 00 1a 00 00 00 00 00 00 00 02 |.B..............| -00000030 a0 65 f5 b0 94 a5 2e 1a c4 a5 97 76 12 8f 82 70 |.e.........v...p| -00000040 49 0c |I.| +00000000 17 03 03 00 1e 00 00 00 00 00 00 00 01 4f 20 33 |.............O 3| +00000010 83 73 86 0a ca 92 4d 8b d5 cf 2e e8 b1 f0 81 9c |.s....M.........| +00000020 c1 3b 0a 15 03 03 00 1a 00 00 00 00 00 00 00 02 |.;..............| +00000030 9c a9 02 e8 ad cf 5f 33 f0 15 86 c7 4a 11 85 20 |......_3....J.. | +00000040 06 04 |..| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-AES128-SHA256 b/libgo/go/crypto/tls/testdata/Client-TLSv12-AES128-SHA256 index 17826d300a4..8714fdbcef7 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv12-AES128-SHA256 +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-AES128-SHA256 @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 03 00 51 02 00 00 4d 03 03 89 90 c7 c5 d0 |....Q...M.......| -00000010 21 e2 50 ac 35 a7 b1 10 8a 32 45 b8 48 02 0e 19 |!.P.5....2E.H...| -00000020 45 58 31 81 a4 db 0f 19 21 53 80 20 ca a7 7f 02 |EX1.....!S. ....| -00000030 5a f4 9b cc 70 72 fa e8 ed 4f 0c 1b c7 7a b2 58 |Z...pr...O...z.X| -00000040 e1 c1 b3 c8 3e a1 82 8e 78 3b c6 02 00 3c 00 00 |....>...x;...<..| +00000000 16 03 03 00 51 02 00 00 4d 03 03 fa f4 c1 2c 7a |....Q...M.....,z| +00000010 a0 09 f0 35 06 c3 79 90 a4 df fa 3c 14 1a 95 92 |...5..y....<....| +00000020 23 16 19 9d 38 83 89 6f ee 7e 7b 20 1f 2d 6c 2b |#...8..o.~{ .-l+| +00000030 bf 93 e4 58 00 13 6d ac 4d 0b c2 b4 4a e5 b3 39 |...X..m.M...J..9| +00000040 80 8e 35 1b 7b ec 9a 2e b8 bb 0b 04 00 3c 00 00 |..5.{........<..| 00000050 05 ff 01 00 01 00 16 03 03 02 59 0b 00 02 55 00 |..........Y...U.| 00000060 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000070 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -65,25 +71,25 @@ 00000070 25 fa 55 c7 ae 31 02 27 00 ef 3f 98 86 20 12 89 |%.U..1.'..?.. ..| 00000080 91 59 28 b4 f7 d7 af d2 69 61 35 14 03 03 00 01 |.Y(.....ia5.....| 00000090 01 16 03 03 00 50 00 00 00 00 00 00 00 00 00 00 |.....P..........| -000000a0 00 00 00 00 00 00 e0 31 66 d7 3b a5 a2 cd 61 c5 |.......1f.;...a.| -000000b0 76 26 ce b4 a7 a3 86 8b 68 98 8a 0c 14 df 71 39 |v&......h.....q9| -000000c0 29 b0 29 05 97 87 2f d5 81 25 0b 46 e7 91 2a fc |).).../..%.F..*.| -000000d0 bb 76 d3 19 31 37 ad 8b 01 f0 66 1f 0f 7f 7a 0f |.v..17....f...z.| -000000e0 bd 2b 76 3f 84 2b |.+v?.+| +000000a0 00 00 00 00 00 00 ab 11 61 9b 81 32 bc 64 54 55 |........a..2.dTU| +000000b0 4d 76 5d 75 77 10 c4 df 34 43 af a5 83 37 24 e9 |Mv]uw...4C...7$.| +000000c0 6c c8 73 ad 28 24 a8 3a be 5d a9 22 21 fc e5 95 |l.s.($.:.]."!...| +000000d0 7e 27 18 d4 c4 b4 c5 70 f6 48 73 a6 97 2a c7 5d |~'.....p.Hs..*.]| +000000e0 46 78 37 9f f1 30 |Fx7..0| >>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 50 b7 1d 0b ad 4a |..........P....J| -00000010 05 27 59 4e 95 11 58 6e 90 02 12 52 40 b2 0e 1d |.'YN..Xn...R@...| -00000020 ca 82 a6 85 2f 01 ad 9c 29 41 f9 a0 3d b2 39 be |..../...)A..=.9.| -00000030 9f 76 72 3e de db 17 de d7 9e 4e 0a 89 be 27 9c |.vr>......N...'.| -00000040 37 88 46 87 8c a9 a9 41 70 01 72 60 18 4a 3b ac |7.F....Ap.r`.J;.| -00000050 97 8e 4f 2c 4b 4e 87 0b bd e4 89 |..O,KN.....| +00000000 14 03 03 00 01 01 16 03 03 00 50 c3 5f 95 d2 ee |..........P._...| +00000010 3d 98 c9 29 ab 06 fc 8c 9b 9c fa 98 36 f1 6c f4 |=..)........6.l.| +00000020 0c bd c6 d3 79 7e ce 90 fa 23 04 d3 41 ea 35 f0 |....y~...#..A.5.| +00000030 3e bc dc 02 ae 0d 87 27 1a 8b d8 f0 e4 32 7d 89 |>......'.....2}.| +00000040 9c 89 50 38 ae 02 e2 c7 65 43 a9 1f ce 42 c9 e3 |..P8....eC...B..| +00000050 ce 0d 68 16 f6 46 6d 40 47 66 3c |..h..Fm@Gf<| >>> Flow 5 (client to server) 00000000 17 03 03 00 40 00 00 00 00 00 00 00 00 00 00 00 |....@...........| -00000010 00 00 00 00 00 b6 0c c1 ab 01 1a 69 8f 48 80 5e |...........i.H.^| -00000020 f8 d6 b7 b9 7c 9e 30 01 ff 4d 27 94 ef 3e 05 c3 |....|.0..M'..>..| -00000030 64 fd 38 f9 b9 29 fe 49 bf 6a fc 6f ac 1e 6d ee |d.8..).I.j.o..m.| -00000040 42 a2 2f 05 e5 15 03 03 00 40 00 00 00 00 00 00 |B./......@......| -00000050 00 00 00 00 00 00 00 00 00 00 37 ca 1c 12 fd 31 |..........7....1| -00000060 2b 9e 56 51 a7 f5 3e 37 48 fe 08 b9 a3 8d 4c 26 |+.VQ..>7H.....L&| -00000070 7d c2 9d 04 f8 7f b9 47 00 87 bd 86 51 36 83 a7 |}......G....Q6..| -00000080 98 cf de ac 76 d6 78 ac bd 95 |....v.x...| +00000010 00 00 00 00 00 55 d6 ad fe d9 c9 28 f1 6e 80 e3 |.....U.....(.n..| +00000020 54 38 52 96 9f cb cb 94 67 ef a1 ed e0 6b 83 c6 |T8R.....g....k..| +00000030 c8 48 c2 bb ed 18 a5 ec cc 6d cc f1 78 a1 be 45 |.H.......m..x..E| +00000040 88 e9 c9 5a 03 15 03 03 00 40 00 00 00 00 00 00 |...Z.....@......| +00000050 00 00 00 00 00 00 00 00 00 00 8a 47 d5 d1 ba 89 |...........G....| +00000060 cb 14 1a a7 99 6b 41 14 4c 85 f3 df f2 51 42 23 |.....kA.L....QB#| +00000070 0d 44 b1 a4 52 3c e8 34 5c 09 cc 92 06 3a 3f 75 |.D..R<.4\....:?u| +00000080 b1 b2 cb bf c7 ff da f7 7a 90 |........z.| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-AES256-GCM-SHA384 b/libgo/go/crypto/tls/testdata/Client-TLSv12-AES256-GCM-SHA384 index 598430dae22..61abb55a519 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv12-AES256-GCM-SHA384 +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-AES256-GCM-SHA384 @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 03 00 51 02 00 00 4d 03 03 de 31 eb 89 cf |....Q...M...1...| -00000010 06 df 45 b2 68 3c 70 8e ef ec 11 14 d1 f3 8c 95 |..E.h>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 28 f0 52 59 4b c1 |..........(.RYK.| -00000010 54 7c 0d 0c 4a 82 96 0a 50 d2 6d ce 7c 2f e9 3c |T|..J...P.m.|/.<| -00000020 55 ea da ea 8a 1a 6f 1d fe 96 01 0f 42 61 61 45 |U.....o.....BaaE| -00000030 ef 31 97 |.1.| +00000000 14 03 03 00 01 01 16 03 03 00 28 68 27 f4 6c ac |..........(h'.l.| +00000010 ae 31 68 1a b3 7c 5f 6f 41 18 5a 24 d3 04 00 d2 |.1h..|_oA.Z$....| +00000020 2d ce 9b 30 a1 55 df f6 7a ff 80 42 9c 86 c7 13 |-..0.U..z..B....| +00000030 c8 fc ca |...| >>> Flow 5 (client to server) -00000000 17 03 03 00 1e 00 00 00 00 00 00 00 01 cb 28 8f |..............(.| -00000010 dd 5d cf 29 ef 92 72 71 43 85 c1 1b fe 41 a4 f8 |.].)..rqC....A..| -00000020 07 f7 96 15 03 03 00 1a 00 00 00 00 00 00 00 02 |................| -00000030 25 52 2c d6 5a f4 95 ea 21 bb 35 70 d1 78 cc 15 |%R,.Z...!.5p.x..| -00000040 d5 79 |.y| +00000000 17 03 03 00 1e 00 00 00 00 00 00 00 01 e3 e7 af |................| +00000010 ee cc 1b e2 13 85 a7 37 85 e9 bd a7 3e 18 e2 f0 |.......7....>...| +00000020 e3 2d 64 15 03 03 00 1a 00 00 00 00 00 00 00 02 |.-d.............| +00000030 3d fe 35 3c b3 13 25 f8 a3 b8 81 da 91 3b 8d 69 |=.5<..%......;.i| +00000040 fc c5 |..| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-ALPN b/libgo/go/crypto/tls/testdata/Client-TLSv12-ALPN index 05c4afb1b5f..72d2b7c4b73 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv12-ALPN +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-ALPN @@ -1,22 +1,28 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 ad 01 00 00 a9 03 03 00 00 00 00 00 |................| +00000000 16 03 01 01 10 01 00 01 0c 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 54 33 74 |.............T3t| -00000060 00 00 00 05 00 05 01 00 00 00 00 00 0a 00 0a 00 |................| -00000070 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 00 00 |................| -00000080 0d 00 12 00 10 04 01 04 03 05 01 05 03 06 01 06 |................| -00000090 03 02 01 02 03 ff 01 00 01 00 00 10 00 10 00 0e |................| -000000a0 06 70 72 6f 74 6f 32 06 70 72 6f 74 6f 31 00 12 |.proto2.proto1..| -000000b0 00 00 |..| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 91 33 74 00 00 00 05 00 05 01 00 00 00 |....3t..........| +00000090 00 00 0a 00 0a 00 08 00 1d 00 17 00 18 00 19 00 |................| +000000a0 0b 00 02 01 00 00 0d 00 18 00 16 08 04 08 05 08 |................| +000000b0 06 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| +000000c0 03 ff 01 00 01 00 00 10 00 10 00 0e 06 70 72 6f |.............pro| +000000d0 74 6f 32 06 70 72 6f 74 6f 31 00 12 00 00 00 2b |to2.proto1.....+| +000000e0 00 09 08 03 04 03 03 03 02 03 01 00 33 00 26 00 |............3.&.| +000000f0 24 00 1d 00 20 2f e5 7d a3 47 cd 62 43 15 28 da |$... /.}.G.bC.(.| +00000100 ac 5f bb 29 07 30 ff f6 84 af c4 cf c2 ed 90 99 |._.).0..........| +00000110 5f 58 cb 3b 74 |_X.;t| >>> Flow 2 (server to client) -00000000 16 03 03 00 66 02 00 00 62 03 03 cb 8e 3f a0 07 |....f...b....?..| -00000010 c3 0e b3 b2 07 39 e2 2d b9 5f 03 31 05 b0 0d b6 |.....9.-._.1....| -00000020 c7 c5 4d 39 2b 3f 1a d7 38 43 69 20 f5 35 e2 93 |..M9+?..8Ci .5..| -00000030 75 c4 eb b3 eb a3 ad cd 9f e3 c6 dc b8 ea 20 7c |u............. || -00000040 94 1b 9c 73 bd 2e af f1 4d 97 6d eb cc a8 00 00 |...s....M.m.....| +00000000 16 03 03 00 66 02 00 00 62 03 03 44 df ea e4 67 |....f...b..D...g| +00000010 62 77 d5 ee 65 9f 25 8b 54 86 1a 1f 09 46 9c 41 |bw..e.%.T....F.A| +00000020 d3 13 bb 6c f5 73 9a 22 eb cf 8d 20 e8 2e 63 9f |...l.s."... ..c.| +00000030 a3 64 aa 59 7b 88 f8 28 7e 57 00 7c 3a cc 80 5e |.d.Y{..(~W.|:..^| +00000040 7d 9a 03 1e 5d 89 c0 ff 53 aa c0 4d cc a8 00 00 |}...]...S..M....| 00000050 1a ff 01 00 01 00 00 0b 00 04 03 00 01 02 00 10 |................| 00000060 00 09 00 07 06 70 72 6f 74 6f 31 16 03 03 02 59 |.....proto1....Y| 00000070 0b 00 02 55 00 02 52 00 02 4f 30 82 02 4b 30 82 |...U..R..O0..K0.| @@ -57,31 +63,31 @@ 000002a0 1c f1 0f a1 d8 40 83 61 c9 4c 72 2b 9d ae db 46 |.....@.a.Lr+...F| 000002b0 06 06 4d f4 c1 b3 3e c0 d1 bd 42 d4 db fe 3d 13 |..M...>...B...=.| 000002c0 60 84 5c 21 d3 3b e9 fa e7 16 03 03 00 ac 0c 00 |`.\!.;..........| -000002d0 00 a8 03 00 1d 20 4c d6 65 c1 74 2c 78 ab 45 87 |..... L.e.t,x.E.| -000002e0 bc 6e 9a cd 6c d4 2f 1e ed 1b ed 68 e0 20 3b 13 |.n..l./....h. ;.| -000002f0 7b b9 45 a1 38 78 04 01 00 80 31 26 2b b6 f8 fe |{.E.8x....1&+...| -00000300 bf 3c c6 8e ec 30 87 09 18 87 27 ec 9f 4f 93 74 |.<...0....'..O.t| -00000310 6b 65 94 12 3e 4d 5e a8 f7 0f ec 9e 60 c5 d5 a0 |ke..>M^.....`...| -00000320 c1 53 10 1d 8a 5b 82 2e 64 07 59 2e 0c b8 e3 90 |.S...[..d.Y.....| -00000330 20 a5 0a 88 3e 7e d6 b9 85 58 78 f1 58 56 a6 d8 | ...>~...Xx.XV..| -00000340 ee 60 52 59 d1 5b 16 58 de ce bc 09 79 99 65 e0 |.`RY.[.X....y.e.| -00000350 6b 0b 4e 3d fb 80 35 6b 56 48 33 b3 17 4e 61 cf |k.N=..5kVH3..Na.| -00000360 88 78 41 14 c8 fa 41 32 f9 2b 87 27 40 d7 2b 51 |.xA...A2.+.'@.+Q| -00000370 bd 16 54 cd f3 79 3a 7d c9 f0 16 03 03 00 04 0e |..T..y:}........| +000002d0 00 a8 03 00 1d 20 5e d1 0b 33 b0 c2 e9 12 eb 00 |..... ^..3......| +000002e0 4d 2f b8 1b 74 b0 b2 a0 01 7a 67 5a 54 9e a5 d1 |M/..t....zgZT...| +000002f0 c5 a5 2e 59 af 53 08 04 00 80 1f ac 73 b9 62 55 |...Y.S......s.bU| +00000300 a2 53 ae 64 db 2a f7 a1 a8 69 09 2d a2 fa 0c d8 |.S.d.*...i.-....| +00000310 9e e8 9a 2f b6 8f f0 e1 5e 53 bb 4c 9e fa e4 7a |.../....^S.L...z| +00000320 68 06 20 d5 e7 d0 de cf 29 a8 bd 6b 54 82 e4 bb |h. .....)..kT...| +00000330 dd 6e ab d1 d1 c9 af 77 01 b1 06 e1 9d 2f 00 7a |.n.....w...../.z| +00000340 2b e7 6f d1 da 7c 6f f5 2c 03 0d 57 9e 19 41 be |+.o..|o.,..W..A.| +00000350 91 85 17 c2 4a 5e 9b 87 44 0e df 81 64 b1 2e 4b |....J^..D...d..K| +00000360 64 80 fb f2 7f 23 f1 19 2c 8a 8d 6d 08 1e e9 0d |d....#..,..m....| +00000370 47 ec 94 b0 db c6 7a 44 79 04 16 03 03 00 04 0e |G.....zDy.......| 00000380 00 00 00 |...| >>> Flow 3 (client to server) 00000000 16 03 03 00 25 10 00 00 21 20 2f e5 7d a3 47 cd |....%...! /.}.G.| 00000010 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 |bC.(.._.).0.....| 00000020 cf c2 ed 90 99 5f 58 cb 3b 74 14 03 03 00 01 01 |....._X.;t......| -00000030 16 03 03 00 20 40 b0 f2 80 ce 38 b3 98 fd 34 ba |.... @....8...4.| -00000040 84 d3 f7 30 dc 9f 09 4b 0e 44 0b 79 b1 28 39 53 |...0...K.D.y.(9S| -00000050 94 03 db c8 2b |....+| +00000030 16 03 03 00 20 b9 03 a2 50 29 94 cc 5b 6c 3c 7f |.... ...P)..[l<.| +00000040 71 13 4b f0 3e 1a 13 df a0 a6 e3 15 a7 36 a2 40 |q.K.>........6.@| +00000050 86 88 d4 63 c0 |...c.| >>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 20 6f 6c ec 1a 29 |.......... ol..)| -00000010 d8 29 6c 10 67 12 4f 45 d3 64 85 e4 bc 28 5b 52 |.)l.g.OE.d...([R| -00000020 d0 46 45 3c ac bc fa 51 c1 00 84 |.FE<...Q...| +00000000 14 03 03 00 01 01 16 03 03 00 20 c0 4e 72 ff 58 |.......... .Nr.X| +00000010 40 70 90 8a ac 4e 94 28 ae 45 5e 2f 5f f4 c3 61 |@p...N.(.E^/_..a| +00000020 64 5d d9 af 43 a0 c1 65 78 2a 5e |d]..C..ex*^| >>> Flow 5 (client to server) -00000000 17 03 03 00 16 7d 3e 49 f0 a6 61 18 fc 10 f4 7f |.....}>I..a.....| -00000010 e2 df b7 58 7d ad 31 84 de 60 e0 15 03 03 00 12 |...X}.1..`......| -00000020 08 cd 3f b6 58 d8 72 12 e0 f5 c6 8f f7 76 d5 29 |..?.X.r......v.)| -00000030 4f b2 |O.| +00000000 17 03 03 00 16 e3 fb 93 b5 c4 17 c2 6a 9c 15 ca |............j...| +00000010 de ca c6 49 67 d6 59 65 4a ee d2 15 03 03 00 12 |...Ig.YeJ.......| +00000020 8b f7 3f 3d ad 68 2b bf f2 96 18 21 d0 0f ea e8 |..?=.h+....!....| +00000030 a0 d9 |..| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-ECDSA-ECDSA b/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-ECDSA-ECDSA index 6fc1b1bd18e..0968c160a59 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-ECDSA-ECDSA +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-ECDSA-ECDSA @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 03 00 59 02 00 00 55 03 03 3d c4 44 53 fd |....Y...U..=.DS.| -00000010 1d ce 32 ba 0a ba 77 43 7a ba d1 e1 5b 7d 78 d4 |..2...wCz...[}x.| -00000020 d3 29 5f e2 2b ab a1 e0 20 70 bd 20 4c 6b 28 a6 |.)_.+... p. Lk(.| -00000030 f0 d0 51 92 3d ed 65 5c bd 26 8f 81 93 14 b0 93 |..Q.=.e\.&......| -00000040 80 af ae f6 3c 59 1f 1c 65 45 f0 13 c0 09 00 00 |.....*.N...| -000002d0 47 59 42 4f 54 51 3f dd fc b9 b0 b4 fe d2 77 28 |GYBOTQ?.......w(| -000002e0 15 58 4f b5 f5 56 da b2 02 02 42 00 cb 0b 69 b7 |.XO..V....B...i.| -000002f0 1b 48 85 7e e3 bf be 27 64 c7 38 4d dc a1 49 73 |.H.~...'d.8M..Is| -00000300 ba f9 45 6b cc 95 d1 72 d8 45 9c 39 3d 3a 93 85 |..Ek...r.E.9=:..| -00000310 a7 22 20 c3 ce 48 e3 0d 31 9c f4 cf 2c dc d7 9d |." ..H..1...,...| -00000320 d3 b4 6a fe 98 31 d9 32 dc 37 1a c0 fa 16 03 03 |..j..1.2.7......| -00000330 00 2a 0d 00 00 26 03 01 02 40 00 1e 06 01 06 02 |.*...&...@......| -00000340 06 03 05 01 05 02 05 03 04 01 04 02 04 03 03 01 |................| -00000350 03 02 03 03 02 01 02 02 02 03 00 00 16 03 03 00 |................| -00000360 04 0e 00 00 00 |.....| +00000270 2a 16 03 03 00 b7 0c 00 00 b3 03 00 1d 20 1c 45 |*............ .E| +00000280 5f 18 e9 5f 2f 0d 3b 3f f2 a8 dc f8 15 1c 03 e4 |_.._/.;?........| +00000290 c1 fa f8 f7 75 cb 74 17 cd 82 7d 26 8e 41 04 03 |....u.t...}&.A..| +000002a0 00 8b 30 81 88 02 42 01 6c ae 9f 61 16 bb 03 50 |..0...B.l..a...P| +000002b0 52 94 7f 89 59 92 a5 3e 74 54 97 7a f0 22 a5 7d |R...Y..>tT.z.".}| +000002c0 de 80 c4 6a 0d a0 cb 50 e1 aa 27 a9 44 4f 24 db |...j...P..'.DO$.| +000002d0 69 b2 d2 6c 6e 26 79 99 d8 31 9d 2d 47 26 f1 c6 |i..ln&y..1.-G&..| +000002e0 42 25 f5 66 6b 03 7a 19 b1 02 42 00 f4 5c 98 a4 |B%.fk.z...B..\..| +000002f0 d3 d7 af 36 42 cc 95 91 be 7e b1 3c 61 df a9 9c |...6B....~.>> Flow 3 (client to server) 00000000 16 03 03 02 0a 0b 00 02 06 00 02 03 00 02 00 30 |...............0| 00000010 82 01 fc 30 82 01 5e 02 09 00 9a 30 84 6c 26 35 |...0..^....0.l&5| @@ -101,32 +108,32 @@ 00000200 e4 fa cc b1 8a ce e2 23 a0 87 f0 e1 67 51 eb 16 |.......#....gQ..| 00000210 03 03 00 25 10 00 00 21 20 2f e5 7d a3 47 cd 62 |...%...! /.}.G.b| 00000220 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 cf |C.(.._.).0......| -00000230 c2 ed 90 99 5f 58 cb 3b 74 16 03 03 00 92 0f 00 |...._X.;t.......| -00000240 00 8e 06 03 00 8a 30 81 87 02 42 00 cb 61 7d bc |......0...B..a}.| -00000250 af 48 88 32 98 9b 34 a0 71 0e 3a 33 bd da 73 16 |.H.2..4.q.:3..s.| -00000260 05 f4 8e d8 30 11 c8 da dd 7a 84 80 57 a1 76 d8 |....0....z..W.v.| -00000270 af 3d 90 d7 e2 44 85 78 c4 12 ed 8d dc 4e 82 08 |.=...D.x.....N..| -00000280 51 20 59 d7 38 26 29 c9 2b 5b 77 fc d2 02 41 3b |Q Y.8&).+[w...A;| -00000290 70 99 7c 46 bf 8e 85 40 d7 75 c5 43 36 f8 e3 30 |p.|F...@.u.C6..0| -000002a0 28 ac 20 1e 79 43 b2 f3 6d b1 ae 6e cf 41 b5 ed |(. .yC..m..n.A..| -000002b0 76 2b d5 17 78 2c fa 91 75 ba 63 8f e9 1c c8 c0 |v+..x,..u.c.....| -000002c0 1e 02 63 70 53 41 e0 98 77 a5 ae 54 6a 74 c0 91 |..cpSA..w..Tjt..| -000002d0 14 03 03 00 01 01 16 03 03 00 40 00 00 00 00 00 |..........@.....| -000002e0 00 00 00 00 00 00 00 00 00 00 00 7d 12 bc ba f4 |...........}....| -000002f0 34 59 b7 c2 a9 5d 11 88 38 cc bc cc 1c 14 b7 5a |4Y...]..8......Z| -00000300 ae d8 0a 45 bc 61 b5 bc d6 8e c4 69 80 10 7a ea |...E.a.....i..z.| -00000310 07 f4 dc 1a c9 dc b8 90 66 6c bc |........fl.| +00000230 c2 ed 90 99 5f 58 cb 3b 74 16 03 03 00 93 0f 00 |...._X.;t.......| +00000240 00 8f 04 03 00 8b 30 81 88 02 42 01 83 b1 39 05 |......0...B...9.| +00000250 25 f1 1b 2b 55 c0 7e 56 e1 0e 33 bc 03 c7 0a 17 |%..+U.~V..3.....| +00000260 b7 c2 b7 da ab 9d 5d 22 da 60 74 7d 85 5e 53 ff |......]".`t}.^S.| +00000270 57 4e c3 0a 47 fd e5 f6 dc 05 56 4c 7a 9f e4 5c |WN..G.....VLz..\| +00000280 04 97 80 61 d5 9f db a5 74 9b ec fc bf 02 42 01 |...a....t.....B.| +00000290 27 f8 0e 21 c2 c2 68 72 82 1b 4b cf d8 0c 1a 09 |'..!..hr..K.....| +000002a0 b0 f5 0f b9 3b e9 63 dc 68 33 5e 41 e2 2c a4 04 |....;.c.h3^A.,..| +000002b0 ec ee 84 6d f3 28 fc 6d c4 f1 04 8c 1d 38 6e e9 |...m.(.m.....8n.| +000002c0 ae 0d 0a 82 0e 42 c4 42 e7 12 33 c5 38 4f 19 51 |.....B.B..3.8O.Q| +000002d0 61 14 03 03 00 01 01 16 03 03 00 40 00 00 00 00 |a..........@....| +000002e0 00 00 00 00 00 00 00 00 00 00 00 00 9e b0 80 10 |................| +000002f0 4c da e3 cd 1e 56 e6 90 10 c5 ea d6 25 f9 34 31 |L....V......%.41| +00000300 cd 42 60 5d ab 3b 13 05 48 cd f6 53 c3 b7 ea ea |.B`].;..H..S....| +00000310 30 f0 58 2d 17 3c 77 fb a7 8f 9f a8 |0.X-.>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 40 df ff fd 43 0b |..........@...C.| -00000010 d1 28 4b db ce 29 8b 01 56 e7 44 9d 69 92 e7 11 |.(K..)..V.D.i...| -00000020 7c 57 f2 a1 cf 35 d4 3a 8f 90 69 ce 80 4e 8b 6c ||W...5.:..i..N.l| -00000030 e9 eb 90 65 0e 89 49 20 41 ae 32 62 66 f4 aa 85 |...e..I A.2bf...| -00000040 cd ca f7 a2 37 8f ef 22 ab b6 7b |....7.."..{| +00000000 14 03 03 00 01 01 16 03 03 00 40 68 2a 2b af 97 |..........@h*+..| +00000010 68 8d 96 ed 55 bc aa d2 d3 81 97 54 a1 01 88 7f |h...U......T....| +00000020 72 b7 3a 38 66 c2 53 9a 01 56 0d e0 02 b5 93 66 |r.:8f.S..V.....f| +00000030 b3 93 74 e2 e0 c5 22 1c 0d 8f bb 7d e1 43 bf bd |..t..."....}.C..| +00000040 bc 69 2e 58 96 7b 39 f0 55 6f 1b |.i.X.{9.Uo.| >>> Flow 5 (client to server) 00000000 17 03 03 00 30 00 00 00 00 00 00 00 00 00 00 00 |....0...........| -00000010 00 00 00 00 00 76 a4 88 f6 fb 0a 0f 8d a6 1f e0 |.....v..........| -00000020 96 4d d0 93 30 c9 b6 27 1e 3c 87 d7 98 f9 d6 e9 |.M..0..'.<......| -00000030 96 f7 e0 af b6 15 03 03 00 30 00 00 00 00 00 00 |.........0......| -00000040 00 00 00 00 00 00 00 00 00 00 82 01 3b 93 6f 78 |............;.ox| -00000050 1b e8 b6 ed 45 11 85 26 0f 40 63 2a a6 c9 f8 7b |....E..&.@c*...{| -00000060 7f 01 42 6b c1 8b 4f c0 a6 b5 |..Bk..O...| +00000010 00 00 00 00 00 a6 98 ea d6 b2 81 83 18 5d 73 13 |.............]s.| +00000020 dc e9 e9 bc 4c 1e a8 ec a5 62 93 f6 b8 0c 0f f0 |....L....b......| +00000030 91 6e 51 2c fe 15 03 03 00 30 00 00 00 00 00 00 |.nQ,.....0......| +00000040 00 00 00 00 00 00 00 00 00 00 7f e8 f5 80 8e 27 |...............'| +00000050 1b 31 aa d0 ec 91 51 d0 18 21 de e3 63 1f ee 80 |.1....Q..!..c...| +00000060 bc db 2f 4f ce 26 46 ce 65 2e |../O.&F.e.| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-ECDSA-RSA b/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-ECDSA-RSA index 47c083e494a..995e9a9bc98 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-ECDSA-RSA +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-ECDSA-RSA @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 03 00 59 02 00 00 55 03 03 b1 01 db c2 3f |....Y...U......?| -00000010 11 0c d0 d2 fd 1d 5f 54 f6 62 4a 47 f9 62 e6 88 |......_T.bJG.b..| -00000020 72 d7 f5 91 78 73 99 94 72 26 ed 20 51 91 b2 bf |r...xs..r&. Q...| -00000030 78 94 0c 1f bb 7b ff a2 b6 8f 57 5d 03 f2 97 b8 |x....{....W]....| -00000040 c2 20 99 cd 48 f3 14 fc 63 38 97 44 c0 2f 00 00 |. ..H...c8.D./..| +00000000 16 03 03 00 59 02 00 00 55 03 03 87 08 05 c4 11 |....Y...U.......| +00000010 d3 bb ca 40 4a 0a 95 79 8c b9 82 54 6f e2 11 ba |...@J..y...To...| +00000020 bd 7b 0d e4 f4 64 0d 35 a0 66 0b 20 41 e2 af c4 |.{...d.5.f. A...| +00000030 e0 db f1 52 6a 6b f3 77 0d 83 f7 00 d0 05 3f 3e |...Rjk.w......?>| +00000040 d8 3f d2 66 fa 19 3d 36 bd ff ae 13 c0 2f 00 00 |.?.f..=6...../..| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 03 02 59 0b 00 02 55 00 02 52 00 02 4f 30 82 02 |..Y...U..R..O0..| 00000070 4b 30 82 01 b4 a0 03 02 01 02 02 09 00 e8 f0 9d |K0..............| @@ -54,21 +60,22 @@ 00000290 77 8d 0c 1c f1 0f a1 d8 40 83 61 c9 4c 72 2b 9d |w.......@.a.Lr+.| 000002a0 ae db 46 06 06 4d f4 c1 b3 3e c0 d1 bd 42 d4 db |..F..M...>...B..| 000002b0 fe 3d 13 60 84 5c 21 d3 3b e9 fa e7 16 03 03 00 |.=.`.\!.;.......| -000002c0 ac 0c 00 00 a8 03 00 1d 20 22 78 15 4f d2 33 df |........ "x.O.3.| -000002d0 3e 82 b7 10 ca 8b 5c d6 f2 84 8f e7 cb cf 3e 2f |>.....\.......>/| -000002e0 65 dd 5b 5c 0a 48 f4 f6 1e 04 01 00 80 40 08 09 |e.[\.H.......@..| -000002f0 e5 bc a2 e3 27 a9 7e 2d e2 1d 47 7c 8c 95 44 28 |....'.~-..G|..D(| -00000300 f8 3d 00 5d f7 38 26 31 8f f3 61 27 f6 c0 a0 12 |.=.].8&1..a'....| -00000310 ed 3b 59 18 ed aa 4c 4a 54 8a 23 0a 13 7a 7d 1c |.;Y...LJT.#..z}.| -00000320 26 5e 7a f1 55 d5 68 dc f9 97 ef 6d 98 0f 87 41 |&^z.U.h....m...A| -00000330 31 e5 a0 f1 84 19 3a 19 cf b3 f7 9d 34 13 05 ab |1.....:.....4...| -00000340 85 2e 6f 4e 8f fd c3 37 63 3e c9 3d 48 87 6a 9b |..oN...7c>.=H.j.| -00000350 c1 21 d1 4f 89 7d a1 dc 23 bb cf d8 b1 d9 91 e0 |.!.O.}..#.......| -00000360 f6 48 f0 20 64 8b f8 f1 86 5c b3 6c 70 16 03 03 |.H. d....\.lp...| -00000370 00 2a 0d 00 00 26 03 01 02 40 00 1e 06 01 06 02 |.*...&...@......| -00000380 06 03 05 01 05 02 05 03 04 01 04 02 04 03 03 01 |................| -00000390 03 02 03 03 02 01 02 02 02 03 00 00 16 03 03 00 |................| -000003a0 04 0e 00 00 00 |.....| +000002c0 ac 0c 00 00 a8 03 00 1d 20 39 84 75 e0 64 4e 6d |........ 9.u.dNm| +000002d0 37 4a cd ae 78 6f d3 b5 bd 3e fb dc 9b f8 51 39 |7J..xo...>....Q9| +000002e0 85 35 a2 11 4b 59 be 57 01 08 04 00 80 a1 dd a6 |.5..KY.W........| +000002f0 f4 e0 89 8a c1 ff e6 20 1e cf 73 41 94 e6 4a 4f |....... ..sA..JO| +00000300 64 49 43 0e 53 90 61 31 92 a5 af 13 2e 00 2b e2 |dIC.S.a1......+.| +00000310 61 6e 3f a1 9a e3 7d f6 79 0e cd f6 c1 84 e0 62 |an?...}.y......b| +00000320 15 69 5a 94 8f af c5 c9 db b8 f4 4b 40 4c ea f7 |.iZ........K@L..| +00000330 bb e9 cd f2 3a 00 c3 f1 c9 5e 43 67 36 c5 73 f1 |....:....^Cg6.s.| +00000340 88 c1 6d 14 2f 92 63 ae 30 9d 3c 59 33 aa 78 62 |..m./.c.0.>> Flow 3 (client to server) 00000000 16 03 03 02 0a 0b 00 02 06 00 02 03 00 02 00 30 |...............0| 00000010 82 01 fc 30 82 01 5e 02 09 00 9a 30 84 6c 26 35 |...0..^....0.l&5| @@ -106,27 +113,27 @@ 00000210 03 03 00 25 10 00 00 21 20 2f e5 7d a3 47 cd 62 |...%...! /.}.G.b| 00000220 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 cf |C.(.._.).0......| 00000230 c2 ed 90 99 5f 58 cb 3b 74 16 03 03 00 93 0f 00 |...._X.;t.......| -00000240 00 8f 06 03 00 8b 30 81 88 02 42 01 9e be 18 6a |......0...B....j| -00000250 b3 8d c4 2f b9 ed db b9 89 cf 2f e5 d6 13 64 68 |.../....../...dh| -00000260 72 e4 51 01 12 a9 83 08 d7 2e fa cc 64 09 80 79 |r.Q.........d..y| -00000270 ce 3d 51 a1 e1 f7 3c 5c 2c dd 97 a2 f9 61 c3 7a |.=Q...<\,....a.z| -00000280 bc 25 ad c1 04 a1 cf bf 06 f5 e2 b5 15 02 42 00 |.%............B.| -00000290 bf 72 20 6f 0e 49 f2 07 bd 07 ef f3 e8 9c 1a 61 |.r o.I.........a| -000002a0 b0 7a 6c b0 14 71 4a aa 76 05 9f d1 ef 5b 41 be |.zl..qJ.v....[A.| -000002b0 4c 20 7b 5c 31 86 da e3 3b 54 0f af 79 6b 54 84 |L {\1...;T..ykT.| -000002c0 72 0b 0a e4 ea 33 48 a2 1a e8 8d dd 16 45 80 d1 |r....3H......E..| -000002d0 88 14 03 03 00 01 01 16 03 03 00 28 00 00 00 00 |...........(....| -000002e0 00 00 00 00 4d 58 00 50 6d 12 ea c2 6c f8 1c 51 |....MX.Pm...l..Q| -000002f0 e8 91 8c 24 dd c2 28 af c7 c7 ed 28 29 34 62 2c |...$..(....()4b,| -00000300 c0 d3 06 7d |...}| +00000240 00 8f 04 03 00 8b 30 81 88 02 42 01 cd 89 13 12 |......0...B.....| +00000250 a4 7f e0 a5 f9 37 30 53 ed 49 39 ca 42 44 cf f0 |.....70S.I9.BD..| +00000260 b3 ab 3f 70 eb ca 82 4d 9e a7 d5 47 0c df c2 fb |..?p...M...G....| +00000270 f3 92 6b 0f 21 92 06 6d 48 e7 ba 36 22 56 d2 f3 |..k.!..mH..6"V..| +00000280 b7 28 00 ab 46 46 f5 32 b9 45 93 57 21 02 42 01 |.(..FF.2.E.W!.B.| +00000290 37 7c d6 f3 bd eb fa 1c 9b c8 83 0b 5c 73 66 42 |7|..........\sfB| +000002a0 0c cd 8d da 40 32 c6 35 26 46 be db 48 56 55 d2 |....@2.5&F..HVU.| +000002b0 e9 33 6e e0 da b8 45 f8 24 f2 59 6e 4f 4a 34 e2 |.3n...E.$.YnOJ4.| +000002c0 51 d7 0f 25 f0 ae 83 d5 fa cd 4f 4a e6 c5 82 3d |Q..%......OJ...=| +000002d0 a5 14 03 03 00 01 01 16 03 03 00 28 00 00 00 00 |...........(....| +000002e0 00 00 00 00 fb 21 d8 50 53 e6 13 13 bc d4 f4 d4 |.....!.PS.......| +000002f0 b5 f1 6c fe ed eb 15 ce 18 a1 3d cf 7f ae 40 d5 |..l.......=...@.| +00000300 0c 91 41 69 |..Ai| >>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 28 b3 71 11 c5 31 |..........(.q..1| -00000010 7b 22 87 23 7b 71 05 ca 95 fc d1 7d 0e fd 68 d3 |{".#{q.....}..h.| -00000020 7f 08 af 41 16 ff cf 87 a4 5a 6b fb b1 5e 89 e0 |...A.....Zk..^..| -00000030 8e 0c 88 |...| +00000000 14 03 03 00 01 01 16 03 03 00 28 36 f9 5d 31 f6 |..........(6.]1.| +00000010 a2 62 16 db 9b ea 79 28 52 1b 06 e1 59 39 f3 4a |.b....y(R...Y9.J| +00000020 67 77 6d 2b 98 80 9d e9 80 55 53 82 37 17 61 65 |gwm+.....US.7.ae| +00000030 f5 fa 06 |...| >>> Flow 5 (client to server) -00000000 17 03 03 00 1e 00 00 00 00 00 00 00 01 3b 83 10 |.............;..| -00000010 ee 6d c5 a9 6a 9e 61 7f df 00 c4 03 39 6a b8 4a |.m..j.a.....9j.J| -00000020 0f 0c e6 15 03 03 00 1a 00 00 00 00 00 00 00 02 |................| -00000030 35 b9 7d a7 29 d0 ba e1 5e 4e f1 67 4a 81 12 e7 |5.}.)...^N.gJ...| -00000040 62 72 |br| +00000000 17 03 03 00 1e 00 00 00 00 00 00 00 01 a0 3f 7e |..............?~| +00000010 ce c3 cf 73 0f 2f 9d ba 5d 2e 3b 84 8b ef cd c4 |...s./..].;.....| +00000020 2a 31 32 15 03 03 00 1a 00 00 00 00 00 00 00 02 |*12.............| +00000030 58 7e 4f 75 06 0d 16 f5 6d 06 0f af 5a 40 9b bd |X~Ou....m...Z@..| +00000040 79 f4 |y.| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-AES256-GCM-SHA384 b/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-AES256-GCM-SHA384 index 892db8accfc..e6791c0da47 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-AES256-GCM-SHA384 +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-AES256-GCM-SHA384 @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 03 00 59 02 00 00 55 03 03 76 09 a7 74 97 |....Y...U..v..t.| -00000010 df 92 1b 14 fb 0f 5c 82 a9 04 22 5f 32 1f 04 50 |......\..."_2..P| -00000020 52 8c ec 30 c1 5e 73 51 8a 0d 22 20 12 f5 11 b3 |R..0.^sQ.." ....| -00000030 3b 8e 49 9a 0b 79 3e 0a a8 7f a8 01 eb b0 ea 4e |;.I..y>........N| -00000040 d5 19 0d 4e c5 7d d7 a0 ff 6e 75 a1 c0 30 00 00 |...N.}...nu..0..| +00000000 16 03 03 00 59 02 00 00 55 03 03 10 af 03 5d d2 |....Y...U.....].| +00000010 4d c8 e6 2e 88 08 57 65 8c c6 fa af b5 e7 bd 49 |M.....We.......I| +00000020 4c d0 dc 04 e6 14 e0 83 40 79 dd 20 5a 11 db 9d |L.......@y. Z...| +00000030 c0 10 71 f5 27 89 5a 7e 17 80 9b 26 39 09 cc ad |..q.'.Z~...&9...| +00000040 be 1a 24 37 d7 08 a2 e1 fe 75 54 71 c0 30 00 00 |..$7.....uTq.0..| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 03 02 59 0b 00 02 55 00 02 52 00 02 4f 30 82 02 |..Y...U..R..O0..| 00000070 4b 30 82 01 b4 a0 03 02 01 02 02 09 00 e8 f0 9d |K0..............| @@ -54,21 +60,22 @@ 00000290 77 8d 0c 1c f1 0f a1 d8 40 83 61 c9 4c 72 2b 9d |w.......@.a.Lr+.| 000002a0 ae db 46 06 06 4d f4 c1 b3 3e c0 d1 bd 42 d4 db |..F..M...>...B..| 000002b0 fe 3d 13 60 84 5c 21 d3 3b e9 fa e7 16 03 03 00 |.=.`.\!.;.......| -000002c0 ac 0c 00 00 a8 03 00 1d 20 24 0d ab 23 1c 61 5d |........ $..#.a]| -000002d0 26 01 04 dd ea 32 2d e4 a1 95 28 fc a7 17 93 6f |&....2-...(....o| -000002e0 ce b8 ef 0a 74 cf 28 ca 33 04 01 00 80 1e e1 03 |....t.(.3.......| -000002f0 e6 a7 bd 38 7b 32 52 01 47 b3 fa 0a 8f 29 2c 98 |...8{2R.G....),.| -00000300 58 37 21 3d 9e 78 48 dc 74 a9 ec d2 9a cb 56 8e |X7!=.xH.t.....V.| -00000310 4a 90 d6 b6 87 82 03 b8 60 04 bf 73 b2 61 e6 ab |J.......`..s.a..| -00000320 7d cd eb ba cf e8 16 86 db 38 7e 96 6b 14 c4 4f |}........8~.k..O| -00000330 05 fb 2b b5 6e 50 9a f5 02 f3 a2 84 95 8d a6 91 |..+.nP..........| -00000340 d2 16 33 98 16 c0 61 55 fe a8 70 02 d1 db 86 d1 |..3...aU..p.....| -00000350 37 0c 02 36 cf b2 10 6d 63 94 f6 18 29 a7 6b 1b |7..6...mc...).k.| -00000360 8f 7c 51 8e 8f e4 ef a8 2b 99 0b ae 1b 16 03 03 |.|Q.....+.......| -00000370 00 2a 0d 00 00 26 03 01 02 40 00 1e 06 01 06 02 |.*...&...@......| -00000380 06 03 05 01 05 02 05 03 04 01 04 02 04 03 03 01 |................| -00000390 03 02 03 03 02 01 02 02 02 03 00 00 16 03 03 00 |................| -000003a0 04 0e 00 00 00 |.....| +000002c0 ac 0c 00 00 a8 03 00 1d 20 42 0e 6e 06 83 b5 4e |........ B.n...N| +000002d0 d9 f5 45 2b 82 1c 30 c7 65 5d 40 44 10 b8 63 aa |..E+..0.e]@D..c.| +000002e0 6f ef 92 13 4b 8d fd 1b 0e 08 04 00 80 63 8f 8a |o...K........c..| +000002f0 f3 6a 42 b9 e2 6d c3 06 c5 04 2d df 4b 06 0f b7 |.jB..m....-.K...| +00000300 e5 36 d2 5f be aa 36 83 82 eb e8 06 e9 a5 b8 47 |.6._..6........G| +00000310 db 43 fb 7d ab 0b 3a db 13 df ab 62 16 7d 80 57 |.C.}..:....b.}.W| +00000320 4b 07 79 f6 d9 9c ad d4 1b b5 cd cb 92 44 bc 74 |K.y..........D.t| +00000330 d0 f3 67 0c e6 1a 5a 18 53 bc bc 65 19 7a 13 f3 |..g...Z.S..e.z..| +00000340 78 36 e7 14 7d 36 6d 85 ea d7 96 18 e2 bc 1d af |x6..}6m.........| +00000350 58 50 f3 f7 a3 27 49 a4 89 10 e2 cc 2d db c5 4a |XP...'I.....-..J| +00000360 4c 24 3e 9b 70 17 ae 2f f9 d0 96 8f b0 16 03 03 |L$>.p../........| +00000370 00 3a 0d 00 00 36 03 01 02 40 00 2e 04 03 05 03 |.:...6...@......| +00000380 06 03 08 07 08 08 08 09 08 0a 08 0b 08 04 08 05 |................| +00000390 08 06 04 01 05 01 06 01 03 03 02 03 03 01 02 01 |................| +000003a0 03 02 02 02 04 02 05 02 06 02 00 00 16 03 03 00 |................| +000003b0 04 0e 00 00 00 |.....| >>> Flow 3 (client to server) 00000000 16 03 03 01 fd 0b 00 01 f9 00 01 f6 00 01 f3 30 |...............0| 00000010 82 01 ef 30 82 01 58 a0 03 02 01 02 02 10 5c 19 |...0..X.......\.| @@ -105,26 +112,26 @@ 00000200 e5 35 16 03 03 00 25 10 00 00 21 20 2f e5 7d a3 |.5....%...! /.}.| 00000210 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 |G.bC.(.._.).0...| 00000220 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 16 03 03 00 |......._X.;t....| -00000230 88 0f 00 00 84 06 01 00 80 9f 32 29 c2 47 12 3b |..........2).G.;| -00000240 c1 2a f5 02 2b be 51 88 68 ed d6 f6 06 72 b8 02 |.*..+.Q.h....r..| -00000250 32 5f f6 c6 a0 72 d1 df d4 01 8c f7 37 ca 3a 8f |2_...r......7.:.| -00000260 cb ee d8 1d 7b 8a 80 0b 21 30 14 55 32 19 ba 8e |....{...!0.U2...| -00000270 a0 6a 0a 8b 53 01 71 09 d2 1c 19 b2 50 4f a4 35 |.j..S.q.....PO.5| -00000280 4d 22 71 74 62 fb 24 8d d1 b2 0e d7 60 ae 9e a9 |M"qtb.$.....`...| -00000290 07 60 84 99 da c9 a4 04 09 35 da c3 98 4e ab fe |.`.......5...N..| -000002a0 41 68 f2 0c 8a 94 b3 26 af 2c 19 52 48 08 8d 00 |Ah.....&.,.RH...| -000002b0 05 69 d8 9f 35 b5 9e 00 2e 14 03 03 00 01 01 16 |.i..5...........| -000002c0 03 03 00 28 00 00 00 00 00 00 00 00 bf fd 71 87 |...(..........q.| -000002d0 c2 8c 1e 69 59 95 8a 75 da 56 7e db e6 5c fd 6c |...iY..u.V~..\.l| -000002e0 74 97 46 66 37 23 3f 39 91 23 c0 d1 |t.Ff7#?9.#..| +00000230 88 0f 00 00 84 08 04 00 80 0d 7c 62 81 7d fc c9 |..........|b.}..| +00000240 d4 4c 3e dd 4c b0 fe ce 43 90 27 39 2c be 01 24 |.L>.L...C.'9,..$| +00000250 bc 55 f5 87 d7 31 00 47 6c 49 ce 82 db 0e 3d af |.U...1.GlI....=.| +00000260 a5 f3 4a 28 c9 f7 0b d3 68 e2 b8 de 2d b3 d8 5d |..J(....h...-..]| +00000270 c6 6d da 2f 74 c4 0a f4 93 ed 58 10 00 94 55 d6 |.m./t.....X...U.| +00000280 c8 62 d0 35 20 cc 90 dc 70 bf 1d 6f c9 76 10 de |.b.5 ...p..o.v..| +00000290 c2 50 ba e9 b4 bd 80 d7 01 b2 aa 1d 27 03 0f ad |.P..........'...| +000002a0 39 46 ec 30 b0 fb 68 0f 1f b3 4c 0c 26 70 4c 33 |9F.0..h...L.&pL3| +000002b0 bf 18 79 81 11 c0 7f b9 ae 14 03 03 00 01 01 16 |..y.............| +000002c0 03 03 00 28 00 00 00 00 00 00 00 00 a2 ee 76 00 |...(..........v.| +000002d0 77 2b 70 9d f7 0a 11 b4 25 00 07 92 d4 4c 9c 68 |w+p.....%....L.h| +000002e0 64 54 11 6d 39 46 6c ea 20 0c 15 ed |dT.m9Fl. ...| >>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 28 16 d9 d6 d4 2f |..........(..../| -00000010 8c 6f 50 8d e6 6f ea eb 6a 55 6a 12 10 d2 dc aa |.oP..o..jUj.....| -00000020 83 7a 38 6a bc 10 aa da 62 ab 94 7b ac f2 03 1a |.z8j....b..{....| -00000030 2f 95 6d |/.m| +00000000 14 03 03 00 01 01 16 03 03 00 28 f5 f7 fe 25 12 |..........(...%.| +00000010 d8 e2 d9 ee b3 c8 02 a9 6e d9 80 ee 7b 7e 95 1f |........n...{~..| +00000020 8e 97 a6 5f e8 4c ee 67 e9 a1 43 ab 0e 17 ce 92 |..._.L.g..C.....| +00000030 7c 03 0f ||..| >>> Flow 5 (client to server) -00000000 17 03 03 00 1e 00 00 00 00 00 00 00 01 36 84 d7 |.............6..| -00000010 5c ef b0 3e 11 86 a9 a1 2c 0c 05 2f fa 86 3b dc |\..>....,../..;.| -00000020 fb 8c 94 15 03 03 00 1a 00 00 00 00 00 00 00 02 |................| -00000030 86 fb 4d dd 33 11 53 9c c2 9f e6 48 79 19 69 f3 |..M.3.S....Hy.i.| -00000040 db 3b |.;| +00000000 17 03 03 00 1e 00 00 00 00 00 00 00 01 4c 67 fb |.............Lg.| +00000010 76 75 0d a4 56 d5 9c 1a 6d 7d 94 06 df 6d 05 98 |vu..V...m}...m..| +00000020 39 be 1e 15 03 03 00 1a 00 00 00 00 00 00 00 02 |9...............| +00000030 31 e3 f4 a1 b7 0e cc 48 17 a6 69 4d ba 43 a0 2d |1......H..iM.C.-| +00000040 12 a2 |..| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-ECDSA b/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-ECDSA index 9f717b1548b..06a9be85a02 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-ECDSA +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-ECDSA @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 03 00 59 02 00 00 55 03 03 63 c7 66 ed 90 |....Y...U..c.f..| -00000010 6f f2 a3 65 32 55 e2 00 ce 15 46 33 22 ad 1a 6f |o..e2U....F3"..o| -00000020 ac 21 89 0e b0 66 a8 04 98 f2 99 20 02 7c 4f 57 |.!...f..... .|OW| -00000030 f4 69 17 6f 23 f5 a6 db 8f a6 ef eb 83 70 53 5d |.i.o#........pS]| -00000040 0e 85 b9 d7 53 01 10 9b 65 97 c0 c1 c0 09 00 00 |....S...e.......| +00000000 16 03 03 00 59 02 00 00 55 03 03 69 98 98 c5 21 |....Y...U..i...!| +00000010 2e b7 a6 8e ba d1 11 b4 0a 84 ad 33 b9 8c 81 d7 |...........3....| +00000020 26 ba 77 32 24 e5 c2 95 5f d2 b8 20 23 79 50 e0 |&.w2$..._.. #yP.| +00000030 59 94 e1 05 47 58 ce a0 52 32 3f 96 1a e5 d8 15 |Y...GX..R2?.....| +00000040 ec ae c9 51 a1 1c 19 e0 ac 40 28 9d c0 09 00 00 |...Q.....@(.....| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 03 02 0e 0b 00 02 0a 00 02 07 00 02 04 30 82 02 |.............0..| 00000070 00 30 82 01 62 02 09 00 b8 bf 2d 47 a0 d2 eb f4 |.0..b.....-G....| @@ -49,22 +55,23 @@ 00000240 13 83 0d 94 06 bb d4 37 7a f6 ec 7a c9 86 2e dd |.......7z..z....| 00000250 d7 11 69 7f 85 7c 56 de fb 31 78 2b e4 c7 78 0d |..i..|V..1x+..x.| 00000260 ae cb be 9e 4e 36 24 31 7b 6a 0f 39 95 12 07 8f |....N6$1{j.9....| -00000270 2a 16 03 03 00 b6 0c 00 00 b2 03 00 1d 20 e2 11 |*............ ..| -00000280 47 88 ee 44 bb 63 68 cc aa 2e ee 22 66 93 25 2b |G..D.ch...."f.%+| -00000290 19 c4 a1 0c 2f c0 a4 9e bb f3 f1 4d de 18 04 03 |..../......M....| -000002a0 00 8a 30 81 87 02 41 7b fc 56 81 1e f9 fe 44 a7 |..0...A{.V....D.| -000002b0 d3 b9 4e 4e 0b 5e d9 11 c1 11 c1 b5 94 60 1d e4 |..NN.^.......`..| -000002c0 82 4b 6d 14 45 02 e3 06 d8 32 b4 c1 da 64 e4 92 |.Km.E....2...d..| -000002d0 b7 52 a4 39 19 4e 21 53 03 4f 64 40 23 7a 75 db |.R.9.N!S.Od@#zu.| -000002e0 e1 67 a8 29 d4 90 56 af 02 42 01 2d c0 14 ed 33 |.g.)..V..B.-...3| -000002f0 7e f9 7d d2 6b 4c ba 06 7d 41 e1 7c d1 82 51 03 |~.}.kL..}A.|..Q.| -00000300 ea b1 66 e5 c5 27 34 b1 b4 36 8e 5d d0 69 f9 10 |..f..'4..6.].i..| -00000310 cc 60 f2 f1 30 2a ff a7 09 4f 87 93 28 26 9d 8d |.`..0*...O..(&..| -00000320 75 a0 11 17 dd 6c e2 33 87 21 6d 0f 16 03 03 00 |u....l.3.!m.....| -00000330 2a 0d 00 00 26 03 01 02 40 00 1e 06 01 06 02 06 |*...&...@.......| -00000340 03 05 01 05 02 05 03 04 01 04 02 04 03 03 01 03 |................| -00000350 02 03 03 02 01 02 02 02 03 00 00 16 03 03 00 04 |................| -00000360 0e 00 00 00 |....| +00000270 2a 16 03 03 00 b7 0c 00 00 b3 03 00 1d 20 b8 1d |*............ ..| +00000280 dd 31 88 3e 51 9e d8 b3 7f f0 93 7c 77 70 79 2c |.1.>Q......|wpy,| +00000290 cb 21 d3 b8 8d 3d 65 33 2b a0 0d bb 5f 6a 04 03 |.!...=e3+..._j..| +000002a0 00 8b 30 81 88 02 42 01 50 71 c1 68 9b a3 b3 7f |..0...B.Pq.h....| +000002b0 ab 3f b0 32 d8 57 36 db 3f e5 5b 26 36 51 ed 89 |.?.2.W6.?.[&6Q..| +000002c0 33 a5 e3 e3 49 2b ac d7 b2 9c 3f 6b 4d 8e 21 3d |3...I+....?kM.!=| +000002d0 f6 bc 22 af 0a 48 f0 14 ff ed 14 95 16 e3 45 b3 |.."..H........E.| +000002e0 b3 e7 c2 09 a5 e9 12 a1 4b 02 42 01 35 34 64 1c |........K.B.54d.| +000002f0 d3 28 48 66 82 f3 93 8e 36 0b f7 ac ad f7 f5 4f |.(Hf....6......O| +00000300 e5 fc b7 a8 a3 f0 fb 28 70 9e 36 bc c3 82 1b 22 |.......(p.6...."| +00000310 ef 95 ab 70 28 07 0d aa c0 42 d6 c6 0e ed 37 d7 |...p(....B....7.| +00000320 a6 a0 75 e6 db 03 b7 3c 61 26 8a 47 e1 16 03 03 |..u....>> Flow 3 (client to server) 00000000 16 03 03 01 fd 0b 00 01 f9 00 01 f6 00 01 f3 30 |...............0| 00000010 82 01 ef 30 82 01 58 a0 03 02 01 02 02 10 5c 19 |...0..X.......\.| @@ -101,31 +108,31 @@ 00000200 e5 35 16 03 03 00 25 10 00 00 21 20 2f e5 7d a3 |.5....%...! /.}.| 00000210 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 |G.bC.(.._.).0...| 00000220 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 16 03 03 00 |......._X.;t....| -00000230 88 0f 00 00 84 06 01 00 80 0a d6 0d 0a 0f 6b 18 |..............k.| -00000240 f4 e3 3a b7 84 cd 56 53 ae 81 3f e8 50 a4 6a ab |..:...VS..?.P.j.| -00000250 4e f7 f5 8f e6 c5 6f e1 88 47 a9 ba 35 07 a3 5d |N.....o..G..5..]| -00000260 d0 e3 f3 b9 2a 33 33 1c af d5 91 4b 92 3d da eb |....*33....K.=..| -00000270 96 3f 4c 0e ac 55 3e 32 8c 56 f9 3e 64 d1 51 03 |.?L..U>2.V.>d.Q.| -00000280 a1 46 2a 47 0b d6 fd 0c 94 15 de 66 22 24 11 06 |.F*G.......f"$..| -00000290 ed 17 ab f0 c5 5b 39 7d f2 ce 02 3f 3a 16 b4 14 |.....[9}...?:...| -000002a0 81 f7 4f 38 a9 46 ee 09 bf ed 14 b5 d8 3c d6 32 |..O8.F.......<.2| -000002b0 26 48 6d 9d 49 70 12 a0 f3 14 03 03 00 01 01 16 |&Hm.Ip..........| +00000230 88 0f 00 00 84 08 04 00 80 0a f0 58 cc 8a d0 1c |...........X....| +00000240 77 22 05 20 40 d3 74 f8 af d9 17 ed 01 61 5e c2 |w". @.t......a^.| +00000250 9d 3a 53 ce 55 c6 11 9c 63 01 14 97 38 5f d8 17 |.:S.U...c...8_..| +00000260 68 6f ee 09 73 42 23 dc 40 f8 4a 41 4d ca c8 98 |ho..sB#.@.JAM...| +00000270 65 09 22 ca cd 27 00 8b 27 36 8a f9 1c 07 7f 3b |e."..'..'6.....;| +00000280 98 46 2e fc 50 8e ca 4c 0e 2a f0 c4 e5 87 e2 24 |.F..P..L.*.....$| +00000290 46 8b 3b 03 d3 03 78 f1 76 f5 14 12 c1 63 f7 21 |F.;...x.v....c.!| +000002a0 e7 27 17 ce 2d a6 eb 50 ef e4 aa 32 14 89 f4 02 |.'..-..P...2....| +000002b0 02 b7 9b 47 27 ca 56 5b 32 14 03 03 00 01 01 16 |...G'.V[2.......| 000002c0 03 03 00 40 00 00 00 00 00 00 00 00 00 00 00 00 |...@............| -000002d0 00 00 00 00 d5 b2 cc f7 6b 74 c0 77 c3 05 7f 09 |........kt.w....| -000002e0 28 54 fe 44 ef b1 4c 40 ff 47 00 59 ae 22 96 53 |(T.D..L@.G.Y.".S| -000002f0 6d db b1 5b fd af 24 10 ca 0d f6 8b 24 7a c0 38 |m..[..$.....$z.8| -00000300 d7 92 7c c2 |..|.| +000002d0 00 00 00 00 5e ab 60 05 38 88 e6 d3 ba fd 13 2a |....^.`.8......*| +000002e0 8a 17 c8 6e 54 d4 4e fd c4 12 87 c4 20 ef de 62 |...nT.N..... ..b| +000002f0 fd d3 50 6f 5f 6b 9d b2 00 aa 5a ab 2c d1 3d 39 |..Po_k....Z.,.=9| +00000300 46 20 ab d7 |F ..| >>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 40 c3 48 00 56 17 |..........@.H.V.| -00000010 16 d1 dd 17 a2 c7 48 c9 d6 3e 6a 1e 4c cc 0a a2 |......H..>j.L...| -00000020 40 3e 31 2e 50 69 d6 06 15 48 87 45 2f f0 a1 04 |@>1.Pi...H.E/...| -00000030 38 b2 81 15 b9 0d ac f4 9e 51 9f b0 9c 79 20 57 |8........Q...y W| -00000040 ab 8a 56 08 97 2b d0 62 12 7d b3 |..V..+.b.}.| +00000000 14 03 03 00 01 01 16 03 03 00 40 d7 80 4d 81 26 |..........@..M.&| +00000010 8f 46 5b b4 63 56 cd bd a6 ca 31 ba 8e b8 5b a2 |.F[.cV....1...[.| +00000020 47 a3 ef 5f ca a2 6a af d2 2c f9 bb c9 1b 20 fc |G.._..j..,.... .| +00000030 a1 78 ca 7e 79 09 66 08 2c cb 0c a5 a3 35 01 ed |.x.~y.f.,....5..| +00000040 90 90 3d 32 f3 7b 30 25 ca 5c 66 |..=2.{0%.\f| >>> Flow 5 (client to server) 00000000 17 03 03 00 30 00 00 00 00 00 00 00 00 00 00 00 |....0...........| -00000010 00 00 00 00 00 27 df 11 a5 71 1a f9 c9 fb d3 a8 |.....'...q......| -00000020 cd f1 5f 88 e4 db ca 2f ec c7 26 e2 c9 69 11 c5 |.._..../..&..i..| -00000030 a4 ba 6f 58 69 15 03 03 00 30 00 00 00 00 00 00 |..oXi....0......| -00000040 00 00 00 00 00 00 00 00 00 00 e8 9d f0 1d f8 4b |...............K| -00000050 fc d1 7e ac 10 b2 5d af ea 87 b9 d8 4b 0d 24 d6 |..~...].....K.$.| -00000060 ff 44 9f 93 bf 51 9d 21 9d 1d |.D...Q.!..| +00000010 00 00 00 00 00 58 dc 0e 2b 4a 58 05 aa 22 cb 21 |.....X..+JX..".!| +00000020 1c 6b 93 40 ab 6b 99 aa ae c0 e0 f8 31 22 a3 1b |.k.@.k......1"..| +00000030 4a 98 bc 70 08 15 03 03 00 30 00 00 00 00 00 00 |J..p.....0......| +00000040 00 00 00 00 00 00 00 00 00 00 8a 7b b8 60 83 23 |...........{.`.#| +00000050 53 04 cf 14 b7 cf a9 d8 70 51 fe 92 f3 9c 25 6a |S.......pQ....%j| +00000060 bf 43 e0 bd ca 33 33 6c 30 dc |.C...33l0.| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-RSA b/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-RSA index 656281cfa65..a0aff2560d7 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-RSA +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-RSA @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 03 00 59 02 00 00 55 03 03 cd 8e 54 03 73 |....Y...U....T.s| -00000010 80 fb 7a 0a 38 a0 cd d3 5c 1a 84 a2 66 43 47 68 |..z.8...\...fCGh| -00000020 7b d9 c0 5b c3 14 2f 51 45 12 62 20 9e 32 b0 17 |{..[../QE.b .2..| -00000030 85 6e 8a de ae 7a f7 09 76 79 5f 74 eb b1 3c e9 |.n...z..vy_t..<.| -00000040 4f 36 09 ef b2 f9 8f 25 c1 db 37 46 c0 2f 00 00 |O6.....%..7F./..| +00000000 16 03 03 00 59 02 00 00 55 03 03 82 19 ee 7f ef |....Y...U.......| +00000010 86 a3 70 b1 75 84 05 bc 43 ed 52 df bf 42 c4 e3 |..p.u...C.R..B..| +00000020 87 50 59 5d 88 4f df b6 85 0c 5d 20 c3 1b c3 9d |.PY].O....] ....| +00000030 a0 2c 6b 16 1c 35 7a 3b 98 eb ba 8a 55 7a 10 af |.,k..5z;....Uz..| +00000040 c4 7f cd 74 e5 f2 e4 6b c1 58 5f 18 c0 2f 00 00 |...t...k.X_../..| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 03 02 59 0b 00 02 55 00 02 52 00 02 4f 30 82 02 |..Y...U..R..O0..| 00000070 4b 30 82 01 b4 a0 03 02 01 02 02 09 00 e8 f0 9d |K0..............| @@ -54,21 +60,22 @@ 00000290 77 8d 0c 1c f1 0f a1 d8 40 83 61 c9 4c 72 2b 9d |w.......@.a.Lr+.| 000002a0 ae db 46 06 06 4d f4 c1 b3 3e c0 d1 bd 42 d4 db |..F..M...>...B..| 000002b0 fe 3d 13 60 84 5c 21 d3 3b e9 fa e7 16 03 03 00 |.=.`.\!.;.......| -000002c0 ac 0c 00 00 a8 03 00 1d 20 57 b6 34 6b 1c 97 1f |........ W.4k...| -000002d0 51 f1 d5 38 68 a2 2f 69 fb 9e 94 cf 7e c3 25 97 |Q..8h./i....~.%.| -000002e0 82 e9 32 c0 0e 99 0c 7c 50 04 01 00 80 2d 08 85 |..2....|P....-..| -000002f0 c5 bc d6 3b 94 c5 7e 26 80 bc 0d 63 50 84 d0 77 |...;..~&...cP..w| -00000300 f8 4b cd 2c d4 cb e0 f2 7c 63 dc 9e 42 4e 3f 3c |.K.,....|c..BN?<| -00000310 a3 b7 c7 41 e6 e9 2c da ff 06 6d ec b5 f3 57 22 |...A..,...m...W"| -00000320 3a 6b cc 6b 00 d0 53 6e b1 89 7c 09 cc db 8e f1 |:k.k..Sn..|.....| -00000330 00 32 d1 68 2f ae 7a 83 00 71 a8 81 e6 66 c2 e7 |.2.h/.z..q...f..| -00000340 13 94 bf 9b 30 84 23 3d 95 03 11 4d 3a e7 4c 0a |....0.#=...M:.L.| -00000350 43 c7 6d 31 c1 92 b1 ab 7d 11 a1 2f 4a 2d bd fe |C.m1....}../J-..| -00000360 f5 d4 b1 ab ef 2d e3 79 ee 2f 6b 44 29 16 03 03 |.....-.y./kD)...| -00000370 00 2a 0d 00 00 26 03 01 02 40 00 1e 06 01 06 02 |.*...&...@......| -00000380 06 03 05 01 05 02 05 03 04 01 04 02 04 03 03 01 |................| -00000390 03 02 03 03 02 01 02 02 02 03 00 00 16 03 03 00 |................| -000003a0 04 0e 00 00 00 |.....| +000002c0 ac 0c 00 00 a8 03 00 1d 20 5f 4e f4 61 c0 7a 45 |........ _N.a.zE| +000002d0 82 9e 8e d4 dc cc cf 75 7e 22 47 c4 61 17 fc ae |.......u~"G.a...| +000002e0 b0 0b 10 eb 4b b5 74 38 25 08 04 00 80 d1 db f1 |....K.t8%.......| +000002f0 bf 1a 22 33 54 0f 85 11 3d 07 05 63 c7 1c 71 90 |.."3T...=..c..q.| +00000300 e5 30 8d e6 3b 48 b3 42 e4 2e 72 9d 3e 6b 10 09 |.0..;H.B..r.>k..| +00000310 d6 32 ae 37 d4 37 5e 46 52 52 40 e5 d2 03 a9 db |.2.7.7^FRR@.....| +00000320 89 06 11 db be 67 73 3c 80 51 ce 09 df b0 ea 2a |.....gs<.Q.....*| +00000330 e3 aa 3e c0 4a c4 7d 88 ec 45 7d e8 a8 1e 46 28 |..>.J.}..E}...F(| +00000340 26 9e 38 d2 2a 97 dc a2 90 1a 7c 98 01 d9 f6 22 |&.8.*.....|...."| +00000350 9e 46 4a a2 2f ae 6e a4 3d 00 82 46 8e 8e 04 21 |.FJ./.n.=..F...!| +00000360 e7 39 23 de f6 51 6c 59 5c 63 40 c5 57 16 03 03 |.9#..QlY\c@.W...| +00000370 00 3a 0d 00 00 36 03 01 02 40 00 2e 04 03 05 03 |.:...6...@......| +00000380 06 03 08 07 08 08 08 09 08 0a 08 0b 08 04 08 05 |................| +00000390 08 06 04 01 05 01 06 01 03 03 02 03 03 01 02 01 |................| +000003a0 03 02 02 02 04 02 05 02 06 02 00 00 16 03 03 00 |................| +000003b0 04 0e 00 00 00 |.....| >>> Flow 3 (client to server) 00000000 16 03 03 01 fd 0b 00 01 f9 00 01 f6 00 01 f3 30 |...............0| 00000010 82 01 ef 30 82 01 58 a0 03 02 01 02 02 10 5c 19 |...0..X.......\.| @@ -105,26 +112,26 @@ 00000200 e5 35 16 03 03 00 25 10 00 00 21 20 2f e5 7d a3 |.5....%...! /.}.| 00000210 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 |G.bC.(.._.).0...| 00000220 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 16 03 03 00 |......._X.;t....| -00000230 88 0f 00 00 84 06 01 00 80 72 5e f2 3f d2 7d 33 |.........r^.?.}3| -00000240 ec 01 70 e5 91 5b 71 ac 48 88 99 5a af ad 40 82 |..p..[q.H..Z..@.| -00000250 a7 de 2f 25 16 67 e1 e3 7d e6 d5 0f 79 63 63 56 |../%.g..}...yccV| -00000260 1b 45 da 38 f7 99 4d a2 8e 6f 70 02 92 21 da 69 |.E.8..M..op..!.i| -00000270 ba 2d 95 ea e5 5a f1 be 23 bb d2 8c 8b 36 b8 bf |.-...Z..#....6..| -00000280 c3 b5 c8 48 3c 27 26 c8 52 9c a4 53 d0 4e a6 7e |...H<'&.R..S.N.~| -00000290 cf 95 01 20 62 e1 47 59 82 b0 f1 64 e7 8e f4 f4 |... b.GY...d....| -000002a0 c7 50 67 83 ec 56 10 9d 0b 54 60 5a 1a 0f 0d 31 |.Pg..V...T`Z...1| -000002b0 31 c6 2d 12 e6 e4 22 77 6a 14 03 03 00 01 01 16 |1.-..."wj.......| -000002c0 03 03 00 28 00 00 00 00 00 00 00 00 91 d6 08 d4 |...(............| -000002d0 74 3f 02 78 ed c3 9d 0b a7 f0 10 c7 e8 4a a3 a7 |t?.x.........J..| -000002e0 d7 b7 c1 ca d4 fc e9 dc b5 ca 35 39 |..........59| +00000230 88 0f 00 00 84 08 04 00 80 41 a2 d2 32 db ce 5b |.........A..2..[| +00000240 04 45 ad 1c 31 7d f0 bc bb c0 53 65 38 b6 75 10 |.E..1}....Se8.u.| +00000250 de 25 38 c2 3b 54 5b 1e 3d bb d2 6a 70 77 16 62 |.%8.;T[.=..jpw.b| +00000260 c2 e8 d0 17 bd 01 89 89 26 28 75 69 ba 5e a1 4a |........&(ui.^.J| +00000270 6d 7e e6 be 6c 64 7e 8b 0c 45 3b 4b ef 1d 75 69 |m~..ld~..E;K..ui| +00000280 1f 51 4b 02 8e a0 19 de 47 41 44 14 4f e7 1e 23 |.QK.....GAD.O..#| +00000290 b0 c0 41 3f 6a 64 0e 30 80 01 ea d8 a9 75 6d 97 |..A?jd.0.....um.| +000002a0 28 4c ae df b1 6e 53 3b c3 aa 48 f1 5a e8 1c 8f |(L...nS;..H.Z...| +000002b0 ed 8c 59 5d e1 0e 57 b1 7d 14 03 03 00 01 01 16 |..Y]..W.}.......| +000002c0 03 03 00 28 00 00 00 00 00 00 00 00 ee 41 37 7b |...(.........A7{| +000002d0 ea 1e c3 d1 a7 7d 76 5c f8 b6 70 57 3c 02 71 49 |.....}v\..pW<.qI| +000002e0 c5 14 35 bb c3 43 63 61 6c 46 6c 11 |..5..CcalFl.| >>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 28 d8 3b 3c 00 02 |..........(.;<..| -00000010 7d c2 88 cf 6e 9b b3 99 cb b6 60 74 da 07 cb 6d |}...n.....`t...m| -00000020 95 ce dd 08 d4 a3 5f 0d 79 89 40 8f 71 03 76 0a |......_.y.@.q.v.| -00000030 c3 c0 d3 |...| +00000000 14 03 03 00 01 01 16 03 03 00 28 87 e9 a4 2c 0f |..........(...,.| +00000010 b5 52 a7 1b d0 99 86 27 d0 20 3e b5 44 77 0b 8f |.R.....'. >.Dw..| +00000020 d5 4e db dc 52 ab 01 c0 1c fd 85 2c 41 3b d0 14 |.N..R......,A;..| +00000030 11 26 29 |.&)| >>> Flow 5 (client to server) -00000000 17 03 03 00 1e 00 00 00 00 00 00 00 01 3e 3d cd |.............>=.| -00000010 9b 8c 53 b7 86 e1 60 bc 3c 3a 7b b1 cf a5 d1 c8 |..S...`.<:{.....| -00000020 1b d1 92 15 03 03 00 1a 00 00 00 00 00 00 00 02 |................| -00000030 83 58 15 c4 87 a3 bf 7b cf e6 e0 b4 10 37 ad 3b |.X.....{.....7.;| -00000040 d9 9a |..| +00000000 17 03 03 00 1e 00 00 00 00 00 00 00 01 e7 09 a0 |................| +00000010 90 12 35 3f 8f 87 41 fc aa 13 24 50 9f 69 a5 c7 |..5?..A...$P.i..| +00000020 37 38 02 15 03 03 00 1a 00 00 00 00 00 00 00 02 |78..............| +00000030 08 53 f5 80 5c eb b2 3b 9d be a3 49 46 24 da 5a |.S..\..;...IF$.Z| +00000040 7d 84 |}.| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-RSAPKCS1v15 b/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-RSAPKCS1v15 new file mode 100644 index 00000000000..48c2868aa66 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-RSAPKCS1v15 @@ -0,0 +1,134 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| +>>> Flow 2 (server to client) +00000000 16 03 03 00 59 02 00 00 55 03 03 27 d5 26 b1 eb |....Y...U..'.&..| +00000010 43 b9 e2 34 e7 3a e2 5e 73 ee b6 d7 4b 0c 88 49 |C..4.:.^s...K..I| +00000020 04 a8 0e fa f7 a1 79 39 e3 a6 29 20 75 68 40 36 |......y9..) uh@6| +00000030 ee c2 11 37 2f ae 43 85 f1 d0 eb ee 3d 69 99 e2 |...7/.C.....=i..| +00000040 3f f1 91 03 5d 00 af c5 f8 0d 4d dc c0 2f 00 00 |?...].....M../..| +00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| +00000060 03 02 59 0b 00 02 55 00 02 52 00 02 4f 30 82 02 |..Y...U..R..O0..| +00000070 4b 30 82 01 b4 a0 03 02 01 02 02 09 00 e8 f0 9d |K0..............| +00000080 3f e2 5b ea a6 30 0d 06 09 2a 86 48 86 f7 0d 01 |?.[..0...*.H....| +00000090 01 0b 05 00 30 1f 31 0b 30 09 06 03 55 04 0a 13 |....0.1.0...U...| +000000a0 02 47 6f 31 10 30 0e 06 03 55 04 03 13 07 47 6f |.Go1.0...U....Go| +000000b0 20 52 6f 6f 74 30 1e 17 0d 31 36 30 31 30 31 30 | Root0...1601010| +000000c0 30 30 30 30 30 5a 17 0d 32 35 30 31 30 31 30 30 |00000Z..25010100| +000000d0 30 30 30 30 5a 30 1a 31 0b 30 09 06 03 55 04 0a |0000Z0.1.0...U..| +000000e0 13 02 47 6f 31 0b 30 09 06 03 55 04 03 13 02 47 |..Go1.0...U....G| +000000f0 6f 30 81 9f 30 0d 06 09 2a 86 48 86 f7 0d 01 01 |o0..0...*.H.....| +00000100 01 05 00 03 81 8d 00 30 81 89 02 81 81 00 db 46 |.......0.......F| +00000110 7d 93 2e 12 27 06 48 bc 06 28 21 ab 7e c4 b6 a2 |}...'.H..(!.~...| +00000120 5d fe 1e 52 45 88 7a 36 47 a5 08 0d 92 42 5b c2 |]..RE.z6G....B[.| +00000130 81 c0 be 97 79 98 40 fb 4f 6d 14 fd 2b 13 8b c2 |....y.@.Om..+...| +00000140 a5 2e 67 d8 d4 09 9e d6 22 38 b7 4a 0b 74 73 2b |..g....."8.J.ts+| +00000150 c2 34 f1 d1 93 e5 96 d9 74 7b f3 58 9f 6c 61 3c |.4......t{.X.la<| +00000160 c0 b0 41 d4 d9 2b 2b 24 23 77 5b 1c 3b bd 75 5d |..A..++$#w[.;.u]| +00000170 ce 20 54 cf a1 63 87 1d 1e 24 c4 f3 1d 1a 50 8b |. T..c...$....P.| +00000180 aa b6 14 43 ed 97 a7 75 62 f4 14 c8 52 d7 02 03 |...C...ub...R...| +00000190 01 00 01 a3 81 93 30 81 90 30 0e 06 03 55 1d 0f |......0..0...U..| +000001a0 01 01 ff 04 04 03 02 05 a0 30 1d 06 03 55 1d 25 |.........0...U.%| +000001b0 04 16 30 14 06 08 2b 06 01 05 05 07 03 01 06 08 |..0...+.........| +000001c0 2b 06 01 05 05 07 03 02 30 0c 06 03 55 1d 13 01 |+.......0...U...| +000001d0 01 ff 04 02 30 00 30 19 06 03 55 1d 0e 04 12 04 |....0.0...U.....| +000001e0 10 9f 91 16 1f 43 43 3e 49 a6 de 6d b6 80 d7 9f |.....CC>I..m....| +000001f0 60 30 1b 06 03 55 1d 23 04 14 30 12 80 10 48 13 |`0...U.#..0...H.| +00000200 49 4d 13 7e 16 31 bb a3 01 d5 ac ab 6e 7b 30 19 |IM.~.1......n{0.| +00000210 06 03 55 1d 11 04 12 30 10 82 0e 65 78 61 6d 70 |..U....0...examp| +00000220 6c 65 2e 67 6f 6c 61 6e 67 30 0d 06 09 2a 86 48 |le.golang0...*.H| +00000230 86 f7 0d 01 01 0b 05 00 03 81 81 00 9d 30 cc 40 |.............0.@| +00000240 2b 5b 50 a0 61 cb ba e5 53 58 e1 ed 83 28 a9 58 |+[P.a...SX...(.X| +00000250 1a a9 38 a4 95 a1 ac 31 5a 1a 84 66 3d 43 d3 2d |..8....1Z..f=C.-| +00000260 d9 0b f2 97 df d3 20 64 38 92 24 3a 00 bc cf 9c |...... d8.$:....| +00000270 7d b7 40 20 01 5f aa d3 16 61 09 a2 76 fd 13 c3 |}.@ ._...a..v...| +00000280 cc e1 0c 5c ee b1 87 82 f1 6c 04 ed 73 bb b3 43 |...\.....l..s..C| +00000290 77 8d 0c 1c f1 0f a1 d8 40 83 61 c9 4c 72 2b 9d |w.......@.a.Lr+.| +000002a0 ae db 46 06 06 4d f4 c1 b3 3e c0 d1 bd 42 d4 db |..F..M...>...B..| +000002b0 fe 3d 13 60 84 5c 21 d3 3b e9 fa e7 16 03 03 00 |.=.`.\!.;.......| +000002c0 ac 0c 00 00 a8 03 00 1d 20 41 51 d5 70 34 15 c0 |........ AQ.p4..| +000002d0 76 3e 2b 5c e2 de 36 69 a9 2e bf b8 60 b4 3a 56 |v>+\..6i....`.:V| +000002e0 00 73 c1 85 4a b2 3e a6 54 04 01 00 80 5d 44 f2 |.s..J.>.T....]D.| +000002f0 28 99 f6 4f 45 bc 83 ce f7 98 ab 29 21 05 a6 c3 |(..OE......)!...| +00000300 8c a9 ef c2 82 b5 b3 bd 31 09 ae 11 15 fa 21 02 |........1.....!.| +00000310 43 59 00 fb 53 9d 0f bb b0 ab ca ba ce e8 41 28 |CY..S.........A(| +00000320 0a 7b ff cb d4 eb 81 8a a2 ce a6 32 f8 d7 f2 a0 |.{.........2....| +00000330 3b 0d c8 fc 8d 45 a8 4c 66 ef 48 ce 4a fc d3 7a |;....E.Lf.H.J..z| +00000340 19 1d 7f bd 71 c6 61 4a 93 b9 01 c9 39 32 48 ec |....q.aJ....92H.| +00000350 fd 01 c9 32 6b 9f d1 0e c1 62 bc 78 32 34 af 7e |...2k....b.x24.~| +00000360 58 16 d0 4c c7 44 a6 3a e5 4c 89 d6 f3 16 03 03 |X..L.D.:.L......| +00000370 00 0c 0d 00 00 08 01 01 00 02 04 01 00 00 16 03 |................| +00000380 03 00 04 0e 00 00 00 |.......| +>>> Flow 3 (client to server) +00000000 16 03 03 01 fd 0b 00 01 f9 00 01 f6 00 01 f3 30 |...............0| +00000010 82 01 ef 30 82 01 58 a0 03 02 01 02 02 10 5c 19 |...0..X.......\.| +00000020 c1 89 65 83 55 6f dc 0b c9 b9 93 9f e9 bc 30 0d |..e.Uo........0.| +00000030 06 09 2a 86 48 86 f7 0d 01 01 0b 05 00 30 12 31 |..*.H........0.1| +00000040 10 30 0e 06 03 55 04 0a 13 07 41 63 6d 65 20 43 |.0...U....Acme C| +00000050 6f 30 1e 17 0d 31 36 30 38 31 37 32 31 35 32 33 |o0...16081721523| +00000060 31 5a 17 0d 31 37 30 38 31 37 32 31 35 32 33 31 |1Z..170817215231| +00000070 5a 30 12 31 10 30 0e 06 03 55 04 0a 13 07 41 63 |Z0.1.0...U....Ac| +00000080 6d 65 20 43 6f 30 81 9f 30 0d 06 09 2a 86 48 86 |me Co0..0...*.H.| +00000090 f7 0d 01 01 01 05 00 03 81 8d 00 30 81 89 02 81 |...........0....| +000000a0 81 00 ba 6f aa 86 bd cf bf 9f f2 ef 5c 94 60 78 |...o........\.`x| +000000b0 6f e8 13 f2 d1 96 6f cd d9 32 6e 22 37 ce 41 f9 |o.....o..2n"7.A.| +000000c0 ca 5d 29 ac e1 27 da 61 a2 ee 81 cb 10 c7 df 34 |.])..'.a.......4| +000000d0 58 95 86 e9 3d 19 e6 5c 27 73 60 c8 8d 78 02 f4 |X...=..\'s`..x..| +000000e0 1d a4 98 09 a3 19 70 69 3c 25 62 66 2a ab 22 23 |......pi<%bf*."#| +000000f0 c5 7b 85 38 4f 2e 09 73 32 a7 bd 3e 9b ad ca 84 |.{.8O..s2..>....| +00000100 07 e6 0f 3a ff 77 c5 9d 41 85 00 8a b6 9b ee b0 |...:.w..A.......| +00000110 a4 3f 2d 4c 4c e6 42 3e bb 51 c8 dd 48 54 f4 0c |.?-LL.B>.Q..HT..| +00000120 8e 47 02 03 01 00 01 a3 46 30 44 30 0e 06 03 55 |.G......F0D0...U| +00000130 1d 0f 01 01 ff 04 04 03 02 05 a0 30 13 06 03 55 |...........0...U| +00000140 1d 25 04 0c 30 0a 06 08 2b 06 01 05 05 07 03 01 |.%..0...+.......| +00000150 30 0c 06 03 55 1d 13 01 01 ff 04 02 30 00 30 0f |0...U.......0.0.| +00000160 06 03 55 1d 11 04 08 30 06 87 04 7f 00 00 01 30 |..U....0.......0| +00000170 0d 06 09 2a 86 48 86 f7 0d 01 01 0b 05 00 03 81 |...*.H..........| +00000180 81 00 46 ab 44 a2 fb 28 54 f8 5a 67 f8 62 94 f1 |..F.D..(T.Zg.b..| +00000190 9a b2 18 9e f2 b1 de 1d 7e 6f 76 95 a9 ba e7 5d |........~ov....]| +000001a0 a8 16 6c 9c f7 09 d3 37 e4 4b 2b 36 7c 01 ad 41 |..l....7.K+6|..A| +000001b0 d2 32 d8 c3 d2 93 f9 10 6b 8e 95 b9 2c 17 8a a3 |.2......k...,...| +000001c0 44 48 bc 59 13 83 16 04 88 a4 81 5c 25 0d 98 0c |DH.Y.......\%...| +000001d0 ac 11 b1 28 56 be 1d cd 61 62 84 09 bf d6 80 c6 |...(V...ab......| +000001e0 45 8d 82 2c b4 d8 83 9b db c9 22 b7 2a 12 11 7b |E..,......".*..{| +000001f0 fa 02 3b c1 c9 ff ea c9 9d a8 49 d3 95 d7 d5 0e |..;.......I.....| +00000200 e5 35 16 03 03 00 25 10 00 00 21 20 2f e5 7d a3 |.5....%...! /.}.| +00000210 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 |G.bC.(.._.).0...| +00000220 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 16 03 03 00 |......._X.;t....| +00000230 88 0f 00 00 84 04 01 00 80 02 7e 43 b4 4e a2 07 |..........~C.N..| +00000240 a4 97 70 3f 80 91 5c b5 a0 f9 d7 c4 52 c9 ee 8a |..p?..\.....R...| +00000250 af 59 63 58 bb ac 55 47 cc 25 27 ea ca 48 0e fb |.YcX..UG.%'..H..| +00000260 87 e3 3e 5f 55 67 d8 60 8c 47 45 10 36 aa 66 6c |..>_Ug.`.GE.6.fl| +00000270 6b 16 2b 9e e5 da 50 73 dc 30 ef 2c 01 01 87 2e |k.+...Ps.0.,....| +00000280 68 eb 14 35 f5 ef c4 45 ae 8e 95 29 86 96 6e 04 |h..5...E...)..n.| +00000290 03 d6 3c 29 49 55 7c 7d ea 6c 1a a8 bf f9 5a e1 |..<)IU|}.l....Z.| +000002a0 a9 c4 66 5b 8d b5 78 b8 05 ce 44 ca 98 77 a2 7d |..f[..x...D..w.}| +000002b0 74 26 f4 ed 41 a3 97 2b 29 14 03 03 00 01 01 16 |t&..A..+).......| +000002c0 03 03 00 28 00 00 00 00 00 00 00 00 ac ec 0d 5a |...(...........Z| +000002d0 c7 81 fe c3 b3 ff 3a 6e d0 f3 f7 8e 17 6a 53 db |......:n.....jS.| +000002e0 58 5f 44 bb ce 59 0a 99 06 21 62 24 |X_D..Y...!b$| +>>> Flow 4 (server to client) +00000000 14 03 03 00 01 01 16 03 03 00 28 59 19 13 9f ea |..........(Y....| +00000010 68 14 58 ab 09 0c af 4d b4 a1 05 09 47 08 50 cd |h.X....M....G.P.| +00000020 b0 40 a0 3a 3f 89 68 c9 9c ea 8f 69 0a ea e1 75 |.@.:?.h....i...u| +00000030 11 97 ab |...| +>>> Flow 5 (client to server) +00000000 17 03 03 00 1e 00 00 00 00 00 00 00 01 38 f1 0f |.............8..| +00000010 d6 4f 5c 0a 60 1a 9f 97 6d 4a 43 e8 c8 a8 18 7e |.O\.`...mJC....~| +00000020 30 6f 67 15 03 03 00 1a 00 00 00 00 00 00 00 02 |0og.............| +00000030 d9 ac f7 69 ca a2 58 78 10 c2 eb 1a 61 da af 28 |...i..Xx....a..(| +00000040 20 02 | .| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-RSAPSS b/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-RSAPSS new file mode 100644 index 00000000000..8c901f083ef --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-ClientCert-RSA-RSAPSS @@ -0,0 +1,135 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| +>>> Flow 2 (server to client) +00000000 16 03 03 00 59 02 00 00 55 03 03 ce d1 7f 55 bc |....Y...U.....U.| +00000010 b8 a8 fb 08 cc d4 2d a2 e9 fa ff 43 24 d2 14 04 |......-....C$...| +00000020 ad 5a 05 77 d4 67 04 8b c1 3e 5c 20 31 6e ba 32 |.Z.w.g...>\ 1n.2| +00000030 70 bd f0 c8 55 74 a1 49 f3 9f 93 86 e9 b3 ee 81 |p...Ut.I........| +00000040 3e 54 09 e9 15 78 78 7e 71 2b f5 cd c0 2f 00 00 |>T...xx~q+.../..| +00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| +00000060 03 02 66 0b 00 02 62 00 02 5f 00 02 5c 30 82 02 |..f...b.._..\0..| +00000070 58 30 82 01 8d a0 03 02 01 02 02 11 00 f2 99 26 |X0.............&| +00000080 eb 87 ea 8a 0d b9 fc c2 47 34 7c 11 b0 30 41 06 |........G4|..0A.| +00000090 09 2a 86 48 86 f7 0d 01 01 0a 30 34 a0 0f 30 0d |.*.H......04..0.| +000000a0 06 09 60 86 48 01 65 03 04 02 01 05 00 a1 1c 30 |..`.H.e........0| +000000b0 1a 06 09 2a 86 48 86 f7 0d 01 01 08 30 0d 06 09 |...*.H......0...| +000000c0 60 86 48 01 65 03 04 02 01 05 00 a2 03 02 01 20 |`.H.e.......... | +000000d0 30 12 31 10 30 0e 06 03 55 04 0a 13 07 41 63 6d |0.1.0...U....Acm| +000000e0 65 20 43 6f 30 1e 17 0d 31 37 31 31 32 33 31 36 |e Co0...17112316| +000000f0 31 36 31 30 5a 17 0d 31 38 31 31 32 33 31 36 31 |1610Z..181123161| +00000100 36 31 30 5a 30 12 31 10 30 0e 06 03 55 04 0a 13 |610Z0.1.0...U...| +00000110 07 41 63 6d 65 20 43 6f 30 81 9f 30 0d 06 09 2a |.Acme Co0..0...*| +00000120 86 48 86 f7 0d 01 01 01 05 00 03 81 8d 00 30 81 |.H............0.| +00000130 89 02 81 81 00 db 46 7d 93 2e 12 27 06 48 bc 06 |......F}...'.H..| +00000140 28 21 ab 7e c4 b6 a2 5d fe 1e 52 45 88 7a 36 47 |(!.~...]..RE.z6G| +00000150 a5 08 0d 92 42 5b c2 81 c0 be 97 79 98 40 fb 4f |....B[.....y.@.O| +00000160 6d 14 fd 2b 13 8b c2 a5 2e 67 d8 d4 09 9e d6 22 |m..+.....g....."| +00000170 38 b7 4a 0b 74 73 2b c2 34 f1 d1 93 e5 96 d9 74 |8.J.ts+.4......t| +00000180 7b f3 58 9f 6c 61 3c c0 b0 41 d4 d9 2b 2b 24 23 |{.X.la<..A..++$#| +00000190 77 5b 1c 3b bd 75 5d ce 20 54 cf a1 63 87 1d 1e |w[.;.u]. T..c...| +000001a0 24 c4 f3 1d 1a 50 8b aa b6 14 43 ed 97 a7 75 62 |$....P....C...ub| +000001b0 f4 14 c8 52 d7 02 03 01 00 01 a3 46 30 44 30 0e |...R.......F0D0.| +000001c0 06 03 55 1d 0f 01 01 ff 04 04 03 02 05 a0 30 13 |..U...........0.| +000001d0 06 03 55 1d 25 04 0c 30 0a 06 08 2b 06 01 05 05 |..U.%..0...+....| +000001e0 07 03 01 30 0c 06 03 55 1d 13 01 01 ff 04 02 30 |...0...U.......0| +000001f0 00 30 0f 06 03 55 1d 11 04 08 30 06 87 04 7f 00 |.0...U....0.....| +00000200 00 01 30 41 06 09 2a 86 48 86 f7 0d 01 01 0a 30 |..0A..*.H......0| +00000210 34 a0 0f 30 0d 06 09 60 86 48 01 65 03 04 02 01 |4..0...`.H.e....| +00000220 05 00 a1 1c 30 1a 06 09 2a 86 48 86 f7 0d 01 01 |....0...*.H.....| +00000230 08 30 0d 06 09 60 86 48 01 65 03 04 02 01 05 00 |.0...`.H.e......| +00000240 a2 03 02 01 20 03 81 81 00 cd ac 4e f2 ce 5f 8d |.... ......N.._.| +00000250 79 88 10 42 70 7f 7c bf 1b 5a 8a 00 ef 19 15 4b |y..Bp.|..Z.....K| +00000260 40 15 17 71 00 6c d4 16 26 e5 49 6d 56 da 0c 1a |@..q.l..&.ImV...| +00000270 13 9f d8 46 95 59 3c b6 7f 87 76 5e 18 aa 03 ea |...F.Y<...v^....| +00000280 06 75 22 dd 78 d2 a5 89 b8 c9 23 64 e1 28 38 ce |.u".x.....#d.(8.| +00000290 34 6c 6e 06 7b 51 f1 a7 e6 f4 b3 7f fa b1 3f 14 |4ln.{Q........?.| +000002a0 11 89 66 79 d1 8e 88 0e 0b a0 9e 30 2a c0 67 ef |..fy.......0*.g.| +000002b0 ca 46 02 88 e9 53 81 22 69 22 97 ad 80 93 d4 f7 |.F...S."i"......| +000002c0 dd 70 14 24 d7 70 0a 46 a1 16 03 03 00 ac 0c 00 |.p.$.p.F........| +000002d0 00 a8 03 00 1d 20 62 1f 63 aa 80 a5 b5 a3 e3 71 |..... b.c......q| +000002e0 71 63 0d be 4d d2 bd f4 3b 0d 78 e8 c1 fe 43 0d |qc..M...;.x...C.| +000002f0 e3 09 9a 01 ed 72 08 04 00 80 59 a7 96 03 f4 60 |.....r....Y....`| +00000300 fa 56 73 a2 14 e8 1e 0b 66 d5 7e 91 7c 99 50 6b |.Vs.....f.~.|.Pk| +00000310 c0 74 8d 24 a5 98 2d df 47 e4 42 73 09 a0 c4 6a |.t.$..-.G.Bs...j| +00000320 42 22 3d 85 f0 a4 05 f8 b5 74 96 85 f7 b0 22 9a |B"=......t....".| +00000330 ee 25 b5 19 c1 ec f0 3b 32 bd 28 6a eb ac 32 e4 |.%.....;2.(j..2.| +00000340 54 18 2e 6c b9 c0 74 d5 e8 36 2b 47 67 65 ba fb |T..l..t..6+Gge..| +00000350 53 18 b2 e3 30 6c 49 4c 8f 07 91 54 93 47 3b b9 |S...0lIL...T.G;.| +00000360 f1 92 81 53 b9 de 5a f5 28 08 e7 4a 46 fa 63 8f |...S..Z.(..JF.c.| +00000370 d0 66 29 0d 6d f0 6b 11 c1 2b 16 03 03 00 0c 0d |.f).m.k..+......| +00000380 00 00 08 01 01 00 02 08 04 00 00 16 03 03 00 04 |................| +00000390 0e 00 00 00 |....| +>>> Flow 3 (client to server) +00000000 16 03 03 01 fd 0b 00 01 f9 00 01 f6 00 01 f3 30 |...............0| +00000010 82 01 ef 30 82 01 58 a0 03 02 01 02 02 10 5c 19 |...0..X.......\.| +00000020 c1 89 65 83 55 6f dc 0b c9 b9 93 9f e9 bc 30 0d |..e.Uo........0.| +00000030 06 09 2a 86 48 86 f7 0d 01 01 0b 05 00 30 12 31 |..*.H........0.1| +00000040 10 30 0e 06 03 55 04 0a 13 07 41 63 6d 65 20 43 |.0...U....Acme C| +00000050 6f 30 1e 17 0d 31 36 30 38 31 37 32 31 35 32 33 |o0...16081721523| +00000060 31 5a 17 0d 31 37 30 38 31 37 32 31 35 32 33 31 |1Z..170817215231| +00000070 5a 30 12 31 10 30 0e 06 03 55 04 0a 13 07 41 63 |Z0.1.0...U....Ac| +00000080 6d 65 20 43 6f 30 81 9f 30 0d 06 09 2a 86 48 86 |me Co0..0...*.H.| +00000090 f7 0d 01 01 01 05 00 03 81 8d 00 30 81 89 02 81 |...........0....| +000000a0 81 00 ba 6f aa 86 bd cf bf 9f f2 ef 5c 94 60 78 |...o........\.`x| +000000b0 6f e8 13 f2 d1 96 6f cd d9 32 6e 22 37 ce 41 f9 |o.....o..2n"7.A.| +000000c0 ca 5d 29 ac e1 27 da 61 a2 ee 81 cb 10 c7 df 34 |.])..'.a.......4| +000000d0 58 95 86 e9 3d 19 e6 5c 27 73 60 c8 8d 78 02 f4 |X...=..\'s`..x..| +000000e0 1d a4 98 09 a3 19 70 69 3c 25 62 66 2a ab 22 23 |......pi<%bf*."#| +000000f0 c5 7b 85 38 4f 2e 09 73 32 a7 bd 3e 9b ad ca 84 |.{.8O..s2..>....| +00000100 07 e6 0f 3a ff 77 c5 9d 41 85 00 8a b6 9b ee b0 |...:.w..A.......| +00000110 a4 3f 2d 4c 4c e6 42 3e bb 51 c8 dd 48 54 f4 0c |.?-LL.B>.Q..HT..| +00000120 8e 47 02 03 01 00 01 a3 46 30 44 30 0e 06 03 55 |.G......F0D0...U| +00000130 1d 0f 01 01 ff 04 04 03 02 05 a0 30 13 06 03 55 |...........0...U| +00000140 1d 25 04 0c 30 0a 06 08 2b 06 01 05 05 07 03 01 |.%..0...+.......| +00000150 30 0c 06 03 55 1d 13 01 01 ff 04 02 30 00 30 0f |0...U.......0.0.| +00000160 06 03 55 1d 11 04 08 30 06 87 04 7f 00 00 01 30 |..U....0.......0| +00000170 0d 06 09 2a 86 48 86 f7 0d 01 01 0b 05 00 03 81 |...*.H..........| +00000180 81 00 46 ab 44 a2 fb 28 54 f8 5a 67 f8 62 94 f1 |..F.D..(T.Zg.b..| +00000190 9a b2 18 9e f2 b1 de 1d 7e 6f 76 95 a9 ba e7 5d |........~ov....]| +000001a0 a8 16 6c 9c f7 09 d3 37 e4 4b 2b 36 7c 01 ad 41 |..l....7.K+6|..A| +000001b0 d2 32 d8 c3 d2 93 f9 10 6b 8e 95 b9 2c 17 8a a3 |.2......k...,...| +000001c0 44 48 bc 59 13 83 16 04 88 a4 81 5c 25 0d 98 0c |DH.Y.......\%...| +000001d0 ac 11 b1 28 56 be 1d cd 61 62 84 09 bf d6 80 c6 |...(V...ab......| +000001e0 45 8d 82 2c b4 d8 83 9b db c9 22 b7 2a 12 11 7b |E..,......".*..{| +000001f0 fa 02 3b c1 c9 ff ea c9 9d a8 49 d3 95 d7 d5 0e |..;.......I.....| +00000200 e5 35 16 03 03 00 25 10 00 00 21 20 2f e5 7d a3 |.5....%...! /.}.| +00000210 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 |G.bC.(.._.).0...| +00000220 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 16 03 03 00 |......._X.;t....| +00000230 88 0f 00 00 84 08 04 00 80 a4 3b 32 76 8f fd 9a |..........;2v...| +00000240 42 99 24 e1 58 f8 21 39 b7 b2 55 ed 25 5c 67 a7 |B.$.X.!9..U.%\g.| +00000250 d3 79 f2 04 36 03 18 ad 76 4e db 9f ce 4f 97 86 |.y..6...vN...O..| +00000260 6f 0c 72 f5 8e 52 44 16 01 f2 4d c2 74 9f 75 51 |o.r..RD...M.t.uQ| +00000270 ea a4 0a 9c 1f a0 96 7e 2b e2 fc f9 80 c8 31 f9 |.......~+.....1.| +00000280 40 19 fe 40 d2 62 fd 9c 1a 29 ed ea 33 b3 ac f7 |@..@.b...)..3...| +00000290 e6 52 b6 2b 69 62 b2 a4 8d 62 db 4b 67 d9 fb b0 |.R.+ib...b.Kg...| +000002a0 2a 25 c5 c1 7e ca 7d 56 75 a0 b4 8e 65 18 ea ba |*%..~.}Vu...e...| +000002b0 fb 86 dc 60 b1 d3 fb 4b ce 14 03 03 00 01 01 16 |...`...K........| +000002c0 03 03 00 28 00 00 00 00 00 00 00 00 40 48 84 70 |...(........@H.p| +000002d0 05 89 8a 4d 25 4b 4f 14 96 bd 29 5f f8 1a e5 c0 |...M%KO...)_....| +000002e0 87 f5 b7 1e 1f ba 73 b4 66 e7 9f ea |......s.f...| +>>> Flow 4 (server to client) +00000000 14 03 03 00 01 01 16 03 03 00 28 9b d9 9c b6 21 |..........(....!| +00000010 4f 16 83 6d 53 a4 df 76 a4 79 60 9d fb 92 b0 57 |O..mS..v.y`....W| +00000020 7f 9b 4e 35 80 d6 d4 04 e6 a9 93 62 f7 41 8a 23 |..N5.......b.A.#| +00000030 78 22 4e |x"N| +>>> Flow 5 (client to server) +00000000 17 03 03 00 1e 00 00 00 00 00 00 00 01 81 49 a3 |..............I.| +00000010 c8 46 e1 9a 79 fa 94 02 69 94 24 0d e2 44 95 76 |.F..y...i.$..D.v| +00000020 ee a0 ca 15 03 03 00 1a 00 00 00 00 00 00 00 02 |................| +00000030 41 df 97 11 9e 64 12 ce 6f 96 be 90 af d8 4a 13 |A....d..o.....J.| +00000040 c5 01 |..| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-ECDHE-ECDSA-AES b/libgo/go/crypto/tls/testdata/Client-TLSv12-ECDHE-ECDSA-AES index 3403023b6b6..4e021207c13 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv12-ECDHE-ECDSA-AES +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-ECDHE-ECDSA-AES @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 03 00 59 02 00 00 55 03 03 78 e9 9b 0c e1 |....Y...U..x....| -00000010 45 f0 55 05 58 ef 80 4f 22 88 e4 7d eb af a5 b2 |E.U.X..O"..}....| -00000020 75 36 9f a2 cc 6d 51 27 ca 7e 38 20 c8 89 89 e7 |u6...mQ'.~8 ....| -00000030 95 70 01 01 67 b0 9a 1a 7a 54 d8 bb 22 72 c6 9c |.p..g...zT.."r..| -00000040 09 ff d4 2c 0a 94 86 bc 51 cb 56 7d c0 09 00 00 |...,....Q.V}....| +00000000 16 03 03 00 59 02 00 00 55 03 03 fa c6 67 00 b7 |....Y...U....g..| +00000010 e2 10 1e 8e b4 64 0e 4e 78 38 25 ff fb 5f bf 9f |.....d.Nx8%.._..| +00000020 b6 de b2 91 50 6c 67 0a bd dc dd 20 83 f5 41 e7 |....Plg.... ..A.| +00000030 98 0c 38 d9 3b 09 18 d2 2e 16 f5 ef 98 a9 ce 38 |..8.;..........8| +00000040 f1 36 3e bb 6d 45 81 b8 03 82 57 3d c0 09 00 00 |.6>.mE....W=....| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 03 02 0e 0b 00 02 0a 00 02 07 00 02 04 30 82 02 |.............0..| 00000070 00 30 82 01 62 02 09 00 b8 bf 2d 47 a0 d2 eb f4 |.0..b.....-G....| @@ -49,39 +55,39 @@ 00000240 13 83 0d 94 06 bb d4 37 7a f6 ec 7a c9 86 2e dd |.......7z..z....| 00000250 d7 11 69 7f 85 7c 56 de fb 31 78 2b e4 c7 78 0d |..i..|V..1x+..x.| 00000260 ae cb be 9e 4e 36 24 31 7b 6a 0f 39 95 12 07 8f |....N6$1{j.9....| -00000270 2a 16 03 03 00 b6 0c 00 00 b2 03 00 1d 20 0f 61 |*............ .a| -00000280 6e 56 ec 74 54 e2 24 09 61 64 45 89 44 aa cb 79 |nV.tT.$.adE.D..y| -00000290 18 37 12 42 07 f8 d7 a3 42 b8 d7 06 21 28 04 03 |.7.B....B...!(..| -000002a0 00 8a 30 81 87 02 42 00 af 5c 33 04 e8 e1 fa b7 |..0...B..\3.....| -000002b0 98 38 96 ea c1 ee 7d 2c 45 85 ab 41 bd d8 88 af |.8....},E..A....| -000002c0 a6 0b e4 22 56 7d 3a e6 a6 8e 0d b5 81 cb 38 43 |..."V}:.......8C| -000002d0 e7 b6 94 ee 20 e7 61 89 00 99 69 18 b3 06 d0 15 |.... .a...i.....| -000002e0 0e f4 10 e9 5a dd 74 10 d1 02 41 27 4c dc 89 d4 |....Z.t...A'L...| -000002f0 75 56 d4 c2 82 7d 53 a0 61 c5 ba 6a 9a ca fa 36 |uV...}S.a..j...6| -00000300 16 db 82 5d 5e b7 9b 6a b8 13 0b 69 2f b5 c9 8e |...]^..j...i/...| -00000310 53 18 03 24 b3 31 b1 48 8c b9 e0 16 96 cc e2 5d |S..$.1.H.......]| -00000320 71 6a 1d 70 8c 1b 57 8e 5d 9a f2 e1 16 03 03 00 |qj.p..W.].......| -00000330 04 0e 00 00 00 |.....| +00000270 2a 16 03 03 00 b7 0c 00 00 b3 03 00 1d 20 da 76 |*............ .v| +00000280 af 3a be 2d da 07 b1 41 61 16 f3 ad c1 3f b5 95 |.:.-...Aa....?..| +00000290 27 4a 91 9d de f0 b8 a3 c7 ad c8 64 47 35 04 03 |'J.........dG5..| +000002a0 00 8b 30 81 88 02 42 01 86 ea 56 df 52 76 06 31 |..0...B...V.Rv.1| +000002b0 ae d9 80 6b 51 a0 61 84 9c a2 e5 aa dc d5 54 ba |...kQ.a.......T.| +000002c0 ca c9 88 d2 90 f6 a1 76 6c 38 39 d4 0b 2e e0 e5 |.......vl89.....| +000002d0 6a f5 f1 98 97 d4 a9 5a 73 a8 c7 67 eb 8b e2 8a |j......Zs..g....| +000002e0 2c 2a 80 a3 7e 5d 5e d8 0c 02 42 01 96 20 c9 4a |,*..~]^...B.. .J| +000002f0 a5 43 f1 c0 08 20 72 ea d2 9c 89 2b ef aa f1 37 |.C... r....+...7| +00000300 ff 00 78 3a 51 61 6a 13 61 7b e9 ea 37 bf 35 18 |..x:Qaj.a{..7.5.| +00000310 5a 19 33 29 4d fe e6 d4 0e cc 1e 21 13 6e ed 62 |Z.3)M......!.n.b| +00000320 bc d5 66 26 a4 82 d5 e0 99 3b ed 70 78 16 03 03 |..f&.....;.px...| +00000330 00 04 0e 00 00 00 |......| >>> Flow 3 (client to server) 00000000 16 03 03 00 25 10 00 00 21 20 2f e5 7d a3 47 cd |....%...! /.}.G.| 00000010 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 |bC.(.._.).0.....| 00000020 cf c2 ed 90 99 5f 58 cb 3b 74 14 03 03 00 01 01 |....._X.;t......| 00000030 16 03 03 00 40 00 00 00 00 00 00 00 00 00 00 00 |....@...........| -00000040 00 00 00 00 00 c1 47 dc 05 80 89 9f 04 e8 88 58 |......G........X| -00000050 bc 59 78 df ce bb d4 f7 cf 45 e2 2a ff ce 09 9c |.Yx......E.*....| -00000060 07 f3 90 49 ad 4d 07 b4 21 46 e3 37 e9 54 82 4d |...I.M..!F.7.T.M| -00000070 a2 05 ad 83 fa |.....| +00000040 00 00 00 00 00 08 0a dc 8c c5 3e 8d 03 ab e1 c3 |..........>.....| +00000050 ea aa 03 d8 1d 19 99 9c 2c 15 09 4b 39 a8 51 c6 |........,..K9.Q.| +00000060 4e 15 46 1c d2 7c b0 a9 4b 7f be c9 35 99 ab db |N.F..|..K...5...| +00000070 4b e0 6c 62 17 |K.lb.| >>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 40 a6 27 61 cd 85 |..........@.'a..| -00000010 3a 7c 35 bb 33 61 ed 4b 0f 0c 42 bd 25 a5 5a a8 |:|5.3a.K..B.%.Z.| -00000020 ef 27 b3 d7 d2 38 64 c7 46 51 5c f2 4b 32 a1 eb |.'...8d.FQ\.K2..| -00000030 b2 6a ba af fc d0 2d 7a 9d 72 d5 23 ae 15 2a fc |.j....-z.r.#..*.| -00000040 1c 03 cd 99 dd ac b0 31 83 0a 1e |.......1...| +00000000 14 03 03 00 01 01 16 03 03 00 40 ae ce d9 46 bc |..........@...F.| +00000010 2f df aa fb d6 7d 52 e3 e9 a0 e6 e9 22 14 ae fe |/....}R....."...| +00000020 ce 34 c2 b2 16 ae aa 6b 72 90 d3 a6 e9 1e 96 3f |.4.....kr......?| +00000030 fd 45 d7 cc 28 db ac f7 42 55 3e 24 2c 5e dc 3e |.E..(...BU>$,^.>| +00000040 5f 6e 36 76 6e ab 1c 35 76 e5 4b |_n6vn..5v.K| >>> Flow 5 (client to server) 00000000 17 03 03 00 30 00 00 00 00 00 00 00 00 00 00 00 |....0...........| -00000010 00 00 00 00 00 a7 0f 50 52 17 a2 5b 19 33 4e 97 |.......PR..[.3N.| -00000020 33 4e 56 2e 1e bf 93 ca ae fa 4c ca ff 47 08 7b |3NV.......L..G.{| -00000030 d2 f8 e1 29 29 15 03 03 00 30 00 00 00 00 00 00 |...))....0......| -00000040 00 00 00 00 00 00 00 00 00 00 a5 ac 57 1c ca 5f |............W.._| -00000050 f2 39 b2 85 a5 4a 06 11 a2 8f e5 1d 55 1d 4f 89 |.9...J......U.O.| -00000060 6c d9 47 bd a2 8b d3 d0 eb d6 |l.G.......| +00000010 00 00 00 00 00 48 f8 b0 95 19 6b 5f 9a 03 5d 10 |.....H....k_..].| +00000020 d6 1a 3c ed d1 f8 73 4f 84 52 63 a2 3a f5 3c 4d |..<...sO.Rc.:.>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 03 00 59 02 00 00 55 03 03 e1 a8 35 92 15 |....Y...U....5..| -00000010 b2 f2 02 ae 4f 1b c5 1c 46 04 d1 bf 60 d6 bd 66 |....O...F...`..f| -00000020 d0 c4 d5 18 26 10 6d 53 19 35 d2 20 15 d3 4b 3f |....&.mS.5. ..K?| -00000030 de 5a f3 8d f7 02 c4 71 8b 4f c2 b6 69 49 f1 2a |.Z.....q.O..iI.*| -00000040 79 66 40 45 ee 9d 1b d8 72 7e b0 23 c0 2b 00 00 |yf@E....r~.#.+..| +00000000 16 03 03 00 59 02 00 00 55 03 03 d1 cf 2d 7a f6 |....Y...U....-z.| +00000010 a2 09 06 6e 67 c1 ce 6e ae 25 49 da fc 24 4f d1 |...ng..n.%I..$O.| +00000020 8a a0 2e d0 7f 87 a4 8b 58 c8 37 20 22 d2 39 81 |........X.7 ".9.| +00000030 5b 59 bd 0f 7b 59 b4 2c 38 d4 e0 03 1c 3b 5a 99 |[Y..{Y.,8....;Z.| +00000040 20 57 75 30 3d 3f a8 d9 cd 33 41 17 c0 2b 00 00 | Wu0=?...3A..+..| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 03 02 0e 0b 00 02 0a 00 02 07 00 02 04 30 82 02 |.............0..| 00000070 00 30 82 01 62 02 09 00 b8 bf 2d 47 a0 d2 eb f4 |.0..b.....-G....| @@ -49,34 +55,34 @@ 00000240 13 83 0d 94 06 bb d4 37 7a f6 ec 7a c9 86 2e dd |.......7z..z....| 00000250 d7 11 69 7f 85 7c 56 de fb 31 78 2b e4 c7 78 0d |..i..|V..1x+..x.| 00000260 ae cb be 9e 4e 36 24 31 7b 6a 0f 39 95 12 07 8f |....N6$1{j.9....| -00000270 2a 16 03 03 00 b6 0c 00 00 b2 03 00 1d 20 2e b4 |*............ ..| -00000280 dd 41 46 08 4d c2 c9 37 b8 50 0b 50 6f c7 bd 13 |.AF.M..7.P.Po...| -00000290 de 59 d4 9f d0 2b 44 2a 8c 6f 2a f9 67 7a 04 03 |.Y...+D*.o*.gz..| -000002a0 00 8a 30 81 87 02 41 7c 9a e0 93 cc 65 a2 af 0e |..0...A|....e...| -000002b0 32 9c 37 b7 39 9a 45 95 fb 2e b2 a9 34 f8 ab 47 |2.7.9.E.....4..G| -000002c0 d8 3b 6f 7d b8 03 32 a9 d0 30 1a 37 cc fd 4a 16 |.;o}..2..0.7..J.| -000002d0 94 f9 23 ce b7 8a e6 91 d7 33 00 25 d3 c7 88 d8 |..#......3.%....| -000002e0 49 2c 81 73 e2 b1 b8 78 02 42 01 c8 58 dc 43 96 |I,.s...x.B..X.C.| -000002f0 40 00 c3 4c 9c a1 ba ef 4a 20 e6 ee 53 28 6e 82 |@..L....J ..S(n.| -00000300 97 ba f3 0b 71 5c f9 4f 05 1e 61 a7 ba 03 60 5c |....q\.O..a...`\| -00000310 f5 61 1e fd 53 c1 74 30 5c 92 b4 4c 6e d2 9f 05 |.a..S.t0\..Ln...| -00000320 6b ad 92 e5 14 b8 a9 07 a0 f3 34 71 16 03 03 00 |k.........4q....| +00000270 2a 16 03 03 00 b6 0c 00 00 b2 03 00 1d 20 1a b3 |*............ ..| +00000280 9a e4 c6 dd ca 36 10 16 55 e4 97 36 a5 b2 e7 e9 |.....6..U..6....| +00000290 42 b3 f3 a0 bb df d8 a5 00 be 40 35 8c 50 04 03 |B.........@5.P..| +000002a0 00 8a 30 81 87 02 42 01 90 c8 0f 71 3e 83 c9 6b |..0...B....q>..k| +000002b0 f2 b0 75 7d 9c 54 d4 33 59 fd ef 69 b4 d9 4d 9b |..u}.T.3Y..i..M.| +000002c0 48 fd cd 45 e5 e4 6c 8a 3a d5 1d 60 dc 88 65 3b |H..E..l.:..`..e;| +000002d0 98 81 e1 69 38 d9 bf fe 19 65 6b d9 da 57 8b d3 |...i8....ek..W..| +000002e0 b3 ef 54 db 4b dc f5 42 02 02 41 0d ab cd 01 a9 |..T.K..B..A.....| +000002f0 fc b8 10 40 2c 1a c7 46 e1 54 c0 5b 7f 24 28 49 |...@,..F.T.[.$(I| +00000300 fc 8b 62 e5 3e 99 db 2f 3d 69 d9 4c 86 c2 45 bb |..b.>../=i.L..E.| +00000310 89 0a f7 2e 7d 9f fb f8 fc 49 f9 c3 fb 21 f6 21 |....}....I...!.!| +00000320 10 35 7f 92 14 09 37 76 8b 2c 6c f2 16 03 03 00 |.5....7v.,l.....| 00000330 04 0e 00 00 00 |.....| >>> Flow 3 (client to server) 00000000 16 03 03 00 25 10 00 00 21 20 2f e5 7d a3 47 cd |....%...! /.}.G.| 00000010 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 |bC.(.._.).0.....| 00000020 cf c2 ed 90 99 5f 58 cb 3b 74 14 03 03 00 01 01 |....._X.;t......| -00000030 16 03 03 00 28 00 00 00 00 00 00 00 00 71 c9 39 |....(........q.9| -00000040 50 b8 91 9e eb f6 48 c6 04 d0 ae 99 dc 63 14 1b |P.....H......c..| -00000050 e9 4f 6b c0 18 46 b6 ca 38 bc 58 c3 85 |.Ok..F..8.X..| +00000030 16 03 03 00 28 00 00 00 00 00 00 00 00 0b f4 58 |....(..........X| +00000040 bd 46 cf 10 2b 5b f7 6b 89 44 12 a2 25 95 cd a3 |.F..+[.k.D..%...| +00000050 df ce 5c e4 e2 50 5f ef 06 84 06 03 8f |..\..P_......| >>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 28 e3 f3 fe 51 7c |..........(...Q|| -00000010 7c f9 ad fe 85 6c 37 fd 8f e2 76 2f 10 38 62 b0 ||....l7...v/.8b.| -00000020 37 7c cf 6e e6 65 c6 f4 5e 67 33 03 10 62 14 29 |7|.n.e..^g3..b.)| -00000030 8a ca 2e |...| +00000000 14 03 03 00 01 01 16 03 03 00 28 2f 02 07 37 3f |..........(/..7?| +00000010 3c 9d 0a fb 03 31 a2 df 0f d6 b4 53 f8 fa 38 bb |<....1.....S..8.| +00000020 47 ed 9d 69 b7 64 72 75 8a 06 f2 fa 9f 06 a4 91 |G..i.dru........| +00000030 65 c5 6e |e.n| >>> Flow 5 (client to server) -00000000 17 03 03 00 1e 00 00 00 00 00 00 00 01 5a 2d fa |.............Z-.| -00000010 9d 55 ff 55 ee 77 9e c0 60 3d 37 aa 82 14 a9 8c |.U.U.w..`=7.....| -00000020 7b d3 92 15 03 03 00 1a 00 00 00 00 00 00 00 02 |{...............| -00000030 8a 69 ad 03 ec 4f 06 55 e6 0c 3a 59 ea 15 26 e7 |.i...O.U..:Y..&.| -00000040 17 de |..| +00000000 17 03 03 00 1e 00 00 00 00 00 00 00 01 31 4a a6 |.............1J.| +00000010 a1 88 d0 36 6a 11 b7 4f 81 a8 f5 1d c1 c6 d1 51 |...6j..O.......Q| +00000020 3b a2 b1 15 03 03 00 1a 00 00 00 00 00 00 00 02 |;...............| +00000030 0e 35 89 7d 67 0e 8d b7 6f c9 86 6d 33 05 9f 7c |.5.}g...o..m3..|| +00000040 ab 8e |..| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-ECDHE-ECDSA-AES128-SHA256 b/libgo/go/crypto/tls/testdata/Client-TLSv12-ECDHE-ECDSA-AES128-SHA256 index 9d79b14dae0..12b87c95c8f 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv12-ECDHE-ECDSA-AES128-SHA256 +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-ECDHE-ECDSA-AES128-SHA256 @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 03 00 59 02 00 00 55 03 03 c7 69 06 a9 64 |....Y...U...i..d| -00000010 53 1a 6c 7b 39 f3 2e e3 01 5e ef e0 ac 69 a6 2e |S.l{9....^...i..| -00000020 39 59 c4 a8 06 60 9c 5b 0a 93 f2 20 b1 ba 93 61 |9Y...`.[... ...a| -00000030 3f c3 a8 d0 e7 22 60 8a 0b c2 68 14 69 c5 8a 9c |?...."`...h.i...| -00000040 35 b2 ba 8a d2 9b a4 e0 13 d8 fc bb c0 23 00 00 |5............#..| +00000000 16 03 03 00 59 02 00 00 55 03 03 bd b8 d6 c0 5c |....Y...U......\| +00000010 0c 7f e3 50 4c 1c d3 b0 0f 67 1a 32 cc 49 18 03 |...PL....g.2.I..| +00000020 41 91 87 43 0c eb 40 53 a4 2c 0c 20 ec a4 59 bd |A..C..@S.,. ..Y.| +00000030 cb 3e b8 94 d9 74 ee ab 8e 7a 24 c8 cc af 08 87 |.>...t...z$.....| +00000040 e7 9c d1 01 4e fe 7d 1d 5d cf e0 2c c0 23 00 00 |....N.}.]..,.#..| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 03 02 0e 0b 00 02 0a 00 02 07 00 02 04 30 82 02 |.............0..| 00000070 00 30 82 01 62 02 09 00 b8 bf 2d 47 a0 d2 eb f4 |.0..b.....-G....| @@ -49,43 +55,43 @@ 00000240 13 83 0d 94 06 bb d4 37 7a f6 ec 7a c9 86 2e dd |.......7z..z....| 00000250 d7 11 69 7f 85 7c 56 de fb 31 78 2b e4 c7 78 0d |..i..|V..1x+..x.| 00000260 ae cb be 9e 4e 36 24 31 7b 6a 0f 39 95 12 07 8f |....N6$1{j.9....| -00000270 2a 16 03 03 00 b6 0c 00 00 b2 03 00 1d 20 bd cd |*............ ..| -00000280 69 00 ff 76 9e 27 f5 4d cb f2 be 87 ec f3 c6 08 |i..v.'.M........| -00000290 79 fa cc 4e a5 db e6 dd 19 cb b1 66 e5 2b 04 03 |y..N.......f.+..| -000002a0 00 8a 30 81 87 02 41 33 72 4b 8e 13 f1 3c 7b 9b |..0...A3rK...<{.| -000002b0 4e 63 e0 28 1c 62 b0 a9 bf 70 96 68 93 52 4b 64 |Nc.(.b...p.h.RKd| -000002c0 02 4b 79 0b 50 7c 16 df 21 8f e4 8b c2 c6 4b cc |.Ky.P|..!.....K.| -000002d0 96 b8 bb 4a cc 89 f6 a5 6d c2 a3 70 b6 5a 25 26 |...J....m..p.Z%&| -000002e0 ad aa 56 95 72 fa d6 13 02 42 01 de 8a 1f 83 51 |..V.r....B.....Q| -000002f0 ce 3e 37 ff 3e ba 0e ed bd f3 95 0c 1b 69 8f f3 |.>7.>........i..| -00000300 f4 a9 26 cb c6 f4 70 79 da 93 5b 25 76 89 e8 3d |..&...py..[%v..=| -00000310 94 7f a9 5b 4f 25 83 63 a2 cb 71 27 41 5e 41 a1 |...[O%.c..q'A^A.| -00000320 5c 65 f2 2d a4 81 91 ca 79 bc 45 d3 16 03 03 00 |\e.-....y.E.....| +00000270 2a 16 03 03 00 b6 0c 00 00 b2 03 00 1d 20 6d 7f |*............ m.| +00000280 23 3f 8c 08 0f db 54 cc dc 84 d7 97 f0 18 85 68 |#?....T........h| +00000290 e3 17 94 f6 48 f3 c2 9c 4c 3e 58 47 ed 29 04 03 |....H...L>XG.)..| +000002a0 00 8a 30 81 87 02 42 01 c1 d9 7a d0 fb d9 ff 31 |..0...B...z....1| +000002b0 78 20 9e 2e 5c f0 22 97 1b 24 e8 50 6f 5d 8c db |x ..\."..$.Po]..| +000002c0 fb 97 0d 2d 73 08 ae 46 14 1c 76 2b 38 ad 75 2d |...-s..F..v+8.u-| +000002d0 a2 8e 5a 99 40 47 51 1f 11 af c0 86 bc c9 3b e3 |..Z.@GQ.......;.| +000002e0 a0 ff 6a e6 87 e6 74 d8 fd 02 41 7a 72 6a 93 12 |..j...t...Azrj..| +000002f0 4b 48 f9 46 af 95 90 1e 3b c7 2c fe 67 a1 44 d8 |KH.F....;.,.g.D.| +00000300 77 1c 7e 03 fe be ba 9d a1 85 81 42 fb 18 7d 08 |w.~........B..}.| +00000310 e6 04 1f 3e 05 eb 48 87 4e 28 1c e9 00 db 7f c4 |...>..H.N(......| +00000320 17 cb 21 02 37 90 47 fd 2f db 95 a7 16 03 03 00 |..!.7.G./.......| 00000330 04 0e 00 00 00 |.....| >>> Flow 3 (client to server) 00000000 16 03 03 00 25 10 00 00 21 20 2f e5 7d a3 47 cd |....%...! /.}.G.| 00000010 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 |bC.(.._.).0.....| 00000020 cf c2 ed 90 99 5f 58 cb 3b 74 14 03 03 00 01 01 |....._X.;t......| 00000030 16 03 03 00 50 00 00 00 00 00 00 00 00 00 00 00 |....P...........| -00000040 00 00 00 00 00 fe 52 a2 0a 9f de 8c 45 36 c5 0e |......R.....E6..| -00000050 a0 b5 f6 06 80 9f 2b 0e 72 4b 86 a7 4c 2a 37 0c |......+.rK..L*7.| -00000060 a0 a3 4c 2c 32 32 cf ed 45 ee e3 a2 1c 17 7d 4f |..L,22..E.....}O| -00000070 d8 60 d6 79 08 01 d7 35 0c 40 c8 85 f1 3e 73 b5 |.`.y...5.@...>s.| -00000080 5d 89 c9 db 03 |]....| +00000040 00 00 00 00 00 7a c5 98 1b ac 30 7c ea 9b cc 6d |.....z....0|...m| +00000050 5d 40 19 5d 6e 47 8a 46 d4 de 8c a3 f8 9b b1 2c |]@.]nG.F.......,| +00000060 9f 90 e9 83 2c a6 18 9f 39 92 d5 1f ab d5 5a 03 |....,...9.....Z.| +00000070 79 44 36 e3 0d b5 c9 e4 36 73 08 7d 55 e0 23 d6 |yD6.....6s.}U.#.| +00000080 82 f3 d7 4e ba |...N.| >>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 50 99 8b 66 fc b2 |..........P..f..| -00000010 0c 18 de 47 7b 72 a2 9b 47 64 58 45 00 70 b6 d3 |...G{r..GdXE.p..| -00000020 33 62 c2 c6 41 da 5d 08 37 16 5c 24 50 06 e0 e6 |3b..A.].7.\$P...| -00000030 7c 90 5e 32 5e 3f 2e bc 70 d2 77 b5 29 d8 d4 fb ||.^2^?..p.w.)...| -00000040 38 8c 05 40 e1 42 1a 25 44 79 fa a6 cc f6 50 5a |8..@.B.%Dy....PZ| -00000050 da e0 85 99 30 20 7d ee 04 fe ca |....0 }....| +00000000 14 03 03 00 01 01 16 03 03 00 50 a4 84 15 44 2e |..........P...D.| +00000010 6e e3 20 8d 7c a0 e4 85 36 7b a6 19 35 38 52 d0 |n. .|...6{..58R.| +00000020 bf 47 7e b4 09 a7 5b 5b e6 7c ad 4a b0 56 0a 28 |.G~...[[.|.J.V.(| +00000030 50 ef 94 89 8b 54 80 06 7a d8 b2 5d 75 ab e2 ff |P....T..z..]u...| +00000040 b1 6c 11 60 d2 0d 06 af bf 45 fd d8 5a 7b 2d 9c |.l.`.....E..Z{-.| +00000050 7c a1 b7 5e 4c 77 c9 ed 56 f0 68 ||..^Lw..V.h| >>> Flow 5 (client to server) 00000000 17 03 03 00 40 00 00 00 00 00 00 00 00 00 00 00 |....@...........| -00000010 00 00 00 00 00 cb cb 98 55 3f 17 18 42 7b 52 0c |........U?..B{R.| -00000020 6f 6c 50 87 b1 af ef 25 ac a5 24 4a d2 bc 39 33 |olP....%..$J..93| -00000030 29 81 c0 4f cf 20 8f 0c 4c a8 64 5f 97 4d da f4 |)..O. ..L.d_.M..| -00000040 89 7c 28 f3 d4 15 03 03 00 40 00 00 00 00 00 00 |.|(......@......| -00000050 00 00 00 00 00 00 00 00 00 00 6b c5 03 a6 9b 87 |..........k.....| -00000060 ac df 05 8d 79 3c 46 12 70 3a 1d a0 d0 29 7c 2a |....y.........PS..K|| +00000080 2a e8 e9 91 64 81 5a f4 43 f3 |*...d.Z.C.| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-ECDHE-ECDSA-AES256-GCM-SHA384 b/libgo/go/crypto/tls/testdata/Client-TLSv12-ECDHE-ECDSA-AES256-GCM-SHA384 index 85f460741c7..70608d8e472 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv12-ECDHE-ECDSA-AES256-GCM-SHA384 +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-ECDHE-ECDSA-AES256-GCM-SHA384 @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 03 00 59 02 00 00 55 03 03 93 2e 79 54 e7 |....Y...U....yT.| -00000010 e4 ce 82 cd 46 2b d1 99 d2 ba c7 37 1e f5 86 2f |....F+.....7.../| -00000020 6c 7d b1 10 e1 98 03 b1 93 a9 d9 20 c2 b6 55 f9 |l}......... ..U.| -00000030 d0 b3 65 3e 99 33 4c a4 5d a3 58 8b b4 ee c3 91 |..e>.3L.].X.....| -00000040 80 34 1c 07 c2 b9 9c bf e4 c0 bd f2 c0 2c 00 00 |.4...........,..| +00000000 16 03 03 00 59 02 00 00 55 03 03 97 16 31 62 59 |....Y...U....1bY| +00000010 8f a6 1c c4 b2 65 e5 d3 85 92 16 5e 52 06 03 9f |.....e.....^R...| +00000020 5a 20 35 3f c2 68 a7 3f 40 18 44 20 d1 5f 9f a0 |Z 5?.h.?@.D ._..| +00000030 2c f9 83 69 98 2f 3f ff ad 1c d8 bc ba 36 33 a7 |,..i./?......63.| +00000040 72 8e a4 a7 1e cb 42 db ef 3c ee b0 c0 2c 00 00 |r.....B..<...,..| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 03 02 0e 0b 00 02 0a 00 02 07 00 02 04 30 82 02 |.............0..| 00000070 00 30 82 01 62 02 09 00 b8 bf 2d 47 a0 d2 eb f4 |.0..b.....-G....| @@ -49,34 +55,34 @@ 00000240 13 83 0d 94 06 bb d4 37 7a f6 ec 7a c9 86 2e dd |.......7z..z....| 00000250 d7 11 69 7f 85 7c 56 de fb 31 78 2b e4 c7 78 0d |..i..|V..1x+..x.| 00000260 ae cb be 9e 4e 36 24 31 7b 6a 0f 39 95 12 07 8f |....N6$1{j.9....| -00000270 2a 16 03 03 00 b7 0c 00 00 b3 03 00 1d 20 d2 39 |*............ .9| -00000280 f6 fc 9c 40 cb ba 04 7c 37 ac df 95 5f 46 44 f4 |...@...|7..._FD.| -00000290 2b 0c 63 24 4e 95 1d 35 b3 68 ab 27 d1 5a 04 03 |+.c$N..5.h.'.Z..| -000002a0 00 8b 30 81 88 02 42 01 3e ff 73 74 01 f5 c8 32 |..0...B.>.st...2| -000002b0 31 f1 d5 0b 26 db 0c ef d0 c9 a7 aa 21 c8 0f 50 |1...&.......!..P| -000002c0 2f ce eb 41 ce 1e de 5d 29 8d c1 20 f2 d9 5d 39 |/..A...]).. ..]9| -000002d0 9d 1d c1 10 b1 a8 35 33 cc 58 f3 fd df 5d 7e fc |......53.X...]~.| -000002e0 ee 8b 15 02 03 2e b0 2b b1 02 42 00 e0 f1 cf e9 |.......+..B.....| -000002f0 e7 e2 1a a7 e1 3c 47 40 c4 fb b2 0d 15 47 4e 26 |.....>> Flow 3 (client to server) 00000000 16 03 03 00 25 10 00 00 21 20 2f e5 7d a3 47 cd |....%...! /.}.G.| 00000010 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 |bC.(.._.).0.....| 00000020 cf c2 ed 90 99 5f 58 cb 3b 74 14 03 03 00 01 01 |....._X.;t......| -00000030 16 03 03 00 28 00 00 00 00 00 00 00 00 5c 78 1d |....(........\x.| -00000040 a7 00 de 4e 5e 13 6a 1d 1d 82 28 f6 b6 8a 88 fe |...N^.j...(.....| -00000050 00 81 fe 04 95 a0 4e 93 e0 01 19 a3 6d |......N.....m| +00000030 16 03 03 00 28 00 00 00 00 00 00 00 00 1a c4 04 |....(...........| +00000040 eb 27 48 c1 ed 93 75 73 01 06 e3 55 70 6c c6 a0 |.'H...us...Upl..| +00000050 62 eb f5 a9 f3 8c a5 8a e3 e9 43 a4 2e |b.........C..| >>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 28 0a 61 1d 77 66 |..........(.a.wf| -00000010 67 ca 17 5a 94 fc bf 36 07 33 f8 7e 34 bc 65 aa |g..Z...6.3.~4.e.| -00000020 0f 28 7d 40 80 6e 33 99 83 09 02 78 b7 d1 cd 56 |.(}@.n3....x...V| -00000030 a7 f7 e5 |...| +00000000 14 03 03 00 01 01 16 03 03 00 28 6e bc 2f ed 32 |..........(n./.2| +00000010 53 00 47 5c 73 6c e3 86 38 e5 df e2 db 40 bf 31 |S.G\sl..8....@.1| +00000020 87 a5 33 fb af dd c9 c7 1c 98 7b ba 11 42 5e 0a |..3.......{..B^.| +00000030 f1 65 3b |.e;| >>> Flow 5 (client to server) -00000000 17 03 03 00 1e 00 00 00 00 00 00 00 01 56 48 af |.............VH.| -00000010 45 e1 76 a8 67 ef 80 cc 92 03 aa b5 88 fc 48 84 |E.v.g.........H.| -00000020 1b 81 39 15 03 03 00 1a 00 00 00 00 00 00 00 02 |..9.............| -00000030 5a 53 90 c9 25 a6 99 ce e7 09 74 97 63 68 fe 0c |ZS..%.....t.ch..| -00000040 5e 89 |^.| +00000000 17 03 03 00 1e 00 00 00 00 00 00 00 01 75 32 a8 |.............u2.| +00000010 ce 12 60 b4 d6 83 2c 4a e5 43 cb 6d c8 f3 f2 ee |..`...,J.C.m....| +00000020 8e 1e 2c 15 03 03 00 1a 00 00 00 00 00 00 00 02 |..,.............| +00000030 4e bb e9 81 44 f2 44 90 7c ac 8a 35 a3 ef e2 9b |N...D.D.|..5....| +00000040 d9 2b |.+| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-ECDHE-ECDSA-CHACHA20-POLY1305 b/libgo/go/crypto/tls/testdata/Client-TLSv12-ECDHE-ECDSA-CHACHA20-POLY1305 index 4d3fbfe8e6f..9acc6be054b 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv12-ECDHE-ECDSA-CHACHA20-POLY1305 +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-ECDHE-ECDSA-CHACHA20-POLY1305 @@ -1,17 +1,24 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 6b 01 00 00 67 03 03 00 00 00 00 00 |....k...g.......| +00000000 16 03 01 00 ce 01 00 00 ca 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 02 cc a9 |................| -00000030 01 00 00 3c 00 05 00 05 01 00 00 00 00 00 0a 00 |...<............| -00000040 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| -00000050 00 00 0d 00 12 00 10 04 01 04 03 05 01 05 03 06 |................| -00000060 01 06 03 02 01 02 03 ff 01 00 01 00 00 12 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 08 cc a9 |................| +00000050 13 01 13 03 13 02 01 00 00 79 00 05 00 05 01 00 |.........y......| +00000060 00 00 00 00 0a 00 0a 00 08 00 1d 00 17 00 18 00 |................| +00000070 19 00 0b 00 02 01 00 00 0d 00 18 00 16 08 04 08 |................| +00000080 05 08 06 04 01 04 03 05 01 05 03 06 01 06 03 02 |................| +00000090 01 02 03 ff 01 00 01 00 00 12 00 00 00 2b 00 09 |.............+..| +000000a0 08 03 04 03 03 03 02 03 01 00 33 00 26 00 24 00 |..........3.&.$.| +000000b0 1d 00 20 2f e5 7d a3 47 cd 62 43 15 28 da ac 5f |.. /.}.G.bC.(.._| +000000c0 bb 29 07 30 ff f6 84 af c4 cf c2 ed 90 99 5f 58 |.).0.........._X| +000000d0 cb 3b 74 |.;t| >>> Flow 2 (server to client) -00000000 16 03 03 00 59 02 00 00 55 03 03 3c 9c e9 fb 22 |....Y...U..<..."| -00000010 8b 32 cb 0d 56 1d a7 a2 c7 c5 d4 41 3d 9f 84 1b |.2..V......A=...| -00000020 26 50 b6 a3 fa f2 c5 20 0d f9 a6 20 38 86 ba 26 |&P..... ... 8..&| -00000030 db 6e d9 ab 3c 73 ec d8 34 56 d1 f2 d3 60 42 9a |.n..>> Flow 3 (client to server) 00000000 16 03 03 00 25 10 00 00 21 20 2f e5 7d a3 47 cd |....%...! /.}.G.| 00000010 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 |bC.(.._.).0.....| 00000020 cf c2 ed 90 99 5f 58 cb 3b 74 14 03 03 00 01 01 |....._X.;t......| -00000030 16 03 03 00 20 6e 2a ec f4 3a e8 88 99 f1 77 94 |.... n*..:....w.| -00000040 b3 a2 c5 3a 59 c2 9a f5 4a fb 89 e4 51 1a 54 a4 |...:Y...J...Q.T.| -00000050 72 d9 54 99 c3 |r.T..| +00000030 16 03 03 00 20 51 20 c3 d5 2d 48 50 98 1a 00 5c |.... Q ..-HP...\| +00000040 35 83 1d c6 22 8d a3 aa 2b 3a ac bf 68 51 a8 9f |5..."...+:..hQ..| +00000050 23 4b c7 91 df |#K...| >>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 20 be 1a 60 4e 4a |.......... ..`NJ| -00000010 2d 81 19 6b 7c f2 80 15 18 9c 38 70 6d a3 49 88 |-..k|.....8pm.I.| -00000020 93 4b e8 cc 9f b2 0e cc ed 29 64 |.K.......)d| +00000000 14 03 03 00 01 01 16 03 03 00 20 09 1f 51 48 37 |.......... ..QH7| +00000010 b5 c7 d8 b3 8a 17 48 1d cc b7 32 5d 82 73 ad a2 |......H...2].s..| +00000020 db 4a dc 4a 0d 3b 0b 26 32 56 ee |.J.J.;.&2V.| >>> Flow 5 (client to server) -00000000 17 03 03 00 16 bd 4c d9 d3 ea d0 d3 4e db dc ea |......L.....N...| -00000010 ad e7 20 17 ec 36 04 29 a5 7c ab 15 03 03 00 12 |.. ..6.).|......| -00000020 7b e1 b6 9b fc f9 18 83 87 31 b3 02 e7 b2 e3 c6 |{........1......| -00000030 37 d8 |7.| +00000000 17 03 03 00 16 de 17 a1 32 d6 09 f3 0d 72 19 eb |........2....r..| +00000010 05 c6 41 f9 0f c6 f7 68 b9 f6 cf 15 03 03 00 12 |..A....h........| +00000020 79 da 43 1b 80 2b d1 46 81 f3 33 78 53 58 79 bc |y.C..+.F..3xSXy.| +00000030 df 51 |.Q| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-ECDHE-RSA-AES b/libgo/go/crypto/tls/testdata/Client-TLSv12-ECDHE-RSA-AES index 9cc3e8ffaa8..8feca539d88 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv12-ECDHE-RSA-AES +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-ECDHE-RSA-AES @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 03 00 59 02 00 00 55 03 03 66 3d ff 45 dc |....Y...U..f=.E.| -00000010 ea f8 4c 56 5d 55 71 63 c1 64 33 9f f5 09 aa 38 |..LV]Uqc.d3....8| -00000020 bd 13 27 d7 85 ed 0a b4 68 83 9a 20 98 69 c4 d9 |..'.....h.. .i..| -00000030 a1 46 f4 30 ed 4d ae 31 7b 3c 18 23 fa b5 b4 a1 |.F.0.M.1{<.#....| -00000040 74 98 34 7f b8 d0 00 e5 22 35 eb 4f c0 13 00 00 |t.4....."5.O....| +00000000 16 03 03 00 59 02 00 00 55 03 03 1c 68 c5 b0 f8 |....Y...U...h...| +00000010 30 5e df 4e ef 13 06 3c 38 33 bd 70 40 9c 90 cb |0^.N...<83.p@...| +00000020 80 bc 8e 68 af 8f c4 59 1e fd 0d 20 40 58 a4 e2 |...h...Y... @X..| +00000030 32 5a d7 19 11 6c d3 66 94 94 21 02 ca 42 ef 25 |2Z...l.f..!..B.%| +00000040 ce 51 d8 d3 70 07 4f 70 8d c2 8f 55 c0 13 00 00 |.Q..p.Op...U....| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 03 02 59 0b 00 02 55 00 02 52 00 02 4f 30 82 02 |..Y...U..R..O0..| 00000070 4b 30 82 01 b4 a0 03 02 01 02 02 09 00 e8 f0 9d |K0..............| @@ -54,38 +60,38 @@ 00000290 77 8d 0c 1c f1 0f a1 d8 40 83 61 c9 4c 72 2b 9d |w.......@.a.Lr+.| 000002a0 ae db 46 06 06 4d f4 c1 b3 3e c0 d1 bd 42 d4 db |..F..M...>...B..| 000002b0 fe 3d 13 60 84 5c 21 d3 3b e9 fa e7 16 03 03 00 |.=.`.\!.;.......| -000002c0 ac 0c 00 00 a8 03 00 1d 20 f1 a9 e3 69 c6 9b 08 |........ ...i...| -000002d0 76 5c 45 2f 7d 16 73 79 b2 c5 9f 01 05 13 74 56 |v\E/}.sy......tV| -000002e0 93 4a dd b2 db 97 61 f9 11 04 01 00 80 81 a1 58 |.J....a........X| -000002f0 99 41 95 ab 7b cc ac 46 e8 04 3e c9 2d 9c 66 63 |.A..{..F..>.-.fc| -00000300 0d 80 19 43 85 bc b5 cf d2 a4 db 9d 28 c2 f4 f7 |...C........(...| -00000310 fe a1 f3 8f 6b e3 b5 6e e2 c2 e2 ac b9 0f f8 8d |....k..n........| -00000320 29 d2 ba 46 dc 10 ae c2 f3 0f b0 8f 1c e6 22 54 |)..F.........."T| -00000330 84 9f 10 c9 a5 ae 53 43 15 61 eb 0c ad 49 78 47 |......SC.a...IxG| -00000340 69 f9 52 9e 58 23 dc df d7 92 0d f5 50 b2 43 44 |i.R.X#......P.CD| -00000350 fe 8b 8b b3 ed 69 e7 15 9c 10 20 51 67 bd b9 40 |.....i.... Qg..@| -00000360 0e 0a f9 65 bf e7 bf 5d 33 5c 71 3d 4c 16 03 03 |...e...]3\q=L...| +000002c0 ac 0c 00 00 a8 03 00 1d 20 5a a4 2f e5 a1 8d 85 |........ Z./....| +000002d0 b5 4e f8 ac 27 83 77 b5 f5 ec c7 0a 92 39 a3 9e |.N..'.w......9..| +000002e0 31 7f e7 10 8f ac 56 07 74 08 04 00 80 6c 8c 2e |1.....V.t....l..| +000002f0 e8 7c d9 a6 d3 e9 bc 74 20 6a ad 01 80 ca 44 0c |.|.....t j....D.| +00000300 14 5d da 64 bd a3 32 07 03 2c 0a cf 87 56 af 01 |.].d..2..,...V..| +00000310 32 4c 46 df c7 3b 34 56 a6 7a f6 1c 43 fb f0 43 |2LF..;4V.z..C..C| +00000320 54 7c c8 47 0b 02 8e 2d 07 e8 bc 4c b2 9e ea 1d |T|.G...-...L....| +00000330 2b 29 9b e4 5d 5f ee 8a 4a 50 eb ec b7 09 68 e4 |+)..]_..JP....h.| +00000340 c1 99 6a 2d b9 d6 11 b2 9f d9 ee 13 ee 2e b3 d2 |..j-............| +00000350 1e be a0 6a 13 86 f0 53 7f aa 60 8e 87 5f ab 5d |...j...S..`.._.]| +00000360 f1 5a a4 1f 0b 85 b1 31 5f 2f af e9 7a 16 03 03 |.Z.....1_/..z...| 00000370 00 04 0e 00 00 00 |......| >>> Flow 3 (client to server) 00000000 16 03 03 00 25 10 00 00 21 20 2f e5 7d a3 47 cd |....%...! /.}.G.| 00000010 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 |bC.(.._.).0.....| 00000020 cf c2 ed 90 99 5f 58 cb 3b 74 14 03 03 00 01 01 |....._X.;t......| 00000030 16 03 03 00 40 00 00 00 00 00 00 00 00 00 00 00 |....@...........| -00000040 00 00 00 00 00 8a cb 7f 37 ba e5 13 2b db f4 15 |........7...+...| -00000050 97 6e b5 08 7b 89 16 21 f8 45 1b ef df 17 e0 ad |.n..{..!.E......| -00000060 44 12 39 4a e6 fb 78 9d aa ab 8a 95 2a 02 1d 74 |D.9J..x.....*..t| -00000070 25 f1 3d 38 21 |%.=8!| +00000040 00 00 00 00 00 d8 4d 17 e4 39 b7 4e 96 d1 1f 75 |......M..9.N...u| +00000050 db 2c 1d df b9 72 c0 c8 5c b3 22 75 98 81 82 67 |.,...r..\."u...g| +00000060 26 2c 45 d3 f0 34 0f 21 0a dd 6b 99 f8 82 70 3c |&,E..4.!..k...p<| +00000070 f3 7d 6a 15 91 |.}j..| >>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 40 1c 73 dd bb 45 |..........@.s..E| -00000010 89 89 e4 a9 05 db 10 5d 22 20 75 c7 b7 82 c5 64 |.......]" u....d| -00000020 2e 30 70 fc 0c a7 a8 c0 cb da ab 60 1e 68 12 bc |.0p........`.h..| -00000030 47 68 87 01 00 96 e1 f4 a1 a3 20 d1 05 31 7f 79 |Gh........ ..1.y| -00000040 28 36 f9 5c 24 a7 ba 68 b0 b6 e2 |(6.\$..h...| +00000000 14 03 03 00 01 01 16 03 03 00 40 27 83 f0 1d 2e |..........@'....| +00000010 f9 99 0e 36 76 7f 1e 8f 67 5d a8 26 27 c7 ad a1 |...6v...g].&'...| +00000020 9f 51 ab d8 2e c8 1c 62 a3 01 b6 f3 6a 95 69 5f |.Q.....b....j.i_| +00000030 5b 09 eb d1 e6 19 76 72 4a 67 26 01 78 89 ac 77 |[.....vrJg&.x..w| +00000040 e3 5c 7d 5b 17 79 a7 e4 19 bc 1a |.\}[.y.....| >>> Flow 5 (client to server) 00000000 17 03 03 00 30 00 00 00 00 00 00 00 00 00 00 00 |....0...........| -00000010 00 00 00 00 00 5d f7 4e 68 f6 93 58 4d 14 ae 10 |.....].Nh..XM...| -00000020 14 93 a4 01 58 59 b2 cf 18 da 91 13 5d be da 9e |....XY......]...| -00000030 12 a4 2c 02 f9 15 03 03 00 30 00 00 00 00 00 00 |..,......0......| -00000040 00 00 00 00 00 00 00 00 00 00 71 41 f1 68 4e 97 |..........qA.hN.| -00000050 b6 30 45 8b b9 89 4c 95 04 da 3e cb 4c ab 05 41 |.0E...L...>.L..A| -00000060 65 af 4e 60 91 34 8b 07 a3 10 |e.N`.4....| +00000010 00 00 00 00 00 24 63 76 ce f0 2a 88 0f 9b 51 b7 |.....$cv..*...Q.| +00000020 15 86 74 ac c9 72 88 7a 26 34 ff c5 ec bb a8 6d |..t..r.z&4.....m| +00000030 44 97 00 3f ff 15 03 03 00 30 00 00 00 00 00 00 |D..?.....0......| +00000040 00 00 00 00 00 00 00 00 00 00 f4 9d 5b 90 05 e6 |............[...| +00000050 42 af 3c 4c 86 d8 ba d5 b7 88 8e ec 8c 07 24 5e |B.>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 03 00 59 02 00 00 55 03 03 6a 17 b0 7f 77 |....Y...U..j...w| -00000010 da 35 bb 45 c1 43 37 52 59 4d 8f 61 1f f8 77 dc |.5.E.C7RYM.a..w.| -00000020 fd 9d 55 5d a7 7f 58 4f dd 3d 42 20 cf e2 65 8f |..U]..XO.=B ..e.| -00000030 7a b8 d3 2c 99 cc 31 2f d7 fa b2 0b 34 2c 72 7e |z..,..1/....4,r~| -00000040 86 a1 c6 e7 b7 55 26 1f 9a 69 43 63 c0 27 00 00 |.....U&..iCc.'..| +00000000 16 03 03 00 59 02 00 00 55 03 03 9a 06 bc 4a 08 |....Y...U.....J.| +00000010 7c e9 b0 32 64 21 d8 bc 41 77 d0 9f a2 0e 9a d4 ||..2d!..Aw......| +00000020 a8 ef ec 18 b7 8b a9 20 27 0a 85 20 46 c0 6b 77 |....... '.. F.kw| +00000030 56 12 53 90 e4 36 72 c4 cb b8 eb 79 6c ed e8 53 |V.S..6r....yl..S| +00000040 c4 36 48 89 fc 3f ff 07 99 47 2d 9e c0 27 00 00 |.6H..?...G-..'..| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 03 02 59 0b 00 02 55 00 02 52 00 02 4f 30 82 02 |..Y...U..R..O0..| 00000070 4b 30 82 01 b4 a0 03 02 01 02 02 09 00 e8 f0 9d |K0..............| @@ -54,42 +60,42 @@ 00000290 77 8d 0c 1c f1 0f a1 d8 40 83 61 c9 4c 72 2b 9d |w.......@.a.Lr+.| 000002a0 ae db 46 06 06 4d f4 c1 b3 3e c0 d1 bd 42 d4 db |..F..M...>...B..| 000002b0 fe 3d 13 60 84 5c 21 d3 3b e9 fa e7 16 03 03 00 |.=.`.\!.;.......| -000002c0 ac 0c 00 00 a8 03 00 1d 20 35 8c 3a f9 8a 04 e7 |........ 5.:....| -000002d0 2e dd 2c 82 05 62 da 91 3f 60 2b 0d a8 4d ec 50 |..,..b..?`+..M.P| -000002e0 d1 b1 e0 f6 34 38 e5 7c 11 04 01 00 80 97 25 9e |....48.|......%.| -000002f0 22 b3 40 b2 b9 ec 0f 0e 44 92 11 82 06 70 26 23 |".@.....D....p&#| -00000300 38 b5 fe de 08 32 cd 8e e5 d7 19 3a ba 40 76 74 |8....2.....:.@vt| -00000310 22 cf 19 dd cc 33 cf 34 a9 3a d4 82 e8 92 79 23 |"....3.4.:....y#| -00000320 c1 14 10 79 08 65 43 e9 02 93 32 c8 5f a4 68 ed |...y.eC...2._.h.| -00000330 24 b7 aa 4c 71 4e 01 63 74 2a f5 36 1a d0 15 95 |$..LqN.ct*.6....| -00000340 10 9c 46 87 75 16 55 88 b7 38 14 10 1c b8 34 84 |..F.u.U..8....4.| -00000350 4f 4a 99 0f 17 95 26 a4 31 e3 8f 71 5b 92 f3 27 |OJ....&.1..q[..'| -00000360 df d7 c4 6d 34 8d 14 e7 8e 62 ae 27 12 16 03 03 |...m4....b.'....| +000002c0 ac 0c 00 00 a8 03 00 1d 20 9e a1 5f 87 14 ff b2 |........ .._....| +000002d0 0c b8 82 0d 24 d8 bb 98 6d 3a ca 09 0b 6d 94 98 |....$...m:...m..| +000002e0 16 20 ed 31 0e 54 23 d5 47 08 04 00 80 4a e0 aa |. .1.T#.G....J..| +000002f0 d0 e9 cb 75 f0 c0 6e 2d 74 8f c9 91 d9 32 98 22 |...u..n-t....2."| +00000300 99 ef 91 77 41 80 c6 83 11 9a ed 55 61 fd b7 58 |...wA......Ua..X| +00000310 70 7a a6 ce e1 28 40 7d 94 8a 96 64 7f f1 b4 97 |pz...(@}...d....| +00000320 db 83 2c 77 55 f4 38 c6 4b 9a 77 74 9d 6b ae 06 |..,wU.8.K.wt.k..| +00000330 b6 f0 07 61 7a e1 dc d9 e3 c4 32 5c c5 91 23 8d |...az.....2\..#.| +00000340 a3 53 db 37 4d ee e4 65 ef 58 42 af 63 72 06 5c |.S.7M..e.XB.cr.\| +00000350 4e aa f5 07 4c bc b3 1a 00 82 9f 72 34 64 52 e7 |N...L......r4dR.| +00000360 1f 85 7a c3 36 3f 8d 4e 53 89 7b c2 d3 16 03 03 |..z.6?.NS.{.....| 00000370 00 04 0e 00 00 00 |......| >>> Flow 3 (client to server) 00000000 16 03 03 00 25 10 00 00 21 20 2f e5 7d a3 47 cd |....%...! /.}.G.| 00000010 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 |bC.(.._.).0.....| 00000020 cf c2 ed 90 99 5f 58 cb 3b 74 14 03 03 00 01 01 |....._X.;t......| 00000030 16 03 03 00 50 00 00 00 00 00 00 00 00 00 00 00 |....P...........| -00000040 00 00 00 00 00 6d a8 40 a4 2f 8d ea bb a0 fb f3 |.....m.@./......| -00000050 a7 38 78 1b 25 57 5c 8a c8 e6 e6 be e2 78 78 c1 |.8x.%W\......xx.| -00000060 dc ec ca 48 9a 85 56 6b da 40 bd 0b cc 0a aa 08 |...H..Vk.@......| -00000070 02 31 57 31 c2 57 ff ac 57 7e e5 08 3a 14 b0 11 |.1W1.W..W~..:...| -00000080 fb 46 83 db 37 |.F..7| +00000040 00 00 00 00 00 ec b0 fe b3 cf eb b0 61 c3 77 f0 |............a.w.| +00000050 ad 63 39 5f 7b 17 0e d7 07 7f cb ea 65 0c b0 8b |.c9_{.......e...| +00000060 45 ab 39 c4 d9 06 c7 3b 2e 98 a2 1f c7 e8 e7 e2 |E.9....;........| +00000070 56 a9 6a b3 75 5e c9 27 66 16 af 0e e4 b4 3d 80 |V.j.u^.'f.....=.| +00000080 8b 1c fd ff 34 |....4| >>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 50 b7 d0 f9 1f 96 |..........P.....| -00000010 64 b8 99 14 da c9 ae d9 40 ff 8f 3f 69 9d bf 56 |d.......@..?i..V| -00000020 ac 9d 15 d7 84 82 bb e9 1e f3 15 1a b3 3a 96 58 |.............:.X| -00000030 9f a7 9e 7a fb 50 5f f2 9d 46 8d ed fc cb 3b 2c |...z.P_..F....;,| -00000040 6e fd 5a fc d5 8f 8b 11 f8 28 3d c7 e2 36 c4 1b |n.Z......(=..6..| -00000050 da ce ec b2 89 f1 80 a5 ec 7f a2 |...........| +00000000 14 03 03 00 01 01 16 03 03 00 50 8b 01 85 06 02 |..........P.....| +00000010 9c 71 ac 29 4c 4c 54 28 26 f7 1b d0 81 17 2c 95 |.q.)LLT(&.....,.| +00000020 01 73 45 fe f3 1e bd 43 56 83 50 84 ad 13 9c 3f |.sE....CV.P....?| +00000030 2e bc 2b 25 67 ce 76 cc e7 4d cc bb 8f 2e 09 3b |..+%g.v..M.....;| +00000040 48 3b 9c c5 fd 17 73 01 18 41 02 46 c1 9c fe 8f |H;....s..A.F....| +00000050 76 a4 6b 1d 6d 2c 6d c1 73 55 fd |v.k.m,m.sU.| >>> Flow 5 (client to server) 00000000 17 03 03 00 40 00 00 00 00 00 00 00 00 00 00 00 |....@...........| -00000010 00 00 00 00 00 78 0e 09 23 37 5d ad e5 97 da 83 |.....x..#7].....| -00000020 93 90 d8 dc 96 5a 61 85 8c 8b e8 35 46 46 ac ac |.....Za....5FF..| -00000030 42 fa ee e1 88 41 bd 1c 9c 6a 0c 00 29 cc a4 56 |B....A...j..)..V| -00000040 40 27 8f 6c e3 15 03 03 00 40 00 00 00 00 00 00 |@'.l.....@......| -00000050 00 00 00 00 00 00 00 00 00 00 51 8d 6f 62 be c4 |..........Q.ob..| -00000060 aa d0 f1 83 04 67 7e c2 0a 8b 50 32 71 17 87 95 |.....g~...P2q...| -00000070 a6 31 f6 3d 3f a8 14 00 5d e0 5b c1 db b4 fa 79 |.1.=?...].[....y| -00000080 01 0f 63 0b fe 8c c9 e1 b4 6b |..c......k| +00000010 00 00 00 00 00 ed 8d fb 10 4e 11 3f 61 35 bd 9c |.........N.?a5..| +00000020 40 16 78 f2 06 68 65 d0 06 85 8e 31 f7 8e d6 b0 |@.x..he....1....| +00000030 a4 bb e6 03 f6 2d 36 12 4e b7 96 4b 42 b2 22 9d |.....-6.N..KB.".| +00000040 93 92 10 8b 0a 15 03 03 00 40 00 00 00 00 00 00 |.........@......| +00000050 00 00 00 00 00 00 00 00 00 00 4c 59 01 7a 1e 64 |..........LY.z.d| +00000060 c9 2a d4 a6 d6 e1 64 a2 e9 7d c0 29 32 53 68 e7 |.*....d..}.)2Sh.| +00000070 a0 66 68 87 70 b5 c3 38 cc ac 18 8b bd 3a 50 85 |.fh.p..8.....:P.| +00000080 d9 9a ca 67 c7 13 5c 74 76 68 |...g..\tvh| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-ECDHE-RSA-CHACHA20-POLY1305 b/libgo/go/crypto/tls/testdata/Client-TLSv12-ECDHE-RSA-CHACHA20-POLY1305 index 0ddfbdc0d83..7a015de464e 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv12-ECDHE-RSA-CHACHA20-POLY1305 +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-ECDHE-RSA-CHACHA20-POLY1305 @@ -1,17 +1,24 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 6b 01 00 00 67 03 03 00 00 00 00 00 |....k...g.......| +00000000 16 03 01 00 ce 01 00 00 ca 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 02 cc a8 |................| -00000030 01 00 00 3c 00 05 00 05 01 00 00 00 00 00 0a 00 |...<............| -00000040 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| -00000050 00 00 0d 00 12 00 10 04 01 04 03 05 01 05 03 06 |................| -00000060 01 06 03 02 01 02 03 ff 01 00 01 00 00 12 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 08 cc a8 |................| +00000050 13 01 13 03 13 02 01 00 00 79 00 05 00 05 01 00 |.........y......| +00000060 00 00 00 00 0a 00 0a 00 08 00 1d 00 17 00 18 00 |................| +00000070 19 00 0b 00 02 01 00 00 0d 00 18 00 16 08 04 08 |................| +00000080 05 08 06 04 01 04 03 05 01 05 03 06 01 06 03 02 |................| +00000090 01 02 03 ff 01 00 01 00 00 12 00 00 00 2b 00 09 |.............+..| +000000a0 08 03 04 03 03 03 02 03 01 00 33 00 26 00 24 00 |..........3.&.$.| +000000b0 1d 00 20 2f e5 7d a3 47 cd 62 43 15 28 da ac 5f |.. /.}.G.bC.(.._| +000000c0 bb 29 07 30 ff f6 84 af c4 cf c2 ed 90 99 5f 58 |.).0.........._X| +000000d0 cb 3b 74 |.;t| >>> Flow 2 (server to client) -00000000 16 03 03 00 59 02 00 00 55 03 03 34 5a e3 34 22 |....Y...U..4Z.4"| -00000010 a6 72 28 26 73 2d 3c 9e f1 39 88 13 07 dd 75 7c |.r(&s-<..9....u|| -00000020 00 58 04 bc 18 28 d0 75 4d 80 96 20 46 c7 3c b7 |.X...(.uM.. F.<.| -00000030 05 16 0d ef 32 51 ab 46 47 95 4b 49 e8 cc 8b 47 |....2Q.FG.KI...G| -00000040 d2 41 e8 05 9a de 5a c3 05 7d d4 b2 cc a8 00 00 |.A....Z..}......| +00000000 16 03 03 00 59 02 00 00 55 03 03 94 bf 96 6e 08 |....Y...U.....n.| +00000010 c5 59 6f b5 bc 22 4b 73 4a ba 5f f4 ea 2b 77 1d |.Yo.."KsJ._..+w.| +00000020 f4 6d 45 46 51 3d 0b 60 d8 6b 4e 20 00 4b 00 f8 |.mEFQ=.`.kN .K..| +00000030 a2 81 c9 1c 44 4f 90 73 ea c7 88 70 d9 56 d9 27 |....DO.s...p.V.'| +00000040 c5 0e e2 42 f0 bb 33 73 08 f1 12 ed cc a8 00 00 |...B..3s........| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 03 02 59 0b 00 02 55 00 02 52 00 02 4f 30 82 02 |..Y...U..R..O0..| 00000070 4b 30 82 01 b4 a0 03 02 01 02 02 09 00 e8 f0 9d |K0..............| @@ -51,31 +58,31 @@ 00000290 77 8d 0c 1c f1 0f a1 d8 40 83 61 c9 4c 72 2b 9d |w.......@.a.Lr+.| 000002a0 ae db 46 06 06 4d f4 c1 b3 3e c0 d1 bd 42 d4 db |..F..M...>...B..| 000002b0 fe 3d 13 60 84 5c 21 d3 3b e9 fa e7 16 03 03 00 |.=.`.\!.;.......| -000002c0 ac 0c 00 00 a8 03 00 1d 20 1a 1c c4 a1 b6 04 70 |........ ......p| -000002d0 b8 b9 cd 26 b1 c0 74 56 6c b5 5c ff e7 20 79 74 |...&..tVl.\.. yt| -000002e0 f7 84 d5 8d 62 57 fa 40 49 04 01 00 80 1b d8 2a |....bW.@I......*| -000002f0 60 af a6 8c 2d 7e 23 be b8 53 c8 8e 32 b2 29 49 |`...-~#..S..2.)I| -00000300 8c 54 c5 fc 7b 2e e4 b9 6c c3 26 21 84 89 2e cd |.T..{...l.&!....| -00000310 7c c1 e0 1e 16 dc 8f 76 1e c2 65 f0 c2 21 6e f7 ||......v..e..!n.| -00000320 cf 91 f9 d5 c5 bf 33 5e 4f bb 8a 85 86 dd 10 c0 |......3^O.......| -00000330 85 22 e6 c0 36 0b 67 48 10 0a 04 49 1d dd aa 97 |."..6.gH...I....| -00000340 11 4f 80 f0 66 cd 82 85 e1 fa 0c b6 3d e7 bd 16 |.O..f.......=...| -00000350 20 82 cd cc 44 bb 67 47 2a db 9f 22 1b 9e cc 13 | ...D.gG*.."....| -00000360 e2 de d1 1d 9f 16 0e 6f 01 5e de f4 72 16 03 03 |.......o.^..r...| +000002c0 ac 0c 00 00 a8 03 00 1d 20 cd 60 09 2c c1 3b d6 |........ .`.,.;.| +000002d0 3b d1 c2 3c 9f 30 81 bb 6b 47 a3 cd 26 48 f4 41 |;..<.0..kG..&H.A| +000002e0 c0 d4 36 57 05 33 93 f8 75 08 04 00 80 9a 67 4b |..6W.3..u.....gK| +000002f0 36 41 f9 c1 5c 80 67 9d 0d bc 64 f1 0d 08 e1 9f |6A..\.g...d.....| +00000300 85 88 44 e3 bc c9 b7 f4 86 ec 5c 79 e6 2c ac 07 |..D.......\y.,..| +00000310 e9 cd 6a 7e 68 41 67 71 34 cb c5 13 7c ec 1a 73 |..j~hAgq4...|..s| +00000320 f8 30 da 08 d0 14 c6 4b e4 11 ac c6 34 f9 2f ca |.0.....K....4./.| +00000330 b4 81 35 76 17 9e 7b 4c f3 f7 ac 6d d3 d8 f7 7c |..5v..{L...m...|| +00000340 70 b8 36 fa cc 85 fb 15 8e 82 c6 50 0e 90 c0 39 |p.6........P...9| +00000350 13 d9 02 b1 ae 17 ea 63 c4 e8 21 c2 c0 eb 5c 63 |.......c..!...\c| +00000360 e4 43 c5 1e ae 01 ee 64 23 42 b2 2a 52 16 03 03 |.C.....d#B.*R...| 00000370 00 04 0e 00 00 00 |......| >>> Flow 3 (client to server) 00000000 16 03 03 00 25 10 00 00 21 20 2f e5 7d a3 47 cd |....%...! /.}.G.| 00000010 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 |bC.(.._.).0.....| 00000020 cf c2 ed 90 99 5f 58 cb 3b 74 14 03 03 00 01 01 |....._X.;t......| -00000030 16 03 03 00 20 3a 2e f4 52 80 92 77 cb e3 54 43 |.... :..R..w..TC| -00000040 cb d5 ba c4 62 e4 77 81 eb fe fc f1 88 c6 e6 46 |....b.w........F| -00000050 7f d9 23 38 e4 |..#8.| +00000030 16 03 03 00 20 8f 97 a6 c4 c1 81 4e 87 8c 17 3a |.... ......N...:| +00000040 6b 85 ad 17 6c 5c 14 b6 84 6b 7e a8 c1 ed 2e 6b |k...l\...k~....k| +00000050 fc e8 8f 8b 84 |.....| >>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 20 21 4e a1 16 d0 |.......... !N...| -00000010 35 9f 19 c6 cc 64 64 f7 a0 25 13 3b 97 75 81 9f |5....dd..%.;.u..| -00000020 2f d3 30 d9 02 ad c7 72 8d 32 20 |/.0....r.2 | +00000000 14 03 03 00 01 01 16 03 03 00 20 51 59 b7 f0 cf |.......... QY...| +00000010 07 d4 9a 45 15 b6 2f dd 03 5e 46 f9 c8 87 dc 99 |...E../..^F.....| +00000020 d2 56 cd 95 f9 3e 2e 42 19 2e e3 |.V...>.B...| >>> Flow 5 (client to server) -00000000 17 03 03 00 16 af 57 12 aa e5 9b e4 c3 54 d9 a8 |......W......T..| -00000010 af ce 8c 28 39 ba df 5d 71 9d 0f 15 03 03 00 12 |...(9..]q.......| -00000020 69 3f 95 18 31 04 5b 17 2a cf 53 9c ca 2d 07 7f |i?..1.[.*.S..-..| -00000030 c1 f8 |..| +00000000 17 03 03 00 16 6d 16 3b 26 a8 60 d8 2c 9f 08 42 |.....m.;&.`.,..B| +00000010 51 bb 2a 58 c3 3b 42 cb 59 46 02 15 03 03 00 12 |Q.*X.;B.YF......| +00000020 1e c6 5e 68 40 58 9c df 5e 11 a3 c2 1e 50 11 d4 |..^h@X..^....P..| +00000030 ff 17 |..| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-ExportKeyingMaterial b/libgo/go/crypto/tls/testdata/Client-TLSv12-ExportKeyingMaterial index 29964f0d407..1a97ddacf15 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv12-ExportKeyingMaterial +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-ExportKeyingMaterial @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 03 00 59 02 00 00 55 03 03 fc 37 e8 a4 e3 |....Y...U...7...| -00000010 5d da a5 95 0b fb e0 c3 d9 78 8b 91 bd 5c 1c b1 |]........x...\..| -00000020 c6 8d 69 62 f9 c6 0f 12 da 46 ba 20 34 a3 22 f2 |..ib.....F. 4.".| -00000030 a9 f7 da 3a c4 5f 6f f7 4b be df 03 e5 b6 d0 ff |...:._o.K.......| -00000040 ca 54 68 59 57 53 63 a5 2f 91 1d 1e cc a8 00 00 |.ThYWSc./.......| +00000000 16 03 03 00 59 02 00 00 55 03 03 de e9 5f 9c 20 |....Y...U...._. | +00000010 c7 37 0d ba e1 2c 21 ad 4b 8a 10 fe 66 4c c2 88 |.7...,!.K...fL..| +00000020 87 fa 43 aa 42 ce e4 ca d8 c2 2d 20 9c cc ef b1 |..C.B.....- ....| +00000030 48 e2 9a e8 5a 61 16 6a 64 dd e9 6e d1 13 06 44 |H...Za.jd..n...D| +00000040 c2 f6 9f e7 68 d3 cc 82 67 54 a0 66 cc a8 00 00 |....h...gT.f....| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 03 02 59 0b 00 02 55 00 02 52 00 02 4f 30 82 02 |..Y...U..R..O0..| 00000070 4b 30 82 01 b4 a0 03 02 01 02 02 09 00 e8 f0 9d |K0..............| @@ -54,31 +60,31 @@ 00000290 77 8d 0c 1c f1 0f a1 d8 40 83 61 c9 4c 72 2b 9d |w.......@.a.Lr+.| 000002a0 ae db 46 06 06 4d f4 c1 b3 3e c0 d1 bd 42 d4 db |..F..M...>...B..| 000002b0 fe 3d 13 60 84 5c 21 d3 3b e9 fa e7 16 03 03 00 |.=.`.\!.;.......| -000002c0 ac 0c 00 00 a8 03 00 1d 20 cc e9 71 f5 36 52 5a |........ ..q.6RZ| -000002d0 d8 19 ce e4 0d 41 8d a6 9b f3 19 56 8d 81 fe 84 |.....A.....V....| -000002e0 71 2f d7 fb e7 86 23 4c 04 04 01 00 80 90 da 29 |q/....#L.......)| -000002f0 79 18 70 e8 81 66 83 70 97 f1 d1 5f dc 1d a2 0a |y.p..f.p..._....| -00000300 94 d8 e8 b8 32 4f 03 34 0b af e8 2d 94 b2 eb 30 |....2O.4...-...0| -00000310 57 b5 a5 92 9e 9a df a6 bc 3e 25 0e 18 cb ea 84 |W........>%.....| -00000320 34 89 08 8a d4 be 16 a3 5d 3a 7d 32 10 9b 41 1c |4.......]:}2..A.| -00000330 2a 1e 05 68 5f fa d9 56 30 b6 44 08 b0 a5 25 5a |*..h_..V0.D...%Z| -00000340 c3 60 c0 9a 98 fd 48 5f a4 18 d0 15 0f fb b3 ea |.`....H_........| -00000350 b9 c4 e3 c6 0c 27 51 64 01 de 65 78 c7 a0 57 df |.....'Qd..ex..W.| -00000360 9b de 2f 74 bc 72 e5 e0 57 7c 59 e6 ae 16 03 03 |../t.r..W|Y.....| +000002c0 ac 0c 00 00 a8 03 00 1d 20 30 ef c9 70 70 23 9c |........ 0..pp#.| +000002d0 b6 1c 35 b7 86 6c 9f 82 62 df e3 6e 47 6d 03 61 |..5..l..b..nGm.a| +000002e0 e6 98 5b ca 86 b9 58 e4 18 08 04 00 80 30 82 41 |..[...X......0.A| +000002f0 64 c8 03 a9 25 d8 b9 2f 9e a1 8d 6e 5b 1c b6 da |d...%../...n[...| +00000300 eb c0 63 2b 72 08 2b 50 2a 2e 4b 91 c1 9f fc df |..c+r.+P*.K.....| +00000310 87 6e 07 6c c5 38 24 02 b4 e8 c5 11 32 17 48 49 |.n.l.8$.....2.HI| +00000320 ce d3 3d d8 58 e6 be 1a fb c1 f2 2a 03 54 8f ae |..=.X......*.T..| +00000330 2a f7 84 2a 65 c3 b7 cd 80 64 b1 8c a8 25 ce 1c |*..*e....d...%..| +00000340 73 eb ae 42 7d 9c 87 72 fe f9 cf bd e1 36 ca bd |s..B}..r.....6..| +00000350 69 78 13 9f c8 16 03 9c 0a 02 1e f3 70 6b ed 38 |ix..........pk.8| +00000360 d8 a5 b6 8a 7e 33 7b 62 44 8b 5e 99 ef 16 03 03 |....~3{bD.^.....| 00000370 00 04 0e 00 00 00 |......| >>> Flow 3 (client to server) 00000000 16 03 03 00 25 10 00 00 21 20 2f e5 7d a3 47 cd |....%...! /.}.G.| 00000010 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 |bC.(.._.).0.....| 00000020 cf c2 ed 90 99 5f 58 cb 3b 74 14 03 03 00 01 01 |....._X.;t......| -00000030 16 03 03 00 20 92 0a 4e aa 2d b3 9b c8 b9 80 28 |.... ..N.-.....(| -00000040 f3 22 e2 57 15 ff a1 9a 33 9b e8 4c 5c dc f4 29 |.".W....3..L\..)| -00000050 7d 25 d7 df bc |}%...| +00000030 16 03 03 00 20 04 8f 3f 72 37 39 12 c4 21 b2 45 |.... ..?r79..!.E| +00000040 5d 90 b9 fa d2 24 70 5f 86 d4 8b 24 e6 af 6e 9f |]....$p_...$..n.| +00000050 71 41 17 a8 54 |qA..T| >>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 20 91 85 06 0e 00 |.......... .....| -00000010 ad 96 2e 1c a5 4d f7 63 f9 84 1c 6e da 54 0b e0 |.....M.c...n.T..| -00000020 44 37 6a 90 4c fd f5 e8 45 1d ce |D7j.L...E..| +00000000 14 03 03 00 01 01 16 03 03 00 20 b0 70 aa d3 44 |.......... .p..D| +00000010 df ef 57 0f bb 69 b3 09 70 1a ad b0 33 e5 97 8e |..W..i..p...3...| +00000020 bc 34 7f aa 27 a2 81 a3 08 7e b1 |.4..'....~.| >>> Flow 5 (client to server) -00000000 17 03 03 00 16 4c e8 8a e0 a6 95 f3 df 37 8a 2d |.....L.......7.-| -00000010 4f 11 ce a6 53 16 2c b0 bb c5 7f 15 03 03 00 12 |O...S.,.........| -00000020 4e 91 d8 67 c5 16 d2 4e cc b8 0a 00 76 91 68 7a |N..g...N....v.hz| -00000030 85 2e |..| +00000000 17 03 03 00 16 52 71 2d 1a 29 2c 84 b7 58 d2 b0 |.....Rq-.),..X..| +00000010 92 c3 64 7f 29 3a da d8 c4 7b 73 15 03 03 00 12 |..d.):...{s.....| +00000020 63 04 d5 2b 6c fc 35 82 bb ba ba 9b 01 a0 0c ac |c..+l.5.........| +00000030 2c 12 |,.| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-P256-ECDHE b/libgo/go/crypto/tls/testdata/Client-TLSv12-P256-ECDHE new file mode 100644 index 00000000000..819a061fb4f --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-P256-ECDHE @@ -0,0 +1,98 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 01 13 01 00 01 0f 03 03 00 00 00 00 00 |................| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 94 00 05 00 05 01 00 00 00 00 00 0a 00 |................| +00000090 04 00 02 00 17 00 0b 00 02 01 00 00 0d 00 18 00 |................| +000000a0 16 08 04 08 05 08 06 04 01 04 03 05 01 05 03 06 |................| +000000b0 01 06 03 02 01 02 03 ff 01 00 01 00 00 12 00 00 |................| +000000c0 00 2b 00 09 08 03 04 03 03 03 02 03 01 00 33 00 |.+............3.| +000000d0 47 00 45 00 17 00 41 04 1e 18 37 ef 0d 19 51 88 |G.E...A...7...Q.| +000000e0 35 75 71 b5 e5 54 5b 12 2e 8f 09 67 fd a7 24 20 |5uq..T[....g..$ | +000000f0 3e b2 56 1c ce 97 28 5e f8 2b 2d 4f 9e f1 07 9f |>.V...(^.+-O....| +00000100 6c 4b 5b 83 56 e2 32 42 e9 58 b6 d7 49 a6 b5 68 |lK[.V.2B.X..I..h| +00000110 1a 41 03 56 6b dc 5a 89 |.A.Vk.Z.| +>>> Flow 2 (server to client) +00000000 16 03 03 00 59 02 00 00 55 03 03 39 5a 55 c9 46 |....Y...U..9ZU.F| +00000010 87 68 62 04 99 88 9e 60 93 a3 79 c3 d6 e0 30 9f |.hb....`..y...0.| +00000020 e5 2b 70 df 81 1f 33 53 f5 89 91 20 ce 7b aa 43 |.+p...3S... .{.C| +00000030 a2 83 d7 6d 3f b9 86 38 1d 52 da 75 82 2b c6 05 |...m?..8.R.u.+..| +00000040 6f a4 e2 15 27 21 18 36 0d 04 ba 42 c0 2f 00 00 |o...'!.6...B./..| +00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| +00000060 03 02 59 0b 00 02 55 00 02 52 00 02 4f 30 82 02 |..Y...U..R..O0..| +00000070 4b 30 82 01 b4 a0 03 02 01 02 02 09 00 e8 f0 9d |K0..............| +00000080 3f e2 5b ea a6 30 0d 06 09 2a 86 48 86 f7 0d 01 |?.[..0...*.H....| +00000090 01 0b 05 00 30 1f 31 0b 30 09 06 03 55 04 0a 13 |....0.1.0...U...| +000000a0 02 47 6f 31 10 30 0e 06 03 55 04 03 13 07 47 6f |.Go1.0...U....Go| +000000b0 20 52 6f 6f 74 30 1e 17 0d 31 36 30 31 30 31 30 | Root0...1601010| +000000c0 30 30 30 30 30 5a 17 0d 32 35 30 31 30 31 30 30 |00000Z..25010100| +000000d0 30 30 30 30 5a 30 1a 31 0b 30 09 06 03 55 04 0a |0000Z0.1.0...U..| +000000e0 13 02 47 6f 31 0b 30 09 06 03 55 04 03 13 02 47 |..Go1.0...U....G| +000000f0 6f 30 81 9f 30 0d 06 09 2a 86 48 86 f7 0d 01 01 |o0..0...*.H.....| +00000100 01 05 00 03 81 8d 00 30 81 89 02 81 81 00 db 46 |.......0.......F| +00000110 7d 93 2e 12 27 06 48 bc 06 28 21 ab 7e c4 b6 a2 |}...'.H..(!.~...| +00000120 5d fe 1e 52 45 88 7a 36 47 a5 08 0d 92 42 5b c2 |]..RE.z6G....B[.| +00000130 81 c0 be 97 79 98 40 fb 4f 6d 14 fd 2b 13 8b c2 |....y.@.Om..+...| +00000140 a5 2e 67 d8 d4 09 9e d6 22 38 b7 4a 0b 74 73 2b |..g....."8.J.ts+| +00000150 c2 34 f1 d1 93 e5 96 d9 74 7b f3 58 9f 6c 61 3c |.4......t{.X.la<| +00000160 c0 b0 41 d4 d9 2b 2b 24 23 77 5b 1c 3b bd 75 5d |..A..++$#w[.;.u]| +00000170 ce 20 54 cf a1 63 87 1d 1e 24 c4 f3 1d 1a 50 8b |. T..c...$....P.| +00000180 aa b6 14 43 ed 97 a7 75 62 f4 14 c8 52 d7 02 03 |...C...ub...R...| +00000190 01 00 01 a3 81 93 30 81 90 30 0e 06 03 55 1d 0f |......0..0...U..| +000001a0 01 01 ff 04 04 03 02 05 a0 30 1d 06 03 55 1d 25 |.........0...U.%| +000001b0 04 16 30 14 06 08 2b 06 01 05 05 07 03 01 06 08 |..0...+.........| +000001c0 2b 06 01 05 05 07 03 02 30 0c 06 03 55 1d 13 01 |+.......0...U...| +000001d0 01 ff 04 02 30 00 30 19 06 03 55 1d 0e 04 12 04 |....0.0...U.....| +000001e0 10 9f 91 16 1f 43 43 3e 49 a6 de 6d b6 80 d7 9f |.....CC>I..m....| +000001f0 60 30 1b 06 03 55 1d 23 04 14 30 12 80 10 48 13 |`0...U.#..0...H.| +00000200 49 4d 13 7e 16 31 bb a3 01 d5 ac ab 6e 7b 30 19 |IM.~.1......n{0.| +00000210 06 03 55 1d 11 04 12 30 10 82 0e 65 78 61 6d 70 |..U....0...examp| +00000220 6c 65 2e 67 6f 6c 61 6e 67 30 0d 06 09 2a 86 48 |le.golang0...*.H| +00000230 86 f7 0d 01 01 0b 05 00 03 81 81 00 9d 30 cc 40 |.............0.@| +00000240 2b 5b 50 a0 61 cb ba e5 53 58 e1 ed 83 28 a9 58 |+[P.a...SX...(.X| +00000250 1a a9 38 a4 95 a1 ac 31 5a 1a 84 66 3d 43 d3 2d |..8....1Z..f=C.-| +00000260 d9 0b f2 97 df d3 20 64 38 92 24 3a 00 bc cf 9c |...... d8.$:....| +00000270 7d b7 40 20 01 5f aa d3 16 61 09 a2 76 fd 13 c3 |}.@ ._...a..v...| +00000280 cc e1 0c 5c ee b1 87 82 f1 6c 04 ed 73 bb b3 43 |...\.....l..s..C| +00000290 77 8d 0c 1c f1 0f a1 d8 40 83 61 c9 4c 72 2b 9d |w.......@.a.Lr+.| +000002a0 ae db 46 06 06 4d f4 c1 b3 3e c0 d1 bd 42 d4 db |..F..M...>...B..| +000002b0 fe 3d 13 60 84 5c 21 d3 3b e9 fa e7 16 03 03 00 |.=.`.\!.;.......| +000002c0 cd 0c 00 00 c9 03 00 17 41 04 76 c4 5d a9 b6 96 |........A.v.]...| +000002d0 aa 4c e2 26 30 ce 69 90 11 42 fe a4 56 4d 4b 1c |.L.&0.i..B..VMK.| +000002e0 5e 1f e1 23 10 c7 8b 52 5a 04 1f 32 85 98 6b d8 |^..#...RZ..2..k.| +000002f0 97 3a 7b 90 79 94 de f4 85 c8 c5 2a 05 b9 6d 79 |.:{.y......*..my| +00000300 6f fb f8 1e b8 ab b8 e9 c3 91 08 04 00 80 b9 00 |o...............| +00000310 a1 01 7d c7 fd 3e bc ba 44 42 64 68 21 7b b7 98 |..}..>..DBdh!{..| +00000320 c1 9f 17 a6 a1 a3 7f 9e 63 d7 ee b7 53 d4 7c 48 |........c...S.|H| +00000330 89 6e 20 0d 29 a1 b4 56 2c 83 7e d7 ab 3a 28 65 |.n .)..V,.~..:(e| +00000340 03 a1 be 6b 0d 89 39 c4 c9 fc fd 41 f0 bd c2 cb |...k..9....A....| +00000350 40 d5 54 2e 98 0a b1 a0 86 65 cc 6a e9 5f 47 51 |@.T......e.j._GQ| +00000360 a4 b4 40 47 25 ae df 93 c2 b6 eb fe b6 71 fe 04 |..@G%........q..| +00000370 1e 98 d0 91 8b c7 ea 58 91 23 a7 76 67 ba 7a fd |.......X.#.vg.z.| +00000380 49 f0 c2 70 70 50 06 23 5e 31 90 4e 58 98 16 03 |I..ppP.#^1.NX...| +00000390 03 00 04 0e 00 00 00 |.......| +>>> Flow 3 (client to server) +00000000 16 03 03 00 46 10 00 00 42 41 04 1e 18 37 ef 0d |....F...BA...7..| +00000010 19 51 88 35 75 71 b5 e5 54 5b 12 2e 8f 09 67 fd |.Q.5uq..T[....g.| +00000020 a7 24 20 3e b2 56 1c ce 97 28 5e f8 2b 2d 4f 9e |.$ >.V...(^.+-O.| +00000030 f1 07 9f 6c 4b 5b 83 56 e2 32 42 e9 58 b6 d7 49 |...lK[.V.2B.X..I| +00000040 a6 b5 68 1a 41 03 56 6b dc 5a 89 14 03 03 00 01 |..h.A.Vk.Z......| +00000050 01 16 03 03 00 28 00 00 00 00 00 00 00 00 e8 f8 |.....(..........| +00000060 61 5f dc c0 12 cd e2 09 7a a9 61 4f 77 29 aa 9d |a_......z.aOw)..| +00000070 52 11 b9 35 66 1d ac e1 e7 05 f8 f7 d7 cc |R..5f.........| +>>> Flow 4 (server to client) +00000000 14 03 03 00 01 01 16 03 03 00 28 dd 5b e0 29 02 |..........(.[.).| +00000010 9a 71 85 fb c1 d6 c0 fe 89 22 8d 86 9f 64 ab 70 |.q......."...d.p| +00000020 ec 07 9a 61 a0 af 13 7b 04 e2 73 df f6 c2 06 86 |...a...{..s.....| +00000030 a7 b2 65 |..e| +>>> Flow 5 (client to server) +00000000 17 03 03 00 1e 00 00 00 00 00 00 00 01 d8 7a 81 |..............z.| +00000010 28 a5 af fc 7d 02 4a 1c f5 a2 0f 65 65 ad d1 c2 |(...}.J....ee...| +00000020 2b fe 49 15 03 03 00 1a 00 00 00 00 00 00 00 02 |+.I.............| +00000030 94 20 af f9 53 43 6e c0 bd 0a fb ce b8 cc b5 3f |. ..SCn........?| +00000040 39 73 |9s| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-RSA-RC4 b/libgo/go/crypto/tls/testdata/Client-TLSv12-RSA-RC4 index b743b5609e5..6b7f11621b8 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv12-RSA-RC4 +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-RSA-RC4 @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 03 00 51 02 00 00 4d 03 03 90 26 c2 6e 52 |....Q...M...&.nR| -00000010 59 b2 e8 f1 c5 fc 4d 59 13 76 43 4e a4 ab 0b 33 |Y.....MY.vCN...3| -00000020 96 d0 4e 89 bd 1e bd 89 f6 2b d7 20 39 94 41 68 |..N......+. 9.Ah| -00000030 81 74 78 60 e1 5f f7 7d e3 9d 81 f1 62 bd 45 67 |.tx`._.}....b.Eg| -00000040 51 50 bd 84 76 70 52 c3 ce 32 90 51 00 05 00 00 |QP..vpR..2.Q....| +00000000 16 03 03 00 51 02 00 00 4d 03 03 c1 47 51 e7 59 |....Q...M...GQ.Y| +00000010 d9 0d ae 9b 9c 93 c6 36 c6 33 e9 38 ba 37 4c 60 |.......6.3.8.7L`| +00000020 ec 0b 63 49 11 67 56 29 1b 78 dd 20 1a 60 41 ea |..cI.gV).x. .`A.| +00000030 93 07 16 61 e4 55 11 3f d1 e2 e6 9d 9f 05 c8 3e |...a.U.?.......>| +00000040 37 47 31 0d f9 5d 7a a5 7b 82 63 23 00 05 00 00 |7G1..]z.{.c#....| 00000050 05 ff 01 00 01 00 16 03 03 02 59 0b 00 02 55 00 |..........Y...U.| 00000060 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000070 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -64,15 +70,15 @@ 00000060 c5 70 0f 08 83 48 e9 48 ef 6e 50 8b 05 7e e5 84 |.p...H.H.nP..~..| 00000070 25 fa 55 c7 ae 31 02 27 00 ef 3f 98 86 20 12 89 |%.U..1.'..?.. ..| 00000080 91 59 28 b4 f7 d7 af d2 69 61 35 14 03 03 00 01 |.Y(.....ia5.....| -00000090 01 16 03 03 00 24 4b 7c 05 1b 5d ed 28 c0 ce db |.....$K|..].(...| -000000a0 c9 1d bb e8 a1 94 d7 30 ac aa 54 08 2a 82 a2 a0 |.......0..T.*...| -000000b0 52 e7 cb 32 0f c2 f8 ad f3 c9 |R..2......| +00000090 01 16 03 03 00 24 f7 0e a5 ad 5d 6d ab c8 04 b7 |.....$....]m....| +000000a0 07 e7 e7 28 30 72 63 a9 02 05 18 7c 07 61 68 58 |...(0rc....|.ahX| +000000b0 6f 7a 5c d2 4f 32 b5 d3 b1 09 |oz\.O2....| >>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 24 ad ef e3 a0 c4 |..........$.....| -00000010 2c a0 ca 82 a6 f0 eb 8f 73 f3 48 11 0f 1f cc 6f |,.......s.H....o| -00000020 6f 63 fa d8 9d 47 6b b2 ab 3e fe bc 0e 44 ce |oc...Gk..>...D.| +00000000 14 03 03 00 01 01 16 03 03 00 24 93 ef cc 6a e8 |..........$...j.| +00000010 8c e4 16 6e 05 cd 2f 9a 31 52 e8 67 3b 93 83 0e |...n../.1R.g;...| +00000020 f0 29 04 29 40 b7 6a c8 c4 51 a4 6a 9d 5c 17 |.).)@.j..Q.j.\.| >>> Flow 5 (client to server) -00000000 17 03 03 00 1a e7 90 92 8b a5 a6 4f 22 97 2f 23 |...........O"./#| -00000010 f1 3c 54 65 2c 14 7e fd 1d 8f c7 76 97 e8 f8 15 |.Tfx...1....C.D.| +00000020 03 03 00 16 34 97 5d 52 01 da 5d 45 c6 51 14 1a |....4.]R..]E.Q..| +00000030 45 8f 96 af fd 6a ea d2 37 cf |E....j..7.| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-RenegotiateOnce b/libgo/go/crypto/tls/testdata/Client-TLSv12-RenegotiateOnce index 9304adfbe6a..9810f522129 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv12-RenegotiateOnce +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-RenegotiateOnce @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 03 00 59 02 00 00 55 03 03 f1 85 19 85 1e |....Y...U.......| -00000010 f5 97 e1 e6 08 15 6f a9 05 93 6f b9 41 ad 11 ae |......o...o.A...| -00000020 92 90 5e 00 97 46 42 af 2f b0 5d 20 b7 f3 e7 76 |..^..FB./.] ...v| -00000030 20 e4 c2 99 6e ba 87 79 21 5c 5c 62 d9 1f 08 88 | ...n..y!\\b....| -00000040 e1 1f 05 0c 31 9c d5 b3 65 19 26 4c cc a8 00 00 |....1...e.&L....| +00000000 16 03 03 00 59 02 00 00 55 03 03 8a b7 29 8f 35 |....Y...U....).5| +00000010 0f 6b 07 77 95 15 94 08 ad b8 e3 8f 97 72 17 b5 |.k.w.........r..| +00000020 79 1d b9 ab 57 d2 58 e0 63 04 8f 20 3b 5d 60 f3 |y...W.X.c.. ;]`.| +00000030 d6 92 21 98 27 3d 20 69 ec c8 47 d0 27 ce 42 39 |..!.'= i..G.'.B9| +00000040 1d 82 b0 e7 ef ca 59 f9 f8 fe 06 79 cc a8 00 00 |......Y....y....| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 03 02 59 0b 00 02 55 00 02 52 00 02 4f 30 82 02 |..Y...U..R..O0..| 00000070 4b 30 82 01 b4 a0 03 02 01 02 02 09 00 e8 f0 9d |K0..............| @@ -54,126 +60,185 @@ 00000290 77 8d 0c 1c f1 0f a1 d8 40 83 61 c9 4c 72 2b 9d |w.......@.a.Lr+.| 000002a0 ae db 46 06 06 4d f4 c1 b3 3e c0 d1 bd 42 d4 db |..F..M...>...B..| 000002b0 fe 3d 13 60 84 5c 21 d3 3b e9 fa e7 16 03 03 00 |.=.`.\!.;.......| -000002c0 ac 0c 00 00 a8 03 00 1d 20 f8 4d 81 d8 29 29 e9 |........ .M..)).| -000002d0 2a 96 44 4b e3 d2 95 11 19 7a d5 26 ed 60 f2 d8 |*.DK.....z.&.`..| -000002e0 e7 7d 96 9e 06 9f 37 f8 3e 04 01 00 80 51 70 fb |.}....7.>....Qp.| -000002f0 66 2e 1f 40 97 95 47 34 e5 69 8b a7 f6 d2 d1 71 |f..@..G4.i.....q| -00000300 0a 4c 34 d8 4f 8a 59 fc a0 93 db 10 77 12 a9 52 |.L4.O.Y.....w..R| -00000310 b6 be 1b 48 2c 56 9a ad 89 57 58 30 90 03 bb 46 |...H,V...WX0...F| -00000320 df 8a 4b 81 9a 14 6a a0 c9 60 76 e5 c6 73 da 35 |..K...j..`v..s.5| -00000330 e5 98 81 31 6c c4 ff 41 0c b1 7c 6e fd 82 75 de |...1l..A..|n..u.| -00000340 d8 84 db 3e fa 80 bc a8 6a 77 6f c9 9b 78 1a 0a |...>....jwo..x..| -00000350 dc 7b f0 65 4d 0f 14 b2 78 e8 db fb ee ca 74 83 |.{.eM...x.....t.| -00000360 2c d5 78 1e 48 09 17 0a d8 08 de f9 9d 16 03 03 |,.x.H...........| +000002c0 ac 0c 00 00 a8 03 00 1d 20 0d 87 80 0d 1d 7c ad |........ .....|.| +000002d0 a2 da 94 09 a5 23 c9 f2 23 cc f2 0a 2e 94 2d 74 |.....#..#.....-t| +000002e0 01 5f 60 63 5b c7 1e a0 45 08 04 00 80 2f 2f 55 |._`c[...E....//U| +000002f0 44 fb f1 5a 0d 37 7c b0 5d 63 bb 7a e3 a8 f3 e9 |D..Z.7|.]c.z....| +00000300 b4 5d a0 ba 31 ec a8 4b 70 5f ce af 98 91 28 0c |.]..1..Kp_....(.| +00000310 47 a2 c9 03 a3 07 e6 67 1e 34 76 cc b8 14 3d 8f |G......g.4v...=.| +00000320 83 6a 10 34 dc 53 7c 57 39 77 49 48 3e dc 0d 37 |.j.4.S|W9wIH>..7| +00000330 8f 37 f7 28 aa 13 19 b1 2f 31 e1 b6 94 45 b1 0d |.7.(..../1...E..| +00000340 ec 9f 39 78 90 24 31 c6 03 88 67 28 72 fa 24 41 |..9x.$1...g(r.$A| +00000350 5c 5e 3f d8 cd e4 58 00 fb 1a ba c9 cc ff 1b 7a |\^?...X........z| +00000360 23 9a fd 38 04 18 6a 82 69 bd e4 59 87 16 03 03 |#..8..j.i..Y....| 00000370 00 04 0e 00 00 00 |......| >>> Flow 3 (client to server) 00000000 16 03 03 00 25 10 00 00 21 20 2f e5 7d a3 47 cd |....%...! /.}.G.| 00000010 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 |bC.(.._.).0.....| 00000020 cf c2 ed 90 99 5f 58 cb 3b 74 14 03 03 00 01 01 |....._X.;t......| -00000030 16 03 03 00 20 c9 e3 4a a0 72 57 a2 c6 8d e9 98 |.... ..J.rW.....| -00000040 28 8d 40 22 6e ed 46 50 0d 08 38 b4 b0 6e a6 0b |(.@"n.FP..8..n..| -00000050 16 57 3f 6a 96 |.W?j.| +00000030 16 03 03 00 20 cb 26 0a 53 64 81 75 f6 f6 17 78 |.... .&.Sd.u...x| +00000040 3f a7 96 52 91 70 91 2d 92 67 cb ae f0 8f 84 9d |?..R.p.-.g......| +00000050 ea 17 3f a1 38 |..?.8| >>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 20 28 1b b9 e9 46 |.......... (...F| -00000010 3d 61 64 fe 84 b5 ea ff 79 e3 b9 5f 7e 1d 9c e1 |=ad.....y.._~...| -00000020 84 0f 17 9b be 67 0e b7 71 b3 de |.....g..q..| +00000000 14 03 03 00 01 01 16 03 03 00 20 83 7c 41 9e 33 |.......... .|A.3| +00000010 b0 89 6c 2f 88 99 61 b1 71 30 04 9f df 48 e9 9e |..l/..a.q0...H..| +00000020 50 5f 22 d8 09 49 f6 17 7f 6a 10 |P_"..I...j.| >>> Flow 5 (client to server) -00000000 17 03 03 00 16 0d d9 98 93 d7 c2 0e 48 53 34 1c |............HS4.| -00000010 b6 58 70 58 af 24 7c 3e 43 55 8a |.XpX.$|>CU.| +00000000 17 03 03 00 16 63 50 67 b6 7a 7d 4e 3d f5 a9 93 |.....cPg.z}N=...| +00000010 f9 6d 61 ea 46 c7 5d 28 77 ad 12 |.ma.F.](w..| >>> Flow 6 (server to client) -00000000 16 03 03 00 14 96 19 2b 56 4c 10 ea 1a c4 6e e3 |.......+VL....n.| -00000010 95 31 61 ed 22 ce 87 b2 bb |.1a."....| +00000000 16 03 03 00 14 f4 d1 27 84 c9 8f 32 7c 0f ff e8 |.......'...2|...| +00000010 ee ba 2e 93 29 cb fa 22 52 |....).."R| >>> Flow 7 (client to server) -00000000 16 03 03 00 b1 a7 01 a1 b3 16 21 88 5a 74 bd a0 |..........!.Zt..| -00000010 58 fa d2 fa ba e3 a2 21 ae b6 92 28 a4 90 e7 f7 |X......!...(....| -00000020 fc 1b 6e dd 12 19 18 30 5d 6e fe be b7 12 16 fc |..n....0]n......| -00000030 26 27 8d e0 8c 18 25 3e 97 fa 5b 3c 06 c0 ee 49 |&'....%>..[<...I| -00000040 6e 6f 29 28 ac 46 02 92 38 c3 e1 1b d8 cc 6e 23 |no)(.F..8.....n#| -00000050 a1 4e 67 58 3e 33 45 ed 85 da f1 e6 76 0d ab f5 |.NgX>3E.....v...| -00000060 25 a7 a1 ac 67 f5 b7 14 52 04 57 6b e7 7f ac 5e |%...g...R.Wk...^| -00000070 bb c4 3f 0b 3b 54 86 a0 9c 4f 9b b5 1e 9d f5 8a |..?.;T...O......| -00000080 0b 62 fd 89 84 16 ee 13 49 40 32 3d 90 d1 4a 11 |.b......I@2=..J.| -00000090 ea 13 84 b8 18 4c 50 9b 18 54 ab f1 b8 77 e7 b2 |.....LP..T...w..| -000000a0 8b 7a 85 34 47 0a 83 fb 86 f2 94 e6 4a 17 db a8 |.z.4G.......J...| -000000b0 31 61 8e e7 d8 f9 |1a....| +00000000 16 03 03 01 14 ba 60 c0 bb d9 cb 55 0f 08 fc 18 |......`....U....| +00000010 15 81 5d 69 a0 b2 c7 87 94 af c1 63 a6 46 e1 57 |..]i.......c.F.W| +00000020 1e c5 9e 2e f1 aa db ad c9 20 4e a2 88 69 48 b5 |......... N..iH.| +00000030 ed 91 14 f1 d0 ec d2 28 9f e3 b7 de 03 7d 53 a6 |.......(.....}S.| +00000040 25 7f 2f e3 5b 6a 79 29 15 4b 25 90 bf a6 49 0a |%./.[jy).K%...I.| +00000050 29 94 86 29 4b 8b a2 6c 82 1e 0a 57 91 1c 46 f1 |)..)K..l...W..F.| +00000060 94 e3 ef e5 6c d5 e7 c8 82 86 82 dc 48 04 9d 11 |....l.......H...| +00000070 d9 85 1a 41 27 ec 1c 25 72 a5 15 53 ef 70 90 a8 |...A'..%r..S.p..| +00000080 a8 17 ae 4f 22 71 1c d3 7e 00 55 67 67 3b 3d cb |...O"q..~.Ugg;=.| +00000090 2c f3 03 39 f3 d8 46 30 4d 60 c4 58 d1 20 f6 1c |,..9..F0M`.X. ..| +000000a0 f2 13 8d c8 58 36 08 97 c6 82 9e 6d a4 bd 0a 71 |....X6.....m...q| +000000b0 e4 e2 7f 76 69 6f 39 19 43 9f 9c ea 8d fb ec ea |...vio9.C.......| +000000c0 90 a0 e7 67 ea d7 48 c6 e5 ce 7c f6 98 fb 0f 8a |...g..H...|.....| +000000d0 5b 9f 85 0b 9e 6b 50 40 32 12 a0 9e c2 5d d7 af |[....kP@2....]..| +000000e0 b1 57 e0 bf 05 59 3b 4c 93 4f 4b 85 6f 8d bf 65 |.W...Y;L.OK.o..e| +000000f0 94 a9 7c fc ab ef 1a 3a 4e 70 bd 54 35 6d f9 68 |..|....:Np.T5m.h| +00000100 36 8d 5e 30 d7 01 5c 1e b1 91 7c 9a fb 18 08 63 |6.^0..\...|....c| +00000110 28 d8 28 5d 53 1c f9 88 cb |(.(]S....| >>> Flow 8 (server to client) -00000000 16 03 03 00 81 8b 09 74 4a 5b 74 ef c4 91 26 84 |.......tJ[t...&.| -00000010 25 33 c2 f7 05 1c 13 cf 00 ba 54 dd 16 e9 f3 4d |%3........T....M| -00000020 80 f5 1f f9 9b 7e a8 a9 60 f1 d6 be f9 c1 75 b0 |.....~..`.....u.| -00000030 1b 98 c4 d2 f0 69 c5 d5 d9 07 dd 19 56 4f cd 6f |.....i......VO.o| -00000040 b0 df 58 a8 da 66 23 e6 8e 20 03 75 33 1a ee 61 |..X..f#.. .u3..a| -00000050 ab 31 f7 2e e0 ea f4 29 26 34 1d 8e 52 0d 1a 6f |.1.....)&4..R..o| -00000060 cc c7 bf 14 dc 1c 47 80 42 b7 d0 ac 26 f5 e1 8e |......G.B...&...| -00000070 08 d7 63 8a 3b c4 d3 e7 15 a1 46 e3 9b c1 4a 5a |..c.;.....F...JZ| -00000080 14 30 da 62 8f 3a 16 03 03 02 69 54 7c 6d 38 37 |.0.b.:....iT|m87| -00000090 01 fe 7c fe 75 30 f1 c0 e8 16 89 b7 d8 7e e0 70 |..|.u0.......~.p| -000000a0 90 4e c5 7d 37 1b 44 57 7b 91 50 cc aa 71 47 9d |.N.}7.DW{.P..qG.| -000000b0 64 67 42 2c b0 01 64 b1 05 6f b3 a9 07 61 f9 99 |dgB,..d..o...a..| -000000c0 f8 2c 59 08 12 80 c5 48 0c 88 67 05 74 da 91 e0 |.,Y....H..g.t...| -000000d0 6d 53 2a ac 02 14 cb f9 f5 c1 dd c2 29 29 e6 7d |mS*.........)).}| -000000e0 78 52 cb 19 74 80 6f 1b ab a9 4c b7 88 09 01 b8 |xR..t.o...L.....| -000000f0 66 a1 8c 1d 1a 06 08 05 7d 60 5d e6 a7 da 36 17 |f.......}`]...6.| -00000100 ef 5c 90 c3 77 d8 34 d4 99 e5 bd 1d 70 15 78 db |.\..w.4.....p.x.| -00000110 71 23 4d 4a 18 bd ac ab 36 86 79 05 70 1c 51 15 |q#MJ....6.y.p.Q.| -00000120 82 c9 a0 c2 cd 80 d0 41 a1 51 10 c5 96 44 1f 97 |.......A.Q...D..| -00000130 a7 20 0a 80 a4 7c fe 6d f3 b4 ae 19 17 17 d4 97 |. ...|.m........| -00000140 37 cf 69 34 8e ad 5a e6 66 fc f3 07 7d a7 5c 0d |7.i4..Z.f...}.\.| -00000150 c2 fd d6 3d 69 dc 41 6f b0 fd 3b db 3a 95 25 52 |...=i.Ao..;.:.%R| -00000160 a0 82 54 7c f3 4d d2 65 8b c6 55 3a 9c 89 19 f1 |..T|.M.e..U:....| -00000170 aa c0 49 7a bf 1c ec 7a 78 d2 11 c0 8f ab 53 2d |..Iz...zx.....S-| -00000180 68 69 9e 12 db ec 77 df 7d 7b 5f 75 76 df 76 1e |hi....w.}{_uv.v.| -00000190 b4 c3 32 3f c9 cb 58 bd c4 b0 45 61 2a dc 14 fb |..2?..X...Ea*...| -000001a0 3a 83 84 e0 ad a0 25 16 e7 1c 3c 4b f6 4e 6d a8 |:.....%...}a.>.b+..| -000001f0 0b 71 d8 1d ae 65 c0 f8 71 98 aa 08 af 10 09 6f |.q...e..q......o| -00000200 9d 79 9b 70 d5 48 5c 96 ac d0 2d ee 61 1f 8a 96 |.y.p.H\...-.a...| -00000210 5e 8b 04 06 80 20 f1 cc 61 93 9f ea c3 3a f0 ba |^.... ..a....:..| -00000220 ed 7c 80 25 4c ba e8 a6 97 62 04 cd 8b 58 00 d6 |.|.%L....b...X..| -00000230 e1 0d 0b f3 c0 73 b9 0d 57 e3 76 8d f8 a9 43 72 |.....s..W.v...Cr| -00000240 c0 37 d9 f5 16 02 0a 0c d1 44 2d e6 fe 57 3d 9f |.7.......D-..W=.| -00000250 64 ef a6 f6 9b 44 7a 16 de f7 64 94 6f 4c c4 57 |d....Dz...d.oL.W| -00000260 f8 ba dd 64 61 87 55 6e ac 96 1c 68 f4 68 b2 90 |...da.Un...h.h..| -00000270 ec 7a a5 f3 7c dd f0 30 af 27 9d c4 dc fe 05 c7 |.z..|..0.'......| -00000280 4b d3 44 63 5c bb e0 e0 eb 0d bc ef ea fa dd 17 |K.Dc\...........| -00000290 1f 27 a6 b7 79 6c 0c 64 25 91 4d a1 cf ae 5b 81 |.'..yl.d%.M...[.| -000002a0 2b d3 18 0b 82 3e 4a 4b 02 6c cb be c7 b7 a7 e0 |+....>JK.l......| -000002b0 2f a7 a0 32 f4 5d b2 5b 6e 9f b4 cd ee 58 e4 bd |/..2.].[n....X..| -000002c0 ac 44 4d 0d 37 31 8b d1 d5 01 83 0a 63 85 14 e3 |.DM.71......c...| -000002d0 55 93 1d 25 61 4b 43 b5 a4 e5 d3 50 e9 01 96 02 |U..%aKC....P....| -000002e0 10 aa 58 6a 9d e0 e4 80 c4 a9 20 c9 b5 0c 79 bb |..Xj...... ...y.| -000002f0 5c 5f 22 43 16 03 03 00 bc 56 b6 aa ae 4c 5f f5 |\_"C.....V...L_.| -00000300 4f 16 84 92 4b d3 be 30 7f ab 74 d2 5e eb 23 de |O...K..0..t.^.#.| -00000310 2f 5b 6e c4 1a b4 e6 39 33 f8 c9 0f a3 b0 d5 bb |/[n....93.......| -00000320 77 21 76 6d 6e 45 b9 75 d1 86 b8 be ad 31 85 db |w!vmnE.u.....1..| -00000330 90 39 92 74 3a fc e1 5c 71 b9 64 b5 ae d8 5b a5 |.9.t:..\q.d...[.| -00000340 ac ca b5 9c 3a ad 58 a3 b3 2d 80 52 47 8f 5c 9b |....:.X..-.RG.\.| -00000350 fd 09 a9 b0 b9 84 e5 01 03 69 ca b3 79 bc 61 da |.........i..y.a.| -00000360 f9 58 0a 0e 86 a3 aa 3a b9 e8 8d 87 a5 0b 62 fa |.X.....:......b.| -00000370 7f de 17 29 ed 75 38 49 4a f9 5f a3 cd 92 f7 bd |...).u8IJ._.....| -00000380 fd 5d d3 0e 2f 49 38 a1 ba b5 87 e2 65 e0 68 c1 |.]../I8.....e.h.| -00000390 c1 3d f2 57 06 25 9e b8 54 6e 9a 33 ee 3f 6a fc |.=.W.%..Tn.3.?j.| -000003a0 53 1c cc 1f ee 6a 0f 43 c5 68 08 02 4e d7 3e 5e |S....j.C.h..N.>^| -000003b0 a6 c9 aa da 0b 16 03 03 00 14 8b 31 f6 f0 2c bf |...........1..,.| -000003c0 d1 fa 59 12 4a 4d 9d 51 d2 79 ff 58 3a fa |..Y.JM.Q.y.X:.| +00000000 16 03 03 00 81 b9 47 ca 9a 81 1b 3e 4e 21 cf 05 |......G....>N!..| +00000010 99 31 4c 2a d4 72 9d 71 1f b9 87 e7 19 36 60 84 |.1L*.r.q.....6`.| +00000020 e4 be 4a d9 7d 10 ad b1 d2 28 58 5b 47 09 cd 19 |..J.}....(X[G...| +00000030 de d3 76 c4 56 e1 19 f5 a3 e2 e3 bd 8b d0 d9 e0 |..v.V...........| +00000040 75 b2 d3 23 04 f0 65 ef 22 f6 10 13 28 80 1b c5 |u..#..e."...(...| +00000050 69 75 7b 8c e6 cb 0e f5 e7 e8 fa 1e d0 e3 c3 24 |iu{............$| +00000060 52 83 c9 a2 5b 57 94 da b9 f2 5e 0a bc f4 a0 da |R...[W....^.....| +00000070 a1 02 b5 18 20 de 40 4e 52 97 12 6b e6 00 b6 eb |.... .@NR..k....| +00000080 af 82 f0 08 d7 33 16 03 03 02 69 26 88 2e 6e 74 |.....3....i&..nt| +00000090 21 8d 66 37 b3 77 37 52 0d 04 e6 89 99 00 3f e6 |!.f7.w7R......?.| +000000a0 e5 6b 56 68 8e 07 0b 2b 35 8f 59 81 f0 b0 82 77 |.kVh...+5.Y....w| +000000b0 dd 13 b8 16 a9 e0 84 9c bc 2d cf c4 30 a4 43 f6 |.........-..0.C.| +000000c0 01 04 c3 7d 9d a1 84 16 73 45 f8 85 c8 fc c2 25 |...}....sE.....%| +000000d0 49 24 07 e1 d8 1c 8f da ce 04 0e ca 1a 4f 97 a0 |I$...........O..| +000000e0 ba 8f 0f 2d 87 02 f9 a1 08 33 4e 53 a7 a1 bb c8 |...-.....3NS....| +000000f0 41 d2 9b c6 44 0a 7e 8e 21 ff 0d 23 61 d0 b9 4d |A...D.~.!..#a..M| +00000100 27 74 3a de 3a 7e 76 1e 8f a1 f8 57 ca 6b 1d dc |'t:.:~v....W.k..| +00000110 75 e9 2b 95 ae dc 5e 93 de 23 43 6e 1f b1 4d df |u.+...^..#Cn..M.| +00000120 f7 e6 d8 bd 3d 31 0a 7f 97 7b 07 c5 ac 8a 1e 51 |....=1...{.....Q| +00000130 95 a1 c5 b3 93 ba ec 41 d8 1a 57 28 2f 53 14 d0 |.......A..W(/S..| +00000140 e0 e9 e9 e2 f4 a8 b1 67 15 2d d8 3b 96 82 75 16 |.......g.-.;..u.| +00000150 f9 4e a1 55 1d b0 e1 48 95 bb ee 46 5f dd 48 4a |.N.U...H...F_.HJ| +00000160 6a ae b4 a0 24 21 85 70 20 80 22 dc c0 cc 0e 15 |j...$!.p .".....| +00000170 55 c8 e1 15 1c 8c 38 c3 fb 38 31 0e 3c d8 49 bf |U.....8..81.<.I.| +00000180 63 4d d4 20 09 a4 b1 57 f8 a3 1c b2 8e 8d 28 c8 |cM. ...W......(.| +00000190 af 20 4c 46 ae b5 eb aa 54 ca 74 cc bc b4 5c a5 |. LF....T.t...\.| +000001a0 a0 ab c1 41 fb cc 0d d6 6a 25 58 c9 f1 10 32 59 |...A....j%X...2Y| +000001b0 6a d3 04 5a fe bb 84 58 94 04 aa fd a4 f9 79 6c |j..Z...X......yl| +000001c0 f8 da 28 7f 16 73 5e 4c a2 07 9d cc 8f 8d 25 27 |..(..s^L......%'| +000001d0 2d 60 a3 a0 0d e3 65 0b 69 1f 44 92 97 d7 1e b8 |-`....e.i.D.....| +000001e0 43 f4 ed f5 3c 6c ce 0e f6 cb a2 83 80 c3 ee 00 |C...).| +00000220 ba 26 31 6e e8 a8 d4 d5 da e0 9f d1 8c 76 9a bf |.&1n.........v..| +00000230 18 f9 02 1d a0 c5 07 b7 fe cd d2 34 47 27 84 b4 |...........4G'..| +00000240 d4 07 3b 37 72 74 64 bb c4 31 5e 7b a9 c6 a9 a2 |..;7rtd..1^{....| +00000250 06 03 ea 32 41 64 b2 6c 57 70 bb 5c 0a a0 3f 48 |...2Ad.lWp.\..?H| +00000260 78 e8 0b 8a b7 dd 67 68 43 aa 8e d9 ff 81 a2 f4 |x.....ghC.......| +00000270 c6 25 9d 06 30 a4 6a 24 e0 b1 cd b4 7a d4 09 6e |.%..0.j$....z..n| +00000280 e3 d4 4c 3e b5 16 c3 44 9d f7 92 d6 40 95 d8 3e |..L>...D....@..>| +00000290 22 61 a3 29 87 8d 63 e0 98 0c db 9b eb 86 84 fe |"a.)..c.........| +000002a0 f3 ca 9f ce 7b de a9 04 3a 61 d4 bf d4 d6 51 60 |....{...:a....Q`| +000002b0 02 06 cb 13 e1 a6 bf db f0 f1 53 c6 62 a6 1a 42 |..........S.b..B| +000002c0 11 6f 5d 0c 13 c3 12 ff f5 7c 9b ef 58 54 14 3d |.o]......|..XT.=| +000002d0 4d 4b c2 fc ae 33 4a 00 24 e9 3c 6f 6f 5b ef c4 |MK...3J.$.>> Flow 9 (client to server) -00000000 16 03 03 00 35 24 68 32 63 8a 43 11 1f 91 a5 8b |....5$h2c.C.....| -00000010 4f 57 63 f6 de a8 23 c2 d2 68 33 d0 fc 9d 41 b1 |OWc...#..h3...A.| -00000020 5f 71 d8 e4 fb b6 71 e6 83 2f cc 15 53 e1 70 48 |_q....q../..S.pH| -00000030 34 92 68 ae 1f f4 88 b0 d0 59 14 03 03 00 11 e9 |4.h......Y......| -00000040 01 e9 1d fa c2 c3 2a 60 68 98 83 fa f5 7e 5f 2a |......*`h....~_*| -00000050 16 03 03 00 20 33 0c 00 8d 8a 60 06 dc 43 9d ae |.... 3....`..C..| -00000060 a5 a7 23 05 3a 55 53 e4 41 42 46 bb 35 ef a6 2c |..#.:US.ABF.5..,| -00000070 d4 d8 4d 85 d4 |..M..| +00000000 16 03 03 02 69 74 87 f6 35 08 6b 36 04 33 bd 50 |....it..5.k6.3.P| +00000010 d8 de c9 0b 8e 98 d4 2a ca f1 68 50 10 03 d4 83 |.......*..hP....| +00000020 56 e2 12 fd 8d 5f ff 7c 16 9b 43 d9 75 f7 c6 ee |V...._.|..C.u...| +00000030 ee dc f6 e9 19 d0 ae 8a 54 fb c6 7e 9e b4 15 79 |........T..~...y| +00000040 17 fa d2 32 8d b4 b0 ff 15 44 ac 4f 28 5d ba 10 |...2.....D.O(]..| +00000050 6e e6 cb b3 ad e8 ef 06 c4 3e aa 1f a8 df 1b 82 |n........>......| +00000060 38 bd 5f 88 5c 0e 5b e7 03 df 9b 6f c2 d9 b8 5f |8._.\.[....o..._| +00000070 bf 60 de 69 f3 12 4f b8 50 28 fc 2d 15 70 92 3b |.`.i..O.P(.-.p.;| +00000080 76 7d 36 13 5e e6 39 e6 29 6d d0 99 14 ca 52 a5 |v}6.^.9.)m....R.| +00000090 12 db 96 d4 d0 38 ef 42 6c 09 ca dc 06 f2 d3 8f |.....8.Bl.......| +000000a0 49 c8 a3 c2 77 c3 c1 f6 18 6a 91 95 36 1b d6 47 |I...w....j..6..G| +000000b0 f6 87 0c 3e 82 b4 22 62 a5 cb 5b e8 73 6e 71 52 |...>.."b..[.snqR| +000000c0 4f 7c 9f b8 b4 f1 5b 77 96 a6 8e 22 52 b6 cf cc |O|....[w..."R...| +000000d0 b4 5b a9 a9 63 4b 9b 1c db a0 ad f4 35 04 20 6c |.[..cK......5. l| +000000e0 33 b2 c6 5c 6f 2a 1e 5f d9 c4 c1 b1 82 4f 6d 12 |3..\o*._.....Om.| +000000f0 e1 6e f9 9f e8 0f e7 9e cf 80 eb 1a 72 de 9e df |.n..........r...| +00000100 b2 6f d4 57 1f cc 01 89 b2 e3 2f 65 dd 05 ae 0d |.o.W....../e....| +00000110 d0 9f 74 21 45 3c c4 00 67 61 2c 37 8e 96 a4 38 |..t!E<..ga,7...8| +00000120 b2 1d d8 58 25 7a 3f 99 0c 7b e7 fd 67 92 e2 3f |...X%z?..{..g..?| +00000130 14 32 79 25 d3 df cd cf 1f fc 5d 67 53 e0 7d 28 |.2y%......]gS.}(| +00000140 60 b1 b0 d8 d9 81 d4 b4 22 81 e4 c2 09 8e 8d 37 |`......."......7| +00000150 82 35 61 37 6c 6e 8e 2d 9f 41 63 b3 e9 f9 1f 73 |.5a7ln.-.Ac....s| +00000160 8f bf 7d 08 65 b8 a2 5a 32 5a 0f 96 70 fc 11 d5 |..}.e..Z2Z..p...| +00000170 b3 af 85 2c 22 cc 8d da 18 80 74 6c d9 64 1e e5 |...,".....tl.d..| +00000180 8a 10 ee 28 6b 3b 85 d9 af b7 65 bd 39 c4 4c 1e |...(k;....e.9.L.| +00000190 c6 40 b7 26 cd 07 1a e1 42 c9 a0 e6 94 34 60 11 |.@.&....B....4`.| +000001a0 5e 1c c1 76 f5 59 70 fb 73 8e 2f 44 53 ea b2 55 |^..v.Yp.s./DS..U| +000001b0 ed 0c 6f 39 f0 0a 04 b9 6c 7e c9 15 dc 3f c7 72 |..o9....l~...?.r| +000001c0 85 78 02 ce 96 49 57 cd 56 dc 9c 76 b9 ae 08 6c |.x...IW.V..v...l| +000001d0 52 82 b2 a0 05 20 f6 2e 28 0d 4c 46 58 42 d5 2f |R.... ..(.LFXB./| +000001e0 83 55 b1 e1 47 f1 b1 70 72 b0 73 7f a5 7f 4d 73 |.U..G..pr.s...Ms| +000001f0 e8 09 46 d7 16 3e 3d df 04 79 24 38 23 e2 a6 e3 |..F..>=..y$8#...| +00000200 e7 70 b5 69 b7 42 fb 45 84 d3 e8 cc eb e5 25 67 |.p.i.B.E......%g| +00000210 ee 71 b9 24 05 8c cc e0 2b 86 1d ac 54 24 e8 7a |.q.$....+...T$.z| +00000220 c3 8f 22 df 01 21 f7 d1 a9 b6 96 3c e8 b4 c9 95 |.."..!.....<....| +00000230 5a e1 2e 46 ac e3 6b a5 14 60 d4 63 c1 37 5e d5 |Z..F..k..`.c.7^.| +00000240 14 d1 97 ae c0 cf 01 d3 b0 b0 3d d7 7e 9f 5a 52 |..........=.~.ZR| +00000250 73 f3 e0 70 22 09 44 85 b9 1e 2f 78 a1 33 cc 39 |s..p".D.../x.3.9| +00000260 fd ff bc 68 1e 96 7e 26 be 31 8e 73 64 21 16 03 |...h..~&.1.sd!..| +00000270 03 00 35 96 4d ac f1 b3 1b 7b e0 ab 2b 47 40 be |..5.M....{..+G@.| +00000280 46 a3 02 2c eb 74 b8 4f 53 b5 7d 05 47 dc 72 d9 |F..,.t.OS.}.G.r.| +00000290 6a 8e 7d 6f 66 2a 6b e2 27 e7 6a bf 39 68 f3 9c |j.}of*k.'.j.9h..| +000002a0 89 51 dc 4e 8c 82 38 57 16 03 03 00 98 fb 44 b6 |.Q.N..8W......D.| +000002b0 36 4a 3e 0a 41 01 3d 78 8b 5d fe 95 69 a5 53 d5 |6J>.A.=x.]..i.S.| +000002c0 d6 37 c3 e3 03 ae b7 33 57 1a 1a dd d0 cf 86 34 |.7.....3W......4| +000002d0 6e 06 30 ac 09 08 13 8b 18 9f a6 ec 96 e4 bc ca |n.0.............| +000002e0 06 6b 01 2d 2e 7c ff 34 9e 16 7e fc e3 0e 3c 0e |.k.-.|.4..~...<.| +000002f0 5c d0 13 88 7d af ec a4 91 fd a1 48 ef b3 fb 2a |\...}......H...*| +00000300 d8 e5 a3 c7 4b 50 34 fc c1 33 dd 43 88 8d 6e 16 |....KP4..3.C..n.| +00000310 9e 0c d7 b0 7f b2 77 cc da e0 8e 02 9e db 2f 12 |......w......./.| +00000320 3b 4f 5b 7b c2 eb e3 10 5c 6f 43 d6 54 e1 8c 55 |;O[{....\oC.T..U| +00000330 ec 51 93 f8 12 5e f6 09 92 a1 95 51 db 75 97 17 |.Q...^.....Q.u..| +00000340 bc cd 80 71 e9 14 03 03 00 11 4b d7 45 5f 00 cd |...q......K.E_..| +00000350 ad 58 83 c6 14 13 d2 89 fa a8 2b 16 03 03 00 20 |.X........+.... | +00000360 33 77 49 9f ff 97 4c 6a f7 42 45 d4 59 6a 1e 6e |3wI...Lj.BE.Yj.n| +00000370 12 29 e7 62 01 0c 9e 8c e2 f1 7f fb aa a4 05 e2 |.).b............| >>> Flow 10 (server to client) -00000000 14 03 03 00 11 ce 28 cc ba 60 2b 9a 92 b1 a1 fc |......(..`+.....| -00000010 73 25 71 fd f5 59 16 03 03 00 20 5d 9c a5 c1 2f |s%q..Y.... ].../| -00000020 2a f3 af 84 9b 15 cd fa a1 6e ca a0 09 2b a4 b8 |*........n...+..| -00000030 e9 e2 b8 eb 17 84 d0 fb 20 7e fc 17 03 03 00 19 |........ ~......| -00000040 43 86 e9 94 82 d6 08 ac a3 90 97 05 b6 f0 54 28 |C.............T(| -00000050 3d d1 c9 f8 d9 19 5a d4 ed |=.....Z..| +00000000 14 03 03 00 11 b3 52 01 6f eb 60 f2 1e 3c 03 47 |......R.o.`..<.G| +00000010 0b be 2c 14 06 9c 16 03 03 00 20 ac c1 ed 57 1b |..,....... ...W.| +00000020 87 8a c6 78 a7 36 17 2b 61 fd db d3 cc 23 88 5e |...x.6.+a....#.^| +00000030 8c 40 1b 04 10 40 1c 51 75 a3 3f 17 03 03 00 19 |.@...@.Qu.?.....| +00000040 16 55 b1 d2 86 e7 fa be 59 4a 7f 13 b5 aa af d1 |.U......YJ......| +00000050 0c 50 2a 7f a9 b9 c5 eb 45 |.P*.....E| >>> Flow 11 (client to server) -00000000 15 03 03 00 12 05 a9 95 98 5c 81 dc ae eb bc 17 |.........\......| -00000010 2e 08 b5 32 82 45 23 |...2.E#| +00000000 15 03 03 00 12 4c e2 da 21 11 be 48 2d 52 09 32 |.....L..!..H-R.2| +00000010 83 9b 6f dc a8 6c 5c |..o..l\| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-RenegotiateTwice b/libgo/go/crypto/tls/testdata/Client-TLSv12-RenegotiateTwice index fb5ca90e034..f85c6907fab 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv12-RenegotiateTwice +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-RenegotiateTwice @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 03 00 59 02 00 00 55 03 03 72 05 00 95 36 |....Y...U..r...6| -00000010 6c a5 d1 0f 06 bd 25 80 25 19 16 0d 70 56 8f c4 |l.....%.%...pV..| -00000020 b4 e9 17 be d2 06 09 b4 05 bc 2e 20 bc b9 5a 92 |........... ..Z.| -00000030 44 a5 91 7c 82 7e b6 c3 50 da cd f2 98 e1 26 14 |D..|.~..P.....&.| -00000040 d3 eb e2 98 c7 f6 6c 96 71 d3 7e b4 cc a8 00 00 |......l.q.~.....| +00000000 16 03 03 00 59 02 00 00 55 03 03 51 2d ad 23 79 |....Y...U..Q-.#y| +00000010 a1 68 89 d6 6d 78 78 ba 0d 65 e7 86 46 c7 5c c9 |.h..mxx..e..F.\.| +00000020 3c fd 70 0e 82 d3 fa 66 5d 98 8a 20 db 5d a5 7f |<.p....f].. .]..| +00000030 85 73 11 b9 cd 80 4c f1 87 a2 5a 33 d7 4d af 49 |.s....L...Z3.M.I| +00000040 ed 3b 5f 3d 13 6f a4 38 1e c9 75 13 cc a8 00 00 |.;_=.o.8..u.....| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 03 02 59 0b 00 02 55 00 02 52 00 02 4f 30 82 02 |..Y...U..R..O0..| 00000070 4b 30 82 01 b4 a0 03 02 01 02 02 09 00 e8 f0 9d |K0..............| @@ -54,219 +60,284 @@ 00000290 77 8d 0c 1c f1 0f a1 d8 40 83 61 c9 4c 72 2b 9d |w.......@.a.Lr+.| 000002a0 ae db 46 06 06 4d f4 c1 b3 3e c0 d1 bd 42 d4 db |..F..M...>...B..| 000002b0 fe 3d 13 60 84 5c 21 d3 3b e9 fa e7 16 03 03 00 |.=.`.\!.;.......| -000002c0 ac 0c 00 00 a8 03 00 1d 20 f0 1b 05 7a 25 88 37 |........ ...z%.7| -000002d0 65 0d 93 e7 44 ff b4 bd 8d 9a eb ca 4f 31 c6 42 |e...D.......O1.B| -000002e0 f8 83 aa 1e 33 6c c8 3f 2a 04 01 00 80 0c 5b 0c |....3l.?*.....[.| -000002f0 92 86 55 5a 05 c9 f0 df 0a 1f 57 46 24 53 a6 77 |..UZ......WF$S.w| -00000300 f9 6b b0 a0 2e a3 64 f0 21 f1 93 10 de 9c 6f fb |.k....d.!.....o.| -00000310 68 8c f0 d4 f6 b4 81 f6 60 8a 64 ee af f6 ee 3c |h.......`.d....<| -00000320 d8 45 fc 3a 70 1d 89 c2 11 94 4e 9a 5c ee 67 64 |.E.:p.....N.\.gd| -00000330 24 91 2c 97 09 ba 1f 76 2d ca e4 a1 52 e9 d6 8a |$.,....v-...R...| -00000340 e5 21 42 66 80 95 72 61 6e d7 09 eb db 30 fc b7 |.!Bf..ran....0..| -00000350 8e d6 3a 91 97 14 09 33 15 9a 5d 45 a9 53 0b 3d |..:....3..]E.S.=| -00000360 49 3b ba 95 8c ae 96 06 e1 e9 4c 2f 72 16 03 03 |I;........L/r...| +000002c0 ac 0c 00 00 a8 03 00 1d 20 68 e3 7e b2 34 ed 21 |........ h.~.4.!| +000002d0 05 68 aa 61 70 f7 67 5b ab 93 87 9c 8d 70 96 a7 |.h.ap.g[.....p..| +000002e0 63 b8 ab 89 84 6b 89 08 13 08 04 00 80 94 a2 04 |c....k..........| +000002f0 de e3 fa 20 2b ea 31 3b c6 d9 ef 04 d9 7f 83 f8 |... +.1;........| +00000300 f1 1e f3 9b d8 d6 db f1 bc 52 52 15 09 c7 6b 17 |.........RR...k.| +00000310 56 ed 2c 51 2f ba 9c 23 1b 49 0f c6 d9 05 5c 66 |V.,Q/..#.I....\f| +00000320 d0 19 af 29 d3 65 60 75 06 4e 15 7b c1 08 fe ac |...).e`u.N.{....| +00000330 0d b2 8c 65 67 f0 5a 9d 9f ed 33 dd 6a 09 58 0b |...eg.Z...3.j.X.| +00000340 25 ed 45 57 ea 61 a1 72 cb 39 ef fc 8b 06 94 b9 |%.EW.a.r.9......| +00000350 68 ff 73 c5 52 8e 2b ef c5 39 e7 93 34 2a cf c1 |h.s.R.+..9..4*..| +00000360 54 cf c3 63 a2 2c 06 92 9f d9 8b 24 2c 16 03 03 |T..c.,.....$,...| 00000370 00 04 0e 00 00 00 |......| >>> Flow 3 (client to server) 00000000 16 03 03 00 25 10 00 00 21 20 2f e5 7d a3 47 cd |....%...! /.}.G.| 00000010 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 |bC.(.._.).0.....| 00000020 cf c2 ed 90 99 5f 58 cb 3b 74 14 03 03 00 01 01 |....._X.;t......| -00000030 16 03 03 00 20 f7 8a a0 59 29 4a b5 a1 1a d2 9c |.... ...Y)J.....| -00000040 d7 4f f7 eb 76 ed 9f d5 93 cb 30 dc dd a1 28 0a |.O..v.....0...(.| -00000050 82 3e fb 3b d0 |.>.;.| +00000030 16 03 03 00 20 c5 ed 46 65 cc 21 42 fc 0f 93 4b |.... ..Fe.!B...K| +00000040 0e 73 eb 8f 8e e2 fe 45 f0 0e 64 f5 1b db 79 a6 |.s.....E..d...y.| +00000050 60 7f ca 5c 72 |`..\r| >>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 20 01 ce 8d 74 22 |.......... ...t"| -00000010 4a 7e 22 fe ab b4 ed 5e 05 27 3f e9 35 97 f4 ef |J~"....^.'?.5...| -00000020 c5 df 0c 7f d7 6a 10 94 a0 72 dc |.....j...r.| +00000000 14 03 03 00 01 01 16 03 03 00 20 eb 22 65 3b 95 |.......... ."e;.| +00000010 dd f8 04 5c 3e cc cb e7 e3 d0 bf 86 bf d6 70 f7 |...\>.........p.| +00000020 1d 75 87 28 bb be 28 e3 b4 fd 7b |.u.(..(...{| >>> Flow 5 (client to server) -00000000 17 03 03 00 16 cc f5 66 f6 5e d6 b5 53 e6 d6 29 |.......f.^..S..)| -00000010 90 c6 dc b3 ad b5 43 ea 16 80 88 |......C....| +00000000 17 03 03 00 16 d0 03 3c 9c 0a 2f 8e 12 d7 9b 3f |.......<../....?| +00000010 66 d3 6b e4 4d 2b be bf 61 e0 f1 |f.k.M+..a..| >>> Flow 6 (server to client) -00000000 16 03 03 00 14 0e 28 a6 a0 4a 78 90 fa d5 ed 0a |......(..Jx.....| -00000010 45 b8 21 75 18 de 93 16 12 |E.!u.....| +00000000 16 03 03 00 14 f2 1c 0c 2c 61 9c 59 eb b5 b2 17 |........,a.Y....| +00000010 50 46 fd a1 3f 06 2c fc ef |PF..?.,..| >>> Flow 7 (client to server) -00000000 16 03 03 00 b1 60 7a a2 91 30 f4 5b a4 5f 4c 38 |.....`z..0.[._L8| -00000010 5e 44 34 09 02 13 c3 1b 02 d3 64 e4 f3 c2 35 87 |^D4.......d...5.| -00000020 b2 4b 39 fd 89 10 12 42 97 b9 97 e5 67 82 0a 5c |.K9....B....g..\| -00000030 24 28 5a 0c be db d2 0b f7 ac b7 f4 9d c1 0f 0a |$(Z.............| -00000040 76 e4 6f 41 e2 31 e3 35 0b 39 71 a9 31 56 b0 41 |v.oA.1.5.9q.1V.A| -00000050 13 d6 0f 2c 10 e9 e7 bb 37 2a e9 b2 4d 8a f3 8a |...,....7*..M...| -00000060 5a ab 12 02 99 ba e4 45 b9 2d c6 be 45 35 37 6a |Z......E.-..E57j| -00000070 e5 24 be db 79 39 df 5e c8 a8 58 42 2d 40 00 96 |.$..y9.^..XB-@..| -00000080 89 8a 2e 45 32 61 3e 65 18 c1 8f bf 90 da 60 bd |...E2a>e......`.| -00000090 03 34 ad 93 ac aa 33 55 31 8c 41 fa d0 85 42 a8 |.4....3U1.A...B.| -000000a0 dd 69 2f fb e5 21 c6 64 39 42 8c af b6 1d 21 e2 |.i/..!.d9B....!.| -000000b0 47 ec 11 ed 4d 6d |G...Mm| +00000000 16 03 03 01 14 06 cd f6 16 2c a0 d5 ee c5 42 68 |.........,....Bh| +00000010 c9 5f a9 b0 e7 79 0f 20 7c 0c 85 a9 ad df ee d6 |._...y. |.......| +00000020 3e 8c ce ea c0 db 1a d4 9d b7 7d db 9f 37 91 93 |>.........}..7..| +00000030 90 1e 48 ce a4 71 df 23 03 0d 29 82 7a 63 ee 2a |..H..q.#..).zc.*| +00000040 82 83 e6 e1 50 ab d2 9b 82 94 de 3d ae 0c e4 8a |....P......=....| +00000050 eb e7 3a d9 cb fb 87 24 2d 91 a3 65 e5 df 36 03 |..:....$-..e..6.| +00000060 ef e4 93 4b 24 aa a5 04 17 60 68 2b 0d c9 e0 24 |...K$....`h+...$| +00000070 18 69 7b 28 59 48 d6 1a 6e 74 23 7c 54 65 8c 3f |.i{(YH..nt#|Te.?| +00000080 51 67 e2 94 35 ce 60 2c 04 3d 04 15 31 b1 42 8a |Qg..5.`,.=..1.B.| +00000090 34 6c b6 47 d9 e0 3c e9 77 62 5f 76 c1 4a d3 f6 |4l.G..<.wb_v.J..| +000000a0 56 b9 08 28 b7 c3 a5 ae 45 0e 26 95 3d fe 97 b4 |V..(....E.&.=...| +000000b0 30 52 6d 57 5a 1f 95 97 67 18 b4 03 f3 b8 8d 0b |0RmWZ...g.......| +000000c0 49 bb 66 87 fb aa 36 35 00 7b fe d9 f1 7b 2b 7e |I.f...65.{...{+~| +000000d0 03 47 80 87 2b c9 17 c9 2e 45 82 af cd 67 49 e2 |.G..+....E...gI.| +000000e0 a7 b5 fb 30 21 23 c6 22 a1 e7 f1 a1 3b 19 ff 04 |...0!#."....;...| +000000f0 1c b4 99 7d b0 5e 49 43 5d 0e d4 62 04 7d 52 ed |...}.^IC]..b.}R.| +00000100 b4 50 86 06 83 d6 e6 9e 42 3d ee 9d 27 f7 6a 11 |.P......B=..'.j.| +00000110 f6 c8 da 92 a2 23 49 8d 80 |.....#I..| >>> Flow 8 (server to client) -00000000 16 03 03 00 81 1b 98 a8 9a 8f 4f c6 d0 1f b0 21 |..........O....!| -00000010 74 47 2a af 9f 6d a0 fb 4e 99 ed ad 05 99 5a 34 |tG*..m..N.....Z4| -00000020 ab 9c 4d c0 24 72 15 f4 6f ba 8f d2 43 33 d5 8b |..M.$r..o...C3..| -00000030 3a f6 10 cd d3 50 3e 8c b7 d6 03 b7 1c 28 d7 fb |:....P>......(..| -00000040 47 1c b9 a7 14 a4 6e 8e 06 65 d3 b8 8a 8c 73 ee |G.....n..e....s.| -00000050 36 63 24 bf 5a c8 0a 27 1f 93 a4 fc 50 c9 48 d0 |6c$.Z..'....P.H.| -00000060 43 27 63 6d c3 d9 ca bf 2c 03 c8 d1 e3 d1 94 43 |C'cm....,......C| -00000070 e0 12 87 b1 96 14 b4 7f ac 8a 85 50 5d f7 64 0e |...........P].d.| -00000080 05 cd 47 43 59 5e 16 03 03 02 69 90 f1 fe ba 32 |..GCY^....i....2| -00000090 b5 0d 2f 98 95 2f c1 95 9a 09 32 ab 9f a8 a8 bc |../../....2.....| -000000a0 2d f0 cf 7e 7f d0 f8 b9 0c e0 11 84 03 8e d3 27 |-..~...........'| -000000b0 c5 15 07 81 02 fa 64 7b eb 21 63 59 15 ba 9e 4e |......d{.!cY...N| -000000c0 6d 03 81 f4 d8 8b 4d f4 82 fd 62 1f 9f 28 64 80 |m.....M...b..(d.| -000000d0 5b af d3 fc fc 2e dd 6c b0 5c 28 5e 58 e7 01 07 |[......l.\(^X...| -000000e0 86 d1 40 35 f2 9c 2c 45 c0 2a 86 67 30 d4 d4 51 |..@5..,E.*.g0..Q| -000000f0 6c 18 31 bd 22 2e d0 6c ea d8 f4 9b 87 30 ea 09 |l.1."..l.....0..| -00000100 66 11 36 a3 ae f5 a7 91 a0 76 8e 77 c1 3d f7 3a |f.6......v.w.=.:| -00000110 88 29 b2 c4 2f 4e cd c6 d9 93 80 7f 9b 29 3a a4 |.)../N.......):.| -00000120 f5 63 77 7d 54 07 62 8c bc 23 c8 36 ea a8 e5 c4 |.cw}T.b..#.6....| -00000130 46 4b 59 dc 02 58 9d 21 00 47 39 29 60 9a 14 d8 |FKY..X.!.G9)`...| -00000140 ae 55 5c 03 fd 05 b7 66 30 de 81 87 9c 45 9f 52 |.U\....f0....E.R| -00000150 1e c5 2d d8 6a 7d d0 64 7b 0c 3a 47 b9 ff dd dd |..-.j}.d{.:G....| -00000160 60 a6 fa 69 f9 a0 43 a5 97 27 e8 fe 2d 99 94 01 |`..i..C..'..-...| -00000170 d7 52 c2 b2 ec 77 10 af ed 5e f6 82 d4 15 60 aa |.R...w...^....`.| -00000180 d3 cd 39 e5 a6 92 c9 f8 9e 63 e1 83 71 33 f2 dc |..9......c..q3..| -00000190 dd 7a eb de ac 91 46 06 ef 23 b2 6f 39 33 69 75 |.z....F..#.o93iu| -000001a0 43 d7 e5 e1 b0 5c 2f 0f 2d 39 d6 14 11 cd 6b a2 |C....\/.-9....k.| -000001b0 37 d2 32 0b b6 45 ad 2c b8 26 ef 43 3e 63 b0 1f |7.2..E.,.&.C>c..| -000001c0 a1 79 d2 c7 84 f9 7a 5f b2 c2 fd 4e 22 89 23 1d |.y....z_...N".#.| -000001d0 b7 4c 6c b5 b1 c1 19 a9 7c f7 23 bf 91 0e aa 8c |.Ll.....|.#.....| -000001e0 da 67 68 57 84 b9 68 5f 69 16 ad c7 32 86 98 81 |.ghW..h_i...2...| -000001f0 06 01 91 66 fd 5e e3 f5 63 4b e3 05 6d 41 f0 4e |...f.^..cK..mA.N| -00000200 f2 b1 70 26 de ed e5 83 87 d3 cf 5d 5c 7b d5 14 |..p&.......]\{..| -00000210 08 e9 e3 88 9a d0 9a e4 d6 40 44 1b 61 57 8f a3 |.........@D.aW..| -00000220 8a 52 5e 83 75 07 3d c2 16 00 3c a3 e9 61 cb 41 |.R^.u.=...<..a.A| -00000230 66 e7 54 7c e1 e5 7b 85 cb 0d f6 50 93 7d 85 c1 |f.T|..{....P.}..| -00000240 de 98 a8 8d 5a 0d 12 80 25 78 25 15 a3 0c 7a 7f |....Z...%x%...z.| -00000250 43 45 2e 0f e0 47 05 9f b2 2a 0d 9f 23 e3 0b 62 |CE...G...*..#..b| -00000260 33 91 d9 d8 7f f5 ac ed ef fd ea a5 f5 df 04 e8 |3...............| -00000270 6f 4a bd a2 bf aa fe 56 49 13 7a d3 58 2b ef ab |oJ.....VI.z.X+..| -00000280 ed f8 4b 6f 77 18 1e 37 59 2c 98 85 c4 59 f5 08 |..Kow..7Y,...Y..| -00000290 a6 03 f3 9b b0 79 24 cc 61 55 e3 b7 a7 f5 96 58 |.....y$.aU.....X| -000002a0 39 57 ec 40 33 a8 94 a2 c8 7f d4 5a f6 5e b0 be |9W.@3......Z.^..| -000002b0 89 b8 4d 45 73 ef 9f e9 cc d1 31 f8 46 97 82 be |..MEs.....1.F...| -000002c0 fa 44 de 62 36 47 6f 7b 5e 50 af b6 1b d2 0b 02 |.D.b6Go{^P......| -000002d0 17 df 6b c4 b5 ca 60 39 49 2e 86 d7 84 60 37 34 |..k...`9I....`74| -000002e0 65 43 0d f7 04 88 38 e4 5f 65 19 d0 62 8c 29 b6 |eC....8._e..b.).| -000002f0 2d d2 52 0f 16 03 03 00 bc 30 b3 f2 e1 bd 5e ec |-.R......0....^.| -00000300 c3 68 8a cc b4 4d e1 f1 76 e7 c1 47 0a c2 54 c1 |.h...M..v..G..T.| -00000310 9d d9 2d 72 1b 44 2d 3e 3d 22 5b 7d a1 c0 17 27 |..-r.D->="[}...'| -00000320 97 dd fe 9e a1 c5 5b ce 5f eb 9d 72 0e 14 ca b1 |......[._..r....| -00000330 61 f6 03 6e 84 d5 c4 53 91 ed 22 41 6e c9 84 91 |a..n...S.."An...| -00000340 59 a2 30 38 2a 29 b3 b8 9e 45 3a 1f 98 30 ce a4 |Y.08*)...E:..0..| -00000350 41 8a d9 ea e8 8d ee 43 cc 29 94 8c e5 86 cc 7b |A......C.).....{| -00000360 04 a7 31 1e 87 2b aa da 6c d0 4a a7 08 6e 31 2f |..1..+..l.J..n1/| -00000370 c3 95 06 3e 6d 9c 1b bb db 74 f5 a2 7e 6a 17 5f |...>m....t..~j._| -00000380 4c 2f f5 56 69 89 04 f7 17 41 85 ea 35 2f 59 db |L/.Vi....A..5/Y.| -00000390 d3 b9 f9 7a 6c 08 f8 f2 2d ba 04 ef 57 b5 d0 2f |...zl...-...W../| -000003a0 f3 3d 31 e6 c1 f8 26 9d 06 be 38 94 ba 8e ca 3f |.=1...&...8....?| -000003b0 4c 5b 70 c6 09 16 03 03 00 14 1e 86 bf c9 1e 7c |L[p............|| -000003c0 08 0c 5a fb e4 92 8c f9 78 85 34 e3 56 86 |..Z.....x.4.V.| +00000000 16 03 03 00 81 7b f1 ac 76 fd 28 ba 97 a6 8e 3a |.....{..v.(....:| +00000010 ae f0 9a f6 ed 64 5d 2a 50 7d b2 83 e5 de b9 3c |.....d]*P}.....<| +00000020 3c 5b ab 48 db ec a7 18 d6 fd af a1 98 32 82 1e |<[.H.........2..| +00000030 b4 8d 83 3f 44 ff e6 1e 86 2b e3 f9 39 f8 30 a4 |...?D....+..9.0.| +00000040 26 f9 cc 3f 73 d5 88 f5 90 c7 b4 20 0b d3 6b c3 |&..?s...... ..k.| +00000050 4c 81 e6 4e 83 81 a7 9d 47 0d 0b 29 4c 2a 45 e2 |L..N....G..)L*E.| +00000060 0d 8b 40 61 0d f1 ee e1 e8 db 8f 43 e4 75 71 44 |..@a.......C.uqD| +00000070 f5 e3 69 99 a7 6d 67 79 06 02 65 4a 80 84 ee d8 |..i..mgy..eJ....| +00000080 56 30 f2 a6 ad b5 16 03 03 02 69 c9 6d 2c 0f ed |V0........i.m,..| +00000090 9c 35 b6 61 29 70 0f ab a0 61 00 cc d6 aa 9c 37 |.5.a)p...a.....7| +000000a0 9a 55 e7 a7 73 77 44 1b bb f0 be 1d 28 6a 45 03 |.U..swD.....(jE.| +000000b0 d1 7e c4 ef 42 e2 37 1d 5e 5a 5e cd 73 54 05 bd |.~..B.7.^Z^.sT..| +000000c0 a5 d9 d3 0d 7d 65 a3 a2 72 86 e0 c3 2d e1 91 96 |....}e..r...-...| +000000d0 d5 11 34 e1 f0 24 97 84 95 12 9f e1 89 f5 1b e0 |..4..$..........| +000000e0 fb 59 5b c4 fa 4e d1 f4 44 34 21 5a 5e 97 1a f7 |.Y[..N..D4!Z^...| +000000f0 ba 06 e8 83 b2 4a ca b4 90 ef f2 06 d5 48 2f 18 |.....J.......H/.| +00000100 11 2b fc 5c 41 ef 73 c4 78 8c 43 3f 63 3a bd ab |.+.\A.s.x.C?c:..| +00000110 5b 61 bc 18 6c ce e3 f1 5c 55 3a 4b 78 70 91 06 |[a..l...\U:Kxp..| +00000120 8f 79 19 4b aa 02 1d 86 f9 96 e6 2c a6 01 70 19 |.y.K.......,..p.| +00000130 3a 84 f2 71 0e 18 6d 9a d6 33 d6 4d 45 7e 83 c9 |:..q..m..3.ME~..| +00000140 21 6a dd 3d 82 1d 18 21 d7 fd b3 6f 8b 7e db ef |!j.=...!...o.~..| +00000150 5e 7c 99 5a dd d1 03 22 d1 cf 2e 73 d5 09 33 2e |^|.Z..."...s..3.| +00000160 8c 51 0b a4 7e e5 da 1b bc ed 13 ed d7 ba a9 25 |.Q..~..........%| +00000170 b7 8a 3f 1c 54 bd 1f a8 53 4b 47 37 44 55 a5 4b |..?.T...SKG7DU.K| +00000180 75 de 9c 86 d7 80 eb f5 f7 76 ff 5c 4d 70 69 02 |u........v.\Mpi.| +00000190 a8 4f b4 a0 65 d7 c5 55 34 3f b0 83 5c a8 bc 60 |.O..e..U4?..\..`| +000001a0 d3 46 c1 33 3c ef f9 53 3e 8d 86 3e c8 22 c4 e5 |.F.3<..S>..>."..| +000001b0 dd 6c 59 55 6b fe 3e 04 10 eb 7d c7 bd d8 3d 71 |.lYUk.>...}...=q| +000001c0 c2 2d 0b cd 29 a0 d9 3c cc c6 21 97 3d 24 36 1c |.-..)..<..!.=$6.| +000001d0 f5 6a b5 12 48 98 ec 91 42 85 cb 45 c2 b6 f6 64 |.j..H...B..E...d| +000001e0 c4 76 53 27 64 d3 89 f2 4e d6 98 23 25 a0 5b 54 |.vS'd...N..#%.[T| +000001f0 83 ab 53 29 5d 39 59 67 77 d0 4f 82 9e 0c 45 ae |..S)]9Ygw.O...E.| +00000200 6d 94 1a 9d 69 45 f0 37 0d 11 ee 46 4f 6a f3 81 |m...iE.7...FOj..| +00000210 ce 9b 74 02 54 a6 d6 49 98 e7 3f 7b 4c fc 53 91 |..t.T..I..?{L.S.| +00000220 80 d3 87 dd 55 91 04 ef 33 27 71 98 ef 1f df b8 |....U...3'q.....| +00000230 d6 5c 31 6f ba 58 f3 89 7b ba b6 ea 9f 75 cd 08 |.\1o.X..{....u..| +00000240 11 84 c9 e8 9f f8 8e 02 7d b7 4a 3b 6f 4d 25 46 |........}.J;oM%F| +00000250 46 5d 7c 60 71 b5 02 d1 91 59 a8 10 c2 fa e8 56 |F]|`q....Y.....V| +00000260 0f 6e 93 d1 dd c6 af e9 e1 c1 bf 64 8f 5b 04 78 |.n.........d.[.x| +00000270 74 1c f5 af ef 48 b0 9e 29 a9 6c a0 ff e4 69 bb |t....H..).l...i.| +00000280 e1 95 12 be 73 b0 35 89 82 93 b4 69 84 79 cc 78 |....s.5....i.y.x| +00000290 1d 93 05 a4 85 25 c5 a3 da 4b c7 72 66 2f 35 78 |.....%...K.rf/5x| +000002a0 62 94 d6 f3 1c dd 23 c8 86 11 fe b0 cb 2f 5c 78 |b.....#....../\x| +000002b0 45 8d 2e 0c 08 c6 7c 5c 92 80 70 25 3b 25 53 a8 |E.....|\..p%;%S.| +000002c0 86 f4 54 b6 a5 94 38 10 ff f9 3e 78 bb ce 86 fa |..T...8...>x....| +000002d0 9d 91 df 9e c1 ef 79 db 1b f8 ed b5 53 6d 24 0f |......y.....Sm$.| +000002e0 18 a8 eb cd 25 bb bb 24 64 25 4a 3e 04 00 16 f2 |....%..$d%J>....| +000002f0 9a 8b 8f 25 16 03 03 00 bc 05 1a 5b 08 49 0c 86 |...%.......[.I..| +00000300 8b 23 78 13 9e a7 3f ce 73 6b 30 ff 65 e5 a7 ba |.#x...?.sk0.e...| +00000310 a4 14 8e e2 4e 14 3a 43 d7 03 50 79 8a fb ea a6 |....N.:C..Py....| +00000320 03 06 8b d1 0b 2b 19 49 5c 50 34 67 ae 02 e7 f7 |.....+.I\P4g....| +00000330 c4 91 ff 33 ad 87 62 bd 35 e4 bf bf c8 01 9f f7 |...3..b.5.......| +00000340 69 74 b0 45 eb 10 f8 82 f6 bc 56 fa 0f 26 b7 cf |it.E......V..&..| +00000350 13 ad fa 0a 55 c1 06 b2 e7 4f 9f 75 fc 65 d6 ff |....U....O.u.e..| +00000360 e8 2d 21 22 52 bc a1 60 27 f9 7c 18 70 25 f1 76 |.-!"R..`'.|.p%.v| +00000370 8d 4a f9 83 6e a0 52 d7 37 fe 2b 1c f2 03 8e d7 |.J..n.R.7.+.....| +00000380 7d 51 a8 07 0b b8 9c e0 5d a3 ac cc bd d0 c9 8f |}Q......].......| +00000390 36 62 b7 9e 19 0d 62 82 fb c2 68 e3 0f 4f eb 3f |6b....b...h..O.?| +000003a0 33 ec f9 1a 3d c1 3d 68 46 1a 03 e1 fc 65 36 45 |3...=.=hF....e6E| +000003b0 76 c2 87 6e 21 16 03 03 00 4a 7e 1f 28 4d ae 0e |v..n!....J~.(M..| +000003c0 d3 90 13 53 ba 15 7a 68 88 1a ed 5f 50 3c 5d b2 |...S..zh..._P<].| +000003d0 11 5a 40 3a 11 44 a8 ce fa 37 b3 0a d0 02 1e cc |.Z@:.D...7......| +000003e0 f9 2f 6d 28 a8 f1 26 ea 52 36 52 5a 70 3f de 89 |./m(..&.R6RZp?..| +000003f0 5c 11 5f e0 ba 5e 18 b6 b8 b4 55 74 44 c5 a0 7c |\._..^....UtD..|| +00000400 73 7c 51 e5 16 03 03 00 14 2d fe a4 59 be 8a e0 |s|Q......-..Y...| +00000410 4a 6c e0 1a ae 8b ce 04 a0 f2 2f 1b f8 |Jl......../..| >>> Flow 9 (client to server) -00000000 16 03 03 00 35 a7 bb 37 bb b1 b0 8e 12 72 8b a8 |....5..7.....r..| -00000010 c5 d4 cc 44 1c 4b 87 1f bc cb 39 35 60 fb 06 de |...D.K....95`...| -00000020 44 ac 0a c5 13 cb 15 1b ce 6b d8 45 28 d6 80 1b |D........k.E(...| -00000030 06 1f 32 4c 26 81 77 08 9c 23 14 03 03 00 11 c0 |..2L&.w..#......| -00000040 1b 3b 4d e8 9d ba d9 2c 50 10 03 b9 0c 57 83 60 |.;M....,P....W.`| -00000050 16 03 03 00 20 e0 d7 07 fe 04 89 25 3c b6 c0 8a |.... ......%<...| -00000060 33 14 6c 3e f4 48 5c 17 33 f8 f0 11 3a cb d8 17 |3.l>.H\.3...:...| -00000070 cd 42 be 22 68 |.B."h| +00000000 16 03 03 02 69 70 17 aa 0e 85 63 a2 39 31 b1 d9 |....ip....c.91..| +00000010 b5 a0 4b 6d 29 eb 23 6c fb 66 11 6f 46 16 65 5e |..Km).#l.f.oF.e^| +00000020 79 75 aa 45 1f eb 07 99 0d 34 fa 10 90 32 5a 94 |yu.E.....4...2Z.| +00000030 2c 85 b2 8f 27 1d ae 15 49 c0 92 49 58 84 54 2a |,...'...I..IX.T*| +00000040 35 d2 f5 56 fd ed c7 0f 33 fe b4 b8 9c 5c 7e 1e |5..V....3....\~.| +00000050 59 ee 41 3e 0c b1 30 f7 2a f4 ca 2c c3 9a 0a a1 |Y.A>..0.*..,....| +00000060 96 96 81 61 77 e4 f2 f5 59 9a 57 71 31 89 7e 25 |...aw...Y.Wq1.~%| +00000070 55 ef 4c 45 8b 54 c8 83 09 41 49 c6 3e cb fe ff |U.LE.T...AI.>...| +00000080 15 ee 48 51 b4 06 c0 c0 27 fb df d1 99 c5 f0 bf |..HQ....'.......| +00000090 fe 07 0b 49 88 fe 53 cf d7 58 12 16 77 5a d1 27 |...I..S..X..wZ.'| +000000a0 29 a2 00 de 48 a6 d3 e6 b2 87 86 55 03 f5 84 3a |)...H......U...:| +000000b0 84 bf 58 ab 48 bc d0 1e f9 89 be 03 d5 af 4b 06 |..X.H.........K.| +000000c0 f2 b5 42 c7 ef a4 bb 92 d1 23 64 ba 36 16 bc ed |..B......#d.6...| +000000d0 ff 3a 43 3a 71 31 66 b5 34 a4 bb 92 3c e2 3e 7c |.:C:q1f.4...<.>|| +000000e0 b2 bb b4 c5 db 1a d4 a8 9a da 16 44 b3 8f 31 39 |...........D..19| +000000f0 3e a7 58 2d 58 af d3 bb ff 70 7e 9d 54 de 90 01 |>.X-X....p~.T...| +00000100 c8 ef d9 24 50 b5 12 c2 ca 7d f6 bf c6 38 1b ad |...$P....}...8..| +00000110 4f 78 70 3d 64 4b 25 4f bc 84 67 5c e1 c6 a4 b7 |Oxp=dK%O..g\....| +00000120 7e 05 30 ad 53 42 d7 40 c8 c0 4d 1b 0c fe 10 a9 |~.0.SB.@..M.....| +00000130 dd 4a 5e 11 3a 79 b7 10 59 a6 5e ef 51 6f cc 4a |.J^.:y..Y.^.Qo.J| +00000140 43 fb fd 5a 51 56 7d d7 d6 23 20 13 13 33 91 43 |C..ZQV}..# ..3.C| +00000150 80 9a 4c e7 f6 78 18 25 02 4a dc 38 19 16 91 ef |..L..x.%.J.8....| +00000160 c9 a6 67 c0 66 85 77 13 3a ff 21 01 ba 65 fc d3 |..g.f.w.:.!..e..| +00000170 23 d8 92 ae 46 a7 a4 7f 5f 57 3d 6d 7c f9 9c d7 |#...F..._W=m|...| +00000180 3d 56 54 4a 69 1d 62 38 d3 75 5c 9b a8 c9 b5 4e |=VTJi.b8.u\....N| +00000190 b7 d6 9e 1a 51 76 57 7b bd bb bd 4b e8 ed 2f df |....QvW{...K../.| +000001a0 34 72 6a 9c 54 3f ff f4 fe 30 3a 4f 2c 74 97 59 |4rj.T?...0:O,t.Y| +000001b0 03 8c cc 71 f3 63 c8 04 55 37 e7 39 5c 0a 84 c6 |...q.c..U7.9\...| +000001c0 75 fc b1 7f 24 59 e0 ca 59 50 29 1a 0d d3 27 47 |u...$Y..YP)...'G| +000001d0 9e ea 6d 66 5a 22 e7 0d 10 56 a2 95 de 84 0e 7e |..mfZ"...V.....~| +000001e0 6d 3a 63 d3 b4 c3 8c 61 79 f5 0a 69 51 a6 c9 69 |m:c....ay..iQ..i| +000001f0 8d 3a f8 e5 7c 04 6b ed c7 5e 70 61 d4 38 c2 93 |.:..|.k..^pa.8..| +00000200 84 26 23 c9 84 a5 ee b5 35 a9 18 6d 84 b1 bd de |.&#.....5..m....| +00000210 72 14 73 a4 ab db 68 47 b3 13 37 e7 56 a3 35 0d |r.s...hG..7.V.5.| +00000220 2c 54 88 21 d4 f1 2f ed 74 85 d6 19 45 9d 62 fa |,T.!../.t...E.b.| +00000230 02 45 d3 14 c9 8f df bd 9f fe da ab c7 e7 4c 96 |.E............L.| +00000240 62 92 ee 4f 41 99 4a 04 18 01 63 cf d1 f6 8a b0 |b..OA.J...c.....| +00000250 b5 d5 f7 26 c6 4a c7 a2 d0 f1 72 3b bf 20 82 c3 |...&.J....r;. ..| +00000260 23 c7 be 4c 55 35 c6 53 27 aa 99 38 8c da 16 03 |#..LU5.S'..8....| +00000270 03 00 35 ba 6e aa 5f 90 48 ee 19 33 dd 0d fc 31 |..5.n._.H..3...1| +00000280 cb ce 1e f2 7b 6b ff 44 60 90 88 13 c6 50 2b f5 |....{k.D`....P+.| +00000290 50 ba 48 ce 6e 3c e5 96 a8 30 bf bd de ba ab 21 |P.H.n<...0.....!| +000002a0 da ff 8b 50 4b 65 5f a3 16 03 03 00 98 87 74 48 |...PKe_.......tH| +000002b0 d2 88 7a b1 67 57 b0 c2 01 be e0 e9 41 6a 56 8f |..z.gW......AjV.| +000002c0 87 6c d2 37 09 45 40 59 9c 50 83 1b 48 6c b4 e4 |.l.7.E@Y.P..Hl..| +000002d0 d3 9b 6d 46 89 83 2a 88 4c b3 b2 58 29 3e 41 76 |..mF..*.L..X)>Av| +000002e0 4c 8a a0 cb aa e9 17 7f 48 7b 14 8a f7 ba 31 b4 |L.......H{....1.| +000002f0 b6 3a e0 12 e6 88 8c 24 5f 97 93 46 bf 27 f3 fd |.:.....$_..F.'..| +00000300 e4 d4 54 54 9e 46 b6 1d 8e 8d 20 49 7e bd 6f 09 |..TT.F.... I~.o.| +00000310 55 af 5d 7f 24 df 69 1b dc a5 76 0c 34 e7 af 4c |U.].$.i...v.4..L| +00000320 2c 1d 2c db 97 37 81 29 41 c1 4e 65 65 33 44 7c |,.,..7.)A.Nee3D|| +00000330 34 a2 dd fd 38 e4 e3 e1 dc af 2f 3f 64 2c 40 80 |4...8...../?d,@.| +00000340 cc ff d2 d4 a7 14 03 03 00 11 8a 81 be 84 7b 14 |..............{.| +00000350 28 fc b3 a5 ad 75 d6 ee 6e 5d 9b 16 03 03 00 20 |(....u..n]..... | +00000360 87 3c 57 93 46 06 f0 6f 18 ce 33 5d 77 33 6c a6 |.>> Flow 10 (server to client) -00000000 14 03 03 00 11 05 69 30 af cd 8e 28 8b 04 3c de |......i0...(..<.| -00000010 39 2c cc 79 60 dc 16 03 03 00 20 64 e4 49 e1 a5 |9,.y`..... d.I..| -00000020 59 be ed d9 04 59 24 01 16 65 aa b9 22 7d 91 5f |Y....Y$..e.."}._| -00000030 e5 e4 db a7 67 a0 10 51 7e 3b 77 17 03 03 00 19 |....g..Q~;w.....| -00000040 70 cc 7d 13 21 aa ac d3 fb a7 ee cc f6 db 51 4b |p.}.!.........QK| -00000050 2d 2a e2 66 f4 ba 29 aa e1 16 03 03 00 14 e2 ba |-*.f..).........| -00000060 56 31 77 97 4a 4a a5 f0 05 28 d5 9f b7 3e 38 50 |V1w.JJ...(...>8P| -00000070 1f 1b |..| +00000000 14 03 03 00 11 79 d6 72 03 0f 48 d1 78 b5 5e 31 |.....y.r..H.x.^1| +00000010 d6 e0 42 bc 6e 60 16 03 03 00 20 3b f1 7f a5 ab |..B.n`.... ;....| +00000020 b7 b7 10 db 3d d6 7a 8a 5a bc c5 af 58 ca 5a 0b |....=.z.Z...X.Z.| +00000030 07 27 2d df e9 aa 44 47 73 ab c5 17 03 03 00 19 |.'-...DGs.......| +00000040 0c d2 a9 df 85 db f3 99 1d 4a ce 4e 40 69 2f d7 |.........J.N@i/.| +00000050 d7 0b e3 dc b8 af 56 99 89 16 03 03 00 14 01 f2 |......V.........| +00000060 5b 6b c9 00 1c 12 e6 14 8d b6 ea 0d 18 19 a9 bd |[k..............| +00000070 07 e3 |..| >>> Flow 11 (client to server) -00000000 16 03 03 00 b1 86 78 3d 4f eb 03 b0 00 ca a5 94 |......x=O.......| -00000010 9d 70 04 ff 30 82 59 9c ea 95 44 02 f0 14 fa 3c |.p..0.Y...D....<| -00000020 aa af fa e8 17 3c ac 69 91 3d b6 23 85 85 7a be |.....<.i.=.#..z.| -00000030 11 9e 17 4e 32 79 de 3e 04 54 71 d0 ae 94 03 97 |...N2y.>.Tq.....| -00000040 d1 90 50 1f d5 8d d3 ff aa ce 0a fb 81 bd e9 11 |..P.............| -00000050 3f c2 c5 68 f9 e6 71 00 4f d9 ef cb c9 fd 0e 0d |?..h..q.O.......| -00000060 23 ce 04 f3 19 86 cb 4c a0 71 52 8e c2 90 a1 5b |#......L.qR....[| -00000070 e2 1e f4 e7 24 4c 9a b0 0c fc eb 70 d0 94 44 4e |....$L.....p..DN| -00000080 fc 5d 2e 16 2d 0f ff 61 20 3a 4d 19 cd 1c 22 d7 |.]..-..a :M...".| -00000090 d0 23 ff a9 a1 bf 79 7c 91 ba d8 15 47 9a a3 88 |.#....y|....G...| -000000a0 cb 06 f9 5d bd 8b c1 cb f6 16 ee 5d af 9c 7a 54 |...].......]..zT| -000000b0 0c af 31 ee 4a d0 |..1.J.| +00000000 16 03 03 01 14 5d 6b cf 2d 1d 78 18 d3 88 51 6c |.....]k.-.x...Ql| +00000010 34 c2 bb f0 e6 a9 8c d9 19 7f f8 3e c1 13 19 2b |4..........>...+| +00000020 61 65 46 cd 4b 3d 2e 91 a4 32 5e 49 ac 4c 67 8c |aeF.K=...2^I.Lg.| +00000030 4a 82 70 18 ac c5 70 b5 c8 9b 6b be 01 0d 91 ca |J.p...p...k.....| +00000040 ea 4d 78 e3 e5 e7 0c db 6b f4 03 31 11 e8 32 ea |.Mx.....k..1..2.| +00000050 bf 6b c2 0d f8 5f 5b 56 20 e9 81 41 53 59 e9 0e |.k..._[V ..ASY..| +00000060 a6 53 59 2e d3 cd 36 02 54 b3 c3 d5 70 64 41 b7 |.SY...6.T...pdA.| +00000070 82 55 10 89 7e 3e 4d 5b c3 32 57 ee 6c 80 6c b7 |.U..~>M[.2W.l.l.| +00000080 4e 20 ac 13 cb 9c 78 b3 eb fb 8d 0c 8a e4 4a 58 |N ....x.......JX| +00000090 de 71 71 6a 54 74 5f 12 3a 52 0f 14 93 1b f7 8f |.qqjTt_.:R......| +000000a0 14 fa 76 76 19 5b eb 8d 61 d7 ed c7 68 ed 1b 9d |..vv.[..a...h...| +000000b0 1b 91 e4 92 df 88 4f af 3c 43 38 fa 0d 19 51 3a |......O.| +000000e0 90 6e 9c 03 ff 9e 44 34 43 38 b6 0f 1f 57 11 cf |.n....D4C8...W..| +000000f0 c3 ad 0d 70 98 6e e5 70 7b 76 c7 f1 6b 69 2f 40 |...p.n.p{v..ki/@| +00000100 df fe 47 c4 32 35 1d 03 42 a0 cc ee dd 5f 34 da |..G.25..B...._4.| +00000110 74 85 4d 56 de e4 bd 0d b5 |t.MV.....| >>> Flow 12 (server to client) -00000000 16 03 03 00 81 d3 34 51 a2 7a 93 5e f9 ef 8f f7 |......4Q.z.^....| -00000010 a3 be aa 40 2c 53 e4 5d 62 2e 19 4a bf f3 dc ce |...@,S.]b..J....| -00000020 da e8 49 8e 4d 0c 68 72 3f 79 74 59 e2 8d 0c 78 |..I.M.hr?ytY...x| -00000030 b7 13 05 0f 4f df 4f 01 71 40 38 f3 79 b2 33 51 |....O.O.q@8.y.3Q| -00000040 f5 25 73 11 9a 30 b9 3c 5f d2 8b 32 71 6f 0d ef |.%s..0.<_..2qo..| -00000050 6a 42 da f6 c5 1d a4 90 ad e4 08 60 39 55 19 97 |jB.........`9U..| -00000060 a6 2c 5e 2c e3 96 ba 0c 54 50 bc b9 0f 3c 53 bd |.,^,....TP...| -00000090 92 4c 49 8e 40 86 28 53 c2 aa 43 2f 49 00 fa ee |.LI.@.(S..C/I...| -000000a0 48 0d 01 ec 94 e0 37 1a 05 97 6e ec a4 71 1e aa |H.....7...n..q..| -000000b0 50 5a 49 e9 cc 21 b0 d6 ab 38 4a 30 a7 84 ec 7d |PZI..!...8J0...}| -000000c0 38 34 91 63 3f 1a 59 eb 22 91 9b 23 23 b1 3f 7d |84.c?.Y."..##.?}| -000000d0 0c 70 23 71 0d 50 09 80 21 56 fe f2 c8 14 3d 19 |.p#q.P..!V....=.| -000000e0 91 04 a8 10 b8 2b b0 cb ff b7 6f 53 62 86 61 22 |.....+....oSb.a"| -000000f0 4e 6d 67 12 d3 18 ac 90 ab 62 42 0f cb 08 47 73 |Nmg......bB...Gs| -00000100 42 97 01 37 67 13 99 49 d6 f1 7f 0d 8a 83 6b 01 |B..7g..I......k.| -00000110 00 76 d9 3a bd 0c 7a 64 c7 49 9e 06 d6 6c 04 48 |.v.:..zd.I...l.H| -00000120 07 cc 96 03 f1 fe 38 76 b2 c3 97 ae 37 57 25 5e |......8v....7W%^| -00000130 54 18 07 b5 e2 6a ca fe 07 01 d7 9c a6 5c 95 df |T....j.......\..| -00000140 02 66 88 53 51 23 ba f2 0f b2 66 b2 df 14 61 28 |.f.SQ#....f...a(| -00000150 50 cd 7a 56 47 79 33 6e 75 0d b6 0d 66 69 eb c6 |P.zVGy3nu...fi..| -00000160 07 31 97 10 46 ec a7 59 b6 02 0b ab 40 d3 ce 88 |.1..F..Y....@...| -00000170 62 aa ab ce 1b 73 9a 62 d7 8c 7c ca 40 a0 bb 1d |b....s.b..|.@...| -00000180 ff f4 85 54 fe ae 83 61 10 ec 38 64 ab 60 36 e1 |...T...a..8d.`6.| -00000190 88 92 ba 74 e0 68 30 0b 61 7b da eb 3b d3 6b ed |...t.h0.a{..;.k.| -000001a0 fc eb 3f 98 dd 30 f1 28 bd e0 07 6b 77 53 29 02 |..?..0.(...kwS).| -000001b0 d7 18 69 2b ac 0b 4c 38 3b 35 e0 15 91 c4 34 42 |..i+..L8;5....4B| -000001c0 74 67 c0 2a 2b df 2f 70 13 7c 99 ba f6 cc e4 f4 |tg.*+./p.|......| -000001d0 bd 3c 7f cd 08 b4 3c 05 da bf c7 01 61 93 21 d6 |.<....<.....a.!.| -000001e0 1b ca b0 35 d1 89 f3 08 67 85 93 c9 da 6f cf a4 |...5....g....o..| -000001f0 ad 1e a8 70 71 4a ac 56 73 25 8f 9c 25 13 5f 2c |...pqJ.Vs%..%._,| -00000200 20 bc f2 56 af a0 03 38 43 9c 83 79 33 ea 81 8c | ..V...8C..y3...| -00000210 d8 5d c0 50 d4 44 cd df 55 e7 4e fc f6 67 55 92 |.].P.D..U.N..gU.| -00000220 39 a2 ec 25 3e 1f 7e 14 28 3b d8 84 f5 83 66 c4 |9..%>.~.(;....f.| -00000230 e1 d7 c3 63 51 d7 4e e4 72 1a da 76 ce 91 6b 56 |...cQ.N.r..v..kV| -00000240 0a 68 42 63 7e 57 31 98 cc d0 e0 3c 7c 7e 81 be |.hBc~W1....<|~..| -00000250 be 37 8d cd e7 da df 91 55 8c 71 e3 67 ec bf 6e |.7......U.q.g..n| -00000260 4c 5a a6 b6 2b 2c 31 0b da 19 66 26 f1 92 c2 7e |LZ..+,1...f&...~| -00000270 fd 12 50 6f 04 ee 83 85 bb d0 f1 77 12 10 c9 e7 |..Po.......w....| -00000280 4a 2f 17 96 55 0f 7e 1e fd 6d 18 13 74 a8 54 38 |J/..U.~..m..t.T8| -00000290 a5 ef bb 70 c9 71 07 09 c5 a3 26 f9 73 1f d0 e8 |...p.q....&.s...| -000002a0 a2 23 a1 46 46 1b f6 b1 e7 ac 22 22 ee df b9 5b |.#.FF.....""...[| -000002b0 38 02 c6 59 33 e5 12 0b 9f 49 e2 d7 de 77 30 ac |8..Y3....I...w0.| -000002c0 1e a0 ee 20 9f 1b 1d e0 8c fd d4 02 09 7b 1b d6 |... .........{..| -000002d0 c7 41 de 67 90 71 5f 06 ea ac 18 e7 5f 11 67 c3 |.A.g.q_....._.g.| -000002e0 d6 5d c1 37 0a 67 5b f7 93 93 eb 29 70 e3 cb 7f |.].7.g[....)p...| -000002f0 2c c9 bb 6b 16 03 03 00 bc ab 60 8e 1d 2e e1 42 |,..k......`....B| -00000300 81 91 89 69 78 5d 99 9c e7 1b d1 ac 36 39 c5 32 |...ix]......69.2| -00000310 58 4e 4c 48 b9 15 eb 21 b6 24 df 8e b2 16 f0 95 |XNLH...!.$......| -00000320 cd 57 8e 14 3b 5b a2 f9 7a 10 0d fa 57 52 70 f9 |.W..;[..z...WRp.| -00000330 b8 a9 b0 fd 22 0a 51 ef dd ba 3c fb 68 00 05 45 |....".Q...<.h..E| -00000340 d6 c3 1f 56 91 b4 06 80 a4 28 84 a5 bb 11 72 af |...V.....(....r.| -00000350 b7 f6 14 58 76 b7 76 ad 1b e6 65 57 af f7 46 a2 |...Xv.v...eW..F.| -00000360 bc 60 12 6d 30 d3 cf 26 62 9d 9f 19 b0 28 96 d2 |.`.m0..&b....(..| -00000370 e2 43 de 64 90 49 1d 29 2c bb 59 4c c7 d1 9b be |.C.d.I.),.YL....| -00000380 c3 e9 ae 8e 74 36 1b 03 00 43 65 56 30 3b e6 8b |....t6...CeV0;..| -00000390 4c d9 98 a2 f7 2b 06 77 4b 9c 53 c4 7f 24 88 75 |L....+.wK.S..$.u| -000003a0 30 91 66 fa ba 9c 7f 84 ab c1 51 21 1c d3 2e 93 |0.f.......Q!....| -000003b0 f9 4d db 6e 08 16 03 03 00 14 ed f9 cc ef c4 2b |.M.n...........+| -000003c0 fd 97 fe 35 ad 33 01 46 9b 52 d7 e9 49 c2 |...5.3.F.R..I.| +00000000 16 03 03 00 81 06 1c 3a f7 71 f8 76 6c b0 7b fc |.......:.q.vl.{.| +00000010 04 d3 69 d9 6d 26 1c 0b fb 7e 16 41 78 bc ba b8 |..i.m&...~.Ax...| +00000020 ee 1f f5 00 e7 1d 32 84 7f 87 66 cb f9 5e e5 6c |......2...f..^.l| +00000030 26 f9 64 83 13 49 a6 ab 98 a2 74 25 61 e1 3a ec |&.d..I....t%a.:.| +00000040 f8 8f 0b e4 ca c3 0d 52 76 38 e2 d1 86 ac ee 7b |.......Rv8.....{| +00000050 5c 69 96 e3 ec 3b f0 5a 4c 5e 8b 73 8f 24 75 bc |\i...;.ZL^.s.$u.| +00000060 7a 48 b3 b2 cc 55 7d 20 4a e1 9b 90 5e 47 b5 71 |zH...U} J...^G.q| +00000070 88 e6 8a a1 a4 f6 45 8e 8b 5b ed 45 96 95 96 7d |......E..[.E...}| +00000080 8b 7c 4d 03 64 34 16 03 03 02 69 d5 41 cd af 43 |.|M.d4....i.A..C| +00000090 42 5f f3 98 87 0a 55 7f c3 02 9c dd b5 8c 22 2e |B_....U.......".| +000000a0 8f 52 71 29 8a 33 dc 22 45 fc 61 bf b4 db fe 4c |.Rq).3."E.a....L| +000000b0 de 69 10 69 df a2 45 e5 fa 78 e8 1c 0a d0 c6 7d |.i.i..E..x.....}| +000000c0 7e 26 3b 12 e0 56 a2 c7 b8 cd 2a 15 8d 20 2a 86 |~&;..V....*.. *.| +000000d0 67 f6 e8 36 3d c6 3e 75 09 15 ba 36 37 46 f0 45 |g..6=.>u...67F.E| +000000e0 de 7a 49 fd 32 3c fc 2f ab de 9c 28 f7 20 ad aa |.zI.2<./...(. ..| +000000f0 e7 10 60 24 71 35 bf 1c ba 4e 98 92 e0 44 0a 39 |..`$q5...N...D.9| +00000100 3c f6 7d 0f 4f aa b4 db 22 7b b5 cc f6 0a 59 46 |<.}.O..."{....YF| +00000110 ba 8d ef dc 13 b5 bd 55 cd 73 50 e7 cb b3 08 3e |.......U.sP....>| +00000120 0c a2 d7 5a 12 bf ce 99 8d 05 ee 4a 03 e9 b7 65 |...Z.......J...e| +00000130 0c 1e 41 46 08 bb 2c 9e 7e e2 c1 6f 3d 9f f4 e2 |..AF..,.~..o=...| +00000140 cc c5 7c b6 87 aa 49 8e a6 67 46 88 d0 ae 17 c9 |..|...I..gF.....| +00000150 14 ae 63 67 bc 57 02 8f 84 90 17 e0 1d 48 80 c2 |..cg.W.......H..| +00000160 7a f2 be c1 5a 44 b3 f3 3a 9a ac b0 41 87 a7 07 |z...ZD..:...A...| +00000170 bb b2 7d 7c 0d 42 a3 c6 d8 d9 ef 0c c6 5b 14 f6 |..}|.B.......[..| +00000180 82 cd 12 01 39 78 dc b2 46 59 22 22 1f d9 39 cf |....9x..FY""..9.| +00000190 b6 ac 13 be 22 50 37 10 33 01 0e 13 ee bc f3 bf |...."P7.3.......| +000001a0 55 c6 61 2a e0 ee 25 f3 01 35 69 7a 74 70 bd 6c |U.a*..%..5iztp.l| +000001b0 d5 08 c5 a3 09 71 8d ea 39 ec 0e c0 f0 16 2f 71 |.....q..9...../q| +000001c0 86 af 28 d9 3e d4 45 b2 ce e7 f8 2b bd 54 9c 98 |..(.>.E....+.T..| +000001d0 85 7d 2a f8 fe a5 95 0b da 08 2a 32 f7 c3 ad 09 |.}*.......*2....| +000001e0 2a aa ee ee 54 fa d5 2d 84 45 cf a0 2c 9c 9b 4a |*...T..-.E..,..J| +000001f0 3c 86 4f 20 12 a7 8a b5 91 36 a9 d2 1a 76 2d 1f |<.O .....6...v-.| +00000200 61 8d 5c 69 15 a1 36 ce 6b 99 48 c9 73 b0 58 69 |a.\i..6.k.H.s.Xi| +00000210 38 c2 48 5d 74 69 7b fb e8 b1 0f a1 03 d6 bd 5f |8.H]ti{........_| +00000220 5c 44 fa 0f 33 33 ce f0 ab 02 f3 26 9f bc 5b 3d |\D..33.....&..[=| +00000230 3f 08 00 a9 1b a5 ee 92 8c 62 a5 32 22 10 05 0e |?........b.2"...| +00000240 bb 59 03 03 6f 5f d1 39 3e 14 66 2f 92 e6 5a 21 |.Y..o_.9>.f/..Z!| +00000250 3a ae b0 12 2c 74 f1 b1 d7 55 9b e9 0c 2a c5 db |:...,t...U...*..| +00000260 ac ae a3 69 49 de 4b 10 68 d4 05 f2 ff 4b c6 21 |...iI.K.h....K.!| +00000270 f8 a7 8f dc 5f 82 f9 4f cf 2e 68 1a 7b 6f 3a eb |...._..O..h.{o:.| +00000280 13 a8 c3 9f 86 aa 80 d3 5c f0 b0 f5 7b 8b 91 2c |........\...{..,| +00000290 e3 d2 bd 9c ad 66 dc 7c 77 0d 73 4e 0b 51 91 23 |.....f.|w.sN.Q.#| +000002a0 f3 38 bb 2b 5a ee 1a 1e 39 40 b1 a3 b9 14 0f 16 |.8.+Z...9@......| +000002b0 78 c9 4a 6e df c4 a4 ce 53 e9 a1 f9 17 14 0a e6 |x.Jn....S.......| +000002c0 b6 3e 4a 25 6f 6e 00 8c a5 67 98 ec e3 22 fe 30 |.>J%on...g...".0| +000002d0 1d 43 c7 62 c8 2a a5 6f 88 99 f6 d1 ba 8a 73 16 |.C.b.*.o......s.| +000002e0 2f 11 b6 a3 46 25 59 67 6e 8b 38 ec ad a4 06 19 |/...F%Ygn.8.....| +000002f0 6e 2e 6c 39 16 03 03 00 bc b5 1d 9a f1 bd 76 6b |n.l9..........vk| +00000300 01 48 91 51 c4 d1 9a a6 35 f5 a8 b3 51 f3 98 cb |.H.Q....5...Q...| +00000310 6d 0e 6d 4f 6f 8b 2b dd 2c 3b b5 0e f0 c5 6a e6 |m.mOo.+.,;....j.| +00000320 ed 04 60 94 3f d2 6a af cf 9b 25 7f d9 56 4e 48 |..`.?.j...%..VNH| +00000330 2c 6b 9c 2c 68 da ed 83 87 13 90 0a 77 39 7e 69 |,k.,h.......w9~i| +00000340 ec 2c 4b bb 51 82 55 9d 8e 59 69 6e 72 dd 4d fb |.,K.Q.U..Yinr.M.| +00000350 2a 5c cf ef 47 13 8d 94 48 5e e8 8f 2c d4 47 14 |*\..G...H^..,.G.| +00000360 82 aa e4 24 04 3f 8c ef c8 3b 15 c0 53 63 b5 6b |...$.?...;..Sc.k| +00000370 ee f7 16 45 17 e4 6b 41 99 4b 18 34 c8 7c 09 f5 |...E..kA.K.4.|..| +00000380 3a f3 79 06 ea 5d f8 96 48 9d 6f c7 ac 55 b0 9e |:.y..]..H.o..U..| +00000390 f9 95 6d e2 31 ce ac 6a b6 4e 8d 66 16 1f dd d9 |..m.1..j.N.f....| +000003a0 e2 2a c6 7d fa ef 37 e6 7b 01 a1 f7 71 76 14 9a |.*.}..7.{...qv..| +000003b0 08 ed a9 f7 8d 16 03 03 00 14 aa 66 05 9c d7 08 |...........f....| +000003c0 9e d8 82 f7 91 18 57 23 4d 9f e9 17 ee f3 |......W#M.....| >>> Flow 13 (client to server) -00000000 16 03 03 00 35 77 aa f6 e5 92 a0 83 9f b7 0e e3 |....5w..........| -00000010 d2 ae 3e 72 3d 67 59 0a 67 04 10 3c 44 9c 6f 8e |..>r=gY.g..>> Flow 14 (server to client) -00000000 14 03 03 00 11 d8 e7 6c 77 f7 f2 11 7c 9b 9b 4e |.......lw...|..N| -00000010 3a a6 e5 d6 2b 47 16 03 03 00 20 b6 28 ee e6 7b |:...+G.... .(..{| -00000020 27 b1 3d c7 b4 d0 ba aa 65 b8 44 f1 8b 1e c2 1a |'.=.....e.D.....| -00000030 1c 63 4d d6 d8 f6 08 e2 9b bb 34 17 03 03 00 19 |.cM.......4.....| -00000040 ed 7c 4e b7 db f6 88 4f 68 85 e9 ff a3 48 96 39 |.|N....Oh....H.9| -00000050 5d 39 69 5b 92 8f 43 c5 ba |]9i[..C..| +00000000 14 03 03 00 11 1b d5 02 f0 2f 26 af 60 d4 c5 18 |........./&.`...| +00000010 86 d6 d3 7a 70 7e 16 03 03 00 20 03 bd c7 ba 11 |...zp~.... .....| +00000020 ab 10 4e 29 23 6c c9 7e 04 b2 da f4 87 3b d7 f1 |..N)#l.~.....;..| +00000030 55 e7 09 29 99 f0 8f cc 3c 98 25 17 03 03 00 19 |U..)....<.%.....| +00000040 6b 68 7e 24 a0 ce 39 e6 1e ca 06 59 71 a1 b1 8a |kh~$..9....Yq...| +00000050 f0 eb 5d 30 84 04 46 64 5f |..]0..Fd_| >>> Flow 15 (client to server) -00000000 15 03 03 00 12 45 0b 80 2d f1 c6 08 39 3c 70 07 |.....E..-...9>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 03 00 59 02 00 00 55 03 03 15 c2 a7 b9 2f |....Y...U....../| -00000010 c7 f0 d8 ce 09 47 ff 49 c2 09 ea b1 59 ab ab cf |.....G.I....Y...| -00000020 d8 97 31 dd e6 5a 84 6e 39 af 23 20 7d 9c ed cb |..1..Z.n9.# }...| -00000030 b4 fc 4f 6b ec 07 75 b2 c4 ca 44 63 12 f5 35 95 |..Ok..u...Dc..5.| -00000040 93 c8 6e d0 59 7e 58 cb 00 05 ae d7 cc a8 00 00 |..n.Y~X.........| +00000000 16 03 03 00 59 02 00 00 55 03 03 e7 f0 26 e8 9f |....Y...U....&..| +00000010 05 30 9e e5 7c 31 a5 b8 a9 38 35 c3 9c c1 d2 d3 |.0..|1...85.....| +00000020 65 ab 3b 55 62 f9 c8 1f 6e 2e 57 20 0e 70 71 1a |e.;Ub...n.W .pq.| +00000030 59 05 45 40 2d 93 c4 0a 15 0b 16 0f 23 bb 28 33 |Y.E@-.......#.(3| +00000040 03 db 44 75 0a 0f 5e 0a 7b 9e 47 63 cc a8 00 00 |..Du..^.{.Gc....| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 03 02 59 0b 00 02 55 00 02 52 00 02 4f 30 82 02 |..Y...U..R..O0..| 00000070 4b 30 82 01 b4 a0 03 02 01 02 02 09 00 e8 f0 9d |K0..............| @@ -54,129 +60,188 @@ 00000290 77 8d 0c 1c f1 0f a1 d8 40 83 61 c9 4c 72 2b 9d |w.......@.a.Lr+.| 000002a0 ae db 46 06 06 4d f4 c1 b3 3e c0 d1 bd 42 d4 db |..F..M...>...B..| 000002b0 fe 3d 13 60 84 5c 21 d3 3b e9 fa e7 16 03 03 00 |.=.`.\!.;.......| -000002c0 ac 0c 00 00 a8 03 00 1d 20 85 eb 3a 12 97 d7 9a |........ ..:....| -000002d0 a3 11 49 ba 0f 32 c8 4c 09 68 b4 15 22 1f fb 78 |..I..2.L.h.."..x| -000002e0 71 25 40 8c 83 1e 0d 6e 65 04 01 00 80 a4 2b 3a |q%@....ne.....+:| -000002f0 aa 92 ce 24 47 ab 1f 02 4e e2 65 34 b3 15 65 0a |...$G...N.e4..e.| -00000300 57 73 d7 a9 27 c5 c7 da cd 23 e1 8a 02 00 56 b8 |Ws..'....#....V.| -00000310 44 90 d2 66 ad a2 05 f6 d6 27 dc 07 52 a9 e5 e6 |D..f.....'..R...| -00000320 af 00 74 ea f0 42 d0 bc f2 c7 94 bd 19 27 cb ca |..t..B.......'..| -00000330 53 96 6c 2e f6 87 8f 68 93 24 4d 8b 62 cd 15 a4 |S.l....h.$M.b...| -00000340 7e 99 86 41 1f 4e 9b ac 3b 2a 23 64 8a 98 8b 0d |~..A.N..;*#d....| -00000350 4a 1c 37 f6 f4 bc fa 11 e7 07 e6 8f 3b 59 06 fd |J.7.........;Y..| -00000360 27 30 e1 45 ef 9f 91 30 42 86 31 11 9f 16 03 03 |'0.E...0B.1.....| +000002c0 ac 0c 00 00 a8 03 00 1d 20 04 06 15 25 55 6d c0 |........ ...%Um.| +000002d0 d0 71 c9 f8 4e d2 48 f3 7d 0b dc 99 a0 67 2a 5d |.q..N.H.}....g*]| +000002e0 eb ce a1 00 b3 d3 8d cd 4c 08 04 00 80 d3 0d 6d |........L......m| +000002f0 a1 41 2e b5 06 c0 e0 9b 70 c0 1a c3 45 61 3e 86 |.A......p...Ea>.| +00000300 02 a8 04 76 f2 87 1d 58 98 82 38 dc 01 9d 5a 53 |...v...X..8...ZS| +00000310 07 3c 65 66 68 bc e4 8f e9 d4 65 b1 0d 90 0f 7f |.>> Flow 3 (client to server) 00000000 16 03 03 00 25 10 00 00 21 20 2f e5 7d a3 47 cd |....%...! /.}.G.| 00000010 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 |bC.(.._.).0.....| 00000020 cf c2 ed 90 99 5f 58 cb 3b 74 14 03 03 00 01 01 |....._X.;t......| -00000030 16 03 03 00 20 1d 93 0e bd 9d 79 c8 be 62 9e c3 |.... .....y..b..| -00000040 5b 6d 1e e7 3a d1 35 32 1b 20 3b 66 70 71 95 f4 |[m..:.52. ;fpq..| -00000050 88 58 6d b8 f1 |.Xm..| +00000030 16 03 03 00 20 50 ea 05 19 9b 2d ea a4 e3 96 6c |.... P....-....l| +00000040 df b1 de db 80 da e9 65 da dd ad 35 42 7f ce fa |.......e...5B...| +00000050 43 79 b5 b7 60 |Cy..`| >>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 20 76 95 22 fc b0 |.......... v."..| -00000010 06 76 53 a8 f5 41 60 39 2b 22 ce 5e d9 d1 1b 6a |.vS..A`9+".^...j| -00000020 36 cc a2 3a 59 a0 a1 51 48 db d3 |6..:Y..QH..| +00000000 14 03 03 00 01 01 16 03 03 00 20 79 ce b5 0f d4 |.......... y....| +00000010 dd 4d 4b 19 9e d4 8c 49 41 2c 14 e3 2e b7 89 d1 |.MK....IA,......| +00000020 3f 9f 2f 90 21 8c 91 98 bf 0c 4a |?./.!.....J| >>> Flow 5 (client to server) -00000000 17 03 03 00 16 67 62 ca a7 ec ee 51 18 ad 90 65 |.....gb....Q...e| -00000010 fc 87 10 13 5c 2d 66 6f e2 5b d6 |....\-fo.[.| +00000000 17 03 03 00 16 97 1a f9 8d c2 df 57 b3 c1 10 b9 |...........W....| +00000010 2f 8f 3b 47 95 83 03 af 88 97 b1 |/.;G.......| >>> Flow 6 (server to client) -00000000 16 03 03 00 14 11 51 b5 e4 d5 d7 df 48 69 2c f8 |......Q.....Hi,.| -00000010 ff 11 fc 02 b2 00 80 30 aa |.......0.| +00000000 16 03 03 00 14 30 98 ac 88 1f db 08 3a be 39 26 |.....0......:.9&| +00000010 d8 5a df b9 5e fe 26 72 09 |.Z..^.&r.| >>> Flow 7 (client to server) -00000000 16 03 03 00 b1 92 1a 73 ea 30 62 10 b9 c7 83 ec |.......s.0b.....| -00000010 55 24 17 f7 ba a1 3a 13 5f cb 8b ff 64 79 5e 5b |U$....:._...dy^[| -00000020 6c 34 7b c8 0b 38 92 b6 14 7f fd 35 be ba 72 2d |l4{..8.....5..r-| -00000030 bd 78 e3 f6 bc 61 ba 65 83 a6 6a 5e cd 1f 34 ab |.x...a.e..j^..4.| -00000040 5d 84 58 03 06 a0 4d 32 a0 a9 42 92 8f d4 27 3d |].X...M2..B...'=| -00000050 e8 a5 75 9b b7 06 c2 3b 4f 8e 83 10 be 12 4f ea |..u....;O.....O.| -00000060 d1 e7 37 9c 29 dc a9 0f aa f6 a1 0c 1c 3b 19 67 |..7.)........;.g| -00000070 b1 7c 41 9a fd b8 dd 86 92 49 4f 7e 23 75 df 82 |.|A......IO~#u..| -00000080 d0 ca 43 94 61 a8 d4 1f 3f 15 69 b0 6c bf f7 15 |..C.a...?.i.l...| -00000090 1c 8d dc 61 11 73 3c 5e b0 bd 23 a9 3d fb ed 1d |...a.s<^..#.=...| -000000a0 d5 3d 6d de b7 29 fe 85 0d af 85 6c 8a 32 90 09 |.=m..).....l.2..| -000000b0 87 c2 a2 4f f9 9b |...O..| +00000000 16 03 03 01 14 a4 24 c3 2f 54 1c 65 c6 79 11 73 |......$./T.e.y.s| +00000010 a8 9b 6e 8b 81 08 e4 e1 8a 12 56 5d 93 cd 1a 0c |..n.......V]....| +00000020 a4 88 fe 2f a5 dc cf d0 1d 1b e8 d3 76 9e 8e a0 |.../........v...| +00000030 d8 70 44 7d b5 1e be 95 2d 21 c8 0d 0d d0 fe ae |.pD}....-!......| +00000040 b0 0b 73 35 f7 82 6d 0e 36 0f e1 34 cf b7 d4 51 |..s5..m.6..4...Q| +00000050 af d1 bc 83 3e 36 35 10 87 fd 59 ba 4b b5 fb 10 |....>65...Y.K...| +00000060 da 41 f2 ce cb ce 4f 4f 42 4c 11 71 5e 60 c3 13 |.A....OOBL.q^`..| +00000070 6a 10 44 3d 93 49 f4 01 aa c4 a1 6e 81 16 60 66 |j.D=.I.....n..`f| +00000080 d2 7f 22 df e2 68 86 13 d8 e9 e2 2a a3 d5 81 11 |.."..h.....*....| +00000090 af 36 9b 78 2e 33 e5 05 b6 47 1d 1c 3e 2c 43 57 |.6.x.3...G..>,CW| +000000a0 a5 1e 1b a6 b2 20 fa 53 80 cb 11 92 51 93 89 f6 |..... .S....Q...| +000000b0 1c 52 1d 32 c9 b4 ac b3 ac ad a1 02 a5 e1 50 e5 |.R.2..........P.| +000000c0 24 6e 91 75 58 72 39 c9 9b 59 f8 79 ed 08 40 7a |$n.uXr9..Y.y..@z| +000000d0 c5 3c 1c fc 44 9d d9 f6 35 f0 2a 61 a4 7a 8c f3 |.<..D...5.*a.z..| +000000e0 d5 81 e4 54 9d cf a2 14 aa 59 e7 6e 9d 0d e7 f1 |...T.....Y.n....| +000000f0 36 d9 db ef 56 c5 8d 95 89 3d 7c 99 f2 e7 b1 12 |6...V....=|.....| +00000100 4e 53 ca e8 84 cb ca 3c 2a 1d fd 4a e7 af 9b 35 |NS.....<*..J...5| +00000110 20 24 49 ff 95 67 b1 e1 98 | $I..g...| >>> Flow 8 (server to client) -00000000 16 03 03 00 81 69 80 3b d5 74 82 55 ad c5 6d 92 |.....i.;.t.U..m.| -00000010 5c d6 02 a0 5a e5 c7 a9 64 94 20 5f b4 03 7d 25 |\...Z...d. _..}%| -00000020 aa 6b de 09 09 cb 92 a1 73 fa 58 bc 02 a2 01 d4 |.k......s.X.....| -00000030 e6 c6 56 42 4e 8e c5 09 de 2d e1 6a 96 9e 1a b4 |..VBN....-.j....| -00000040 1f 73 44 f2 20 07 3d 99 5f 8e 6e 76 ba 6f 8f d5 |.sD. .=._.nv.o..| -00000050 a1 f9 78 22 9d 84 b3 b1 9c 91 88 3c a7 0f d4 64 |..x".......<...d| -00000060 6d 6e 16 54 b4 1c 38 07 3c 56 b7 67 b5 ab d7 79 |mn.T..8......| -00000230 7b 65 85 82 ba 23 3d 78 22 17 d0 03 02 a0 04 1d |{e...#=x".......| -00000240 e5 b0 be d7 4d a4 6e 40 83 b2 ae ee b9 c3 18 ce |....M.n@........| -00000250 45 7d d8 2e 6d d1 92 7d 60 bd 44 dd 29 11 cd 7d |E}..m..}`.D.)..}| -00000260 13 2f a2 97 b1 ca 6a 76 e0 88 fd 6a b4 cc f3 f1 |./....jv...j....| -00000270 63 4b 4a 74 cb c6 49 ba 82 2b 29 22 0e a0 23 78 |cKJt..I..+)"..#x| -00000280 ad 25 59 85 a8 b2 6e d3 34 1f 31 ff 94 ac 3b 42 |.%Y...n.4.1...;B| -00000290 84 97 17 8a 21 1d 3f 7c e5 ac 17 50 d9 77 a9 54 |....!.?|...P.w.T| -000002a0 2f bd 19 3b b9 de 90 64 8a 02 46 bf 7e 02 ac 60 |/..;...d..F.~..`| -000002b0 55 0c 6f c3 58 04 3a a7 fd e9 26 26 41 a1 8f 43 |U.o.X.:...&&A..C| -000002c0 7a 9e dd a6 1a 7f cf 1d 0c 40 11 59 4f 36 bc e1 |z........@.YO6..| -000002d0 63 20 0b ef 3c e7 de 25 e2 e0 d2 4d 42 62 84 97 |c ..<..%...MBb..| -000002e0 23 64 b2 b5 22 e4 8f f5 b2 1f 9e 99 00 e5 27 f6 |#d..".........'.| -000002f0 02 b9 b3 d0 16 03 03 00 bc 9c 9e 74 fe d3 9f c5 |...........t....| -00000300 50 2a 35 af 0d 27 96 94 a0 0a b4 79 f5 ca 9e 30 |P*5..'.....y...0| -00000310 8c 03 87 75 9c ac 63 a4 96 a5 d8 05 ef cd d5 1a |...u..c.........| -00000320 13 24 81 a7 84 aa 69 a2 e4 a4 13 85 25 c0 ca c8 |.$....i.....%...| -00000330 ec 8f 27 68 77 12 78 bc 98 b2 4e 8b b4 ae c8 47 |..'hw.x...N....G| -00000340 53 b8 7f d6 cf f0 9a 1e 65 33 b0 77 11 9e f4 72 |S.......e3.w...r| -00000350 57 f5 c4 55 06 07 1f a7 3e 3e 31 ce 52 97 58 0c |W..U....>>1.R.X.| -00000360 23 6e 3c 4c b6 a7 f5 c5 ec 3a fa 96 a4 f6 ee 0d |#nf]^...#..| +00000160 b1 e0 f7 e9 af 4c e2 d4 7d 92 df ef c5 16 57 de |.....L..}.....W.| +00000170 1d 68 23 53 46 8b 22 8c d0 8d 25 f6 07 75 b0 19 |.h#SF."...%..u..| +00000180 e1 80 82 67 d5 74 f2 2e 51 34 f0 84 56 5b 45 de |...g.t..Q4..V[E.| +00000190 d1 eb 00 41 94 f4 15 ef 60 23 39 63 cb f0 86 e7 |...A....`#9c....| +000001a0 ee cc 34 cc b4 14 f7 f9 71 48 0c f0 66 9f d3 0c |..4.....qH..f...| +000001b0 92 a4 20 9c 40 44 da e5 4f a2 91 de a4 6b c3 5f |.. .@D..O....k._| +000001c0 0c dd b4 22 e7 6a b8 f3 46 2d aa 0d f3 c6 b6 10 |...".j..F-......| +000001d0 9a 69 f1 3c a4 89 6f d5 b6 45 6c e5 7b 10 d8 f4 |.i.<..o..El.{...| +000001e0 7f 9e 83 eb 44 5f 6c 00 e0 a9 5a 56 c8 80 5a 92 |....D_l...ZV..Z.| +000001f0 20 48 7c ee 22 65 8a e2 35 55 3f 7c 1a bd 4c cf | H|."e..5U?|..L.| +00000200 84 2e af 26 d1 d1 1a fc 81 d3 90 a8 9e d0 56 c3 |...&..........V.| +00000210 f4 f9 7e ac 29 9e d8 91 57 a0 a2 7b 00 b2 42 0f |..~.)...W..{..B.| +00000220 d0 5e ce 26 3c de f7 75 2d c9 74 c7 98 72 c8 b1 |.^.&<..u-.t..r..| +00000230 86 33 81 21 f5 f7 4c c9 f3 04 c2 48 24 d0 3e a6 |.3.!..L....H$.>.| +00000240 c4 8d 0f 3e 25 09 32 36 66 4c e4 67 27 4d 09 71 |...>%.26fL.g'M.q| +00000250 45 91 8e 6a ca a1 ab 69 4a 20 ea e6 a5 a1 8a 53 |E..j...iJ .....S| +00000260 b3 85 4f de de c8 4d a5 ec bd 4e 11 e7 78 f8 4c |..O...M...N..x.L| +00000270 7a 46 28 a7 0b 3d ce 1f 4a be 2d c3 1b 7c 79 9c |zF(..=..J.-..|y.| +00000280 da ae f3 ee ae 58 1f 93 6e ca f4 03 b7 4d be ac |.....X..n....M..| +00000290 d8 32 d9 0a 4e 3b dd a8 c3 b6 24 c7 e5 78 bc 7d |.2..N;....$..x.}| +000002a0 be 12 d9 c4 f9 c1 16 23 79 ba 00 27 fd 0c 93 38 |.......#y..'...8| +000002b0 2c 36 0f e1 a3 9f 27 46 82 2b 60 b5 3f f9 9b cd |,6....'F.+`.?...| +000002c0 60 39 85 96 60 aa 1c 3d 0a 9e 53 46 90 0e 49 68 |`9..`..=..SF..Ih| +000002d0 67 96 db 82 02 c9 4e f4 d7 fe 06 bf d7 01 ae db |g.....N.........| +000002e0 c5 eb 70 c2 51 72 2d 41 ca 2c ae 48 2c 19 bb ae |..p.Qr-A.,.H,...| +000002f0 7f 2f d4 cf 16 03 03 00 bc 75 f7 cb 92 aa 8c ab |./.......u......| +00000300 d7 ea 79 a1 b6 31 a5 5b 5a 19 98 a2 e2 a7 5a a6 |..y..1.[Z.....Z.| +00000310 9c c8 d5 84 1e f0 cc 18 a3 ba 1b 21 2f 9a 0e 3d |...........!/..=| +00000320 54 10 17 ee a4 40 4d 0f b9 36 bf 4a 41 76 7b 0a |T....@M..6.JAv{.| +00000330 7f d8 50 1c 1f 99 5b bf 50 87 e4 24 67 fe 45 93 |..P...[.P..$g.E.| +00000340 a4 a2 41 ce e4 17 67 08 af 35 43 5c 12 ea c3 0e |..A...g..5C\....| +00000350 1f e6 80 89 76 4f 36 71 fe a2 51 ef 05 cb 10 55 |....vO6q..Q....U| +00000360 16 fd 6d 07 aa ba 6a 68 d8 e5 53 cb 9e 17 cd 25 |..m...jh..S....%| +00000370 98 83 62 a6 55 74 79 36 87 1c 5c ef 4a 65 85 a1 |..b.Uty6..\.Je..| +00000380 a4 1b 5d 7c 0d cf e3 63 37 14 b2 ac 74 12 d9 f3 |..]|...c7...t...| +00000390 25 52 d7 a9 d8 f2 c4 75 08 57 5b 48 c5 5e 07 78 |%R.....u.W[H.^.x| +000003a0 c6 74 f3 6e 5a fb 09 67 4d a0 6a d0 f8 b4 0a 00 |.t.nZ..gM.j.....| +000003b0 71 f2 ce e0 20 16 03 03 00 4a 1d 3b c4 a4 6e e3 |q... ....J.;..n.| +000003c0 a0 43 f3 44 b6 eb d7 bb 47 dc 18 b6 84 4a c1 4d |.C.D....G....J.M| +000003d0 05 ee 71 1a 40 75 d1 ac be c3 cb f0 4b f2 a3 c3 |..q.@u......K...| +000003e0 03 6a 1d 3e 77 09 61 f0 0a 35 47 af 67 23 a1 76 |.j.>w.a..5G.g#.v| +000003f0 9e 90 be 10 a0 6b 9d 49 9e 79 38 b8 6a c4 53 ba |.....k.I.y8.j.S.| +00000400 37 88 86 f2 16 03 03 00 14 c7 e1 2e 8a 83 d1 b0 |7...............| +00000410 3e a6 81 d3 6b 62 89 d1 a3 43 c4 7b 4e |>...kb...C.{N| >>> Flow 9 (client to server) -00000000 16 03 03 00 35 01 62 fd 6b 2e 24 0f 01 03 98 44 |....5.b.k.$....D| -00000010 7a 1a 51 4c 09 f0 da 53 b7 cf 31 06 94 9d 09 bd |z.QL...S..1.....| -00000020 d2 ec 3a 20 47 1e 28 e6 d6 66 4d bb dd 2f 9d 4b |..: G.(..fM../.K| -00000030 ff e5 4e ed 84 1d 9b 0c 40 a4 14 03 03 00 11 58 |..N.....@......X| -00000040 2f a4 8e f0 38 bb f8 44 b2 e9 61 68 63 ba 8e 63 |/...8..D..ahc..c| -00000050 16 03 03 00 20 f3 0f ac 3d e2 65 c4 0e c8 b7 22 |.... ...=.e...."| -00000060 2f c9 08 d3 b1 75 e1 f8 91 ea 98 c3 9b c8 9b 21 |/....u.........!| -00000070 cb cd 35 b3 ce |..5..| +00000000 16 03 03 02 69 07 d0 f5 52 49 69 16 9e a0 95 ae |....i...RIi.....| +00000010 90 23 85 b7 03 e7 93 76 bc 81 8f 30 73 d3 0b 58 |.#.....v...0s..X| +00000020 cb 9a 18 00 66 cd 4c 43 a7 a7 8d e3 84 1a dc 86 |....f.LC........| +00000030 11 c2 2e 02 07 94 9f 64 2d 77 8a 60 60 07 22 be |.......d-w.``.".| +00000040 dc 36 14 b4 04 b8 94 46 f6 d4 db bc 68 82 14 7e |.6.....F....h..~| +00000050 d9 cf 60 4b a3 ff 03 d7 05 e0 a5 f4 94 1f ee 76 |..`K...........v| +00000060 4e 96 d0 70 1b cc 4e ad ef d4 4d df 71 82 a1 b5 |N..p..N...M.q...| +00000070 96 97 63 dc cc 13 75 29 bb b5 b7 46 fb b6 dd 17 |..c...u)...F....| +00000080 fd 8d be 54 14 35 a9 2b 66 c5 80 fb 41 e6 92 c1 |...T.5.+f...A...| +00000090 4b db 97 30 12 d1 4c c4 bc 4e 91 a4 17 c7 4e 22 |K..0..L..N....N"| +000000a0 bd 81 69 26 b4 8e d8 63 c8 33 0c 89 b5 12 6e af |..i&...c.3....n.| +000000b0 ea 09 10 66 5e c3 f2 9f c5 c2 0c 91 75 d5 c8 cc |...f^.......u...| +000000c0 4b dd 1f 42 22 29 fe f5 15 3f e6 96 b5 af 41 5d |K..B")...?....A]| +000000d0 06 59 33 40 da 8e c8 2f 00 9c 6b 7c fc fe 45 fe |.Y3@.../..k|..E.| +000000e0 fd 9c b4 87 18 f8 90 9c 8f 22 0d f4 d5 39 96 a0 |........."...9..| +000000f0 77 55 4e 52 f7 31 15 cb ea d6 dd 65 5c 91 f4 36 |wUNR.1.....e\..6| +00000100 a2 d3 c0 d5 c7 9c 07 38 6e 38 e2 00 c9 82 c9 d3 |.......8n8......| +00000110 e5 b0 77 11 4f 3b 82 7e 28 2c c0 69 7e 5d 76 ff |..w.O;.~(,.i~]v.| +00000120 c7 e0 f2 13 5e 5f 8d a0 51 f5 07 8c f2 4f 1c e9 |....^_..Q....O..| +00000130 eb 36 62 3e 9f db 15 11 b7 b0 c2 9f 92 84 37 81 |.6b>..........7.| +00000140 92 aa ea 5e 2a 70 74 3a 16 06 88 9a 98 1a de a9 |...^*pt:........| +00000150 08 91 01 b0 d8 f1 1f fa 54 bd 44 ef 25 49 4d 81 |........T.D.%IM.| +00000160 ec 3b 59 ec 3c b0 ba 08 d4 30 71 66 c1 46 c1 ba |.;Y.<....0qf.F..| +00000170 9d 56 8c b0 b9 b0 3d fa 35 51 7c 91 1f 3c b6 8f |.V....=.5Q|..<..| +00000180 05 fa d2 70 62 78 17 1e 27 68 3b e4 65 ca c4 dc |...pbx..'h;.e...| +00000190 b3 6b 91 27 7c 12 49 36 93 c6 62 5d d8 1f e2 de |.k.'|.I6..b]....| +000001a0 e7 2e 36 6b c5 9c 68 6d 91 29 d3 eb 8c 07 7c fa |..6k..hm.)....|.| +000001b0 42 3e 90 62 c0 0a eb 63 a5 2c b3 4b 3d 2e 5a 36 |B>.b...c.,.K=.Z6| +000001c0 78 71 c1 5a 94 a7 b9 5a b2 e2 8d dd b7 95 0d 94 |xq.Z...Z........| +000001d0 63 38 8f 60 94 c0 2a b9 d6 77 14 34 a2 ac 2c 7e |c8.`..*..w.4..,~| +000001e0 97 f4 76 87 c9 31 bf 73 97 37 9e ef a0 3e dc 49 |..v..1.s.7...>.I| +000001f0 db e1 4b 61 52 2a 1f 73 cd 76 49 28 f2 73 28 6f |..KaR*.s.vI(.s(o| +00000200 75 12 91 c6 5c 55 34 66 63 5f 79 22 9e 13 31 25 |u...\U4fc_y"..1%| +00000210 42 c0 68 59 38 37 85 dd ec 47 65 d1 9b 24 44 d2 |B.hY87...Ge..$D.| +00000220 37 d9 8f d8 f9 e4 37 7b a8 cd ad 25 65 f0 a1 27 |7.....7{...%e..'| +00000230 5e d8 8b 69 1f a7 0b 26 d1 d8 cd b2 e5 ba 31 20 |^..i...&......1 | +00000240 f0 9e 6a 39 6f 9d 04 cf 96 1f 4c 69 cc 4d 16 32 |..j9o.....Li.M.2| +00000250 59 d6 4e eb b7 c5 bc 33 c2 18 9d 58 82 73 64 c0 |Y.N....3...X.sd.| +00000260 a6 09 00 2b 04 1b 05 68 77 dd bb 73 b4 b3 16 03 |...+...hw..s....| +00000270 03 00 35 3a 50 32 09 27 fd 20 17 11 7b 7b e1 42 |..5:P2.'. ..{{.B| +00000280 9c af b2 bb 38 5a 89 c7 e5 eb c4 8e 1e 04 94 1f |....8Z..........| +00000290 40 17 4e b4 94 5b c7 fd d9 14 6e 0d f8 4c f6 cc |@.N..[....n..L..| +000002a0 76 a3 08 02 7e a7 a2 4c 16 03 03 00 98 08 77 4a |v...~..L......wJ| +000002b0 7a f0 ba 64 6e 14 8e fd d9 2f 67 57 1f 4b 05 7b |z..dn..../gW.K.{| +000002c0 99 ed 0d e9 03 de 88 60 44 0c 04 d2 5a 24 4a 9d |.......`D...Z$J.| +000002d0 9b bf fd d6 2f 60 03 63 e4 82 58 bb 69 92 41 c5 |..../`.c..X.i.A.| +000002e0 30 18 cf 9b cc c5 66 b2 b6 ef 15 5f b3 60 93 c6 |0.....f...._.`..| +000002f0 27 59 27 bc d5 dd 3b 5a 9d f7 ad 05 11 b7 9e bc |'Y'...;Z........| +00000300 ff 43 f8 0c 83 0f 6c fa d1 23 09 03 42 60 61 d4 |.C....l..#..B`a.| +00000310 ff 3b c9 ee 15 4a 02 fa d9 60 97 91 50 03 7d 6b |.;...J...`..P.}k| +00000320 c1 a2 64 00 5b b1 12 62 bd e5 c9 8a 2e 0c c1 71 |..d.[..b.......q| +00000330 a8 e2 94 45 be 8b ba a7 c0 6e e7 5e a5 bc 7a f8 |...E.....n.^..z.| +00000340 48 06 e2 27 3f 14 03 03 00 11 ef 57 1d e6 74 e2 |H..'?......W..t.| +00000350 9f 49 cd dc 7a 7d 0b 21 f7 1b e8 16 03 03 00 20 |.I..z}.!....... | +00000360 39 a4 df 59 44 4c b2 99 aa 0c c6 90 b3 a1 0d 00 |9..YDL..........| +00000370 38 ee 40 d2 b0 62 b4 cf e3 20 e7 d7 5f f8 cf aa |8.@..b... .._...| >>> Flow 10 (server to client) -00000000 14 03 03 00 11 c0 ed 05 6a 71 44 98 9a d6 b8 ae |........jqD.....| -00000010 ab 10 43 a9 27 91 16 03 03 00 20 93 fe ed 5f 3e |..C.'..... ..._>| -00000020 61 9f 10 95 c9 f6 82 c5 68 14 3d 9e 3e c3 9d e9 |a.......h.=.>...| -00000030 f2 2d a1 a5 ff ec b9 31 ae 78 e8 17 03 03 00 19 |.-.....1.x......| -00000040 27 c4 6c 54 03 88 b2 36 38 79 1f 1d 68 c2 ca fd |'.lT...68y..h...| -00000050 bf 47 67 44 e1 13 3b f2 fb 16 03 03 00 14 9d 9d |.GgD..;.........| -00000060 67 bf 0e 28 3c 56 a3 7b 49 cb 56 b5 5d 3e 39 45 |g..(9E| -00000070 c8 c5 |..| +00000000 14 03 03 00 11 be d5 20 ab dc c2 df f6 29 bc b7 |....... .....)..| +00000010 a3 7e 70 b9 48 73 16 03 03 00 20 b2 f3 25 a9 70 |.~p.Hs.... ..%.p| +00000020 7f 99 0d f4 01 0a 58 ad b8 6d 02 e8 6f 89 7b 77 |......X..m..o.{w| +00000030 bf 22 89 b3 23 a8 02 28 00 94 f1 17 03 03 00 19 |."..#..(........| +00000040 e3 22 a6 cd a4 dd 9d 2b 6f 6c 84 08 a5 dd 97 0d |.".....+ol......| +00000050 9a 37 a7 ac e4 6b 03 1f db 16 03 03 00 14 ec d7 |.7...k..........| +00000060 d4 fd ec 94 6c 0a 46 8f ec ee 87 61 5c 0a 82 a2 |....l.F....a\...| +00000070 03 91 |..| >>> Flow 11 (client to server) -00000000 15 03 03 00 12 00 dc 08 22 b1 d3 cc d2 f7 6b 03 |........".....k.| -00000010 92 e9 4d 62 8d 5d f6 15 03 03 00 12 ce e8 8d 1b |..Mb.]..........| -00000020 78 a3 63 10 bc 77 e8 88 1f 91 9c a5 b5 f2 |x.c..w........| +00000000 15 03 03 00 12 4b bc 67 b6 13 0f 0c df e1 42 46 |.....K.g......BF| +00000010 05 97 85 e5 97 bc 81 15 03 03 00 12 d7 e8 b7 5c |...............\| +00000020 a4 d8 8e fb b3 a7 1f 06 2f bb 77 f1 13 35 |......../.w..5| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-RenegotiationRejected b/libgo/go/crypto/tls/testdata/Client-TLSv12-RenegotiationRejected index 71d98417ce4..57febfbc851 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv12-RenegotiationRejected +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-RenegotiationRejected @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 03 00 59 02 00 00 55 03 03 db bb 55 42 4d |....Y...U....UBM| -00000010 7e 2c 47 97 1c 97 97 e4 35 a1 a9 f4 d6 1a 2f 97 |~,G.....5...../.| -00000020 96 f7 d6 3b 7e 81 7c 96 f4 42 f8 20 b1 92 02 f0 |...;~.|..B. ....| -00000030 91 56 81 2c 4e ba e0 02 26 c7 f6 d9 0a ef e9 40 |.V.,N...&......@| -00000040 54 10 60 a4 d3 e1 b5 cf d3 ad 59 c7 cc a8 00 00 |T.`.......Y.....| +00000000 16 03 03 00 59 02 00 00 55 03 03 e0 77 db d2 ca |....Y...U...w...| +00000010 46 29 bc ce 1a ee 39 d0 58 35 74 c0 1f 17 86 c0 |F)....9.X5t.....| +00000020 a8 58 ad b6 e3 f5 e0 80 ae 71 43 20 cd a1 49 bb |.X.......qC ..I.| +00000030 94 bc fc 26 a5 56 ea dc 9d 9a b4 ee c7 70 fa 72 |...&.V.......p.r| +00000040 04 c1 d8 e2 a9 63 24 9a 07 18 a5 fa cc a8 00 00 |.....c$.........| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 03 02 59 0b 00 02 55 00 02 52 00 02 4f 30 82 02 |..Y...U..R..O0..| 00000070 4b 30 82 01 b4 a0 03 02 01 02 02 09 00 e8 f0 9d |K0..............| @@ -54,36 +60,36 @@ 00000290 77 8d 0c 1c f1 0f a1 d8 40 83 61 c9 4c 72 2b 9d |w.......@.a.Lr+.| 000002a0 ae db 46 06 06 4d f4 c1 b3 3e c0 d1 bd 42 d4 db |..F..M...>...B..| 000002b0 fe 3d 13 60 84 5c 21 d3 3b e9 fa e7 16 03 03 00 |.=.`.\!.;.......| -000002c0 ac 0c 00 00 a8 03 00 1d 20 7c 4a f0 08 30 5f 04 |........ |J..0_.| -000002d0 46 3d 38 6c 55 57 44 82 a5 98 a1 fd 60 26 ce 03 |F=8lUWD.....`&..| -000002e0 cd 93 14 0a 0b 69 02 bf 03 04 01 00 80 c6 a5 05 |.....i..........| -000002f0 fa 60 d4 cb 47 ad 03 16 04 bf a7 43 7c 84 54 b3 |.`..G......C|.T.| -00000300 29 dc 73 29 d2 43 29 90 3b 1f ff dd da 8b 56 06 |).s).C).;.....V.| -00000310 08 9d fd 1f f6 42 7a 3e f9 ab 76 87 0b 42 e3 d8 |.....Bz>..v..B..| -00000320 29 32 55 50 d0 1a 1e 00 8e c9 83 cc 08 bc e5 39 |)2UP...........9| -00000330 9c 58 79 ab 27 5a 55 21 99 fb 2b ee 3a 3a a2 27 |.Xy.'ZU!..+.::.'| -00000340 d6 64 a7 d9 c9 c6 46 dc 03 0a 30 b4 1b 8a 61 36 |.d....F...0...a6| -00000350 b8 22 46 6a ea cc ee 30 e5 58 8e 7e 09 b2 0d 6a |."Fj...0.X.~...j| -00000360 b5 84 54 ea ab ed d5 29 1e 7e 67 17 48 16 03 03 |..T....).~g.H...| +000002c0 ac 0c 00 00 a8 03 00 1d 20 96 83 76 7c af 6c af |........ ..v|.l.| +000002d0 be 20 ec 79 87 9e e0 23 fa 34 78 96 91 30 3b 78 |. .y...#.4x..0;x| +000002e0 1b 3f 0f 73 b4 45 05 2f 22 08 04 00 80 38 fe 9b |.?.s.E./"....8..| +000002f0 e1 c2 82 13 ce 00 c2 0e 08 98 22 d0 4d 86 38 97 |..........".M.8.| +00000300 c1 78 b9 11 a4 9d af e0 75 d1 c9 dc a1 dc 25 03 |.x......u.....%.| +00000310 cd ba 15 2e be 0a 61 39 4f 4f d3 48 95 61 3f 2c |......a9OO.H.a?,| +00000320 fb e1 63 e7 8f 51 b4 1f c8 98 f7 3e 23 11 8c 4a |..c..Q.....>#..J| +00000330 b4 76 15 cc 83 bd dc 6f af 0c d9 f1 80 0d 9b a2 |.v.....o........| +00000340 a3 ac 2f 26 c8 d3 23 94 bc c9 3d fb 44 4e 47 3e |../&..#...=.DNG>| +00000350 3b de ce 24 b8 ab 52 f3 5f 26 96 7f e6 a4 ec 9e |;..$..R._&......| +00000360 fc 44 4a 1b 73 d1 ea 2a a9 b9 c8 ba f6 16 03 03 |.DJ.s..*........| 00000370 00 04 0e 00 00 00 |......| >>> Flow 3 (client to server) 00000000 16 03 03 00 25 10 00 00 21 20 2f e5 7d a3 47 cd |....%...! /.}.G.| 00000010 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 |bC.(.._.).0.....| 00000020 cf c2 ed 90 99 5f 58 cb 3b 74 14 03 03 00 01 01 |....._X.;t......| -00000030 16 03 03 00 20 c8 0e 66 f9 0a 9c 23 fb ed 6a 04 |.... ..f...#..j.| -00000040 83 b3 72 c4 5f 7b 2f 9f 03 c9 32 d5 60 30 6d 07 |..r._{/...2.`0m.| -00000050 e7 d3 fc ed 83 |.....| +00000030 16 03 03 00 20 f3 a4 06 da e0 55 ed 41 d1 71 2a |.... .....U.A.q*| +00000040 d5 aa 00 31 eb 23 23 52 20 43 36 8f 10 70 d3 e0 |...1.##R C6..p..| +00000050 6d cc 77 f9 68 |m.w.h| >>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 20 2e 07 51 3c b8 |.......... ..Q<.| -00000010 97 34 f5 21 da 22 b1 e9 e6 98 61 83 22 06 45 c2 |.4.!."....a.".E.| -00000020 db 60 08 27 bc 64 30 3e 1c 77 70 |.`.'.d0>.wp| +00000000 14 03 03 00 01 01 16 03 03 00 20 f5 84 89 dc 37 |.......... ....7| +00000010 bf d9 75 10 c2 30 50 9e 2c 71 00 30 46 f3 af 00 |..u..0P.,q.0F...| +00000020 9c 6c fd 78 2d d1 54 88 98 c4 8a |.l.x-.T....| >>> Flow 5 (client to server) -00000000 17 03 03 00 16 89 dc 04 82 f8 16 f2 0d 91 53 80 |..............S.| -00000010 7a a7 7b 43 66 f4 95 b3 c2 db ec |z.{Cf......| +00000000 17 03 03 00 16 e7 10 a8 74 64 64 01 ea af 4a f2 |........tdd...J.| +00000010 6a 09 c7 60 49 ba 59 71 bc f6 90 |j..`I.Yq...| >>> Flow 6 (server to client) -00000000 16 03 03 00 14 c7 99 03 a6 e5 88 0c f4 31 22 67 |.............1"g| -00000010 ee 08 ff ff df d8 5d 63 ad |......]c.| +00000000 16 03 03 00 14 4c ff 21 fb 5d ef 36 28 6f f8 7b |.....L.!.].6(o.{| +00000010 c0 08 b6 1b e3 17 c3 6e 49 |.......nI| >>> Flow 7 (client to server) -00000000 15 03 03 00 12 ea 8d 5d 03 03 80 85 91 ca cf 7e |.......].......~| -00000010 10 53 60 44 f6 86 3d 15 03 03 00 12 96 b9 d3 2b |.S`D..=........+| -00000020 c9 d0 bd 38 c3 4d 32 10 4c e9 c4 9a b3 01 |...8.M2.L.....| +00000000 15 03 03 00 12 ab 44 a2 47 b2 14 a3 5f 40 1b 56 |......D.G..._@.V| +00000010 d0 f0 3f ea 95 cf aa 15 03 03 00 12 28 1b e3 5f |..?.........(.._| +00000020 8c c4 87 b4 d6 28 2f c9 93 30 66 7a 35 ce |.....(/..0fz5.| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-SCT b/libgo/go/crypto/tls/testdata/Client-TLSv12-SCT index e081554833b..f817ea594fe 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv12-SCT +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-SCT @@ -1,44 +1,50 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 95 01 00 00 91 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 3c 00 05 |.............<..| -00000060 00 05 01 00 00 00 00 00 0a 00 0a 00 08 00 1d 00 |................| -00000070 17 00 18 00 19 00 0b 00 02 01 00 00 0d 00 12 00 |................| -00000080 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| -00000090 03 ff 01 00 01 00 00 12 00 00 |..........| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| >>> Flow 2 (server to client) -00000000 16 03 03 01 c6 02 00 01 c2 03 03 7c 81 f9 b1 c8 |...........|....| -00000010 a6 92 26 e6 ef 52 6b 33 51 64 e1 e8 77 73 c2 c6 |..&..Rk3Qd..ws..| -00000020 9a 7c 38 c8 df 43 8e da 8c ea 21 20 6b ea 4c 41 |.|8..C....! k.LA| -00000030 1e 3d d0 b9 e9 d8 e9 0b 12 e1 a2 82 b7 69 0a d7 |.=...........i..| -00000040 42 57 8e 24 62 77 3d e0 af 5b 97 2c cc a8 00 01 |BW.$bw=..[.,....| -00000050 7a ff 01 00 01 00 00 0b 00 04 03 00 01 02 00 12 |z...............| -00000060 01 69 01 67 00 75 00 a4 b9 09 90 b4 18 58 14 87 |.i.g.u.......X..| -00000070 bb 13 a2 cc 67 70 0a 3c 35 98 04 f9 1b df b8 e3 |....gp.<5.......| -00000080 77 cd 0e c8 0d dc 10 00 00 01 47 97 99 ee 16 00 |w.........G.....| -00000090 00 04 03 00 46 30 44 02 20 1c 4b 82 5d 95 6e 67 |....F0D. .K.].ng| -000000a0 5b db 04 95 4b f6 ce f4 32 3e 86 7a 7a 32 ab 18 |[...K...2>.zz2..| -000000b0 60 74 de 08 da 05 91 4c 2f 02 20 73 54 1b 6e 7f |`t.....L/. sT.n.| -000000c0 a1 b0 7d 11 bc e6 f3 85 2f 97 66 1a f7 8a e4 10 |..}...../.f.....| -000000d0 25 8f 12 f4 6f 39 0f d2 9e 18 f0 00 76 00 68 f6 |%...o9......v.h.| -000000e0 98 f8 1f 64 82 be 3a 8c ee b9 28 1d 4c fc 71 51 |...d..:...(.L.qQ| -000000f0 5d 67 93 d4 44 d1 0a 67 ac bb 4f 4f fb c4 00 00 |]g..D..g..OO....| -00000100 01 47 97 e1 b5 70 00 00 04 03 00 47 30 45 02 20 |.G...p.....G0E. | -00000110 32 21 14 38 06 d8 72 2e 00 30 64 1a e2 e8 6d 4e |2!.8..r..0d...mN| -00000120 5a e1 d9 42 1e 82 4b 96 25 89 d5 26 13 d3 9c fa |Z..B..K.%..&....| -00000130 02 21 00 8f 12 28 64 51 4f 44 d5 8c 18 62 23 b2 |.!...(dQOD...b#.| -00000140 43 93 33 05 f3 43 55 a1 d9 ee cd c5 71 35 91 dd |C.3..CU.....q5..| -00000150 49 d1 0b 00 76 00 ee 4b bd b7 75 ce 60 ba e1 42 |I...v..K..u.`..B| -00000160 69 1f ab e1 9e 66 a3 0f 7e 5f b0 72 d8 83 00 c4 |i....f..~_.r....| -00000170 7b 89 7a a8 fd cb 00 00 01 48 5c 64 8a 87 00 00 |{.z......H\d....| -00000180 04 03 00 47 30 45 02 20 29 89 d6 b0 53 d3 d2 e9 |...G0E. )...S...| -00000190 91 bc f1 b5 40 be 1e 2e e7 5c b4 74 27 ed 8f 9b |....@....\.t'...| -000001a0 02 e9 fa c2 4c ba a2 be 02 21 00 af 43 64 52 71 |....L....!..CdRq| -000001b0 15 29 58 40 91 c7 08 16 96 03 a8 73 a5 65 a0 6c |.)X@.......s.e.l| -000001c0 b8 48 56 5a b6 29 83 64 6d 2a 9d 16 03 03 02 59 |.HVZ.).dm*.....Y| +00000000 16 03 03 01 c6 02 00 01 c2 03 03 cb c8 2f af ab |............./..| +00000010 d1 5b 34 64 8e 3f b3 6e b7 bf 0b e8 15 0f c3 97 |.[4d.?.n........| +00000020 a1 99 64 45 ac 8f 2a 60 9c 03 a3 20 41 c5 a1 11 |..dE..*`... A...| +00000030 79 cd 6b 70 27 1f 0f e8 59 ac d3 d7 ae ae 1e d4 |y.kp'...Y.......| +00000040 e2 74 81 43 26 b1 37 d1 14 87 a6 20 cc a8 00 01 |.t.C&.7.... ....| +00000050 7a 00 12 01 69 01 67 00 75 00 a4 b9 09 90 b4 18 |z...i.g.u.......| +00000060 58 14 87 bb 13 a2 cc 67 70 0a 3c 35 98 04 f9 1b |X......gp.<5....| +00000070 df b8 e3 77 cd 0e c8 0d dc 10 00 00 01 47 97 99 |...w.........G..| +00000080 ee 16 00 00 04 03 00 46 30 44 02 20 1c 4b 82 5d |.......F0D. .K.]| +00000090 95 6e 67 5b db 04 95 4b f6 ce f4 32 3e 86 7a 7a |.ng[...K...2>.zz| +000000a0 32 ab 18 60 74 de 08 da 05 91 4c 2f 02 20 73 54 |2..`t.....L/. sT| +000000b0 1b 6e 7f a1 b0 7d 11 bc e6 f3 85 2f 97 66 1a f7 |.n...}...../.f..| +000000c0 8a e4 10 25 8f 12 f4 6f 39 0f d2 9e 18 f0 00 76 |...%...o9......v| +000000d0 00 68 f6 98 f8 1f 64 82 be 3a 8c ee b9 28 1d 4c |.h....d..:...(.L| +000000e0 fc 71 51 5d 67 93 d4 44 d1 0a 67 ac bb 4f 4f fb |.qQ]g..D..g..OO.| +000000f0 c4 00 00 01 47 97 e1 b5 70 00 00 04 03 00 47 30 |....G...p.....G0| +00000100 45 02 20 32 21 14 38 06 d8 72 2e 00 30 64 1a e2 |E. 2!.8..r..0d..| +00000110 e8 6d 4e 5a e1 d9 42 1e 82 4b 96 25 89 d5 26 13 |.mNZ..B..K.%..&.| +00000120 d3 9c fa 02 21 00 8f 12 28 64 51 4f 44 d5 8c 18 |....!...(dQOD...| +00000130 62 23 b2 43 93 33 05 f3 43 55 a1 d9 ee cd c5 71 |b#.C.3..CU.....q| +00000140 35 91 dd 49 d1 0b 00 76 00 ee 4b bd b7 75 ce 60 |5..I...v..K..u.`| +00000150 ba e1 42 69 1f ab e1 9e 66 a3 0f 7e 5f b0 72 d8 |..Bi....f..~_.r.| +00000160 83 00 c4 7b 89 7a a8 fd cb 00 00 01 48 5c 64 8a |...{.z......H\d.| +00000170 87 00 00 04 03 00 47 30 45 02 20 29 89 d6 b0 53 |......G0E. )...S| +00000180 d3 d2 e9 91 bc f1 b5 40 be 1e 2e e7 5c b4 74 27 |.......@....\.t'| +00000190 ed 8f 9b 02 e9 fa c2 4c ba a2 be 02 21 00 af 43 |.......L....!..C| +000001a0 64 52 71 15 29 58 40 91 c7 08 16 96 03 a8 73 a5 |dRq.)X@.......s.| +000001b0 65 a0 6c b8 48 56 5a b6 29 83 64 6d 2a 9d ff 01 |e.l.HVZ.).dm*...| +000001c0 00 01 00 00 0b 00 04 03 00 01 02 16 03 03 02 59 |...............Y| 000001d0 0b 00 02 55 00 02 52 00 02 4f 30 82 02 4b 30 82 |...U..R..O0..K0.| 000001e0 01 b4 a0 03 02 01 02 02 09 00 e8 f0 9d 3f e2 5b |.............?.[| 000001f0 ea a6 30 0d 06 09 2a 86 48 86 f7 0d 01 01 0b 05 |..0...*.H.......| @@ -77,31 +83,31 @@ 00000400 1c f1 0f a1 d8 40 83 61 c9 4c 72 2b 9d ae db 46 |.....@.a.Lr+...F| 00000410 06 06 4d f4 c1 b3 3e c0 d1 bd 42 d4 db fe 3d 13 |..M...>...B...=.| 00000420 60 84 5c 21 d3 3b e9 fa e7 16 03 03 00 ac 0c 00 |`.\!.;..........| -00000430 00 a8 03 00 1d 20 46 5e b3 7c 5b 77 d3 2d ff 1a |..... F^.|[w.-..| -00000440 60 d8 56 9b c8 f0 fa 09 ec 33 89 08 8f 9e 54 86 |`.V......3....T.| -00000450 7e 5d 72 e5 3d 37 04 01 00 80 6e e6 45 b9 1d b5 |~]r.=7....n.E...| -00000460 03 a5 d6 ec 37 ca 35 a1 b0 e9 3f b5 b8 2f 65 d2 |....7.5...?../e.| -00000470 f6 8e 28 e8 23 76 23 f7 26 b6 96 64 89 bb ab 88 |..(.#v#.&..d....| -00000480 4b c5 9a b0 f5 df f2 44 19 15 25 67 5e 66 8c f7 |K......D..%g^f..| -00000490 3d 9a 6a 2a c7 1d 85 d3 7c 2e 5e 9c 9d ca 87 c3 |=.j*....|.^.....| -000004a0 ee 12 ec bd ba 19 fd bc 86 0e d7 8e d2 6a 90 f6 |.............j..| -000004b0 bf bb 15 ab 2e 6b 6a 4d 6f 59 dd c9 ca 40 f5 60 |.....kjMoY...@.`| -000004c0 b0 ab 47 2a 6e ee 1b 20 d8 ca c4 8c 8b f3 51 65 |..G*n.. ......Qe| -000004d0 18 25 41 d3 1f 4e 6b fe ef 10 16 03 03 00 04 0e |.%A..Nk.........| +00000430 00 a8 03 00 1d 20 c5 a7 0f f6 d3 e0 dd fe c0 6f |..... .........o| +00000440 b9 d5 82 34 0f 6d e9 5c e2 38 3e 23 83 17 07 f8 |...4.m.\.8>#....| +00000450 00 1c 5e e6 6b 40 08 04 00 80 93 f8 75 72 dc 74 |..^.k@......ur.t| +00000460 68 62 98 55 f6 64 81 d1 03 9f f8 8c 17 77 d3 a6 |hb.U.d.......w..| +00000470 f9 3e 41 b8 f7 73 e6 c7 83 21 3b e8 72 cf 5f 08 |.>A..s...!;.r._.| +00000480 84 51 cf e5 f6 b0 f2 83 d9 cf b9 fc d7 3c 0d 39 |.Q...........<.9| +00000490 a2 14 ae 78 07 24 25 95 13 90 71 f9 ac 0f 64 c7 |...x.$%...q...d.| +000004a0 e9 15 35 37 83 02 10 38 be c1 d1 00 3d 4b f2 36 |..57...8....=K.6| +000004b0 f6 7f ac 3e b2 ef 51 eb df d6 8b 92 a6 8e 71 17 |...>..Q.......q.| +000004c0 63 bd 6a 92 15 b7 b1 2d 0a 4c 58 68 65 23 ff ad |c.j....-.LXhe#..| +000004d0 59 03 85 9c a2 cf 02 3b 70 d4 16 03 03 00 04 0e |Y......;p.......| 000004e0 00 00 00 |...| >>> Flow 3 (client to server) 00000000 16 03 03 00 25 10 00 00 21 20 2f e5 7d a3 47 cd |....%...! /.}.G.| 00000010 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 |bC.(.._.).0.....| 00000020 cf c2 ed 90 99 5f 58 cb 3b 74 14 03 03 00 01 01 |....._X.;t......| -00000030 16 03 03 00 20 5f a3 77 a5 b0 8f 47 73 4c a9 1d |.... _.w...GsL..| -00000040 84 17 76 fe a5 17 6e c8 cd a4 dc 47 e5 76 23 2f |..v...n....G.v#/| -00000050 18 8b 59 41 12 |..YA.| +00000030 16 03 03 00 20 62 1f 1a 94 94 88 9c 0c 3c ab d1 |.... b.......<..| +00000040 32 32 9f 8d be 28 a8 86 43 e6 53 d3 c4 bf 13 84 |22...(..C.S.....| +00000050 50 7f 30 84 e1 |P.0..| >>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 20 3e 65 a2 34 77 |.......... >e.4w| -00000010 84 52 61 db 52 89 e8 f0 27 f3 ab 70 17 38 1f 37 |.Ra.R...'..p.8.7| -00000020 17 ad d8 56 23 32 2d 2d e2 b3 d0 |...V#2--...| +00000000 14 03 03 00 01 01 16 03 03 00 20 bf 16 ab 1a 98 |.......... .....| +00000010 d0 c1 95 b7 fe c2 45 fd 01 79 6b 8a 13 80 e4 96 |......E..yk.....| +00000020 64 15 1b 6e 31 12 19 1d 6f ba b0 |d..n1...o..| >>> Flow 5 (client to server) -00000000 17 03 03 00 16 92 d2 88 0c 8a ac 62 fe fd d5 d4 |...........b....| -00000010 fd 98 b2 60 02 97 a2 80 d7 5f f9 15 03 03 00 12 |...`....._......| -00000020 e9 3d 30 95 1b f8 fd 05 3b ba ac af f9 66 f7 ac |.=0.....;....f..| -00000030 e5 ec |..| +00000000 17 03 03 00 16 a4 27 40 7a 6a 54 03 b6 ec 5f 4a |......'@zjT..._J| +00000010 56 a5 6e cb cc 4c 49 2e 08 29 37 15 03 03 00 12 |V.n..LI..)7.....| +00000020 88 20 fe 73 46 06 a7 f0 31 1a d9 89 7a fe a8 28 |. .sF...1...z..(| +00000030 d6 e8 |..| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv12-X25519-ECDHE-RSA-AES-GCM b/libgo/go/crypto/tls/testdata/Client-TLSv12-X25519-ECDHE similarity index 53% rename from libgo/go/crypto/tls/testdata/Client-TLSv12-X25519-ECDHE-RSA-AES-GCM rename to libgo/go/crypto/tls/testdata/Client-TLSv12-X25519-ECDHE index 7a265ea2fb8..178106f0dff 100644 --- a/libgo/go/crypto/tls/testdata/Client-TLSv12-X25519-ECDHE-RSA-AES-GCM +++ b/libgo/go/crypto/tls/testdata/Client-TLSv12-X25519-ECDHE @@ -1,20 +1,26 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 8f 01 00 00 8b 03 03 00 00 00 00 00 |................| +00000000 16 03 01 00 f2 01 00 00 ee 03 03 00 00 00 00 00 |................| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2c cc a8 |.............,..| -00000030 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| -00000040 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| -00000050 c0 12 00 0a 00 05 c0 11 c0 07 01 00 00 36 00 05 |.............6..| -00000060 00 05 01 00 00 00 00 00 0a 00 04 00 02 00 1d 00 |................| -00000070 0b 00 02 01 00 00 0d 00 12 00 10 04 01 04 03 05 |................| -00000080 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 01 00 |................| -00000090 00 12 00 00 |....| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 73 00 05 00 05 01 00 00 00 00 00 0a 00 |...s............| +00000090 04 00 02 00 1d 00 0b 00 02 01 00 00 0d 00 18 00 |................| +000000a0 16 08 04 08 05 08 06 04 01 04 03 05 01 05 03 06 |................| +000000b0 01 06 03 02 01 02 03 ff 01 00 01 00 00 12 00 00 |................| +000000c0 00 2b 00 09 08 03 04 03 03 03 02 03 01 00 33 00 |.+............3.| +000000d0 26 00 24 00 1d 00 20 2f e5 7d a3 47 cd 62 43 15 |&.$... /.}.G.bC.| +000000e0 28 da ac 5f bb 29 07 30 ff f6 84 af c4 cf c2 ed |(.._.).0........| +000000f0 90 99 5f 58 cb 3b 74 |.._X.;t| >>> Flow 2 (server to client) -00000000 16 03 03 00 59 02 00 00 55 03 03 ff 52 25 9b 48 |....Y...U...R%.H| -00000010 77 0c cd cf 49 c4 b4 5e 02 32 d4 56 99 d0 ce ad |w...I..^.2.V....| -00000020 d4 9d 8b e9 ae 4c 50 26 4b 65 c3 20 99 54 f7 5d |.....LP&Ke. .T.]| -00000030 68 da 00 e0 88 d8 0c ed b1 8f 60 d1 70 16 c4 c6 |h.........`.p...| -00000040 84 69 55 23 43 27 22 b7 94 2a 79 4c c0 2f 00 00 |.iU#C'"..*yL./..| +00000000 16 03 03 00 59 02 00 00 55 03 03 14 f0 64 fb 80 |....Y...U....d..| +00000010 40 49 f6 48 a5 65 9d e1 2e 37 c3 f7 b9 27 fe 6b |@I.H.e...7...'.k| +00000020 de 49 93 da 97 0d 59 c5 a8 5d 42 20 f9 10 79 a2 |.I....Y..]B ..y.| +00000030 e6 33 e8 eb 6c 7d 3b 1d e2 e9 3e df 5f 5a 40 d5 |.3..l};...>._Z@.| +00000040 a2 0d c7 35 f2 db a1 e0 1f 90 bb 6b c0 2f 00 00 |...5.......k./..| 00000050 0d ff 01 00 01 00 00 0b 00 04 03 00 01 02 16 03 |................| 00000060 03 02 59 0b 00 02 55 00 02 52 00 02 4f 30 82 02 |..Y...U..R..O0..| 00000070 4b 30 82 01 b4 a0 03 02 01 02 02 09 00 e8 f0 9d |K0..............| @@ -54,33 +60,33 @@ 00000290 77 8d 0c 1c f1 0f a1 d8 40 83 61 c9 4c 72 2b 9d |w.......@.a.Lr+.| 000002a0 ae db 46 06 06 4d f4 c1 b3 3e c0 d1 bd 42 d4 db |..F..M...>...B..| 000002b0 fe 3d 13 60 84 5c 21 d3 3b e9 fa e7 16 03 03 00 |.=.`.\!.;.......| -000002c0 ac 0c 00 00 a8 03 00 1d 20 7e 24 e6 eb 12 22 e0 |........ ~$...".| -000002d0 7b 1e ad 2d 1e a8 3a ea ff 9e 87 bf 38 21 6e 51 |{..-..:.....8!nQ| -000002e0 a8 42 0b 13 a2 3f 01 b9 7d 04 01 00 80 be e8 7e |.B...?..}......~| -000002f0 db 65 e8 0c 5e 31 4c 72 b4 fb 42 ca f0 e2 e2 32 |.e..^1Lr..B....2| -00000300 26 46 f5 62 e5 09 71 8c 82 60 d3 e1 3b 1d d4 3d |&F.b..q..`..;..=| -00000310 6f 9d 5e 22 e7 22 41 44 1b b1 77 18 dc 5a 82 18 |o.^"."AD..w..Z..| -00000320 f3 ae 31 a2 46 32 86 cb 6e f7 37 b3 a4 7e 5c 62 |..1.F2..n.7..~\b| -00000330 11 8d 78 aa 78 6b 6f 78 da 75 26 bf 9b fc 5a 4b |..x.xkox.u&...ZK| -00000340 18 d7 28 84 9d 66 70 69 2f f5 24 c5 90 ef 33 14 |..(..fpi/.$...3.| -00000350 2e c8 14 3f 46 5c 61 c1 a5 2e ee 81 b5 4e 32 01 |...?F\a......N2.| -00000360 85 8b 3a 30 de 0d e7 23 07 be 36 9a 66 16 03 03 |..:0...#..6.f...| +000002c0 ac 0c 00 00 a8 03 00 1d 20 45 79 ac ef 3b d5 3e |........ Ey..;.>| +000002d0 81 e1 7d 8a 9e 94 b3 d8 15 49 3c 2a 71 0a 31 74 |..}......I<*q.1t| +000002e0 2b 7a cc f7 5d 2d 72 d5 60 08 04 00 80 d1 63 69 |+z..]-r.`.....ci| +000002f0 e9 5f 99 c1 43 18 29 04 39 f2 ec 2b d8 dc e6 59 |._..C.).9..+...Y| +00000300 80 ff 27 f9 96 39 de 2c 26 9c f0 15 39 fa 42 ba |..'..9.,&...9.B.| +00000310 80 d8 1b f6 64 07 e4 2e b3 1e ce 20 51 59 82 97 |....d...... QY..| +00000320 a1 2f d5 3f 18 05 12 12 1e aa cf 29 93 34 89 18 |./.?.......).4..| +00000330 0b 19 e0 30 21 5f ce c2 75 58 a1 aa 98 44 cb c0 |...0!_..uX...D..| +00000340 08 db 6e c5 95 9c a7 f5 a2 30 c7 9d 9d 31 1d a1 |..n......0...1..| +00000350 b8 3f 05 b8 13 b6 89 a8 3c 78 fe ae e5 6f 2a 91 |.?......>> Flow 3 (client to server) 00000000 16 03 03 00 25 10 00 00 21 20 2f e5 7d a3 47 cd |....%...! /.}.G.| 00000010 62 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 |bC.(.._.).0.....| 00000020 cf c2 ed 90 99 5f 58 cb 3b 74 14 03 03 00 01 01 |....._X.;t......| -00000030 16 03 03 00 28 00 00 00 00 00 00 00 00 71 e9 b4 |....(........q..| -00000040 8b 8a 93 23 22 6a 61 09 5f e6 5b 05 53 f6 7e b0 |...#"ja._.[.S.~.| -00000050 18 53 da 44 b4 04 4d a4 d6 8e fe 8e d8 |.S.D..M......| +00000030 16 03 03 00 28 00 00 00 00 00 00 00 00 b5 c1 dc |....(...........| +00000040 8e c0 bc 78 74 a7 c6 36 23 67 55 5d bc 82 db 77 |...xt..6#gU]...w| +00000050 85 d8 76 c8 98 65 63 8e f2 47 0b 5b 10 |..v..ec..G.[.| >>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 28 b0 0e df 0e b0 |..........(.....| -00000010 b0 3b 09 c7 9e 23 21 34 35 3a 15 94 64 8e 54 c9 |.;...#!45:..d.T.| -00000020 5c c7 e3 3f b6 8f ca 10 4e d9 60 60 b7 b4 f9 13 |\..?....N.``....| -00000030 5d c4 53 |].S| +00000000 14 03 03 00 01 01 16 03 03 00 28 6e 20 eb fc d1 |..........(n ...| +00000010 a1 0e 6c a5 d9 6c ab fc 4d 0e f3 f0 61 84 2d 14 |..l..l..M...a.-.| +00000020 06 53 eb 69 18 b3 e3 f1 32 e8 19 00 5e 74 97 e5 |.S.i....2...^t..| +00000030 98 a7 8a |...| >>> Flow 5 (client to server) -00000000 17 03 03 00 1e 00 00 00 00 00 00 00 01 6b a1 83 |.............k..| -00000010 cc af 9b e1 88 55 43 c2 7d 05 b7 2d 7d 33 d9 b6 |.....UC.}..-}3..| -00000020 a3 9b 85 15 03 03 00 1a 00 00 00 00 00 00 00 02 |................| -00000030 e2 8b 82 76 99 3d 8b b7 7d 69 76 d5 cd 6c aa 7c |...v.=..}iv..l.|| -00000040 64 82 |d.| +00000000 17 03 03 00 1e 00 00 00 00 00 00 00 01 32 91 ac |.............2..| +00000010 63 b8 71 f1 26 18 ac 15 45 58 6c 60 18 77 bc 5c |c.q.&...EXl`.w.\| +00000020 ff 5b cd 15 03 03 00 1a 00 00 00 00 00 00 00 02 |.[..............| +00000030 ad 89 71 22 f0 e0 61 3e 2b f7 d9 da 96 34 51 72 |..q"..a>+....4Qr| +00000040 c9 be |..| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv13-AES128-SHA256 b/libgo/go/crypto/tls/testdata/Client-TLSv13-AES128-SHA256 new file mode 100644 index 00000000000..c35db9e681f --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Client-TLSv13-AES128-SHA256 @@ -0,0 +1,90 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 e6 6e e6 44 9a |....z...v...n.D.| +00000010 c9 e2 51 58 ac ba 02 48 ea 6f dd 09 7a 08 04 d2 |..QX...H.o..z...| +00000020 df b6 96 2f 31 d4 6b bf ab 0e 8e 20 00 00 00 00 |.../1.k.... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 13 01 00 00 |................| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 98 |..+.....3.$... .| +00000060 b2 16 47 4d 82 da 23 5b 2a a4 63 29 11 a8 d4 c0 |..GM..#[*.c)....| +00000070 0b 5e 2d 73 0d d6 e7 1e 15 78 1a c2 58 93 70 14 |.^-s.....x..X.p.| +00000080 03 03 00 01 01 17 03 03 00 17 c3 65 82 87 0c 61 |...........e...a| +00000090 57 28 08 d5 da fc 59 8d a3 76 49 0f d5 80 68 3d |W(....Y..vI...h=| +000000a0 03 17 03 03 02 6d c5 f1 b7 8a 61 03 06 9e 0f 3b |.....m....a....;| +000000b0 be 71 5b 29 17 c7 ed 0e 23 40 90 c6 7a 22 4e ad |.q[)....#@..z"N.| +000000c0 d5 f1 60 f6 db d9 37 73 1f b6 43 f7 7b fe 7b aa |..`...7s..C.{.{.| +000000d0 f7 16 28 e5 a8 b6 be 69 da 79 09 b5 dc ab bf d3 |..(....i.y......| +000000e0 36 ca 19 ae 8c de 27 5c 0d 44 5e 4a e2 ac ff bc |6.....'\.D^J....| +000000f0 33 4e 35 d3 8d 21 22 4d 12 38 e2 f9 73 3b 3d d1 |3N5..!"M.8..s;=.| +00000100 a7 b1 06 6a 6a 8d 25 0f 47 b1 d1 f2 da 32 cc 58 |...jj.%.G....2.X| +00000110 9e 78 b6 b4 4e c1 bc 9d 91 38 44 ff 35 71 a7 c3 |.x..N....8D.5q..| +00000120 39 67 5b 50 b1 9b 87 5d fd 6d 87 42 25 10 1a 19 |9g[P...].m.B%...| +00000130 e1 95 19 2f a1 2c 95 6e ce 6c c9 d9 92 1d e6 7f |.../.,.n.l......| +00000140 9d d0 98 60 f3 6c cf 64 8e 66 bb a4 af de 1e b6 |...`.l.d.f......| +00000150 6a 6d 7b 11 a7 ca e1 29 49 f3 57 50 73 e8 36 79 |jm{....)I.WPs.6y| +00000160 81 fe 33 f7 04 1a 04 e3 60 8e e7 11 fa 07 bb 79 |..3.....`......y| +00000170 73 c0 b7 5e 0f 61 b7 3a 50 85 a4 e1 8e 3b a3 43 |s..^.a.:P....;.C| +00000180 79 8a 14 78 0a ff 66 b4 c3 c0 fe 0a 6a c6 66 72 |y..x..f.....j.fr| +00000190 a8 8a e1 9c a6 ad ee 74 53 d9 b8 07 17 b3 9b f6 |.......tS.......| +000001a0 eb 28 1b 64 97 aa 17 fa 80 36 cb b1 35 6e ec e1 |.(.d.....6..5n..| +000001b0 16 1f ba 00 0c 26 fb 17 0e 00 8a e3 28 0d 6a 76 |.....&......(.jv| +000001c0 8c 78 ee 55 02 78 66 90 5b 87 f2 16 e2 af ef fb |.x.U.xf.[.......| +000001d0 a1 f3 8f fd b9 8e e3 16 68 7a ec c0 54 2f 88 c4 |........hz..T/..| +000001e0 08 6c 55 48 58 56 ac 3e 26 5b 67 42 18 72 6e a1 |.lUHXV.>&[gB.rn.| +000001f0 b5 86 cf 55 d1 29 c5 9b 2c 7b 7d f3 a5 26 2e 5e |...U.)..,{}..&.^| +00000200 21 3a 40 97 5a c1 c8 13 3d c3 12 4e d8 88 e1 8f |!:@.Z...=..N....| +00000210 e8 c5 d3 9b 0f 49 24 42 da 27 ac e5 5e 21 2e 2c |.....I$B.'..^!.,| +00000220 8b 27 ae c4 39 49 6f 43 69 a3 e4 0d f1 fc 62 9f |.'..9IoCi.....b.| +00000230 be 65 78 01 d8 c8 4e 0f b5 d7 12 d1 fc 73 cc 6e |.ex...N......s.n| +00000240 cc df d3 df 33 e4 f8 8e 4f 82 60 cd 1f a1 71 74 |....3...O.`...qt| +00000250 20 7a e2 46 fc 7a 83 15 dc 6c 5d b3 4f 92 de a2 | z.F.z...l].O...| +00000260 99 b5 33 4e b0 5d 19 0f 84 ae de 65 2e ee ef 40 |..3N.].....e...@| +00000270 e9 5b c6 53 86 0d 88 fc 2a b2 2c 5c 76 66 95 a7 |.[.S....*.,\vf..| +00000280 96 ad 7f ba 27 ea e4 54 5e 77 97 0d 6f 9e b8 e5 |....'..T^w..o...| +00000290 b7 2f 75 13 42 7e 61 08 e3 69 31 d4 e6 d0 c0 6d |./u.B~a..i1....m| +000002a0 e3 e2 e4 69 5d d0 7d c2 f1 48 a1 e0 23 f1 19 81 |...i].}..H..#...| +000002b0 23 ed a7 ac ed 88 70 60 c6 eb cf 11 23 39 cb 91 |#.....p`....#9..| +000002c0 35 3b 32 6c 20 fc 61 cb 49 77 9c d9 5d e2 b4 41 |5;2l .a.Iw..]..A| +000002d0 b9 c6 22 af 36 e4 a4 c4 45 47 f4 53 3f 7f b4 25 |..".6...EG.S?..%| +000002e0 a0 34 f4 40 42 04 17 63 3b fa 05 35 c3 76 ec f7 |.4.@B..c;..5.v..| +000002f0 b3 ee 62 fb 03 dc 06 22 90 4b fd 07 62 3b cd 27 |..b....".K..b;.'| +00000300 da 87 32 73 3d 46 5c e7 b6 22 f7 02 8e 43 f4 46 |..2s=F\.."...C.F| +00000310 79 cb 9b 17 03 03 00 99 81 e1 c1 b3 1d 11 4b 61 |y.............Ka| +00000320 6a 4a f2 9a 97 52 36 2a fc ef 77 54 aa 28 a7 4f |jJ...R6*..wT.(.O| +00000330 46 c5 69 2a a7 d7 da d6 ff 28 b1 21 3b 66 ac a7 |F.i*.....(.!;f..| +00000340 ff 66 0a 10 20 1d 24 9b f3 46 1a a7 04 4b b5 3d |.f.. .$..F...K.=| +00000350 e8 49 fc 3a f0 74 a8 02 b9 2d 5d e4 de 91 ef 4d |.I.:.t...-]....M| +00000360 ab 47 10 2c ba 70 c1 aa a9 79 a8 96 27 71 90 e3 |.G.,.p...y..'q..| +00000370 91 4d 4e dd 96 e0 4c ad c5 0b 44 0a c0 4d 17 42 |.MN...L...D..M.B| +00000380 65 12 8a ba fb 7c 66 7c 92 61 87 07 cd e3 a0 16 |e....|f|.a......| +00000390 8b 94 23 77 85 70 88 d2 22 64 14 16 b5 ab db 6a |..#w.p.."d.....j| +000003a0 b9 23 26 ee c8 33 6e 9b a6 e4 d1 85 d2 81 3a 5d |.#&..3n.......:]| +000003b0 33 17 03 03 00 35 b2 85 a7 fd fc 27 46 25 8f cd |3....5.....'F%..| +000003c0 ac ff 84 0a 54 cf f2 11 94 41 d0 7e 04 50 61 7d |....T....A.~.Pa}| +000003d0 71 40 df bc 48 0f c1 32 50 83 5c 05 c9 a5 02 95 |q@..H..2P.\.....| +000003e0 77 04 8c 76 ee 44 32 44 94 e3 8b |w..v.D2D...| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 00 35 11 f3 e0 d9 39 |..........5....9| +00000010 43 24 33 e1 54 01 5d f2 c7 50 21 9f db 2d 31 81 |C$3.T.]..P!..-1.| +00000020 3f d5 9c cb 59 cb 24 40 2a 77 da 0a 9e 52 12 11 |?...Y.$@*w...R..| +00000030 1e a8 f8 e2 f2 9e 32 6c 06 8c 48 e8 bf 9d ef 0f |......2l..H.....| +00000040 17 03 03 00 17 bc a1 a2 8a a1 6c c3 19 d1 49 7f |..........l...I.| +00000050 57 af 58 5b ff 7b 11 b2 bb 45 3c 6f 17 03 03 00 |W.X[.{...E>> Flow 1 (client to server) +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 fa ff 71 26 f0 |....z...v....q&.| +00000010 2c ee 80 2c 1c f9 ea 4b de ad d0 61 83 7f 89 6f |,..,...K...a...o| +00000020 db e6 a9 53 ff c5 b5 ec 04 08 4c 20 00 00 00 00 |...S......L ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 13 02 00 00 |................| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 6f |..+.....3.$... o| +00000060 2a 3a fe 8e dc cf 2e 7d 26 bd 12 fb da 0a 00 16 |*:.....}&.......| +00000070 b7 12 79 72 a0 a8 95 11 81 d5 b3 ae f8 d7 26 14 |..yr..........&.| +00000080 03 03 00 01 01 17 03 03 00 17 42 95 95 65 84 db |..........B..e..| +00000090 3e dc c4 41 bb e2 21 94 27 2d 9e 27 4e dd 3e 9d |>..A..!.'-.'N.>.| +000000a0 6e 17 03 03 02 6d 71 24 bb 82 cf aa 37 52 4c 15 |n....mq$....7RL.| +000000b0 6d 5c 74 44 c5 08 21 31 ab 47 5a 75 b9 31 d6 97 |m\tD..!1.GZu.1..| +000000c0 69 64 40 b5 09 1c 2b 36 1d 54 19 52 4b ad c9 1c |id@...+6.T.RK...| +000000d0 d4 51 33 80 a4 b9 df 47 17 6a eb 7a d7 bc 12 3e |.Q3....G.j.z...>| +000000e0 7b 28 fa 15 16 aa 23 6f b5 5f a4 f6 8e 2b 00 11 |{(....#o._...+..| +000000f0 1b f2 00 e4 c8 31 38 ee 61 71 bc 7f dd a1 45 2d |.....18.aq....E-| +00000100 ac 1c 2b fd cd 40 51 29 4e 07 fd f4 04 45 09 56 |..+..@Q)N....E.V| +00000110 72 c8 83 22 3e 20 06 3a 93 16 89 21 4a 9f 3b bc |r.."> .:...!J.;.| +00000120 63 7f c0 1b 6a b2 30 d1 49 43 90 08 af 28 4a c1 |c...j.0.IC...(J.| +00000130 79 96 a1 72 0a 82 fe fb 20 1d 18 f8 b7 03 01 89 |y..r.... .......| +00000140 05 04 d7 98 1b 77 2e ad 81 56 de 08 f1 83 1e 9c |.....w...V......| +00000150 7d 2b 16 e1 15 87 12 db 5f 59 5d a3 95 75 ab f8 |}+......_Y]..u..| +00000160 54 87 91 0d 7f 80 76 6e d8 44 f3 c5 ef d6 b4 3d |T.....vn.D.....=| +00000170 6e 91 4c 65 b7 94 2d 05 d1 1e e6 49 d4 78 1c 34 |n.Le..-....I.x.4| +00000180 48 4a 5b 8c ed ad f7 cb 60 98 56 b5 98 ed 7e 88 |HJ[.....`.V...~.| +00000190 4b 98 ec aa 7d 79 71 2c f2 2f 15 5e c1 ed a6 14 |K...}yq,./.^....| +000001a0 01 df 25 df 79 35 1c f0 52 85 7b 2b 46 2c 09 14 |..%.y5..R.{+F,..| +000001b0 26 86 2c 6a d5 ec cf 24 04 49 9c d8 61 65 02 aa |&.,j...$.I..ae..| +000001c0 d6 ce 55 07 2f b6 23 f3 a7 8d 78 f9 72 fc 77 8b |..U./.#...x.r.w.| +000001d0 45 72 0e 61 c2 e8 8d 65 00 50 8b 00 42 48 d1 10 |Er.a...e.P..BH..| +000001e0 1f 3e cc ca 21 10 4c 0b 6b fc f8 c1 b7 83 3e 25 |.>..!.L.k.....>%| +000001f0 8e 40 11 55 32 34 83 0b 98 38 ad 2a ff e0 ae 71 |.@.U24...8.*...q| +00000200 86 0d 9a ef 50 e8 8a 32 53 ba c8 71 4e 96 46 95 |....P..2S..qN.F.| +00000210 c2 31 b5 64 6c 74 8e b6 be 8c e7 bd 5c 79 fd 87 |.1.dlt......\y..| +00000220 db 7e 39 82 7c 7b 38 58 42 34 a1 64 e9 15 f8 f3 |.~9.|{8XB4.d....| +00000230 56 2c ec c9 4f f3 4d e0 3d a6 ec 87 5f 48 be 75 |V,..O.M.=..._H.u| +00000240 d0 9e a6 6c ef 97 db a8 66 ff 8b 5e 34 28 bb 34 |...l....f..^4(.4| +00000250 e0 9c a0 a1 18 2a f4 98 71 e7 8b 18 2c 7c 37 a9 |.....*..q...,|7.| +00000260 c0 75 b4 24 7f ce 85 42 fe ed 7f fd 6d 7c 3d 5b |.u.$...B....m|=[| +00000270 bf d4 72 b9 2f 6d b6 09 86 cd 48 2f 69 a5 94 86 |..r./m....H/i...| +00000280 ab e9 04 b7 b3 88 3b 49 6b 28 e5 8a 30 73 60 9a |......;Ik(..0s`.| +00000290 c9 ff c5 ff 62 0b cc 3a ec 8b 4b a5 f2 2e c3 9d |....b..:..K.....| +000002a0 a1 5d 51 9d f0 2d 88 20 24 cc bf cf 79 69 aa 4d |.]Q..-. $...yi.M| +000002b0 f0 86 ba 9f 7c b4 f0 e3 97 54 7b f5 68 f8 da 26 |....|....T{.h..&| +000002c0 38 a5 5c 86 c5 0a f5 06 af 58 66 e3 40 a0 33 d4 |8.\......Xf.@.3.| +000002d0 cb 90 52 1b 81 3d 31 9d f9 8f 4f d9 38 80 f3 ea |..R..=1...O.8...| +000002e0 79 c4 2c 55 3f ea 9b 79 51 24 dc 70 6e 5c 68 ce |y.,U?..yQ$.pn\h.| +000002f0 b0 65 58 ec 3d 62 27 f3 1c 34 b4 7c b5 8e 91 1d |.eX.=b'..4.|....| +00000300 dc 6b 21 b5 3d 9c 6f 30 91 f8 39 d8 11 03 65 95 |.k!.=.o0..9...e.| +00000310 72 71 36 17 03 03 00 99 4f 82 32 b2 1c df 6d 0d |rq6.....O.2...m.| +00000320 c5 6f d7 89 39 07 42 4d d5 ae 7d 0d 6f a8 68 41 |.o..9.BM..}.o.hA| +00000330 ca 64 5c 38 5a 31 85 02 d7 99 28 ac 0d 33 1b e2 |.d\8Z1....(..3..| +00000340 d8 f7 f2 d3 13 30 50 0f e9 21 3c 9e 53 1c fb cd |.....0P..!<.S...| +00000350 96 e7 00 ef 35 5d d6 a7 64 77 fd 76 07 fa e6 e0 |....5]..dw.v....| +00000360 04 ec cf c0 76 41 a7 12 37 e0 c3 42 43 11 54 7e |....vA..7..BC.T~| +00000370 4f b8 38 3a 3e 60 0f 9c ac 65 d1 84 d3 6e b1 c2 |O.8:>`...e...n..| +00000380 fc be a7 96 59 89 87 c7 b9 d7 09 c0 ef 68 d7 10 |....Y........h..| +00000390 a5 08 8a 45 23 17 47 e3 eb f7 9f d3 ab 54 d1 4a |...E#.G......T.J| +000003a0 8c 69 1f aa a3 43 af dd ce 76 a3 9a 6f e5 4c 6a |.i...C...v..o.Lj| +000003b0 07 17 03 03 00 45 b8 72 a2 fb af 1c 5e 8f ed 0a |.....E.r....^...| +000003c0 53 85 d3 cd 32 ad 56 ba 38 82 1c 23 40 83 7e c1 |S...2.V.8..#@.~.| +000003d0 ce 0f 53 f5 74 a0 54 39 aa fb f1 13 8d 5f 3a 93 |..S.t.T9....._:.| +000003e0 fc 98 72 3f e5 70 e2 e5 97 fb 92 ca 2b 52 50 96 |..r?.p......+RP.| +000003f0 3f d0 8d 94 d5 17 2b 0d 90 4a 12 |?.....+..J.| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 00 45 f6 a2 b0 dd 25 |..........E....%| +00000010 6e 65 f4 c5 74 2b 60 e0 14 12 92 b3 fc 8c 18 06 |ne..t+`.........| +00000020 fb 5d c4 de d9 41 df 39 47 b1 d0 2f 3c 4e 90 fb |.]...A.9G../>> Flow 1 (client to server) +00000000 16 03 01 01 10 01 00 01 0c 03 03 00 00 00 00 00 |................| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 91 33 74 00 00 00 05 00 05 01 00 00 00 |....3t..........| +00000090 00 00 0a 00 0a 00 08 00 1d 00 17 00 18 00 19 00 |................| +000000a0 0b 00 02 01 00 00 0d 00 18 00 16 08 04 08 05 08 |................| +000000b0 06 04 01 04 03 05 01 05 03 06 01 06 03 02 01 02 |................| +000000c0 03 ff 01 00 01 00 00 10 00 10 00 0e 06 70 72 6f |.............pro| +000000d0 74 6f 32 06 70 72 6f 74 6f 31 00 12 00 00 00 2b |to2.proto1.....+| +000000e0 00 09 08 03 04 03 03 03 02 03 01 00 33 00 26 00 |............3.&.| +000000f0 24 00 1d 00 20 2f e5 7d a3 47 cd 62 43 15 28 da |$... /.}.G.bC.(.| +00000100 ac 5f bb 29 07 30 ff f6 84 af c4 cf c2 ed 90 99 |._.).0..........| +00000110 5f 58 cb 3b 74 |_X.;t| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 8b 65 4e 74 f0 |....z...v...eNt.| +00000010 c4 05 7a a1 58 a7 fd b0 55 9e d2 15 67 1f 19 f9 |..z.X...U...g...| +00000020 25 e1 3e 89 4f a6 79 90 95 5a 8c 20 00 00 00 00 |%.>.O.y..Z. ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 13 01 00 00 |................| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 a5 |..+.....3.$... .| +00000060 e3 ac d0 3c 26 f8 66 41 ac b5 47 6f 63 a0 8f 0a |...<&.fA..Goc...| +00000070 6f 79 62 23 15 01 d0 57 5d 66 9c 09 50 c5 45 14 |oyb#...W]f..P.E.| +00000080 03 03 00 01 01 17 03 03 00 24 7d dc b2 50 38 8e |.........$}..P8.| +00000090 15 52 73 25 90 d3 d3 f2 19 da 76 ae 64 42 29 eb |.Rs%......v.dB).| +000000a0 21 1b 7d b1 d9 04 94 ac 71 b9 b3 e1 d7 59 17 03 |!.}.....q....Y..| +000000b0 03 02 6d cb 4e 30 d0 df 41 b8 1a 76 1d e2 a2 14 |..m.N0..A..v....| +000000c0 24 ec e4 b8 e4 5b 98 49 ed 4e 48 98 3d a7 89 d4 |$....[.I.NH.=...| +000000d0 d1 35 2f d4 12 dc 0b c3 3f e7 0c df 11 20 41 fb |.5/.....?.... A.| +000000e0 5c 24 62 82 26 ad 28 25 59 c0 c0 81 41 9d 80 b7 |\$b.&.(%Y...A...| +000000f0 db cd 41 bb 27 66 ba 55 e6 2f 52 5d 71 d4 77 6a |..A.'f.U./R]q.wj| +00000100 5c 5d 72 34 e6 83 9d c6 24 d1 be 3b 99 90 9b 22 |\]r4....$..;..."| +00000110 7f d8 81 39 d4 7b a8 f9 d7 61 82 a1 72 f9 27 0b |...9.{...a..r.'.| +00000120 b8 6a 5c 72 bd 8f 84 34 c6 d0 c8 1a b9 27 d6 7b |.j\r...4.....'.{| +00000130 12 20 37 b7 64 85 19 7e b4 37 46 df 51 77 23 be |. 7.d..~.7F.Qw#.| +00000140 c4 7a e4 7e 37 3b 53 3e 3b 86 8f 22 31 28 4b 8f |.z.~7;S>;.."1(K.| +00000150 89 0d dc 8d 67 37 53 9d 38 f2 5f 99 2c f4 76 64 |....g7S.8._.,.vd| +00000160 87 e4 ce b7 4f d0 83 99 b2 55 8c 38 8c d0 89 d1 |....O....U.8....| +00000170 2f 91 e8 ae ec b1 a6 29 65 3a 8f af 69 e0 48 00 |/......)e:..i.H.| +00000180 db 3e 30 bd 7f 4b 82 56 cf f9 5b 5e 74 d7 d5 4b |.>0..K.V..[^t..K| +00000190 47 4f 22 17 53 fc e6 98 a4 5a 25 ca 7d ca 39 e9 |GO".S....Z%.}.9.| +000001a0 fe 11 f5 ca 91 e1 25 3c 6d f2 b3 d0 9f ee 88 d2 |......%>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 00 35 f6 6b cb 4a 37 |..........5.k.J7| +00000010 3e e2 61 7e 5b ac c5 25 cc 54 a2 6d 4e 7c 37 19 |>.a~[..%.T.mN|7.| +00000020 ea 21 af df 7b dc 04 2d db 84 ad 06 04 bd 50 f5 |.!..{..-......P.| +00000030 05 9b 19 01 37 22 d2 6f 06 c2 63 dd 95 e6 ef 45 |....7".o..c....E| +00000040 17 03 03 00 17 6d 03 e7 38 f9 a4 3c a7 c2 ee 8d |.....m..8..<....| +00000050 07 49 bd e6 e4 be 3f a3 ec 64 6c 3a 17 03 03 00 |.I....?..dl:....| +00000060 13 cc a9 19 b1 03 56 99 c1 4c d0 f5 fd 3b e2 dd |......V..L...;..| +00000070 0e ef a0 20 |... | diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv13-CHACHA20-SHA256 b/libgo/go/crypto/tls/testdata/Client-TLSv13-CHACHA20-SHA256 new file mode 100644 index 00000000000..98c3c52170c --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Client-TLSv13-CHACHA20-SHA256 @@ -0,0 +1,90 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 49 41 93 3b 12 |....z...v..IA.;.| +00000010 17 ef c7 e6 29 09 70 0e 6b df f7 3d bb 01 9d 27 |....).p.k..=...'| +00000020 cb 0d 97 6b ce 4c 49 60 3e ff 18 20 00 00 00 00 |...k.LI`>.. ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 13 03 00 00 |................| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 a6 |..+.....3.$... .| +00000060 16 ca 24 6e e9 b1 38 c9 3c 45 0e 35 98 32 c5 7c |..$n..8...U<| +00000150 00 77 9a 72 ba fc 13 ad 7a dc 34 0f aa 26 f9 c6 |.w.r....z.4..&..| +00000160 fe b7 ef 0f e8 d7 46 d0 a7 ee e8 39 4d c1 13 a2 |......F....9M...| +00000170 5c 00 e2 3e 47 08 71 b7 53 94 38 f6 31 3a 60 a5 |\..>G.q.S.8.1:`.| +00000180 57 82 4c bc c0 f7 9b c3 4e 00 5e 5e 40 ef ae 61 |W.L.....N.^^@..a| +00000190 09 37 38 40 b7 93 12 0a 7c 02 22 b9 39 a2 43 e3 |.78@....|.".9.C.| +000001a0 f3 09 36 a7 2a c9 2b 35 fc 2c fc 1c 82 d0 3f 03 |..6.*.+5.,....?.| +000001b0 a9 fc bc 53 79 23 5a ce 2d 07 80 5c 2c aa 34 52 |...Sy#Z.-..\,.4R| +000001c0 9d 71 2d 16 4a f0 09 e6 95 94 2b dd bf d5 9c 84 |.q-.J.....+.....| +000001d0 79 fc 41 15 a6 68 81 23 7e dc 83 55 b0 a4 a4 1c |y.A..h.#~..U....| +000001e0 4e 1e 4d 78 6d 62 45 59 1d bb c3 98 d5 0b 3a 8c |N.MxmbEY......:.| +000001f0 f1 98 49 6b 0f 64 29 d5 38 ad 6a ea 8b 34 29 99 |..Ik.d).8.j..4).| +00000200 c0 04 ce 5a 4f 74 e8 ec bb 0a a5 cd 23 6d 31 7a |...ZOt......#m1z| +00000210 d6 6e 1a 74 53 57 59 76 e9 e7 b2 5d 9f 5d 9a 53 |.n.tSWYv...].].S| +00000220 b0 e6 d1 ad ba 43 b6 40 65 65 3a 04 35 12 e1 f7 |.....C.@ee:.5...| +00000230 0e 91 f6 0c 1e 74 65 e3 90 ed e6 ec fd 88 99 e8 |.....te.........| +00000240 20 64 90 33 b9 a9 d8 a2 f0 d7 e8 e0 cf 8d d4 2a | d.3...........*| +00000250 91 12 44 28 3b 99 69 93 aa 3e b2 3b 6a f0 dc 0a |..D(;.i..>.;j...| +00000260 8b 2e 7c d9 c0 c7 b7 d6 f2 07 69 81 97 7b d9 6a |..|.......i..{.j| +00000270 56 c3 6a e5 d5 6a 06 e7 60 b2 72 1c 4f cc 3f 6e |V.j..j..`.r.O.?n| +00000280 e9 fe 94 79 49 36 a6 5f 6d bf b2 87 a1 59 a3 c4 |...yI6._m....Y..| +00000290 39 ad 9a ea 57 a5 69 47 f0 9b 60 4a a6 45 e8 70 |9...W.iG..`J.E.p| +000002a0 6c 6b 1b 17 8a 4e 5e 56 89 40 de 91 c3 8a 05 06 |lk...N^V.@......| +000002b0 57 9e 68 87 1e 00 c8 08 93 1c f1 57 0f 91 dd 32 |W.h........W...2| +000002c0 b7 e8 96 99 e3 90 44 5e 7a 68 d8 e0 55 67 80 a0 |......D^zh..Ug..| +000002d0 e3 bd d5 f7 01 f4 30 58 a7 b4 62 d7 7b 9c 5b 9b |......0X..b.{.[.| +000002e0 62 20 b6 01 25 1b ff 6f b3 4f bc 41 ae 9c 88 71 |b ..%..o.O.A...q| +000002f0 51 f5 25 06 44 a1 49 6b 1b db ac 4b 37 41 78 29 |Q.%.D.Ik...K7Ax)| +00000300 1c c9 33 82 f4 fe d3 0a f9 e0 e8 ca 8c 7b 76 3d |..3..........{v=| +00000310 8b 3c 3b 17 03 03 00 99 3e 4c 63 66 48 fa 43 7a |.<;.....>LcfH.Cz| +00000320 4d 4b 8b 95 25 ca 9a e7 cf d8 d6 e2 4d e7 15 07 |MK..%.......M...| +00000330 d2 cb 07 79 66 63 b5 8f 3a 7d 00 f4 3a 05 b4 ae |...yfc..:}..:...| +00000340 e6 7e 0e b5 a2 20 ee 0e cc 85 de c2 5d d5 49 32 |.~... ......].I2| +00000350 83 d8 2a 11 36 36 86 93 46 ac ce 7e b4 4d e6 20 |..*.66..F..~.M. | +00000360 24 7d 8e c7 37 5f 05 aa 5e a7 de e6 c7 79 88 a7 |$}..7_..^....y..| +00000370 e7 f7 86 51 07 e0 80 63 76 b2 03 a9 6c c4 86 1a |...Q...cv...l...| +00000380 8d 98 e7 16 e0 a2 dc 6e 5c 19 d1 98 c4 10 2b 39 |.......n\.....+9| +00000390 f4 03 b9 0f b5 ab c3 25 18 bf 8c 59 16 7a 06 60 |.......%...Y.z.`| +000003a0 73 9a 7c 6f d1 1e e1 de 07 23 21 0e 28 c2 fb 19 |s.|o.....#!.(...| +000003b0 64 17 03 03 00 35 e0 fd 9c 49 88 45 b3 c7 da a3 |d....5...I.E....| +000003c0 02 ee 8e 0c e0 33 64 01 35 7e aa 31 aa 43 75 64 |.....3d.5~.1.Cud| +000003d0 30 fc 89 d8 f0 dc 6e 49 68 e8 4e 01 41 0d 31 07 |0.....nIh.N.A.1.| +000003e0 c4 e1 bd db 83 b1 e6 46 f0 06 56 |.......F..V| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 00 35 a3 4c 7d ed 56 |..........5.L}.V| +00000010 62 f5 7a b9 39 08 02 7f 12 72 c2 de 2f dc 35 a2 |b.z.9....r../.5.| +00000020 1f d0 8e 1a 7b c2 19 17 93 df 83 84 66 9e 8d 1a |....{.......f...| +00000030 fa 8c 37 74 04 13 b5 a2 81 7f dc 85 4c 37 f0 f1 |..7t........L7..| +00000040 17 03 03 00 17 51 47 a8 1b bc 86 62 90 79 8a c7 |.....QG....b.y..| +00000050 db 2c 99 95 bf 7c d0 27 6c c3 b6 24 17 03 03 00 |.,...|.'l..$....| +00000060 13 e2 a8 b5 52 61 b0 66 54 50 60 83 78 3d 26 ef |....Ra.fTP`.x=&.| +00000070 f5 5e 36 58 |.^6X| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv13-ClientCert-ECDSA-RSA b/libgo/go/crypto/tls/testdata/Client-TLSv13-ClientCert-ECDSA-RSA new file mode 100644 index 00000000000..633397542c1 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Client-TLSv13-ClientCert-ECDSA-RSA @@ -0,0 +1,139 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 9b d5 46 91 59 |....z...v....F.Y| +00000010 c3 26 be 21 ae 20 5f 26 4f 5f 19 ae 3c fe b9 df |.&.!. _&O_..<...| +00000020 16 1b 16 45 4b da 4e 08 58 e9 05 20 00 00 00 00 |...EK.N.X.. ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 13 01 00 00 |................| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 08 |..+.....3.$... .| +00000060 7c 10 a4 69 11 21 4e 78 e3 38 76 c1 4a c2 da 5e ||..i.!Nx.8v.J..^| +00000070 8f 82 b8 4a 32 d8 7c 48 b6 78 e2 61 1d b6 21 14 |...J2.|H.x.a..!.| +00000080 03 03 00 01 01 17 03 03 00 17 7f ac 84 c7 d4 6a |...............j| +00000090 fc 73 53 a6 ae 25 f9 ad e4 4c b9 31 71 4f ba b1 |.sS..%...L.1qO..| +000000a0 55 17 03 03 00 42 61 ac 61 81 87 40 f1 15 d1 7a |U....Ba.a..@...z| +000000b0 44 ef c0 c8 4a 79 99 f1 16 28 36 4b 31 24 95 b7 |D...Jy...(6K1$..| +000000c0 38 49 60 00 a9 aa 51 40 91 52 2f 39 20 d1 37 92 |8I`...Q@.R/9 .7.| +000000d0 cf e1 cb 42 4a 7a 83 27 d3 77 20 4c 3c 22 0b 65 |...BJz.'.w L<".e| +000000e0 8f ce 2a ec c2 5f 90 b0 17 03 03 02 6d 3a d2 ce |..*.._......m:..| +000000f0 b7 7b d3 94 d4 33 91 be 81 f1 af 80 e6 3e 28 d5 |.{...3.......>(.| +00000100 d8 2f 23 08 b6 a6 80 ec b4 bb 2e 85 31 ed 90 46 |./#.........1..F| +00000110 74 34 90 77 0d d3 51 2d 6e 67 f0 4c 36 7c f2 30 |t4.w..Q-ng.L6|.0| +00000120 08 86 6e 53 08 01 c5 06 c8 a4 c6 6a c0 32 80 d4 |..nS.......j.2..| +00000130 0f 05 ff 91 96 a6 75 5f 71 72 be 63 fb 88 dc 5c |......u_qr.c...\| +00000140 06 06 eb 06 57 94 04 61 11 b5 03 1a 96 a3 c4 10 |....W..a........| +00000150 7b b9 ee 83 3e 73 42 71 93 52 a3 44 b8 9d fb 8e |{...>sBq.R.D....| +00000160 5b 5d e4 af 22 0b dc 40 09 34 aa dc 08 d3 e9 54 |[].."..@.4.....T| +00000170 0a b6 ea 87 33 e6 f5 eb 59 e0 6e c3 24 be 81 b3 |....3...Y.n.$...| +00000180 93 89 d1 f4 dd 8f ab c9 a4 1f bf ed 58 86 f4 41 |............X..A| +00000190 de bf 87 2e 1c fb b0 99 f0 ab 4e ec 3e 22 80 78 |..........N.>".x| +000001a0 45 71 eb 6a f0 0a 89 bf fe 37 e4 1d a6 90 f4 f3 |Eq.j.....7......| +000001b0 7c 96 26 47 9d 07 53 16 7c 15 b1 8a 60 ec ad 55 ||.&G..S.|...`..U| +000001c0 e3 50 7c 1f 5f 67 bc 29 b0 c5 12 99 db d9 b2 1f |.P|._g.)........| +000001d0 6c b6 bc 7d ed 0c d3 76 a0 1d c3 f1 f3 10 9d 63 |l..}...v.......c| +000001e0 22 fd 66 f4 12 4d 4f 2e 7a 81 6e 9f 55 cb 40 26 |".f..MO.z.n.U.@&| +000001f0 77 6a 9c 44 5b c2 cf ae 2d de 7c 85 ca 3e f6 c9 |wj.D[...-.|..>..| +00000200 22 d0 34 f8 36 f2 a4 56 5d dc aa 7d f4 9d 3a e0 |".4.6..V]..}..:.| +00000210 3e 4a b8 77 be 7e 8c c1 f0 0f 42 e7 54 a3 a0 b7 |>J.w.~....B.T...| +00000220 76 33 fd 51 8c 2b e8 c3 85 de 0c d3 d7 1a 34 16 |v3.Q.+........4.| +00000230 41 fb e4 eb fb 0f 8b b2 71 45 a7 3e 8f 82 ac b9 |A.......qE.>....| +00000240 85 54 6f 5a 66 a0 16 90 00 24 e0 91 6e 7f 11 55 |.ToZf....$..n..U| +00000250 cb 1a 6f f1 89 b2 a7 23 52 a7 ec 54 cc 0c 51 71 |..o....#R..T..Qq| +00000260 e8 21 fc b2 ca 90 0d 44 ab 05 18 62 4c 01 41 44 |.!.....D...bL.AD| +00000270 eb a9 ca 97 31 a8 0f 5f b9 3a d3 18 a0 be a1 cc |....1.._.:......| +00000280 2f 88 54 b6 c3 8d e7 12 9f 2d 53 62 2e 05 ba 6e |/.T......-Sb...n| +00000290 9c 75 69 cb 4e 3d 2a 46 20 c0 92 c8 e6 e4 1a 16 |.ui.N=*F .......| +000002a0 4b 09 7d 02 ec 8e 7f a2 b9 e9 05 32 88 4b be 39 |K.}........2.K.9| +000002b0 30 c5 f9 ed ca 2a 1d a3 3b fe 18 76 2e f2 51 d4 |0....*..;..v..Q.| +000002c0 b3 aa 61 67 3b eb 90 9c bb ea 1a 6c 11 7b ba 86 |..ag;......l.{..| +000002d0 38 f1 cd c7 3c 64 56 f3 ca ff fd b2 14 bf 37 7f |8...>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 02 1e e2 06 ae 3e 78 |..............>x| +00000010 b4 85 1b 44 b7 6d 04 4b 9f 2c ea 23 79 66 d5 7d |...D.m.K.,.#yf.}| +00000020 c5 39 57 5c 15 49 9a 6e c8 19 1b ed 5d 95 ce 6f |.9W\.I.n....]..o| +00000030 df 96 3a 16 87 88 c0 25 6a 36 fc 62 05 01 bd c1 |..:....%j6.b....| +00000040 00 a8 11 da 7f 0e a3 6c 28 26 9f 4a 18 e2 44 b9 |.......l(&.J..D.| +00000050 aa 71 b2 f6 fa 8b cc 67 c5 29 72 32 cf 78 36 6b |.q.....g.)r2.x6k| +00000060 22 67 86 ac 71 19 cb 9d 9e 36 7b 03 42 01 e5 4b |"g..q....6{.B..K| +00000070 4c c0 0d 93 22 51 a6 d3 65 00 87 ef 92 f3 08 33 |L..."Q..e......3| +00000080 4b e1 18 bc ba 2b 43 90 0f 2f d5 8e 4c 79 9f a7 |K....+C../..Ly..| +00000090 bd 00 2a b7 89 27 b3 e3 db b7 a7 26 b4 8e 48 6f |..*..'.....&..Ho| +000000a0 e7 12 55 f0 8e 02 a8 3f 30 d4 22 a4 d0 e3 89 63 |..U....?0."....c| +000000b0 7d cf c2 46 27 31 8c 10 5f 28 9f 85 fb 02 64 6a |}..F'1.._(....dj| +000000c0 8d 50 26 e6 73 57 43 53 39 c7 bb 72 4e c2 dd 07 |.P&.sWCS9..rN...| +000000d0 86 b0 96 30 f5 d8 f0 5a a0 09 1c 42 26 65 50 d1 |...0...Z...B&eP.| +000000e0 65 1f 97 fd a0 3a c2 ae d6 a4 08 af 5c 9d 30 12 |e....:......\.0.| +000000f0 fc d8 a2 cd d3 b1 7b de 4b be df 54 aa 31 48 32 |......{.K..T.1H2| +00000100 7a d2 d5 59 f1 39 bc cd 23 2b ac 17 ff e4 0e ec |z..Y.9..#+......| +00000110 55 d2 b9 6b a0 30 65 db 5b e9 b4 ab b9 1e dd 3c |U..k.0e.[......<| +00000120 fd 38 7b 19 7f ea 79 56 90 f8 41 bc 3d 64 0b df |.8{...yV..A.=d..| +00000130 05 a3 6c b8 14 5f f5 41 4f 3c 6d 46 a3 24 92 22 |..l.._.AO.....| +00000250 18 9d de 95 a3 d2 00 98 88 90 4d d0 19 a0 47 60 |..........M...G`| +00000260 6f 1b 36 e4 c0 d8 02 52 b8 0b f4 78 44 8d 72 56 |o.6....R...xD.rV| +00000270 e4 68 ce c0 cd 71 34 60 6b 6c 8f 22 cb 78 d2 d7 |.h...q4`kl.".x..| +00000280 fc 89 b9 d6 34 34 c9 f1 44 78 84 36 27 bc 73 0e |....44..Dx.6'.s.| +00000290 ae 43 72 66 07 e4 6c fd ee da ca 99 a2 25 21 a7 |.Crf..l......%!.| +000002a0 eb 63 11 21 c4 30 45 b3 82 27 7d 8c 9d 37 86 8d |.c.!.0E..'}..7..| +000002b0 35 90 5c 13 be 21 fc bd 65 af ec 65 3d c0 9a 1d |5.\..!..e..e=...| +000002c0 6b 75 38 17 8d d1 92 ba 43 c1 e8 a5 43 f5 0b ab |ku8.....C...C...| +000002d0 16 4d 17 03 03 00 35 a9 24 2a fd af f5 da 3b ed |.M....5.$*....;.| +000002e0 d7 15 86 16 c5 e8 bf 95 bc e1 90 fb 0f be f2 3c |...............<| +000002f0 75 b0 30 1b ce f9 ac f7 97 ae 7e 29 d7 17 aa a4 |u.0.......~)....| +00000300 ba c3 2a db 1a 7c 5e bc 18 84 6e e0 17 03 03 00 |..*..|^...n.....| +00000310 17 52 2f 82 87 2d ca 50 2c 51 f6 99 9d 54 5a 68 |.R/..-.P,Q...TZh| +00000320 38 61 ca 02 81 2c 62 dc 17 03 03 00 13 35 e5 58 |8a...,b......5.X| +00000330 b4 26 e0 83 2a 8e 61 e9 96 1a cd 1a 6e c9 67 c0 |.&..*.a.....n.g.| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv13-ClientCert-RSA-ECDSA b/libgo/go/crypto/tls/testdata/Client-TLSv13-ClientCert-RSA-ECDSA new file mode 100644 index 00000000000..74163f0521f --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Client-TLSv13-ClientCert-RSA-ECDSA @@ -0,0 +1,134 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 dd 25 8d f2 41 |....z...v...%..A| +00000010 0b 2f 7b 80 24 03 af 9d 81 4e fd a8 ae e4 00 ee |./{.$....N......| +00000020 99 5f 09 05 8b 2a c2 0a 7c 92 ad 20 00 00 00 00 |._...*..|.. ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 13 01 00 00 |................| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 fd |..+.....3.$... .| +00000060 03 d1 75 4e 57 ae b0 cc 43 4f 7e 2b de a8 01 46 |..uNW...CO~+...F| +00000070 98 c7 f9 8e a5 46 95 68 fa 5e 07 c3 a1 55 5e 14 |.....F.h.^...U^.| +00000080 03 03 00 01 01 17 03 03 00 17 df 30 a4 ce 8e db |...........0....| +00000090 20 0d 74 59 0a df 8e 67 23 af 3d 2f 87 8f 31 a0 | .tY...g#.=/..1.| +000000a0 bf 17 03 03 00 42 0f 0a 20 4e 21 cd d8 01 13 ea |.....B.. N!.....| +000000b0 74 29 8d e4 a0 1b 6a a5 be 89 03 8d 2b 39 c4 23 |t)....j.....+9.#| +000000c0 5e b1 f7 4f e4 1f dd ea f8 38 fe 07 89 ca f1 e6 |^..O.....8......| +000000d0 11 e9 2d 40 ca f1 63 11 ac 29 44 c2 25 18 4d 29 |..-@..c..)D.%.M)| +000000e0 30 aa cb 35 b4 33 27 8a 17 03 03 02 22 36 fb 97 |0..5.3'....."6..| +000000f0 fd ba 12 9b e5 19 14 79 2b 78 0e 6c a9 d8 13 a2 |.......y+x.l....| +00000100 51 d8 c1 4b 53 ac a4 73 cf b1 2d 2c 4d 14 b8 10 |Q..KS..s..-,M...| +00000110 de 5d 86 81 19 77 19 a0 b4 1b eb 85 f4 dc 21 2f |.]...w........!/| +00000120 c5 5c 62 44 1b ca f2 91 06 95 14 7a 07 02 1f 98 |.\bD.......z....| +00000130 0d bc a4 89 7c 96 21 6b 37 1c 47 4a 10 e8 e2 b6 |....|.!k7.GJ....| +00000140 f9 e2 97 06 a5 88 ad 5c f1 08 28 4b f5 d5 9a a0 |.......\..(K....| +00000150 51 74 30 ab 9c 52 b0 b9 2d 38 bb 25 b8 6e 71 a7 |Qt0..R..-8.%.nq.| +00000160 7b c9 76 56 13 e6 60 bf 70 15 11 0c 21 12 cd a1 |{.vV..`.p...!...| +00000170 b8 e5 3a 49 00 ad 9c 2f e5 2b 1f cc 4e 4f 0b 90 |..:I.../.+..NO..| +00000180 e1 77 64 5f b5 fc 7b 1c f3 09 cb 0e c4 94 d7 33 |.wd_..{........3| +00000190 59 5b 8f ae e1 9c e4 f6 83 10 f0 71 5f 17 4b b3 |Y[.........q_.K.| +000001a0 3f 81 2c 0a 22 c5 f4 6b bd 83 32 37 4a 2a 9a db |?.,."..k..27J*..| +000001b0 7b 42 c2 c0 7d 13 e0 e7 ea d7 58 a6 b1 20 68 bc |{B..}.....X.. h.| +000001c0 ba 4e 1a 91 6d dd 11 b9 fc 57 02 4d d4 e8 47 74 |.N..m....W.M..Gt| +000001d0 9d e1 a0 25 2f d9 7d 21 39 b9 ca 4c ff de 42 8c |...%/.}!9..L..B.| +000001e0 36 bb 46 79 d3 52 be bc 1c dc 1f e3 6e 18 b8 4e |6.Fy.R......n..N| +000001f0 b2 47 e6 74 d3 50 fa cf fd 5a c8 33 9a 17 2f 48 |.G.t.P...Z.3../H| +00000200 e6 20 29 b3 7b e3 de a1 c8 e7 74 f0 ca eb f9 6e |. ).{.....t....n| +00000210 29 2c 73 17 df 5f 8f ed dc ae 2a a6 37 f2 b7 f7 |),s.._....*.7...| +00000220 38 da 45 63 cd 2e e6 bf c7 a4 3c 15 c2 89 6f 59 |8.Ec......<...oY| +00000230 c2 19 29 19 13 4f a4 59 57 f9 da 8c 7d 5a 82 7a |..)..O.YW...}Z.z| +00000240 9f 79 01 51 94 7c 25 46 7e c2 b2 bf b4 dd c1 e8 |.y.Q.|%F~.......| +00000250 12 14 3e 77 44 8c 47 8b 9b ab 88 47 5d 12 cd 63 |..>wD.G....G]..c| +00000260 17 c2 15 29 a3 cf 8c 08 e0 12 f6 36 ff ae a6 72 |...).......6...r| +00000270 3b 71 4d c7 a2 3b 38 63 be 77 43 67 fb 78 e6 a8 |;qM..;8c.wCg.x..| +00000280 1d aa 3a 42 f5 47 f8 d4 8d 83 f7 f0 93 ba 90 6d |..:B.G.........m| +00000290 25 65 e1 49 f5 3e fe e9 76 ea fb 23 38 6f b2 8f |%e.I.>..v..#8o..| +000002a0 3c 72 d3 fc 85 92 a0 d1 11 7c 6a 0b 0f 31 5d 8b |..| +000003c0 4a ba 5a 91 7b d1 b9 0e d1 98 5e 95 4d 1c 7f 77 |J.Z.{.....^.M..w| +000003d0 6e eb b9 8c 95 ce d4 04 5c 69 8f 7e 48 89 30 2b |n.......\i.~H.0+| +000003e0 71 27 a3 54 c2 b7 f2 ad 23 7b ee 64 88 a0 0d 75 |q'.T....#{.d...u| +000003f0 76 |v| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 02 11 1d fa f6 f0 5f |..............._| +00000010 36 d9 1a b8 03 4b b5 2e ba ca 43 ea 31 c2 08 05 |6....K....C.1...| +00000020 e5 a1 55 2e 93 82 3b d5 5a b3 ca fe 11 92 9a 30 |..U...;.Z......0| +00000030 7e d8 02 b4 95 29 8f 29 ba b5 34 22 97 99 bc a9 |~....).)..4"....| +00000040 43 1f 18 5c e2 26 7e 2e 5d ff 2c 68 86 82 7c da |C..\.&~.].,h..|.| +00000050 7e da c5 46 21 69 37 3b f5 65 a4 cd 70 ed e3 c8 |~..F!i7;.e..p...| +00000060 47 21 88 8d 45 3a 0f c9 1e 37 a9 0a 6e 2e 59 0e |G!..E:...7..n.Y.| +00000070 1b 6b 08 22 10 81 74 00 0c 15 6f c6 1e a0 2d 60 |.k."..t...o...-`| +00000080 b1 c6 ec 65 ff 91 16 1a e4 18 86 1b 43 04 dc b1 |...e........C...| +00000090 a0 f2 1d e8 4e 46 72 84 20 14 75 1e 72 52 1b 46 |....NFr. .u.rR.F| +000000a0 1f 8a ed 08 c8 e0 07 1b 6d e3 44 68 ec 52 74 d5 |........m.Dh.Rt.| +000000b0 8d 7f 41 96 b4 77 01 25 0c 1f aa 50 2f 8b d7 1a |..A..w.%...P/...| +000000c0 77 1b 24 01 0b 1f 0f c2 0f e1 00 db 0a 28 e9 c5 |w.$..........(..| +000000d0 a7 22 a2 fd c2 98 c5 69 51 91 d4 55 0f 52 da 33 |.".....iQ..U.R.3| +000000e0 47 f2 34 bd 06 bb 22 53 55 8c 6c e1 95 b5 0f b8 |G.4..."SU.l.....| +000000f0 e5 8a 64 51 50 47 5d ca 5b 1a 20 22 99 b2 d4 74 |..dQPG].[. "...t| +00000100 9e 6b 01 44 6b 7c 40 a0 e3 95 eb 96 53 c0 8d c0 |.k.Dk|@.....S...| +00000110 c1 e1 2b 21 04 f1 64 03 ba 0f d9 34 57 f2 2e 62 |..+!..d....4W..b| +00000120 5e f6 69 d6 86 3e f0 00 96 ca b7 ed 7d b4 1c 79 |^.i..>......}..y| +00000130 f3 ea f4 10 79 d2 6d 6e 49 6c e4 32 c1 81 da 9d |....y.mnIl.2....| +00000140 cc 59 ea 41 3f 1e 62 34 61 6b 0e a4 07 4f ef f7 |.Y.A?.b4ak...O..| +00000150 a3 31 ee 52 14 60 4c 06 5c 69 49 8e 6a ab e9 94 |.1.R.`L.\iI.j...| +00000160 bf cc a5 12 b7 94 10 87 2f cc d8 40 b1 f3 a9 27 |......../..@...'| +00000170 97 5c 7f 85 f9 14 dd e0 66 27 9e 3d f4 eb 75 ab |.\......f'.=..u.| +00000180 1d 1a c0 c3 72 af 6e 13 bb 24 ac fe f0 fb 47 d0 |....r.n..$....G.| +00000190 1d 79 37 70 86 d3 43 9b 64 8c d0 f5 2b a8 7a 77 |.y7p..C.d...+.zw| +000001a0 4a e7 92 a3 bf 1e db 22 5a 40 39 07 76 1c 71 de |J......"Z@9.v.q.| +000001b0 9c ff 75 b7 0d 6e 3e 14 69 8d 08 e5 f3 24 ae 6a |..u..n>.i....$.j| +000001c0 61 f3 dd a7 57 52 9e da f1 de aa 07 11 65 41 64 |a...WR.......eAd| +000001d0 61 57 23 71 47 aa 8e 47 9c 5f 99 84 90 2d 9a fd |aW#qG..G._...-..| +000001e0 5b 15 27 44 41 5c a0 41 87 05 8a 53 8f ed 93 22 |[.'DA\.A...S..."| +000001f0 50 15 b4 60 55 c7 78 20 b5 d8 dd 9d 5d 8c 69 bc |P..`U.x ....].i.| +00000200 74 da d6 a6 a6 86 fe 93 e1 48 48 f2 f0 36 93 86 |t........HH..6..| +00000210 d6 62 9d 09 3a 19 f7 9d 01 9b 87 85 17 03 03 00 |.b..:...........| +00000220 99 37 bf 65 e8 18 ef 10 d7 02 e2 73 3f 13 4a 6f |.7.e.......s?.Jo| +00000230 ea f0 e2 c8 a3 fc a4 3a d2 ea 96 2d 77 cb cc b3 |.......:...-w...| +00000240 1d 8a 77 4d 97 a6 e9 6e 6e b5 af 67 d1 e4 e6 be |..wM...nn..g....| +00000250 0b 05 b1 da 15 83 ca af 19 cf 57 60 05 16 47 bd |..........W`..G.| +00000260 ce 94 f9 bf 48 5c 2c 38 57 57 c3 39 9b 84 19 59 |....H\,8WW.9...Y| +00000270 db fc 09 06 29 4d e7 71 be d4 86 12 fa 8e 54 e8 |....)M.q......T.| +00000280 b0 7e 79 56 dc b2 7a 30 08 e2 8b c7 fa 46 ce 84 |.~yV..z0.....F..| +00000290 d3 3e 6d 1c 8d 4c 5e 76 c7 d2 1d 8b 85 5d be a3 |.>m..L^v.....]..| +000002a0 1b d8 92 72 6d b1 73 d9 b4 a7 14 00 58 80 79 a9 |...rm.s.....X.y.| +000002b0 75 55 96 af d9 d2 20 92 ef ca 17 03 03 00 35 b0 |uU.... .......5.| +000002c0 fe 3f 36 6e 82 b5 d3 7c e9 7b 75 d6 b1 4d f6 7b |.?6n...|.{u..M.{| +000002d0 d0 10 68 32 9a 7b 04 69 38 bf a2 42 1b 3d 14 75 |..h2.{.i8..B.=.u| +000002e0 31 00 90 d4 1b b1 bf 5b 76 65 50 42 21 60 75 30 |1......[vePB!`u0| +000002f0 f9 b8 ee 45 17 03 03 00 17 0b b8 78 9e a2 94 45 |...E.......x...E| +00000300 47 f4 8e af 08 d0 80 75 09 7b c6 44 45 82 19 30 |G......u.{.DE..0| +00000310 17 03 03 00 13 0e fb b9 24 58 7c ab 97 b3 6e 2e |........$X|...n.| +00000320 55 50 ff 05 5d 04 dc 72 |UP..]..r| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv13-ClientCert-RSA-RSAPSS b/libgo/go/crypto/tls/testdata/Client-TLSv13-ClientCert-RSA-RSAPSS new file mode 100644 index 00000000000..d2092baa8c6 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Client-TLSv13-ClientCert-RSA-RSAPSS @@ -0,0 +1,136 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 01 26 b2 48 f5 |....z...v...&.H.| +00000010 b7 cc 24 54 75 e5 9d cd 17 e1 02 e4 2d e1 32 28 |..$Tu.......-.2(| +00000020 4e 19 1e 6d 8a 1e 3f 0e 37 3c 5f 20 00 00 00 00 |N..m..?.7<_ ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 13 01 00 00 |................| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 67 |..+.....3.$... g| +00000060 35 32 50 33 37 9b 04 46 e4 7d 40 53 9d 3b c3 53 |52P37..F.}@S.;.S| +00000070 6d 16 d3 7a 95 ec 2b 09 37 ff 01 55 60 9c 53 14 |m..z..+.7..U`.S.| +00000080 03 03 00 01 01 17 03 03 00 17 b9 d8 da 19 0a e9 |................| +00000090 37 9a 76 b8 b1 e6 38 27 83 aa 0a 3a d5 cc 9a 25 |7.v...8'...:...%| +000000a0 1c 17 03 03 00 20 17 a1 70 92 5e 78 bf 9f e3 0c |..... ..p.^x....| +000000b0 cc e8 a3 6d c9 ba 77 e1 b5 0c 4b 1e 84 08 04 33 |...m..w...K....3| +000000c0 88 a3 05 4a e2 6a 17 03 03 02 7a f0 39 57 69 59 |...J.j....z.9WiY| +000000d0 dd 3d b1 be 1a 06 fc 7b 21 a1 7a cb b9 6e f6 ce |.=.....{!.z..n..| +000000e0 62 13 c8 b6 b3 85 b2 93 22 ab 5c f2 32 a2 af 32 |b.......".\.2..2| +000000f0 42 d1 c0 94 08 f4 ba 1f bb d9 16 f7 2b 40 8d dd |B...........+@..| +00000100 43 a2 80 0e 3a e4 ff 2d a3 18 59 b4 08 88 46 bf |C...:..-..Y...F.| +00000110 bb 46 58 82 b2 db 98 c0 9f 3a f8 c4 71 f0 87 ac |.FX......:..q...| +00000120 c5 ee 30 ea c4 b2 63 ee d0 cb 17 06 5c 80 19 3a |..0...c.....\..:| +00000130 bc f8 07 a1 e8 47 b4 b2 77 e0 14 ea 5d 16 c1 31 |.....G..w...]..1| +00000140 e6 34 bc 50 92 1a e8 9f e5 e9 0d 60 af 00 ad 9b |.4.P.......`....| +00000150 e3 10 bc 64 bd d4 c0 35 e8 26 67 df fb 3d d4 e8 |...d...5.&g..=..| +00000160 11 f2 24 13 d9 fb 68 5d 69 ce 23 98 07 e8 4a 4a |..$...h]i.#...JJ| +00000170 d9 d1 a7 b1 63 e1 01 08 ae e5 d1 57 1c e6 9a 5a |....c......W...Z| +00000180 ac 4a f8 f7 9a 33 51 d1 3b 68 42 1a 0d e0 08 f3 |.J...3Q.;hB.....| +00000190 a1 ea 83 5c 8f 95 7f ee bb 45 e3 72 72 2c a0 39 |...\.....E.rr,.9| +000001a0 86 f1 e0 58 6c 82 01 b0 3c 17 09 82 f3 d9 99 0c |...Xl...<.......| +000001b0 24 33 7d 50 b0 b7 84 3e 9b 91 a8 1f 91 02 95 aa |$3}P...>........| +000001c0 44 b6 de 0e 35 e1 b7 f6 ca 73 f8 6f f4 5a 21 db |D...5....s.o.Z!.| +000001d0 d6 f8 04 88 4e d6 04 7c 67 93 22 9a ff d0 0e 79 |....N..|g."....y| +000001e0 e6 cb b2 03 b9 f2 46 27 a3 1a 89 2e 8f 46 4f c5 |......F'.....FO.| +000001f0 4a ad 09 e7 79 38 a4 84 43 19 c9 1f 62 a0 5a 4a |J...y8..C...b.ZJ| +00000200 fa e4 98 14 e7 34 a6 3f 07 93 ab 6a fb 1c 3e 1f |.....4.?...j..>.| +00000210 a2 82 0a 42 43 d7 ef e7 aa fa 42 e0 be a1 dd 4e |...BC.....B....N| +00000220 2e 9e 49 da 81 da bc 5f 40 fa f8 00 99 19 d0 13 |..I...._@.......| +00000230 50 77 8b c5 69 f0 ec 7c bd 2d 9e c5 66 16 56 ca |Pw..i..|.-..f.V.| +00000240 bd 51 67 7b 87 5e 1f 4d 21 05 30 72 ac a8 ab 13 |.Qg{.^.M!.0r....| +00000250 12 dd 4c f7 e0 cc 95 c3 3e f0 94 95 40 ea c5 f1 |..L.....>...@...| +00000260 31 f9 53 32 40 64 5f c8 29 52 7a d6 22 5c 2d e8 |1.S2@d_.)Rz."\-.| +00000270 f9 eb f8 b9 e6 66 09 48 ad ed 73 6a 42 bc a8 7c |.....f.H..sjB..|| +00000280 d6 f9 62 45 25 f6 bf 8a 56 13 b4 50 cb 1b 5e 8b |..bE%...V..P..^.| +00000290 92 f3 9d 50 fc 7d 3c e4 b1 55 ae b2 3f 6a a8 a2 |...P.}<..U..?j..| +000002a0 f1 dd 83 9a 97 0e 3f 93 a9 6d 94 e5 cc a9 53 14 |......?..m....S.| +000002b0 24 44 80 28 a2 6a 21 57 07 63 96 78 3f 05 40 7d |$D.(.j!W.c.x?.@}| +000002c0 be 83 b2 b8 b3 0a 58 a7 50 29 dc bb b1 7f c6 c7 |......X.P)......| +000002d0 4b 5a ff 95 4a c8 50 0b 8e 44 ec 9b 0f 95 ac 8f |KZ..J.P..D......| +000002e0 f9 b3 19 d0 aa a6 67 f8 ce dc 67 34 0e c9 98 98 |......g...g4....| +000002f0 82 b1 54 4a a0 0e 02 d7 02 d3 36 06 4d 51 6f e4 |..TJ......6.MQo.| +00000300 f5 68 ff 4d 8f 00 94 a6 6b 6c 33 41 31 1a 9e 2c |.h.M....kl3A1..,| +00000310 f5 df 4a 43 b7 00 01 5b 6e 59 af 9c 9f bb c5 37 |..JC...[nY.....7| +00000320 22 32 35 25 bf 69 0a 9d 75 7e aa 19 b9 4e b1 17 |"25%.i..u~...N..| +00000330 cb f8 b5 8f 0f 81 9c df b1 ce a0 5b f2 ed df 20 |...........[... | +00000340 5a bd 8a 88 b1 17 03 03 00 99 15 09 f2 8d 63 c0 |Z.............c.| +00000350 f2 00 9f e8 1a d3 0f cc 35 0b ce eb 3c 45 87 59 |........5...>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 02 11 7e e6 cb d5 bf |...........~....| +00000010 e1 5f 0a a5 6f 08 47 a4 27 a0 a0 2d 8e 6b 56 c6 |._..o.G.'..-.kV.| +00000020 2e d4 7d 3d 83 f0 25 31 59 9d e5 61 a0 95 21 2e |..}=..%1Y..a..!.| +00000030 f8 39 8c 16 4b 6e d9 e0 19 23 05 b0 6c 89 2c f2 |.9..Kn...#..l.,.| +00000040 e2 60 fb 83 99 2b 33 37 38 b0 85 67 cf 91 5f 22 |.`...+378..g.._"| +00000050 32 8b 10 f6 0b 2b 0d 4a 18 32 e7 41 fc 07 58 54 |2....+.J.2.A..XT| +00000060 d1 e2 6e da bb f7 4a 45 60 34 02 01 95 5e b3 4f |..n...JE`4...^.O| +00000070 0a df 33 d6 07 06 fc 20 5a 97 2f b8 bf 66 23 40 |..3.... Z./..f#@| +00000080 32 24 0d f5 c8 a2 aa e4 6a 85 21 d5 a3 95 a8 3b |2$......j.!....;| +00000090 8f 6a 43 5c 96 64 80 ef 04 ed a4 10 2f e4 a8 8d |.jC\.d....../...| +000000a0 ff fb 77 53 28 30 cd ca df 8e 25 08 51 ee 56 b8 |..wS(0....%.Q.V.| +000000b0 3a ae 2f 27 a4 4a 71 9e 77 cc 70 af 62 d1 a7 2f |:./'.Jq.w.p.b../| +000000c0 2b 2f 98 2f e5 62 b5 3b 65 b6 2e a5 a5 19 1f c2 |+/./.b.;e.......| +000000d0 a9 ef d8 2a 95 25 fc 10 32 31 da 29 bf 7e 58 d0 |...*.%..21.).~X.| +000000e0 b5 2f 62 bf ed 57 c8 b4 55 85 29 66 07 52 6f 25 |./b..W..U.)f.Ro%| +000000f0 02 2b 98 22 a5 e8 41 50 de f5 e3 e9 ce 60 f2 af |.+."..AP.....`..| +00000100 b3 c8 80 f1 27 2a 04 7a 1f 3b 13 0f 76 ec 6a 74 |....'*.z.;..v.jt| +00000110 ad a9 8f e9 0d 67 9d 1c a3 54 b3 14 a0 5c 36 80 |.....g...T...\6.| +00000120 a7 be 7f 2b d1 89 c0 19 3f 25 c6 7a fd 04 44 c2 |...+....?%.z..D.| +00000130 18 75 a9 44 7b cc 20 2b f3 6a 9a e1 cc 4f aa 76 |.u.D{. +.j...O.v| +00000140 e2 0a 45 75 81 0d d7 72 a1 e7 b2 82 02 77 45 e9 |..Eu...r.....wE.| +00000150 f8 07 93 8b e5 79 c2 06 65 52 a5 0e 13 73 a7 f6 |.....y..eR...s..| +00000160 be 85 5c 00 af 90 ed 83 3f b4 53 68 cf 0b b9 a6 |..\.....?.Sh....| +00000170 06 43 3c 7a 15 6a b1 74 be af 70 3b fa 70 f3 4b |.C....{E.R$| +00000310 17 03 03 00 13 3b 43 97 33 75 c2 b6 9a f7 cd 96 |.....;C.3u......| +00000320 e3 67 b7 2d cf ac d8 0a |.g.-....| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv13-ECDSA b/libgo/go/crypto/tls/testdata/Client-TLSv13-ECDSA new file mode 100644 index 00000000000..96c8e8c1ee5 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Client-TLSv13-ECDSA @@ -0,0 +1,86 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 05 cf 30 74 87 |....z...v....0t.| +00000010 37 6e f2 12 86 19 bd ec 54 21 42 4c 2d 1a 71 4f |7n......T!BL-.qO| +00000020 fe de 90 2b a0 c4 73 d1 3e 57 40 20 00 00 00 00 |...+..s.>W@ ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 13 01 00 00 |................| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 16 |..+.....3.$... .| +00000060 4c 6f 4f d1 32 2e 2e b5 4c 48 29 0f cb 65 23 b2 |LoO.2...LH)..e#.| +00000070 ab 2e 41 d8 c4 70 30 88 4f a1 d9 bb 52 e8 35 14 |..A..p0.O...R.5.| +00000080 03 03 00 01 01 17 03 03 00 17 a7 86 3a 06 dc db |............:...| +00000090 c6 bc d5 8e 55 0f 93 b5 fc f4 d4 17 40 dc 3e d7 |....U.......@.>.| +000000a0 16 17 03 03 02 22 b3 07 3f ab 52 ac c4 0d 50 75 |....."..?.R...Pu| +000000b0 18 37 a5 f5 4b ba e7 e7 c0 30 3c b4 3f e4 11 2d |.7..K....0<.?..-| +000000c0 d1 33 07 a7 9d 41 47 61 40 ec db bb dd 7c 89 7b |.3...AGa@....|.{| +000000d0 e4 3e db 5a 30 c6 a3 74 7c 7a b1 53 d2 0a 48 65 |.>.Z0..t|z.S..He| +000000e0 2c f6 d9 ca b4 f4 88 d2 d8 7e a6 ce b0 30 c6 32 |,........~...0.2| +000000f0 36 fa 73 b2 0e 39 8e d5 af 41 ab 88 8c 3d d1 56 |6.s..9...A...=.V| +00000100 2e 7b 7d 93 77 c6 51 66 d6 ed 20 52 a9 b1 98 ae |.{}.w.Qf.. R....| +00000110 c9 04 a5 1a 97 36 91 b9 38 39 7c 7c 8c bb 0f 37 |.....6..89||...7| +00000120 e2 37 9c c0 49 fb a7 59 7d f2 0f 97 ee 15 9c e9 |.7..I..Y}.......| +00000130 5a 9b 6d fd 7e 36 61 fb 30 69 ea 2f e8 37 70 b0 |Z.m.~6a.0i./.7p.| +00000140 b5 65 1c 05 25 7a 32 36 6e 24 c9 e2 ca 6c c2 82 |.e..%z26n$...l..| +00000150 d0 5b 1f 85 ba 1b f0 b2 49 71 2a bd 8d ae 16 95 |.[......Iq*.....| +00000160 2c b9 ab ce f1 05 47 59 e5 65 02 57 34 85 df 26 |,.....GY.e.W4..&| +00000170 cf 97 94 29 09 4d aa a6 dd 18 ef 9d 15 38 10 90 |...).M.......8..| +00000180 ea a3 76 b7 25 c8 9c cd b6 1e 88 a6 4e b8 b1 34 |..v.%.......N..4| +00000190 70 1f 7b a1 83 e2 2e 3f d8 e8 f2 2e 74 f1 93 bc |p.{....?....t...| +000001a0 ee 80 8a c3 d0 e0 d2 7a 16 5a 97 a5 57 1c c6 37 |.......z.Z..W..7| +000001b0 ba 8a cd 07 8f ca 93 3a d7 57 82 be 69 1d 83 5e |.......:.W..i..^| +000001c0 62 0e 65 f3 7f 3b 28 8f 51 f0 96 da 55 4c f5 55 |b.e..;(.Q...UL.U| +000001d0 60 59 7c c4 61 1f 1d 50 38 09 e0 7b 90 ed b9 35 |`Y|.a..P8..{...5| +000001e0 4d 70 37 f8 c8 59 09 9e 77 02 27 cc 5a cc 7c 8d |Mp7..Y..w.'.Z.|.| +000001f0 a8 cc 83 9d 3d dc e1 85 89 98 65 e9 aa 16 f9 e9 |....=.....e.....| +00000200 85 f9 ec 6d 28 8d 20 4b 33 01 2f df fb 7d 6c 6e |...m(. K3./..}ln| +00000210 b8 28 d4 2e 72 1d af 66 15 1a ff ba bc 68 31 cb |.(..r..f.....h1.| +00000220 3e c8 62 d3 3e fd e8 ce 90 bc 30 36 31 e2 6d 47 |>.b.>.....061.mG| +00000230 06 d4 df ad e8 51 3d 61 b7 8f b6 16 d5 e1 81 ff |.....Q=a........| +00000240 c7 ad 99 04 e1 af d0 a8 37 5e 57 44 93 7b e0 6d |........7^WD.{.m| +00000250 c2 23 f2 b7 7d 14 41 c6 ab 17 c8 3b de 48 20 73 |.#..}.A....;.H s| +00000260 78 78 78 4a c4 1f ea 55 11 6e dc 55 48 5d 9b f1 |xxxJ...U.n.UH]..| +00000270 33 84 17 35 cc b9 8d d4 6e 86 87 f1 c3 ab 31 46 |3..5....n.....1F| +00000280 79 39 5f 41 19 40 7b 54 44 79 21 25 06 a1 ca 36 |y9_A.@{TDy!%...6| +00000290 e0 9f d6 70 7c 3f 9f 5c 17 29 cc a3 ed a2 cd 6f |...p|?.\.).....o| +000002a0 12 19 d9 89 aa a1 fa 51 53 98 9f 34 d2 75 12 22 |.......QS..4.u."| +000002b0 ea 63 85 3c 32 c8 cb e2 74 15 13 55 61 a1 80 1f |.c.<2...t..Ua...| +000002c0 85 5e 45 95 9c 92 4a 8d 17 03 03 00 a4 e8 50 d5 |.^E...J.......P.| +000002d0 71 f4 21 a6 79 63 11 6a 8e 5e 3e 5d 96 63 4e 42 |q.!.yc.j.^>].cNB| +000002e0 08 27 34 b7 4c 36 8a fe b1 ed f2 f1 3c 72 00 99 |.'4.L6.......D..h.S.qA| +000003a0 61 17 e3 da 92 ff 5a 8f 21 06 f5 |a.....Z.!..| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 00 35 a3 d4 49 e5 82 |..........5..I..| +00000010 8d 09 1b 33 8a 0d 9b 4f 8d a8 95 66 0e 50 e0 85 |...3...O...f.P..| +00000020 a7 0d f2 09 f6 05 44 f5 59 c3 48 92 9d 80 a7 db |......D.Y.H.....| +00000030 d0 18 7e 7b 5c fa 31 bf c5 94 71 60 cf 0c d1 c7 |..~{\.1...q`....| +00000040 17 03 03 00 17 f7 61 d6 c4 fa 7f 34 e7 cf cb b0 |......a....4....| +00000050 9f 5d 13 25 8c 75 6c 1a 87 91 44 84 17 03 03 00 |.].%.ul...D.....| +00000060 13 89 68 71 8d be 27 8e 31 f5 ca 7a 4e c5 b6 38 |..hq..'.1..zN..8| +00000070 b2 68 b8 0d |.h..| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv13-ExportKeyingMaterial b/libgo/go/crypto/tls/testdata/Client-TLSv13-ExportKeyingMaterial new file mode 100644 index 00000000000..a30a26249b7 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Client-TLSv13-ExportKeyingMaterial @@ -0,0 +1,90 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 fe a9 2f 00 0c |....z...v..../..| +00000010 0b 91 a0 86 1d 9b 21 19 35 a1 07 9e 36 1d d2 82 |......!.5...6...| +00000020 51 b7 d2 3e a6 42 ce 6f 86 e9 69 20 00 00 00 00 |Q..>.B.o..i ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 13 01 00 00 |................| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 20 |..+.....3.$... | +00000060 8c d2 dd d7 17 cc 15 f7 0b dc 75 48 d0 82 54 36 |..........uH..T6| +00000070 b0 f6 ae fe 29 7b 0d af 9f 06 4e 58 8c 66 10 14 |....){....NX.f..| +00000080 03 03 00 01 01 17 03 03 00 17 8c ef b2 76 05 ee |.............v..| +00000090 eb e8 55 a3 56 d6 4a b7 d7 10 8e f0 f9 7e 49 eb |..U.V.J......~I.| +000000a0 fd 17 03 03 02 6d c2 33 a8 17 70 1e 66 4c b8 32 |.....m.3..p.fL.2| +000000b0 99 41 79 b8 85 98 c8 f7 f4 c6 25 41 9b 30 ea f5 |.Ay.......%A.0..| +000000c0 24 6c ad 7c b6 c1 c7 a6 d5 2c 0b d8 78 e0 ec df |$l.|.....,..x...| +000000d0 bb 8d ea 0a ff ba c9 aa ec 24 05 63 2a ff 13 37 |.........$.c*..7| +000000e0 5e fe c1 7b 6e c0 dd e1 09 c1 87 33 fc 18 90 28 |^..{n......3...(| +000000f0 5b b2 ba 7e 69 06 dc 8e ac c4 ca 08 84 aa df 0c |[..~i...........| +00000100 2a a7 74 46 e7 c8 db 23 96 67 95 f4 79 9b 6e 3d |*.tF...#.g..y.n=| +00000110 94 fc 80 07 d9 e7 cf 0d 31 27 84 08 66 23 2d 05 |........1'..f#-.| +00000120 64 2f 63 27 5c e2 1c 2e f7 6f 99 4f 59 4c f4 3d |d/c'\....o.OYL.=| +00000130 cf a9 ff 32 f4 6a 7d b4 c4 11 01 9d f2 8a ce da |...2.j}.........| +00000140 21 51 b0 99 0c a8 a6 fa 09 b1 c4 cf a9 84 96 7d |!Q.............}| +00000150 aa 80 b4 b3 c7 ed 70 08 1b 50 b9 07 a5 2c a0 21 |......p..P...,.!| +00000160 da 97 a7 5f 35 d4 55 24 8b 2d 14 85 0d 63 10 7f |..._5.U$.-...c..| +00000170 0b 22 03 a5 e3 26 e4 2b ca c4 54 39 4d 52 41 8b |."...&.+..T9MRA.| +00000180 8e b0 60 2f 61 f5 7f d2 62 2c a3 f9 f2 46 08 76 |..`/a...b,...F.v| +00000190 37 92 d0 bc 6c 0e 75 a2 f5 c1 f4 b3 7d f9 83 8e |7...l.u.....}...| +000001a0 bd 30 4f 04 77 98 b7 d0 e9 a0 19 4c 61 c1 58 09 |.0O.w......La.X.| +000001b0 04 82 60 38 55 51 c1 94 46 40 a2 12 68 0a 83 7b |..`8UQ..F@..h..{| +000001c0 30 71 a3 08 83 f7 67 86 df 44 df ea 6d 56 65 25 |0q....g..D..mVe%| +000001d0 16 55 5d cd 8a f4 03 10 86 1d 5a fd d8 2e 23 7e |.U].......Z...#~| +000001e0 34 77 b7 af 4b 2c 8a 36 ad 07 a5 5a 3b 39 c8 90 |4w..K,.6...Z;9..| +000001f0 4b 77 60 81 2e ac 51 37 09 ac c0 e7 6b 18 a5 76 |Kw`...Q7....k..v| +00000200 52 91 62 95 6d 1c 9d 8e 6c 03 f5 12 cd 80 7f 40 |R.b.m...l......@| +00000210 4e f3 e6 7d d2 f1 3d 94 a7 16 ec fc 0c c9 72 b9 |N..}..=.......r.| +00000220 ee 33 bb 76 d0 6d 27 3d 58 cd ed 34 60 f4 bb 23 |.3.v.m'=X..4`..#| +00000230 49 a8 8d 94 7c 46 85 04 65 26 c2 5e 4f 22 f6 7d |I...|F..e&.^O".}| +00000240 46 ae 1b 63 eb 6b 43 c5 64 fa 9d 43 86 e5 29 8f |F..c.kC.d..C..).| +00000250 98 20 9e 21 b2 f3 32 c9 82 75 4d 97 5e cf dd cb |. .!..2..uM.^...| +00000260 1d 6b 6e fc 8f 61 86 a9 71 12 96 e3 18 42 d3 28 |.kn..a..q....B.(| +00000270 f9 86 7e ab 90 9b f6 5c c2 46 fb 93 e6 51 7d f5 |..~....\.F...Q}.| +00000280 8a b2 e9 c6 e1 70 62 fa 08 e1 91 0b ee 89 12 01 |.....pb.........| +00000290 ca dd 25 56 8f 2d 45 0d a5 47 26 f0 a2 4d f5 4b |..%V.-E..G&..M.K| +000002a0 8b dd 6f ab 0f f1 5b 60 9c b0 dc 88 24 df 1c 5b |..o...[`....$..[| +000002b0 a9 90 66 44 e1 e1 6b 96 b5 3f e2 69 76 a7 84 d6 |..fD..k..?.iv...| +000002c0 2b 68 b0 f5 8a ba e7 83 83 88 45 78 2d e0 a4 82 |+h........Ex-...| +000002d0 74 53 4a cf 14 84 fa 49 78 ce 3b 9a 24 66 00 a9 |tSJ....Ix.;.$f..| +000002e0 5b 0b 83 20 fb 20 a8 20 45 10 53 76 7d ee b2 d6 |[.. . . E.Sv}...| +000002f0 af 33 f9 29 d0 f7 16 7e d6 59 b0 4a 06 ac d4 7d |.3.)...~.Y.J...}| +00000300 84 1d 50 64 d0 f8 67 65 54 2f a3 2c 50 9e 93 43 |..Pd..geT/.,P..C| +00000310 58 59 67 17 03 03 00 99 62 ac 15 76 89 cb 8d 67 |XYg.....b..v...g| +00000320 25 75 a7 57 b6 65 8c 73 24 a6 71 ba c4 75 ad f8 |%u.W.e.s$.q..u..| +00000330 2a a6 94 12 c2 8d ca 7e 1a 75 e4 21 da cb 1e 77 |*......~.u.!...w| +00000340 69 d0 e1 4b 25 46 ce 99 1b e0 10 9d 12 d6 16 62 |i..K%F.........b| +00000350 f9 42 3b b8 3a 7b 3a 11 1f d7 04 fe 88 0b 62 ba |.B;.:{:.......b.| +00000360 a9 d6 51 c4 f5 be d9 92 e6 d6 05 94 9b f9 76 0d |..Q...........v.| +00000370 ca da 55 45 e4 fe a9 f3 dc d5 08 db 50 7c 4a 7c |..UE........P|J|| +00000380 f1 9c a7 5d e6 0d f9 cf 32 67 c0 66 a6 85 26 8b |...]....2g.f..&.| +00000390 57 f0 2c 5e b7 7e c1 cb 3d 6c 23 e2 18 3e c2 67 |W.,^.~..=l#..>.g| +000003a0 97 23 3f 86 f2 38 b5 a7 df 98 68 57 89 a3 e4 86 |.#?..8....hW....| +000003b0 d7 17 03 03 00 35 4a d4 e1 fb d1 39 57 90 d1 19 |.....5J....9W...| +000003c0 b9 f2 1b 0b 1a 0d 8f fb 4b f3 f1 f8 31 d2 ac 3b |........K...1..;| +000003d0 25 ad e7 da 8a 78 ab 2a d6 97 9b 66 88 6a db ef |%....x.*...f.j..| +000003e0 bf b6 ed b9 8a 39 72 8c ea 8f 0d |.....9r....| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 00 35 8c 85 73 71 98 |..........5..sq.| +00000010 40 37 77 e7 8c fd d1 f0 42 a8 97 f3 7c 68 f4 a7 |@7w.....B...|h..| +00000020 ac dc 7a ff 9b 2e f4 fe 2a c0 37 f9 56 a4 00 f5 |..z.....*.7.V...| +00000030 b1 40 34 53 89 48 9a a6 9d af a1 75 3f 34 53 fd |.@4S.H.....u?4S.| +00000040 17 03 03 00 17 92 cf 4a 20 2e 0c 2b 4a dc 86 2a |.......J ..+J..*| +00000050 75 cd 8f 73 b3 b3 4b 3b 3a e4 39 c3 17 03 03 00 |u..s..K;:.9.....| +00000060 13 83 08 42 b1 a8 95 2d a5 4c 8b e8 e8 35 d2 4c |...B...-.L...5.L| +00000070 23 8b 83 73 |#..s| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv13-HelloRetryRequest b/libgo/go/crypto/tls/testdata/Client-TLSv13-HelloRetryRequest new file mode 100644 index 00000000000..c06837e6da2 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Client-TLSv13-HelloRetryRequest @@ -0,0 +1,118 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 f4 01 00 00 f0 03 03 00 00 00 00 00 |................| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 75 00 05 00 05 01 00 00 00 00 00 0a 00 |...u............| +00000090 06 00 04 00 1d 00 17 00 0b 00 02 01 00 00 0d 00 |................| +000000a0 18 00 16 08 04 08 05 08 06 04 01 04 03 05 01 05 |................| +000000b0 03 06 01 06 03 02 01 02 03 ff 01 00 01 00 00 12 |................| +000000c0 00 00 00 2b 00 09 08 03 04 03 03 03 02 03 01 00 |...+............| +000000d0 33 00 26 00 24 00 1d 00 20 2f e5 7d a3 47 cd 62 |3.&.$... /.}.G.b| +000000e0 43 15 28 da ac 5f bb 29 07 30 ff f6 84 af c4 cf |C.(.._.).0......| +000000f0 c2 ed 90 99 5f 58 cb 3b 74 |...._X.;t| +>>> Flow 2 (server to client) +00000000 16 03 03 00 58 02 00 00 54 03 03 cf 21 ad 74 e5 |....X...T...!.t.| +00000010 9a 61 11 be 1d 8c 02 1e 65 b8 91 c2 a2 11 16 7a |.a......e......z| +00000020 bb 8c 5e 07 9e 09 e2 c8 a8 33 9c 20 00 00 00 00 |..^......3. ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 13 01 00 00 |................| +00000050 0c 00 2b 00 02 03 04 00 33 00 02 00 17 14 03 03 |..+.....3.......| +00000060 00 01 01 |...| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 16 03 03 01 15 01 00 01 11 03 |................| +00000010 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000030 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |. ..............| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000050 00 00 00 32 cc a8 cc a9 c0 2f c0 2b c0 30 c0 2c |...2...../.+.0.,| +00000060 c0 27 c0 13 c0 23 c0 09 c0 14 c0 0a 00 9c 00 9d |.'...#..........| +00000070 00 3c 00 2f 00 35 c0 12 00 0a 00 05 c0 11 c0 07 |.<./.5..........| +00000080 13 01 13 03 13 02 01 00 00 96 00 05 00 05 01 00 |................| +00000090 00 00 00 00 0a 00 06 00 04 00 1d 00 17 00 0b 00 |................| +000000a0 02 01 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 |................| +000000b0 01 04 03 05 01 05 03 06 01 06 03 02 01 02 03 ff |................| +000000c0 01 00 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 |.........+......| +000000d0 03 03 02 03 01 00 33 00 47 00 45 00 17 00 41 04 |......3.G.E...A.| +000000e0 1e 18 37 ef 0d 19 51 88 35 75 71 b5 e5 54 5b 12 |..7...Q.5uq..T[.| +000000f0 2e 8f 09 67 fd a7 24 20 3e b2 56 1c ce 97 28 5e |...g..$ >.V...(^| +00000100 f8 2b 2d 4f 9e f1 07 9f 6c 4b 5b 83 56 e2 32 42 |.+-O....lK[.V.2B| +00000110 e9 58 b6 d7 49 a6 b5 68 1a 41 03 56 6b dc 5a 89 |.X..I..h.A.Vk.Z.| +>>> Flow 4 (server to client) +00000000 16 03 03 00 9b 02 00 00 97 03 03 84 0c ed 20 38 |.............. 8| +00000010 61 6f 28 24 e6 70 28 71 1d 3e 38 fc e2 94 da fa |ao($.p(q.>8.....| +00000020 34 04 33 99 7a 18 e2 2a cc d1 67 20 00 00 00 00 |4.3.z..*..g ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 13 01 00 00 |................| +00000050 4f 00 2b 00 02 03 04 00 33 00 45 00 17 00 41 04 |O.+.....3.E...A.| +00000060 c8 a0 2b 32 b8 d5 a7 19 a7 5e 02 f6 f1 e9 ad 34 |..+2.....^.....4| +00000070 72 59 97 9e 05 a8 46 42 21 53 06 06 81 ea b6 f1 |rY....FB!S......| +00000080 ca b6 c6 a1 b6 2e c6 b7 93 17 8e bc 92 3f ac 9c |.............?..| +00000090 7a 74 d0 f9 b2 00 68 e3 f2 1d b6 b8 66 7b 8a cd |zt....h.....f{..| +000000a0 17 03 03 00 17 69 26 9c 4e 1d ec 10 61 5f 5b ef |.....i&.N...a_[.| +000000b0 d1 ad 5d 6a c5 0c d4 ef a8 c4 8c ee 17 03 03 02 |..]j............| +000000c0 6d c1 89 98 5a 1d 09 68 1a cd 6e 75 e6 d7 9c d4 |m...Z..h..nu....| +000000d0 fb c4 70 dd c4 0d 6b 28 09 9b 59 53 81 44 80 f3 |..p...k(..YS.D..| +000000e0 9f 16 7a 04 e2 15 8a 80 58 2d 98 1e aa 1c ac dc |..z.....X-......| +000000f0 f4 60 d9 b3 ff d3 da 56 4a d4 dc 99 89 78 7b 0e |.`.....VJ....x{.| +00000100 0a 76 93 08 9f c4 a6 22 de fe 9f ad 19 19 92 20 |.v....."....... | +00000110 f3 2f ba c7 dd bc 15 54 03 8a ed 2f 5f 75 32 f2 |./.....T.../_u2.| +00000120 2b cf 0e 08 2e c6 7e 6a 4c 3f 40 4e 89 3f c5 de |+.....~jL?@N.?..| +00000130 f0 0d a2 f3 e7 b6 48 ac a6 c8 e9 78 8b ee a3 f1 |......H....x....| +00000140 7c 87 ff 5d d0 9b 4c 98 bc fc 25 1b b8 56 00 22 ||..]..L...%..V."| +00000150 e0 7e 52 24 c6 12 a3 21 39 2a 63 77 da ff de 21 |.~R$...!9*cw...!| +00000160 98 85 1d 73 57 df 21 6c e3 f8 de 06 4b 50 39 0e |...sW.!l....KP9.| +00000170 7c c9 c9 bc 7b 16 1e d7 e3 b2 e4 9e d3 a9 94 35 ||...{..........5| +00000180 fb 65 22 b9 a9 f8 ef 13 5e 54 ef 4b d7 09 b8 72 |.e".....^T.K...r| +00000190 a9 a5 30 a2 67 d3 ef 6e aa 00 7c fb fa 63 28 e7 |..0.g..n..|..c(.| +000001a0 48 18 23 9b 7e 0f dd 8b b2 13 4f f6 d2 e4 75 42 |H.#.~.....O...uB| +000001b0 27 8a 42 0c 02 d8 1e 45 82 ef 1b 65 a7 eb b5 19 |'.B....E...e....| +000001c0 26 e5 42 06 80 80 d7 84 1e 05 c5 d5 f4 ea 53 51 |&.B...........SQ| +000001d0 78 ba f3 47 47 01 7b 25 ab 34 f7 fc 52 71 ff a4 |x..GG.{%.4..Rq..| +000001e0 d5 50 2b b5 7d e2 62 6a e9 8e 9c 8d b2 6f d4 78 |.P+.}.bj.....o.x| +000001f0 07 da 3a 9c 51 a3 d4 f5 24 a6 c0 c8 39 85 5f e1 |..:.Q...$...9._.| +00000200 03 b0 65 8b 50 c4 5d 03 f6 36 d2 3d f2 36 e3 c6 |..e.P.]..6.=.6..| +00000210 26 5b 82 d1 bd 54 e7 90 50 23 a8 e3 36 d9 d9 a0 |&[...T..P#..6...| +00000220 07 df 1b 47 17 9c 2a ab 56 07 d5 ea e5 c7 71 0b |...G..*.V.....q.| +00000230 fb 0c 4e f3 5b 0e 1d d6 75 df 21 50 c3 c9 18 5f |..N.[...u.!P..._| +00000240 55 e1 84 91 5c 9c 13 68 95 15 ab 0e db 17 b1 b7 |U...\..h........| +00000250 ee 3e 89 61 0f 6f 09 8b 6a 67 b5 bc 2a 61 cd 42 |.>.a.o..jg..*a.B| +00000260 79 9a 9c a4 99 98 0d 1c 43 2c bd 8d ee ac a9 2e |y.......C,......| +00000270 6d 73 cc b3 a0 b7 b7 8f 8f 09 32 8a 9f 00 87 5f |ms........2...._| +00000280 ae b4 0f 47 22 0b ec f4 e2 be 4e 6f 13 8d 30 97 |...G".....No..0.| +00000290 5a a8 f0 38 46 dd 1a 28 10 8b a8 4a e4 e6 fb 84 |Z..8F..(...J....| +000002a0 c4 85 15 11 3d 0b 08 f7 9d fd 45 6a 6b f5 bf d4 |....=.....Ejk...| +000002b0 2b 84 e5 20 5a a8 cb df 1f a3 af 96 17 df e8 b2 |+.. Z...........| +000002c0 61 f1 d0 d1 85 91 d2 02 a5 38 a0 5e 19 ba c4 2c |a........8.^...,| +000002d0 80 64 77 13 e1 27 86 d3 d4 17 07 86 c7 11 c0 38 |.dw..'.........8| +000002e0 11 69 89 48 39 7e b2 e5 d9 72 c1 b4 29 50 ab 9b |.i.H9~...r..)P..| +000002f0 49 cd 74 b9 4a ce c5 67 46 47 73 81 b1 a1 82 8f |I.t.J..gFGs.....| +00000300 76 ee 81 28 70 66 da 94 2a 8e 20 b0 ab 2e e4 d4 |v..(pf..*. .....| +00000310 ef 26 8b 31 07 85 b6 b0 c2 5b 05 0a 32 2e e7 73 |.&.1.....[..2..s| +00000320 41 e7 a1 97 f7 5e 2f 9c 73 25 c1 f7 77 12 17 03 |A....^/.s%..w...| +00000330 03 00 99 92 0a 8c 17 e9 0d 77 a3 6f ab 1a 4f dd |.........w.o..O.| +00000340 de 1d 0f 72 39 5c 8f 9f 80 00 b2 e5 fe 28 79 a2 |...r9\.......(y.| +00000350 16 21 e3 a2 25 90 c6 cd f2 28 6d b6 08 5b 51 0d |.!..%....(m..[Q.| +00000360 58 22 a6 11 ac 29 5d 54 aa 05 35 28 87 da 54 39 |X"...)]T..5(..T9| +00000370 b6 7f ef 94 3e 1c 80 59 f1 12 06 77 66 20 a1 00 |....>..Y...wf ..| +00000380 82 ed 0b 7a 1f 5d 55 5e 31 11 85 93 69 94 2a 44 |...z.]U^1...i.*D| +00000390 96 1c 39 7b 5b 7f 5b a6 05 6a 6d 52 79 20 52 f7 |..9{[.[..jmRy R.| +000003a0 1f 79 50 36 f1 a9 00 aa 9d 46 57 fd 00 70 7b 4a |.yP6.....FW..p{J| +000003b0 7a 14 75 20 91 83 3e 1b 47 2a 90 c9 09 71 b6 95 |z.u ..>.G*...q..| +000003c0 48 53 2a 3f 22 5f 9c 46 d6 12 27 b1 17 03 03 00 |HS*?"_.F..'.....| +000003d0 35 98 15 74 4c d4 52 cf 0c 78 88 8f 82 9b c5 23 |5..tL.R..x.....#| +000003e0 14 02 71 da 63 6c 28 36 aa 91 a0 14 74 0a 47 59 |..q.cl(6....t.GY| +000003f0 ea 6f b1 46 1e a7 c4 5f 76 33 96 ae 82 eb 4b b4 |.o.F..._v3....K.| +00000400 88 6a ce 37 db fd |.j.7..| +>>> Flow 5 (client to server) +00000000 17 03 03 00 35 7b c5 88 f4 a0 83 1e 6e 67 e6 05 |....5{......ng..| +00000010 05 fa b4 40 e3 7f fc f8 bc 50 11 76 93 22 92 5f |...@.....P.v."._| +00000020 9a 67 e5 65 a1 a3 af bc ae 3b c7 aa b3 fb 99 f0 |.g.e.....;......| +00000030 2a c2 65 aa 4b bd 91 20 17 22 17 03 03 00 17 1d |*.e.K.. ."......| +00000040 4f a0 06 07 65 2e 10 e7 15 c9 56 f3 2c 18 10 51 |O...e.....V.,..Q| +00000050 c7 d5 ac 09 e6 93 17 03 03 00 13 34 b2 1d 5e da |...........4..^.| +00000060 55 b2 dd 2b c1 e0 ac 65 7e a2 52 f8 a4 5b |U..+...e~.R..[| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv13-KeyUpdate b/libgo/go/crypto/tls/testdata/Client-TLSv13-KeyUpdate new file mode 100644 index 00000000000..a613b78da58 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Client-TLSv13-KeyUpdate @@ -0,0 +1,102 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 f8 01 00 00 f4 03 03 00 00 00 00 00 |................| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 79 00 05 00 05 01 00 00 00 00 00 0a 00 |...y............| +00000090 0a 00 08 00 1d 00 17 00 18 00 19 00 0b 00 02 01 |................| +000000a0 00 00 0d 00 18 00 16 08 04 08 05 08 06 04 01 04 |................| +000000b0 03 05 01 05 03 06 01 06 03 02 01 02 03 ff 01 00 |................| +000000c0 01 00 00 12 00 00 00 2b 00 09 08 03 04 03 03 03 |.......+........| +000000d0 02 03 01 00 33 00 26 00 24 00 1d 00 20 2f e5 7d |....3.&.$... /.}| +000000e0 a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 ff f6 |.G.bC.(.._.).0..| +000000f0 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 |........_X.;t| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 59 2c d4 a8 e3 |....z...v..Y,...| +00000010 ec 72 f1 2f 9b ff af 2f ab 13 fe 21 80 a5 c1 71 |.r./.../...!...q| +00000020 02 55 9b 06 67 0f 7b dd 27 32 66 20 00 00 00 00 |.U..g.{.'2f ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 13 01 00 00 |................| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 3e |..+.....3.$... >| +00000060 13 b1 51 26 01 be c0 e5 85 a7 18 aa b5 83 21 6e |..Q&..........!n| +00000070 85 48 1b ea 4c 99 13 ba b8 de 07 30 f4 9f 5b 14 |.H..L......0..[.| +00000080 03 03 00 01 01 17 03 03 00 17 9f 78 1e 98 cb 85 |...........x....| +00000090 0e 65 2b e5 20 c1 63 c1 b7 49 49 76 e3 90 0c c9 |.e+. .c..IIv....| +000000a0 b6 17 03 03 02 6d 8f 91 03 6b b7 0d 7d 79 4c 16 |.....m...k..}yL.| +000000b0 fc cb 62 11 62 12 2a 52 9a 19 7c b6 1c fc 31 d2 |..b.b.*R..|...1.| +000000c0 11 4d b4 e9 23 3c 58 3e 87 f1 9e e0 27 04 a2 fb |.M..#....'...| +000000d0 21 9a 82 59 3b ea 6b 29 ec a8 0e 1c 58 99 46 9b |!..Y;.k)....X.F.| +000000e0 2b c2 90 10 5d bc df d1 a0 71 00 8f 9b 90 10 49 |+...]....q.....I| +000000f0 97 1d b5 d2 8f e2 a6 78 b1 2a e9 2d 8d 13 38 2f |.......x.*.-..8/| +00000100 db 56 bb cd 0f 08 69 f7 04 de 53 ec 3c 90 97 ca |.V....i...S.<...| +00000110 9f 63 d0 96 7f 3a 98 98 77 21 c8 ee 0f 5c 4e 97 |.c...:..w!...\N.| +00000120 3c 72 88 13 48 82 1b 70 b2 83 b4 95 03 81 05 ef |:.....U3| +00000300 76 5f ce 26 f6 53 d0 23 3a e2 78 0f 0a fe 2f 89 |v_.&.S.#:.x.../.| +00000310 43 27 b3 17 03 03 00 99 61 da d2 f7 6d 84 f0 08 |C'......a...m...| +00000320 b0 89 f8 a4 1f b4 99 6a cf d1 08 d6 a7 03 fa f9 |.......j........| +00000330 db c2 8a 9a 74 62 0c 93 7d 7c 22 c0 2d 84 5d 96 |....tb..}|".-.].| +00000340 f8 66 05 6c c5 ab b6 5b 2d f5 10 27 c6 c3 81 13 |.f.l...[-..'....| +00000350 94 3c af 56 ca 37 ca a6 24 86 34 54 f2 60 e2 51 |.<.V.7..$.4T.`.Q| +00000360 67 5e dd 81 7f 87 81 84 15 cf b9 92 01 9c fc 90 |g^..............| +00000370 18 21 ad 6a 4a b8 4f fe 03 c8 83 08 fd 55 5a 4d |.!.jJ.O......UZM| +00000380 75 b7 e3 2d ff 9d 0a e5 61 b2 e9 82 bf 65 6a 05 |u..-....a....ej.| +00000390 d1 8d 36 82 07 8d a0 95 78 26 9e 3a c7 99 27 3f |..6.....x&.:..'?| +000003a0 54 0e a3 dd 9a 93 a6 6c 9b a3 14 46 bb cc f8 70 |T......l...F...p| +000003b0 f1 17 03 03 00 35 34 03 e6 68 dc f1 3e ae 38 69 |.....54..h..>.8i| +000003c0 87 ce 72 92 13 4a c0 4a 0d 22 28 3a 9f df 7d d5 |..r..J.J."(:..}.| +000003d0 de 5f 3c 0d 49 be b7 63 85 67 90 be 68 dc e7 88 |._<.I..c.g..h...| +000003e0 e3 58 90 43 99 0a db ee ad be 6d |.X.C......m| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 00 35 ea a5 10 9a 0a |..........5.....| +00000010 57 40 9c b7 f8 e6 01 28 9e 3f ae ce ec 73 7f 2e |W@.....(.?...s..| +00000020 84 8e a9 e3 cb 03 3b b3 1b 98 3c 09 5b 23 c2 10 |......;...<.[#..| +00000030 c1 18 47 74 a8 a5 0e 33 93 5f 83 e9 e6 aa ed f5 |..Gt...3._......| +00000040 17 03 03 00 17 80 72 fb 00 25 ff 83 4c df 43 66 |......r..%..L.Cf| +00000050 cd e5 64 2e 78 44 e4 b7 58 61 fe 01 |..d.xD..Xa..| +>>> Flow 4 (server to client) +00000000 17 03 03 00 16 54 f1 cd 5a 87 da 6a e7 a6 e5 00 |.....T..Z..j....| +00000010 60 f8 cd 6b af db 1b 85 3b 40 23 |`..k....;@#| +>>> Flow 5 (client to server) +00000000 17 03 03 00 16 b2 74 fa c8 c6 6e 4f 62 4f ea 02 |......t...nObO..| +00000010 4d 10 78 f1 b3 4a e2 e5 1d 8f 33 |M.x..J....3| +>>> Flow 6 (server to client) +00000000 17 03 03 00 1a ba bc 59 f7 ad b4 77 2f bc 3d 60 |.......Y...w/.=`| +00000010 5c bd 6c 6e 37 86 75 bd e1 41 b9 07 f6 87 47 |\.ln7.u..A....G| +>>> Flow 7 (client to server) +00000000 17 03 03 00 1d 7d 12 1b b2 a7 b7 ae 37 fb 2d 71 |.....}......7.-q| +00000010 98 ec c2 f0 7f 16 e9 b9 f9 49 05 e2 b2 c3 c6 ec |.........I......| +00000020 38 32 17 03 03 00 13 9f c4 f4 f7 e9 c9 5f e2 70 |82..........._.p| +00000030 b4 33 9f 35 f3 2a b1 cd 01 d5 |.3.5.*....| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv13-P256-ECDHE b/libgo/go/crypto/tls/testdata/Client-TLSv13-P256-ECDHE new file mode 100644 index 00000000000..20cafb45b61 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Client-TLSv13-P256-ECDHE @@ -0,0 +1,94 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 01 13 01 00 01 0f 03 03 00 00 00 00 00 |................| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 94 00 05 00 05 01 00 00 00 00 00 0a 00 |................| +00000090 04 00 02 00 17 00 0b 00 02 01 00 00 0d 00 18 00 |................| +000000a0 16 08 04 08 05 08 06 04 01 04 03 05 01 05 03 06 |................| +000000b0 01 06 03 02 01 02 03 ff 01 00 01 00 00 12 00 00 |................| +000000c0 00 2b 00 09 08 03 04 03 03 03 02 03 01 00 33 00 |.+............3.| +000000d0 47 00 45 00 17 00 41 04 1e 18 37 ef 0d 19 51 88 |G.E...A...7...Q.| +000000e0 35 75 71 b5 e5 54 5b 12 2e 8f 09 67 fd a7 24 20 |5uq..T[....g..$ | +000000f0 3e b2 56 1c ce 97 28 5e f8 2b 2d 4f 9e f1 07 9f |>.V...(^.+-O....| +00000100 6c 4b 5b 83 56 e2 32 42 e9 58 b6 d7 49 a6 b5 68 |lK[.V.2B.X..I..h| +00000110 1a 41 03 56 6b dc 5a 89 |.A.Vk.Z.| +>>> Flow 2 (server to client) +00000000 16 03 03 00 9b 02 00 00 97 03 03 42 8e 0f 88 bb |...........B....| +00000010 99 f5 32 74 2a 0a 66 98 59 da 0c 3f df 23 8c 72 |..2t*.f.Y..?.#.r| +00000020 a7 ba f5 52 78 88 22 a0 db 3d cc 20 00 00 00 00 |...Rx."..=. ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 13 01 00 00 |................| +00000050 4f 00 2b 00 02 03 04 00 33 00 45 00 17 00 41 04 |O.+.....3.E...A.| +00000060 42 55 a6 b0 22 e7 51 7f ce 3c 15 f5 ef db 69 89 |BU..".Q..<....i.| +00000070 80 e1 5a 54 37 d9 df 4c bd 83 72 43 5f b5 bf 28 |..ZT7..L..rC_..(| +00000080 21 41 0f 4c 71 a4 42 ae 90 20 8b 2e 95 88 1d a0 |!A.Lq.B.. ......| +00000090 4d 50 6f 05 3d 71 26 e2 ca 12 2b bf 5b 18 b6 16 |MPo.=q&...+.[...| +000000a0 14 03 03 00 01 01 17 03 03 00 17 fd a0 c1 f6 d6 |................| +000000b0 f5 7c 39 25 4c 67 ad fa 10 18 d1 90 b2 61 90 3f |.|9%Lg.......a.?| +000000c0 71 49 17 03 03 02 6d 28 31 4d 75 d8 9d 93 a0 ee |qI....m(1Mu.....| +000000d0 ad ef a3 dc 14 12 a8 af 17 b4 46 20 50 96 26 54 |..........F P.&T| +000000e0 78 4d d7 4f 08 e9 93 61 b6 53 da b2 e9 9c 67 54 |xM.O...a.S....gT| +000000f0 e8 87 0d 64 0c cc 14 cd d0 b5 df 1e d7 25 58 ce |...d.........%X.| +00000100 0b c9 a6 dc 38 9d 00 85 ce c3 01 29 3a 74 26 d4 |....8......):t&.| +00000110 71 db c0 92 2b 95 d2 00 d0 38 8d 85 f5 22 05 c7 |q...+....8..."..| +00000120 3b d4 d5 c7 a6 36 0d 3e 39 2c d5 0f 0d 84 80 22 |;....6.>9,....."| +00000130 e5 f0 71 24 0d 93 68 21 db 51 e2 24 84 0c 30 2a |..q$..h!.Q.$..0*| +00000140 87 e5 b5 a2 b6 b8 9c 53 a1 bb 76 7d e8 10 e4 59 |.......S..v}...Y| +00000150 f2 be 69 6f 39 75 e2 ed 70 f3 f0 fd 70 2f ce 2a |..io9u..p...p/.*| +00000160 24 d0 05 3e 13 ee 76 f5 6b b8 ed ee 34 40 cc e5 |$..>..v.k...4@..| +00000170 11 58 62 22 99 04 3c 22 43 24 46 78 66 a0 04 11 |.Xb"..<"C$Fxf...| +00000180 86 b4 b7 87 71 ff f9 ed 6f 4f 7e 9f 2d 08 ed ae |....q...oO~.-...| +00000190 cc 03 29 6f 34 9b 18 2c ae d7 d5 e9 03 51 5d 37 |..)o4..,.....Q]7| +000001a0 d5 ac 93 07 2a 78 8f 7d b0 85 ae 19 37 a5 e8 d6 |....*x.}....7...| +000001b0 e4 b3 01 14 04 fc ab 36 d6 5e 31 45 47 14 f8 d9 |.......6.^1EG...| +000001c0 c8 a0 a0 49 56 74 68 5b b4 20 f7 e0 54 34 41 45 |...IVth[. ..T4AE| +000001d0 c0 5e ed a6 1c 84 d8 3a c7 2d 17 5a 4c bd 7d d1 |.^.....:.-.ZL.}.| +000001e0 a8 9e 5e d1 31 b1 6b 48 64 11 d8 89 01 9f ed 12 |..^.1.kHd.......| +000001f0 60 73 66 80 38 13 23 8d 31 ca 94 06 22 e9 45 ff |`sf.8.#.1...".E.| +00000200 d6 a3 0b 7c 30 c8 d7 30 4f c0 62 84 ac f9 b0 3d |...|0..0O.b....=| +00000210 68 76 d2 02 27 d9 1e 7e da ae 85 47 e1 08 0f 4f |hv..'..~...G...O| +00000220 74 a9 fc ca f2 38 68 6d c6 f3 3c e9 99 c5 48 79 |t....8hm..<...Hy| +00000230 88 37 b6 5d 4f f8 8b 53 41 9a 39 a7 2f 8e 39 81 |.7.]O..SA.9./.9.| +00000240 75 cf 70 2f 28 4c 10 32 73 9b 6e 4f 58 1f ae 28 |u.p/(L.2s.nOX..(| +00000250 3f 6c 3d 60 49 48 15 10 2a af ea d7 ce 55 07 47 |?l=`IH..*....U.G| +00000260 90 3a c8 0d 6a 4a 88 c2 9c d3 08 99 02 c9 88 be |.:..jJ..........| +00000270 91 5b c9 41 46 cf b1 5e fe 28 1e 97 8a 44 5a e0 |.[.AF..^.(...DZ.| +00000280 d0 a3 a9 ea f7 51 27 87 b3 0f fd dc 7d d4 96 4a |.....Q'.....}..J| +00000290 39 2c 0a 58 9c 23 0d 41 89 42 5e fd 19 ab 19 a8 |9,.X.#.A.B^.....| +000002a0 e4 70 3f ef c6 54 fb ed 80 9b 68 d6 d9 6f 21 53 |.p?..T....h..o!S| +000002b0 89 40 06 c9 0c 56 40 8c 36 61 91 18 81 ce 76 5d |.@...V@.6a....v]| +000002c0 78 f5 01 9f 2e de 3e 89 61 d7 81 a5 f9 32 24 44 |x.....>.a....2$D| +000002d0 6b fa 0b 9c 8b a4 f6 df a1 2a 31 91 b2 40 cd 7e |k........*1..@.~| +000002e0 6c d1 75 c9 56 48 e3 36 eb 13 00 cf ea d5 d9 98 |l.u.VH.6........| +000002f0 71 4c d2 af 06 e5 f1 f7 8f ce 79 7a 93 4c 1c 99 |qL........yz.L..| +00000300 61 8f 93 76 de 1d ca ff 1b e5 c3 8f 99 ac 65 92 |a..v..........e.| +00000310 74 a9 d6 fd 9d bd a7 da f6 d5 94 7f 66 87 e1 7e |t...........f..~| +00000320 16 43 04 8a 9f 00 cc 89 1b 33 32 a2 26 e1 62 76 |.C.......32.&.bv| +00000330 30 07 5d 0e 17 03 03 00 99 22 4f 7b 1f 73 59 91 |0.]......"O{.sY.| +00000340 1e dc 62 ce 8b 32 7f 7d 99 b0 71 7a fb 79 09 5a |..b..2.}..qz.y.Z| +00000350 2e 0c b4 f2 00 13 5d ae 7d ae 80 1c 5f 8a a1 99 |......].}..._...| +00000360 c9 20 39 a9 66 36 f0 2b de 2e 1d ef 1f e1 ce 34 |. 9.f6.+.......4| +00000370 9a db f7 7b 17 52 91 ac 76 ff 22 63 8c 07 dd 7d |...{.R..v."c...}| +00000380 72 eb 9b 34 0f e9 a4 43 6b e3 fa e1 00 e3 dc 65 |r..4...Ck......e| +00000390 7a 49 bf a6 cd 97 4f e9 49 ae 91 4c be c3 3a b1 |zI....O.I..L..:.| +000003a0 a1 ee 09 55 ce 87 e7 59 58 24 cb 43 16 c9 5f d6 |...U...YX$.C.._.| +000003b0 11 32 83 47 dd 14 8d 11 c9 29 ac b8 57 7d 1e 07 |.2.G.....)..W}..| +000003c0 34 cc 79 13 22 00 62 39 4c 7e 5f 89 dc 94 b9 ca |4.y.".b9L~_.....| +000003d0 d9 ef 17 03 03 00 35 6a 70 22 84 c0 ed d6 70 b1 |......5jp"....p.| +000003e0 d5 8c 29 f9 0d 03 69 d1 0e 4c 01 79 1b 97 2f 24 |..)...i..L.y../$| +000003f0 45 08 25 4e 56 58 7c d7 d1 79 67 73 7c e2 30 54 |E.%NVX|..ygs|.0T| +00000400 54 2f c0 e2 28 e3 5a 87 47 0f f9 33 |T/..(.Z.G..3| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 00 35 f1 7c 55 b2 e9 |..........5.|U..| +00000010 01 cd 57 d5 17 17 30 51 43 74 46 00 83 c7 d2 73 |..W...0QCtF....s| +00000020 2b ff 57 45 5c 13 d9 9e ec 56 c5 f1 d2 26 00 76 |+.WE\....V...&.v| +00000030 75 5c f0 3c 80 39 74 4e 38 72 35 39 a3 29 4d ff |u\.<.9tN8r59.)M.| +00000040 17 03 03 00 17 43 aa f1 73 de 22 92 8c 54 2c 3f |.....C..s."..T,?| +00000050 c6 f2 f1 07 27 b2 f6 0e 54 79 4d 05 17 03 03 00 |....'...TyM.....| +00000060 13 a5 64 ef ae 3f f0 52 08 71 9e 24 dc ea f1 50 |..d..?.R.q.$...P| +00000070 b5 27 20 54 |.' T| diff --git a/libgo/go/crypto/tls/testdata/Client-TLSv13-X25519-ECDHE b/libgo/go/crypto/tls/testdata/Client-TLSv13-X25519-ECDHE new file mode 100644 index 00000000000..7de7d279b2b --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Client-TLSv13-X25519-ECDHE @@ -0,0 +1,90 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 f2 01 00 00 ee 03 03 00 00 00 00 00 |................| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 |........... ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 32 cc a8 |.............2..| +00000050 cc a9 c0 2f c0 2b c0 30 c0 2c c0 27 c0 13 c0 23 |.../.+.0.,.'...#| +00000060 c0 09 c0 14 c0 0a 00 9c 00 9d 00 3c 00 2f 00 35 |...........<./.5| +00000070 c0 12 00 0a 00 05 c0 11 c0 07 13 01 13 03 13 02 |................| +00000080 01 00 00 73 00 05 00 05 01 00 00 00 00 00 0a 00 |...s............| +00000090 04 00 02 00 1d 00 0b 00 02 01 00 00 0d 00 18 00 |................| +000000a0 16 08 04 08 05 08 06 04 01 04 03 05 01 05 03 06 |................| +000000b0 01 06 03 02 01 02 03 ff 01 00 01 00 00 12 00 00 |................| +000000c0 00 2b 00 09 08 03 04 03 03 03 02 03 01 00 33 00 |.+............3.| +000000d0 26 00 24 00 1d 00 20 2f e5 7d a3 47 cd 62 43 15 |&.$... /.}.G.bC.| +000000e0 28 da ac 5f bb 29 07 30 ff f6 84 af c4 cf c2 ed |(.._.).0........| +000000f0 90 99 5f 58 cb 3b 74 |.._X.;t| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 cd c7 29 34 e2 |....z...v....)4.| +00000010 96 86 e5 32 80 01 ea b9 3f d1 c5 90 da 7d 6e b9 |...2....?....}n.| +00000020 6f c2 f3 de 0f 16 7c c6 be 22 9f 20 00 00 00 00 |o.....|..". ....| +00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000040 00 00 00 00 00 00 00 00 00 00 00 00 13 01 00 00 |................| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 71 |..+.....3.$... q| +00000060 a3 1e 19 38 17 d7 fb c4 d7 c0 c5 0b 1a 4f 43 b8 |...8.........OC.| +00000070 36 73 5b ba ac 71 44 76 e5 18 a8 5f f0 e9 53 14 |6s[..qDv..._..S.| +00000080 03 03 00 01 01 17 03 03 00 17 2b d0 f2 01 36 99 |..........+...6.| +00000090 3c fe 38 af 22 1c 4f ec 1f 31 a2 48 31 a4 b9 83 |<.8.".O..1.H1...| +000000a0 74 17 03 03 02 6d 87 69 ac 88 28 88 6e 62 c8 96 |t....m.i..(.nb..| +000000b0 b9 32 1a 3d f6 a3 10 70 06 bd a6 3b d1 e4 a6 3a |.2.=...p...;...:| +000000c0 be e0 93 61 27 d4 bf 1f b0 17 f0 19 b3 30 e1 5e |...a'........0.^| +000000d0 94 18 13 78 9b 9d d5 16 b2 c7 8a 21 54 c9 f0 31 |...x.......!T..1| +000000e0 09 5b 6c 7f 22 79 9f 33 66 b7 e7 ea d4 11 63 5f |.[l."y.3f.....c_| +000000f0 05 21 e2 1a 66 96 ac 62 10 be 4b 51 73 df 29 9e |.!..f..b..KQs.).| +00000100 71 92 1a cb d2 d3 99 0c a7 35 7d 12 b4 44 d7 96 |q........5}..D..| +00000110 2b 29 9d 49 70 11 8c f8 5c 80 a4 98 56 21 66 2b |+).Ip...\...V!f+| +00000120 ac 72 1c 2e 86 e3 62 d2 e5 f1 7f 58 97 7b ac 85 |.r....b....X.{..| +00000130 a8 c1 99 62 3b 8c 7f 47 95 09 e7 dc 7d 31 ed d2 |...b;..G....}1..| +00000140 9b f8 71 fb 15 9c 80 1c cc 28 dd 4d ef 95 89 92 |..q......(.M....| +00000150 1f e8 c0 c3 78 b9 8f 92 88 e9 57 f6 2b 30 90 f1 |....x.....W.+0..| +00000160 27 b8 d8 65 0e 12 6d 51 9c e8 f2 5d b0 58 90 88 |'..e..mQ...].X..| +00000170 22 e3 fb 0e 2e 1f 6b 6b a2 8e 52 2c a7 2a 32 03 |".....kk..R,.*2.| +00000180 a4 e9 fc b7 e4 ec f5 73 37 fc bb d3 62 68 90 3d |.......s7...bh.=| +00000190 69 02 65 d5 35 6c 9b 89 68 c2 93 df 84 e3 f0 5f |i.e.5l..h......_| +000001a0 35 c7 05 d1 4d 60 93 b9 1d 5e 39 78 fd ed 85 f7 |5...M`...^9x....| +000001b0 1b 82 f6 cc 0a 02 5e f6 e0 7a 78 55 3a 12 e3 b3 |......^..zxU:...| +000001c0 45 ab 7e f0 12 2e 28 11 fd 73 7e 05 ef e1 c2 a0 |E.~...(..s~.....| +000001d0 45 ac 2e 3c 0b 00 69 ad 01 78 c7 2b 15 4e 6b eb |E..<..i..x.+.Nk.| +000001e0 65 3d d8 c2 4b e6 9d 73 35 62 4f 58 d1 ec 7f 8d |e=..K..s5bOX....| +000001f0 6e 56 66 06 cf 90 56 09 70 53 bd ed 16 ff c1 14 |nVf...V.pS......| +00000200 7f 1b 13 80 73 d2 7d f3 85 99 bd f2 f8 16 65 00 |....s.}.......e.| +00000210 97 51 12 64 7a 34 20 b1 1a d9 fb 5c 38 e6 b7 ae |.Q.dz4 ....\8...| +00000220 99 34 6d 1a 87 30 09 96 13 04 f9 4d 51 b7 f5 76 |.4m..0.....MQ..v| +00000230 30 ac 18 05 ba e4 0e 3d 28 6e 09 5e ec 52 18 d4 |0......=(n.^.R..| +00000240 1e da d3 7e b4 16 ff 76 4e 31 10 42 5a 7e 75 ea |...~...vN1.BZ~u.| +00000250 86 82 4e ad 7a 11 1d a8 6b ab 5c 7d bd 7b 07 b8 |..N.z...k.\}.{..| +00000260 aa bb 13 57 4a 24 d1 92 1d bb b9 7b 46 8b 7e 69 |...WJ$.....{F.~i| +00000270 9c a5 ea a6 9d 20 42 b1 92 4f b6 0e 48 8a 29 be |..... B..O..H.).| +00000280 67 19 b8 5b 27 7f fd c0 7e b1 01 e0 19 42 bb 19 |g..['...~....B..| +00000290 c4 91 b0 52 3e 0b 4c a6 2b 03 ff e3 e2 b9 d7 54 |...R>.L.+......T| +000002a0 77 4c 04 83 c6 41 3b 8f ee 8a 70 d8 16 e7 02 6f |wL...A;...p....o| +000002b0 13 9c a4 22 1d 1b cc 9e 6a 0e e8 96 94 54 df 2e |..."....j....T..| +000002c0 8a 60 53 e2 45 30 7b 8f 46 d2 ab 0e c1 6d 75 e2 |.`S.E0{.F....mu.| +000002d0 cf 6c fe 9e 2d 31 af 9e 51 73 a6 39 02 ff 7b c2 |.l..-1..Qs.9..{.| +000002e0 da 66 d6 27 87 9d 51 99 c9 7e 1b e7 43 8d 1e dc |.f.'..Q..~..C...| +000002f0 49 93 0e 9c 47 5c d6 97 19 ee 80 6d 4f 92 9d 25 |I...G\.....mO..%| +00000300 ff ea bf ab 9a 64 a6 d4 70 80 5e 13 42 48 75 4e |.....d..p.^.BHuN| +00000310 8c c3 9b 17 03 03 00 99 7b 4a 09 b6 85 dc 5c 10 |........{J....\.| +00000320 76 05 e8 11 e1 bc 63 ec ec b8 19 14 f3 95 16 6b |v.....c........k| +00000330 2a a6 e1 ae b9 1c e0 5c 94 20 49 62 8c fd 76 7e |*......\. Ib..v~| +00000340 0e f9 9f ec 0d 01 47 4b 86 a8 b1 9f a2 bc 83 85 |......GK........| +00000350 de e8 e0 2f c4 a4 f6 90 72 57 38 ad 2e aa 1e 4f |.../....rW8....O| +00000360 d4 8b e1 a2 b8 ba 80 99 ad 57 09 72 98 1c 5b 7b |.........W.r..[{| +00000370 a7 35 a2 c5 4a be 76 14 ee d4 63 a9 96 5e 33 7c |.5..J.v...c..^3|| +00000380 0a e0 15 0d 14 19 f1 5a 5a e4 2c 9c 22 19 db e3 |.......ZZ.,."...| +00000390 ea ee a1 c6 f8 1d 22 cc 5c 34 94 fa af 02 b0 26 |......".\4.....&| +000003a0 8d 25 67 e6 f5 74 a9 38 38 37 57 ee 11 ac 0a 73 |.%g..t.887W....s| +000003b0 01 17 03 03 00 35 bf ef 2c 2e 6c ae 90 ba d7 e0 |.....5..,.l.....| +000003c0 99 b3 ea 42 db 8e ad 03 5b af 93 1e 35 3a fb f7 |...B....[...5:..| +000003d0 87 bc 90 b6 98 ad e2 e6 1c 24 3b c1 20 8c 1a 79 |.........$;. ..y| +000003e0 97 ad e3 8b 08 7b cc 7e 2b 98 fa |.....{.~+..| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 00 35 ce 50 b5 dc 27 |..........5.P..'| +00000010 34 5b ea 1b 27 76 67 d1 9e 24 cf f9 51 4a 9a 6b |4[..'vg..$..QJ.k| +00000020 cd 57 12 b2 5a 52 03 be e8 62 e2 29 64 1e 16 f1 |.W..ZR...b.)d...| +00000030 61 af 70 a7 11 f1 41 ef e3 44 da 0e 9b 90 05 ad |a.p...A..D......| +00000040 17 03 03 00 17 b4 9d 4e de fb da 13 02 ad 51 40 |.......N......Q@| +00000050 b0 55 1d 89 ec 09 2b 52 e5 51 34 1f 17 03 03 00 |.U....+R.Q4.....| +00000060 13 52 89 42 ba d7 14 f0 53 b4 b1 5a a5 a3 37 55 |.R.B....S..Z..7U| +00000070 bd f8 e9 e5 |....| diff --git a/libgo/go/crypto/tls/testdata/Server-SSLv3-RSA-3DES b/libgo/go/crypto/tls/testdata/Server-SSLv3-RSA-3DES index 11a8a1c8cb2..869b22bc554 100644 --- a/libgo/go/crypto/tls/testdata/Server-SSLv3-RSA-3DES +++ b/libgo/go/crypto/tls/testdata/Server-SSLv3-RSA-3DES @@ -1,12 +1,12 @@ >>> Flow 1 (client to server) -00000000 16 03 00 00 2f 01 00 00 2b 03 00 47 b4 bd 36 64 |..../...+..G..6d| -00000010 0a 7d 37 1d 99 ac fd 1c 7a 3f d5 0f 9d 90 e3 59 |.}7.....z?.....Y| -00000020 64 e4 fb 59 3a 4a 5f 53 d2 af 88 00 00 04 00 0a |d..Y:J_S........| +00000000 16 03 00 00 2f 01 00 00 2b 03 00 6b 1d 6c 38 1a |..../...+..k.l8.| +00000010 50 71 9a 32 88 4f 4a fe 47 00 8f 2a 58 08 72 cf |Pq.2.OJ.G..*X.r.| +00000020 b5 f8 27 9d f9 17 76 32 8a 3b 29 00 00 04 00 0a |..'...v2.;).....| 00000030 00 ff 01 00 |....| >>> Flow 2 (server to client) 00000000 16 03 00 00 31 02 00 00 2d 03 00 00 00 00 00 00 |....1...-.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 0a 00 00 |................| +00000020 00 00 00 44 4f 57 4e 47 52 44 00 00 00 0a 00 00 |...DOWNGRD......| 00000030 05 ff 01 00 01 00 16 03 00 02 59 0b 00 02 55 00 |..........Y...U.| 00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -47,30 +47,30 @@ 00000280 b3 3e c0 d1 bd 42 d4 db fe 3d 13 60 84 5c 21 d3 |.>...B...=.`.\!.| 00000290 3b e9 fa e7 16 03 00 00 04 0e 00 00 00 |;............| >>> Flow 3 (client to server) -00000000 16 03 00 00 84 10 00 00 80 43 4d 76 6b 7f b3 e6 |.........CMvk...| -00000010 82 18 f9 8a a5 cd 45 ab 8f 1a 1d d4 9a 0a 1d 50 |......E........P| -00000020 96 f2 08 14 a7 6b e3 ef d1 31 6b 18 d2 f5 ee e3 |.....k...1k.....| -00000030 cd df 67 23 3d ec 70 09 07 df 32 c2 cd 60 6c 2b |..g#=.p...2..`l+| -00000040 7f 04 cd b3 77 87 78 e5 90 60 41 0c fc 22 1a 3a |....w.x..`A..".:| -00000050 82 29 28 92 9c f8 33 3a 72 ee 08 58 55 d5 ea 9c |.)(...3:r..XU...| -00000060 37 96 a4 92 75 e0 29 8a 18 ad 5a c1 1f 4c aa c7 |7...u.)...Z..L..| -00000070 49 89 6e ff 29 32 a3 c8 51 e8 50 3f 41 10 36 27 |I.n.)2..Q.P?A.6'| -00000080 0b 60 a2 96 4b 82 a9 c6 52 14 03 00 00 01 01 16 |.`..K...R.......| -00000090 03 00 00 40 b3 59 d0 de d1 47 8e 9e 1a 27 16 41 |...@.Y...G...'.A| -000000a0 f7 38 4e 91 12 a0 71 89 1c 68 29 dc 60 7e 2c 39 |.8N...q..h).`~,9| -000000b0 45 cb e6 98 8d 43 5e 76 34 ca 5b 86 24 9d 77 0a |E....C^v4.[.$.w.| -000000c0 90 60 19 75 67 74 3d 95 1d e7 82 ee a8 9f 3a 60 |.`.ugt=.......:`| -000000d0 8e ac 28 74 |..(t| +00000000 16 03 00 00 84 10 00 00 80 24 e4 7a 2a e8 1b 68 |.........$.z*..h| +00000010 c5 87 ac 26 72 70 76 c6 3a 2c 9d ed ff 63 3c 5b |...&rpv.:,...c<[| +00000020 97 17 3e d4 e9 ab 5b f1 30 ed 29 07 1a 6b 69 f6 |..>...[.0.)..ki.| +00000030 65 b1 c7 b9 15 9f b1 69 7d 74 c4 73 04 2a 45 77 |e......i}t.s.*Ew| +00000040 ba f7 8f 98 65 ed 19 2d a4 de 74 1e 4e 96 78 11 |....e..-..t.N.x.| +00000050 33 9f be a5 20 e4 bd a8 a4 1a 4d 02 e7 7a ac 01 |3... .....M..z..| +00000060 f4 12 01 8d 51 9a 52 26 ac a4 f6 52 fc cf 91 97 |....Q.R&...R....| +00000070 b5 d7 9f 25 92 b4 16 c4 33 46 bd 41 27 89 a2 72 |...%....3F.A'..r| +00000080 7b 50 d3 ed b3 29 17 aa ab 14 03 00 00 01 01 16 |{P...)..........| +00000090 03 00 00 40 ba 01 09 10 84 68 0c 97 25 b5 2d ef |...@.....h..%.-.| +000000a0 be c6 d9 21 85 fe bf ef d4 f3 24 2f 79 04 fd e6 |...!......$/y...| +000000b0 d3 c1 d2 1b a9 94 10 2e 1f dd dd 1f 97 de 63 e9 |..............c.| +000000c0 8f 8a c1 d0 ac e1 69 de 92 fa 16 10 2c 9e 5f 3a |......i.....,._:| +000000d0 45 7c 3f 88 |E|?.| >>> Flow 4 (server to client) -00000000 14 03 00 00 01 01 16 03 00 00 40 e8 3e 89 b5 10 |..........@.>...| -00000010 e4 c9 eb f7 3f 83 e5 6a 7c 04 fd e6 96 69 25 fb |....?..j|....i%.| -00000020 0b 0b 0e f7 13 4e 99 45 d2 0e 13 22 6b d1 0e 32 |.....N.E..."k..2| -00000030 30 b5 c4 a2 03 cf 22 59 68 5c cc 63 96 f5 01 f3 |0....."Yh\.c....| -00000040 2c b3 b5 13 e1 9d 19 45 c0 4f 28 17 03 00 00 18 |,......E.O(.....| -00000050 2e cb 8c b3 d4 d5 c2 18 fd 6e dc 72 7b b3 4b b8 |.........n.r{.K.| -00000060 10 56 0a 01 af 55 e8 5a 17 03 00 00 28 3f df 74 |.V...U.Z....(?.t| -00000070 2f b9 5b a4 43 ec 24 68 ad ff 6c 52 b5 6a 91 0c |/.[.C.$h..lR.j..| -00000080 be 3b 25 c9 e4 40 59 66 17 cb f0 e7 6b 6e cd 43 |.;%..@Yf....kn.C| -00000090 ac be b7 62 d0 15 03 00 00 18 43 4d 3c fd 83 6e |...b......CM<..n| -000000a0 e0 3f ae 40 0c 8a a1 08 d2 74 e2 60 7b d0 97 d5 |.?.@.....t.`{...| -000000b0 e8 a5 |..| +00000000 14 03 00 00 01 01 16 03 00 00 40 3b 60 e6 62 bc |..........@;`.b.| +00000010 53 0f 95 32 d8 95 33 1b 29 78 49 fd 1f a9 bf 64 |S..2..3.)xI....d| +00000020 71 2d b5 3e 03 80 a0 06 7a ca cd f6 f3 45 e9 d9 |q-.>....z....E..| +00000030 c1 fc da 4f 5d 77 a3 07 82 89 3b 77 00 9a 99 a2 |...O]w....;w....| +00000040 ac bf 73 78 31 a9 8c bf eb d1 2c 17 03 00 00 18 |..sx1.....,.....| +00000050 e9 c8 b2 91 db fa 9f 3c d4 ed 7d 43 f6 b3 53 d2 |.......<..}C..S.| +00000060 46 12 d2 6c a5 50 bd e1 17 03 00 00 28 2e 6f 91 |F..l.P......(.o.| +00000070 21 18 89 7b 94 3d c0 6f 8a 4c b4 95 44 4c fe 1a |!..{.=.o.L..DL..| +00000080 78 f5 6a fd 8f d0 79 c0 12 2f 4c 12 c4 29 9a 88 |x.j...y../L..)..| +00000090 43 1c b7 93 3a 15 03 00 00 18 ae 35 00 1f 79 99 |C...:......5..y.| +000000a0 cd 9f b1 16 a8 0f d6 28 29 e2 0a 16 e2 c2 de b3 |.......().......| +000000b0 5c 41 |\A| diff --git a/libgo/go/crypto/tls/testdata/Server-SSLv3-RSA-AES b/libgo/go/crypto/tls/testdata/Server-SSLv3-RSA-AES index 771373c27fb..5b09409ae76 100644 --- a/libgo/go/crypto/tls/testdata/Server-SSLv3-RSA-AES +++ b/libgo/go/crypto/tls/testdata/Server-SSLv3-RSA-AES @@ -1,12 +1,12 @@ >>> Flow 1 (client to server) -00000000 16 03 00 00 2f 01 00 00 2b 03 00 26 1e 06 cd 27 |..../...+..&...'| -00000010 f5 2a b4 8d 00 07 47 16 02 23 aa 5e 92 02 95 4a |.*....G..#.^...J| -00000020 1a 0b a8 51 8a 6f 4a 31 3c e9 a2 00 00 04 00 2f |...Q.oJ1<....../| +00000000 16 03 00 00 2f 01 00 00 2b 03 00 c0 74 e5 6f 1e |..../...+...t.o.| +00000010 3d 51 26 e2 34 31 68 10 ee 99 ca 45 0f 7d d6 7d |=Q&.41h....E.}.}| +00000020 29 82 15 23 3f af d1 48 36 1f ac 00 00 04 00 2f |)..#?..H6....../| 00000030 00 ff 01 00 |....| >>> Flow 2 (server to client) 00000000 16 03 00 00 31 02 00 00 2d 03 00 00 00 00 00 00 |....1...-.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2f 00 00 |............./..| +00000020 00 00 00 44 4f 57 4e 47 52 44 00 00 00 2f 00 00 |...DOWNGRD.../..| 00000030 05 ff 01 00 01 00 16 03 00 02 59 0b 00 02 55 00 |..........Y...U.| 00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -47,31 +47,31 @@ 00000280 b3 3e c0 d1 bd 42 d4 db fe 3d 13 60 84 5c 21 d3 |.>...B...=.`.\!.| 00000290 3b e9 fa e7 16 03 00 00 04 0e 00 00 00 |;............| >>> Flow 3 (client to server) -00000000 16 03 00 00 84 10 00 00 80 66 67 59 2f 21 b9 e3 |.........fgY/!..| -00000010 0d a9 78 0c 6b fc dc 6f 69 4e f9 00 8b 40 a2 0f |..x.k..oiN...@..| -00000020 5a d8 8c d2 59 ab 33 78 f6 42 2f fa cf d6 48 7a |Z...Y.3x.B/...Hz| -00000030 59 30 94 1c 10 49 30 69 4a 6c a2 e5 ce 59 6d e3 |Y0...I0iJl...Ym.| -00000040 49 0c a7 0a ab 17 8b c6 48 82 71 44 d5 7d 80 e5 |I.......H.qD.}..| -00000050 6d 45 6c 10 12 01 85 71 ee dc c5 e3 19 41 ed 22 |mEl....q.....A."| -00000060 11 5c c4 25 c6 90 ad c8 4c 48 45 8d ad 6c f4 ef |.\.%....LHE..l..| -00000070 fb b4 2b 53 90 cc 78 b0 9e 22 e7 2c 1a 64 0e 8b |..+S..x..".,.d..| -00000080 d8 57 54 74 c5 33 20 3f 42 14 03 00 00 01 01 16 |.WTt.3 ?B.......| -00000090 03 00 00 40 18 b6 0a d4 9e 4d fa 8a 67 ce 8e d5 |...@.....M..g...| -000000a0 51 31 75 65 f1 ff 54 a2 1b 80 c5 c3 a0 fc d2 78 |Q1ue..T........x| -000000b0 0b 99 3b 65 6c 1d 52 6d a9 9f 64 13 97 d5 2e b1 |..;el.Rm..d.....| -000000c0 76 0b a0 fb f6 16 f7 72 28 a5 8a 11 a7 46 d5 59 |v......r(....F.Y| -000000d0 e1 f4 f3 6f |...o| +00000000 16 03 00 00 84 10 00 00 80 62 6a 6e 2e 83 74 fe |.........bjn..t.| +00000010 08 7b e3 38 de be 06 18 ed c3 aa e0 27 5e bb 5d |.{.8........'^.]| +00000020 a3 22 38 92 d4 94 ec 18 02 f1 fd 57 98 ac 84 3c |."8........W...<| +00000030 07 ef c9 e2 c4 05 03 9c 89 69 dd cb 47 7c 61 5c |.........i..G|a\| +00000040 7b c7 02 7b e4 4c 94 28 ea d7 34 ed 03 ef eb de |{..{.L.(..4.....| +00000050 c0 75 e3 75 46 24 8a ed 33 33 5c 19 65 a2 f8 0c |.u.uF$..33\.e...| +00000060 69 f9 ce 3e b6 88 e3 f4 2a ba 5c 0d 85 2f 64 88 |i..>....*.\../d.| +00000070 cb 0e af 03 58 1b 54 71 21 fb 4c 13 ff 67 dd e9 |....X.Tq!.L..g..| +00000080 1a 83 08 a9 ad 46 85 2b 95 14 03 00 00 01 01 16 |.....F.+........| +00000090 03 00 00 40 65 17 83 78 12 b1 50 a8 7e 91 ad cf |...@e..x..P.~...| +000000a0 ff da 1b c3 c2 62 d7 7b dc 85 6a 1e 64 65 2e fc |.....b.{..j.de..| +000000b0 71 ea bd 4b a6 61 e3 95 27 78 f5 93 e6 6e 4c 83 |q..K.a..'x...nL.| +000000c0 78 f4 a0 ac 3b 23 08 61 b5 b6 96 3f a5 fd 50 be |x...;#.a...?..P.| +000000d0 20 ef 8f af | ...| >>> Flow 4 (server to client) -00000000 14 03 00 00 01 01 16 03 00 00 40 6c 5b 64 b5 f9 |..........@l[d..| -00000010 76 cc 7e 51 72 46 ab 21 17 b3 fb 2b 48 c5 5a 9f |v.~QrF.!...+H.Z.| -00000020 e6 35 14 ff df c7 a7 4b 5e 5a 9b 82 57 b5 bf 4d |.5.....K^Z..W..M| -00000030 5f 7c a5 be 67 96 71 3a 63 ad 76 86 66 06 e9 a2 |_|..g.q:c.v.f...| -00000040 35 39 6f 79 13 21 4b 19 c1 83 0e 17 03 00 00 20 |59oy.!K........ | -00000050 1a 80 c5 d1 8b 33 79 89 39 fc 11 44 80 33 1a f7 |.....3y.9..D.3..| -00000060 9f 63 96 5d c9 1a d4 56 2a ee 68 24 68 83 5d ca |.c.]...V*.h$h.].| -00000070 17 03 00 00 30 7c d4 88 17 d0 10 66 6a b3 61 ed |....0|.....fj.a.| -00000080 0a b5 72 55 ca fb c4 ec e2 f2 e2 bf 67 dd 3d c9 |..rU........g.=.| -00000090 01 3b 50 5c 35 ce 28 2d e6 9c 1f 5c 70 14 46 2a |.;P\5.(-...\p.F*| -000000a0 d8 9e ef 6a 66 15 03 00 00 20 c7 af e1 86 10 30 |...jf.... .....0| -000000b0 41 73 88 b2 86 02 a8 60 38 61 92 32 11 22 2d 47 |As.....`8a.2."-G| -000000c0 76 fe 22 9c 76 c2 00 ee e9 03 |v.".v.....| +00000000 14 03 00 00 01 01 16 03 00 00 40 c1 63 5c 1e 81 |..........@.c\..| +00000010 ef 1c 55 e7 5b ee 19 2b 89 c9 19 7a 53 96 ae f6 |..U.[..+...zS...| +00000020 47 22 4b b2 b9 64 38 06 99 b1 58 39 bc c2 7f 1c |G"K..d8...X9....| +00000030 c4 8e 0a ec f2 3d 41 ac a9 a2 34 d9 a2 66 4e 35 |.....=A...4..fN5| +00000040 a1 a5 a5 ad 70 c2 62 67 f7 83 3f 17 03 00 00 20 |....p.bg..?.... | +00000050 bf 4b 66 00 de 5f 75 f1 57 a1 47 e3 35 cb 1a 1b |.Kf.._u.W.G.5...| +00000060 1e f4 3b f5 96 84 bc ed 36 74 8a 8b 62 46 94 fd |..;.....6t..bF..| +00000070 17 03 00 00 30 a2 a7 8c ac 1b 27 d7 1a 6a 2b 37 |....0.....'..j+7| +00000080 cc 76 03 e3 93 6e ee 3d 12 d5 cd d7 b2 fc 59 ae |.v...n.=......Y.| +00000090 a5 e5 d5 9d 61 86 0b bf 2c 61 de ef 38 95 de 0c |....a...,a..8...| +000000a0 01 80 15 04 71 15 03 00 00 20 85 70 23 62 cb 0a |....q.... .p#b..| +000000b0 e0 fd f4 36 a6 7d 1a 85 50 36 70 c1 77 85 0d 94 |...6.}..P6p.w...| +000000c0 fd 90 8a eb cd ce a4 b5 d8 fc |..........| diff --git a/libgo/go/crypto/tls/testdata/Server-SSLv3-RSA-RC4 b/libgo/go/crypto/tls/testdata/Server-SSLv3-RSA-RC4 index f5674ccd670..6feee485acd 100644 --- a/libgo/go/crypto/tls/testdata/Server-SSLv3-RSA-RC4 +++ b/libgo/go/crypto/tls/testdata/Server-SSLv3-RSA-RC4 @@ -1,12 +1,12 @@ >>> Flow 1 (client to server) -00000000 16 03 00 00 2f 01 00 00 2b 03 00 3f cc 8d 3f f0 |..../...+..?..?.| -00000010 c9 36 6f 43 43 c1 46 45 cd bf e5 ba 02 e6 55 2c |.6oCC.FE......U,| -00000020 3a 24 4a db cb a8 f2 1d 26 3e ef 00 00 04 00 05 |:$J.....&>......| +00000000 16 03 00 00 2f 01 00 00 2b 03 00 d6 26 87 86 f3 |..../...+...&...| +00000010 3f e3 08 85 7a fc 3c fe 91 44 1a 68 9f c8 77 10 |?...z.<..D.h..w.| +00000020 5e af fa b9 e1 09 5f fb fa ad dd 00 00 04 00 05 |^....._.........| 00000030 00 ff 01 00 |....| >>> Flow 2 (server to client) 00000000 16 03 00 00 31 02 00 00 2d 03 00 00 00 00 00 00 |....1...-.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 05 00 00 |................| +00000020 00 00 00 44 4f 57 4e 47 52 44 00 00 00 05 00 00 |...DOWNGRD......| 00000030 05 ff 01 00 01 00 16 03 00 02 59 0b 00 02 55 00 |..........Y...U.| 00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -47,26 +47,26 @@ 00000280 b3 3e c0 d1 bd 42 d4 db fe 3d 13 60 84 5c 21 d3 |.>...B...=.`.\!.| 00000290 3b e9 fa e7 16 03 00 00 04 0e 00 00 00 |;............| >>> Flow 3 (client to server) -00000000 16 03 00 00 84 10 00 00 80 13 5d 75 f0 6d 24 54 |..........]u.m$T| -00000010 f5 a1 f0 13 86 61 ce ea 66 86 06 eb c8 27 78 9f |.....a..f....'x.| -00000020 10 0d ef 94 3f 1b fb 8c 11 14 67 2a 0e 2a 1b cf |....?.....g*.*..| -00000030 ae 5a cb ac b8 b2 ea a8 70 85 ee fd 88 a9 61 a4 |.Z......p.....a.| -00000040 75 66 86 a5 88 96 a0 0d 6f 77 fe 63 5e 88 60 4d |uf......ow.c^.`M| -00000050 f6 b7 93 28 99 72 e8 60 ed 64 9a 3f e6 12 ea ee |...(.r.`.d.?....| -00000060 83 58 d4 0c 19 e0 2b ce b0 b4 fa 73 9f 78 d9 09 |.X....+....s.x..| -00000070 8c 17 b8 f5 04 e1 de c4 fe a9 1a aa ba 0d be f3 |................| -00000080 c8 e1 e4 e8 cc 39 4c f0 b9 14 03 00 00 01 01 16 |.....9L.........| -00000090 03 00 00 3c 1b 70 07 7f ad 8f a7 78 fd e8 eb b2 |...<.p.....x....| -000000a0 9a 54 86 a2 dd bc fa b6 0a 52 48 24 79 6a 04 f6 |.T.......RH$yj..| -000000b0 28 80 1f b7 b1 c6 4e 07 a3 52 60 5a 5a 81 14 11 |(.....N..R`ZZ...| -000000c0 d2 ee 33 71 e7 d3 ba 3e 4b 31 81 f2 f0 49 ee e4 |..3q...>K1...I..| +00000000 16 03 00 00 84 10 00 00 80 d2 67 c1 73 bb 95 8d |..........g.s...| +00000010 b2 e7 30 ca 6c 53 eb f0 34 e5 26 11 0b 91 e9 0a |..0.lS..4.&.....| +00000020 cb 7d 9f d8 f9 01 38 06 01 83 29 a7 1d 69 b8 a1 |.}....8...)..i..| +00000030 1f aa bf 73 1e 26 82 ed 44 f5 82 ec 95 69 88 4b |...s.&..D....i.K| +00000040 b7 ce dd 52 c1 a6 3f be b8 02 23 a5 f3 0c 1e 36 |...R..?...#....6| +00000050 f9 c9 00 1f da e9 d5 38 48 b0 24 5e 25 c1 d4 cb |.......8H.$^%...| +00000060 64 c2 16 ff 94 d6 bd e2 e1 bf 7a 98 d9 77 09 a1 |d.........z..w..| +00000070 c4 f0 99 e6 57 89 02 c8 dd f0 d5 94 d8 44 34 0b |....W........D4.| +00000080 7a 08 52 95 75 20 02 0a 83 14 03 00 00 01 01 16 |z.R.u ..........| +00000090 03 00 00 3c e9 19 7a 94 45 9a b0 ec 3f 8f 1d 19 |...<..z.E...?...| +000000a0 64 65 45 6c e8 4e e3 c8 c8 c6 dc d3 a1 05 cf ea |deEl.N..........| +000000b0 fa cf 59 74 93 84 53 a3 bd 7b f0 07 64 92 ea a2 |..Yt..S..{..d...| +000000c0 f1 2a ea 29 4a 80 c6 99 76 3c 7e c3 f7 b0 e5 e2 |.*.)J...v<~.....| >>> Flow 4 (server to client) -00000000 14 03 00 00 01 01 16 03 00 00 3c 47 20 7c b9 0d |............Ht...........| -00000070 00 16 67 0d 6d 69 53 87 92 23 21 51 72 f6 31 73 |..g.miS..#!Qr.1s| -00000080 db bd 3c e6 f4 12 4c 69 |..<...Li| +00000000 14 03 00 00 01 01 16 03 00 00 3c 14 6c 96 8a 5e |..........<.l..^| +00000010 ab 93 c2 65 9b 22 57 31 e6 f1 ce 6a a2 28 31 e8 |...e."W1...j.(1.| +00000020 b5 c3 e7 07 98 2f 0b 40 b7 65 ec 92 f5 60 61 c2 |...../.@.e...`a.| +00000030 25 40 91 2f fa a4 4e 4a ad 7b b3 2a 26 23 d3 04 |%@./..NJ.{.*&#..| +00000040 0f c2 2e 95 82 9d 4b 17 03 00 00 21 5e c6 1e 2c |......K....!^..,| +00000050 49 23 4d 14 b2 87 4b c2 f9 09 17 f0 1a 11 15 50 |I#M...K........P| +00000060 52 d3 85 7b 25 0e e5 2c 7b 74 4b 5e 9d 15 03 00 |R..{%..,{tK^....| +00000070 00 16 6b aa 31 b5 e4 ff 02 0a 39 bc d7 57 51 a1 |..k.1.....9..WQ.| +00000080 42 07 c9 ba 2b 35 26 b7 |B...+5&.| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv10-ECDHE-ECDSA-AES b/libgo/go/crypto/tls/testdata/Server-TLSv10-ECDHE-ECDSA-AES index 3e170818a05..c5494af7df6 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv10-ECDHE-ECDSA-AES +++ b/libgo/go/crypto/tls/testdata/Server-TLSv10-ECDHE-ECDSA-AES @@ -1,14 +1,15 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 4f 01 00 00 4b 03 01 f1 86 d0 c8 69 |....O...K......i| -00000010 46 0b 0b 89 08 c0 82 c0 f7 f1 9a b6 d2 2b e1 46 |F............+.F| -00000020 e6 e1 44 65 de 39 0a 68 a8 d5 1c 00 00 04 c0 0a |..De.9.h........| -00000030 00 ff 01 00 00 1e 00 0b 00 04 03 00 01 02 00 0a |................| -00000040 00 0a 00 08 00 1d 00 17 00 19 00 18 00 16 00 00 |................| -00000050 00 17 00 00 |....| +00000000 16 03 01 00 63 01 00 00 5f 03 01 c7 00 ca ac 5f |....c..._......_| +00000010 08 6c a0 aa e8 a0 55 6f fb 20 ae 5d 6c 07 fa 6b |.l....Uo. .]l..k| +00000020 f8 2b 16 e2 46 ce f7 e7 c1 ba 5c 00 00 04 c0 0a |.+..F.....\.....| +00000030 00 ff 01 00 00 32 00 00 00 0e 00 0c 00 00 09 31 |.....2.........1| +00000040 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000050 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 00 18 |................| +00000060 00 16 00 00 00 17 00 00 |........| >>> Flow 2 (server to client) 00000000 16 03 01 00 31 02 00 00 2d 03 01 00 00 00 00 00 |....1...-.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 c0 0a 00 00 |................| +00000020 00 00 00 44 4f 57 4e 47 52 44 00 00 c0 0a 00 00 |...DOWNGRD......| 00000030 05 ff 01 00 01 00 16 03 01 02 0e 0b 00 02 0a 00 |................| 00000040 02 07 00 02 04 30 82 02 00 30 82 01 62 02 09 00 |.....0...0..b...| 00000050 b8 bf 2d 47 a0 d2 eb f4 30 09 06 07 2a 86 48 ce |..-G....0...*.H.| @@ -42,37 +43,37 @@ 00000210 0e bd 3f a3 8c 25 c1 33 13 83 0d 94 06 bb d4 37 |..?..%.3.......7| 00000220 7a f6 ec 7a c9 86 2e dd d7 11 69 7f 85 7c 56 de |z..z......i..|V.| 00000230 fb 31 78 2b e4 c7 78 0d ae cb be 9e 4e 36 24 31 |.1x+..x.....N6$1| -00000240 7b 6a 0f 39 95 12 07 8f 2a 16 03 01 00 b5 0c 00 |{j.9....*.......| -00000250 00 b1 03 00 1d 20 2f e5 7d a3 47 cd 62 43 15 28 |..... /.}.G.bC.(| +00000240 7b 6a 0f 39 95 12 07 8f 2a 16 03 01 00 b4 0c 00 |{j.9....*.......| +00000250 00 b0 03 00 1d 20 2f e5 7d a3 47 cd 62 43 15 28 |..... /.}.G.bC.(| 00000260 da ac 5f bb 29 07 30 ff f6 84 af c4 cf c2 ed 90 |.._.).0.........| -00000270 99 5f 58 cb 3b 74 00 8b 30 81 88 02 42 00 ad 93 |._X.;t..0...B...| -00000280 e2 c2 3d 7e 95 63 17 5d 45 cf cd 27 af d2 db b3 |..=~.c.]E..'....| -00000290 d0 bc 13 1e 6f 0a 61 3a fb 3c b3 03 61 2c 36 ae |....o.a:.<..a,6.| -000002a0 4f be 27 e9 43 3c cf 57 9b 82 5e 7d 54 36 ed 7e |O.'.C<.W..^}T6.~| -000002b0 0b 34 68 26 90 00 20 02 0f c1 18 bc 79 1b 90 02 |.4h&.. .....y...| -000002c0 42 01 6b 66 9d 56 48 8e 5e 38 93 48 03 6b b9 d7 |B.kf.VH.^8.H.k..| -000002d0 bd 14 a0 3e 8a 27 81 7f fe 4d e5 8a 12 4d 95 16 |...>.'...M...M..| -000002e0 ef c7 8d 60 07 1d 22 f8 5d 72 0d cc be c3 51 69 |...`..".]r....Qi| -000002f0 7a 04 e3 84 e5 ba dd 04 1d d4 4c 6f 9f 6b 12 e0 |z.........Lo.k..| -00000300 2f 83 3c 16 03 01 00 04 0e 00 00 00 |/.<.........| +00000270 99 5f 58 cb 3b 74 00 8a 30 81 87 02 41 4f 15 dd |._X.;t..0...AO..| +00000280 a7 4a 1e 90 6f f5 4b 31 f7 8f c5 5f 26 60 0c d2 |.J..o.K1..._&`..| +00000290 ab 71 cf e4 3e 20 2e 83 9e 94 00 fc 92 4f 87 43 |.q..> .......O.C| +000002a0 e8 53 2f a3 ee 4a 4e 58 6e d5 5f 11 64 54 de cc |.S/..JNXn._.dT..| +000002b0 ae 83 b1 53 4a 16 1d 14 5c f0 fe 6b c1 7a 02 42 |...SJ...\..k.z.B| +000002c0 00 89 a0 e3 33 70 5f 20 c3 72 e7 93 1a fa b1 49 |....3p_ .r.....I| +000002d0 4a 46 83 f4 a3 88 24 c0 22 72 e6 09 ad a7 bd d1 |JF....$."r......| +000002e0 c8 c1 b3 7c 21 04 dc 67 58 8e 8e d4 bf 2d f3 d7 |...|!..gX....-..| +000002f0 c4 5a 06 d6 c1 65 84 dc 97 5c 0d 6f a4 64 d2 5f |.Z...e...\.o.d._| +00000300 47 99 16 03 01 00 04 0e 00 00 00 |G..........| >>> Flow 3 (client to server) -00000000 16 03 01 00 25 10 00 00 21 20 18 40 ea d1 e1 17 |....%...! .@....| -00000010 b6 a2 a5 db 20 13 70 81 90 fc ac e8 96 7c b1 e1 |.... .p......|..| -00000020 ff 6f 57 1f c1 64 72 94 f7 05 14 03 01 00 01 01 |.oW..dr.........| -00000030 16 03 01 00 30 05 33 48 f0 2a 3a df df 1d c4 3d |....0.3H.*:....=| -00000040 87 ea 9d 04 04 eb 84 bf a0 ed bc 56 2f ab 36 52 |...........V/.6R| -00000050 d5 b2 2c 6f 8c 58 49 51 33 d5 fc df 5d 09 df e9 |..,o.XIQ3...]...| -00000060 be 20 30 9a 37 |. 0.7| +00000000 16 03 01 00 25 10 00 00 21 20 91 71 e4 59 10 64 |....%...! .q.Y.d| +00000010 19 77 13 21 9c 60 ee 81 58 ba 41 10 39 61 e0 a7 |.w.!.`..X.A.9a..| +00000020 73 4d ec e8 cd cc b5 e0 cc 6d 14 03 01 00 01 01 |sM.......m......| +00000030 16 03 01 00 30 5c 35 d5 37 46 1e 28 52 32 ed 35 |....0\5.7F.(R2.5| +00000040 44 37 9c ca 83 4c 06 80 ff 17 7c cd 7d e5 22 14 |D7...L....|.}.".| +00000050 0e 70 12 01 f0 e5 ce 5a ca be 41 e2 ee 48 9d 95 |.p.....Z..A..H..| +00000060 c3 51 0c 15 bb |.Q...| >>> Flow 4 (server to client) -00000000 14 03 01 00 01 01 16 03 01 00 30 8c b6 5b 83 03 |..........0..[..| -00000010 c0 d8 83 f7 1d 24 2e ec 39 68 00 91 73 d2 5a 15 |.....$..9h..s.Z.| -00000020 3f 83 aa e3 6d fd cc 31 58 90 e9 a9 e3 e4 78 5d |?...m..1X.....x]| -00000030 ce 8e b3 ba cd 71 aa a2 fd f4 7c 17 03 01 00 20 |.....q....|.... | -00000040 62 98 34 9d 01 13 13 2d 1b 27 3a 4f 10 28 48 d6 |b.4....-.':O.(H.| -00000050 32 8c 99 2a c8 64 14 6e dc f5 7c 6d 16 59 45 8e |2..*.d.n..|m.YE.| -00000060 17 03 01 00 30 1e ed f9 40 ad 5c 5d f6 94 c9 fd |....0...@.\]....| -00000070 a1 ac fc 00 7b 48 9a 59 6d f5 b7 06 a4 66 25 04 |....{H.Ym....f%.| -00000080 61 33 08 f3 66 86 21 00 fb f3 03 78 83 4c b6 c8 |a3..f.!....x.L..| -00000090 9d 5e ea f5 7e 15 03 01 00 20 98 d8 f6 2a 79 60 |.^..~.... ...*y`| -000000a0 8d fb c9 45 2f 27 59 17 a9 79 eb e7 b9 46 f1 57 |...E/'Y..y...F.W| -000000b0 a6 fa ea e1 d0 23 8c 03 4f 72 |.....#..Or| +00000000 14 03 01 00 01 01 16 03 01 00 30 ba 12 b3 9d e1 |..........0.....| +00000010 9a 4d 9d d4 74 50 d7 b0 db 05 68 53 ba 1f 4b 3a |.M..tP....hS..K:| +00000020 b5 c4 91 ee e6 ed d4 e9 07 c7 12 c5 90 42 f5 44 |.............B.D| +00000030 5a 34 59 07 9d fa 8c ec a4 7e 5f 17 03 01 00 20 |Z4Y......~_.... | +00000040 04 58 11 87 90 9b fe ae 63 39 15 07 ec 74 fd 9a |.X......c9...t..| +00000050 15 28 ec b0 75 c4 e8 7a c5 59 73 9c cf 85 75 af |.(..u..z.Ys...u.| +00000060 17 03 01 00 30 24 12 78 fc 37 d4 d8 ec 25 67 38 |....0$.x.7...%g8| +00000070 63 91 68 3a fc 97 26 ab 11 b9 4b 8f 20 8f 75 4f |c.h:..&...K. .uO| +00000080 ca 02 ef 2b 43 b1 4e 7a ed dd dc 36 93 ae 79 6f |...+C.Nz...6..yo| +00000090 c5 8c a2 39 d6 15 03 01 00 20 b0 a0 fb f1 40 b2 |...9..... ....@.| +000000a0 09 00 94 fd b3 f5 98 1e d6 fb e8 96 20 36 bb 4b |............ 6.K| +000000b0 4a 28 fb 51 0e 6e 7b fe 05 48 |J(.Q.n{..H| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv10-ExportKeyingMaterial b/libgo/go/crypto/tls/testdata/Server-TLSv10-ExportKeyingMaterial index 84e0e37005f..7e6b5bcd676 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv10-ExportKeyingMaterial +++ b/libgo/go/crypto/tls/testdata/Server-TLSv10-ExportKeyingMaterial @@ -1,15 +1,16 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 61 01 00 00 5d 03 01 f4 ec 99 73 ec |....a...].....s.| -00000010 36 30 c7 0b 26 33 a2 c4 26 8e 9f 04 f7 5b e7 4f |60..&3..&....[.O| -00000020 86 85 14 bf f7 49 96 a4 ae c9 1d 00 00 12 c0 0a |.....I..........| +00000000 16 03 01 00 75 01 00 00 71 03 01 7c 54 5c c6 6c |....u...q..|T\.l| +00000010 e9 bc 40 7a 4b 4e 46 5d 0a 37 3b d9 8f d7 97 47 |..@zKNF].7;....G| +00000020 44 42 d4 23 db 0d d2 3b 60 83 c3 00 00 12 c0 0a |DB.#...;`.......| 00000030 c0 14 00 39 c0 09 c0 13 00 33 00 35 00 2f 00 ff |...9.....3.5./..| -00000040 01 00 00 22 00 0b 00 04 03 00 01 02 00 0a 00 0a |..."............| -00000050 00 08 00 1d 00 17 00 19 00 18 00 23 00 00 00 16 |...........#....| -00000060 00 00 00 17 00 00 |......| +00000040 01 00 00 36 00 00 00 0e 00 0c 00 00 09 31 32 37 |...6.........127| +00000050 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 00 0a |.0.0.1..........| +00000060 00 0c 00 0a 00 1d 00 17 00 1e 00 19 00 18 00 23 |...............#| +00000070 00 00 00 16 00 00 00 17 00 00 |..........| >>> Flow 2 (server to client) 00000000 16 03 01 00 35 02 00 00 31 03 01 00 00 00 00 00 |....5...1.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 c0 14 00 00 |................| +00000020 00 00 00 44 4f 57 4e 47 52 44 00 00 c0 14 00 00 |...DOWNGRD......| 00000030 09 00 23 00 00 ff 01 00 01 00 16 03 01 02 59 0b |..#...........Y.| 00000040 00 02 55 00 02 52 00 02 4f 30 82 02 4b 30 82 01 |..U..R..O0..K0..| 00000050 b4 a0 03 02 01 02 02 09 00 e8 f0 9d 3f e2 5b ea |............?.[.| @@ -51,42 +52,42 @@ 00000290 84 5c 21 d3 3b e9 fa e7 16 03 01 00 aa 0c 00 00 |.\!.;...........| 000002a0 a6 03 00 1d 20 2f e5 7d a3 47 cd 62 43 15 28 da |.... /.}.G.bC.(.| 000002b0 ac 5f bb 29 07 30 ff f6 84 af c4 cf c2 ed 90 99 |._.).0..........| -000002c0 5f 58 cb 3b 74 00 80 8e fe 28 f2 06 d8 b9 d6 74 |_X.;t....(.....t| -000002d0 72 34 dc fa 00 38 56 1a fc a1 68 e8 ca 8f 7a 61 |r4...8V...h...za| -000002e0 92 e2 2a 63 ce 4d 96 c6 bb 84 82 41 2d 97 35 13 |..*c.M.....A-.5.| -000002f0 e1 ff 4c ec f2 e6 62 16 15 35 da 8a 57 55 cb 28 |..L...b..5..WU.(| -00000300 26 35 e6 86 00 b0 92 44 b7 40 7b 6a c4 b0 b8 10 |&5.....D.@{j....| -00000310 b7 16 97 a7 26 eb 1e 0b 99 b3 22 4a 6b 7f 0b 69 |....&....."Jk..i| -00000320 0d 21 1e 33 6d fd 78 b5 62 68 53 db 62 69 ba b4 |.!.3m.x.bhS.bi..| -00000330 bc 74 b3 d4 ce a2 41 d7 ba 62 aa cc b2 39 65 86 |.t....A..b...9e.| -00000340 5f 00 68 e2 16 a5 13 16 03 01 00 04 0e 00 00 00 |_.h.............| +000002c0 5f 58 cb 3b 74 00 80 67 06 ef c8 04 2d a2 ae 6b |_X.;t..g....-..k| +000002d0 4f 9b d7 94 aa a4 db dc 37 65 ac c5 49 96 7e 48 |O.......7e..I.~H| +000002e0 0f ea 82 62 d9 74 c8 e2 b4 20 72 77 b9 c1 b3 72 |...b.t... rw...r| +000002f0 4c 67 78 4b c9 4d 98 63 6d b7 df 16 43 65 d1 37 |LgxK.M.cm...Ce.7| +00000300 41 48 a3 4e 75 59 83 b9 7a 10 78 d3 84 d9 21 54 |AH.NuY..z.x...!T| +00000310 c2 86 b3 45 22 e7 e1 35 b7 74 0b 96 fc 7e 81 fa |...E"..5.t...~..| +00000320 27 9e 44 8b a7 87 b3 cb 39 d9 7f d2 dc 7f 98 f1 |'.D.....9.......| +00000330 45 34 cb c1 73 6a 1d 3e 01 f6 0b 9a 26 cf 48 d7 |E4..sj.>....&.H.| +00000340 ef 56 f2 fb 75 c3 af 16 03 01 00 04 0e 00 00 00 |.V..u...........| >>> Flow 3 (client to server) -00000000 16 03 01 00 25 10 00 00 21 20 81 08 e4 37 1d 03 |....%...! ...7..| -00000010 87 5a 00 68 ae 49 76 08 4a e2 20 82 0b e5 7c 3e |.Z.h.Iv.J. ...|>| -00000020 90 49 9b c3 b9 c7 c9 3c 29 24 14 03 01 00 01 01 |.I.....<)$......| -00000030 16 03 01 00 30 33 07 d5 08 ca ae f9 70 50 93 0a |....03......pP..| -00000040 55 2e e0 df 1d 88 ae 1e 06 17 47 64 a3 52 36 37 |U.........Gd.R67| -00000050 d5 ca f1 b1 d2 76 7b f8 89 59 13 e9 ab b1 cb dc |.....v{..Y......| -00000060 1f a8 89 f4 2f |..../| +00000000 16 03 01 00 25 10 00 00 21 20 67 7e 47 91 48 7e |....%...! g~G.H~| +00000010 09 88 9e e7 6c 17 a8 36 3a fb b8 bf f3 1d 51 01 |....l..6:.....Q.| +00000020 b1 b4 fb 16 a6 9c 19 74 a0 65 14 03 01 00 01 01 |.......t.e......| +00000030 16 03 01 00 30 f5 06 6c 15 ad 06 45 cc 5d 12 67 |....0..l...E.].g| +00000040 93 63 e8 50 b5 df f8 75 9d 67 e6 45 92 26 a4 60 |.c.P...u.g.E.&.`| +00000050 3a fe 2e 75 6f 8b a9 da de 12 7d 61 05 b7 50 32 |:..uo.....}a..P2| +00000060 e9 c9 ab 46 e9 |...F.| >>> Flow 4 (server to client) 00000000 16 03 01 00 82 04 00 00 7e 00 00 00 00 00 78 50 |........~.....xP| 00000010 46 ad c1 db a8 38 86 7b 2b bb fd d0 c3 42 3e 00 |F....8.{+....B>.| 00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 94 |................| -00000030 6d ec a4 83 61 a4 a1 9c 14 de f8 59 c8 c7 f0 10 |m...a......Y....| -00000040 08 fe c9 37 29 ed 47 05 d2 bd a8 4c 05 b9 8c f8 |...7).G....L....| -00000050 b5 4d e4 a6 30 0f 49 4a b1 73 1f 89 73 c8 bb 36 |.M..0.IJ.s..s..6| -00000060 14 9d d2 95 70 33 94 fb 82 e6 fe 3e 64 8c 9d e8 |....p3.....>d...| -00000070 e3 e5 93 3d fe 4e 23 a3 97 8a a3 91 80 c9 00 01 |...=.N#.........| -00000080 a6 f0 47 cf 11 a6 90 14 03 01 00 01 01 16 03 01 |..G.............| -00000090 00 30 1f 70 17 a1 30 82 5a 32 e7 aa a1 7f 1b f6 |.0.p..0.Z2......| -000000a0 d8 aa 6a 51 64 1b 4a f1 94 12 08 2f 5d 95 fe 83 |..jQd.J..../]...| -000000b0 52 c8 3b d4 58 73 50 19 b8 08 61 b3 3a 5d f6 d3 |R.;.XsP...a.:]..| -000000c0 67 e6 17 03 01 00 20 bd 79 44 08 9d 86 cf 5e e9 |g..... .yD....^.| -000000d0 e4 3c 80 ed b7 18 10 07 0f 42 85 ca a4 51 fd 9b |.<.......B...Q..| -000000e0 38 3e 04 7e 72 6e 80 17 03 01 00 30 2c 46 c2 71 |8>.~rn.....0,F.q| -000000f0 4a 83 46 eb 63 87 f5 83 b4 72 70 4f a3 59 b3 ff |J.F.c....rpO.Y..| -00000100 3c 00 74 12 db 33 51 4c 7c e0 c1 27 44 20 68 25 |<.t..3QL|..'D h%| -00000110 95 f1 37 2a 24 f1 85 a3 5a e4 50 fe 15 03 01 00 |..7*$...Z.P.....| -00000120 20 72 01 cc 74 d5 b4 6b 05 ce de f0 b4 fe 4f 6b | r..t..k......Ok| -00000130 a8 8f ad 5a c2 7d 40 65 d6 a2 57 52 b8 8a c5 4f |...Z.}@e..WR...O| -00000140 d9 |.| +00000030 6d ec a4 83 61 7c 54 a3 1a 2d bb 5f f0 10 99 e1 |m...a|T..-._....| +00000040 34 de 77 7f ee 2f ff 04 6d d3 d3 ef 66 e2 2d d1 |4.w../..m...f.-.| +00000050 6b 50 30 3c e0 24 e6 22 e3 f2 26 f3 d1 d7 4d ae |kP0<.$."..&...M.| +00000060 d3 7e 7f fa 1a 33 94 ef bd 3f 22 57 45 75 6c 1f |.~...3...?"WEul.| +00000070 fe ca 44 27 c1 20 14 cb 42 92 2d db 34 38 dc 50 |..D'. ..B.-.48.P| +00000080 3f a0 52 a0 78 7f ca 14 03 01 00 01 01 16 03 01 |?.R.x...........| +00000090 00 30 fe 05 cc db 6f b4 2b 94 01 56 c0 5e 6e cf |.0....o.+..V.^n.| +000000a0 29 b0 4d dc 74 ec a7 f6 68 2c 33 d9 cb f5 92 8b |).M.t...h,3.....| +000000b0 35 d3 e4 21 a1 a8 dc 4b a7 a3 97 8d a8 3b 55 21 |5..!...K.....;U!| +000000c0 17 bd 17 03 01 00 20 15 02 68 3e 6a 6f b8 4d bf |...... ..h>jo.M.| +000000d0 1b ef b3 0f 52 a0 9d 07 8f ae 57 50 a0 94 06 9b |....R.....WP....| +000000e0 29 d7 c9 4c 5d ad 50 17 03 01 00 30 ab 31 2f 85 |)..L].P....0.1/.| +000000f0 32 54 67 03 49 3c 25 00 9d b0 17 1d 90 07 ca e2 |2Tg.I<%.........| +00000100 6c 7e b9 cf 5a ea 7c 10 e4 9a 0c cf 0e fc 7d 4a |l~..Z.|.......}J| +00000110 f6 17 0d dc 5b be 3f cb 78 90 9b 87 15 03 01 00 |....[.?.x.......| +00000120 20 ab 1d cf 80 17 58 01 98 e7 c1 39 81 9f f5 18 | .....X....9....| +00000130 3e 88 30 81 64 62 36 89 8b e9 06 55 2b d3 ee 85 |>.0.db6....U+...| +00000140 b9 |.| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv10-RSA-3DES b/libgo/go/crypto/tls/testdata/Server-TLSv10-RSA-3DES index 9590b0daa1e..10fade15333 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv10-RSA-3DES +++ b/libgo/go/crypto/tls/testdata/Server-TLSv10-RSA-3DES @@ -1,12 +1,15 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 39 01 00 00 35 03 01 58 71 a3 0c c4 |....9...5..Xq...| -00000010 b6 b0 33 0a 66 3c eb c6 f4 d9 0e 99 75 d4 9e b6 |..3.f<......u...| -00000020 03 b4 ae ae ad bc a8 ab 64 a0 27 00 00 04 00 0a |........d.'.....| -00000030 00 ff 01 00 00 08 00 16 00 00 00 17 00 00 |..............| +00000000 16 03 01 00 63 01 00 00 5f 03 01 33 4b 5c 08 a3 |....c..._..3K\..| +00000010 64 52 8d 1f c9 55 bd 2e 03 e8 9d 88 f4 ff c0 35 |dR...U.........5| +00000020 33 ad d0 aa 7d f6 2d 42 0c c4 85 00 00 04 00 0a |3...}.-B........| +00000030 00 ff 01 00 00 32 00 00 00 0e 00 0c 00 00 09 31 |.....2.........1| +00000040 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000050 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 00 18 |................| +00000060 00 16 00 00 00 17 00 00 |........| >>> Flow 2 (server to client) 00000000 16 03 01 00 31 02 00 00 2d 03 01 00 00 00 00 00 |....1...-.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 0a 00 00 |................| +00000020 00 00 00 44 4f 57 4e 47 52 44 00 00 00 0a 00 00 |...DOWNGRD......| 00000030 05 ff 01 00 01 00 16 03 01 02 59 0b 00 02 55 00 |..........Y...U.| 00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -47,26 +50,26 @@ 00000280 b3 3e c0 d1 bd 42 d4 db fe 3d 13 60 84 5c 21 d3 |.>...B...=.`.\!.| 00000290 3b e9 fa e7 16 03 01 00 04 0e 00 00 00 |;............| >>> Flow 3 (client to server) -00000000 16 03 01 00 86 10 00 00 82 00 80 ab 50 cd 04 9e |............P...| -00000010 db 19 e4 18 26 ff 59 41 20 02 a5 a2 20 a3 1c 44 |....&.YA ... ..D| -00000020 02 bc 9a 1c d9 d7 5d 5b 55 fc 2a 4d 2b 03 22 b1 |......][U.*M+.".| -00000030 de 96 10 84 6f e3 f2 22 2d 6f cb 29 07 43 a6 6e |....o.."-o.).C.n| -00000040 ce 23 64 f7 72 2b dc 9b c0 6f 7f bd 8e cf e2 7f |.#d.r+...o......| -00000050 75 12 24 72 23 6b 26 08 69 76 17 c0 21 91 c0 7d |u.$r#k&.iv..!..}| -00000060 8c 8f 20 83 08 02 0d 73 27 23 91 35 5f 3f e6 56 |.. ....s'#.5_?.V| -00000070 1d 69 d3 1d 3b 0e fa 60 86 8b 40 ad c0 48 59 60 |.i..;..`..@..HY`| -00000080 45 eb b0 77 2c 91 94 75 fd 6a d3 14 03 01 00 01 |E..w,..u.j......| -00000090 01 16 03 01 00 28 8b 25 c1 8f 25 32 b5 cb 74 6d |.....(.%..%2..tm| -000000a0 08 67 59 a3 ae ae 16 f9 fa 03 f6 54 42 f4 56 3f |.gY........TB.V?| -000000b0 c4 12 66 f3 1a b0 48 95 24 79 fe 41 a5 d1 |..f...H.$y.A..| +00000000 16 03 01 00 86 10 00 00 82 00 80 69 ea b8 fd 3a |...........i...:| +00000010 76 cb 76 4d b2 7a 0e 61 4d 9d 9e 26 13 02 07 aa |v.vM.z.aM..&....| +00000020 31 94 01 9f 57 00 80 f1 aa 75 06 09 65 42 c7 c8 |1...W....u..eB..| +00000030 6d ea 8c 75 4e 69 35 d2 84 71 89 5a 44 f6 15 91 |m..uNi5..q.ZD...| +00000040 b0 a9 e1 ff 65 0a 51 fe 06 a3 2d eb cb 33 6e 07 |....e.Q...-..3n.| +00000050 dd 2f 02 fe d3 ec 89 7c 87 48 27 eb d8 8c 4c 6d |./.....|.H'...Lm| +00000060 95 4c 6f 8a a8 a0 fe 59 d6 a4 b4 7a a5 48 aa f1 |.Lo....Y...z.H..| +00000070 37 95 1d 4d 18 ee b0 a7 aa ca a8 18 65 83 8e 26 |7..M........e..&| +00000080 05 9c d6 76 ff 9b 40 65 b7 2e 47 14 03 01 00 01 |...v..@e..G.....| +00000090 01 16 03 01 00 28 fa 03 ae d2 47 ef 75 4e 99 79 |.....(....G.uN.y| +000000a0 69 87 be 5e 61 1f 0f 09 65 56 31 08 09 38 34 1b |i..^a...eV1..84.| +000000b0 41 6a 9e 2c 3b a9 11 62 34 a8 58 bc 1d 92 |Aj.,;..b4.X...| >>> Flow 4 (server to client) -00000000 14 03 01 00 01 01 16 03 01 00 28 ff 69 ed 0f 20 |..........(.i.. | -00000010 ff e1 42 78 b9 bc a8 61 48 82 08 a0 01 a5 98 91 |..Bx...aH.......| -00000020 3e 39 d4 6d 17 38 a2 04 18 ed 90 3c f0 cf 6a 9a |>9.m.8.....<..j.| -00000030 ea c5 45 17 03 01 00 18 b5 76 2c 0e f1 34 51 e5 |..E......v,..4Q.| -00000040 f5 38 d3 9f c9 c5 d5 19 35 c3 2e ec 18 df 8e c8 |.8......5.......| -00000050 17 03 01 00 28 47 6f e9 c0 fa b3 21 ec 6c 16 e7 |....(Go....!.l..| -00000060 71 a8 09 15 17 86 68 1c cf fa ea 37 68 d3 33 ef |q.....h....7h.3.| -00000070 4a b1 95 46 5b 16 d7 95 f8 13 65 2f 93 15 03 01 |J..F[.....e/....| -00000080 00 18 1b 0c 09 81 ff fc 6d 82 84 ab 83 98 fc 72 |........m......r| -00000090 f5 4a a0 eb 08 96 79 01 76 26 |.J....y.v&| +00000000 14 03 01 00 01 01 16 03 01 00 28 a4 c5 9f 93 86 |..........(.....| +00000010 fe 08 22 16 05 20 81 e3 a3 38 74 5d 32 24 41 50 |..".. ...8t]2$AP| +00000020 f4 e4 6b dd 92 0b d6 77 86 44 32 f9 2d f0 52 0e |..k....w.D2.-.R.| +00000030 c4 98 02 17 03 01 00 18 20 ee 92 bf 46 ce 52 ed |........ ...F.R.| +00000040 ac 85 df cd 2a a7 c1 6c 82 be ed 55 9e 55 25 b2 |....*..l...U.U%.| +00000050 17 03 01 00 28 b0 45 3d 83 94 79 d1 a5 a3 b0 0a |....(.E=..y.....| +00000060 59 63 13 62 1e 66 c2 69 4d a4 8d e0 fb 87 cb dc |Yc.b.f.iM.......| +00000070 5e 51 49 05 82 4d d6 1e 40 78 f0 cd 4b 15 03 01 |^QI..M..@x..K...| +00000080 00 18 38 0e 60 43 55 25 82 d2 4c 97 cf cd a9 7a |..8.`CU%..L....z| +00000090 e8 8a 4a eb c1 8d 54 cb e6 92 |..J...T...| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv10-RSA-AES b/libgo/go/crypto/tls/testdata/Server-TLSv10-RSA-AES index c1750292d73..10fc9f06238 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv10-RSA-AES +++ b/libgo/go/crypto/tls/testdata/Server-TLSv10-RSA-AES @@ -1,12 +1,15 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 39 01 00 00 35 03 01 82 f3 04 d5 71 |....9...5......q| -00000010 d8 65 69 36 46 cb 45 77 b2 ef 00 75 98 e4 16 d2 |.ei6F.Ew...u....| -00000020 70 f7 3c 97 84 49 ef da 5d cd 64 00 00 04 00 2f |p.<..I..].d..../| -00000030 00 ff 01 00 00 08 00 16 00 00 00 17 00 00 |..............| +00000000 16 03 01 00 63 01 00 00 5f 03 01 a1 4c 20 79 0a |....c..._...L y.| +00000010 35 d6 8b 7d e7 f2 3e eb bd c2 72 73 a9 18 c2 9b |5..}..>...rs....| +00000020 8a a0 b6 ae 17 21 df 6f d0 b0 f8 00 00 04 00 2f |.....!.o......./| +00000030 00 ff 01 00 00 32 00 00 00 0e 00 0c 00 00 09 31 |.....2.........1| +00000040 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000050 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 00 18 |................| +00000060 00 16 00 00 00 17 00 00 |........| >>> Flow 2 (server to client) 00000000 16 03 01 00 31 02 00 00 2d 03 01 00 00 00 00 00 |....1...-.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2f 00 00 |............./..| +00000020 00 00 00 44 4f 57 4e 47 52 44 00 00 00 2f 00 00 |...DOWNGRD.../..| 00000030 05 ff 01 00 01 00 16 03 01 02 59 0b 00 02 55 00 |..........Y...U.| 00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -47,29 +50,29 @@ 00000280 b3 3e c0 d1 bd 42 d4 db fe 3d 13 60 84 5c 21 d3 |.>...B...=.`.\!.| 00000290 3b e9 fa e7 16 03 01 00 04 0e 00 00 00 |;............| >>> Flow 3 (client to server) -00000000 16 03 01 00 86 10 00 00 82 00 80 9c a1 18 77 22 |..............w"| -00000010 f5 a1 cf 4d cc df 27 7c c5 7e 98 24 24 be 2f b2 |...M..'|.~.$$./.| -00000020 1d d7 b8 2f fe 90 73 d0 fc f6 88 3c 91 a4 bc dc |.../..s....<....| -00000030 b9 0b 48 0d 55 e5 9f c1 8a 6c 1c 7d 4d a9 12 d5 |..H.U....l.}M...| -00000040 87 4b 9a 77 74 3d 33 8c c7 17 fb 32 09 df 86 f1 |.K.wt=3....2....| -00000050 93 cc 17 f9 08 bd bc 0e 38 df 9d 82 ad cc 70 0c |........8.....p.| -00000060 f5 8b 8d 99 e8 5f 3e e5 a6 c7 c2 6a 67 02 90 82 |....._>....jg...| -00000070 28 9a 72 e1 3e 77 51 10 84 29 21 09 56 36 f2 6a |(.r.>wQ..)!.V6.j| -00000080 1d 15 08 7b 44 41 43 59 55 8d 52 14 03 01 00 01 |...{DACYU.R.....| -00000090 01 16 03 01 00 30 06 5b 20 42 7e 7b 1f 4b 7c 36 |.....0.[ B~{.K|6| -000000a0 99 bb c6 b4 ea a1 19 3e 02 0c 3b 3a 38 be 80 11 |.......>..;:8...| -000000b0 29 72 a8 12 92 ad 24 9d bf 01 3e ef 9a f1 db 33 |)r....$...>....3| -000000c0 3e c1 dc d2 51 b1 |>...Q.| +00000000 16 03 01 00 86 10 00 00 82 00 80 95 ba 78 12 0e |.............x..| +00000010 c1 98 6b 93 f6 7d bd f4 8c 77 de 0a 0a 2a 6e 25 |..k..}...w...*n%| +00000020 18 a9 eb 41 c2 c0 63 26 82 7a ea 84 ad cc e8 e2 |...A..c&.z......| +00000030 d8 f1 20 e4 fb 39 87 b8 47 f3 8a 6c 9f b6 08 13 |.. ..9..G..l....| +00000040 b0 76 99 65 cf 68 87 c4 e7 54 ff 6d 5f 81 f2 9f |.v.e.h...T.m_...| +00000050 57 1d 21 e8 ed aa 50 17 e7 85 a5 74 6e 9c cc 84 |W.!...P....tn...| +00000060 bb 06 11 ec 67 8b dc cd 7a 31 4c 08 f4 16 5f d5 |....g...z1L..._.| +00000070 07 0d 17 aa 00 56 51 6a 4c f5 9d 81 40 27 77 45 |.....VQjL...@'wE| +00000080 78 4d 68 6d 96 f7 28 c8 bd 18 b1 14 03 01 00 01 |xMhm..(.........| +00000090 01 16 03 01 00 30 df 7f 74 cd e8 0f 09 06 dd a5 |.....0..t.......| +000000a0 84 46 db ad 71 85 1a 0d e5 f1 d2 f0 2a b2 ef bb |.F..q.......*...| +000000b0 0b 79 88 ab ad 39 6d 4b 16 ae 0e 07 9b 9c 3a ea |.y...9mK......:.| +000000c0 b9 4b 8a 4b 73 06 |.K.Ks.| >>> Flow 4 (server to client) -00000000 14 03 01 00 01 01 16 03 01 00 30 2e d5 04 91 6d |..........0....m| -00000010 32 12 8b 41 4a 46 2c f3 7f d4 16 0a 21 c2 ac 88 |2..AJF,.....!...| -00000020 09 a0 b5 0d 65 4e 44 e1 92 5a ae b8 3f 61 1f 35 |....eND..Z..?a.5| -00000030 ab 3a fe bd f8 3c 2c 42 dd 68 0f 17 03 01 00 20 |.:...<,B.h..... | -00000040 6e d4 08 98 bf b7 18 84 ee 68 f8 17 88 c5 13 7a |n........h.....z| -00000050 73 e0 c6 ca 0d 21 4d 6b 44 dc 94 36 6c e4 a0 2f |s....!MkD..6l../| -00000060 17 03 01 00 30 a0 45 d0 88 5d 96 48 26 46 37 33 |....0.E..].H&F73| -00000070 f6 48 f3 38 2e 38 d7 b6 ef d5 25 bf f3 1b b6 78 |.H.8.8....%....x| -00000080 32 a7 9c fe be 55 35 f2 07 5b b7 14 87 89 80 f2 |2....U5..[......| -00000090 cc d5 cb c8 57 15 03 01 00 20 80 2a 8e 6c b8 5a |....W.... .*.l.Z| -000000a0 41 b4 ae 56 ca 3f 8b a2 e1 ea a0 55 64 b5 60 44 |A..V.?.....Ud.`D| -000000b0 8f de 33 c6 37 f7 df b5 d9 c3 |..3.7.....| +00000000 14 03 01 00 01 01 16 03 01 00 30 cd 95 e4 10 a8 |..........0.....| +00000010 1b dd 36 80 7c 9e 04 23 4c 23 57 0a 57 cf 9a 2e |..6.|..#L#W.W...| +00000020 07 6d 81 b0 27 f8 5c cc 3b a8 80 40 38 be e0 27 |.m..'.\.;..@8..'| +00000030 25 ed f2 7d b9 5e a0 76 68 f8 06 17 03 01 00 20 |%..}.^.vh...... | +00000040 9c 12 9d 3b a0 e5 04 8b 78 44 bc 80 68 22 2b 4c |...;....xD..h"+L| +00000050 64 f1 ca 5c 83 eb 27 e7 29 ad cc 7d d5 e6 ec 1d |d..\..'.)..}....| +00000060 17 03 01 00 30 6e 42 31 b0 3d 46 7d e6 08 8c 43 |....0nB1.=F}...C| +00000070 ea 48 53 34 29 b4 6e ac 2e c4 1f a3 fb fa 70 d5 |.HS4).n.......p.| +00000080 36 9b 94 4f 6f 3f 00 fa e3 f4 4b e6 b3 f2 0d e2 |6..Oo?....K.....| +00000090 0f 60 e4 34 4d 15 03 01 00 20 21 a1 22 a3 e1 71 |.`.4M.... !."..q| +000000a0 ab 28 89 7c 12 ed 12 f7 3e 8a 9a 0e c0 f5 2b 2e |.(.|....>.....+.| +000000b0 91 bd 3f 05 ff 48 1c 3c b5 af |..?..H.<..| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv10-RSA-RC4 b/libgo/go/crypto/tls/testdata/Server-TLSv10-RSA-RC4 index 3d788c35d23..cbf41d5c3a1 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv10-RSA-RC4 +++ b/libgo/go/crypto/tls/testdata/Server-TLSv10-RSA-RC4 @@ -1,12 +1,15 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 39 01 00 00 35 03 01 71 34 00 f7 c4 |....9...5..q4...| -00000010 e6 94 b4 ca f2 af d5 0a 82 ce d4 f6 b7 4a a7 d1 |.............J..| -00000020 1a 88 65 b2 3c b2 6c ec f7 eb 4a 00 00 04 00 05 |..e.<.l...J.....| -00000030 00 ff 01 00 00 08 00 16 00 00 00 17 00 00 |..............| +00000000 16 03 01 00 63 01 00 00 5f 03 01 79 6a d2 2d 89 |....c..._..yj.-.| +00000010 ce 1b 74 2f fd 6b ea e2 2d 21 56 0d e9 37 ce b9 |..t/.k..-!V..7..| +00000020 bc 96 ef 0c 71 66 7a 3b 13 3a 6b 00 00 04 00 05 |....qfz;.:k.....| +00000030 00 ff 01 00 00 32 00 00 00 0e 00 0c 00 00 09 31 |.....2.........1| +00000040 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000050 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 00 18 |................| +00000060 00 16 00 00 00 17 00 00 |........| >>> Flow 2 (server to client) 00000000 16 03 01 00 31 02 00 00 2d 03 01 00 00 00 00 00 |....1...-.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 05 00 00 |................| +00000020 00 00 00 44 4f 57 4e 47 52 44 00 00 00 05 00 00 |...DOWNGRD......| 00000030 05 ff 01 00 01 00 16 03 01 02 59 0b 00 02 55 00 |..........Y...U.| 00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -47,23 +50,23 @@ 00000280 b3 3e c0 d1 bd 42 d4 db fe 3d 13 60 84 5c 21 d3 |.>...B...=.`.\!.| 00000290 3b e9 fa e7 16 03 01 00 04 0e 00 00 00 |;............| >>> Flow 3 (client to server) -00000000 16 03 01 00 86 10 00 00 82 00 80 a5 75 5a 20 2c |............uZ ,| -00000010 31 f7 61 dc 73 c7 f6 4c 06 d2 b9 c0 e8 5f cc 0c |1.a.s..L....._..| -00000020 51 70 0a 30 b2 8a bb 3b 4c 37 f6 d3 38 da 13 48 |Qp.0...;L7..8..H| -00000030 90 4f fe 41 ec 53 3c fb 07 26 77 68 07 a0 fb 71 |.O.A.S<..&wh...q| -00000040 b6 cc 3c cd b4 64 03 08 3a 76 97 6e 6c f1 b4 a9 |..<..d..:v.nl...| -00000050 af f4 e0 ce bf 36 b9 8e 37 12 de 5b ac 24 06 63 |.....6..7..[.$.c| -00000060 e2 fb 13 33 be 3b 8d 93 e3 10 95 29 21 b2 22 77 |...3.;.....)!."w| -00000070 cb 95 b2 13 b3 76 47 98 13 1b a8 cc 50 47 ed 50 |.....vG.....PG.P| -00000080 f0 cc ca 5a c6 a0 1e c9 9c 97 58 14 03 01 00 01 |...Z......X.....| -00000090 01 16 03 01 00 24 e7 fd a2 7e fd 6f 53 da 29 68 |.....$...~.oS.)h| -000000a0 c3 49 2e e9 69 a1 94 b9 e4 a0 cb a2 94 14 a6 42 |.I..i..........B| -000000b0 df 75 1e da 95 e5 60 e3 35 f1 |.u....`.5.| +00000000 16 03 01 00 86 10 00 00 82 00 80 d4 da 80 53 5a |..............SZ| +00000010 4c fc 0b c3 91 a0 b4 91 24 5a 6b 59 01 fa 05 52 |L.......$ZkY...R| +00000020 cb 37 8c de 51 58 d7 ac 24 e2 d3 ac ad e6 00 0f |.7..QX..$.......| +00000030 72 50 a4 81 c3 18 ef f9 cb 0f 8b 6a cd e5 0e 46 |rP.........j...F| +00000040 9a f1 3c 61 ed 31 d4 c0 35 61 14 1e e8 b5 0c b2 |..>> Flow 4 (server to client) -00000000 14 03 01 00 01 01 16 03 01 00 24 44 a6 c8 7b 5f |..........$D..{_| -00000010 b9 4e c2 62 2d e0 c3 9f 76 0f b3 e5 f5 07 b7 c0 |.N.b-...v.......| -00000020 93 cd 1f 32 3c 0a 7a 83 57 4a 24 59 ac 95 f9 17 |...2<.z.WJ$Y....| -00000030 03 01 00 21 6f 02 76 2e 70 82 a0 6c 11 ce 3c b8 |...!o.v.p..l..<.| -00000040 dd d3 9e 2a ee ce d7 7f 63 1a 5b 35 d0 46 68 7d |...*....c.[5.Fh}| -00000050 21 6e 5b 64 fc 15 03 01 00 16 81 56 32 7d 51 e4 |!n[d.......V2}Q.| -00000060 08 53 85 45 65 c3 87 ac b0 58 70 4f 6f f7 64 4e |.S.Ee....XpOo.dN| +00000000 14 03 01 00 01 01 16 03 01 00 24 0a 1c be 60 96 |..........$...`.| +00000010 78 67 15 22 ac 38 39 87 80 f5 69 2b 08 32 01 23 |xg.".89...i+.2.#| +00000020 e0 96 b3 89 8c 57 5f e4 27 33 66 90 b9 47 bc 17 |.....W_.'3f..G..| +00000030 03 01 00 21 fd 10 f3 e3 e6 14 bf b2 72 ab f0 bb |...!........r...| +00000040 11 04 54 da cd 93 03 14 78 2c 26 32 44 2c 0c e8 |..T.....x,&2D,..| +00000050 7e 56 25 83 0f 15 03 01 00 16 0c 26 07 14 19 aa |~V%........&....| +00000060 7e 78 bf 39 96 07 44 3d a9 c6 50 7d dc c9 de f5 |~x.9..D=..P}....| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv11-FallbackSCSV b/libgo/go/crypto/tls/testdata/Server-TLSv11-FallbackSCSV index 209e6216cfd..7bd034105ec 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv11-FallbackSCSV +++ b/libgo/go/crypto/tls/testdata/Server-TLSv11-FallbackSCSV @@ -1,10 +1,11 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 63 01 00 00 5f 03 02 6e 78 cc 6a ea |....c..._..nx.j.| -00000010 13 aa a8 20 76 7d 32 ca c7 3f be 88 36 ae fb c3 |... v}2..?..6...| -00000020 ca 95 35 70 54 20 3b 18 3b ba 82 00 00 14 c0 0a |..5pT ;.;.......| +00000000 16 03 01 00 77 01 00 00 73 03 02 0a 6b c9 55 9d |....w...s...k.U.| +00000010 bf 4e 61 b2 0a c7 c6 96 9f eb 90 91 87 ca d3 d3 |.Na.............| +00000020 62 dc b6 b4 db ea 41 fe 43 3e a3 00 00 14 c0 0a |b.....A.C>......| 00000030 c0 14 00 39 c0 09 c0 13 00 33 00 35 00 2f 00 ff |...9.....3.5./..| -00000040 56 00 01 00 00 22 00 0b 00 04 03 00 01 02 00 0a |V...."..........| -00000050 00 0a 00 08 00 1d 00 17 00 19 00 18 00 23 00 00 |.............#..| -00000060 00 16 00 00 00 17 00 00 |........| +00000040 56 00 01 00 00 36 00 00 00 0e 00 0c 00 00 09 31 |V....6.........1| +00000050 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000060 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 00 18 |................| +00000070 00 23 00 00 00 16 00 00 00 17 00 00 |.#..........| >>> Flow 2 (server to client) 00000000 15 03 02 00 02 02 56 |......V| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv11-RSA-RC4 b/libgo/go/crypto/tls/testdata/Server-TLSv11-RSA-RC4 index 18debc470ce..22e2291c54b 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv11-RSA-RC4 +++ b/libgo/go/crypto/tls/testdata/Server-TLSv11-RSA-RC4 @@ -1,12 +1,15 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 39 01 00 00 35 03 02 15 67 73 bf 3f |....9...5...gs.?| -00000010 6f 15 30 c2 34 2e c6 1b 23 3a 42 45 4d d9 87 a2 |o.0.4...#:BEM...| -00000020 e7 b8 de 1c b8 2b cc 21 7a 0b a1 00 00 04 00 05 |.....+.!z.......| -00000030 00 ff 01 00 00 08 00 16 00 00 00 17 00 00 |..............| +00000000 16 03 01 00 63 01 00 00 5f 03 02 ea cf 4a b4 40 |....c..._....J.@| +00000010 33 f1 d3 b2 c1 2a f6 d6 bb 3f 48 8c 1a d2 40 0f |3....*...?H...@.| +00000020 4a 1e e8 07 8a 06 19 45 6a 02 cb 00 00 04 00 05 |J......Ej.......| +00000030 00 ff 01 00 00 32 00 00 00 0e 00 0c 00 00 09 31 |.....2.........1| +00000040 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000050 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 00 18 |................| +00000060 00 16 00 00 00 17 00 00 |........| >>> Flow 2 (server to client) 00000000 16 03 02 00 31 02 00 00 2d 03 02 00 00 00 00 00 |....1...-.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 05 00 00 |................| +00000020 00 00 00 44 4f 57 4e 47 52 44 00 00 00 05 00 00 |...DOWNGRD......| 00000030 05 ff 01 00 01 00 16 03 02 02 59 0b 00 02 55 00 |..........Y...U.| 00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -47,23 +50,23 @@ 00000280 b3 3e c0 d1 bd 42 d4 db fe 3d 13 60 84 5c 21 d3 |.>...B...=.`.\!.| 00000290 3b e9 fa e7 16 03 02 00 04 0e 00 00 00 |;............| >>> Flow 3 (client to server) -00000000 16 03 02 00 86 10 00 00 82 00 80 75 8e 85 93 be |...........u....| -00000010 53 df e0 4f 65 92 ed 3d 58 34 f8 06 fd 36 e4 5a |S..Oe..=X4...6.Z| -00000020 f7 7a 59 88 f6 ac bd de 21 ed c4 04 0d 35 19 cd |.zY.....!....5..| -00000030 ff 3b 9f c4 bc 93 4f 21 2a 36 a3 99 a4 6f eb 1e |.;....O!*6...o..| -00000040 7b b4 a8 a7 6d 69 a5 93 b6 e3 d2 2d be 7a c8 f3 |{...mi.....-.z..| -00000050 9f 25 9e f9 51 75 d9 4f 05 41 0e 17 56 31 4e 3f |.%..Qu.O.A..V1N?| -00000060 c0 15 d8 c4 29 4d e5 92 f9 ed 50 b6 88 f1 41 ea |....)M....P...A.| -00000070 cb 5a 8c 50 12 78 16 e7 21 b6 11 ca 2c 49 cf b6 |.Z.P.x..!...,I..| -00000080 d2 1a 16 28 f7 08 b5 c9 61 e0 18 14 03 02 00 01 |...(....a.......| -00000090 01 16 03 02 00 24 a1 cf 1b 5d dc 4c 9c 2c d7 39 |.....$...].L.,.9| -000000a0 af 13 e9 04 48 c0 2a aa 6f 3a 9c fb 9e 0a 25 55 |....H.*.o:....%U| -000000b0 7e 82 3d 1b 78 d1 e3 e0 f5 30 |~.=.x....0| +00000000 16 03 02 00 86 10 00 00 82 00 80 a2 98 fb e6 12 |................| +00000010 7d 1c 3c de 04 9c 01 11 41 69 a4 e3 74 62 88 36 |}.<.....Ai..tb.6| +00000020 97 b5 28 14 6a 6d 27 1b 7d 27 0f fd 5b 76 07 3f |..(.jm'.}'..[v.?| +00000030 3e 99 21 93 46 9d 2c a0 4c d9 54 25 70 11 b8 ac |>.!.F.,.L.T%p...| +00000040 8e 5c 29 31 2c b2 39 92 10 32 dc b0 60 af 2e d4 |.\)1,.9..2..`...| +00000050 b3 f7 ba 44 0a 6c e2 4b 38 18 4b 51 60 1b a5 0d |...D.l.K8.KQ`...| +00000060 bf ec 00 fb fd 53 1f 6e b5 eb cd 32 1b 15 e9 ea |.....S.n...2....| +00000070 5c 93 72 dc 67 94 39 ed 2d 1e 6f f9 10 da 79 50 |\.r.g.9.-.o...yP| +00000080 e1 d2 db 6f 34 38 d1 fb 2c 38 cb 14 03 02 00 01 |...o48..,8......| +00000090 01 16 03 02 00 24 b4 29 aa 9d 48 a3 59 07 f8 a8 |.....$.)..H.Y...| +000000a0 f0 aa aa 0f 63 dd 0e ca d6 20 45 6d 88 ba 52 e2 |....c.... Em..R.| +000000b0 f9 cd 2f 25 d3 88 b1 a6 cf 9d |../%......| >>> Flow 4 (server to client) -00000000 14 03 02 00 01 01 16 03 02 00 24 7b 68 71 56 0f |..........${hqV.| -00000010 a5 46 1c 13 34 81 b5 b6 ba 29 fb 41 46 dc fe 78 |.F..4....).AF..x| -00000020 cc 0b 2d 75 bd fe c1 55 45 b1 fc 04 28 5e b1 17 |..-u...UE...(^..| -00000030 03 02 00 21 0b fa a9 2f 9e 82 5b 77 30 c2 27 88 |...!.../..[w0.'.| -00000040 f5 f3 50 47 7b 62 4c 7a d4 07 71 74 46 da 24 de |..PG{bLz..qtF.$.| -00000050 bf 3f 56 a7 9b 15 03 02 00 16 85 26 8a 89 33 21 |.?V........&..3!| -00000060 36 ce 69 83 84 50 fc 8f 99 b3 43 ad 6b 14 1e b2 |6.i..P....C.k...| +00000000 14 03 02 00 01 01 16 03 02 00 24 cc 9a e8 46 cc |..........$...F.| +00000010 e5 45 8c f6 aa 71 28 f7 1b 2a 51 f8 33 c3 08 a3 |.E...q(..*Q.3...| +00000020 cd 72 7d 38 a9 d1 6f b8 c6 ce ef ae 4f 3d 50 17 |.r}8..o.....O=P.| +00000030 03 02 00 21 e1 9b 1e f6 56 28 6d 78 53 96 a4 41 |...!....V(mxS..A| +00000040 7b a8 15 29 74 40 b5 f4 d3 ae b7 8b b2 01 53 dd |{..)t@........S.| +00000050 45 bf 3a 55 9d 15 03 02 00 16 cb a8 cb 98 ac 0d |E.:U............| +00000060 1c eb aa c4 2a 71 65 aa b4 c9 d7 90 f7 88 3b b0 |....*qe.......;.| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv12-ALPN b/libgo/go/crypto/tls/testdata/Server-TLSv12-ALPN index f2e7eb7b13b..ec9bf724362 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv12-ALPN +++ b/libgo/go/crypto/tls/testdata/Server-TLSv12-ALPN @@ -1,21 +1,23 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 bf 01 00 00 bb 03 03 dc d0 a1 64 e2 |..............d.| -00000010 38 c3 1c 2b 8c fc d4 e9 25 b7 20 01 fb 72 37 8f |8..+....%. ..r7.| -00000020 1b da 7b ec 74 f3 20 c4 78 eb 15 00 00 38 c0 2c |..{.t. .x....8.,| +00000000 16 03 01 00 e3 01 00 00 df 03 03 2d 48 5c c5 05 |...........-H\..| +00000010 19 52 14 d8 ed 53 5d 30 50 4d 3a ae d9 58 53 96 |.R...S]0PM:..XS.| +00000020 0a ce fb 18 ed ef f1 57 fe 42 75 00 00 38 c0 2c |.......W.Bu..8.,| 00000030 c0 30 00 9f cc a9 cc a8 cc aa c0 2b c0 2f 00 9e |.0.........+./..| 00000040 c0 24 c0 28 00 6b c0 23 c0 27 00 67 c0 0a c0 14 |.$.(.k.#.'.g....| 00000050 00 39 c0 09 c0 13 00 33 00 9d 00 9c 00 3d 00 3c |.9.....3.....=.<| -00000060 00 35 00 2f 00 ff 01 00 00 5a 00 0b 00 04 03 00 |.5./.....Z......| -00000070 01 02 00 0a 00 0a 00 08 00 1d 00 17 00 19 00 18 |................| -00000080 00 23 00 00 00 0d 00 20 00 1e 06 01 06 02 06 03 |.#..... ........| -00000090 05 01 05 02 05 03 04 01 04 02 04 03 03 01 03 02 |................| -000000a0 03 03 02 01 02 02 02 03 00 10 00 10 00 0e 06 70 |...............p| -000000b0 72 6f 74 6f 32 06 70 72 6f 74 6f 31 00 16 00 00 |roto2.proto1....| -000000c0 00 17 00 00 |....| +00000060 00 35 00 2f 00 ff 01 00 00 7e 00 00 00 0e 00 0c |.5./.....~......| +00000070 00 00 09 31 32 37 2e 30 2e 30 2e 31 00 0b 00 04 |...127.0.0.1....| +00000080 03 00 01 02 00 0a 00 0c 00 0a 00 1d 00 17 00 1e |................| +00000090 00 19 00 18 00 23 00 00 00 10 00 10 00 0e 06 70 |.....#.........p| +000000a0 72 6f 74 6f 32 06 70 72 6f 74 6f 31 00 16 00 00 |roto2.proto1....| +000000b0 00 17 00 00 00 0d 00 30 00 2e 04 03 05 03 06 03 |.......0........| +000000c0 08 07 08 08 08 09 08 0a 08 0b 08 04 08 05 08 06 |................| +000000d0 04 01 05 01 06 01 03 03 02 03 03 01 02 01 03 02 |................| +000000e0 02 02 04 02 05 02 06 02 |........| >>> Flow 2 (server to client) 00000000 16 03 03 00 42 02 00 00 3e 03 03 00 00 00 00 00 |....B...>.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 c0 30 00 00 |.............0..| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 c0 30 00 00 |...DOWNGRD...0..| 00000030 16 00 23 00 00 ff 01 00 01 00 00 10 00 09 00 07 |..#.............| 00000040 06 70 72 6f 74 6f 31 16 03 03 02 59 0b 00 02 55 |.proto1....Y...U| 00000050 00 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 |..R..O0..K0.....| @@ -58,37 +60,37 @@ 000002a0 d3 3b e9 fa e7 16 03 03 00 ac 0c 00 00 a8 03 00 |.;..............| 000002b0 1d 20 2f e5 7d a3 47 cd 62 43 15 28 da ac 5f bb |. /.}.G.bC.(.._.| 000002c0 29 07 30 ff f6 84 af c4 cf c2 ed 90 99 5f 58 cb |).0.........._X.| -000002d0 3b 74 06 01 00 80 54 89 2f 46 ff 41 c2 56 47 33 |;t....T./F.A.VG3| -000002e0 fa d6 91 64 47 df 46 89 75 73 6d 84 c6 8a 54 f8 |...dG.F.usm...T.| -000002f0 80 34 55 00 34 8d 64 ab 72 94 6e e9 e6 18 a1 e9 |.4U.4.d.r.n.....| -00000300 15 00 f5 2a 84 9f 22 95 c5 a3 17 91 b3 36 3a 9c |...*.."......6:.| -00000310 b9 65 54 bd 03 29 69 1a 5b 44 bd 1f c1 16 5a 7d |.eT..)i.[D....Z}| -00000320 53 35 8c c3 28 5f 3c ac 71 d2 bc c7 86 82 08 e7 |S5..(_<.q.......| -00000330 72 22 1f 98 68 5d a7 0e 8b 2c 6c 80 b9 36 79 4a |r"..h]...,l..6yJ| -00000340 f2 64 c1 14 8b b2 61 a8 c2 ca 83 44 e9 5a f8 fb |.d....a....D.Z..| -00000350 6d 67 b4 d6 7e fa 16 03 03 00 04 0e 00 00 00 |mg..~..........| +000002d0 3b 74 08 04 00 80 0a 5e 25 64 2c 25 6d 9d 7d da |;t.....^%d,%m.}.| +000002e0 18 0a 9b ff c7 6a 0b 89 ed f8 96 00 70 6f ab 35 |.....j......po.5| +000002f0 d3 3b 56 cc a1 78 c8 60 4e 50 12 1a 59 02 d9 4c |.;V..x.`NP..Y..L| +00000300 07 21 03 65 62 9c a4 06 2d ce 34 68 c8 01 57 f1 |.!.eb...-.4h..W.| +00000310 b5 33 a0 00 72 9f e8 46 87 7c 18 65 e2 2a 18 5e |.3..r..F.|.e.*.^| +00000320 d3 9d 60 bc cf b8 38 10 2d 21 c0 9e 2c 5d 89 4c |..`...8.-!..,].L| +00000330 93 27 02 6b 5a 04 02 60 b0 f0 3f 7c 54 aa 9a f1 |.'.kZ..`..?|T...| +00000340 30 10 50 31 36 0e 87 0c 86 29 53 92 3b 91 24 72 |0.P16....)S.;.$r| +00000350 79 6d 5c 09 15 19 16 03 03 00 04 0e 00 00 00 |ym\............| >>> Flow 3 (client to server) -00000000 16 03 03 00 25 10 00 00 21 20 61 b6 16 25 fb ca |....%...! a..%..| -00000010 39 11 1b 39 91 0f ad a0 1b 53 cb 23 3a 8b 4c bf |9..9.....S.#:.L.| -00000020 c3 95 b7 fa 74 2c 44 55 d3 3b 14 03 03 00 01 01 |....t,DU.;......| -00000030 16 03 03 00 28 2a f0 0e a4 54 25 0c 3f 46 9e d4 |....(*...T%.?F..| -00000040 32 63 db 36 71 11 9d 63 57 d5 5d e6 70 86 01 f8 |2c.6q..cW.].p...| -00000050 2f 8e 79 65 b7 39 4f 31 a9 f5 a5 70 9a |/.ye.9O1...p.| +00000000 16 03 03 00 25 10 00 00 21 20 2e 56 a8 73 0e 9c |....%...! .V.s..| +00000010 90 0d aa 07 77 a8 09 17 61 e2 11 5c 3a f6 33 6d |....w...a..\:.3m| +00000020 be 6b 08 77 8a 0d eb 68 2f 21 14 03 03 00 01 01 |.k.w...h/!......| +00000030 16 03 03 00 28 a7 07 30 a2 67 4f 2d 2f 5f 52 7c |....(..0.gO-/_R|| +00000040 11 81 d0 ea 37 51 73 8a fc 35 fc 58 b2 e6 6b b7 |....7Qs..5.X..k.| +00000050 66 a9 f0 cf 16 e7 31 b6 83 58 d3 e4 58 |f.....1..X..X| >>> Flow 4 (server to client) 00000000 16 03 03 00 82 04 00 00 7e 00 00 00 00 00 78 50 |........~.....xP| 00000010 46 ad c1 db a8 38 86 7b 2b bb fd d0 c3 42 3e 00 |F....8.{+....B>.| 00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 94 |................| -00000030 6f ec 80 83 61 19 68 1a 40 8c 4c 8f 85 a2 2e fa |o...a.h.@.L.....| -00000040 3f b5 7c 5f 46 d1 fa 20 23 89 e7 e6 d6 82 6f 78 |?.|_F.. #.....ox| -00000050 5b 28 32 89 60 4a e7 22 51 9a 13 f5 0e 82 9c 1e |[(2.`J."Q.......| -00000060 29 e1 2a 91 62 33 94 51 e1 bf b8 99 2a 20 e6 87 |).*.b3.Q....* ..| -00000070 c4 1f 65 fe 7e 6e 0e 33 7f 77 f9 33 0c 9d 05 df |..e.~n.3.w.3....| -00000080 e5 7d 2c db cc 48 f6 14 03 03 00 01 01 16 03 03 |.},..H..........| -00000090 00 28 00 00 00 00 00 00 00 00 91 05 0e 09 9f b6 |.(..............| -000000a0 e1 48 98 28 ae 68 0a 89 9f a7 47 1b 67 d5 8c 0a |.H.(.h....G.g...| -000000b0 3c 4f da 1e 4f 3f 13 80 cd a5 17 03 03 00 25 00 |>> Flow 1 (client to server) -00000000 16 03 01 00 bf 01 00 00 bb 03 03 12 5f 10 32 01 |............_.2.| -00000010 84 0f 82 05 7e ca 97 58 65 65 d5 ad d3 94 e4 88 |....~..Xee......| -00000020 e9 15 91 0a 2c 99 55 ca ae 18 aa 00 00 38 c0 2c |....,.U......8.,| +00000000 16 03 01 00 e3 01 00 00 df 03 03 fc a5 8d 79 5f |..............y_| +00000010 01 7f 77 df 86 0f 60 10 0a 88 ad 68 7f 7b 3b 63 |..w...`....h.{;c| +00000020 46 a9 7e c6 4e 7c 47 b5 00 2f a7 00 00 38 c0 2c |F.~.N|G../...8.,| 00000030 c0 30 00 9f cc a9 cc a8 cc aa c0 2b c0 2f 00 9e |.0.........+./..| 00000040 c0 24 c0 28 00 6b c0 23 c0 27 00 67 c0 0a c0 14 |.$.(.k.#.'.g....| 00000050 00 39 c0 09 c0 13 00 33 00 9d 00 9c 00 3d 00 3c |.9.....3.....=.<| -00000060 00 35 00 2f 00 ff 01 00 00 5a 00 0b 00 04 03 00 |.5./.....Z......| -00000070 01 02 00 0a 00 0a 00 08 00 1d 00 17 00 19 00 18 |................| -00000080 00 23 00 00 00 0d 00 20 00 1e 06 01 06 02 06 03 |.#..... ........| -00000090 05 01 05 02 05 03 04 01 04 02 04 03 03 01 03 02 |................| -000000a0 03 03 02 01 02 02 02 03 00 10 00 10 00 0e 06 70 |...............p| -000000b0 72 6f 74 6f 32 06 70 72 6f 74 6f 31 00 16 00 00 |roto2.proto1....| -000000c0 00 17 00 00 |....| +00000060 00 35 00 2f 00 ff 01 00 00 7e 00 00 00 0e 00 0c |.5./.....~......| +00000070 00 00 09 31 32 37 2e 30 2e 30 2e 31 00 0b 00 04 |...127.0.0.1....| +00000080 03 00 01 02 00 0a 00 0c 00 0a 00 1d 00 17 00 1e |................| +00000090 00 19 00 18 00 23 00 00 00 10 00 10 00 0e 06 70 |.....#.........p| +000000a0 72 6f 74 6f 32 06 70 72 6f 74 6f 31 00 16 00 00 |roto2.proto1....| +000000b0 00 17 00 00 00 0d 00 30 00 2e 04 03 05 03 06 03 |.......0........| +000000c0 08 07 08 08 08 09 08 0a 08 0b 08 04 08 05 08 06 |................| +000000d0 04 01 05 01 06 01 03 03 02 03 03 01 02 01 03 02 |................| +000000e0 02 02 04 02 05 02 06 02 |........| >>> Flow 2 (server to client) 00000000 16 03 03 00 35 02 00 00 31 03 03 00 00 00 00 00 |....5...1.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 c0 30 00 00 |.............0..| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 c0 30 00 00 |...DOWNGRD...0..| 00000030 09 00 23 00 00 ff 01 00 01 00 16 03 03 02 59 0b |..#...........Y.| 00000040 00 02 55 00 02 52 00 02 4f 30 82 02 4b 30 82 01 |..U..R..O0..K0..| 00000050 b4 a0 03 02 01 02 02 09 00 e8 f0 9d 3f e2 5b ea |............?.[.| @@ -57,38 +59,38 @@ 00000290 84 5c 21 d3 3b e9 fa e7 16 03 03 00 ac 0c 00 00 |.\!.;...........| 000002a0 a8 03 00 1d 20 2f e5 7d a3 47 cd 62 43 15 28 da |.... /.}.G.bC.(.| 000002b0 ac 5f bb 29 07 30 ff f6 84 af c4 cf c2 ed 90 99 |._.).0..........| -000002c0 5f 58 cb 3b 74 06 01 00 80 50 95 28 ab df d3 74 |_X.;t....P.(...t| -000002d0 7a 9b 7a d8 d2 31 34 87 75 29 a9 d0 fd 3c e4 be |z.z..14.u)...<..| -000002e0 59 e6 60 52 39 9f 8e 9d e3 1c 1d 75 47 b0 86 57 |Y.`R9......uG..W| -000002f0 3f e1 a8 a5 72 21 1a 22 49 61 71 83 20 76 8c b6 |?...r!."Iaq. v..| -00000300 e4 c4 99 de 4e 9c f6 22 df 8d 92 1e a9 c7 0e 83 |....N.."........| -00000310 d2 93 a9 2d 9b 74 f8 1b 1b 2f 1e 71 b6 7c d0 99 |...-.t.../.q.|..| -00000320 a3 d2 95 45 87 36 28 be 0a 26 53 89 77 6b b6 e4 |...E.6(..&S.wk..| -00000330 f9 3a 82 7c 67 81 08 22 cf 3a 94 83 68 29 f3 a5 |.:.|g..".:..h)..| -00000340 67 b4 95 77 0f fb 06 da 5f 16 03 03 00 04 0e 00 |g..w...._.......| +000002c0 5f 58 cb 3b 74 08 04 00 80 62 db d2 f4 17 c6 f2 |_X.;t....b......| +000002d0 73 d1 63 50 1f 26 96 af 9d bd cb 11 9a 95 c4 dd |s.cP.&..........| +000002e0 49 c3 9a 06 a3 8d 2a 1e b9 74 76 22 36 2e fd 08 |I.....*..tv"6...| +000002f0 a6 d1 9d 2e 20 75 e6 50 59 49 db 3f d9 b1 0e 81 |.... u.PYI.?....| +00000300 fb 16 25 67 0d 8b 1c af 35 95 59 d4 56 b2 9f 08 |..%g....5.Y.V...| +00000310 fd 85 68 46 30 59 2b 66 9e 86 b4 35 4c 4a 9f 6f |..hF0Y+f...5LJ.o| +00000320 8f 2b 8d 9f 19 c2 9a 4e 91 6e fe 56 cc 9b 39 e7 |.+.....N.n.V..9.| +00000330 8d e2 5e 07 55 16 76 e0 7f 8b aa 0e 36 94 9f 78 |..^.U.v.....6..x| +00000340 bd 06 a2 65 a3 f5 83 04 97 16 03 03 00 04 0e 00 |...e............| 00000350 00 00 |..| >>> Flow 3 (client to server) -00000000 16 03 03 00 25 10 00 00 21 20 a4 d7 31 f0 60 aa |....%...! ..1.`.| -00000010 97 48 1f a8 fb 3c 78 77 5f 90 b3 f7 f2 0c 5e ed |.H....w.r....e......| -00000030 16 03 03 00 28 6d 3e 7f a1 0e 5b ea 24 ee ec 77 |....(m>...[.$..w| -00000040 3c 03 eb cb 5c ad b4 21 b2 c1 9c 5e 4f 36 88 01 |<...\..!...^O6..| -00000050 b6 0c 7c 92 70 70 63 4f d4 e1 98 45 e4 |..|.ppcO...E.| +00000000 16 03 03 00 25 10 00 00 21 20 56 69 9c 58 80 3e |....%...! Vi.X.>| +00000010 72 ee ee b1 05 fd a0 a7 8d 78 9c 5a 7d e0 21 63 |r........x.Z}.!c| +00000020 d4 19 3c e2 b1 72 92 03 ed 6a 14 03 03 00 01 01 |..<..r...j......| +00000030 16 03 03 00 28 6b c0 b3 6e 77 df ef 99 2d 7a 93 |....(k..nw...-z.| +00000040 d5 9d 7f 1e 8c 36 eb 7c bb 32 f9 a1 b0 65 b3 85 |.....6.|.2...e..| +00000050 fb 33 64 9f 73 10 41 5a 01 6f d1 6b 73 |.3d.s.AZ.o.ks| >>> Flow 4 (server to client) 00000000 16 03 03 00 82 04 00 00 7e 00 00 00 00 00 78 50 |........~.....xP| 00000010 46 ad c1 db a8 38 86 7b 2b bb fd d0 c3 42 3e 00 |F....8.{+....B>.| 00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 94 |................| -00000030 6f ec 80 83 61 34 3a 86 15 18 26 50 d0 12 69 5a |o...a4:...&P..iZ| -00000040 8e 67 6a ce 99 67 0a 90 09 d5 ad 29 62 08 9b 29 |.gj..g.....)b..)| -00000050 6c 12 bb d4 74 3c fb 5b dc e5 89 f0 98 93 03 e9 |l...t<.[........| -00000060 2a ea 31 74 0a 33 94 96 49 53 80 c9 3e 9b 53 32 |*.1t.3..IS..>.S2| -00000070 4a 15 31 0e fa 90 bd da af 07 d1 a8 fa 15 e8 df |J.1.............| -00000080 3d f1 d1 7a 21 8c 7a 14 03 03 00 01 01 16 03 03 |=..z!.z.........| -00000090 00 28 00 00 00 00 00 00 00 00 70 0c c0 3b 84 68 |.(........p..;.h| -000000a0 4d e5 7d 54 18 ba 77 3d 8c 20 03 3e 50 69 45 0d |M.}T..w=. .>PiE.| -000000b0 64 a2 0f 1e 4e bf 86 0b 9c 05 17 03 03 00 25 00 |d...N.........%.| -000000c0 00 00 00 00 00 00 01 43 a9 fa 0f e3 5a 86 46 2a |.......C....Z.F*| -000000d0 56 3a 6c d5 88 b7 40 a0 d5 59 45 45 ac 06 5d b0 |V:l...@..YEE..].| -000000e0 d7 c9 ed 00 15 03 03 00 1a 00 00 00 00 00 00 00 |................| -000000f0 02 ce de ef aa b4 47 77 4c f6 e9 fb 67 e8 fb 7f |......GwL...g...| -00000100 c6 05 20 |.. | +00000030 6f ec 80 83 61 59 7e 5a 0d 70 cc 83 b5 c8 ed d4 |o...aY~Z.p......| +00000040 79 ab 28 49 65 f8 52 5f 78 5a 83 1a d4 b6 76 fa |y.(Ie.R_xZ....v.| +00000050 b7 e3 ef 12 48 1b 73 42 18 ee 78 5a 4e 05 70 66 |....H.sB..xZN.pf| +00000060 1a 51 7b 20 e0 33 94 93 4f 86 e2 54 48 67 df 11 |.Q{ .3..O..THg..| +00000070 ca f2 6d 73 d1 06 3b 88 ef af 91 1c f0 fd 64 4f |..ms..;.......dO| +00000080 c8 d7 45 cb cc 90 14 14 03 03 00 01 01 16 03 03 |..E.............| +00000090 00 28 00 00 00 00 00 00 00 00 58 a6 55 c9 de bc |.(........X.U...| +000000a0 04 23 e7 85 cf 8c 44 d1 da ad c2 73 45 3e 42 f0 |.#....D....sE>B.| +000000b0 05 58 7e 7b 35 24 1c 86 93 1e 17 03 03 00 25 00 |.X~{5$........%.| +000000c0 00 00 00 00 00 00 01 c8 90 76 8e 60 ca b3 75 47 |.........v.`..uG| +000000d0 78 f2 5d a8 62 82 10 0f 3c b5 b6 51 d2 0b 40 40 |x.].b...<..Q..@@| +000000e0 66 b4 82 11 15 03 03 00 1a 00 00 00 00 00 00 00 |f...............| +000000f0 02 f4 16 23 56 26 87 e1 22 9f d3 30 e9 fa 99 a5 |...#V&.."..0....| +00000100 f0 5b 2c |.[,| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv12-CipherSuiteCertPreferenceECDSA b/libgo/go/crypto/tls/testdata/Server-TLSv12-CipherSuiteCertPreferenceECDSA index 3a84905c1c5..cbf7564050f 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv12-CipherSuiteCertPreferenceECDSA +++ b/libgo/go/crypto/tls/testdata/Server-TLSv12-CipherSuiteCertPreferenceECDSA @@ -1,19 +1,21 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 a7 01 00 00 a3 03 03 7e 8a c0 04 93 |...........~....| -00000010 7a be 32 5c b3 38 83 b1 ec d0 31 8d a1 61 f3 2b |z.2\.8....1..a.+| -00000020 b2 6a 0d 08 71 41 fb 20 c2 46 0c 00 00 38 c0 2c |.j..qA. .F...8.,| +00000000 16 03 01 00 cb 01 00 00 c7 03 03 7c ce 63 72 4d |...........|.crM| +00000010 0b d9 aa 2f b4 22 f4 e3 88 50 10 11 1a d9 ce 5d |.../."...P.....]| +00000020 db 14 d4 68 61 48 c1 2d 0d ad dd 00 00 38 c0 2c |...haH.-.....8.,| 00000030 c0 30 00 9f cc a9 cc a8 cc aa c0 2b c0 2f 00 9e |.0.........+./..| 00000040 c0 24 c0 28 00 6b c0 23 c0 27 00 67 c0 0a c0 14 |.$.(.k.#.'.g....| 00000050 00 39 c0 09 c0 13 00 33 00 9d 00 9c 00 3d 00 3c |.9.....3.....=.<| -00000060 00 35 00 2f 00 ff 01 00 00 42 00 0b 00 04 03 00 |.5./.....B......| -00000070 01 02 00 0a 00 0a 00 08 00 1d 00 17 00 19 00 18 |................| -00000080 00 0d 00 20 00 1e 06 01 06 02 06 03 05 01 05 02 |... ............| -00000090 05 03 04 01 04 02 04 03 03 01 03 02 03 03 02 01 |................| -000000a0 02 02 02 03 00 16 00 00 00 17 00 00 |............| +00000060 00 35 00 2f 00 ff 01 00 00 66 00 00 00 0e 00 0c |.5./.....f......| +00000070 00 00 09 31 32 37 2e 30 2e 30 2e 31 00 0b 00 04 |...127.0.0.1....| +00000080 03 00 01 02 00 0a 00 0c 00 0a 00 1d 00 17 00 1e |................| +00000090 00 19 00 18 00 16 00 00 00 17 00 00 00 0d 00 30 |...............0| +000000a0 00 2e 04 03 05 03 06 03 08 07 08 08 08 09 08 0a |................| +000000b0 08 0b 08 04 08 05 08 06 04 01 05 01 06 01 03 03 |................| +000000c0 02 03 03 01 02 01 03 02 02 02 04 02 05 02 06 02 |................| >>> Flow 2 (server to client) 00000000 16 03 03 00 31 02 00 00 2d 03 03 00 00 00 00 00 |....1...-.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 c0 0a 00 00 |................| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 c0 0a 00 00 |...DOWNGRD......| 00000030 05 ff 01 00 01 00 16 03 03 02 0e 0b 00 02 0a 00 |................| 00000040 02 07 00 02 04 30 82 02 00 30 82 01 62 02 09 00 |.....0...0..b...| 00000050 b8 bf 2d 47 a0 d2 eb f4 30 09 06 07 2a 86 48 ce |..-G....0...*.H.| @@ -47,39 +49,39 @@ 00000210 0e bd 3f a3 8c 25 c1 33 13 83 0d 94 06 bb d4 37 |..?..%.3.......7| 00000220 7a f6 ec 7a c9 86 2e dd d7 11 69 7f 85 7c 56 de |z..z......i..|V.| 00000230 fb 31 78 2b e4 c7 78 0d ae cb be 9e 4e 36 24 31 |.1x+..x.....N6$1| -00000240 7b 6a 0f 39 95 12 07 8f 2a 16 03 03 00 b6 0c 00 |{j.9....*.......| -00000250 00 b2 03 00 1d 20 2f e5 7d a3 47 cd 62 43 15 28 |..... /.}.G.bC.(| +00000240 7b 6a 0f 39 95 12 07 8f 2a 16 03 03 00 b7 0c 00 |{j.9....*.......| +00000250 00 b3 03 00 1d 20 2f e5 7d a3 47 cd 62 43 15 28 |..... /.}.G.bC.(| 00000260 da ac 5f bb 29 07 30 ff f6 84 af c4 cf c2 ed 90 |.._.).0.........| -00000270 99 5f 58 cb 3b 74 06 03 00 8a 30 81 87 02 42 01 |._X.;t....0...B.| -00000280 ed a6 35 6b 28 3f cc 4a 66 c1 21 a0 ba e3 a2 c2 |..5k(?.Jf.!.....| -00000290 3b 45 41 87 9b c4 5d 01 b7 8b 01 89 b4 b1 16 99 |;EA...].........| -000002a0 72 e2 94 6d 24 f2 9f be 6a 8b 9b b5 c7 9c cb 65 |r..m$...j......e| -000002b0 38 ab 29 de 38 e5 64 4c 0b 75 67 c9 9d 5b dc 37 |8.).8.dL.ug..[.7| -000002c0 86 02 41 33 ac b4 ff f3 db f7 2c c9 0b 43 8a 62 |..A3......,..C.b| -000002d0 df 9d b9 c5 50 0b 8c f1 da 40 b1 ba a8 41 99 66 |....P....@...A.f| -000002e0 1b e8 a0 20 0b 4f 0d 1e 55 12 c5 a2 a3 89 88 a0 |... .O..U.......| -000002f0 9f 91 b9 73 9b b1 19 95 d6 53 3a b3 d7 5d 73 5c |...s.....S:..]s\| -00000300 c4 d6 6a 1a 16 03 03 00 04 0e 00 00 00 |..j..........| +00000270 99 5f 58 cb 3b 74 04 03 00 8b 30 81 88 02 42 01 |._X.;t....0...B.| +00000280 f1 77 f4 3f e9 ed b7 55 54 25 08 68 ab b9 42 7c |.w.?...UT%.h..B|| +00000290 64 71 dc ce c0 13 23 20 f3 cd b7 68 09 23 6d c9 |dq....# ...h.#m.| +000002a0 c5 1f f3 3a 46 f1 e3 2b b4 92 6a 1c bd c8 60 7c |...:F..+..j...`|| +000002b0 da 63 0e c7 4f 4f c4 5e aa 30 b4 b1 3a d4 11 09 |.c..OO.^.0..:...| +000002c0 05 02 42 01 dd dc 50 07 2f 51 6c 75 7f 3f fd a2 |..B...P./Qlu.?..| +000002d0 68 62 1d 7a 49 78 4e 57 1b bc 3a 4d 02 84 d5 f6 |hb.zIxNW..:M....| +000002e0 2a 37 28 4e c0 30 2b a5 22 cc 28 d8 e0 66 2b 4d |*7(N.0+.".(..f+M| +000002f0 2a cd d8 01 3d 76 55 72 56 90 dc d0 99 85 ee 45 |*...=vUrV......E| +00000300 01 03 91 88 a5 16 03 03 00 04 0e 00 00 00 |..............| >>> Flow 3 (client to server) -00000000 16 03 03 00 25 10 00 00 21 20 5e 83 48 ba 4f 66 |....%...! ^.H.Of| -00000010 74 7d 8a c6 53 d2 a9 cf 68 f1 50 f4 2a 06 74 ef |t}..S...h.P.*.t.| -00000020 07 57 b0 f9 3e 1a 49 98 52 44 14 03 03 00 01 01 |.W..>.I.RD......| -00000030 16 03 03 00 40 1a b1 de ad 95 eb 28 ed 07 ce fe |....@......(....| -00000040 8b 8a fc 9a 24 a8 c3 d4 2f 27 20 52 9d 47 ac 45 |....$.../' R.G.E| -00000050 cc 66 c0 a4 03 cb 49 3c 93 05 3c 3e 64 91 d6 5c |.f....I<..<>d..\| -00000060 f9 73 1b 18 54 0b 67 c7 97 53 c8 7d 72 18 ab 47 |.s..T.g..S.}r..G| -00000070 98 32 54 4c ff |.2TL.| +00000000 16 03 03 00 25 10 00 00 21 20 5b 72 c3 fc 0c a5 |....%...! [r....| +00000010 a3 b1 e6 db 1d e7 f2 4a dd c8 36 97 25 f9 4c 74 |.......J..6.%.Lt| +00000020 68 04 e5 02 17 ca 67 e2 a6 59 14 03 03 00 01 01 |h.....g..Y......| +00000030 16 03 03 00 40 f0 40 1c 1a a9 d8 e7 88 c4 9d 6d |....@.@........m| +00000040 ad bd e7 5c c4 63 1a 06 5a e9 f5 39 6d 15 ac 41 |...\.c..Z..9m..A| +00000050 2f ed b9 3b f8 68 13 46 20 be 9b f9 be b6 8a cc |/..;.h.F .......| +00000060 f4 87 31 53 b3 ef 79 4e ce 73 ea a6 45 de 21 3e |..1S..yN.s..E.!>| +00000070 99 87 6a cb 4d |..j.M| >>> Flow 4 (server to client) 00000000 14 03 03 00 01 01 16 03 03 00 40 00 00 00 00 00 |..........@.....| -00000010 00 00 00 00 00 00 00 00 00 00 00 21 f3 63 c9 0a |...........!.c..| -00000020 7e 39 23 21 2d 2b 4b 72 47 65 30 b4 43 21 d1 d7 |~9#!-+KrGe0.C!..| -00000030 4f fa 00 65 a1 95 fd 62 2c d3 4d 7d 30 d7 fd eb |O..e...b,.M}0...| -00000040 64 08 41 d6 70 ab cf 9d 75 c5 e1 17 03 03 00 40 |d.A.p...u......@| +00000010 00 00 00 00 00 00 00 00 00 00 00 10 1f 05 23 89 |..............#.| +00000020 1d 50 5f cb 33 09 57 70 32 fc 01 76 f8 e9 dc ec |.P_.3.Wp2..v....| +00000030 13 b6 70 95 24 55 52 21 ed e6 5e 59 45 9f c9 c0 |..p.$UR!..^YE...| +00000040 74 6d d1 2f e6 4d 7c 6e 1e 41 4c 17 03 03 00 40 |tm./.M|n.AL....@| 00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000060 50 e5 5e 3a c1 2a 71 0a ba eb 40 74 f1 70 0d 0a |P.^:.*q...@t.p..| -00000070 e1 86 22 fd 13 de e8 8f a0 d3 22 a8 62 76 ca fa |..".......".bv..| -00000080 5f 63 95 ba bb e2 f3 b3 ef 5b d8 bf 56 0b 60 53 |_c.......[..V.`S| +00000060 e8 04 12 d8 cd fc 76 19 e0 27 c1 f2 12 66 d8 86 |......v..'...f..| +00000070 a8 25 b6 3f 13 aa 5c c5 43 c5 83 a1 c0 4a 7c c6 |.%.?..\.C....J|.| +00000080 7b d4 63 86 b8 87 d1 36 af 99 f3 6f 9d 7e 86 37 |{.c....6...o.~.7| 00000090 15 03 03 00 30 00 00 00 00 00 00 00 00 00 00 00 |....0...........| -000000a0 00 00 00 00 00 4d 2c 41 d8 4c 63 71 bd bc 83 5a |.....M,A.Lcq...Z| -000000b0 1b 2b b7 20 5b 14 51 d4 5b 38 4b fc 61 58 97 34 |.+. [.Q.[8K.aX.4| -000000c0 1a cf 08 f1 16 |.....| +000000a0 00 00 00 00 00 f0 fe 4c 32 8b c2 63 78 6c ba de |.......L2..cxl..| +000000b0 b3 55 0f e4 32 38 53 5e 2b 32 5c b9 23 4a 84 b7 |.U..28S^+2\.#J..| +000000c0 6f 2f 86 54 11 |o/.T.| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv12-CipherSuiteCertPreferenceRSA b/libgo/go/crypto/tls/testdata/Server-TLSv12-CipherSuiteCertPreferenceRSA index 154521da998..db7199d9a9e 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv12-CipherSuiteCertPreferenceRSA +++ b/libgo/go/crypto/tls/testdata/Server-TLSv12-CipherSuiteCertPreferenceRSA @@ -1,19 +1,21 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 a7 01 00 00 a3 03 03 df fc 06 29 d8 |..............).| -00000010 a1 69 bd 2c d2 21 97 39 e8 4f 81 94 fa b9 58 6d |.i.,.!.9.O....Xm| -00000020 aa 15 ae f7 bc 03 7a fa e3 33 bf 00 00 38 c0 2c |......z..3...8.,| +00000000 16 03 01 00 cb 01 00 00 c7 03 03 39 27 e9 a6 45 |...........9'..E| +00000010 cf a6 18 8c f0 d1 fb 71 81 b6 bf 16 d7 75 af f2 |.......q.....u..| +00000020 1e 4f 4c 72 2a ce 66 52 a6 87 32 00 00 38 c0 2c |.OLr*.fR..2..8.,| 00000030 c0 30 00 9f cc a9 cc a8 cc aa c0 2b c0 2f 00 9e |.0.........+./..| 00000040 c0 24 c0 28 00 6b c0 23 c0 27 00 67 c0 0a c0 14 |.$.(.k.#.'.g....| 00000050 00 39 c0 09 c0 13 00 33 00 9d 00 9c 00 3d 00 3c |.9.....3.....=.<| -00000060 00 35 00 2f 00 ff 01 00 00 42 00 0b 00 04 03 00 |.5./.....B......| -00000070 01 02 00 0a 00 0a 00 08 00 1d 00 17 00 19 00 18 |................| -00000080 00 0d 00 20 00 1e 06 01 06 02 06 03 05 01 05 02 |... ............| -00000090 05 03 04 01 04 02 04 03 03 01 03 02 03 03 02 01 |................| -000000a0 02 02 02 03 00 16 00 00 00 17 00 00 |............| +00000060 00 35 00 2f 00 ff 01 00 00 66 00 00 00 0e 00 0c |.5./.....f......| +00000070 00 00 09 31 32 37 2e 30 2e 30 2e 31 00 0b 00 04 |...127.0.0.1....| +00000080 03 00 01 02 00 0a 00 0c 00 0a 00 1d 00 17 00 1e |................| +00000090 00 19 00 18 00 16 00 00 00 17 00 00 00 0d 00 30 |...............0| +000000a0 00 2e 04 03 05 03 06 03 08 07 08 08 08 09 08 0a |................| +000000b0 08 0b 08 04 08 05 08 06 04 01 05 01 06 01 03 03 |................| +000000c0 02 03 03 01 02 01 03 02 02 02 04 02 05 02 06 02 |................| >>> Flow 2 (server to client) 00000000 16 03 03 00 31 02 00 00 2d 03 03 00 00 00 00 00 |....1...-.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 c0 14 00 00 |................| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 c0 14 00 00 |...DOWNGRD......| 00000030 05 ff 01 00 01 00 16 03 03 02 59 0b 00 02 55 00 |..........Y...U.| 00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -55,35 +57,35 @@ 00000290 3b e9 fa e7 16 03 03 00 ac 0c 00 00 a8 03 00 1d |;...............| 000002a0 20 2f e5 7d a3 47 cd 62 43 15 28 da ac 5f bb 29 | /.}.G.bC.(.._.)| 000002b0 07 30 ff f6 84 af c4 cf c2 ed 90 99 5f 58 cb 3b |.0.........._X.;| -000002c0 74 06 01 00 80 a3 e7 63 ff 8a 7e 1c cb 9b ab 8a |t......c..~.....| -000002d0 7e f3 d1 fe c0 34 23 10 5e 0c e3 60 0d c5 cc 11 |~....4#.^..`....| -000002e0 49 37 37 b6 ad b1 9a 29 b7 e4 1f 90 29 bf b3 bd |I77....)....)...| -000002f0 31 ed e6 20 4d 4c 2a a1 64 d8 cb 44 5e b1 5d b5 |1.. ML*.d..D^.].| -00000300 a5 d5 67 de 29 e4 89 29 a9 51 bd b9 1f 01 de 72 |..g.)..).Q.....r| -00000310 8b c1 b2 d0 fd 96 ec 94 29 4d 2e ee da 08 58 81 |........)M....X.| -00000320 3b db 53 26 26 0e cb 57 37 f4 d0 fe 19 3e 41 a0 |;.S&&..W7....>A.| -00000330 d5 0e a8 7a bf 29 56 a9 d4 84 da 33 bb bf f9 ba |...z.)V....3....| -00000340 54 7b d0 4a 95 16 03 03 00 04 0e 00 00 00 |T{.J..........| +000002c0 74 08 04 00 80 41 cd 5d a0 ba 92 1f 26 47 6d 72 |t....A.]....&Gmr| +000002d0 33 44 47 a4 80 66 d8 1c 17 93 1e 25 8e c3 8e 95 |3DG..f.....%....| +000002e0 9c ae b6 99 7e f6 80 3f b1 73 cc c3 db 7a 4b 40 |....~..?.s...zK@| +000002f0 a1 0b bc ff 0e 4b c1 67 11 b2 ca 33 06 41 f9 ac |.....K.g...3.A..| +00000300 56 dc f6 26 1b a3 04 2a 28 f9 47 0f 0b 56 05 73 |V..&...*(.G..V.s| +00000310 93 cb 12 45 4f 6b 93 5d 0f 4c ca d3 f5 64 e2 4a |...EOk.].L...d.J| +00000320 eb 36 bb 87 3f 71 9b 36 08 99 79 48 fc a6 02 d6 |.6..?q.6..yH....| +00000330 38 88 09 68 cf 71 e8 d4 51 f8 b1 77 70 42 8b 18 |8..h.q..Q..wpB..| +00000340 ab cd e1 52 d9 16 03 03 00 04 0e 00 00 00 |...R..........| >>> Flow 3 (client to server) -00000000 16 03 03 00 25 10 00 00 21 20 36 84 23 91 d3 76 |....%...! 6.#..v| -00000010 b3 ea 4a a6 39 f6 c9 1a 99 2c 69 c0 70 2d b2 72 |..J.9....,i.p-.r| -00000020 72 be b3 24 4b d3 72 a1 eb 76 14 03 03 00 01 01 |r..$K.r..v......| -00000030 16 03 03 00 40 e9 a5 32 9d 72 3d 9d 38 f3 0b fa |....@..2.r=.8...| -00000040 38 95 0f de 7d 99 42 b2 5b 1c f0 fe e4 66 2b 5a |8...}.B.[....f+Z| -00000050 98 1c e5 0e bf d9 37 d4 4c 72 29 a3 eb 8a f5 0e |......7.Lr).....| -00000060 44 ee 1e 21 c7 8c 10 23 dc 41 6d ac ee 72 5b d5 |D..!...#.Am..r[.| -00000070 4b 3f 66 f3 d1 |K?f..| +00000000 16 03 03 00 25 10 00 00 21 20 b5 a5 bc 9f 09 79 |....%...! .....y| +00000010 25 1a 7b af 52 0f 8a c2 16 a8 20 8d 0c 11 26 11 |%.{.R..... ...&.| +00000020 32 79 35 b9 2f ee 63 ce b7 49 14 03 03 00 01 01 |2y5./.c..I......| +00000030 16 03 03 00 40 d8 eb b7 d7 b4 a6 62 a1 8d c6 a5 |....@......b....| +00000040 5f 15 8e 1f de d9 98 90 3b d8 dd b1 13 7e 49 9b |_.......;....~I.| +00000050 d4 82 15 b9 a9 31 ac ae eb 77 21 dc 9f e0 8e 5b |.....1...w!....[| +00000060 d8 ea 09 fc a2 35 64 af 8d 1a fb a3 f1 97 0e 09 |.....5d.........| +00000070 b4 5b c9 e9 19 |.[...| >>> Flow 4 (server to client) 00000000 14 03 03 00 01 01 16 03 03 00 40 00 00 00 00 00 |..........@.....| -00000010 00 00 00 00 00 00 00 00 00 00 00 f8 fb 0a 12 f2 |................| -00000020 ee 27 b0 88 5d c9 02 c0 16 3c b8 a5 54 86 4b cb |.'..]....<..T.K.| -00000030 01 ef d1 6e 31 a8 88 86 e3 9f 71 f5 fb 2a a9 12 |...n1.....q..*..| -00000040 72 76 98 30 1e 59 49 64 b1 6b e5 17 03 03 00 40 |rv.0.YId.k.....@| +00000010 00 00 00 00 00 00 00 00 00 00 00 3b 2a 79 f1 0d |...........;*y..| +00000020 65 b8 4a 2a aa a5 87 60 69 8f 8f 87 4b 21 24 9a |e.J*...`i...K!$.| +00000030 6e 07 f0 a4 be ce 3d 67 29 85 53 98 fb cf a1 ee |n.....=g).S.....| +00000040 b0 e0 52 61 c1 16 e5 09 b9 0b 9c 17 03 03 00 40 |..Ra...........@| 00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000060 da fe c6 34 b0 e7 8d 34 78 11 b1 94 43 da 85 21 |...4...4x...C..!| -00000070 28 9a f3 f8 f0 7f 14 9a 59 be 4e c4 a0 81 17 1b |(.......Y.N.....| -00000080 08 cd 6d 47 57 73 f1 10 e4 df 25 1b 8b 9d 87 98 |..mGWs....%.....| +00000060 fe d7 63 a8 10 70 b8 2c 0c 95 da 92 84 2b d3 63 |..c..p.,.....+.c| +00000070 03 d8 19 94 68 d8 d2 da f7 e2 83 5b 24 78 87 0f |....h......[$x..| +00000080 ca ce 14 3a 8a d4 da b2 90 eb 6f 0e de 14 30 96 |...:......o...0.| 00000090 15 03 03 00 30 00 00 00 00 00 00 00 00 00 00 00 |....0...........| -000000a0 00 00 00 00 00 41 b6 ed ca 43 0d 83 67 da 4b 0e |.....A...C..g.K.| -000000b0 5a f4 a8 90 85 7f d6 d7 76 03 62 2e 49 7e 4a 62 |Z.......v.b.I~Jb| -000000c0 32 03 a8 7c a0 |2..|.| +000000a0 00 00 00 00 00 ab e5 6b f9 d3 a6 07 ce 0b 64 7e |.......k......d~| +000000b0 14 42 d3 17 6a d4 89 2c 37 7d cd ee 77 23 0c 60 |.B..j..,7}..w#.`| +000000c0 e0 db 35 5e 96 |..5^.| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv12-ClientAuthRequestedAndECDSAGiven b/libgo/go/crypto/tls/testdata/Server-TLSv12-ClientAuthRequestedAndECDSAGiven index 8c6a7ed98c2..07a000a7b4e 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv12-ClientAuthRequestedAndECDSAGiven +++ b/libgo/go/crypto/tls/testdata/Server-TLSv12-ClientAuthRequestedAndECDSAGiven @@ -1,15 +1,18 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 5d 01 00 00 59 03 03 ba cf e7 3a 42 |....]...Y.....:B| -00000010 aa f9 cd ca b8 b7 46 a0 4a 87 2c f8 76 14 d6 d0 |......F.J.,.v...| -00000020 f8 66 ad ed 80 57 b0 9f bf f5 32 00 00 04 00 2f |.f...W....2..../| -00000030 00 ff 01 00 00 2c 00 0d 00 20 00 1e 06 01 06 02 |.....,... ......| -00000040 06 03 05 01 05 02 05 03 04 01 04 02 04 03 03 01 |................| -00000050 03 02 03 03 02 01 02 02 02 03 00 16 00 00 00 17 |................| -00000060 00 00 |..| +00000000 16 03 01 00 97 01 00 00 93 03 03 f9 a8 6c 6d 8e |.............lm.| +00000010 46 32 35 bb 63 0e 00 89 d0 e2 36 04 62 73 5f 1a |F25.c.....6.bs_.| +00000020 32 39 a1 a8 0d 5d 65 e1 3d 79 43 00 00 04 00 2f |29...]e.=yC..../| +00000030 00 ff 01 00 00 66 00 00 00 0e 00 0c 00 00 09 31 |.....f.........1| +00000040 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000050 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 00 18 |................| +00000060 00 16 00 00 00 17 00 00 00 0d 00 30 00 2e 04 03 |...........0....| +00000070 05 03 06 03 08 07 08 08 08 09 08 0a 08 0b 08 04 |................| +00000080 08 05 08 06 04 01 05 01 06 01 03 03 02 03 03 01 |................| +00000090 02 01 03 02 02 02 04 02 05 02 06 02 |............| >>> Flow 2 (server to client) 00000000 16 03 03 00 31 02 00 00 2d 03 03 00 00 00 00 00 |....1...-.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2f 00 00 |............./..| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 00 2f 00 00 |...DOWNGRD.../..| 00000030 05 ff 01 00 01 00 16 03 03 02 59 0b 00 02 55 00 |..........Y...U.| 00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -48,9 +51,10 @@ 00000260 f1 6c 04 ed 73 bb b3 43 77 8d 0c 1c f1 0f a1 d8 |.l..s..Cw.......| 00000270 40 83 61 c9 4c 72 2b 9d ae db 46 06 06 4d f4 c1 |@.a.Lr+...F..M..| 00000280 b3 3e c0 d1 bd 42 d4 db fe 3d 13 60 84 5c 21 d3 |.>...B...=.`.\!.| -00000290 3b e9 fa e7 16 03 03 00 1b 0d 00 00 17 02 01 40 |;..............@| -000002a0 00 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 |................| -000002b0 02 03 00 00 16 03 03 00 04 0e 00 00 00 |.............| +00000290 3b e9 fa e7 16 03 03 00 21 0d 00 00 1d 02 01 40 |;.......!......@| +000002a0 00 16 08 04 08 05 08 06 04 01 04 03 05 01 05 03 |................| +000002b0 06 01 06 03 02 01 02 03 00 00 16 03 03 00 04 0e |................| +000002c0 00 00 00 |...| >>> Flow 3 (client to server) 00000000 16 03 03 02 0a 0b 00 02 06 00 02 03 00 02 00 30 |...............0| 00000010 82 01 fc 30 82 01 5e 02 09 00 9a 30 84 6c 26 35 |...0..^....0.l&5| @@ -85,36 +89,40 @@ 000001e0 be e8 91 b3 da 1a f5 5d a3 23 f5 26 8b 45 70 8d |.......].#.&.Ep.| 000001f0 65 62 9b 7e 01 99 3d 18 f6 10 9a 38 61 9b 2e 57 |eb.~..=....8a..W| 00000200 e4 fa cc b1 8a ce e2 23 a0 87 f0 e1 67 51 eb 16 |.......#....gQ..| -00000210 03 03 00 86 10 00 00 82 00 80 d4 03 c6 f3 e2 5d |...............]| -00000220 15 db 9d c5 28 c4 30 e9 80 7b 56 89 0f 20 5b 8f |....(.0..{V.. [.| -00000230 47 8f bf 04 a5 d4 49 c9 ac 0f 54 c9 3d f0 cc 37 |G.....I...T.=..7| -00000240 51 3c f8 3e 18 69 5b 58 a9 5a 88 ac 2c ff 5c b9 |Q<.>.i[X.Z..,.\.| -00000250 65 2e 9a 9d 9e d4 3f 01 6b 47 e3 c8 ec e2 90 23 |e.....?.kG.....#| -00000260 b9 9f a7 1f bf 7a c4 b3 68 e5 8a ee f5 4e 7b 49 |.....z..h....N{I| -00000270 f3 3c b7 86 89 76 60 14 d5 a4 8e b1 5e 3f 5c 89 |.<...v`.....^?\.| -00000280 a5 f8 69 7e 12 88 9d 30 7a 07 c2 ff 8f bb d0 94 |..i~...0z.......| -00000290 1b 3c c4 fe 73 e6 25 99 77 d3 16 03 03 00 93 0f |.<..s.%.w.......| -000002a0 00 00 8f 04 03 00 8b 30 81 88 02 42 01 21 35 66 |.......0...B.!5f| -000002b0 57 df 29 1a e5 10 1d e0 e0 00 ee 2a 0b 20 22 8b |W.)........*. ".| -000002c0 1d 70 4f 39 cb 96 30 b1 f0 8d 12 ba c8 15 67 05 |.pO9..0.......g.| -000002d0 45 d2 fe 0a 4e 25 ce f4 8d 14 7b b8 6c 92 8b 99 |E...N%....{.l...| -000002e0 9b 56 0a 78 ad 45 d6 09 88 ae c7 e6 2d 13 02 42 |.V.x.E......-..B| -000002f0 01 5e 7e c9 ae 56 9e b6 de 38 fc a9 a6 e7 b9 35 |.^~..V...8.....5| -00000300 9b 47 cd f7 82 1a 56 1c cc d4 3a 15 79 d9 44 c4 |.G....V...:.y.D.| -00000310 96 1a 10 69 31 ad c7 96 6b 3f f7 81 b6 04 4c bd |...i1...k?....L.| -00000320 ee e2 a1 15 8a 83 bc a0 42 b9 0f aa 6a 14 d1 fd |........B...j...| -00000330 9d 95 14 03 03 00 01 01 16 03 03 00 40 46 6b 0c |............@Fk.| -00000340 5d 7e 32 26 ef 7c a5 88 f0 ec 50 92 de 5f 87 7c |]~2&.|....P.._.|| -00000350 b4 80 19 80 f4 89 19 f5 28 8f 21 09 fc 19 43 81 |........(.!...C.| -00000360 92 94 37 f5 9b 6e 07 b1 35 29 ed 9a 87 a5 e9 ce |..7..n..5)......| -00000370 c3 e3 83 42 dd 2e 5a 0b 8e 22 bf 32 4e |...B..Z..".2N| +00000210 03 03 00 86 10 00 00 82 00 80 9f 2d b7 51 a0 7b |...........-.Q.{| +00000220 1f 57 7c 20 9f 8a 3a 23 19 2a 3f 29 31 c9 97 12 |.W| ..:#.*?)1...| +00000230 fd 40 92 45 eb cd bf 45 19 b1 7a 80 14 22 a4 b7 |.@.E...E..z.."..| +00000240 68 7a 6e f9 c1 a3 3d 44 ad 22 b1 e1 ae 52 2c a7 |hzn...=D."...R,.| +00000250 fe 95 30 b7 cc 94 ce 9b 9d 94 ff 80 1f ca 75 90 |..0...........u.| +00000260 7e d5 20 15 eb 46 b4 78 d8 ca e0 42 fe a0 aa d5 |~. ..F.x...B....| +00000270 a3 69 34 61 1a 14 93 4e 1b 52 81 6f ae 90 59 3b |.i4a...N.R.o..Y;| +00000280 ac 7f a1 23 75 0b 97 7f 16 6f 85 99 68 b0 57 34 |...#u....o..h.W4| +00000290 de 0e 60 62 61 6d 31 a8 46 9a 16 03 03 00 92 0f |..`bam1.F.......| +000002a0 00 00 8e 04 03 00 8a 30 81 87 02 41 74 3c e9 2d |.......0...At<.-| +000002b0 47 15 d6 a5 e8 21 b6 2c d4 a4 83 3f ca 90 35 2f |G....!.,...?..5/| +000002c0 ae 36 26 81 49 ae 6c d9 d3 13 17 7f 8f 8a a0 2f |.6&.I.l......../| +000002d0 92 a2 6d 29 fb 09 6a 4d b5 ea bc f0 05 43 bc fa |..m)..jM.....C..| +000002e0 6c ab 89 25 84 21 78 1c f8 86 36 86 1b 02 42 00 |l..%.!x...6...B.| +000002f0 98 0a bf 1e ee 62 85 43 c1 6c f0 49 9b 9a 46 96 |.....b.C.l.I..F.| +00000300 32 24 66 3d 1e 09 e1 7e 47 af 6d d1 9e 5d 6f 85 |2$f=...~G.m..]o.| +00000310 74 dc 7e ac c9 2b b7 e3 40 0a 25 45 76 6b 6e 5c |t.~..+..@.%Evkn\| +00000320 6f 42 59 5e 5e a4 b3 3d 4a c2 d7 1c 91 74 15 f9 |oBY^^..=J....t..| +00000330 e3 14 03 03 00 01 01 16 03 03 00 40 57 f7 7c d6 |...........@W.|.| +00000340 1a da 14 09 b3 8f 75 cc c7 dd fe 2b 4d 11 3e 16 |......u....+M.>.| +00000350 09 5a a0 d7 c3 05 b6 28 75 27 58 64 37 af 46 28 |.Z.....(u'Xd7.F(| +00000360 74 a8 4d 9b c4 9d 5c 6c f2 e3 be 45 65 93 be 89 |t.M...\l...Ee...| +00000370 b6 5f 24 2b 26 3c d0 43 ce 05 91 c7 |._$+&<.C....| >>> Flow 4 (server to client) 00000000 14 03 03 00 01 01 16 03 03 00 40 00 00 00 00 00 |..........@.....| -00000010 00 00 00 00 00 00 00 00 00 00 00 13 c4 d2 3f b0 |..............?.| -00000020 84 08 32 74 de cc e0 97 90 8a c6 cc 94 87 ac 48 |..2t...........H| -00000030 65 f7 20 04 18 42 68 46 8e c0 19 b6 9d 2a 84 58 |e. ..BhF.....*.X| -00000040 85 20 b3 ed 75 94 71 4e 5b 0a de 17 03 03 00 40 |. ..u.qN[......@| +00000010 00 00 00 00 00 00 00 00 00 00 00 54 54 12 18 10 |...........TT...| +00000020 cf 34 c3 2d 68 91 25 8e 2f 04 26 74 c1 bc 96 a1 |.4.-h.%./.&t....| +00000030 65 a5 4e 88 58 fe 95 81 59 57 74 bf 0a 9d f9 98 |e.N.X...YWt.....| +00000040 cb e2 7d 39 64 3e f4 09 9d e2 aa 17 03 03 00 40 |..}9d>.........@| 00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000060 c2 6e c5 13 4d 35 ab b1 de e2 1b a6 6f 0e 40 64 |.n..M5......o.@d| -00000070 cc 67 bf 0d b1 e4 fe 48 c4 01 35 6a 94 50 17 7a |.g.....H..5j.P.z| -00000080 b3 6b f6 6b 2a 24 c9 b9 7b b0 42 0e 71 4d c2 da |.k.k*$..{.B.qM..| +00000060 82 e5 1d 01 10 a6 dd 52 42 b6 e7 8b 3f 45 03 39 |.......RB...?E.9| +00000070 f1 3c 27 73 f0 8b a7 98 99 e9 da b8 88 34 25 49 |.<'s.........4%I| +00000080 38 4d 6b 3a 8d f8 61 c8 b7 0d 80 4b 7b 83 e3 9a |8Mk:..a....K{...| +00000090 15 03 03 00 30 00 00 00 00 00 00 00 00 00 00 00 |....0...........| +000000a0 00 00 00 00 00 4c b8 9a e7 90 56 f7 ce 20 41 bf |.....L....V.. A.| +000000b0 44 f4 b7 85 ff 97 e9 43 4a 09 9e 7d 0e 91 1d 56 |D......CJ..}...V| +000000c0 2d eb fb 44 4b |-..DK| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv12-ClientAuthRequestedAndGiven b/libgo/go/crypto/tls/testdata/Server-TLSv12-ClientAuthRequestedAndGiven index aa4cfe1261c..37c813d559a 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv12-ClientAuthRequestedAndGiven +++ b/libgo/go/crypto/tls/testdata/Server-TLSv12-ClientAuthRequestedAndGiven @@ -1,15 +1,15 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 5d 01 00 00 59 03 03 ed f9 4a 41 31 |....]...Y....JA1| -00000010 20 6a df af 85 92 37 a1 38 81 ed 3c 1a 7e d2 31 | j....7.8..<.~.1| -00000020 80 5b 68 87 b6 72 43 8e c0 f0 dd 00 00 04 00 2f |.[h..rC......../| -00000030 00 ff 01 00 00 2c 00 0d 00 20 00 1e 06 01 06 02 |.....,... ......| -00000040 06 03 05 01 05 02 05 03 04 01 04 02 04 03 03 01 |................| -00000050 03 02 03 03 02 01 02 02 02 03 00 16 00 00 00 17 |................| -00000060 00 00 |..| +00000000 16 03 01 00 6b 01 00 00 67 03 03 e1 81 50 38 7b |....k...g....P8{| +00000010 dd e5 6f 1c 98 9e 2b 86 2d 50 95 de 00 b7 87 6e |..o...+.-P.....n| +00000020 b3 d2 20 0f 61 5c 3e 6d 19 0c 76 00 00 04 00 2f |.. .a\>m..v..../| +00000030 00 ff 01 00 00 3a 00 00 00 0e 00 0c 00 00 09 31 |.....:.........1| +00000040 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000050 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 00 18 |................| +00000060 00 16 00 00 00 17 00 00 00 0d 00 04 00 02 08 04 |................| >>> Flow 2 (server to client) 00000000 16 03 03 00 31 02 00 00 2d 03 03 00 00 00 00 00 |....1...-.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2f 00 00 |............./..| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 00 2f 00 00 |...DOWNGRD.../..| 00000030 05 ff 01 00 01 00 16 03 03 02 59 0b 00 02 55 00 |..........Y...U.| 00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -48,9 +48,10 @@ 00000260 f1 6c 04 ed 73 bb b3 43 77 8d 0c 1c f1 0f a1 d8 |.l..s..Cw.......| 00000270 40 83 61 c9 4c 72 2b 9d ae db 46 06 06 4d f4 c1 |@.a.Lr+...F..M..| 00000280 b3 3e c0 d1 bd 42 d4 db fe 3d 13 60 84 5c 21 d3 |.>...B...=.`.\!.| -00000290 3b e9 fa e7 16 03 03 00 1b 0d 00 00 17 02 01 40 |;..............@| -000002a0 00 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 |................| -000002b0 02 03 00 00 16 03 03 00 04 0e 00 00 00 |.............| +00000290 3b e9 fa e7 16 03 03 00 21 0d 00 00 1d 02 01 40 |;.......!......@| +000002a0 00 16 08 04 08 05 08 06 04 01 04 03 05 01 05 03 |................| +000002b0 06 01 06 03 02 01 02 03 00 00 16 03 03 00 04 0e |................| +000002c0 00 00 00 |...| >>> Flow 3 (client to server) 00000000 16 03 03 01 fd 0b 00 01 f9 00 01 f6 00 01 f3 30 |...............0| 00000010 82 01 ef 30 82 01 58 a0 03 02 01 02 02 10 5c 19 |...0..X.......\.| @@ -84,40 +85,40 @@ 000001d0 ac 11 b1 28 56 be 1d cd 61 62 84 09 bf d6 80 c6 |...(V...ab......| 000001e0 45 8d 82 2c b4 d8 83 9b db c9 22 b7 2a 12 11 7b |E..,......".*..{| 000001f0 fa 02 3b c1 c9 ff ea c9 9d a8 49 d3 95 d7 d5 0e |..;.......I.....| -00000200 e5 35 16 03 03 00 86 10 00 00 82 00 80 90 96 a6 |.5..............| -00000210 45 0a 8d 6a 38 86 3a f0 0a cb d6 bb db 9b 27 a6 |E..j8.:.......'.| -00000220 17 ca 02 6d 67 3c 56 80 74 9b 06 6e 62 58 55 43 |...mg...4%| +00000360 94 63 17 99 fc |.c...| >>> Flow 4 (server to client) 00000000 14 03 03 00 01 01 16 03 03 00 40 00 00 00 00 00 |..........@.....| -00000010 00 00 00 00 00 00 00 00 00 00 00 52 d1 34 99 c9 |...........R.4..| -00000020 60 18 c3 99 36 2d c5 c2 14 ae f4 e5 10 e1 6f af |`...6-........o.| -00000030 70 3b c3 d6 d1 81 ee da fe 6e a5 96 81 53 cf 9a |p;.......n...S..| -00000040 cc c2 ac 98 95 0c 75 81 ac 55 6b 17 03 03 00 40 |......u..Uk....@| +00000010 00 00 00 00 00 00 00 00 00 00 00 c6 b8 7e 65 f8 |.............~e.| +00000020 c4 d9 2c 00 11 f4 ae 2b 13 33 84 31 e6 e6 6e d5 |..,....+.3.1..n.| +00000030 b0 8c 12 c9 6d 26 c2 8c 9c d0 2e 1b 3d 68 98 27 |....m&......=h.'| +00000040 a2 f9 92 46 60 40 dc a6 12 c1 ee 17 03 03 00 40 |...F`@.........@| 00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000060 46 ff 8d a9 0d 65 e1 82 48 4c 31 ec 60 24 61 52 |F....e..HL1.`$aR| -00000070 33 41 b1 7b 6a a8 96 b3 59 eb c9 2c f8 f2 4d 15 |3A.{j...Y..,..M.| -00000080 83 3e 99 c4 08 89 24 e3 de 4a bf 54 f4 eb a3 2a |.>....$..J.T...*| +00000060 70 ae c5 b1 11 36 22 4f 4b 11 cd 75 25 9c 8d 5e |p....6"OK..u%..^| +00000070 8b 3b f0 e0 fd 78 22 c7 e1 14 67 2e 12 13 53 44 |.;...x"...g...SD| +00000080 38 7b f9 53 08 90 c8 95 3a 16 b1 b0 81 ce 44 b3 |8{.S....:.....D.| 00000090 15 03 03 00 30 00 00 00 00 00 00 00 00 00 00 00 |....0...........| -000000a0 00 00 00 00 00 dc f3 c7 14 24 b7 a8 fa f4 78 6f |.........$....xo| -000000b0 7a 0c bd ad 14 d5 83 f7 97 30 58 0a a8 b5 76 88 |z........0X...v.| -000000c0 60 00 3d 4c 1a |`.=L.| +000000a0 00 00 00 00 00 a1 82 43 82 46 02 07 98 13 cc a1 |.......C.F......| +000000b0 9f bd 78 9d 7a d0 c3 cc e1 08 46 84 49 97 fb 5c |..x.z.....F.I..\| +000000c0 49 62 01 65 de |Ib.e.| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv12-ClientAuthRequestedAndPKCS1v15Given b/libgo/go/crypto/tls/testdata/Server-TLSv12-ClientAuthRequestedAndPKCS1v15Given new file mode 100644 index 00000000000..ebc16c590b8 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Server-TLSv12-ClientAuthRequestedAndPKCS1v15Given @@ -0,0 +1,124 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 6b 01 00 00 67 03 03 a5 db 42 40 b5 |....k...g....B@.| +00000010 57 97 90 6f de 6e 07 7c 3d f6 ce a5 ec 37 52 2e |W..o.n.|=....7R.| +00000020 d9 cf 7c dc f9 66 34 7f ef a3 90 00 00 04 00 2f |..|..f4......../| +00000030 00 ff 01 00 00 3a 00 00 00 0e 00 0c 00 00 09 31 |.....:.........1| +00000040 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000050 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 00 18 |................| +00000060 00 16 00 00 00 17 00 00 00 0d 00 04 00 02 04 01 |................| +>>> Flow 2 (server to client) +00000000 16 03 03 00 31 02 00 00 2d 03 03 00 00 00 00 00 |....1...-.......| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 00 2f 00 00 |...DOWNGRD.../..| +00000030 05 ff 01 00 01 00 16 03 03 02 59 0b 00 02 55 00 |..........Y...U.| +00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| +00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| +00000060 09 2a 86 48 86 f7 0d 01 01 0b 05 00 30 1f 31 0b |.*.H........0.1.| +00000070 30 09 06 03 55 04 0a 13 02 47 6f 31 10 30 0e 06 |0...U....Go1.0..| +00000080 03 55 04 03 13 07 47 6f 20 52 6f 6f 74 30 1e 17 |.U....Go Root0..| +00000090 0d 31 36 30 31 30 31 30 30 30 30 30 30 5a 17 0d |.160101000000Z..| +000000a0 32 35 30 31 30 31 30 30 30 30 30 30 5a 30 1a 31 |250101000000Z0.1| +000000b0 0b 30 09 06 03 55 04 0a 13 02 47 6f 31 0b 30 09 |.0...U....Go1.0.| +000000c0 06 03 55 04 03 13 02 47 6f 30 81 9f 30 0d 06 09 |..U....Go0..0...| +000000d0 2a 86 48 86 f7 0d 01 01 01 05 00 03 81 8d 00 30 |*.H............0| +000000e0 81 89 02 81 81 00 db 46 7d 93 2e 12 27 06 48 bc |.......F}...'.H.| +000000f0 06 28 21 ab 7e c4 b6 a2 5d fe 1e 52 45 88 7a 36 |.(!.~...]..RE.z6| +00000100 47 a5 08 0d 92 42 5b c2 81 c0 be 97 79 98 40 fb |G....B[.....y.@.| +00000110 4f 6d 14 fd 2b 13 8b c2 a5 2e 67 d8 d4 09 9e d6 |Om..+.....g.....| +00000120 22 38 b7 4a 0b 74 73 2b c2 34 f1 d1 93 e5 96 d9 |"8.J.ts+.4......| +00000130 74 7b f3 58 9f 6c 61 3c c0 b0 41 d4 d9 2b 2b 24 |t{.X.la<..A..++$| +00000140 23 77 5b 1c 3b bd 75 5d ce 20 54 cf a1 63 87 1d |#w[.;.u]. T..c..| +00000150 1e 24 c4 f3 1d 1a 50 8b aa b6 14 43 ed 97 a7 75 |.$....P....C...u| +00000160 62 f4 14 c8 52 d7 02 03 01 00 01 a3 81 93 30 81 |b...R.........0.| +00000170 90 30 0e 06 03 55 1d 0f 01 01 ff 04 04 03 02 05 |.0...U..........| +00000180 a0 30 1d 06 03 55 1d 25 04 16 30 14 06 08 2b 06 |.0...U.%..0...+.| +00000190 01 05 05 07 03 01 06 08 2b 06 01 05 05 07 03 02 |........+.......| +000001a0 30 0c 06 03 55 1d 13 01 01 ff 04 02 30 00 30 19 |0...U.......0.0.| +000001b0 06 03 55 1d 0e 04 12 04 10 9f 91 16 1f 43 43 3e |..U..........CC>| +000001c0 49 a6 de 6d b6 80 d7 9f 60 30 1b 06 03 55 1d 23 |I..m....`0...U.#| +000001d0 04 14 30 12 80 10 48 13 49 4d 13 7e 16 31 bb a3 |..0...H.IM.~.1..| +000001e0 01 d5 ac ab 6e 7b 30 19 06 03 55 1d 11 04 12 30 |....n{0...U....0| +000001f0 10 82 0e 65 78 61 6d 70 6c 65 2e 67 6f 6c 61 6e |...example.golan| +00000200 67 30 0d 06 09 2a 86 48 86 f7 0d 01 01 0b 05 00 |g0...*.H........| +00000210 03 81 81 00 9d 30 cc 40 2b 5b 50 a0 61 cb ba e5 |.....0.@+[P.a...| +00000220 53 58 e1 ed 83 28 a9 58 1a a9 38 a4 95 a1 ac 31 |SX...(.X..8....1| +00000230 5a 1a 84 66 3d 43 d3 2d d9 0b f2 97 df d3 20 64 |Z..f=C.-...... d| +00000240 38 92 24 3a 00 bc cf 9c 7d b7 40 20 01 5f aa d3 |8.$:....}.@ ._..| +00000250 16 61 09 a2 76 fd 13 c3 cc e1 0c 5c ee b1 87 82 |.a..v......\....| +00000260 f1 6c 04 ed 73 bb b3 43 77 8d 0c 1c f1 0f a1 d8 |.l..s..Cw.......| +00000270 40 83 61 c9 4c 72 2b 9d ae db 46 06 06 4d f4 c1 |@.a.Lr+...F..M..| +00000280 b3 3e c0 d1 bd 42 d4 db fe 3d 13 60 84 5c 21 d3 |.>...B...=.`.\!.| +00000290 3b e9 fa e7 16 03 03 00 21 0d 00 00 1d 02 01 40 |;.......!......@| +000002a0 00 16 08 04 08 05 08 06 04 01 04 03 05 01 05 03 |................| +000002b0 06 01 06 03 02 01 02 03 00 00 16 03 03 00 04 0e |................| +000002c0 00 00 00 |...| +>>> Flow 3 (client to server) +00000000 16 03 03 01 fd 0b 00 01 f9 00 01 f6 00 01 f3 30 |...............0| +00000010 82 01 ef 30 82 01 58 a0 03 02 01 02 02 10 5c 19 |...0..X.......\.| +00000020 c1 89 65 83 55 6f dc 0b c9 b9 93 9f e9 bc 30 0d |..e.Uo........0.| +00000030 06 09 2a 86 48 86 f7 0d 01 01 0b 05 00 30 12 31 |..*.H........0.1| +00000040 10 30 0e 06 03 55 04 0a 13 07 41 63 6d 65 20 43 |.0...U....Acme C| +00000050 6f 30 1e 17 0d 31 36 30 38 31 37 32 31 35 32 33 |o0...16081721523| +00000060 31 5a 17 0d 31 37 30 38 31 37 32 31 35 32 33 31 |1Z..170817215231| +00000070 5a 30 12 31 10 30 0e 06 03 55 04 0a 13 07 41 63 |Z0.1.0...U....Ac| +00000080 6d 65 20 43 6f 30 81 9f 30 0d 06 09 2a 86 48 86 |me Co0..0...*.H.| +00000090 f7 0d 01 01 01 05 00 03 81 8d 00 30 81 89 02 81 |...........0....| +000000a0 81 00 ba 6f aa 86 bd cf bf 9f f2 ef 5c 94 60 78 |...o........\.`x| +000000b0 6f e8 13 f2 d1 96 6f cd d9 32 6e 22 37 ce 41 f9 |o.....o..2n"7.A.| +000000c0 ca 5d 29 ac e1 27 da 61 a2 ee 81 cb 10 c7 df 34 |.])..'.a.......4| +000000d0 58 95 86 e9 3d 19 e6 5c 27 73 60 c8 8d 78 02 f4 |X...=..\'s`..x..| +000000e0 1d a4 98 09 a3 19 70 69 3c 25 62 66 2a ab 22 23 |......pi<%bf*."#| +000000f0 c5 7b 85 38 4f 2e 09 73 32 a7 bd 3e 9b ad ca 84 |.{.8O..s2..>....| +00000100 07 e6 0f 3a ff 77 c5 9d 41 85 00 8a b6 9b ee b0 |...:.w..A.......| +00000110 a4 3f 2d 4c 4c e6 42 3e bb 51 c8 dd 48 54 f4 0c |.?-LL.B>.Q..HT..| +00000120 8e 47 02 03 01 00 01 a3 46 30 44 30 0e 06 03 55 |.G......F0D0...U| +00000130 1d 0f 01 01 ff 04 04 03 02 05 a0 30 13 06 03 55 |...........0...U| +00000140 1d 25 04 0c 30 0a 06 08 2b 06 01 05 05 07 03 01 |.%..0...+.......| +00000150 30 0c 06 03 55 1d 13 01 01 ff 04 02 30 00 30 0f |0...U.......0.0.| +00000160 06 03 55 1d 11 04 08 30 06 87 04 7f 00 00 01 30 |..U....0.......0| +00000170 0d 06 09 2a 86 48 86 f7 0d 01 01 0b 05 00 03 81 |...*.H..........| +00000180 81 00 46 ab 44 a2 fb 28 54 f8 5a 67 f8 62 94 f1 |..F.D..(T.Zg.b..| +00000190 9a b2 18 9e f2 b1 de 1d 7e 6f 76 95 a9 ba e7 5d |........~ov....]| +000001a0 a8 16 6c 9c f7 09 d3 37 e4 4b 2b 36 7c 01 ad 41 |..l....7.K+6|..A| +000001b0 d2 32 d8 c3 d2 93 f9 10 6b 8e 95 b9 2c 17 8a a3 |.2......k...,...| +000001c0 44 48 bc 59 13 83 16 04 88 a4 81 5c 25 0d 98 0c |DH.Y.......\%...| +000001d0 ac 11 b1 28 56 be 1d cd 61 62 84 09 bf d6 80 c6 |...(V...ab......| +000001e0 45 8d 82 2c b4 d8 83 9b db c9 22 b7 2a 12 11 7b |E..,......".*..{| +000001f0 fa 02 3b c1 c9 ff ea c9 9d a8 49 d3 95 d7 d5 0e |..;.......I.....| +00000200 e5 35 16 03 03 00 86 10 00 00 82 00 80 50 e9 35 |.5...........P.5| +00000210 02 8f b8 95 2f 2c 00 92 dd 06 c9 0b 41 13 2b 1a |..../,......A.+.| +00000220 94 3c 98 24 9e 5b 08 ba aa d2 8c 25 64 01 2c 19 |.<.$.[.....%d.,.| +00000230 2a 10 3d 85 de e6 9d 7e e3 a6 a1 ca 04 85 78 8e |*.=....~......x.| +00000240 4e ff 74 d2 0f 5f c9 6a 27 41 71 78 f9 64 e4 b9 |N.t.._.j'Aqx.d..| +00000250 27 c8 c3 f4 64 f5 e7 9c 5b 02 e5 e7 be a2 aa 5a |'...d...[......Z| +00000260 a6 77 83 7e 6a 4b 5f 18 5c a2 f8 b9 42 3d 06 21 |.w.~jK_.\...B=.!| +00000270 65 88 11 cf 0e 8a 9f c2 0b 7d c4 8e a0 aa 2d d8 |e........}....-.| +00000280 93 15 88 61 8c c4 7c a8 e0 cb 13 6b b0 16 03 03 |...a..|....k....| +00000290 00 88 0f 00 00 84 04 01 00 80 27 77 f1 9a 6e d1 |..........'w..n.| +000002a0 d0 2d e1 cc 69 85 64 67 e0 fa 54 de 93 89 ca e8 |.-..i.dg..T.....| +000002b0 a2 90 09 7b 96 22 f7 d8 f9 3e a5 c3 d0 31 9b 1e |...{."...>...1..| +000002c0 b8 e6 8b 6e 7b 46 87 c2 21 c6 40 b9 d4 ec 54 67 |...n{F..!.@...Tg| +000002d0 ce 49 5e a6 9f 14 cc 84 ea 71 dd e6 b6 f9 e1 2d |.I^......q.....-| +000002e0 d6 dc 35 fa fd ce 39 70 97 15 6e 27 33 a2 da e9 |..5...9p..n'3...| +000002f0 2c a6 5b 1b 18 57 78 a7 47 b8 04 26 35 55 5a 02 |,.[..Wx.G..&5UZ.| +00000300 9a e8 48 73 f7 8a ac e8 59 86 61 2d bd c5 02 a6 |..Hs....Y.a-....| +00000310 72 cc 37 8e ec 93 b5 53 6d f9 14 03 03 00 01 01 |r.7....Sm.......| +00000320 16 03 03 00 40 e0 2f d8 1c fd 1a d0 e1 0c 92 4a |....@./........J| +00000330 8b 2b 01 10 58 8c dc 8f c8 b3 22 42 9b 10 d1 a6 |.+..X....."B....| +00000340 3e fe 3b 94 46 2f 41 ec b6 d3 33 90 95 8c 69 fa |>.;.F/A...3...i.| +00000350 f6 1d 6c a2 45 27 1f d3 d9 6b cb 2d e4 e2 c1 39 |..l.E'...k.-...9| +00000360 5d ed fa a1 b8 |]....| +>>> Flow 4 (server to client) +00000000 14 03 03 00 01 01 16 03 03 00 40 00 00 00 00 00 |..........@.....| +00000010 00 00 00 00 00 00 00 00 00 00 00 37 e0 14 c7 88 |...........7....| +00000020 ef de eb 58 7c bc 28 35 0e 5d 42 c0 45 5e 7c 50 |...X|.(5.]B.E^|P| +00000030 82 5b f6 4d 28 b6 75 7b b0 bf 01 05 b1 16 e1 d8 |.[.M(.u{........| +00000040 96 0c 4e c5 84 19 64 1e ee be 4c 17 03 03 00 40 |..N...d...L....@| +00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000060 6a ca ba a3 69 e8 b8 74 19 dc 93 50 df 1c 62 71 |j...i..t...P..bq| +00000070 54 c0 55 c0 aa 40 8e b9 f6 3c fe 54 6f 36 b8 26 |T.U..@...<.To6.&| +00000080 ea 5b e8 83 fc 7b a0 a8 f6 b1 36 7d 8c db c3 8a |.[...{....6}....| +00000090 15 03 03 00 30 00 00 00 00 00 00 00 00 00 00 00 |....0...........| +000000a0 00 00 00 00 00 2c e0 ed 49 c6 bc 76 c4 9d 2e 1c |.....,..I..v....| +000000b0 ca f8 80 61 b8 11 4a 3f 9f ad 7e 0e 79 58 25 bf |...a..J?..~.yX%.| +000000c0 c5 3f 95 9a e9 |.?...| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv12-ClientAuthRequestedNotGiven b/libgo/go/crypto/tls/testdata/Server-TLSv12-ClientAuthRequestedNotGiven index 924ef9df7e5..7b38a99abb8 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv12-ClientAuthRequestedNotGiven +++ b/libgo/go/crypto/tls/testdata/Server-TLSv12-ClientAuthRequestedNotGiven @@ -1,15 +1,18 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 5d 01 00 00 59 03 03 ee 51 24 51 2c |....]...Y...Q$Q,| -00000010 0b 9f 26 d2 7c e0 8b 8a 9b a8 d3 a9 a7 59 05 a3 |..&.|........Y..| -00000020 67 92 fc 3f cb e8 cd ba 62 b7 19 00 00 04 00 2f |g..?....b....../| -00000030 00 ff 01 00 00 2c 00 0d 00 20 00 1e 06 01 06 02 |.....,... ......| -00000040 06 03 05 01 05 02 05 03 04 01 04 02 04 03 03 01 |................| -00000050 03 02 03 03 02 01 02 02 02 03 00 16 00 00 00 17 |................| -00000060 00 00 |..| +00000000 16 03 01 00 97 01 00 00 93 03 03 23 f3 fb 5f cb |...........#.._.| +00000010 3f 63 8a f2 4c c7 41 cd 64 00 4f 7c 63 66 e1 3f |?c..L.A.d.O|cf.?| +00000020 b6 8d 4e 24 20 35 9c c5 c3 96 e9 00 00 04 00 2f |..N$ 5........./| +00000030 00 ff 01 00 00 66 00 00 00 0e 00 0c 00 00 09 31 |.....f.........1| +00000040 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000050 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 00 18 |................| +00000060 00 16 00 00 00 17 00 00 00 0d 00 30 00 2e 04 03 |...........0....| +00000070 05 03 06 03 08 07 08 08 08 09 08 0a 08 0b 08 04 |................| +00000080 08 05 08 06 04 01 05 01 06 01 03 03 02 03 03 01 |................| +00000090 02 01 03 02 02 02 04 02 05 02 06 02 |............| >>> Flow 2 (server to client) 00000000 16 03 03 00 31 02 00 00 2d 03 03 00 00 00 00 00 |....1...-.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2f 00 00 |............./..| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 00 2f 00 00 |...DOWNGRD.../..| 00000030 05 ff 01 00 01 00 16 03 03 02 59 0b 00 02 55 00 |..........Y...U.| 00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -48,36 +51,37 @@ 00000260 f1 6c 04 ed 73 bb b3 43 77 8d 0c 1c f1 0f a1 d8 |.l..s..Cw.......| 00000270 40 83 61 c9 4c 72 2b 9d ae db 46 06 06 4d f4 c1 |@.a.Lr+...F..M..| 00000280 b3 3e c0 d1 bd 42 d4 db fe 3d 13 60 84 5c 21 d3 |.>...B...=.`.\!.| -00000290 3b e9 fa e7 16 03 03 00 1b 0d 00 00 17 02 01 40 |;..............@| -000002a0 00 10 04 01 04 03 05 01 05 03 06 01 06 03 02 01 |................| -000002b0 02 03 00 00 16 03 03 00 04 0e 00 00 00 |.............| +00000290 3b e9 fa e7 16 03 03 00 21 0d 00 00 1d 02 01 40 |;.......!......@| +000002a0 00 16 08 04 08 05 08 06 04 01 04 03 05 01 05 03 |................| +000002b0 06 01 06 03 02 01 02 03 00 00 16 03 03 00 04 0e |................| +000002c0 00 00 00 |...| >>> Flow 3 (client to server) 00000000 16 03 03 00 07 0b 00 00 03 00 00 00 16 03 03 00 |................| -00000010 86 10 00 00 82 00 80 0b e8 d9 4f fa 7d 63 8c 89 |..........O.}c..| -00000020 b7 c8 73 76 9b fa 7f b6 c3 57 f2 54 75 90 90 ec |..sv.....W.Tu...| -00000030 9e 8d 08 ae 3f dc 6e fa df 2a 32 2b 35 e9 03 f7 |....?.n..*2+5...| -00000040 c5 d1 7c f5 20 1f 77 0a 24 b8 4e 7e 11 fe b0 87 |..|. .w.$.N~....| -00000050 db f6 ff 92 1a fc 6a 8d 48 7e ac bc 95 99 4a f8 |......j.H~....J.| -00000060 1b cc 07 42 48 0c 25 d2 47 82 59 14 76 84 d3 e9 |...BH.%.G.Y.v...| -00000070 d6 0a 5a b1 0a c6 31 3e 80 e2 29 c8 a6 31 dd 64 |..Z...1>..)..1.d| -00000080 96 7a f5 ee d9 0f 03 b5 93 05 b8 a2 04 66 ff fc |.z...........f..| -00000090 f5 2f e7 6c b9 2d 98 14 03 03 00 01 01 16 03 03 |./.l.-..........| -000000a0 00 40 f2 d2 da 46 89 c4 17 25 b8 33 d6 38 46 5c |.@...F...%.3.8F\| -000000b0 80 a0 eb cf fd 5a 27 f3 0b 16 e1 29 bd b8 46 28 |.....Z'....)..F(| -000000c0 11 d3 cc 12 12 96 9b b8 31 52 50 73 81 57 aa 29 |........1RPs.W.)| -000000d0 5c 66 da 39 2d f8 cb 15 e0 01 86 b5 0b d5 1f 56 |\f.9-..........V| -000000e0 23 a0 |#.| +00000010 86 10 00 00 82 00 80 d7 50 22 1d 9e b8 81 12 e5 |........P"......| +00000020 47 e6 65 cf 82 19 a2 43 9a 5c 7b 44 98 eb d9 ac |G.e....C.\{D....| +00000030 e1 4e f5 9d ad bd 0a 0e 17 07 81 b9 b5 4b bb b1 |.N...........K..| +00000040 95 da 0a 82 67 ba 98 1b cc 45 91 62 ee 36 eb e3 |....g....E.b.6..| +00000050 18 30 34 f6 38 ab 3d 0c a7 2b bd 90 94 49 81 af |.04.8.=..+...I..| +00000060 67 a0 f2 b4 0f c0 09 eb c3 23 24 4b 76 3f cb b9 |g........#$Kv?..| +00000070 4c a3 53 a7 f6 53 34 1b 24 24 2f cc 24 d8 fb 12 |L.S..S4.$$/.$...| +00000080 65 60 cf 06 92 c3 7c 63 18 b1 92 88 e3 a8 1d 9c |e`....|c........| +00000090 f7 c1 9a a4 af 78 7d 14 03 03 00 01 01 16 03 03 |.....x}.........| +000000a0 00 40 91 9a 6b 71 c5 3e 88 9a 26 b4 af fa 41 26 |.@..kq.>..&...A&| +000000b0 72 33 a7 72 9b 22 89 d9 a5 ed 3d 0e 0e af c8 ef |r3.r."....=.....| +000000c0 3d c8 89 e4 0d 21 df 06 37 23 0f 50 d1 3e ef af |=....!..7#.P.>..| +000000d0 d8 cd 30 cc c4 18 3a 12 49 c0 0a 21 20 cd ac 66 |..0...:.I..! ..f| +000000e0 96 c3 |..| >>> Flow 4 (server to client) 00000000 14 03 03 00 01 01 16 03 03 00 40 00 00 00 00 00 |..........@.....| -00000010 00 00 00 00 00 00 00 00 00 00 00 65 58 5e 2f 25 |...........eX^/%| -00000020 67 71 87 7d a9 75 73 80 6b 03 76 63 a8 1f 80 06 |gq.}.us.k.vc....| -00000030 0f 78 b0 75 20 9e ab 36 59 d7 f9 88 22 c1 d1 be |.x.u ..6Y..."...| -00000040 c9 d2 c1 13 20 6a 75 07 95 00 ca 17 03 03 00 40 |.... ju........@| +00000010 00 00 00 00 00 00 00 00 00 00 00 2d 70 ad 8f ed |...........-p...| +00000020 c0 cf ce 73 28 76 8f da 65 41 46 53 dd 06 0d cc |...s(v..eAFS....| +00000030 36 cb f3 b8 c7 1f df 53 1a 7d 1e 9f d6 b9 e3 9e |6......S.}......| +00000040 fe a8 d9 91 6c 3b d2 ef b6 30 55 17 03 03 00 40 |....l;...0U....@| 00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000060 25 31 9c 1d 48 d9 c3 e4 59 3a 3a e2 85 3a 78 27 |%1..H...Y::..:x'| -00000070 85 69 63 8e 3c 32 b2 03 65 3f 7a 7f 3b fe b1 83 |.ic.<2..e?z.;...| -00000080 f6 64 a1 3e 83 55 7b 39 2a 01 86 de 79 a3 55 b1 |.d.>.U{9*...y.U.| +00000060 6a 43 95 20 f0 f9 b4 e0 12 24 ae c1 55 c2 ad ec |jC. .....$..U...| +00000070 de 42 1f 0b ff 5b e5 ab 8b aa 72 69 2f 10 12 ca |.B...[....ri/...| +00000080 8c f2 77 be 60 81 ef c9 34 dc d7 68 57 d5 17 aa |..w.`...4..hW...| 00000090 15 03 03 00 30 00 00 00 00 00 00 00 00 00 00 00 |....0...........| -000000a0 00 00 00 00 00 40 26 48 75 e5 e0 83 c0 1a 66 5a |.....@&Hu.....fZ| -000000b0 5f b2 11 a6 b7 a3 4d f2 ca 49 6a f2 48 a1 ee 99 |_.....M..Ij.H...| -000000c0 ff 0d c1 f7 4f |....O| +000000a0 00 00 00 00 00 c0 4b 9e e5 6b 45 60 e1 7b 87 b1 |......K..kE`.{..| +000000b0 76 06 e4 dc d7 01 eb db 04 9c 9b d4 bd 5c e0 18 |v............\..| +000000c0 72 7a 73 93 4f |rzs.O| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv12-ECDHE-ECDSA-AES b/libgo/go/crypto/tls/testdata/Server-TLSv12-ECDHE-ECDSA-AES index 8aa11abc62a..d72746872e2 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv12-ECDHE-ECDSA-AES +++ b/libgo/go/crypto/tls/testdata/Server-TLSv12-ECDHE-ECDSA-AES @@ -1,16 +1,18 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 73 01 00 00 6f 03 03 8b 7a 0c fa 8b |....s...o...z...| -00000010 92 b9 b6 d6 b8 93 50 29 07 2e 8e 70 9b a1 55 65 |......P)...p..Ue| -00000020 ba 05 9d 74 2e 7e a6 2a 10 e1 3c 00 00 04 c0 0a |...t.~.*..<.....| -00000030 00 ff 01 00 00 42 00 0b 00 04 03 00 01 02 00 0a |.....B..........| -00000040 00 0a 00 08 00 1d 00 17 00 19 00 18 00 0d 00 20 |............... | -00000050 00 1e 06 01 06 02 06 03 05 01 05 02 05 03 04 01 |................| -00000060 04 02 04 03 03 01 03 02 03 03 02 01 02 02 02 03 |................| -00000070 00 16 00 00 00 17 00 00 |........| +00000000 16 03 01 00 97 01 00 00 93 03 03 85 04 eb 6f 6a |..............oj| +00000010 88 25 0b 90 fb 37 a8 63 c7 18 1a ac 91 a9 aa 24 |.%...7.c.......$| +00000020 c3 99 1a 69 e5 f5 1e 12 73 ef 1a 00 00 04 c0 0a |...i....s.......| +00000030 00 ff 01 00 00 66 00 00 00 0e 00 0c 00 00 09 31 |.....f.........1| +00000040 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000050 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 00 18 |................| +00000060 00 16 00 00 00 17 00 00 00 0d 00 30 00 2e 04 03 |...........0....| +00000070 05 03 06 03 08 07 08 08 08 09 08 0a 08 0b 08 04 |................| +00000080 08 05 08 06 04 01 05 01 06 01 03 03 02 03 03 01 |................| +00000090 02 01 03 02 02 02 04 02 05 02 06 02 |............| >>> Flow 2 (server to client) 00000000 16 03 03 00 31 02 00 00 2d 03 03 00 00 00 00 00 |....1...-.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 c0 0a 00 00 |................| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 c0 0a 00 00 |...DOWNGRD......| 00000030 05 ff 01 00 01 00 16 03 03 02 0e 0b 00 02 0a 00 |................| 00000040 02 07 00 02 04 30 82 02 00 30 82 01 62 02 09 00 |.....0...0..b...| 00000050 b8 bf 2d 47 a0 d2 eb f4 30 09 06 07 2a 86 48 ce |..-G....0...*.H.| @@ -47,36 +49,36 @@ 00000240 7b 6a 0f 39 95 12 07 8f 2a 16 03 03 00 b7 0c 00 |{j.9....*.......| 00000250 00 b3 03 00 1d 20 2f e5 7d a3 47 cd 62 43 15 28 |..... /.}.G.bC.(| 00000260 da ac 5f bb 29 07 30 ff f6 84 af c4 cf c2 ed 90 |.._.).0.........| -00000270 99 5f 58 cb 3b 74 06 03 00 8b 30 81 88 02 42 00 |._X.;t....0...B.| -00000280 cb 8e af 48 f8 79 66 5b 9a 52 8d 67 ec 13 02 a5 |...H.yf[.R.g....| -00000290 ab 77 9e 15 17 c2 4e ff 7a b4 5b 53 1a 16 22 3f |.w....N.z.[S.."?| -000002a0 b8 83 40 99 64 67 b3 54 19 29 6b 2d a8 3c 63 44 |..@.dg.T.)k-.>> Flow 3 (client to server) -00000000 16 03 03 00 25 10 00 00 21 20 d2 c0 5b 2a f2 05 |....%...! ..[*..| -00000010 4d 57 b0 d0 8b 51 b0 7f 1f 71 8b d9 55 76 46 c9 |MW...Q...q..UvF.| -00000020 a8 40 44 2c a1 51 74 50 4a 22 14 03 03 00 01 01 |.@D,.QtPJ"......| -00000030 16 03 03 00 40 79 6d 1b bc e7 5b 5c 7b 99 62 2b |....@ym...[\{.b+| -00000040 4a 1a b2 0f 76 72 67 d1 ec 25 04 5f fb 25 f4 9c |J...vrg..%._.%..| -00000050 9c 47 bb b9 85 28 59 0c 0c 15 3f 86 a5 16 c8 ef |.G...(Y...?.....| -00000060 a4 e6 8e c0 96 37 47 5a c8 cd f2 90 41 9b 94 dc |.....7GZ....A...| -00000070 ec fe e2 df d4 |.....| +00000000 16 03 03 00 25 10 00 00 21 20 80 d6 42 fa 29 87 |....%...! ..B.).| +00000010 df 45 d0 44 75 c7 bd a9 be e7 8c ef 3f 74 3d bd |.E.Du.......?t=.| +00000020 e2 49 40 ad f9 7f 90 ff 5e 75 14 03 03 00 01 01 |.I@.....^u......| +00000030 16 03 03 00 40 dc c3 d3 7b 19 19 67 e1 f1 f7 3b |....@...{..g...;| +00000040 f7 76 0f da df 38 88 73 61 34 83 04 b9 ab 61 72 |.v...8.sa4....ar| +00000050 2f 38 cb c3 1b 04 60 20 32 a8 db 46 63 85 f2 21 |/8....` 2..Fc..!| +00000060 54 6e 9d 5d ba 0a 07 2e 9d 38 af 76 0e 29 b1 c6 |Tn.].....8.v.)..| +00000070 d5 b0 f8 b3 39 |....9| >>> Flow 4 (server to client) 00000000 14 03 03 00 01 01 16 03 03 00 40 00 00 00 00 00 |..........@.....| -00000010 00 00 00 00 00 00 00 00 00 00 00 8a 19 1e 82 d0 |................| -00000020 46 f4 79 8d 9b fd 55 25 a9 6b d8 30 b3 41 f8 df |F.y...U%.k.0.A..| -00000030 a5 f8 9d 4c fe cc e1 1c 62 70 cf 60 12 cb 14 3e |...L....bp.`...>| -00000040 86 e9 d1 bb 46 60 7d b5 74 5f f5 17 03 03 00 40 |....F`}.t_.....@| +00000010 00 00 00 00 00 00 00 00 00 00 00 4f dc d7 df d3 |...........O....| +00000020 ab 43 f7 20 57 51 28 d2 0a ce ac e0 88 5c 01 c5 |.C. WQ(......\..| +00000030 22 f7 37 e8 ac d3 38 ab 1b 43 53 b1 a7 35 6f 86 |".7...8..CS..5o.| +00000040 2b a5 9b 98 8f 9d a3 ff 11 d2 c7 17 03 03 00 40 |+..............@| 00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000060 97 1c 70 9d cf 17 89 8c c7 ad 84 38 6e f5 c6 d1 |..p........8n...| -00000070 c8 6e b2 a2 69 27 9a 59 fb bc af c0 15 47 40 b9 |.n..i'.Y.....G@.| -00000080 e1 35 9b 37 50 9f 05 53 60 f8 f9 91 40 67 36 a8 |.5.7P..S`...@g6.| +00000060 3f 4c d0 ee d7 12 3c ef 73 55 b0 8d b7 78 8a de |?L....<.sU...x..| +00000070 d9 a5 c0 58 25 95 ae 8c 0f 85 bd ee 93 80 f6 3d |...X%..........=| +00000080 ac 28 a6 87 98 d2 4c e4 54 a6 a5 ef 12 70 0c 37 |.(....L.T....p.7| 00000090 15 03 03 00 30 00 00 00 00 00 00 00 00 00 00 00 |....0...........| -000000a0 00 00 00 00 00 0f 90 a8 00 9e 0e 51 29 b5 96 da |...........Q)...| -000000b0 b1 0d 81 7b 71 ff c9 de f8 aa c4 bd e1 7d 0d 35 |...{q........}.5| -000000c0 b1 ed ae 20 3c |... <| +000000a0 00 00 00 00 00 e3 51 95 2e 0c 71 a9 e6 c6 4d bc |......Q...q...M.| +000000b0 2e 89 99 c0 db e8 59 0a e0 a2 f8 46 ef 3b 20 c6 |......Y....F.; .| +000000c0 8d a4 55 a2 5e |..U.^| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv12-ExportKeyingMaterial b/libgo/go/crypto/tls/testdata/Server-TLSv12-ExportKeyingMaterial index 6415c42928d..7d7ee638616 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv12-ExportKeyingMaterial +++ b/libgo/go/crypto/tls/testdata/Server-TLSv12-ExportKeyingMaterial @@ -1,19 +1,22 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 ab 01 00 00 a7 03 03 7a 49 9d 20 62 |...........zI. b| -00000010 45 8d 0c 1e 8e eb b1 5e 73 62 6d 48 61 31 cb 1a |E......^sbmHa1..| -00000020 89 b2 68 1b 2c cb 35 87 2a 17 fb 00 00 38 c0 2c |..h.,.5.*....8.,| +00000000 16 03 01 00 cf 01 00 00 cb 03 03 79 bf 0b 29 ec |...........y..).| +00000010 6a 0b 84 1e 2c d5 bf 30 b7 55 b9 7b 77 69 8f 9a |j...,..0.U.{wi..| +00000020 71 34 c9 83 d1 af de 50 d5 d6 fc 00 00 38 c0 2c |q4.....P.....8.,| 00000030 c0 30 00 9f cc a9 cc a8 cc aa c0 2b c0 2f 00 9e |.0.........+./..| 00000040 c0 24 c0 28 00 6b c0 23 c0 27 00 67 c0 0a c0 14 |.$.(.k.#.'.g....| 00000050 00 39 c0 09 c0 13 00 33 00 9d 00 9c 00 3d 00 3c |.9.....3.....=.<| -00000060 00 35 00 2f 00 ff 01 00 00 46 00 0b 00 04 03 00 |.5./.....F......| -00000070 01 02 00 0a 00 0a 00 08 00 1d 00 17 00 19 00 18 |................| -00000080 00 23 00 00 00 16 00 00 00 17 00 00 00 0d 00 20 |.#............. | -00000090 00 1e 06 01 06 02 06 03 05 01 05 02 05 03 04 01 |................| -000000a0 04 02 04 03 03 01 03 02 03 03 02 01 02 02 02 03 |................| +00000060 00 35 00 2f 00 ff 01 00 00 6a 00 00 00 0e 00 0c |.5./.....j......| +00000070 00 00 09 31 32 37 2e 30 2e 30 2e 31 00 0b 00 04 |...127.0.0.1....| +00000080 03 00 01 02 00 0a 00 0c 00 0a 00 1d 00 17 00 1e |................| +00000090 00 19 00 18 00 23 00 00 00 16 00 00 00 17 00 00 |.....#..........| +000000a0 00 0d 00 30 00 2e 04 03 05 03 06 03 08 07 08 08 |...0............| +000000b0 08 09 08 0a 08 0b 08 04 08 05 08 06 04 01 05 01 |................| +000000c0 06 01 03 03 02 03 03 01 02 01 03 02 02 02 04 02 |................| +000000d0 05 02 06 02 |....| >>> Flow 2 (server to client) 00000000 16 03 03 00 35 02 00 00 31 03 03 00 00 00 00 00 |....5...1.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 c0 30 00 00 |.............0..| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 c0 30 00 00 |...DOWNGRD...0..| 00000030 09 00 23 00 00 ff 01 00 01 00 16 03 03 02 59 0b |..#...........Y.| 00000040 00 02 55 00 02 52 00 02 4f 30 82 02 4b 30 82 01 |..U..R..O0..K0..| 00000050 b4 a0 03 02 01 02 02 09 00 e8 f0 9d 3f e2 5b ea |............?.[.| @@ -55,38 +58,38 @@ 00000290 84 5c 21 d3 3b e9 fa e7 16 03 03 00 ac 0c 00 00 |.\!.;...........| 000002a0 a8 03 00 1d 20 2f e5 7d a3 47 cd 62 43 15 28 da |.... /.}.G.bC.(.| 000002b0 ac 5f bb 29 07 30 ff f6 84 af c4 cf c2 ed 90 99 |._.).0..........| -000002c0 5f 58 cb 3b 74 06 01 00 80 7f ee dd 6b 38 23 29 |_X.;t.......k8#)| -000002d0 56 ff d2 c2 08 86 52 b6 e3 8a d5 fe 47 79 5e ef |V.....R.....Gy^.| -000002e0 99 7a 0b d7 44 84 b9 2f 7a 2c 64 4f b3 7c aa 44 |.z..D../z,dO.|.D| -000002f0 aa 38 5d 1b 69 16 9f f2 7d f8 24 43 47 ad 31 bc |.8].i...}.$CG.1.| -00000300 f5 3d b8 c8 33 6e 3f 6f 2b ea 19 a2 30 32 2b 2a |.=..3n?o+...02+*| -00000310 81 64 3c ee ed 78 4c fa 80 fd e7 5f ef 85 98 d4 |.d<..xL...._....| -00000320 48 06 b8 f5 5e 1e e6 f3 42 a8 2f 99 5f ea b3 ba |H...^...B./._...| -00000330 8e a8 31 99 85 f2 46 11 a3 d2 c6 81 4b f1 22 7d |..1...F.....K."}| -00000340 d7 45 04 f1 a6 d6 7e 8f 9d 16 03 03 00 04 0e 00 |.E....~.........| +000002c0 5f 58 cb 3b 74 08 04 00 80 36 12 82 aa d1 40 60 |_X.;t....6....@`| +000002d0 6c fb da 0b 04 f6 23 94 3f 3d 8c a5 f4 fe ed 1f |l.....#.?=......| +000002e0 be 25 85 94 c9 2f 19 64 52 2b 8a 13 29 52 ae 77 |.%.../.dR+..)R.w| +000002f0 ca 24 40 f1 31 1c f3 aa 33 29 1f cc b0 a3 8b e6 |.$@.1...3)......| +00000300 c3 26 90 e4 11 48 e6 91 a6 5d 5e c6 18 8d 4f 2c |.&...H...]^...O,| +00000310 21 be bc 13 4d de bb 68 42 0b e1 29 3e 8e fc b9 |!...M..hB..)>...| +00000320 45 ed c4 87 ed 62 1d 04 c0 4f d5 f5 94 62 65 07 |E....b...O...be.| +00000330 8c f0 00 3d 47 f6 f5 93 e3 a9 69 ce 79 8a e5 24 |...=G.....i.y..$| +00000340 01 d4 28 e6 f5 f5 a9 7e ab 16 03 03 00 04 0e 00 |..(....~........| 00000350 00 00 |..| >>> Flow 3 (client to server) -00000000 16 03 03 00 25 10 00 00 21 20 22 e7 e7 61 a9 27 |....%...! "..a.'| -00000010 7b 93 d1 42 76 dd 16 32 e8 92 37 37 2f fd 0d 92 |{..Bv..2..77/...| -00000020 1f 8e b7 c5 69 40 d3 1a 7d 06 14 03 03 00 01 01 |....i@..}.......| -00000030 16 03 03 00 28 4e 7f b2 a2 20 5d cf a1 5a de 42 |....(N... ]..Z.B| -00000040 c5 72 c3 ef c3 23 a7 2c f3 5b 3d a4 81 21 ac db |.r...#.,.[=..!..| -00000050 44 1c f3 a1 83 aa a1 b7 85 9a c7 23 03 |D..........#.| +00000000 16 03 03 00 25 10 00 00 21 20 ea 09 8a 21 18 89 |....%...! ...!..| +00000010 7d 4f ee 95 8e 6c 1a 07 22 59 e7 f9 05 41 2a c2 |}O...l.."Y...A*.| +00000020 ad 51 71 9c a4 0e 08 eb 49 71 14 03 03 00 01 01 |.Qq.....Iq......| +00000030 16 03 03 00 28 6a ab 19 f6 b6 cb 70 34 ee 73 d2 |....(j.....p4.s.| +00000040 05 bf 99 37 44 b7 f9 1e b1 8a 3d f9 13 bd 0c 77 |...7D.....=....w| +00000050 02 b0 64 08 f9 d9 f2 96 b4 5b 87 ff 0b |..d......[...| >>> Flow 4 (server to client) 00000000 16 03 03 00 82 04 00 00 7e 00 00 00 00 00 78 50 |........~.....xP| 00000010 46 ad c1 db a8 38 86 7b 2b bb fd d0 c3 42 3e 00 |F....8.{+....B>.| 00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 94 |................| -00000030 6f ec 80 83 61 3f 55 e3 9d ab 39 87 5b d0 ba 44 |o...a?U...9.[..D| -00000040 07 91 a8 d0 37 8a 7e 51 0d 00 97 ec 1b 61 f3 3b |....7.~Q.....a.;| -00000050 9f 29 24 d5 98 f7 4d 3b 80 ef 2f 4d aa 02 98 93 |.)$...M;../M....| -00000060 81 03 87 d8 06 33 94 f5 ed 5d cc 8f 57 97 70 26 |.....3...]..W.p&| -00000070 00 dc 0d d2 96 16 a2 6d fc be 8d 4b fa 5f b3 04 |.......m...K._..| -00000080 ce bb 48 ee c0 75 23 14 03 03 00 01 01 16 03 03 |..H..u#.........| -00000090 00 28 00 00 00 00 00 00 00 00 3a 69 e0 40 e2 d1 |.(........:i.@..| -000000a0 a6 96 33 0f b3 58 5a dc 41 ea d1 80 44 66 9f 2e |..3..XZ.A...Df..| -000000b0 00 e4 9e 10 13 56 b4 1b c9 42 17 03 03 00 25 00 |.....V...B....%.| -000000c0 00 00 00 00 00 00 01 88 f3 d9 5b ed 6b 3c 70 0c |..........[.k...s...(..$.| +00000050 a9 3f 60 a3 7a f2 c1 a6 12 0e 69 3b 72 89 dd 36 |.?`.z.....i;r..6| +00000060 d8 ff 80 5d 71 33 94 32 01 77 ce 77 5e ac b8 05 |...]q3.2.w.w^...| +00000070 69 68 e5 81 51 4d 52 f6 e9 c5 cd 70 56 23 3c aa |ih..QMR....pV#<.| +00000080 2e c6 a2 d6 e3 5f 29 14 03 03 00 01 01 16 03 03 |....._).........| +00000090 00 28 00 00 00 00 00 00 00 00 59 27 e3 e7 05 60 |.(........Y'...`| +000000a0 03 68 93 6d 28 1d 8e 7f f1 c8 a6 eb b4 57 a5 22 |.h.m(........W."| +000000b0 98 ce 7e 56 00 44 fe d5 5e 26 17 03 03 00 25 00 |..~V.D..^&....%.| +000000c0 00 00 00 00 00 00 01 9d 87 53 e9 29 e4 d7 45 29 |.........S.)..E)| +000000d0 ef 71 a6 7e b8 99 d4 4f 08 da 11 6b 9b d2 20 b9 |.q.~...O...k.. .| +000000e0 c4 ae 7f 84 15 03 03 00 1a 00 00 00 00 00 00 00 |................| +000000f0 02 06 17 a2 45 91 d0 b0 50 aa 8f a2 f1 8b 48 cf |....E...P.....H.| +00000100 40 87 a4 |@..| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv12-IssueTicket b/libgo/go/crypto/tls/testdata/Server-TLSv12-IssueTicket index feced4bb8ff..925fad087f5 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv12-IssueTicket +++ b/libgo/go/crypto/tls/testdata/Server-TLSv12-IssueTicket @@ -1,15 +1,18 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 61 01 00 00 5d 03 03 b1 be 1f 18 b6 |....a...].......| -00000010 a2 5d 4f 2f a0 e5 3b c4 4a 2d 76 bd 98 92 32 85 |.]O/..;.J-v...2.| -00000020 9d 6b 9e 10 4b fc 03 7b fb bc e4 00 00 04 00 2f |.k..K..{......./| -00000030 00 ff 01 00 00 30 00 23 00 00 00 0d 00 20 00 1e |.....0.#..... ..| -00000040 06 01 06 02 06 03 05 01 05 02 05 03 04 01 04 02 |................| -00000050 04 03 03 01 03 02 03 03 02 01 02 02 02 03 00 16 |................| -00000060 00 00 00 17 00 00 |......| +00000000 16 03 01 00 9b 01 00 00 97 03 03 d7 1e 2f 33 47 |............./3G| +00000010 7e 92 97 4b 62 40 60 32 de ee 2e bd 5c 57 3c f8 |~..Kb@`2....\W<.| +00000020 6a 4a 78 23 4f ad db 3c 33 ea f2 00 00 04 00 2f |jJx#O..<3....../| +00000030 00 ff 01 00 00 6a 00 00 00 0e 00 0c 00 00 09 31 |.....j.........1| +00000040 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000050 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 00 18 |................| +00000060 00 23 00 00 00 16 00 00 00 17 00 00 00 0d 00 30 |.#.............0| +00000070 00 2e 04 03 05 03 06 03 08 07 08 08 08 09 08 0a |................| +00000080 08 0b 08 04 08 05 08 06 04 01 05 01 06 01 03 03 |................| +00000090 02 03 03 01 02 01 03 02 02 02 04 02 05 02 06 02 |................| >>> Flow 2 (server to client) 00000000 16 03 03 00 35 02 00 00 31 03 03 00 00 00 00 00 |....5...1.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2f 00 00 |............./..| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 00 2f 00 00 |...DOWNGRD.../..| 00000030 09 00 23 00 00 ff 01 00 01 00 16 03 03 02 59 0b |..#...........Y.| 00000040 00 02 55 00 02 52 00 02 4f 30 82 02 4b 30 82 01 |..U..R..O0..K0..| 00000050 b4 a0 03 02 01 02 02 09 00 e8 f0 9d 3f e2 5b ea |............?.[.| @@ -51,39 +54,39 @@ 00000290 84 5c 21 d3 3b e9 fa e7 16 03 03 00 04 0e 00 00 |.\!.;...........| 000002a0 00 |.| >>> Flow 3 (client to server) -00000000 16 03 03 00 86 10 00 00 82 00 80 8f f0 5a 2f 01 |.............Z/.| -00000010 99 79 e6 f2 a0 31 a4 02 d8 c0 1e 70 e8 67 58 bd |.y...1.....p.gX.| -00000020 a0 2a 37 3a 3c 2d 45 53 e7 d2 7d 94 16 ea 10 5c |.*7:<-ES..}....\| -00000030 07 91 36 87 ab f6 d1 7a c7 40 a7 7f 23 1b ef 33 |..6....z.@..#..3| -00000040 80 ea 7d 75 d3 62 de 7d d2 6b cf 90 54 0f e7 02 |..}u.b.}.k..T...| -00000050 03 85 ef 38 f4 e9 88 8f e4 7c 8c ac 95 e6 88 f4 |...8.....|......| -00000060 05 f7 c7 89 4a 64 de 34 5f 09 c2 84 19 36 c1 42 |....Jd.4_....6.B| -00000070 ea 03 69 38 7e 32 10 8a b5 cf c7 2f 8e c6 5f 29 |..i8~2...../.._)| -00000080 4e 8a 8e d4 17 6c 9c 18 7b ea df 14 03 03 00 01 |N....l..{.......| -00000090 01 16 03 03 00 40 5f 50 47 5a 97 52 9d 11 b5 db |.....@_PGZ.R....| -000000a0 ab 7b b9 e3 74 52 c5 cd f4 73 18 cf 12 c4 fe 07 |.{..tR...s......| -000000b0 88 5f a9 18 7a 12 23 67 ec 72 07 9f 19 b5 bf 52 |._..z.#g.r.....R| -000000c0 2f dd 26 66 25 98 8c 5a 07 0f 26 c1 b0 38 6c 01 |/.&f%..Z..&..8l.| -000000d0 e4 f4 ee dd b3 72 |.....r| +00000000 16 03 03 00 86 10 00 00 82 00 80 d7 37 f9 ec 2b |............7..+| +00000010 61 07 05 d0 90 28 33 64 14 8c 71 16 05 0f 72 31 |a....(3d..q...r1| +00000020 83 ea 88 be b3 27 1a 4a 09 c5 28 66 ea 14 bb 17 |.....'.J..(f....| +00000030 2e 12 56 d1 c5 7e cf 35 a8 77 4d 48 1a a1 b1 bd |..V..~.5.wMH....| +00000040 63 a4 40 8c 04 20 00 5c d7 ac 22 34 ac 46 08 ea |c.@.. .\.."4.F..| +00000050 53 e6 7e aa 6f 19 03 ec e8 17 3a f9 26 35 0e 3e |S.~.o.....:.&5.>| +00000060 47 1a 3e 13 57 a9 e9 71 7a 09 78 82 a9 7a ea d5 |G.>.W..qz.x..z..| +00000070 7d 14 15 b5 98 0b 92 9c e3 e3 82 6f 95 ba 00 b7 |}..........o....| +00000080 6f b6 24 e1 be 14 39 63 6f 57 cb 14 03 03 00 01 |o.$...9coW......| +00000090 01 16 03 03 00 40 3a 85 bc 9c 00 57 6c db cf e8 |.....@:....Wl...| +000000a0 99 7a 7c ee 09 df 56 8a 3a ac dd 1f f9 bf 1f 6c |.z|...V.:......l| +000000b0 dc 38 5b 2d 6a ad 36 26 b7 4f 23 7f 23 5f 69 fa |.8[-j.6&.O#.#_i.| +000000c0 e5 ea f4 1e 26 6e e4 a6 80 c1 b6 29 e7 0b b8 03 |....&n.....)....| +000000d0 8e 88 d3 29 a2 99 |...)..| >>> Flow 4 (server to client) 00000000 16 03 03 00 82 04 00 00 7e 00 00 00 00 00 78 50 |........~.....xP| 00000010 46 ad c1 db a8 38 86 7b 2b bb fd d0 c3 42 3e 00 |F....8.{+....B>.| 00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 94 |................| -00000030 6f 2c 9f 83 61 0b b1 b7 9e 10 2d 0c 56 e8 70 66 |o,..a.....-.V.pf| -00000040 ad de b1 15 74 2f 8b 08 8c 96 bb 4b 1b 4e dd 81 |....t/.....K.N..| -00000050 0e bf 84 4d 43 8f c0 7e a0 7f be c0 59 bf 83 26 |...MC..~....Y..&| -00000060 0f a2 22 52 2c 33 94 5a 77 54 f3 b5 f2 22 51 d5 |.."R,3.ZwT..."Q.| -00000070 24 c2 60 c3 2e 0f 9c 5e 33 3b e8 7c 52 2a 76 08 |$.`....^3;.|R*v.| -00000080 58 ac 47 98 bc 36 b6 14 03 03 00 01 01 16 03 03 |X.G..6..........| +00000030 6f 2c 9f 83 61 fe 79 79 ae dc c2 a0 99 e2 59 46 |o,..a.yy......YF| +00000040 79 88 b8 ed 74 da ef da 3e 7e 69 af 34 63 b3 7f |y...t...>~i.4c..| +00000050 52 e1 07 4d f8 40 69 63 85 8c 66 a6 d6 f7 b7 b0 |R..M.@ic..f.....| +00000060 f2 d4 12 f4 2a 33 94 64 76 91 5b 6c 7d 49 37 3c |....*3.dv.[l}I7<| +00000070 0b 76 3e d6 5c 0b 65 79 96 31 51 46 01 51 94 38 |.v>.\.ey.1QF.Q.8| +00000080 5b 51 d5 2d 1a 8b 19 14 03 03 00 01 01 16 03 03 |[Q.-............| 00000090 00 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |.@..............| -000000a0 00 00 31 fa c3 6c 95 c0 86 a5 55 30 41 c3 2d 6b |..1..l....U0A.-k| -000000b0 a5 00 0b af 33 63 de 80 01 3d 7a 38 8e a7 f4 b1 |....3c...=z8....| -000000c0 2d bb e3 1d 1a b4 61 18 b5 d9 d1 7f d1 9a e7 e8 |-.....a.........| -000000d0 49 ee 17 03 03 00 40 00 00 00 00 00 00 00 00 00 |I.....@.........| -000000e0 00 00 00 00 00 00 00 a6 d5 e4 a8 9b d3 7d 72 1c |.............}r.| -000000f0 ff 14 03 68 34 c9 ca 0d 2e 80 a1 09 f7 92 f6 86 |...h4...........| -00000100 44 22 e8 1c ea e9 dd cc a7 92 9a 72 ec 22 5b 82 |D".........r."[.| -00000110 7b 43 02 f7 fa 59 7b 15 03 03 00 30 00 00 00 00 |{C...Y{....0....| -00000120 00 00 00 00 00 00 00 00 00 00 00 00 5f ab 03 1d |............_...| -00000130 08 72 07 6d 78 66 5b 18 ec 3a b7 ea 75 96 ce 95 |.r.mxf[..:..u...| -00000140 0c c9 6f 86 91 14 30 d6 2e 5d b1 b4 |..o...0..]..| +000000a0 00 00 99 ca bd 2f c3 31 77 54 b5 70 de 96 e5 30 |...../.1wT.p...0| +000000b0 ad 2e 6b 03 af f0 42 38 b6 70 dd 81 35 65 b6 fe |..k...B8.p..5e..| +000000c0 f6 d8 44 f3 c1 98 30 f4 21 16 06 57 b4 e8 c1 ec |..D...0.!..W....| +000000d0 bc 12 17 03 03 00 40 00 00 00 00 00 00 00 00 00 |......@.........| +000000e0 00 00 00 00 00 00 00 f8 26 b5 28 2d 4d 0a 05 da |........&.(-M...| +000000f0 84 66 ae ac ee b1 fa 31 96 76 df bd 52 c6 d6 2c |.f.....1.v..R..,| +00000100 c5 39 c9 f9 eb c4 97 8f d1 c2 a4 1f e9 28 3d 81 |.9...........(=.| +00000110 64 7a 7d 41 f3 1d be 15 03 03 00 30 00 00 00 00 |dz}A.......0....| +00000120 00 00 00 00 00 00 00 00 00 00 00 00 20 cc 54 9c |............ .T.| +00000130 9e 4a cc fc 9b 0d 35 59 cd 9b 49 74 1a aa fd f6 |.J....5Y..It....| +00000140 4d dd 0e 9e c8 4f 3a 8b a8 7a a6 d5 |M....O:..z..| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv12-IssueTicketPreDisable b/libgo/go/crypto/tls/testdata/Server-TLSv12-IssueTicketPreDisable index 467e3324898..d1a34805e67 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv12-IssueTicketPreDisable +++ b/libgo/go/crypto/tls/testdata/Server-TLSv12-IssueTicketPreDisable @@ -1,15 +1,18 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 61 01 00 00 5d 03 03 91 2f b7 db 1e |....a...].../...| -00000010 41 ac c6 17 1d 0f 0c 8e 86 15 e0 de e9 c8 6b f5 |A.............k.| -00000020 69 c7 bf ad ff 63 58 2b b1 79 a6 00 00 04 00 2f |i....cX+.y...../| -00000030 00 ff 01 00 00 30 00 23 00 00 00 0d 00 20 00 1e |.....0.#..... ..| -00000040 06 01 06 02 06 03 05 01 05 02 05 03 04 01 04 02 |................| -00000050 04 03 03 01 03 02 03 03 02 01 02 02 02 03 00 16 |................| -00000060 00 00 00 17 00 00 |......| +00000000 16 03 01 00 9b 01 00 00 97 03 03 b9 ed cc cc b2 |................| +00000010 93 69 38 bf d0 24 20 b1 24 99 8a 4d b2 81 5d 58 |.i8..$ .$..M..]X| +00000020 b7 a0 b1 a3 ef fd 21 01 75 01 b3 00 00 04 00 2f |......!.u....../| +00000030 00 ff 01 00 00 6a 00 00 00 0e 00 0c 00 00 09 31 |.....j.........1| +00000040 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000050 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 00 18 |................| +00000060 00 23 00 00 00 16 00 00 00 17 00 00 00 0d 00 30 |.#.............0| +00000070 00 2e 04 03 05 03 06 03 08 07 08 08 08 09 08 0a |................| +00000080 08 0b 08 04 08 05 08 06 04 01 05 01 06 01 03 03 |................| +00000090 02 03 03 01 02 01 03 02 02 02 04 02 05 02 06 02 |................| >>> Flow 2 (server to client) 00000000 16 03 03 00 35 02 00 00 31 03 03 00 00 00 00 00 |....5...1.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2f 00 00 |............./..| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 00 2f 00 00 |...DOWNGRD.../..| 00000030 09 00 23 00 00 ff 01 00 01 00 16 03 03 02 59 0b |..#...........Y.| 00000040 00 02 55 00 02 52 00 02 4f 30 82 02 4b 30 82 01 |..U..R..O0..K0..| 00000050 b4 a0 03 02 01 02 02 09 00 e8 f0 9d 3f e2 5b ea |............?.[.| @@ -51,39 +54,39 @@ 00000290 84 5c 21 d3 3b e9 fa e7 16 03 03 00 04 0e 00 00 |.\!.;...........| 000002a0 00 |.| >>> Flow 3 (client to server) -00000000 16 03 03 00 86 10 00 00 82 00 80 c5 0c 17 b1 b2 |................| -00000010 65 0b b7 7b 45 6f cb 7d b4 9c 5c 82 3a 1a 75 11 |e..{Eo.}..\.:.u.| -00000020 22 6f 41 3a 81 e2 81 2e 74 f8 70 61 fd e1 7c ce |"oA:....t.pa..|.| -00000030 bf 06 d7 29 77 07 b3 9d cc 33 25 53 17 12 43 ae |...)w....3%S..C.| -00000040 4f df ad a4 3e 49 6e 97 50 b6 23 d0 fa 3d a6 bc |O...>In.P.#..=..| -00000050 38 d8 5f 2b 45 a7 d0 aa cd b1 39 03 8f 62 9e 46 |8._+E.....9..b.F| -00000060 50 d4 83 1d b8 76 41 29 d4 40 9a 65 41 8d 1c f0 |P....vA).@.eA...| -00000070 d4 4d 88 d2 5e 42 ec c8 86 d6 fd df 65 d8 f1 82 |.M..^B......e...| -00000080 8f 6a 80 31 1a 0e fc 13 2b 90 a8 14 03 03 00 01 |.j.1....+.......| -00000090 01 16 03 03 00 40 50 ad ed 91 c4 6a ed f8 aa 06 |.....@P....j....| -000000a0 9e 13 03 38 bf 83 ef 4b 8e d5 89 d4 a3 f8 d9 8d |...8...K........| -000000b0 bb 88 72 a6 16 f6 5d d5 ca 55 bb e4 76 47 08 35 |..r...]..U..vG.5| -000000c0 b9 fb 92 a4 0a b9 36 d7 62 44 81 e8 cf db ad 9a |......6.bD......| -000000d0 6d 72 c0 af 70 bd |mr..p.| +00000000 16 03 03 00 86 10 00 00 82 00 80 35 f0 ea c2 96 |...........5....| +00000010 09 7c b6 2c 8a 53 e4 52 0f 70 ba 1d 61 cf 8f 2d |.|.,.S.R.p..a..-| +00000020 8a b8 c7 0f 3b 50 41 67 60 f1 e6 5c 72 4a 48 69 |....;PAg`..\rJHi| +00000030 a5 43 c8 ab cb 3a 33 ab fd 56 f1 53 1f 18 85 c0 |.C...:3..V.S....| +00000040 c0 3a 2d 97 65 e1 00 89 c0 9f 16 42 c7 ed 74 17 |.:-.e......B..t.| +00000050 f4 35 e9 6f c5 9f e2 68 70 b1 7d fc 6e 5b a5 5d |.5.o...hp.}.n[.]| +00000060 d0 16 28 c7 65 8a 7a 50 e4 48 d0 73 4a 94 59 cf |..(.e.zP.H.sJ.Y.| +00000070 ad 3f 44 78 3d 6b 90 53 2e 28 a2 9b c5 85 ea 51 |.?Dx=k.S.(.....Q| +00000080 58 2c 6d 40 c2 15 57 ad 76 6d 86 14 03 03 00 01 |X,m@..W.vm......| +00000090 01 16 03 03 00 40 84 60 b6 51 55 96 d1 32 48 dd |.....@.`.QU..2H.| +000000a0 d3 31 5e 18 3a fc 94 21 52 81 8f 48 5a a9 f3 71 |.1^.:..!R..HZ..q| +000000b0 e1 0e d6 1c 20 68 a3 94 c3 4c 84 b3 08 85 96 5c |.... h...L.....\| +000000c0 16 f3 1e 5d cc 6b 2b 42 3f f8 39 64 65 33 9b 18 |...].k+B?.9de3..| +000000d0 ee 67 13 ab 57 52 |.g..WR| >>> Flow 4 (server to client) 00000000 16 03 03 00 82 04 00 00 7e 00 00 00 00 00 78 50 |........~.....xP| 00000010 46 ad c1 db a8 38 86 7b 2b bb fd d0 c3 42 3e 00 |F....8.{+....B>.| 00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 94 |................| -00000030 6f 2c 9f 83 61 2e fe 48 fe f6 bb 98 a0 6f b0 be |o,..a..H.....o..| -00000040 9e 86 d7 b2 f2 67 c7 44 c7 3d e4 2b de d0 f4 d2 |.....g.D.=.+....| -00000050 17 51 84 8e 7a a7 80 c4 65 14 f7 49 09 68 15 56 |.Q..z...e..I.h.V| -00000060 68 32 41 d1 6f 33 94 a1 3a c9 37 20 5d e6 b0 6f |h2A.o3..:.7 ]..o| -00000070 37 0a 10 e3 28 e1 34 b6 6d e6 7a 44 24 7f 2f cf |7...(.4.m.zD$./.| -00000080 1b ae dd 4c d0 11 75 14 03 03 00 01 01 16 03 03 |...L..u.........| +00000030 6f 2c 9f 83 61 70 4f 8e 34 f4 65 e4 64 ba af 8d |o,..apO.4.e.d...| +00000040 55 d8 8a c4 90 a4 94 d1 84 44 51 72 f0 79 b3 2b |U........DQr.y.+| +00000050 c3 49 48 58 e7 66 8c 3d 60 dd 65 ba 93 0a f1 45 |.IHX.f.=`.e....E| +00000060 28 83 56 19 28 33 94 dd d4 29 db f0 80 d1 b2 0a |(.V.(3...)......| +00000070 ef 69 03 b5 fa 19 82 a9 0e 42 b0 bb c2 b5 c7 b5 |.i.......B......| +00000080 92 1f e6 3b 38 e3 85 14 03 03 00 01 01 16 03 03 |...;8...........| 00000090 00 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |.@..............| -000000a0 00 00 7e 4a 31 e8 7d c6 eb 34 56 3b 62 0c 11 a2 |..~J1.}..4V;b...| -000000b0 f0 bd 9b 9a 4c c9 39 2d ed 21 dd 0c 72 3a 92 e1 |....L.9-.!..r:..| -000000c0 0f b3 7f 71 c5 cf 2a 6f 68 bc 8e 84 7e d5 10 2e |...q..*oh...~...| -000000d0 c3 d4 17 03 03 00 40 00 00 00 00 00 00 00 00 00 |......@.........| -000000e0 00 00 00 00 00 00 00 43 76 cc 74 b3 1c 89 c0 6b |.......Cv.t....k| -000000f0 96 f7 2c 84 c1 0a 6e d6 7f b4 76 76 2c 2f 74 6a |..,...n...vv,/tj| -00000100 c7 4e 18 69 1c 97 cd ca f2 7a 33 01 3e 6f bb 54 |.N.i.....z3.>o.T| -00000110 49 4e 8e 1d f4 13 74 15 03 03 00 30 00 00 00 00 |IN....t....0....| -00000120 00 00 00 00 00 00 00 00 00 00 00 00 2d 70 b1 13 |............-p..| -00000130 a9 e3 72 ca 05 8e 8d b7 f4 97 de 58 46 aa 2a 9c |..r........XF.*.| -00000140 2f 8c 3e 59 7b 64 e5 51 61 7f a6 39 |/.>Y{d.Qa..9| +000000a0 00 00 a3 42 c4 79 0d 44 92 ab af f9 a0 f2 3f 10 |...B.y.D......?.| +000000b0 f6 51 24 66 e4 e1 87 b1 5b 21 4e 0d 77 12 93 b8 |.Q$f....[!N.w...| +000000c0 19 21 2e c5 0f 29 3c 5a 3b dd 8f 96 41 7b 31 9e |.!...)...Ky..i\P| +00000140 24 dc 81 e0 28 97 53 e4 a1 36 ef bc |$...(.S..6..| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv12-P256 b/libgo/go/crypto/tls/testdata/Server-TLSv12-P256 new file mode 100644 index 00000000000..5295d60a8df --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Server-TLSv12-P256 @@ -0,0 +1,85 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 8f 01 00 00 8b 03 03 e8 ef f7 4f 44 |..............OD| +00000010 1a 63 08 10 fe aa 68 d5 75 18 f5 6c de 83 50 d2 |.c....h.u..l..P.| +00000020 bb 86 6e 48 d0 cb 97 c4 56 46 9f 00 00 04 c0 2f |..nH....VF...../| +00000030 00 ff 01 00 00 5e 00 00 00 0e 00 0c 00 00 09 31 |.....^.........1| +00000040 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000050 00 0a 00 04 00 02 00 17 00 16 00 00 00 17 00 00 |................| +00000060 00 0d 00 30 00 2e 04 03 05 03 06 03 08 07 08 08 |...0............| +00000070 08 09 08 0a 08 0b 08 04 08 05 08 06 04 01 05 01 |................| +00000080 06 01 03 03 02 03 03 01 02 01 03 02 02 02 04 02 |................| +00000090 05 02 06 02 |....| +>>> Flow 2 (server to client) +00000000 16 03 03 00 31 02 00 00 2d 03 03 00 00 00 00 00 |....1...-.......| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 c0 2f 00 00 |...DOWNGRD.../..| +00000030 05 ff 01 00 01 00 16 03 03 02 59 0b 00 02 55 00 |..........Y...U.| +00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| +00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| +00000060 09 2a 86 48 86 f7 0d 01 01 0b 05 00 30 1f 31 0b |.*.H........0.1.| +00000070 30 09 06 03 55 04 0a 13 02 47 6f 31 10 30 0e 06 |0...U....Go1.0..| +00000080 03 55 04 03 13 07 47 6f 20 52 6f 6f 74 30 1e 17 |.U....Go Root0..| +00000090 0d 31 36 30 31 30 31 30 30 30 30 30 30 5a 17 0d |.160101000000Z..| +000000a0 32 35 30 31 30 31 30 30 30 30 30 30 5a 30 1a 31 |250101000000Z0.1| +000000b0 0b 30 09 06 03 55 04 0a 13 02 47 6f 31 0b 30 09 |.0...U....Go1.0.| +000000c0 06 03 55 04 03 13 02 47 6f 30 81 9f 30 0d 06 09 |..U....Go0..0...| +000000d0 2a 86 48 86 f7 0d 01 01 01 05 00 03 81 8d 00 30 |*.H............0| +000000e0 81 89 02 81 81 00 db 46 7d 93 2e 12 27 06 48 bc |.......F}...'.H.| +000000f0 06 28 21 ab 7e c4 b6 a2 5d fe 1e 52 45 88 7a 36 |.(!.~...]..RE.z6| +00000100 47 a5 08 0d 92 42 5b c2 81 c0 be 97 79 98 40 fb |G....B[.....y.@.| +00000110 4f 6d 14 fd 2b 13 8b c2 a5 2e 67 d8 d4 09 9e d6 |Om..+.....g.....| +00000120 22 38 b7 4a 0b 74 73 2b c2 34 f1 d1 93 e5 96 d9 |"8.J.ts+.4......| +00000130 74 7b f3 58 9f 6c 61 3c c0 b0 41 d4 d9 2b 2b 24 |t{.X.la<..A..++$| +00000140 23 77 5b 1c 3b bd 75 5d ce 20 54 cf a1 63 87 1d |#w[.;.u]. T..c..| +00000150 1e 24 c4 f3 1d 1a 50 8b aa b6 14 43 ed 97 a7 75 |.$....P....C...u| +00000160 62 f4 14 c8 52 d7 02 03 01 00 01 a3 81 93 30 81 |b...R.........0.| +00000170 90 30 0e 06 03 55 1d 0f 01 01 ff 04 04 03 02 05 |.0...U..........| +00000180 a0 30 1d 06 03 55 1d 25 04 16 30 14 06 08 2b 06 |.0...U.%..0...+.| +00000190 01 05 05 07 03 01 06 08 2b 06 01 05 05 07 03 02 |........+.......| +000001a0 30 0c 06 03 55 1d 13 01 01 ff 04 02 30 00 30 19 |0...U.......0.0.| +000001b0 06 03 55 1d 0e 04 12 04 10 9f 91 16 1f 43 43 3e |..U..........CC>| +000001c0 49 a6 de 6d b6 80 d7 9f 60 30 1b 06 03 55 1d 23 |I..m....`0...U.#| +000001d0 04 14 30 12 80 10 48 13 49 4d 13 7e 16 31 bb a3 |..0...H.IM.~.1..| +000001e0 01 d5 ac ab 6e 7b 30 19 06 03 55 1d 11 04 12 30 |....n{0...U....0| +000001f0 10 82 0e 65 78 61 6d 70 6c 65 2e 67 6f 6c 61 6e |...example.golan| +00000200 67 30 0d 06 09 2a 86 48 86 f7 0d 01 01 0b 05 00 |g0...*.H........| +00000210 03 81 81 00 9d 30 cc 40 2b 5b 50 a0 61 cb ba e5 |.....0.@+[P.a...| +00000220 53 58 e1 ed 83 28 a9 58 1a a9 38 a4 95 a1 ac 31 |SX...(.X..8....1| +00000230 5a 1a 84 66 3d 43 d3 2d d9 0b f2 97 df d3 20 64 |Z..f=C.-...... d| +00000240 38 92 24 3a 00 bc cf 9c 7d b7 40 20 01 5f aa d3 |8.$:....}.@ ._..| +00000250 16 61 09 a2 76 fd 13 c3 cc e1 0c 5c ee b1 87 82 |.a..v......\....| +00000260 f1 6c 04 ed 73 bb b3 43 77 8d 0c 1c f1 0f a1 d8 |.l..s..Cw.......| +00000270 40 83 61 c9 4c 72 2b 9d ae db 46 06 06 4d f4 c1 |@.a.Lr+...F..M..| +00000280 b3 3e c0 d1 bd 42 d4 db fe 3d 13 60 84 5c 21 d3 |.>...B...=.`.\!.| +00000290 3b e9 fa e7 16 03 03 00 cd 0c 00 00 c9 03 00 17 |;...............| +000002a0 41 04 1e 18 37 ef 0d 19 51 88 35 75 71 b5 e5 54 |A...7...Q.5uq..T| +000002b0 5b 12 2e 8f 09 67 fd a7 24 20 3e b2 56 1c ce 97 |[....g..$ >.V...| +000002c0 28 5e f8 2b 2d 4f 9e f1 07 9f 6c 4b 5b 83 56 e2 |(^.+-O....lK[.V.| +000002d0 32 42 e9 58 b6 d7 49 a6 b5 68 1a 41 03 56 6b dc |2B.X..I..h.A.Vk.| +000002e0 5a 89 08 04 00 80 b8 fd 6d 56 36 b6 b3 8a 6c cb |Z.......mV6...l.| +000002f0 6b 52 79 28 45 97 1e 97 1b 7f 96 2e e0 b0 23 af |kRy(E.........#.| +00000300 cb 13 cf dc e6 11 2b 04 88 08 56 2d a4 3a b1 7e |......+...V-.:.~| +00000310 79 b5 de 25 35 6b 82 98 d9 9e be 99 d4 37 bf 19 |y..%5k.......7..| +00000320 bb 0e 25 86 b6 19 e8 58 de ab 63 ed 3c 09 d6 6b |..%....X..c.<..k| +00000330 f5 da 16 e6 75 5d e7 7b e5 54 1b de 03 1d cd fb |....u].{.T......| +00000340 3d 9f 24 cc ff 07 d2 cb f2 0b 4a 61 57 ec 84 dd |=.$.......JaW...| +00000350 92 44 da 71 a2 31 ba 2e 68 19 2b ee 90 19 12 a5 |.D.q.1..h.+.....| +00000360 59 53 28 9d 0a 87 16 03 03 00 04 0e 00 00 00 |YS(............| +>>> Flow 3 (client to server) +00000000 16 03 03 00 46 10 00 00 42 41 04 01 9c 4d 77 6b |....F...BA...Mwk| +00000010 ce 2f a7 9e 8b ae ba 9d f2 6d c8 9e 0e 54 07 c9 |./.......m...T..| +00000020 6d e3 58 67 c6 a8 9a a5 c2 f7 27 26 84 36 e1 6f |m.Xg......'&.6.o| +00000030 e3 a1 89 50 7c e0 e6 88 06 b9 94 16 d8 23 cb 2e |...P|........#..| +00000040 ff 62 67 1e 93 cb d6 1d f5 43 79 14 03 03 00 01 |.bg......Cy.....| +00000050 01 16 03 03 00 28 83 36 85 d0 b7 23 5e 7d 0a 33 |.....(.6...#^}.3| +00000060 41 0f bd 31 4d a0 32 6a c2 67 93 cc 8f 41 f5 bd |A..1M.2j.g...A..| +00000070 b2 57 af 5c 90 d6 17 24 be 76 6b b4 13 ca |.W.\...$.vk...| +>>> Flow 4 (server to client) +00000000 14 03 03 00 01 01 16 03 03 00 28 00 00 00 00 00 |..........(.....| +00000010 00 00 00 80 6a 93 5b 7d 70 3c bc 7c f8 d6 4e 51 |....j.[}p<.|..NQ| +00000020 5e 34 52 13 06 c4 aa 8c ed b5 9f aa c6 db c0 0d |^4R.............| +00000030 67 97 36 17 03 03 00 25 00 00 00 00 00 00 00 01 |g.6....%........| +00000040 d6 24 e8 21 4b 2c fb 5e 79 2d ca 7b 6d 44 dd 2d |.$.!K,.^y-.{mD.-| +00000050 aa 3a 33 ee ea 6f e3 b7 cd c5 c3 1d 4a 15 03 03 |.:3..o......J...| +00000060 00 1a 00 00 00 00 00 00 00 02 4f 71 74 9e 63 ad |..........Oqt.c.| +00000070 d7 61 b9 c7 47 d6 44 9f b3 3d 49 34 |.a..G.D..=I4| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-3DES b/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-3DES index af50381abc8..8d1cadf85a7 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-3DES +++ b/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-3DES @@ -1,15 +1,18 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 5d 01 00 00 59 03 03 0c fb 72 82 e5 |....]...Y....r..| -00000010 9a 04 90 c8 0d 73 25 9a 3f 88 e3 48 71 a2 33 3e |.....s%.?..Hq.3>| -00000020 90 32 74 bc 12 38 d6 3a d3 11 1d 00 00 04 00 0a |.2t..8.:........| -00000030 00 ff 01 00 00 2c 00 0d 00 20 00 1e 06 01 06 02 |.....,... ......| -00000040 06 03 05 01 05 02 05 03 04 01 04 02 04 03 03 01 |................| -00000050 03 02 03 03 02 01 02 02 02 03 00 16 00 00 00 17 |................| -00000060 00 00 |..| +00000000 16 03 01 00 97 01 00 00 93 03 03 48 e2 22 70 f7 |...........H."p.| +00000010 9a 24 ce 92 69 d1 ff fc c0 c9 ba b2 da 8e 83 7a |.$..i..........z| +00000020 6e 8d 24 60 e2 e2 81 76 e6 72 37 00 00 04 00 0a |n.$`...v.r7.....| +00000030 00 ff 01 00 00 66 00 00 00 0e 00 0c 00 00 09 31 |.....f.........1| +00000040 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000050 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 00 18 |................| +00000060 00 16 00 00 00 17 00 00 00 0d 00 30 00 2e 04 03 |...........0....| +00000070 05 03 06 03 08 07 08 08 08 09 08 0a 08 0b 08 04 |................| +00000080 08 05 08 06 04 01 05 01 06 01 03 03 02 03 03 01 |................| +00000090 02 01 03 02 02 02 04 02 05 02 06 02 |............| >>> Flow 2 (server to client) 00000000 16 03 03 00 31 02 00 00 2d 03 03 00 00 00 00 00 |....1...-.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 0a 00 00 |................| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 00 0a 00 00 |...DOWNGRD......| 00000030 05 ff 01 00 01 00 16 03 03 02 59 0b 00 02 55 00 |..........Y...U.| 00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -50,27 +53,27 @@ 00000280 b3 3e c0 d1 bd 42 d4 db fe 3d 13 60 84 5c 21 d3 |.>...B...=.`.\!.| 00000290 3b e9 fa e7 16 03 03 00 04 0e 00 00 00 |;............| >>> Flow 3 (client to server) -00000000 16 03 03 00 86 10 00 00 82 00 80 04 90 54 41 b9 |.............TA.| -00000010 22 12 39 d9 1d 0b b8 6c d4 b3 8a ec 78 42 80 a5 |".9....l....xB..| -00000020 03 c9 2a 9e 95 6f a0 28 3a 5c e9 59 28 ba 49 9b |..*..o.(:\.Y(.I.| -00000030 37 63 61 3f c4 ac ba 55 6b 85 a5 27 ed 37 b9 25 |7ca?...Uk..'.7.%| -00000040 04 cf 84 ad 43 6b ab 13 fa 72 29 b8 01 d9 aa 0c |....Ck...r).....| -00000050 be b1 9a c4 5a 05 3d 2d 71 b4 72 f5 3a 77 fb 6b |....Z.=-q.r.:w.k| -00000060 45 b0 5b 00 f8 1e f9 70 7f a4 64 c9 1e 35 56 0b |E.[....p..d..5V.| -00000070 68 07 4c 04 95 f4 ca b1 0a b3 25 2b 93 2d be 80 |h.L.......%+.-..| -00000080 76 15 75 07 23 ee 25 f3 1b a8 2f 14 03 03 00 01 |v.u.#.%.../.....| -00000090 01 16 03 03 00 30 e5 cd 56 75 e6 a4 58 e5 33 cc |.....0..Vu..X.3.| -000000a0 95 23 e0 7f 01 f2 45 21 bb 7d 7c 17 1f 59 7c f9 |.#....E!.}|..Y|.| -000000b0 38 05 a3 95 4d 9b f2 3f 9d 84 2c 31 15 8b 4d d4 |8...M..?..,1..M.| -000000c0 17 3c 62 2b f6 71 |.v.....| +00000050 70 91 b7 ed 12 54 e2 e7 68 cb ed 26 be 84 a9 24 |p....T..h..&...$| +00000060 fb 89 48 49 4e 9b 14 98 82 ab 64 0c a5 a0 ec 1d |..HIN.....d.....| +00000070 96 b7 83 c3 14 cb de a5 97 d1 86 28 b6 d4 65 5d |...........(..e]| +00000080 0b 45 04 37 02 53 8c 96 5d f8 d3 14 03 03 00 01 |.E.7.S..].......| +00000090 01 16 03 03 00 30 04 43 06 c4 96 f5 f6 23 5d 46 |.....0.C.....#]F| +000000a0 ec 3d f4 18 44 3f f8 d2 e9 74 37 22 56 df f2 35 |.=..D?...t7"V..5| +000000b0 3d a0 8d 8a 80 be 4e 40 66 28 4c 37 aa f7 43 cf |=.....N@f(L7..C.| +000000c0 9e 29 83 7b 39 28 |.).{9(| >>> Flow 4 (server to client) 00000000 14 03 03 00 01 01 16 03 03 00 30 00 00 00 00 00 |..........0.....| -00000010 00 00 00 b3 85 c2 1b ac 9e c2 01 f7 0f 76 6d 09 |.............vm.| -00000020 5c 4f 9f a6 89 1b 56 e3 05 0b 7e 0d 9d 6b 36 35 |\O....V...~..k65| -00000030 49 99 aa 4c 14 3b 69 2a 87 71 7d 17 03 03 00 30 |I..L.;i*.q}....0| -00000040 00 00 00 00 00 00 00 00 15 65 d4 be e5 1b c9 29 |.........e.....)| -00000050 e9 3a c4 22 72 f8 0c 40 c7 f5 45 a1 a3 c8 a8 64 |.:."r..@..E....d| -00000060 22 4c 6c 79 3f 32 66 d4 05 09 a8 d4 d8 a8 f3 c7 |"Lly?2f.........| -00000070 15 03 03 00 20 00 00 00 00 00 00 00 00 fc 8d c6 |.... ...........| -00000080 3d b1 c4 9f 30 26 e3 b9 46 8f ce 9f 7e 5b 1e a3 |=...0&..F...~[..| -00000090 d0 98 64 3c 0d |..d<.| +00000010 00 00 00 27 75 8a 8d 43 68 0e af 19 6d d2 63 1c |...'u..Ch...m.c.| +00000020 44 51 0b 86 4c fc 16 1c 77 f8 96 1e 72 3d b9 45 |DQ..L...w...r=.E| +00000030 40 cc 70 bc 72 a3 d3 ff f6 e5 3f 17 03 03 00 30 |@.p.r.....?....0| +00000040 00 00 00 00 00 00 00 00 f4 cf bc 55 e6 d7 4f d2 |...........U..O.| +00000050 8f ae 52 8d 16 d0 44 9a c9 39 5b a7 69 bb 04 96 |..R...D..9[.i...| +00000060 c9 d9 0c 92 a0 da b4 52 c5 dd 20 cb 4b 8c ad 51 |.......R.. .K..Q| +00000070 15 03 03 00 20 00 00 00 00 00 00 00 00 43 52 b5 |.... ........CR.| +00000080 d2 98 37 93 69 73 49 27 08 75 76 54 e7 39 b3 4c |..7.isI'.uvT.9.L| +00000090 da 48 84 00 20 |.H.. | diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-AES b/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-AES index 813f7489c80..e4d773d4c47 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-AES +++ b/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-AES @@ -1,15 +1,18 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 5d 01 00 00 59 03 03 7a e5 86 e2 0a |....]...Y..z....| -00000010 53 e7 ba 32 d1 57 47 ed 45 29 1b 33 2c 58 33 8f |S..2.WG.E).3,X3.| -00000020 36 2c 50 6f f9 c7 3b 12 40 23 e2 00 00 04 00 2f |6,Po..;.@#...../| -00000030 00 ff 01 00 00 2c 00 0d 00 20 00 1e 06 01 06 02 |.....,... ......| -00000040 06 03 05 01 05 02 05 03 04 01 04 02 04 03 03 01 |................| -00000050 03 02 03 03 02 01 02 02 02 03 00 16 00 00 00 17 |................| -00000060 00 00 |..| +00000000 16 03 01 00 97 01 00 00 93 03 03 41 7b 60 d8 f5 |...........A{`..| +00000010 1c 4a 95 f9 03 de 94 0c b6 34 94 3c 6e 82 f2 de |.J.......4.>> Flow 2 (server to client) 00000000 16 03 03 00 31 02 00 00 2d 03 03 00 00 00 00 00 |....1...-.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2f 00 00 |............./..| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 00 2f 00 00 |...DOWNGRD.../..| 00000030 05 ff 01 00 01 00 16 03 03 02 59 0b 00 02 55 00 |..........Y...U.| 00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -50,31 +53,31 @@ 00000280 b3 3e c0 d1 bd 42 d4 db fe 3d 13 60 84 5c 21 d3 |.>...B...=.`.\!.| 00000290 3b e9 fa e7 16 03 03 00 04 0e 00 00 00 |;............| >>> Flow 3 (client to server) -00000000 16 03 03 00 86 10 00 00 82 00 80 8f 13 d1 23 1b |..............#.| -00000010 8d 28 c7 a3 97 66 9f 8a c1 13 a1 c9 3b 25 93 7a |.(...f......;%.z| -00000020 ea 54 58 fc 57 41 ca 92 77 99 13 01 61 e4 73 90 |.TX.WA..w...a.s.| -00000030 c7 f1 2b 5e 5e 79 cf 69 7d 6b 3f 6e 5f 2e b0 f5 |..+^^y.i}k?n_...| -00000040 f7 53 2b 46 15 92 6c 20 95 6b 44 6a 0a 3d 0b 56 |.S+F..l .kDj.=.V| -00000050 66 53 ff 55 ec 38 10 cf 76 2c 0e ab 45 7a 02 6a |fS.U.8..v,..Ez.j| -00000060 75 07 11 80 6c d0 57 79 ed d6 4b b8 a0 04 91 a0 |u...l.Wy..K.....| -00000070 d4 4b 76 38 9c b3 a6 2e 0c 3e 63 a8 18 15 c9 ab |.Kv8.....>c.....| -00000080 54 69 cd e5 6f 3c 56 a6 5f a7 e0 14 03 03 00 01 |Ti..o>> Flow 4 (server to client) 00000000 14 03 03 00 01 01 16 03 03 00 40 00 00 00 00 00 |..........@.....| -00000010 00 00 00 00 00 00 00 00 00 00 00 51 27 cd 07 6e |...........Q'..n| -00000020 72 c8 17 ba e7 62 7c d0 49 55 e7 e6 c5 2c 93 39 |r....b|.IU...,.9| -00000030 55 02 f5 fa 9a 7a 6f c5 79 6f ff 0f 4b b9 3d ad |U....zo.yo..K.=.| -00000040 23 c7 53 ad 13 2d d6 da 83 d0 67 17 03 03 00 40 |#.S..-....g....@| +00000010 00 00 00 00 00 00 00 00 00 00 00 ef 1a ed 92 e1 |................| +00000020 e1 81 1e a8 e1 ff 2b 2b 64 89 17 55 2d ce eb be |......++d..U-...| +00000030 17 a6 b8 a7 55 8a c4 3b 8a 5a c7 56 7c b5 90 c9 |....U..;.Z.V|...| +00000040 19 bc 13 07 50 91 42 2a 46 13 d1 17 03 03 00 40 |....P.B*F......@| 00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000060 f5 09 3b 69 c2 1f f8 03 78 1b 13 57 ca 92 96 eb |..;i....x..W....| -00000070 f8 71 30 09 5a 68 01 47 96 b1 5b 7d b7 57 5e 70 |.q0.Zh.G..[}.W^p| -00000080 00 77 bb 55 32 7b d9 a5 f7 e2 a8 6d 4b d6 be c6 |.w.U2{.....mK...| +00000060 9e fe 95 fa 67 a5 af 14 f0 80 fd 65 65 ac 0a 91 |....g......ee...| +00000070 4a 1d 4a c3 de 3f 35 a7 de 10 94 55 b0 8f be e6 |J.J..?5....U....| +00000080 76 a2 74 4c 89 47 b9 10 8f 78 a9 01 6b ac bb d9 |v.tL.G...x..k...| 00000090 15 03 03 00 30 00 00 00 00 00 00 00 00 00 00 00 |....0...........| -000000a0 00 00 00 00 00 58 1e a0 14 82 8d e4 c5 92 35 79 |.....X........5y| -000000b0 3b 5e 3a fe 97 18 db 27 19 7e b5 14 8c 01 fb 6a |;^:....'.~.....j| -000000c0 e4 26 96 e6 de |.&...| +000000a0 00 00 00 00 00 36 ce 1a 97 3e e3 0e 62 74 70 10 |.....6...>..btp.| +000000b0 ec a5 30 16 1f 2d e0 5b c9 38 4d fb 61 2e 45 35 |..0..-.[.8M.a.E5| +000000c0 4b 69 da 43 39 |Ki.C9| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-AES-GCM b/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-AES-GCM index 4c1cbc9ede4..01f961208fa 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-AES-GCM +++ b/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-AES-GCM @@ -1,16 +1,18 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 73 01 00 00 6f 03 03 38 2b d9 54 15 |....s...o..8+.T.| -00000010 60 c3 a7 88 e6 c3 73 8f b0 76 4f d0 10 72 2c d6 |`.....s..vO..r,.| -00000020 55 fc c2 f0 ab 0f 62 43 f1 86 f8 00 00 04 c0 2f |U.....bC......./| -00000030 00 ff 01 00 00 42 00 0b 00 04 03 00 01 02 00 0a |.....B..........| -00000040 00 0a 00 08 00 1d 00 17 00 19 00 18 00 0d 00 20 |............... | -00000050 00 1e 06 01 06 02 06 03 05 01 05 02 05 03 04 01 |................| -00000060 04 02 04 03 03 01 03 02 03 03 02 01 02 02 02 03 |................| -00000070 00 16 00 00 00 17 00 00 |........| +00000000 16 03 01 00 97 01 00 00 93 03 03 d3 6a 87 ad b2 |............j...| +00000010 a0 59 86 0e 34 86 c1 b3 c9 64 17 92 aa 87 04 05 |.Y..4....d......| +00000020 32 d4 2e aa a1 48 94 87 82 a7 ab 00 00 04 c0 2f |2....H........./| +00000030 00 ff 01 00 00 66 00 00 00 0e 00 0c 00 00 09 31 |.....f.........1| +00000040 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000050 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 00 18 |................| +00000060 00 16 00 00 00 17 00 00 00 0d 00 30 00 2e 04 03 |...........0....| +00000070 05 03 06 03 08 07 08 08 08 09 08 0a 08 0b 08 04 |................| +00000080 08 05 08 06 04 01 05 01 06 01 03 03 02 03 03 01 |................| +00000090 02 01 03 02 02 02 04 02 05 02 06 02 |............| >>> Flow 2 (server to client) 00000000 16 03 03 00 31 02 00 00 2d 03 03 00 00 00 00 00 |....1...-.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 c0 2f 00 00 |............./..| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 c0 2f 00 00 |...DOWNGRD.../..| 00000030 05 ff 01 00 01 00 16 03 03 02 59 0b 00 02 55 00 |..........Y...U.| 00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -52,28 +54,28 @@ 00000290 3b e9 fa e7 16 03 03 00 ac 0c 00 00 a8 03 00 1d |;...............| 000002a0 20 2f e5 7d a3 47 cd 62 43 15 28 da ac 5f bb 29 | /.}.G.bC.(.._.)| 000002b0 07 30 ff f6 84 af c4 cf c2 ed 90 99 5f 58 cb 3b |.0.........._X.;| -000002c0 74 06 01 00 80 65 4e 5d 69 d6 97 39 e8 dc 13 58 |t....eN]i..9...X| -000002d0 c1 2a cf 72 12 42 34 8c 4a c1 b5 94 44 0c f2 97 |.*.r.B4.J...D...| -000002e0 46 ba 59 20 1c f2 9d 23 d7 2e 9f 7c 52 ac 08 fe |F.Y ...#...|R...| -000002f0 02 23 e3 ee ec 21 1f bd 08 8a 50 48 aa 21 b7 ed |.#...!....PH.!..| -00000300 be 30 be ac ff 8f e8 71 c9 bc d8 b8 56 63 8a fc |.0.....q....Vc..| -00000310 52 0e 3d e1 4e ce cc 53 d4 f8 36 70 1f 4e 16 61 |R.=.N..S..6p.N.a| -00000320 14 4d dd fe 17 08 f5 09 53 9b c6 24 7d de af dc |.M......S..$}...| -00000330 1b 84 23 c2 72 9c 25 73 1a 4f 42 27 b5 95 b1 06 |..#.r.%s.OB'....| -00000340 dd 36 de 0c 76 16 03 03 00 04 0e 00 00 00 |.6..v.........| +000002c0 74 08 04 00 80 65 2f 82 18 27 04 84 db 3d c6 5e |t....e/..'...=.^| +000002d0 6b 33 f9 87 59 e1 06 0c ce a7 3a f9 bd e7 54 47 |k3..Y.....:...TG| +000002e0 03 58 f7 0b a3 16 6a 47 4b 61 b6 d9 0d 04 c8 95 |.X....jGKa......| +000002f0 f5 d5 e5 0f 1b d2 26 3b c5 67 c0 87 dd a5 da a8 |......&;.g......| +00000300 e1 7e 52 a1 6a 0d 10 e8 dd 2e 09 39 21 3e a2 0f |.~R.j......9!>..| +00000310 a2 00 e4 a1 a6 df a8 3f 5d 1b d7 22 f8 b8 b5 32 |.......?].."...2| +00000320 31 3a 36 16 9e 6c ab f1 d5 25 ae 3c 4a 11 c8 ae |1:6..l...%..cuo.....| +00000340 11 40 c9 7f ca 16 03 03 00 04 0e 00 00 00 |.@............| >>> Flow 3 (client to server) -00000000 16 03 03 00 25 10 00 00 21 20 95 a4 0d a1 cd 3a |....%...! .....:| -00000010 5e 81 bb e3 77 39 f0 6b 37 fe 35 e2 dc 29 6c b0 |^...w9.k7.5..)l.| -00000020 2b e9 b9 84 1d 65 b1 63 d7 0e 14 03 03 00 01 01 |+....e.c........| -00000030 16 03 03 00 28 13 84 cb 17 e5 aa c8 09 43 ed 1a |....(........C..| -00000040 08 92 55 3c e1 b8 5a c0 05 00 30 ae 63 6f 4c 78 |..U<..Z...0.coLx| -00000050 22 42 66 18 91 85 9c 2b c6 88 76 7d bd |"Bf....+..v}.| +00000000 16 03 03 00 25 10 00 00 21 20 d1 f3 61 78 d1 34 |....%...! ..ax.4| +00000010 36 b4 9f 5e e5 24 1e 48 02 be f0 13 c2 3d b0 ce |6..^.$.H.....=..| +00000020 fb 96 39 6b 96 76 aa 87 18 41 14 03 03 00 01 01 |..9k.v...A......| +00000030 16 03 03 00 28 27 e1 50 92 20 e1 2c 98 b6 15 8f |....('.P. .,....| +00000040 dd bd 26 98 04 12 5d cb 29 66 ab 2d 37 f3 8e eb |..&...].)f.-7...| +00000050 3e 14 3b cf 4d 99 c4 2e ea 7c 04 a5 45 |>.;.M....|..E| >>> Flow 4 (server to client) 00000000 14 03 03 00 01 01 16 03 03 00 28 00 00 00 00 00 |..........(.....| -00000010 00 00 00 fb 80 e0 2e 22 3e 45 98 c2 64 a1 0d 0a |.......">E..d...| -00000020 0c 55 40 6e 1b a9 de 29 e3 c8 1a b3 36 ba 5d 88 |.U@n...)....6.].| -00000030 c0 c9 d6 17 03 03 00 25 00 00 00 00 00 00 00 01 |.......%........| -00000040 ef 6a 01 41 ec 78 94 2d d5 c3 48 b8 5e 57 93 34 |.j.A.x.-..H.^W.4| -00000050 82 03 33 ae 03 22 69 9b 32 8f 71 73 6c 15 03 03 |..3.."i.2.qsl...| -00000060 00 1a 00 00 00 00 00 00 00 02 31 37 35 60 f8 01 |..........175`..| -00000070 5d 1f ab be 0d 79 ac c8 34 f0 14 f9 |]....y..4...| +00000010 00 00 00 88 39 9d c1 8d 8c bb c4 79 ba a5 2a bd |....9......y..*.| +00000020 34 62 bf 66 85 b5 cd 2e f7 1e 6e b4 96 1c f6 b3 |4b.f......n.....| +00000030 13 ba c9 17 03 03 00 25 00 00 00 00 00 00 00 01 |.......%........| +00000040 c3 ca b5 57 11 26 ec 18 be 00 6c 8b 79 a5 ed f7 |...W.&....l.y...| +00000050 7d ae 42 ff a2 8b fb 68 d0 08 0f 2e d1 15 03 03 |}.B....h........| +00000060 00 1a 00 00 00 00 00 00 00 02 58 ad 11 d2 74 5c |..........X...t\| +00000070 17 f2 60 e5 d9 fa 0e 47 5a 48 31 f7 |..`....GZH1.| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-AES256-GCM-SHA384 b/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-AES256-GCM-SHA384 index f80f166a47f..83a37e0587e 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-AES256-GCM-SHA384 +++ b/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-AES256-GCM-SHA384 @@ -1,16 +1,18 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 73 01 00 00 6f 03 03 7c 43 b4 7c 36 |....s...o..|C.|6| -00000010 56 e5 d4 47 83 a7 ae 17 cb 5e 7d 5f b7 ef 41 dd |V..G.....^}_..A.| -00000020 63 d3 e6 a0 62 f7 af 91 25 75 15 00 00 04 c0 30 |c...b...%u.....0| -00000030 00 ff 01 00 00 42 00 0b 00 04 03 00 01 02 00 0a |.....B..........| -00000040 00 0a 00 08 00 1d 00 17 00 19 00 18 00 0d 00 20 |............... | -00000050 00 1e 06 01 06 02 06 03 05 01 05 02 05 03 04 01 |................| -00000060 04 02 04 03 03 01 03 02 03 03 02 01 02 02 02 03 |................| -00000070 00 16 00 00 00 17 00 00 |........| +00000000 16 03 01 00 97 01 00 00 93 03 03 39 40 da f7 9f |...........9@...| +00000010 e9 66 91 25 2a d0 74 e1 71 4b 74 ff 47 41 5e f4 |.f.%*.t.qKt.GA^.| +00000020 d2 71 d0 3e 96 8e 8e 31 ee 81 8b 00 00 04 c0 30 |.q.>...1.......0| +00000030 00 ff 01 00 00 66 00 00 00 0e 00 0c 00 00 09 31 |.....f.........1| +00000040 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000050 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 00 18 |................| +00000060 00 16 00 00 00 17 00 00 00 0d 00 30 00 2e 04 03 |...........0....| +00000070 05 03 06 03 08 07 08 08 08 09 08 0a 08 0b 08 04 |................| +00000080 08 05 08 06 04 01 05 01 06 01 03 03 02 03 03 01 |................| +00000090 02 01 03 02 02 02 04 02 05 02 06 02 |............| >>> Flow 2 (server to client) 00000000 16 03 03 00 31 02 00 00 2d 03 03 00 00 00 00 00 |....1...-.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 c0 30 00 00 |.............0..| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 c0 30 00 00 |...DOWNGRD...0..| 00000030 05 ff 01 00 01 00 16 03 03 02 59 0b 00 02 55 00 |..........Y...U.| 00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -52,28 +54,28 @@ 00000290 3b e9 fa e7 16 03 03 00 ac 0c 00 00 a8 03 00 1d |;...............| 000002a0 20 2f e5 7d a3 47 cd 62 43 15 28 da ac 5f bb 29 | /.}.G.bC.(.._.)| 000002b0 07 30 ff f6 84 af c4 cf c2 ed 90 99 5f 58 cb 3b |.0.........._X.;| -000002c0 74 06 01 00 80 8b b6 3e 52 d2 87 bf 9f 82 6d 0e |t......>R.....m.| -000002d0 8f de 69 34 58 71 9e 36 46 35 7e 73 ad f0 ee 30 |..i4Xq.6F5~s...0| -000002e0 0c 95 dc cc 28 ce 9b ee e6 44 3d ab ab 60 13 7c |....(....D=..`.|| -000002f0 3d 37 2d d0 36 95 04 74 df 5a a5 ef 9b 68 7c 58 |=7-.6..t.Z...h|X| -00000300 b4 22 e9 5d 15 aa 18 cc fc 8d 35 f4 ad aa dc 0d |.".]......5.....| -00000310 86 b6 e5 ac e3 8f ea c7 63 c6 a5 1e 2a 7e e2 9b |........c...*~..| -00000320 05 33 81 04 d4 87 ad 15 2d 7f 91 fd ca 85 a8 cb |.3......-.......| -00000330 66 56 e3 7a 4a 90 8c dc 7d 8f d0 af 6e 5e 88 7b |fV.zJ...}...n^.{| -00000340 34 2e 2f a0 2e 16 03 03 00 04 0e 00 00 00 |4./...........| +000002c0 74 08 04 00 80 67 b9 f4 b4 4e 00 7c 40 80 f1 77 |t....g...N.|@..w| +000002d0 2e 09 f6 04 17 bb ab f6 e1 13 03 b3 b6 71 22 0b |.............q".| +000002e0 38 49 98 65 54 db 3b e0 71 17 2a f3 d4 2a 0d 7e |8I.eT.;.q.*..*.~| +000002f0 af 56 37 ea a9 1e df 45 24 fd 90 ad 5e 3c aa 2e |.V7....E$...^<..| +00000300 98 74 b5 dc b5 22 0e 77 70 66 2f 6e d7 49 f6 a1 |.t...".wpf/n.I..| +00000310 93 c9 0a ce 45 2b 55 bb 02 a3 b1 1d 5f 45 08 cd |....E+U....._E..| +00000320 4d 34 9e ef 27 f2 f0 af a8 bd 14 60 45 df b4 54 |M4..'......`E..T| +00000330 2c 6f c8 c8 dc f1 07 9a e8 f3 f3 40 1d 29 39 9e |,o.........@.)9.| +00000340 a0 28 3a 19 de 16 03 03 00 04 0e 00 00 00 |.(:...........| >>> Flow 3 (client to server) -00000000 16 03 03 00 25 10 00 00 21 20 a5 ce 37 03 eb 08 |....%...! ..7...| -00000010 67 8e 6b f8 37 b6 f8 cd c6 62 59 c1 8f 46 22 0d |g.k.7....bY..F".| -00000020 d8 e1 85 2e 26 dc 40 d3 f0 60 14 03 03 00 01 01 |....&.@..`......| -00000030 16 03 03 00 28 7d cf e0 cb 63 b3 22 fb b2 94 82 |....(}...c."....| -00000040 a7 1e 8d 71 15 a8 ba 14 b6 4b 67 37 f9 78 c4 33 |...q.....Kg7.x.3| -00000050 1b 7d 6c 8b 56 8f 85 d1 3e d3 9c 9f 95 |.}l.V...>....| +00000000 16 03 03 00 25 10 00 00 21 20 73 eb 70 45 10 e4 |....%...! s.pE..| +00000010 a7 a6 35 b2 51 59 1e 6d 65 9a 0e d4 5a c2 39 13 |..5.QY.me...Z.9.| +00000020 81 83 41 f8 60 0c 6b 0e 7f 4c 14 03 03 00 01 01 |..A.`.k..L......| +00000030 16 03 03 00 28 44 ed a7 2b dc 7a 00 b5 26 bd 56 |....(D..+.z..&.V| +00000040 0d b7 47 f3 2c d8 b7 c5 f6 21 3a e6 1f b8 fd 3a |..G.,....!:....:| +00000050 f8 44 65 0d 6e fd b8 32 cf dd f5 25 ce |.De.n..2...%.| >>> Flow 4 (server to client) 00000000 14 03 03 00 01 01 16 03 03 00 28 00 00 00 00 00 |..........(.....| -00000010 00 00 00 3e cd 20 97 7b b3 2c 24 f2 cc ac 70 a4 |...>. .{.,$...p.| -00000020 4f f5 db 05 51 52 a8 ff 6e 01 98 c3 ec c7 2c 97 |O...QR..n.....,.| -00000030 6f f9 2c 17 03 03 00 25 00 00 00 00 00 00 00 01 |o.,....%........| -00000040 67 b8 c3 d5 7e 02 18 6f b8 db 10 5c 28 29 3d f6 |g...~..o...\()=.| -00000050 d0 69 a1 4f e8 a4 ce 22 81 65 10 7e d1 15 03 03 |.i.O...".e.~....| -00000060 00 1a 00 00 00 00 00 00 00 02 b0 df 28 f8 b8 f2 |............(...| -00000070 32 43 c3 d0 01 55 8f 47 c1 52 8d e3 |2C...U.G.R..| +00000010 00 00 00 cb e9 44 b4 25 7e a5 9d ed 8e 8b 5c 4c |.....D.%~.....\L| +00000020 b9 c4 85 5b 9b 03 02 34 2c 61 40 fe 4a 84 9d 42 |...[...4,a@.J..B| +00000030 67 67 53 17 03 03 00 25 00 00 00 00 00 00 00 01 |ggS....%........| +00000040 ec a1 21 b6 85 61 d1 35 71 50 c1 6d 4d 32 81 3f |..!..a.5qP.mM2.?| +00000050 24 38 1d 8a 45 f7 9e 14 3b be e9 ec 37 15 03 03 |$8..E...;...7...| +00000060 00 1a 00 00 00 00 00 00 00 02 f7 76 a1 1b bb 55 |...........v...U| +00000070 aa 1d 10 c2 07 61 b3 0d 54 2d 6b e4 |.....a..T-k.| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-RC4 b/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-RC4 index e49d1bcbbc4..da549aa32e0 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-RC4 +++ b/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-RC4 @@ -1,15 +1,18 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 5d 01 00 00 59 03 03 55 3e 1a 3f cc |....]...Y..U>.?.| -00000010 14 18 07 db 5e 97 15 33 62 9d de 56 7b ea 52 bf |....^..3b..V{.R.| -00000020 a3 ce c2 75 3f 52 0a 2f 3e 99 07 00 00 04 00 05 |...u?R./>.......| -00000030 00 ff 01 00 00 2c 00 0d 00 20 00 1e 06 01 06 02 |.....,... ......| -00000040 06 03 05 01 05 02 05 03 04 01 04 02 04 03 03 01 |................| -00000050 03 02 03 03 02 01 02 02 02 03 00 16 00 00 00 17 |................| -00000060 00 00 |..| +00000000 16 03 01 00 97 01 00 00 93 03 03 c7 7f 29 46 41 |.............)FA| +00000010 08 97 7c 3f 77 e0 11 8f 14 30 23 3e fa fc ca f3 |..|?w....0#>....| +00000020 45 10 83 10 1f 8f 25 b6 9d c1 4d 00 00 04 00 05 |E.....%...M.....| +00000030 00 ff 01 00 00 66 00 00 00 0e 00 0c 00 00 09 31 |.....f.........1| +00000040 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000050 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 00 18 |................| +00000060 00 16 00 00 00 17 00 00 00 0d 00 30 00 2e 04 03 |...........0....| +00000070 05 03 06 03 08 07 08 08 08 09 08 0a 08 0b 08 04 |................| +00000080 08 05 08 06 04 01 05 01 06 01 03 03 02 03 03 01 |................| +00000090 02 01 03 02 02 02 04 02 05 02 06 02 |............| >>> Flow 2 (server to client) 00000000 16 03 03 00 31 02 00 00 2d 03 03 00 00 00 00 00 |....1...-.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 05 00 00 |................| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 00 05 00 00 |...DOWNGRD......| 00000030 05 ff 01 00 01 00 16 03 03 02 59 0b 00 02 55 00 |..........Y...U.| 00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -50,23 +53,23 @@ 00000280 b3 3e c0 d1 bd 42 d4 db fe 3d 13 60 84 5c 21 d3 |.>...B...=.`.\!.| 00000290 3b e9 fa e7 16 03 03 00 04 0e 00 00 00 |;............| >>> Flow 3 (client to server) -00000000 16 03 03 00 86 10 00 00 82 00 80 a7 55 0a e7 33 |............U..3| -00000010 8e be 5a 3a b4 f4 06 6e fc 0e 42 6e f3 0c 01 5a |..Z:...n..Bn...Z| -00000020 65 73 36 bd cd be 0f 65 2f d2 88 1a f0 5e f8 07 |es6....e/....^..| -00000030 c1 fe 5f 5f d6 f5 fa 79 24 44 0d 33 4f e6 74 88 |..__...y$D.3O.t.| -00000040 86 f1 76 84 29 b4 f2 ae eb 9b 00 a2 6a e4 97 58 |..v.).......j..X| -00000050 8b 2e 04 8f 8f 5e fe b4 9d 38 1d 8d 40 a4 9b a2 |.....^...8..@...| -00000060 17 50 8a e5 39 c9 e9 41 3e 0d 9c 42 2c 7a 88 bf |.P..9..A>..B,z..| -00000070 f7 09 4e 27 0b fe cc 53 13 07 d5 7e 0e e6 02 3c |..N'...S...~...<| -00000080 8a 3f f9 03 df b6 65 a0 77 ee 50 14 03 03 00 01 |.?....e.w.P.....| -00000090 01 16 03 03 00 24 5f 41 3e 38 05 08 74 62 5b 4e |.....$_A>8..tb[N| -000000a0 94 55 98 74 5c 65 1a 4c 49 08 1d 77 d7 f0 12 47 |.U.t\e.LI..w...G| -000000b0 d2 ef a6 31 5c 36 03 b5 b5 9d |...1\6....| +00000000 16 03 03 00 86 10 00 00 82 00 80 d1 b0 57 28 da |.............W(.| +00000010 7a f8 46 7c c2 24 0d e0 04 48 33 d4 bc d7 f0 d0 |z.F|.$...H3.....| +00000020 85 fb ff 22 27 20 91 42 19 55 7b ef d8 fd 72 42 |..."' .B.U{...rB| +00000030 75 e6 71 e4 9f 67 30 72 68 b6 0e 00 34 d3 2f b8 |u.q..g0rh...4./.| +00000040 23 1b 00 43 17 68 fd 0f 90 ee 97 16 23 36 90 02 |#..C.h......#6..| +00000050 5c 71 10 03 80 ea 74 ef a4 5a ac e4 9f 48 f0 76 |\q....t..Z...H.v| +00000060 62 43 17 05 7c 8f 59 1d 16 b1 97 48 99 8d 66 5e |bC..|.Y....H..f^| +00000070 83 20 b3 02 e4 ac 73 52 b2 24 21 06 5a 49 89 df |. ....sR.$!.ZI..| +00000080 4b ad 4e f4 a9 7b 0c 3a b1 39 5d 14 03 03 00 01 |K.N..{.:.9].....| +00000090 01 16 03 03 00 24 8b de 7e 10 53 71 e0 0b 68 f6 |.....$..~.Sq..h.| +000000a0 36 67 66 c2 b9 0a c0 3e 39 0d ab 2e eb 5e eb 06 |6gf....>9....^..| +000000b0 a6 45 2b d7 48 8f c0 5e f3 a0 |.E+.H..^..| >>> Flow 4 (server to client) -00000000 14 03 03 00 01 01 16 03 03 00 24 6f 68 a2 c0 4d |..........$oh..M| -00000010 f4 cb c0 e5 8b 19 f9 2e 46 c3 3b 92 eb a9 42 8b |........F.;...B.| -00000020 03 4a e2 62 9d f1 c0 39 b1 63 61 08 15 b0 ca 17 |.J.b...9.ca.....| -00000030 03 03 00 21 50 9e 16 ce 7e af 8f 43 d1 1c 30 37 |...!P...~..C..07| -00000040 85 e9 68 3a 9c 7e 26 90 dc 14 b1 ec 91 20 2b 4a |..h:.~&...... +J| -00000050 24 b4 fa b1 50 15 03 03 00 16 59 74 08 41 73 01 |$...P.....Yt.As.| -00000060 22 19 0b 35 6b 4d ee d2 15 50 42 de cc cf cc 09 |"..5kM...PB.....| +00000000 14 03 03 00 01 01 16 03 03 00 24 ee dc 70 d2 3a |..........$..p.:| +00000010 f1 9c c6 c8 01 01 84 4f 3c 95 a3 ac 7a 78 92 3d |.......O<...zx.=| +00000020 8c 05 a1 db 34 fe 92 f2 9e f3 81 a1 33 a5 7f 17 |....4.......3...| +00000030 03 03 00 21 6e a9 f8 f9 99 0b c1 f5 8a d0 ab 93 |...!n...........| +00000040 15 4d 2f 24 1c 0b 43 77 cf 14 60 87 b0 8d f7 80 |.M/$..Cw..`.....| +00000050 c0 69 ea f6 9e 15 03 03 00 16 ef 09 73 d8 06 ec |.i..........s...| +00000060 b8 02 14 9c d3 39 32 d4 3d 94 ec 17 79 1d a9 d3 |.....92.=...y...| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-RSAPKCS1v15 b/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-RSAPKCS1v15 new file mode 100644 index 00000000000..6d98a309ee9 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-RSAPKCS1v15 @@ -0,0 +1,81 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 91 01 00 00 8d 03 03 c1 6b f6 4d 77 |............k.Mw| +00000010 95 dc 8a 54 04 62 4a b4 dc e3 06 51 b8 88 4e 9f |...T.bJ....Q..N.| +00000020 9a f5 2b 87 82 51 df e9 54 c7 93 00 00 2a c0 30 |..+..Q..T....*.0| +00000030 00 9f cc a8 cc aa c0 2f 00 9e c0 28 00 6b c0 27 |......./...(.k.'| +00000040 00 67 c0 14 00 39 c0 13 00 33 00 9d 00 9c 00 3d |.g...9...3.....=| +00000050 00 3c 00 35 00 2f 00 ff 01 00 00 3a 00 00 00 0e |.<.5./.....:....| +00000060 00 0c 00 00 09 31 32 37 2e 30 2e 30 2e 31 00 0b |.....127.0.0.1..| +00000070 00 04 03 00 01 02 00 0a 00 0c 00 0a 00 1d 00 17 |................| +00000080 00 1e 00 19 00 18 00 16 00 00 00 17 00 00 00 0d |................| +00000090 00 04 00 02 04 01 |......| +>>> Flow 2 (server to client) +00000000 16 03 03 00 31 02 00 00 2d 03 03 00 00 00 00 00 |....1...-.......| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 c0 30 00 00 |...DOWNGRD...0..| +00000030 05 ff 01 00 01 00 16 03 03 02 59 0b 00 02 55 00 |..........Y...U.| +00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| +00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| +00000060 09 2a 86 48 86 f7 0d 01 01 0b 05 00 30 1f 31 0b |.*.H........0.1.| +00000070 30 09 06 03 55 04 0a 13 02 47 6f 31 10 30 0e 06 |0...U....Go1.0..| +00000080 03 55 04 03 13 07 47 6f 20 52 6f 6f 74 30 1e 17 |.U....Go Root0..| +00000090 0d 31 36 30 31 30 31 30 30 30 30 30 30 5a 17 0d |.160101000000Z..| +000000a0 32 35 30 31 30 31 30 30 30 30 30 30 5a 30 1a 31 |250101000000Z0.1| +000000b0 0b 30 09 06 03 55 04 0a 13 02 47 6f 31 0b 30 09 |.0...U....Go1.0.| +000000c0 06 03 55 04 03 13 02 47 6f 30 81 9f 30 0d 06 09 |..U....Go0..0...| +000000d0 2a 86 48 86 f7 0d 01 01 01 05 00 03 81 8d 00 30 |*.H............0| +000000e0 81 89 02 81 81 00 db 46 7d 93 2e 12 27 06 48 bc |.......F}...'.H.| +000000f0 06 28 21 ab 7e c4 b6 a2 5d fe 1e 52 45 88 7a 36 |.(!.~...]..RE.z6| +00000100 47 a5 08 0d 92 42 5b c2 81 c0 be 97 79 98 40 fb |G....B[.....y.@.| +00000110 4f 6d 14 fd 2b 13 8b c2 a5 2e 67 d8 d4 09 9e d6 |Om..+.....g.....| +00000120 22 38 b7 4a 0b 74 73 2b c2 34 f1 d1 93 e5 96 d9 |"8.J.ts+.4......| +00000130 74 7b f3 58 9f 6c 61 3c c0 b0 41 d4 d9 2b 2b 24 |t{.X.la<..A..++$| +00000140 23 77 5b 1c 3b bd 75 5d ce 20 54 cf a1 63 87 1d |#w[.;.u]. T..c..| +00000150 1e 24 c4 f3 1d 1a 50 8b aa b6 14 43 ed 97 a7 75 |.$....P....C...u| +00000160 62 f4 14 c8 52 d7 02 03 01 00 01 a3 81 93 30 81 |b...R.........0.| +00000170 90 30 0e 06 03 55 1d 0f 01 01 ff 04 04 03 02 05 |.0...U..........| +00000180 a0 30 1d 06 03 55 1d 25 04 16 30 14 06 08 2b 06 |.0...U.%..0...+.| +00000190 01 05 05 07 03 01 06 08 2b 06 01 05 05 07 03 02 |........+.......| +000001a0 30 0c 06 03 55 1d 13 01 01 ff 04 02 30 00 30 19 |0...U.......0.0.| +000001b0 06 03 55 1d 0e 04 12 04 10 9f 91 16 1f 43 43 3e |..U..........CC>| +000001c0 49 a6 de 6d b6 80 d7 9f 60 30 1b 06 03 55 1d 23 |I..m....`0...U.#| +000001d0 04 14 30 12 80 10 48 13 49 4d 13 7e 16 31 bb a3 |..0...H.IM.~.1..| +000001e0 01 d5 ac ab 6e 7b 30 19 06 03 55 1d 11 04 12 30 |....n{0...U....0| +000001f0 10 82 0e 65 78 61 6d 70 6c 65 2e 67 6f 6c 61 6e |...example.golan| +00000200 67 30 0d 06 09 2a 86 48 86 f7 0d 01 01 0b 05 00 |g0...*.H........| +00000210 03 81 81 00 9d 30 cc 40 2b 5b 50 a0 61 cb ba e5 |.....0.@+[P.a...| +00000220 53 58 e1 ed 83 28 a9 58 1a a9 38 a4 95 a1 ac 31 |SX...(.X..8....1| +00000230 5a 1a 84 66 3d 43 d3 2d d9 0b f2 97 df d3 20 64 |Z..f=C.-...... d| +00000240 38 92 24 3a 00 bc cf 9c 7d b7 40 20 01 5f aa d3 |8.$:....}.@ ._..| +00000250 16 61 09 a2 76 fd 13 c3 cc e1 0c 5c ee b1 87 82 |.a..v......\....| +00000260 f1 6c 04 ed 73 bb b3 43 77 8d 0c 1c f1 0f a1 d8 |.l..s..Cw.......| +00000270 40 83 61 c9 4c 72 2b 9d ae db 46 06 06 4d f4 c1 |@.a.Lr+...F..M..| +00000280 b3 3e c0 d1 bd 42 d4 db fe 3d 13 60 84 5c 21 d3 |.>...B...=.`.\!.| +00000290 3b e9 fa e7 16 03 03 00 ac 0c 00 00 a8 03 00 1d |;...............| +000002a0 20 2f e5 7d a3 47 cd 62 43 15 28 da ac 5f bb 29 | /.}.G.bC.(.._.)| +000002b0 07 30 ff f6 84 af c4 cf c2 ed 90 99 5f 58 cb 3b |.0.........._X.;| +000002c0 74 04 01 00 80 15 c5 ee da 37 f8 6d b8 9e 7c 68 |t........7.m..|h| +000002d0 b2 08 2a 8d 79 6c 6e 95 4e b5 6f 8e 84 24 31 d4 |..*.yln.N.o..$1.| +000002e0 e7 8c 6c 7e 9c 58 a4 fe 18 59 aa f7 0d 7d ff 7a |..l~.X...Y...}.z| +000002f0 f2 b0 eb b6 d3 4f fa 3f 36 0d 2e 43 8e d7 96 14 |.....O.?6..C....| +00000300 99 a0 34 6a 51 cf 49 48 2f 6a 69 3b e4 ec 8b 61 |..4jQ.IH/ji;...a| +00000310 a1 f4 ea 20 c5 72 90 b1 c6 54 75 42 4e f6 1f 12 |... .r...TuBN...| +00000320 da e1 98 36 01 02 30 b4 75 7b 4f 4b f1 4f ac 20 |...6..0.u{OK.O. | +00000330 ac c8 d2 0f 8f 2a 00 09 b8 2c ab 9e 5f b2 ce 25 |.....*...,.._..%| +00000340 e3 a3 27 9d 53 16 03 03 00 04 0e 00 00 00 |..'.S.........| +>>> Flow 3 (client to server) +00000000 16 03 03 00 25 10 00 00 21 20 fe 11 76 84 dd 42 |....%...! ..v..B| +00000010 d9 fd ad 50 81 7e 62 d4 38 cb b3 5d ec c8 5a 7a |...P.~b.8..]..Zz| +00000020 40 d9 10 23 2f e6 c7 a8 95 3b 14 03 03 00 01 01 |@..#/....;......| +00000030 16 03 03 00 28 61 18 1a 65 0c 24 59 01 fe 28 fc |....(a..e.$Y..(.| +00000040 4f 7f d9 c5 6d b7 bf 9c 5c 8b dc 91 e7 48 40 72 |O...m...\....H@r| +00000050 06 4d 49 a4 4d 32 e2 10 b9 36 a4 06 a6 |.MI.M2...6...| +>>> Flow 4 (server to client) +00000000 14 03 03 00 01 01 16 03 03 00 28 00 00 00 00 00 |..........(.....| +00000010 00 00 00 6c 7b 84 e6 84 d3 31 8e 6a 3e e7 7e f2 |...l{....1.j>.~.| +00000020 94 16 6c 6f 01 a9 2d f7 de 5d 94 b2 9c 4b f0 51 |..lo..-..]...K.Q| +00000030 70 9e 3c 17 03 03 00 25 00 00 00 00 00 00 00 01 |p.<....%........| +00000040 94 ca c5 e7 58 20 7d 3b 74 9d e0 97 a2 dd 63 ab |....X };t.....c.| +00000050 33 08 2f 16 69 59 ba 0e 82 52 75 98 eb 15 03 03 |3./.iY...Ru.....| +00000060 00 1a 00 00 00 00 00 00 00 02 fc 38 72 72 09 6a |...........8rr.j| +00000070 ee c0 61 39 50 71 ad d3 ec a9 d1 0e |..a9Pq......| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-RSAPSS b/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-RSAPSS new file mode 100644 index 00000000000..5ec0f25a17e --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Server-TLSv12-RSA-RSAPSS @@ -0,0 +1,81 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 91 01 00 00 8d 03 03 0f 06 da 7d 85 |..............}.| +00000010 33 d8 3c c3 ad c5 19 f8 06 d8 f6 02 80 9a fb 8c |3.<.............| +00000020 55 a5 6b 67 c4 6e 68 11 74 61 28 00 00 2a c0 30 |U.kg.nh.ta(..*.0| +00000030 00 9f cc a8 cc aa c0 2f 00 9e c0 28 00 6b c0 27 |......./...(.k.'| +00000040 00 67 c0 14 00 39 c0 13 00 33 00 9d 00 9c 00 3d |.g...9...3.....=| +00000050 00 3c 00 35 00 2f 00 ff 01 00 00 3a 00 00 00 0e |.<.5./.....:....| +00000060 00 0c 00 00 09 31 32 37 2e 30 2e 30 2e 31 00 0b |.....127.0.0.1..| +00000070 00 04 03 00 01 02 00 0a 00 0c 00 0a 00 1d 00 17 |................| +00000080 00 1e 00 19 00 18 00 16 00 00 00 17 00 00 00 0d |................| +00000090 00 04 00 02 08 04 |......| +>>> Flow 2 (server to client) +00000000 16 03 03 00 31 02 00 00 2d 03 03 00 00 00 00 00 |....1...-.......| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 c0 30 00 00 |...DOWNGRD...0..| +00000030 05 ff 01 00 01 00 16 03 03 02 59 0b 00 02 55 00 |..........Y...U.| +00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| +00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| +00000060 09 2a 86 48 86 f7 0d 01 01 0b 05 00 30 1f 31 0b |.*.H........0.1.| +00000070 30 09 06 03 55 04 0a 13 02 47 6f 31 10 30 0e 06 |0...U....Go1.0..| +00000080 03 55 04 03 13 07 47 6f 20 52 6f 6f 74 30 1e 17 |.U....Go Root0..| +00000090 0d 31 36 30 31 30 31 30 30 30 30 30 30 5a 17 0d |.160101000000Z..| +000000a0 32 35 30 31 30 31 30 30 30 30 30 30 5a 30 1a 31 |250101000000Z0.1| +000000b0 0b 30 09 06 03 55 04 0a 13 02 47 6f 31 0b 30 09 |.0...U....Go1.0.| +000000c0 06 03 55 04 03 13 02 47 6f 30 81 9f 30 0d 06 09 |..U....Go0..0...| +000000d0 2a 86 48 86 f7 0d 01 01 01 05 00 03 81 8d 00 30 |*.H............0| +000000e0 81 89 02 81 81 00 db 46 7d 93 2e 12 27 06 48 bc |.......F}...'.H.| +000000f0 06 28 21 ab 7e c4 b6 a2 5d fe 1e 52 45 88 7a 36 |.(!.~...]..RE.z6| +00000100 47 a5 08 0d 92 42 5b c2 81 c0 be 97 79 98 40 fb |G....B[.....y.@.| +00000110 4f 6d 14 fd 2b 13 8b c2 a5 2e 67 d8 d4 09 9e d6 |Om..+.....g.....| +00000120 22 38 b7 4a 0b 74 73 2b c2 34 f1 d1 93 e5 96 d9 |"8.J.ts+.4......| +00000130 74 7b f3 58 9f 6c 61 3c c0 b0 41 d4 d9 2b 2b 24 |t{.X.la<..A..++$| +00000140 23 77 5b 1c 3b bd 75 5d ce 20 54 cf a1 63 87 1d |#w[.;.u]. T..c..| +00000150 1e 24 c4 f3 1d 1a 50 8b aa b6 14 43 ed 97 a7 75 |.$....P....C...u| +00000160 62 f4 14 c8 52 d7 02 03 01 00 01 a3 81 93 30 81 |b...R.........0.| +00000170 90 30 0e 06 03 55 1d 0f 01 01 ff 04 04 03 02 05 |.0...U..........| +00000180 a0 30 1d 06 03 55 1d 25 04 16 30 14 06 08 2b 06 |.0...U.%..0...+.| +00000190 01 05 05 07 03 01 06 08 2b 06 01 05 05 07 03 02 |........+.......| +000001a0 30 0c 06 03 55 1d 13 01 01 ff 04 02 30 00 30 19 |0...U.......0.0.| +000001b0 06 03 55 1d 0e 04 12 04 10 9f 91 16 1f 43 43 3e |..U..........CC>| +000001c0 49 a6 de 6d b6 80 d7 9f 60 30 1b 06 03 55 1d 23 |I..m....`0...U.#| +000001d0 04 14 30 12 80 10 48 13 49 4d 13 7e 16 31 bb a3 |..0...H.IM.~.1..| +000001e0 01 d5 ac ab 6e 7b 30 19 06 03 55 1d 11 04 12 30 |....n{0...U....0| +000001f0 10 82 0e 65 78 61 6d 70 6c 65 2e 67 6f 6c 61 6e |...example.golan| +00000200 67 30 0d 06 09 2a 86 48 86 f7 0d 01 01 0b 05 00 |g0...*.H........| +00000210 03 81 81 00 9d 30 cc 40 2b 5b 50 a0 61 cb ba e5 |.....0.@+[P.a...| +00000220 53 58 e1 ed 83 28 a9 58 1a a9 38 a4 95 a1 ac 31 |SX...(.X..8....1| +00000230 5a 1a 84 66 3d 43 d3 2d d9 0b f2 97 df d3 20 64 |Z..f=C.-...... d| +00000240 38 92 24 3a 00 bc cf 9c 7d b7 40 20 01 5f aa d3 |8.$:....}.@ ._..| +00000250 16 61 09 a2 76 fd 13 c3 cc e1 0c 5c ee b1 87 82 |.a..v......\....| +00000260 f1 6c 04 ed 73 bb b3 43 77 8d 0c 1c f1 0f a1 d8 |.l..s..Cw.......| +00000270 40 83 61 c9 4c 72 2b 9d ae db 46 06 06 4d f4 c1 |@.a.Lr+...F..M..| +00000280 b3 3e c0 d1 bd 42 d4 db fe 3d 13 60 84 5c 21 d3 |.>...B...=.`.\!.| +00000290 3b e9 fa e7 16 03 03 00 ac 0c 00 00 a8 03 00 1d |;...............| +000002a0 20 2f e5 7d a3 47 cd 62 43 15 28 da ac 5f bb 29 | /.}.G.bC.(.._.)| +000002b0 07 30 ff f6 84 af c4 cf c2 ed 90 99 5f 58 cb 3b |.0.........._X.;| +000002c0 74 08 04 00 80 49 30 b1 a5 47 19 7f a7 35 61 cb |t....I0..G...5a.| +000002d0 dc 41 47 f0 6a 96 e1 63 48 d9 4f d3 a4 ac 06 46 |.AG.j..cH.O....F| +000002e0 f2 8d 07 95 25 c6 61 59 4a df 35 2e ce dd 71 7e |....%.aYJ.5...q~| +000002f0 1e d6 f4 9f 43 93 84 35 6a 98 41 45 16 ee cb 14 |....C..5j.AE....| +00000300 dd bb 52 27 08 d5 a2 39 e7 6e f6 d6 e4 c6 bd f3 |..R'...9.n......| +00000310 b6 9b 6d 61 30 2a 07 c6 04 39 87 fd 99 00 15 78 |..ma0*...9.....x| +00000320 3d bf 20 8c b9 52 fb 5d c7 b7 77 78 fb 77 2a ac |=. ..R.]..wx.w*.| +00000330 f5 3e e5 4b 8f 4d 9b ca c2 33 1c 66 3c cb e0 1f |.>.K.M...3.f<...| +00000340 81 36 78 39 70 16 03 03 00 04 0e 00 00 00 |.6x9p.........| +>>> Flow 3 (client to server) +00000000 16 03 03 00 25 10 00 00 21 20 79 9a e7 42 96 52 |....%...! y..B.R| +00000010 f6 52 7d 10 9a 36 9b aa a7 2f 96 be 5b 0a 3b 40 |.R}..6.../..[.;@| +00000020 d9 32 3a 0b 17 7b 8d 92 7c 7b 14 03 03 00 01 01 |.2:..{..|{......| +00000030 16 03 03 00 28 92 3e da 41 d2 87 60 b3 e1 4f f7 |....(.>.A..`..O.| +00000040 bb b7 09 50 47 2e 05 d5 fe f6 ed 94 ba 3b 60 aa |...PG........;`.| +00000050 38 2d b2 38 c7 07 64 63 dd ca 1a 8e ae |8-.8..dc.....| +>>> Flow 4 (server to client) +00000000 14 03 03 00 01 01 16 03 03 00 28 00 00 00 00 00 |..........(.....| +00000010 00 00 00 8e c6 6e 45 21 eb 35 11 7a b5 74 d7 f7 |.....nE!.5.z.t..| +00000020 67 53 15 23 9d 61 a1 bc 20 10 c8 8e 7e ee 45 fc |gS.#.a.. ...~.E.| +00000030 60 13 20 17 03 03 00 25 00 00 00 00 00 00 00 01 |`. ....%........| +00000040 bf f9 63 b5 b1 39 70 43 c7 62 38 be d1 f5 0d a5 |..c..9pC.b8.....| +00000050 87 91 95 71 ab 03 c2 08 d0 38 dc 70 9a 15 03 03 |...q.....8.p....| +00000060 00 1a 00 00 00 00 00 00 00 02 0c 6f b1 f5 45 6d |...........o..Em| +00000070 44 2c 1f ec a4 fa 5c c1 aa 23 1e 82 |D,....\..#..| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv12-Resume b/libgo/go/crypto/tls/testdata/Server-TLSv12-Resume index 366ca8f75d9..cebc00b5338 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv12-Resume +++ b/libgo/go/crypto/tls/testdata/Server-TLSv12-Resume @@ -1,41 +1,48 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 f9 01 00 00 f5 03 03 23 77 58 99 0e |...........#wX..| -00000010 44 ed 63 44 e4 e4 eb d1 83 c3 9c d0 24 12 a3 b9 |D.cD........$...| -00000020 55 6b 4d da bf 84 9d 35 de 43 a0 20 7b 93 cb d3 |UkM....5.C. {...| -00000030 c5 ce 5e d5 aa 48 91 a4 b2 c2 d7 72 09 0d 21 78 |..^..H.....r..!x| -00000040 f0 ac 7a ed 9a a9 ad dd 51 8b b2 1c 00 04 00 2f |..z.....Q....../| -00000050 00 ff 01 00 00 a8 00 23 00 78 50 46 ad c1 db a8 |.......#.xPF....| -00000060 38 86 7b 2b bb fd d0 c3 42 3e 00 00 00 00 00 00 |8.{+....B>......| -00000070 00 00 00 00 00 00 00 00 00 00 94 6f 2c 9f 83 61 |...........o,..a| -00000080 0b b1 b7 9e 10 2d 0c 56 e8 70 66 ad de b1 15 74 |.....-.V.pf....t| -00000090 2f 8b 08 8c 96 bb 4b 1b 4e dd 81 0e bf 84 4d 43 |/.....K.N.....MC| -000000a0 8f c0 7e a0 7f be c0 59 bf 83 26 0f a2 22 52 2c |..~....Y..&.."R,| -000000b0 33 94 5a 77 54 f3 b5 f2 22 51 d5 24 c2 60 c3 2e |3.ZwT..."Q.$.`..| -000000c0 0f 9c 5e 33 3b e8 7c 52 2a 76 08 58 ac 47 98 bc |..^3;.|R*v.X.G..| -000000d0 36 b6 00 0d 00 20 00 1e 06 01 06 02 06 03 05 01 |6.... ..........| -000000e0 05 02 05 03 04 01 04 02 04 03 03 01 03 02 03 03 |................| -000000f0 02 01 02 02 02 03 00 16 00 00 00 17 00 00 |..............| +00000000 16 03 01 01 33 01 00 01 2f 03 03 b0 fe 51 14 a8 |....3.../....Q..| +00000010 15 64 e2 64 e4 8e 4f 93 bf 17 38 50 d8 fb 4c fb |.d.d..O...8P..L.| +00000020 03 04 a2 c0 9d b9 d2 19 8f e6 9a 20 5e e4 28 dd |........... ^.(.| +00000030 e1 a6 89 f5 b2 5e 1a 7b d3 af 0a bb 19 dc e1 2f |.....^.{......./| +00000040 58 d7 9e 59 a7 b7 de 07 bb 06 4d 0c 00 04 00 2f |X..Y......M..../| +00000050 00 ff 01 00 00 e2 00 00 00 0e 00 0c 00 00 09 31 |...............1| +00000060 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000070 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 00 18 |................| +00000080 00 23 00 78 50 46 ad c1 db a8 38 86 7b 2b bb fd |.#.xPF....8.{+..| +00000090 d0 c3 42 3e 00 00 00 00 00 00 00 00 00 00 00 00 |..B>............| +000000a0 00 00 00 00 94 6f 2c 9f 83 61 fe 79 79 ae dc c2 |.....o,..a.yy...| +000000b0 a0 99 e2 59 46 79 88 b8 ed 74 da ef da 3e 7e 69 |...YFy...t...>~i| +000000c0 af 34 63 b3 7f 52 e1 07 4d f8 40 69 63 85 8c 66 |.4c..R..M.@ic..f| +000000d0 a6 d6 f7 b7 b0 f2 d4 12 f4 2a 33 94 64 76 91 5b |.........*3.dv.[| +000000e0 6c 7d 49 37 3c 0b 76 3e d6 5c 0b 65 79 96 31 51 |l}I7<.v>.\.ey.1Q| +000000f0 46 01 51 94 38 5b 51 d5 2d 1a 8b 19 00 16 00 00 |F.Q.8[Q.-.......| +00000100 00 17 00 00 00 0d 00 30 00 2e 04 03 05 03 06 03 |.......0........| +00000110 08 07 08 08 08 09 08 0a 08 0b 08 04 08 05 08 06 |................| +00000120 04 01 05 01 06 01 03 03 02 03 03 01 02 01 03 02 |................| +00000130 02 02 04 02 05 02 06 02 |........| >>> Flow 2 (server to client) 00000000 16 03 03 00 51 02 00 00 4d 03 03 00 00 00 00 00 |....Q...M.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 20 7b 93 cb d3 |........... {...| -00000030 c5 ce 5e d5 aa 48 91 a4 b2 c2 d7 72 09 0d 21 78 |..^..H.....r..!x| -00000040 f0 ac 7a ed 9a a9 ad dd 51 8b b2 1c 00 2f 00 00 |..z.....Q..../..| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 20 5e e4 28 dd |...DOWNGRD. ^.(.| +00000030 e1 a6 89 f5 b2 5e 1a 7b d3 af 0a bb 19 dc e1 2f |.....^.{......./| +00000040 58 d7 9e 59 a7 b7 de 07 bb 06 4d 0c 00 2f 00 00 |X..Y......M../..| 00000050 05 ff 01 00 01 00 14 03 03 00 01 01 16 03 03 00 |................| 00000060 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |@...............| -00000070 00 ac d9 95 88 c6 37 e8 3c 24 d8 d9 15 46 25 c6 |......7.<$...F%.| -00000080 32 0c 75 80 11 3d 89 53 1c 7a b1 78 6a c1 1a d7 |2.u..=.S.z.xj...| -00000090 91 6e c2 55 99 84 11 43 cd 62 99 3b 28 1b 2e 08 |.n.U...C.b.;(...| -000000a0 a8 |.| +00000070 00 c6 4d ae 43 25 3e 7a 8b 1d bc 77 6f 6d 05 c8 |..M.C%>z...wom..| +00000080 93 a1 d0 ee 81 0b e6 3e e6 0d 55 ff 3a 76 f3 e1 |.......>..U.:v..| +00000090 49 0b e4 3b d2 1c cb 2d 9f 1e 03 cb f9 8c 60 96 |I..;...-......`.| +000000a0 b1 |.| >>> Flow 3 (client to server) -00000000 14 03 03 00 01 01 16 03 03 00 40 67 fd 43 2a 0b |..........@g.C*.| -00000010 14 6b 89 53 84 a8 04 62 d6 30 af 68 eb 8e 2a de |.k.S...b.0.h..*.| -00000020 67 c9 40 af 8b ac dd 29 a4 20 e4 da b0 dd c3 05 |g.@....). ......| -00000030 82 83 8f 75 77 db 6c fe e7 20 54 e3 eb 51 31 68 |...uw.l.. T..Q1h| -00000040 da 11 a3 6d a1 34 d9 f5 d1 ef c9 |...m.4.....| +00000000 14 03 03 00 01 01 16 03 03 00 40 c9 ab 6e 5b 04 |..........@..n[.| +00000010 35 28 90 72 16 86 e8 ad a5 4d 2e f8 5a ee 42 8e |5(.r.....M..Z.B.| +00000020 6c 3f a4 00 3a de a8 c5 8f e3 59 15 10 09 31 91 |l?..:.....Y...1.| +00000030 5c ad a1 b1 15 bc fd a1 4a 91 4b 7a 50 a7 37 c4 |\.......J.KzP.7.| +00000040 3b 9d 3b 30 8e cd 8c ec b3 bc 94 |;.;0.......| >>> Flow 4 (server to client) 00000000 17 03 03 00 40 00 00 00 00 00 00 00 00 00 00 00 |....@...........| -00000010 00 00 00 00 00 ee e2 75 6f 78 b0 88 1a 8b 9b 91 |.......uox......| -00000020 c9 8c 3b ae a5 93 71 12 55 66 f8 09 a5 1f 4b 1b |..;...q.Uf....K.| -00000030 c2 fe 65 8b 3d d9 dc fa af dc 29 1b 83 da e0 6a |..e.=.....)....j| -00000040 4b cd d0 dc 27 |K...'| +00000010 00 00 00 00 00 95 7d fd bf 36 bd 7d 5f 42 2f 0a |......}..6.}_B/.| +00000020 84 27 ed 2d 76 07 cb 5a 96 93 74 68 9f 2a 66 fa |.'.-v..Z..th.*f.| +00000030 85 b0 38 bc da 8d 11 7f 80 80 21 ed 34 db 58 91 |..8.......!.4.X.| +00000040 b0 d7 8d 08 f1 15 03 03 00 30 00 00 00 00 00 00 |.........0......| +00000050 00 00 00 00 00 00 00 00 00 00 6f ed 4a be 10 ea |..........o.J...| +00000060 6a 75 ee 69 c2 2c f7 54 8a 18 aa 5f 7c 65 d0 d8 |ju.i.,.T..._|e..| +00000070 0c 94 dc a8 47 45 83 e6 68 09 |....GE..h.| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv12-ResumeDisabled b/libgo/go/crypto/tls/testdata/Server-TLSv12-ResumeDisabled index 34748371cff..102ca95d8f9 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv12-ResumeDisabled +++ b/libgo/go/crypto/tls/testdata/Server-TLSv12-ResumeDisabled @@ -1,24 +1,28 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 f9 01 00 00 f5 03 03 e8 59 b4 a7 b2 |............Y...| -00000010 77 86 57 47 0d d7 7b 2b c1 a2 04 fd 8d 4d e4 f5 |w.WG..{+.....M..| -00000020 be e2 65 8e 28 9a fe c3 19 fc 43 20 40 38 fb 60 |..e.(.....C @8.`| -00000030 f8 2f 36 f4 85 1d ee f1 53 f2 90 cf 3c 58 36 cd |./6.....S.........| -00000070 00 00 00 00 00 00 00 00 00 00 94 6f 2c 9f 83 61 |...........o,..a| -00000080 2e fe 48 fe f6 bb 98 a0 6f b0 be 9e 86 d7 b2 f2 |..H.....o.......| -00000090 67 c7 44 c7 3d e4 2b de d0 f4 d2 17 51 84 8e 7a |g.D.=.+.....Q..z| -000000a0 a7 80 c4 65 14 f7 49 09 68 15 56 68 32 41 d1 6f |...e..I.h.Vh2A.o| -000000b0 33 94 a1 3a c9 37 20 5d e6 b0 6f 37 0a 10 e3 28 |3..:.7 ]..o7...(| -000000c0 e1 34 b6 6d e6 7a 44 24 7f 2f cf 1b ae dd 4c d0 |.4.m.zD$./....L.| -000000d0 11 75 00 0d 00 20 00 1e 06 01 06 02 06 03 05 01 |.u... ..........| -000000e0 05 02 05 03 04 01 04 02 04 03 03 01 03 02 03 03 |................| -000000f0 02 01 02 02 02 03 00 16 00 00 00 17 00 00 |..............| +00000000 16 03 01 01 33 01 00 01 2f 03 03 ec 14 e8 1f 51 |....3.../......Q| +00000010 60 0d 36 02 55 a0 c0 26 d1 a3 c4 e9 3a aa 95 4d |`.6.U..&....:..M| +00000020 6e 2b 72 fa 21 3d 26 0c 33 d6 87 20 12 fa 92 10 |n+r.!=&.3.. ....| +00000030 d6 81 cb 7d 83 97 81 0a 7b 02 0d b7 88 48 fd 14 |...}....{....H..| +00000040 82 23 7e c1 88 e7 2c 79 be 5c e1 30 00 04 00 2f |.#~...,y.\.0.../| +00000050 00 ff 01 00 00 e2 00 00 00 0e 00 0c 00 00 09 31 |...............1| +00000060 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000070 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 00 18 |................| +00000080 00 23 00 78 50 46 ad c1 db a8 38 86 7b 2b bb fd |.#.xPF....8.{+..| +00000090 d0 c3 42 3e 00 00 00 00 00 00 00 00 00 00 00 00 |..B>............| +000000a0 00 00 00 00 94 6f 2c 9f 83 61 70 4f 8e 34 f4 65 |.....o,..apO.4.e| +000000b0 e4 64 ba af 8d 55 d8 8a c4 90 a4 94 d1 84 44 51 |.d...U........DQ| +000000c0 72 f0 79 b3 2b c3 49 48 58 e7 66 8c 3d 60 dd 65 |r.y.+.IHX.f.=`.e| +000000d0 ba 93 0a f1 45 28 83 56 19 28 33 94 dd d4 29 db |....E(.V.(3...).| +000000e0 f0 80 d1 b2 0a ef 69 03 b5 fa 19 82 a9 0e 42 b0 |......i.......B.| +000000f0 bb c2 b5 c7 b5 92 1f e6 3b 38 e3 85 00 16 00 00 |........;8......| +00000100 00 17 00 00 00 0d 00 30 00 2e 04 03 05 03 06 03 |.......0........| +00000110 08 07 08 08 08 09 08 0a 08 0b 08 04 08 05 08 06 |................| +00000120 04 01 05 01 06 01 03 03 02 03 03 01 02 01 03 02 |................| +00000130 02 02 04 02 05 02 06 02 |........| >>> Flow 2 (server to client) 00000000 16 03 03 00 31 02 00 00 2d 03 03 00 00 00 00 00 |....1...-.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2f 00 00 |............./..| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 00 2f 00 00 |...DOWNGRD.../..| 00000030 05 ff 01 00 01 00 16 03 03 02 59 0b 00 02 55 00 |..........Y...U.| 00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -59,31 +63,31 @@ 00000280 b3 3e c0 d1 bd 42 d4 db fe 3d 13 60 84 5c 21 d3 |.>...B...=.`.\!.| 00000290 3b e9 fa e7 16 03 03 00 04 0e 00 00 00 |;............| >>> Flow 3 (client to server) -00000000 16 03 03 00 86 10 00 00 82 00 80 5e 04 66 f2 27 |...........^.f.'| -00000010 99 3b f8 15 9f b8 4a ab 8c 32 10 0d 5b c9 5b 0b |.;....J..2..[.[.| -00000020 04 69 dc 2b 9e bb 28 38 b6 a0 0f 32 ae 8c 96 64 |.i.+..(8...2...d| -00000030 63 97 6b b6 63 94 45 84 03 28 d1 d8 85 2f a7 bb |c.k.c.E..(.../..| -00000040 be ca 3e f5 30 27 e1 fd e5 cc bc b5 61 3d 26 8d |..>.0'......a=&.| -00000050 0e 93 dd 78 07 5c fe 1b a9 57 c7 ce e6 df eb 28 |...x.\...W.....(| -00000060 74 ce 12 f3 df 3f c0 9e 54 b6 e0 b0 ea f7 08 c6 |t....?..T.......| -00000070 e1 9b cb e7 e9 41 b0 b4 68 2f f2 9b 1a 0a e3 17 |.....A..h/......| -00000080 df d7 18 ff 95 ca 36 07 32 ff f9 14 03 03 00 01 |......6.2.......| -00000090 01 16 03 03 00 40 cb c3 74 05 82 ab 93 07 a2 8b |.....@..t.......| -000000a0 24 27 c0 21 3e d1 15 12 9a 85 20 5b f5 7e 7e 0a |$'.!>..... [.~~.| -000000b0 a0 8e b2 de aa 25 2a b3 3d 12 1b 01 45 ec 36 53 |.....%*.=...E.6S| -000000c0 32 1d 81 c7 1d a6 96 c2 a9 2e af fa 90 6e 76 bb |2............nv.| -000000d0 a2 bc 43 91 c9 ca |..C...| +00000000 16 03 03 00 86 10 00 00 82 00 80 a1 9c 83 96 72 |...............r| +00000010 04 cb dd 16 d6 02 0c fd ec 03 7f bb 23 9a a4 b5 |............#...| +00000020 f0 50 3e 0f 32 bb 92 9d 09 b0 20 f2 08 4b f0 37 |.P>.2..... ..K.7| +00000030 0d ef f6 22 0d 75 ad 2f 1b ce 1f 87 f0 fe 50 9a |...".u./......P.| +00000040 c5 3b a3 fa c7 59 bf dd 4c b6 04 95 a2 c4 83 97 |.;...Y..L.......| +00000050 04 e8 ab 3a ff 25 7b 2d aa c0 bd 0f 1f ef 55 34 |...:.%{-......U4| +00000060 c5 bf 7c 48 b7 9c d0 9a 37 ab fa 32 53 fb 5c 66 |..|H....7..2S.\f| +00000070 53 8a 81 cf bd 5a 8f d2 76 87 01 b9 29 72 b4 4e |S....Z..v...)r.N| +00000080 7c 25 6d b1 4f 59 8b a4 fc cf 27 14 03 03 00 01 ||%m.OY....'.....| +00000090 01 16 03 03 00 40 e2 b7 3e 75 4d 7a ee 8e 32 75 |.....@..>uMz..2u| +000000a0 e1 04 11 55 63 87 d6 f2 8d f1 78 de 8a fa bb 1e |...Uc.....x.....| +000000b0 74 1d 5c e3 c3 77 c4 10 6b 6d 63 ab 5c 08 b4 3e |t.\..w..kmc.\..>| +000000c0 f0 f7 cb 72 cd 5e 83 e2 6f 67 06 83 cf 22 73 05 |...r.^..og..."s.| +000000d0 2d 6f 12 58 2c 74 |-o.X,t| >>> Flow 4 (server to client) 00000000 14 03 03 00 01 01 16 03 03 00 40 00 00 00 00 00 |..........@.....| -00000010 00 00 00 00 00 00 00 00 00 00 00 7f 39 4c 83 d4 |............9L..| -00000020 ca a2 7a a8 eb 3e 45 18 6e 33 3d 6f eb 2d 4f 72 |..z..>E.n3=o.-Or| -00000030 35 ee c3 f8 22 fd 39 28 47 23 55 16 6c 47 80 b7 |5...".9(G#U.lG..| -00000040 65 31 15 f6 89 79 96 bd 6a df 1d 17 03 03 00 40 |e1...y..j......@| +00000010 00 00 00 00 00 00 00 00 00 00 00 d3 51 28 12 19 |............Q(..| +00000020 67 4f 60 7e 0e af f1 f9 31 4b 2c a3 87 a5 5c 61 |gO`~....1K,...\a| +00000030 1a d3 58 57 8f b5 a1 75 87 86 ca 7b e2 a3 bf 53 |..XW...u...{...S| +00000040 2a 92 09 04 43 29 9b 22 c5 19 a4 17 03 03 00 40 |*...C).".......@| 00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000060 0c ea 0d 87 9a 24 d5 cc 26 9a a2 32 df 04 24 7d |.....$..&..2..$}| -00000070 45 ed 35 4e 5b a0 57 c1 c7 f1 0f 8b b0 f9 49 85 |E.5N[.W.......I.| -00000080 d6 e6 36 26 d5 f3 e4 00 76 d0 d6 20 be b3 31 e5 |..6&....v.. ..1.| +00000060 58 bf 73 aa ed 8a a0 61 c5 81 ac 22 1d ab 7b 75 |X.s....a..."..{u| +00000070 8b 31 97 fc df 6a e9 07 a7 3e c8 2d 3d 70 b1 b7 |.1...j...>.-=p..| +00000080 c1 ca 15 d5 c6 ac 32 ed 64 1f 98 d5 7e 17 3b 95 |......2.d...~.;.| 00000090 15 03 03 00 30 00 00 00 00 00 00 00 00 00 00 00 |....0...........| -000000a0 00 00 00 00 00 6c 51 e9 c2 e8 4f 43 e2 ce 01 9d |.....lQ...OC....| -000000b0 d9 6f d7 c7 bf 16 d9 28 ca 8a ea 5e d5 84 ba 55 |.o.....(...^...U| -000000c0 b7 23 9d 79 28 |.#.y(| +000000a0 00 00 00 00 00 e1 a6 0c 04 db 23 62 bb 99 9f b7 |..........#b....| +000000b0 1b 2b ae 6d 7d 9f 54 8e 39 60 6c d6 94 34 fa cd |.+.m}.T.9`l..4..| +000000c0 a8 7c ed a8 52 |.|..R| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv12-SNI b/libgo/go/crypto/tls/testdata/Server-TLSv12-SNI index 852cc63d03d..f1c35527d20 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv12-SNI +++ b/libgo/go/crypto/tls/testdata/Server-TLSv12-SNI @@ -1,16 +1,18 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 71 01 00 00 6d 03 03 35 8f 03 0b f4 |....q...m..5....| -00000010 81 dd d7 ec 8b cc 85 bd 07 5b 83 16 cc 6e b2 67 |.........[...n.g| -00000020 fd 33 69 81 14 9a 14 9d 37 43 5a 00 00 04 00 2f |.3i.....7CZ..../| -00000030 00 ff 01 00 00 40 00 00 00 10 00 0e 00 00 0b 73 |.....@.........s| -00000040 6e 69 74 65 73 74 2e 63 6f 6d 00 0d 00 20 00 1e |nitest.com... ..| -00000050 06 01 06 02 06 03 05 01 05 02 05 03 04 01 04 02 |................| -00000060 04 03 03 01 03 02 03 03 02 01 02 02 02 03 00 16 |................| -00000070 00 00 00 17 00 00 |......| +00000000 16 03 01 00 99 01 00 00 95 03 03 4d 04 34 4d c9 |...........M.4M.| +00000010 52 17 f0 1c 49 b6 2b d1 a0 16 a2 04 f4 d3 7c ca |R...I.+.......|.| +00000020 3d 4e 41 44 3d de 29 60 32 d6 a7 00 00 04 00 2f |=NAD=.)`2....../| +00000030 00 ff 01 00 00 68 00 00 00 10 00 0e 00 00 0b 73 |.....h.........s| +00000040 6e 69 74 65 73 74 2e 63 6f 6d 00 0b 00 04 03 00 |nitest.com......| +00000050 01 02 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 |................| +00000060 00 18 00 16 00 00 00 17 00 00 00 0d 00 30 00 2e |.............0..| +00000070 04 03 05 03 06 03 08 07 08 08 08 09 08 0a 08 0b |................| +00000080 08 04 08 05 08 06 04 01 05 01 06 01 03 03 02 03 |................| +00000090 03 01 02 01 03 02 02 02 04 02 05 02 06 02 |..............| >>> Flow 2 (server to client) 00000000 16 03 03 00 31 02 00 00 2d 03 03 00 00 00 00 00 |....1...-.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2f 00 00 |............./..| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 00 2f 00 00 |...DOWNGRD.../..| 00000030 05 ff 01 00 01 00 16 03 03 02 59 0b 00 02 55 00 |..........Y...U.| 00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -51,31 +53,31 @@ 00000280 b3 3e c0 d1 bd 42 d4 db fe 3d 13 60 84 5c 21 d3 |.>...B...=.`.\!.| 00000290 3b e9 fa e7 16 03 03 00 04 0e 00 00 00 |;............| >>> Flow 3 (client to server) -00000000 16 03 03 00 86 10 00 00 82 00 80 4c 15 46 23 91 |...........L.F#.| -00000010 a0 d8 6c 45 f0 49 7e 70 84 9f bf 53 3d 68 2c cc |..lE.I~p...S=h,.| -00000020 20 3f 28 bd cf e6 6e fd e6 90 ff 87 14 82 65 00 | ?(...n.......e.| -00000030 d6 b6 ef 5a 0c d6 30 76 88 d2 37 33 39 de 00 b4 |...Z..0v..739...| -00000040 ec dd 30 3b f6 88 ff 4c b2 98 75 77 fd c3 61 38 |..0;...L..uw..a8| -00000050 2d 00 f7 14 d8 a4 37 22 c0 db 8a bd 12 0b b8 cc |-.....7"........| -00000060 37 82 78 d3 0e f2 0b 9b 51 c5 26 c5 e2 ce 3e 0e |7.x.....Q.&...>.| -00000070 04 34 39 83 a8 f5 65 ff 40 d9 9b 4a 11 6b b3 d2 |.49...e.@..J.k..| -00000080 f7 02 78 a9 7c f4 69 56 3a a4 98 14 03 03 00 01 |..x.|.iV:.......| -00000090 01 16 03 03 00 40 d6 90 b3 07 d1 a1 c1 12 35 07 |.....@........5.| -000000a0 4e c0 df 4b 17 cc fa 49 47 c9 22 c3 6f 70 fa ee |N..K...IG.".op..| -000000b0 cf b3 61 d6 06 54 cd ce c2 15 17 8a a0 f6 5c 43 |..a..T........\C| -000000c0 7c 92 ce 89 d4 96 53 d0 c7 e6 9a 24 bc 5a 83 e5 ||.....S....$.Z..| -000000d0 9c 65 72 e7 80 a4 |.er...| +00000000 16 03 03 00 86 10 00 00 82 00 80 ca 5a ef 73 b7 |............Z.s.| +00000010 e2 11 b7 9a 45 22 8f 0d 44 ca 44 77 c0 ec 67 95 |....E"..D.Dw..g.| +00000020 cc 63 2a 55 65 69 34 93 a2 64 fa f8 c0 db 56 91 |.c*Uei4..d....V.| +00000030 d2 50 d4 a8 8c 89 13 e6 c0 ce 2b 26 46 cb ea 39 |.P........+&F..9| +00000040 66 4c 89 58 8d 8a da 9c bd 16 b3 28 40 a1 6f f8 |fL.X.......(@.o.| +00000050 f7 f5 d9 9f d1 cd 44 ca b5 ed 19 ea ec fa 97 2d |......D........-| +00000060 87 a5 c2 a8 1e f0 0c 70 fd fc a7 e7 1b dc 0c 99 |.......p........| +00000070 d0 1f 6d 68 df 64 8f cb ce 7b 3e 38 ab 9d b3 ba |..mh.d...{>8....| +00000080 66 a4 17 60 d6 fd ab 1d d8 a2 b4 14 03 03 00 01 |f..`............| +00000090 01 16 03 03 00 40 31 e3 94 eb 85 21 63 5e 29 b8 |.....@1....!c^).| +000000a0 2b 9a 42 d1 4d f1 3c e8 df 66 ed 6f 61 42 aa 46 |+.B.M.<..f.oaB.F| +000000b0 c0 4b 33 27 93 94 c5 6a 6c 94 f9 ba 6a 81 11 b1 |.K3'...jl...j...| +000000c0 be 21 00 97 d9 84 9d ee fd fd 79 18 ad 07 7a a8 |.!........y...z.| +000000d0 d3 89 e3 2a b0 f0 |...*..| >>> Flow 4 (server to client) 00000000 14 03 03 00 01 01 16 03 03 00 40 00 00 00 00 00 |..........@.....| -00000010 00 00 00 00 00 00 00 00 00 00 00 a0 61 69 4c 9d |............aiL.| -00000020 68 f3 f8 f6 a0 ef 1b f4 a2 f5 83 fa 03 87 ad 67 |h..............g| -00000030 7e 9f df c6 ce 9f 69 ce 22 fc de 91 0d 18 00 fb |~.....i.".......| -00000040 c1 5d a1 2d bb 89 29 4f f6 de 57 17 03 03 00 40 |.].-..)O..W....@| +00000010 00 00 00 00 00 00 00 00 00 00 00 98 ae 81 aa e9 |................| +00000020 4e 1f 93 59 89 05 a2 98 c3 17 dd e1 9d 9a 12 7d |N..Y...........}| +00000030 30 c6 6c b4 a6 f3 b7 b2 c5 df dc 9d 81 99 ce 29 |0.l............)| +00000040 4b 75 04 9e d3 82 06 fa 22 1f a2 17 03 03 00 40 |Ku......"......@| 00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000060 bb 54 f4 80 69 1d 3b 9c e7 9c 1a fb 4e 3d c1 02 |.T..i.;.....N=..| -00000070 d3 05 86 35 47 61 59 aa 45 54 ae a2 59 4c 75 8c |...5GaY.ET..YLu.| -00000080 8d a9 7d 7f a0 4b d9 65 7a 53 ef 7e ed a3 fa 9e |..}..K.ezS.~....| +00000060 dc 0e 49 1a ad 28 b6 c1 f2 27 ae bf 94 45 57 15 |..I..(...'...EW.| +00000070 74 33 ae 3a f0 ee e5 76 7e 72 6c d9 56 64 88 58 |t3.:...v~rl.Vd.X| +00000080 0b 96 35 a9 83 2e 4e 82 f8 a4 f8 f5 5b 08 6f 79 |..5...N.....[.oy| 00000090 15 03 03 00 30 00 00 00 00 00 00 00 00 00 00 00 |....0...........| -000000a0 00 00 00 00 00 cc fd 0f cb 74 a5 36 ce c1 cd 54 |.........t.6...T| -000000b0 6f 66 81 c0 ab ff 72 ea f3 1f a6 b7 ef 46 45 68 |of....r......FEh| -000000c0 9b 0b 7f 4f 46 |...OF| +000000a0 00 00 00 00 00 63 55 cb 53 f8 b1 48 85 33 aa c6 |.....cU.S..H.3..| +000000b0 aa 60 c4 d0 b6 bb cc 85 3e a9 92 f9 be 53 8b 8b |.`......>....S..| +000000c0 3e 9c ee 8f f4 |>....| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv12-SNI-GetCertificate b/libgo/go/crypto/tls/testdata/Server-TLSv12-SNI-GetCertificate index b35cd8de268..f407ffd0b53 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv12-SNI-GetCertificate +++ b/libgo/go/crypto/tls/testdata/Server-TLSv12-SNI-GetCertificate @@ -1,16 +1,18 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 71 01 00 00 6d 03 03 31 c7 3f 2b 99 |....q...m..1.?+.| -00000010 95 d8 d5 b7 91 ab 95 c6 09 35 0c 2b bd b6 94 1e |.........5.+....| -00000020 64 4a 2d b6 43 23 a0 01 e7 93 22 00 00 04 00 2f |dJ-.C#...."..../| -00000030 00 ff 01 00 00 40 00 00 00 10 00 0e 00 00 0b 73 |.....@.........s| -00000040 6e 69 74 65 73 74 2e 63 6f 6d 00 0d 00 20 00 1e |nitest.com... ..| -00000050 06 01 06 02 06 03 05 01 05 02 05 03 04 01 04 02 |................| -00000060 04 03 03 01 03 02 03 03 02 01 02 02 02 03 00 16 |................| -00000070 00 00 00 17 00 00 |......| +00000000 16 03 01 00 99 01 00 00 95 03 03 9d e8 44 6f ac |.............Do.| +00000010 b8 f3 4e 96 5e c0 2a 81 4d 71 2e 0e 8a a0 2f 88 |..N.^.*.Mq..../.| +00000020 4a 87 39 d2 ed 94 0b 41 ad 2b bf 00 00 04 00 2f |J.9....A.+...../| +00000030 00 ff 01 00 00 68 00 00 00 10 00 0e 00 00 0b 73 |.....h.........s| +00000040 6e 69 74 65 73 74 2e 63 6f 6d 00 0b 00 04 03 00 |nitest.com......| +00000050 01 02 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 |................| +00000060 00 18 00 16 00 00 00 17 00 00 00 0d 00 30 00 2e |.............0..| +00000070 04 03 05 03 06 03 08 07 08 08 08 09 08 0a 08 0b |................| +00000080 08 04 08 05 08 06 04 01 05 01 06 01 03 03 02 03 |................| +00000090 03 01 02 01 03 02 02 02 04 02 05 02 06 02 |..............| >>> Flow 2 (server to client) 00000000 16 03 03 00 31 02 00 00 2d 03 03 00 00 00 00 00 |....1...-.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2f 00 00 |............./..| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 00 2f 00 00 |...DOWNGRD.../..| 00000030 05 ff 01 00 01 00 16 03 03 02 59 0b 00 02 55 00 |..........Y...U.| 00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -51,31 +53,31 @@ 00000280 b3 3e c0 d1 bd 42 d4 db fe 3d 13 60 84 5c 21 d3 |.>...B...=.`.\!.| 00000290 3b e9 fa e7 16 03 03 00 04 0e 00 00 00 |;............| >>> Flow 3 (client to server) -00000000 16 03 03 00 86 10 00 00 82 00 80 c9 3a 9d ea e3 |............:...| -00000010 19 f1 07 77 61 ef 5a aa ed 0f 26 b4 7a 45 db 05 |...wa.Z...&.zE..| -00000020 bd 51 77 f5 ee 7b c1 83 9c 95 49 7b 70 5e 5b fe |.Qw..{....I{p^[.| -00000030 25 d2 3d 64 74 b8 a4 97 fd cb b9 75 7b 8f b0 59 |%.=dt......u{..Y| -00000040 30 bf b3 41 ce 54 83 0a ca 29 49 5a fe 29 4c 53 |0..A.T...)IZ.)LS| -00000050 fb d6 6e 46 d9 f7 31 17 d6 ee f9 ac 41 82 22 11 |..nF..1.....A.".| -00000060 a7 34 07 41 50 43 2f 83 f6 1f c6 c0 9d 4a 67 5a |.4.APC/......JgZ| -00000070 af 44 59 c0 00 33 be 24 f7 0a a4 fe 76 6b 03 05 |.DY..3.$....vk..| -00000080 2e ec 4d 49 db 6e e5 0a 5f af 09 14 03 03 00 01 |..MI.n.._.......| -00000090 01 16 03 03 00 40 ad 89 4d 25 a2 ce 98 8c cf b6 |.....@..M%......| -000000a0 f5 f4 76 6b e7 71 66 4a f9 a7 67 fb 1d 6c a7 83 |..vk.qfJ..g..l..| -000000b0 3b 1d 6a af 65 f2 c1 1d 97 03 5b c2 34 ee 3b 8e |;.j.e.....[.4.;.| -000000c0 cc bd 8f 3a b8 9b 4f 90 3f de 1e 97 1e 8e 61 37 |...:..O.?.....a7| -000000d0 2d 30 35 84 3b 26 |-05.;&| +00000000 16 03 03 00 86 10 00 00 82 00 80 a4 d5 09 e3 4c |...............L| +00000010 78 eb 7d 76 4f 7f cf c7 2b 9d d1 fe 8f 5e a2 6b |x.}vO...+....^.k| +00000020 83 82 cb 93 37 63 47 ec 38 48 42 2a 3e e1 bf 6b |....7cG.8HB*>..k| +00000030 02 0a 8c b8 07 a7 11 5d fd cc 6d dc 3b ed 26 24 |.......]..m.;.&$| +00000040 18 64 ed 2e 98 93 49 45 ea 49 be 3f 12 43 47 c0 |.d....IE.I.?.CG.| +00000050 c3 ef 25 e0 be 06 f2 e5 fe 9f 3e c7 e6 23 90 d1 |..%.......>..#..| +00000060 2e 6f fc e2 72 ba a2 c2 e9 94 ab 7e ca 59 fa 93 |.o..r......~.Y..| +00000070 40 4a 48 39 f9 5e 5f ac 60 a0 94 61 1c 6e 10 1e |@JH9.^_.`..a.n..| +00000080 30 44 1d 28 cb 2b b9 7f 00 dd 23 14 03 03 00 01 |0D.(.+....#.....| +00000090 01 16 03 03 00 40 81 02 8e b2 b5 e2 b2 0a 95 9e |.....@..........| +000000a0 1e 65 4a 63 98 5b f0 30 4b 63 0a 74 87 58 20 fb |.eJc.[.0Kc.t.X .| +000000b0 2f 58 f8 10 a5 5f 4e b9 19 21 96 5f 13 8d d6 ed |/X..._N..!._....| +000000c0 a3 39 92 e5 4c 0f 31 c3 df 51 2d bb 7c 29 54 34 |.9..L.1..Q-.|)T4| +000000d0 f6 68 fb f2 49 2d |.h..I-| >>> Flow 4 (server to client) 00000000 14 03 03 00 01 01 16 03 03 00 40 00 00 00 00 00 |..........@.....| -00000010 00 00 00 00 00 00 00 00 00 00 00 fe 23 de 33 4b |............#.3K| -00000020 55 f2 8e 73 09 ba ae f1 12 bd f7 15 75 90 8f 19 |U..s........u...| -00000030 1b 19 b6 3f 2c 19 47 87 a9 43 d5 1e 85 fb 0c 90 |...?,.G..C......| -00000040 c8 18 72 8f 08 6f 48 43 3c 5c 5a 17 03 03 00 40 |..r..oHC<\Z....@| +00000010 00 00 00 00 00 00 00 00 00 00 00 3a 54 5f df 8a |...........:T_..| +00000020 c4 53 fb 18 31 f5 72 47 fd ef 38 84 72 80 81 88 |.S..1.rG..8.r...| +00000030 45 69 81 aa c8 0d d7 4a 95 e9 cf ea b0 0e 07 3b |Ei.....J.......;| +00000040 9c f5 b3 47 00 58 55 e3 06 e1 a3 17 03 03 00 40 |...G.XU........@| 00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000060 4d 44 d7 eb a3 94 00 74 90 9d c0 bd 8e 11 eb b6 |MD.....t........| -00000070 93 43 c6 14 0d ba c2 aa f0 f5 2d 85 9a 7c 27 44 |.C........-..|'D| -00000080 fc d8 46 76 b2 21 4f 70 1a 9a df 9e 3a 8f a3 58 |..Fv.!Op....:..X| +00000060 dd c3 b2 95 87 4d fb ae ee 0e cd 78 ac f3 2d 06 |.....M.....x..-.| +00000070 f1 a1 86 91 a3 d3 8f f6 66 b6 1c 6d 3f 6b 5b ba |........f..m?k[.| +00000080 4c c8 b2 5e bf 46 2b 05 bd 17 51 29 bd 1a 91 39 |L..^.F+...Q)...9| 00000090 15 03 03 00 30 00 00 00 00 00 00 00 00 00 00 00 |....0...........| -000000a0 00 00 00 00 00 91 0f c3 2a 98 79 57 39 3c 68 98 |........*.yW9>> Flow 1 (client to server) -00000000 16 03 01 00 71 01 00 00 6d 03 03 f8 16 6b 20 c3 |....q...m....k .| -00000010 a4 cf fc ca 04 47 7a f9 cc d9 cf 4a 15 ff 6e 82 |.....Gz....J..n.| -00000020 14 6a 91 91 7f f1 f4 42 e6 7c d4 00 00 04 00 2f |.j.....B.|...../| -00000030 00 ff 01 00 00 40 00 00 00 10 00 0e 00 00 0b 73 |.....@.........s| -00000040 6e 69 74 65 73 74 2e 63 6f 6d 00 0d 00 20 00 1e |nitest.com... ..| -00000050 06 01 06 02 06 03 05 01 05 02 05 03 04 01 04 02 |................| -00000060 04 03 03 01 03 02 03 03 02 01 02 02 02 03 00 16 |................| -00000070 00 00 00 17 00 00 |......| +00000000 16 03 01 00 99 01 00 00 95 03 03 cf 60 be 69 fc |............`.i.| +00000010 d8 3d f8 5e 5a 67 1d 86 93 9a b1 58 4e ca 35 d8 |.=.^Zg.....XN.5.| +00000020 2d 92 56 f8 74 b0 9a 96 20 75 46 00 00 04 00 2f |-.V.t... uF..../| +00000030 00 ff 01 00 00 68 00 00 00 10 00 0e 00 00 0b 73 |.....h.........s| +00000040 6e 69 74 65 73 74 2e 63 6f 6d 00 0b 00 04 03 00 |nitest.com......| +00000050 01 02 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 |................| +00000060 00 18 00 16 00 00 00 17 00 00 00 0d 00 30 00 2e |.............0..| +00000070 04 03 05 03 06 03 08 07 08 08 08 09 08 0a 08 0b |................| +00000080 08 04 08 05 08 06 04 01 05 01 06 01 03 03 02 03 |................| +00000090 03 01 02 01 03 02 02 02 04 02 05 02 06 02 |..............| >>> Flow 2 (server to client) 00000000 16 03 03 00 31 02 00 00 2d 03 03 00 00 00 00 00 |....1...-.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 2f 00 00 |............./..| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 00 2f 00 00 |...DOWNGRD.../..| 00000030 05 ff 01 00 01 00 16 03 03 02 59 0b 00 02 55 00 |..........Y...U.| 00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -51,31 +53,31 @@ 00000280 b3 3e c0 d1 bd 42 d4 db fe 3d 13 60 84 5c 21 d3 |.>...B...=.`.\!.| 00000290 3b e9 fa e7 16 03 03 00 04 0e 00 00 00 |;............| >>> Flow 3 (client to server) -00000000 16 03 03 00 86 10 00 00 82 00 80 80 e8 00 cc 09 |................| -00000010 fc 87 20 9f 2a 38 33 6f cb 61 71 86 6d 55 6a 87 |.. .*83o.aq.mUj.| -00000020 e0 22 78 62 4e 3b 98 5c 87 fd 3b 1c 73 d3 77 7e |."xbN;.\..;.s.w~| -00000030 a4 c3 6f d4 6d 82 65 40 0e 70 2f 24 e9 7d ff 49 |..o.m.e@.p/$.}.I| -00000040 c7 bd 45 44 af ae a5 7a 06 06 5e 1e ce 31 73 4b |..ED...z..^..1sK| -00000050 4a 38 f0 11 ba 32 58 ab a5 94 12 13 30 83 95 85 |J8...2X.....0...| -00000060 f5 7e 8d a7 cc 6d 19 14 f9 b0 dc 64 e5 4d b1 7d |.~...m.....d.M.}| -00000070 e6 95 d4 4a 7f 85 11 5b a7 c9 32 84 c2 ec 2e c3 |...J...[..2.....| -00000080 40 fe 5c e2 cf 5b 96 8a 72 9f 9f 14 03 03 00 01 |@.\..[..r.......| -00000090 01 16 03 03 00 40 a8 d2 5b 24 28 2b 86 1e c1 2e |.....@..[$(+....| -000000a0 6f da 7a ac 6b bf 02 ea 10 5d 9c 71 fb 19 eb 17 |o.z.k....].q....| -000000b0 19 b2 07 7c b9 df d0 6d 9f 80 cf 37 a0 2a 18 c9 |...|...m...7.*..| -000000c0 e9 b5 9f 94 42 6a 6b 33 55 fb 6d 94 3b 79 ed 26 |....Bjk3U.m.;y.&| -000000d0 5c 5a 7f 68 2c d8 |\Z.h,.| +00000000 16 03 03 00 86 10 00 00 82 00 80 aa e3 c3 d5 76 |...............v| +00000010 d7 f7 da d5 93 39 8f 6d c2 6a ed dc b1 69 c9 2e |.....9.m.j...i..| +00000020 74 55 e3 2a c8 7d 03 f5 a6 6a 4e 04 b1 7f 14 86 |tU.*.}...jN.....| +00000030 4c 5a 0d 55 00 dc 58 2b b6 34 bb 51 b0 d6 df ff |LZ.U..X+.4.Q....| +00000040 ab 0e 1a a8 df b1 58 de 73 9d 94 e4 d1 26 28 df |......X.s....&(.| +00000050 64 09 fd b0 bc d5 9e 85 0d e8 0c ff 1a 5c 87 47 |d............\.G| +00000060 57 d0 3e a8 46 c6 5d c4 57 5c 95 c1 ca 91 69 c3 |W.>.F.].W\....i.| +00000070 26 2f 93 0a f8 56 51 10 e9 ff f2 82 4f 21 54 30 |&/...VQ.....O!T0| +00000080 d3 87 fd e9 e6 a1 05 53 d0 b4 10 14 03 03 00 01 |.......S........| +00000090 01 16 03 03 00 40 1f 6b ca bc 42 19 fe c6 64 cf |.....@.k..B...d.| +000000a0 6f de ff 54 28 56 de 1a 99 fb 19 d7 4a 5e 34 97 |o..T(V......J^4.| +000000b0 f6 38 99 17 16 fb 06 ae 88 fb a6 07 2f 01 7b 54 |.8........../.{T| +000000c0 63 8a 4a c1 6b ee 4e 61 4e c1 46 b5 d6 8f 51 a9 |c.J.k.NaN.F...Q.| +000000d0 fb 07 9b 88 27 20 |....' | >>> Flow 4 (server to client) 00000000 14 03 03 00 01 01 16 03 03 00 40 00 00 00 00 00 |..........@.....| -00000010 00 00 00 00 00 00 00 00 00 00 00 18 e9 b5 96 14 |................| -00000020 38 98 d4 23 cd e5 32 0e 09 ae b3 3b 90 a4 4d c2 |8..#..2....;..M.| -00000030 e5 a8 df 72 e8 97 0b 67 cb 87 f4 d0 3e 52 ca d1 |...r...g....>R..| -00000040 28 94 ed 88 6c cb 62 53 b2 a1 04 17 03 03 00 40 |(...l.bS.......@| +00000010 00 00 00 00 00 00 00 00 00 00 00 62 37 c3 c7 5e |...........b7..^| +00000020 7a 8c 16 99 2d a4 21 cd 44 ab ae ff 52 d4 a9 6f |z...-.!.D...R..o| +00000030 fe 58 9a 61 2e ed 51 47 8b 9f f1 ca be b9 46 78 |.X.a..QG......Fx| +00000040 9a fc d0 38 45 da a9 41 fd 51 8f 17 03 03 00 40 |...8E..A.Q.....@| 00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000060 0e e3 b0 da 4b 19 ca 29 7b 1d c8 e3 0d d7 f2 97 |....K..){.......| -00000070 b0 0b 6e f0 d2 4b f0 c4 ca 87 75 3c ae 66 e1 b3 |..n..K....u<.f..| -00000080 06 e3 e6 90 54 fd 31 f7 5d 3b 6f de 0f d5 e4 09 |....T.1.];o.....| +00000060 7d aa 32 6f 59 1c d9 83 fe 11 2f ff b7 92 fb 22 |}.2oY...../...."| +00000070 c0 9c 77 d6 73 66 da 10 f1 36 61 34 0f e6 e9 77 |..w.sf...6a4...w| +00000080 8a 5c c1 8c ba 36 9d cc 8d 3f 48 03 2c c1 a5 1e |.\...6...?H.,...| 00000090 15 03 03 00 30 00 00 00 00 00 00 00 00 00 00 00 |....0...........| -000000a0 00 00 00 00 00 ee a1 b0 94 b5 86 71 73 66 14 ac |...........qsf..| -000000b0 5c 4e 1b 67 27 af db b6 e3 44 15 38 b1 f5 e0 13 |\N.g'....D.8....| -000000c0 a5 e1 82 c0 6a |....j| +000000a0 00 00 00 00 00 29 14 57 d1 dc f3 ab 63 40 92 00 |.....).W....c@..| +000000b0 31 3b d5 36 a8 3c e3 cf b5 64 ee b7 e9 36 86 75 |1;.6.<...d...6.u| +000000c0 6e d8 91 29 f0 |n..).| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv12-X25519-ECDHE-RSA-AES-GCM b/libgo/go/crypto/tls/testdata/Server-TLSv12-X25519 similarity index 58% rename from libgo/go/crypto/tls/testdata/Server-TLSv12-X25519-ECDHE-RSA-AES-GCM rename to libgo/go/crypto/tls/testdata/Server-TLSv12-X25519 index 17136d41130..f8e6ab38d16 100644 --- a/libgo/go/crypto/tls/testdata/Server-TLSv12-X25519-ECDHE-RSA-AES-GCM +++ b/libgo/go/crypto/tls/testdata/Server-TLSv12-X25519 @@ -1,16 +1,18 @@ >>> Flow 1 (client to server) -00000000 16 03 01 00 73 01 00 00 6f 03 03 c3 5c 1e ad 54 |....s...o...\..T| -00000010 5b 03 af 49 42 dd cc 76 83 21 fe b4 4f 15 84 81 |[..IB..v.!..O...| -00000020 e5 07 5c 7d 58 3d 37 5a 3a ae f8 00 00 04 c0 2f |..\}X=7Z:....../| -00000030 00 ff 01 00 00 42 00 0b 00 04 03 00 01 02 00 0a |.....B..........| -00000040 00 0a 00 08 00 1d 00 17 00 19 00 18 00 0d 00 20 |............... | -00000050 00 1e 06 01 06 02 06 03 05 01 05 02 05 03 04 01 |................| -00000060 04 02 04 03 03 01 03 02 03 03 02 01 02 02 02 03 |................| -00000070 00 16 00 00 00 17 00 00 |........| +00000000 16 03 01 00 8f 01 00 00 8b 03 03 77 a6 19 8a 94 |...........w....| +00000010 4a 1a d4 51 10 98 c3 22 5d 5d 76 2d 4f 27 ea e8 |J..Q..."]]v-O'..| +00000020 61 d0 10 7a 08 43 23 42 b0 e0 12 00 00 04 c0 2f |a..z.C#B......./| +00000030 00 ff 01 00 00 5e 00 00 00 0e 00 0c 00 00 09 31 |.....^.........1| +00000040 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000050 00 0a 00 04 00 02 00 1d 00 16 00 00 00 17 00 00 |................| +00000060 00 0d 00 30 00 2e 04 03 05 03 06 03 08 07 08 08 |...0............| +00000070 08 09 08 0a 08 0b 08 04 08 05 08 06 04 01 05 01 |................| +00000080 06 01 03 03 02 03 03 01 02 01 03 02 02 02 04 02 |................| +00000090 05 02 06 02 |....| >>> Flow 2 (server to client) 00000000 16 03 03 00 31 02 00 00 2d 03 03 00 00 00 00 00 |....1...-.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| -00000020 00 00 00 00 00 00 00 00 00 00 00 00 c0 2f 00 00 |............./..| +00000020 00 00 00 44 4f 57 4e 47 52 44 01 00 c0 2f 00 00 |...DOWNGRD.../..| 00000030 05 ff 01 00 01 00 16 03 03 02 59 0b 00 02 55 00 |..........Y...U.| 00000040 02 52 00 02 4f 30 82 02 4b 30 82 01 b4 a0 03 02 |.R..O0..K0......| 00000050 01 02 02 09 00 e8 f0 9d 3f e2 5b ea a6 30 0d 06 |........?.[..0..| @@ -52,28 +54,28 @@ 00000290 3b e9 fa e7 16 03 03 00 ac 0c 00 00 a8 03 00 1d |;...............| 000002a0 20 2f e5 7d a3 47 cd 62 43 15 28 da ac 5f bb 29 | /.}.G.bC.(.._.)| 000002b0 07 30 ff f6 84 af c4 cf c2 ed 90 99 5f 58 cb 3b |.0.........._X.;| -000002c0 74 06 01 00 80 d1 1b d9 90 1c 69 ef 70 d8 76 10 |t.........i.p.v.| -000002d0 fe ea ce c5 42 ea e7 da 1a 45 83 11 75 51 e9 a4 |....B....E..uQ..| -000002e0 fe 4c c6 b2 76 62 35 83 ae 45 08 80 07 76 0c d2 |.L..vb5..E...v..| -000002f0 b6 a7 7d b4 ca 5d a0 70 88 2c ad 03 44 30 14 d7 |..}..].p.,..D0..| -00000300 0b 9e 19 77 5f 2f 95 83 8a 5e 07 3e 7f 22 ca 86 |...w_/...^.>."..| -00000310 b9 ae 0d eb b8 0e ce ec 5d 1f 72 95 cf a5 3f 2c |........].r...?,| -00000320 82 2f 17 f7 63 07 cd 01 d1 50 31 49 e4 d1 2c 75 |./..c....P1I..,u| -00000330 1a 18 b9 76 51 33 f4 ff 74 37 cc bd 18 f9 3a 09 |...vQ3..t7....:.| -00000340 25 38 56 a4 7b 16 03 03 00 04 0e 00 00 00 |%8V.{.........| +000002c0 74 08 04 00 80 0f e7 f4 b4 b9 f2 83 95 26 d7 70 |t............&.p| +000002d0 5f b2 e3 5e 42 86 b6 67 0a df 4e 60 2d d2 91 be |_..^B..g..N`-...| +000002e0 2c ba c1 24 9c 57 29 eb aa df 52 e5 8e 5f 9c ab |,..$.W)...R.._..| +000002f0 9c 88 c5 8a 92 fd b6 d5 e2 6b 0d ea 1c de 73 22 |.........k....s"| +00000300 a1 51 05 e0 b6 87 e1 e4 2b 8e 1d 06 26 53 37 4e |.Q......+...&S7N| +00000310 c7 8f 05 4a 0c 48 69 d3 7b f8 44 33 7b 2b 54 f5 |...J.Hi.{.D3{+T.| +00000320 d9 a8 70 f3 6d b5 1c e4 4d 53 5f 0d 29 76 92 d3 |..p.m...MS_.)v..| +00000330 63 19 25 b0 8c c6 31 13 e4 b5 d5 d0 b9 47 ed 54 |c.%...1......G.T| +00000340 28 82 6c 04 a9 16 03 03 00 04 0e 00 00 00 |(.l...........| >>> Flow 3 (client to server) -00000000 16 03 03 00 25 10 00 00 21 20 71 94 86 30 e3 73 |....%...! q..0.s| -00000010 65 46 cb e3 ea 30 0b 32 77 f5 52 28 6f 98 a2 ed |eF...0.2w.R(o...| -00000020 52 6e 14 eb 5f 89 33 98 13 4a 14 03 03 00 01 01 |Rn.._.3..J......| -00000030 16 03 03 00 28 31 f7 9a 7d 84 21 17 7f c4 6e 9e |....(1..}.!...n.| -00000040 78 59 64 d1 d0 e7 74 fb 77 1b 7a b9 d5 e0 a6 c6 |xYd...t.w.z.....| -00000050 ec a4 9f 64 38 dd 24 8c d8 13 71 69 4f |...d8.$...qiO| +00000000 16 03 03 00 25 10 00 00 21 20 a4 db 55 a3 5a 6f |....%...! ..U.Zo| +00000010 af bf a2 53 ad 81 4d ea ef c0 d7 02 5d 42 9f ee |...S..M.....]B..| +00000020 34 ff bf 08 c9 13 56 8c e3 26 14 03 03 00 01 01 |4.....V..&......| +00000030 16 03 03 00 28 bd 32 89 70 2a eb 54 d1 ae 60 08 |....(.2.p*.T..`.| +00000040 4e 05 c9 e8 bb a7 fc 96 56 1a ba c7 51 a5 4d 2a |N.......V...Q.M*| +00000050 de da 6e a9 97 82 aa 37 44 00 4a 1f 0a |..n....7D.J..| >>> Flow 4 (server to client) 00000000 14 03 03 00 01 01 16 03 03 00 28 00 00 00 00 00 |..........(.....| -00000010 00 00 00 65 fc d6 aa c0 c7 6d 5e 94 bb cb 7c 19 |...e.....m^...|.| -00000020 f4 4f 4b 0e d5 b1 66 cc fb 7b d0 bb bc d3 de 55 |.OK...f..{.....U| -00000030 79 d5 57 17 03 03 00 25 00 00 00 00 00 00 00 01 |y.W....%........| -00000040 bf d0 4a cb ab f0 86 9a ec 92 19 5e 51 6e 63 4e |..J........^QncN| -00000050 00 c6 1f e8 af 15 ec e7 29 45 f5 54 dd 15 03 03 |........)E.T....| -00000060 00 1a 00 00 00 00 00 00 00 02 7e 20 a1 70 fa b9 |..........~ .p..| -00000070 6f b3 3b b0 65 b5 96 15 b0 f6 db 8a |o.;.e.......| +00000010 00 00 00 7e 16 80 9b 85 03 3b 19 35 dc 22 75 4d |...~.....;.5."uM| +00000020 08 36 ad ee 24 f2 75 de fe c2 c6 ba 91 62 1d 29 |.6..$.u......b.)| +00000030 68 53 d3 17 03 03 00 25 00 00 00 00 00 00 00 01 |hS.....%........| +00000040 65 36 ef c0 52 ae be bc 94 af 01 d6 c1 a8 2c 04 |e6..R.........,.| +00000050 3c 83 a2 88 61 7f 41 c0 76 ec aa 52 8d 15 03 03 |<...a.A.v..R....| +00000060 00 1a 00 00 00 00 00 00 00 02 4a dd b0 50 cf 59 |..........J..P.Y| +00000070 01 67 74 45 f2 ae 47 f1 38 ef 51 04 |.gtE..G.8.Q.| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv13-AES128-SHA256 b/libgo/go/crypto/tls/testdata/Server-TLSv13-AES128-SHA256 new file mode 100644 index 00000000000..9e854036184 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Server-TLSv13-AES128-SHA256 @@ -0,0 +1,100 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 dc 01 00 00 d8 03 03 8f 2d ec dc ac |............-...| +00000010 28 76 2d d2 5e b8 34 2f 3f b9 96 46 31 8a 12 d5 |(v-.^.4/?..F1...| +00000020 6a 9f a0 bf 11 00 3e d1 4c ba 17 20 72 a7 88 94 |j.....>.L.. r...| +00000030 ad d2 b6 e8 86 d8 34 45 42 44 b7 36 50 9b 64 36 |......4EBD.6P.d6| +00000040 de 03 b0 e5 99 8b f9 5a 67 5b f6 72 00 04 13 01 |.......Zg[.r....| +00000050 00 ff 01 00 00 8b 00 00 00 0e 00 0c 00 00 09 31 |...............1| +00000060 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000070 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 00 18 |................| +00000080 00 16 00 00 00 17 00 00 00 0d 00 1e 00 1c 04 03 |................| +00000090 05 03 06 03 08 07 08 08 08 09 08 0a 08 0b 08 04 |................| +000000a0 08 05 08 06 04 01 05 01 06 01 00 2b 00 03 02 03 |...........+....| +000000b0 04 00 2d 00 02 01 01 00 33 00 26 00 24 00 1d 00 |..-.....3.&.$...| +000000c0 20 52 35 32 79 0e bf 01 91 5a b1 be 9b ff bf f4 | R52y....Z......| +000000d0 72 13 1a 3d a6 a8 15 9f ad c3 a9 b6 32 79 84 32 |r..=........2y.2| +000000e0 71 |q| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 00 00 00 00 00 |....z...v.......| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 72 a7 88 94 |........... r...| +00000030 ad d2 b6 e8 86 d8 34 45 42 44 b7 36 50 9b 64 36 |......4EBD.6P.d6| +00000040 de 03 b0 e5 99 8b f9 5a 67 5b f6 72 13 01 00 00 |.......Zg[.r....| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 2f |..+.....3.$... /| +00000060 e5 7d a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 |.}.G.bC.(.._.).0| +00000070 ff f6 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 14 |.........._X.;t.| +00000080 03 03 00 01 01 17 03 03 00 17 2a 27 a8 a8 aa f7 |..........*'....| +00000090 7f c4 74 12 f2 f5 b3 46 e3 fc 9f c6 8e 4d 81 4c |..t....F.....M.L| +000000a0 f2 17 03 03 02 6d 4c ad 3d 6f 2b c3 22 fc e0 3f |.....mL.=o+."..?| +000000b0 74 c2 f7 20 1a 37 ff 42 3e 5c c7 7e 0a 27 48 88 |t.. .7.B>\.~.'H.| +000000c0 23 77 d3 e9 96 d0 6c 44 67 e0 13 03 06 e3 f8 70 |#w....lDg......p| +000000d0 c0 e1 56 8f a3 18 58 8a d0 a0 f1 96 0a 4b 47 f8 |..V...X......KG.| +000000e0 a0 51 06 82 03 09 e8 82 e7 c1 91 5a fb 2e a4 a7 |.Q.........Z....| +000000f0 34 19 d8 c1 86 0d 56 e9 74 f1 28 7a 7e bf 50 30 |4.....V.t.(z~.P0| +00000100 e1 29 43 fa d9 67 6f d1 94 4c 7f 06 b9 b7 5d 6c |.)C..go..L....]l| +00000110 f1 a4 dc 48 53 de 7e d6 c2 8a 32 a3 78 94 2d 55 |...HS.~...2.x.-U| +00000120 76 0d 3c b8 93 76 98 70 36 c2 2e a2 b3 8c ec 32 |v.<..v.p6......2| +00000130 43 50 06 f8 76 28 19 3b a3 51 64 26 24 fa 97 43 |CP..v(.;.Qd&$..C| +00000140 65 12 aa 2f 55 c3 30 33 9a 88 dc 4c 86 e5 13 aa |e../U.03...L....| +00000150 4b 4d 85 e6 67 0c 87 61 26 cd 1b 7b 80 67 87 60 |KM..g..a&..{.g.`| +00000160 00 0d 7a eb 9a e4 d2 a6 72 b5 66 f4 5b 9c 2f 42 |..z.....r.f.[./B| +00000170 c1 4b d3 cf 9f e7 be bf a4 12 57 d4 15 83 ce 61 |.K........W....a| +00000180 c0 29 71 ed d5 c3 e3 68 a0 c7 02 ed 94 d7 1f b2 |.)q....h........| +00000190 11 c1 38 67 a6 42 d2 23 ae b8 16 ed 69 92 91 57 |..8g.B.#....i..W| +000001a0 ca b6 fd 93 8f 32 ab 2d 8b 74 f8 b0 bb 5a a0 16 |.....2.-.t...Z..| +000001b0 72 92 6e 9e 10 46 3a 7d 2f 55 de 0c d4 9d b6 d0 |r.n..F:}/U......| +000001c0 e1 f6 2d 10 de 97 c1 28 c8 d4 63 4a 5b f9 08 c7 |..-....(..cJ[...| +000001d0 8b 28 65 0b 07 e2 62 82 09 3e d2 dd 82 a6 72 79 |.(e...b..>....ry| +000001e0 1d 59 ef 58 87 5a b6 b1 38 20 3c 4c 55 c0 9d fb |.Y.X.Z..8 3.$oe7@..A_| +000003e0 43 3a dd 65 3d a7 b4 6c bf 21 f4 17 03 03 00 93 |C:.e=..l.!......| +000003f0 1a a6 3b b4 be dd c0 64 5f ae 2d 05 70 3b 5e fc |..;....d_.-.p;^.| +00000400 83 e0 ad 5b d0 b3 32 bc f9 98 b2 f5 9f 16 14 52 |...[..2........R| +00000410 37 2c 72 90 c1 be 97 49 a3 4d 10 97 0e d0 ec ff |7,r....I.M......| +00000420 98 50 87 90 ba f2 f0 81 08 14 ad f6 f9 3b d0 b8 |.P...........;..| +00000430 f8 c2 62 96 d1 4b 4f 5a 96 43 9f b6 96 6b 59 b8 |..b..KOZ.C...kY.| +00000440 f5 cc cf bc 79 1a a6 6e c6 7d 06 10 8f a0 21 39 |....y..n.}....!9| +00000450 67 5f 36 37 19 fa 0f 56 00 36 16 10 a2 80 9f 01 |g_67...V.6......| +00000460 0a 68 2d 50 a1 fc 67 c5 00 24 36 54 c2 5a 93 a4 |.h-P..g..$6T.Z..| +00000470 0a 6c cd aa 3f 22 bf ef f4 80 32 6a 14 e1 1e 6b |.l..?"....2j...k| +00000480 8a 38 40 |.8@| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 00 35 3c 0b 73 34 15 |..........5<.s4.| +00000010 e0 fc da 7f 3a 12 a0 50 95 09 0c ec 6a d5 7b 55 |....:..P....j.{U| +00000020 76 0f 7a 8e 25 e4 d2 b9 5f 5a 79 95 a5 a4 c6 9d |v.z.%..._Zy.....| +00000030 eb 0a ad 13 d1 97 a5 bd c4 d0 1e ce 59 59 04 16 |............YY..| +>>> Flow 4 (server to client) +00000000 17 03 03 00 1e 9a 92 bf 83 9f 0b 36 66 2f 8e d5 |...........6f/..| +00000010 69 74 a7 a2 20 bb b2 d5 ac e8 99 b1 e6 df 4d 03 |it.. .........M.| +00000020 3e 9e 9c 17 03 03 00 13 7e 0c 85 34 9e 48 48 4a |>.......~..4.HHJ| +00000030 ce fa 96 dd 7b 7c 11 38 20 8d 33 |....{|.8 .3| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv13-AES256-SHA384 b/libgo/go/crypto/tls/testdata/Server-TLSv13-AES256-SHA384 new file mode 100644 index 00000000000..60aa82df891 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Server-TLSv13-AES256-SHA384 @@ -0,0 +1,103 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 dc 01 00 00 d8 03 03 70 b7 07 12 16 |...........p....| +00000010 50 d7 b9 c9 5f 02 47 2d ff 93 a7 2f e8 51 dc a0 |P..._.G-.../.Q..| +00000020 8f 0d c8 80 38 c7 af 7e da bb ed 20 67 73 58 d7 |....8..~... gsX.| +00000030 11 8b c6 0d 72 86 e0 08 3e 2d d9 b9 16 9f 85 6e |....r...>-.....n| +00000040 3c 87 fd 87 c3 95 f6 4c 76 21 50 af 00 04 13 02 |<......Lv!P.....| +00000050 00 ff 01 00 00 8b 00 00 00 0e 00 0c 00 00 09 31 |...............1| +00000060 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000070 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 00 18 |................| +00000080 00 16 00 00 00 17 00 00 00 0d 00 1e 00 1c 04 03 |................| +00000090 05 03 06 03 08 07 08 08 08 09 08 0a 08 0b 08 04 |................| +000000a0 08 05 08 06 04 01 05 01 06 01 00 2b 00 03 02 03 |...........+....| +000000b0 04 00 2d 00 02 01 01 00 33 00 26 00 24 00 1d 00 |..-.....3.&.$...| +000000c0 20 f4 08 51 f6 69 b7 d6 a9 3e 18 a7 ee c0 30 f3 | ..Q.i...>....0.| +000000d0 13 63 52 40 30 7c 79 6c 24 03 c9 89 25 bd a4 5f |.cR@0|yl$...%.._| +000000e0 64 |d| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 00 00 00 00 00 |....z...v.......| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 67 73 58 d7 |........... gsX.| +00000030 11 8b c6 0d 72 86 e0 08 3e 2d d9 b9 16 9f 85 6e |....r...>-.....n| +00000040 3c 87 fd 87 c3 95 f6 4c 76 21 50 af 13 02 00 00 |<......Lv!P.....| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 2f |..+.....3.$... /| +00000060 e5 7d a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 |.}.G.bC.(.._.).0| +00000070 ff f6 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 14 |.........._X.;t.| +00000080 03 03 00 01 01 17 03 03 00 17 cc b9 e4 43 5e f6 |.............C^.| +00000090 9a 5a 62 14 02 39 fb 13 76 e8 10 db 26 1c 07 ec |.Zb..9..v...&...| +000000a0 06 17 03 03 02 6d 39 e9 a0 33 ee 39 36 54 62 f1 |.....m9..3.96Tb.| +000000b0 e9 1d 32 45 0f 5a ca 72 f7 7e 43 d8 89 97 00 3d |..2E.Z.r.~C....=| +000000c0 59 70 08 b4 d1 e1 84 24 7a b8 45 3c b8 32 93 b5 |Yp.....$z.E<.2..| +000000d0 51 a5 58 60 3f 60 52 aa c1 ff 85 fb fd 50 87 38 |Q.X`?`R......P.8| +000000e0 47 7a 88 c6 d1 e6 3c b3 16 14 5b cb 23 50 26 7a |Gz....<...[.#P&z| +000000f0 1d 28 d1 d2 29 5d b0 40 97 2f 3b 58 7c 8a 76 1f |.(..)].@./;X|.v.| +00000100 1c c1 d2 2b 63 9d 53 bc fb c2 42 cb 40 0d d0 7c |...+c.S...B.@..|| +00000110 73 6c dc 63 90 89 e3 66 67 2b a2 70 af e0 af fe |sl.c...fg+.p....| +00000120 0c c0 db 41 76 d0 16 37 2a 09 7a 79 31 03 c6 4a |...Av..7*.zy1..J| +00000130 f4 06 22 ac 96 b4 25 1f 54 11 24 c8 67 22 8f 2a |.."...%.T.$.g".*| +00000140 56 0c 24 fa 20 ed a8 37 66 f7 38 44 43 e2 e6 e3 |V.$. ..7f.8DC...| +00000150 96 b5 d5 dd a5 2c 23 e4 57 57 7d 7a 59 e2 4f 66 |.....,#.WW}zY.Of| +00000160 c4 29 d6 d1 32 a3 9c 4c dd 63 b2 a6 dc ff 6f 61 |.)..2..L.c....oa| +00000170 c2 db 88 80 23 c1 27 d4 be dd 4f b4 c9 b8 56 4c |....#.'...O...VL| +00000180 65 b6 f8 32 b2 60 7b af 5f 54 71 61 20 db 25 85 |e..2.`{._Tqa .%.| +00000190 34 b6 58 9b 71 01 dd 53 cd 13 65 2e 23 69 96 0e |4.X.q..S..e.#i..| +000001a0 89 94 75 09 64 60 76 d2 65 85 38 3d f1 0e cb 47 |..u.d`v.e.8=...G| +000001b0 c1 2c 52 f8 ce 7a a6 9f dd 7c 39 7e a7 f9 a6 1b |.,R..z...|9~....| +000001c0 c1 23 81 a6 7a b1 6c d4 3c 1c f3 71 ce 72 24 01 |.#..z.l.<..q.r$.| +000001d0 4a 8d e9 24 47 51 73 67 dc 7a 9f 0b 63 7d 29 e1 |J..$GQsg.z..c}).| +000001e0 3e 5e ac 72 d7 c8 d9 c2 13 de 92 dd 04 cb 09 21 |>^.r...........!| +000001f0 ad 41 69 27 77 48 eb 87 cb 3b 23 ba 06 a3 68 96 |.Ai'wH...;#...h.| +00000200 ad 24 35 f6 a6 03 87 a7 4d 9f d4 bf e5 8b 9f 56 |.$5.....M......V| +00000210 54 dd 0e 08 da 29 ff eb 9b e1 0a a5 25 b1 85 be |T....)......%...| +00000220 f8 ae 63 f4 49 64 cc 0a 41 0e 26 8a 8e bc 6f c9 |..c.Id..A.&...o.| +00000230 f5 41 55 80 0d bd 70 ad 85 b0 d4 8d 33 ac b6 40 |.AU...p.....3..@| +00000240 3e 76 fc fb 8f d2 7d 06 14 d4 45 24 6e 36 46 1c |>v....}...E$n6F.| +00000250 06 d3 f7 f3 4c 3a a5 83 4f 75 72 77 b4 5e 37 49 |....L:..Ourw.^7I| +00000260 41 f1 9f e6 d1 46 87 56 c8 64 28 fd 38 f0 0f 9c |A....F.V.d(.8...| +00000270 d0 39 ff 4b 46 56 73 0d 12 7d bf 63 b4 b8 0d 33 |.9.KFVs..}.c...3| +00000280 6b 4a 2b f8 39 67 f1 ec 2d a6 0b 5c 91 2d d8 3e |kJ+.9g..-..\.-.>| +00000290 91 81 1a 37 29 c7 14 d2 be db 31 61 dc 5d b1 e4 |...7).....1a.]..| +000002a0 64 af 14 9c 93 85 e7 5b 0e 42 63 c7 5e b5 cc 51 |d......[.Bc.^..Q| +000002b0 ca 83 ca fa 52 bd 44 a1 1c 76 20 bc 3d 9f 82 79 |....R.D..v .=..y| +000002c0 20 5c 01 14 e3 07 02 4c f6 87 f7 46 b8 de 47 23 | \.....L...F..G#| +000002d0 5d 5c b3 8f cd 96 49 51 32 3f d2 5d 92 32 19 b5 |]\....IQ2?.].2..| +000002e0 10 33 46 37 f0 b5 82 23 a5 91 1f 60 fb 21 2c 08 |.3F7...#...`.!,.| +000002f0 c3 6e 17 72 0b 5d c9 7b cc 77 97 6f 20 d9 a6 fa |.n.r.].{.w.o ...| +00000300 cc 4a bb c6 3b 0e b1 66 ae 57 f5 1b 16 46 36 b7 |.J..;..f.W...F6.| +00000310 a5 94 ae 17 03 03 00 99 d7 86 a0 5f c0 d2 33 3e |..........._..3>| +00000320 ce ce ea db cb a1 a5 11 b7 cc a1 48 b6 86 f5 11 |...........H....| +00000330 d6 32 8c f9 e8 bb e3 3e ea 6f 1a df 64 cd c8 7d |.2.....>.o..d..}| +00000340 e9 cb e4 19 fe cd 75 74 03 4a fe 91 1d 87 28 65 |......ut.J....(e| +00000350 25 79 3a 19 13 ba 67 16 aa 7e 8e c0 e6 53 4f bb |%y:...g..~...SO.| +00000360 98 ed cc 59 db 5e 73 23 d4 a9 a7 2a 6d 01 73 4a |...Y.^s#...*m.sJ| +00000370 e6 65 2e c0 34 49 c1 d8 70 2e 70 1b 10 97 74 23 |.e..4I..p.p...t#| +00000380 fe 6b 5d cd fa 71 c8 43 c3 5b 42 5c 7b e0 9e 3f |.k]..q.C.[B\{..?| +00000390 a8 3d a9 d1 97 17 87 80 af 7c 5d 8b 70 ba 87 06 |.=.......|].p...| +000003a0 67 dd 29 df f3 ca 9a f4 c8 93 e8 f8 ac c0 df 8e |g.).............| +000003b0 c5 17 03 03 00 45 40 a4 26 66 29 18 b8 d6 a7 87 |.....E@.&f).....| +000003c0 91 5f 6d 79 13 f8 7a 47 cf ac 93 7c 11 cb 4a b2 |._my..zG...|..J.| +000003d0 24 a6 40 fb d4 ed 71 ec 19 53 ba ae e0 bb e6 cf |$.@...q..S......| +000003e0 d6 8a a6 3c 6a 4e a3 6f 6c d7 2d e1 8a a4 6c da |.....q=....| +00000410 dc 2f 4a 62 c2 9f e2 e5 16 51 ff 35 a7 70 df 12 |./Jb.....Q.5.p..| +00000420 23 d6 f7 6c 96 91 7f 0f 6d d4 45 5f c6 8c c5 93 |#..l....m.E_....| +00000430 b1 b7 46 ef f0 f4 a3 68 35 ff 09 38 8d 6d c6 84 |..F....h5..8.m..| +00000440 d3 1c 4d 48 4e fc 4a c0 46 06 b1 a5 1c 74 a0 44 |..MHN.J.F....t.D| +00000450 69 68 20 33 df 70 60 69 57 c7 85 bd 3e ed 55 d0 |ih 3.p`iW...>.U.| +00000460 56 84 8f 19 03 5a 54 9a d5 3e 5d 37 98 40 4c f0 |V....ZT..>]7.@L.| +00000470 5e f1 26 e5 97 01 fc 0f 2a 09 e9 7a 51 69 c0 8e |^.&.....*..zQi..| +00000480 d4 25 80 f4 ca 91 f3 a7 5c 0c 96 ba ec a8 b5 ee |.%......\.......| +00000490 ab ec 05 cb 99 30 78 48 1b 78 bf 3d b9 f4 e8 33 |.....0xH.x.=...3| +000004a0 4d 45 d1 |ME.| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 00 45 54 0e c1 aa 95 |..........ET....| +00000010 fd c5 d2 8b a0 ae 40 a1 9a b8 87 39 17 53 f7 10 |......@....9.S..| +00000020 62 6f 55 18 42 cf 75 cb 05 de 32 28 c4 a0 f1 17 |boU.B.u...2(....| +00000030 f1 55 ae 2c 97 9e dd d2 d0 a7 6b c6 51 51 c6 0c |.U.,......k.QQ..| +00000040 81 3f 04 db 94 e6 68 f0 a1 80 10 39 06 99 25 e2 |.?....h....9..%.| +>>> Flow 4 (server to client) +00000000 17 03 03 00 1e e4 4f d5 b0 e7 a0 e2 13 69 75 7c |......O......iu|| +00000010 b1 84 93 be 99 ea 27 20 dd 08 89 6c e2 5a c6 bc |......' ...l.Z..| +00000020 b8 41 3d 17 03 03 00 13 cf 64 ad ad d9 84 87 36 |.A=......d.....6| +00000030 b9 ea b8 76 97 93 c1 03 44 c5 de |...v....D..| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv13-ALPN b/libgo/go/crypto/tls/testdata/Server-TLSv13-ALPN new file mode 100644 index 00000000000..4ac9f1d7d4e --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Server-TLSv13-ALPN @@ -0,0 +1,104 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 f8 01 00 00 f4 03 03 65 16 78 26 cc |...........e.x&.| +00000010 27 bc 06 a0 4c f5 a3 e3 cd c2 f0 42 8c 61 0e e9 |'...L......B.a..| +00000020 8b 2b 52 ca a3 07 d6 58 96 4f f1 20 c3 7f e3 22 |.+R....X.O. ..."| +00000030 2c 27 94 91 ab cc e5 56 b1 31 fb eb ed b4 84 3e |,'.....V.1.....>| +00000040 ae 93 6e 6e a9 5c d2 47 6e 5b 0c 43 00 08 13 02 |..nn.\.Gn[.C....| +00000050 13 03 13 01 00 ff 01 00 00 a3 00 00 00 0e 00 0c |................| +00000060 00 00 09 31 32 37 2e 30 2e 30 2e 31 00 0b 00 04 |...127.0.0.1....| +00000070 03 00 01 02 00 0a 00 0c 00 0a 00 1d 00 17 00 1e |................| +00000080 00 19 00 18 00 23 00 00 00 10 00 10 00 0e 06 70 |.....#.........p| +00000090 72 6f 74 6f 32 06 70 72 6f 74 6f 31 00 16 00 00 |roto2.proto1....| +000000a0 00 17 00 00 00 0d 00 1e 00 1c 04 03 05 03 06 03 |................| +000000b0 08 07 08 08 08 09 08 0a 08 0b 08 04 08 05 08 06 |................| +000000c0 04 01 05 01 06 01 00 2b 00 03 02 03 04 00 2d 00 |.......+......-.| +000000d0 02 01 01 00 33 00 26 00 24 00 1d 00 20 76 1d a9 |....3.&.$... v..| +000000e0 43 43 a4 98 96 39 59 80 b0 7e 13 29 2a ea 53 e7 |CC...9Y..~.)*.S.| +000000f0 34 73 7a 10 0c f5 b0 92 b1 ab e2 26 17 |4sz........&.| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 00 00 00 00 00 |....z...v.......| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 c3 7f e3 22 |........... ..."| +00000030 2c 27 94 91 ab cc e5 56 b1 31 fb eb ed b4 84 3e |,'.....V.1.....>| +00000040 ae 93 6e 6e a9 5c d2 47 6e 5b 0c 43 13 02 00 00 |..nn.\.Gn[.C....| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 2f |..+.....3.$... /| +00000060 e5 7d a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 |.}.G.bC.(.._.).0| +00000070 ff f6 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 14 |.........._X.;t.| +00000080 03 03 00 01 01 17 03 03 00 24 1a dd ed 59 79 84 |.........$...Yy.| +00000090 d6 2e 17 81 75 e0 ee b3 98 8c 04 a3 ea 7c 46 f0 |....u........|F.| +000000a0 76 58 78 5a 37 99 a6 32 ad c6 5a 5a 3a ce 17 03 |vXxZ7..2..ZZ:...| +000000b0 03 02 6d 31 3b 00 34 ef 22 53 8a 31 f5 88 fb 3f |..m1;.4."S.1...?| +000000c0 e4 72 a8 20 65 ef be c6 78 84 4e 93 6a 8a fa 01 |.r. e...x.N.j...| +000000d0 10 b0 dd 0e 7d 8f 07 b8 da 29 4b 0a 5b 32 de cf |....}....)K.[2..| +000000e0 31 66 04 9c c6 d8 ab f0 07 f0 aa c3 b6 3e bf d4 |1f...........>..| +000000f0 0e 53 5d a4 4f aa 19 cf f4 3d 60 5b 19 ec e3 e2 |.S].O....=`[....| +00000100 71 1b 54 20 48 41 68 32 f5 28 06 e2 b7 29 89 c3 |q.T HAh2.(...)..| +00000110 d5 eb 07 f3 49 fb 0b f5 81 0a f2 65 70 24 a9 bc |....I......ep$..| +00000120 6b e7 70 58 7c f2 0a 91 3e f4 26 ea 1a 22 15 24 |k.pX|...>.&..".$| +00000130 5a 28 43 89 ac 1c 9b 39 1a 93 ec 32 5e ba cb f4 |Z(C....9...2^...| +00000140 57 a1 ca 03 8e 2e 0b 96 e7 7f e5 c5 30 22 ec fd |W...........0"..| +00000150 fe 6d 5f 01 e9 7a 5e b3 68 67 ee e9 23 d5 72 46 |.m_..z^.hg..#.rF| +00000160 77 05 b7 27 26 78 fe f9 cc c8 c2 fe a8 4e 93 04 |w..'&x.......N..| +00000170 56 bc 64 f1 55 ff 92 8d cb 81 46 cb 2d db 9b 41 |V.d.U.....F.-..A| +00000180 59 76 0c b5 65 7a e1 09 2f b6 3b d4 92 87 7c a6 |Yv..ez../.;...|.| +00000190 06 d7 37 aa db bc 07 12 a4 2e 38 be 97 83 80 80 |..7.......8.....| +000001a0 86 05 3a 4b 89 25 7f ef 5e 54 42 4a 89 99 f2 95 |..:K.%..^TBJ....| +000001b0 70 92 fb ac 2f ae b4 1f a0 5c 8c bf 45 2d 54 91 |p.../....\..E-T.| +000001c0 01 88 d5 9b a3 da af 67 1c ce 2e 9c 05 4c 68 d8 |.......g.....Lh.| +000001d0 b5 ee 98 06 a4 18 c8 c0 2d 7c bf 6e e2 eb 0d aa |........-|.n....| +000001e0 5b c6 f8 27 ad 3a 1a cf ac 35 f4 55 41 3c e0 8c |[..'.:...5.UA<..| +000001f0 3e 26 56 95 33 c4 f1 05 5a e7 9d 6e 33 90 d1 37 |>&V.3...Z..n3..7| +00000200 03 77 1f 76 1a 35 43 c1 a4 8c 5a 68 f5 bc 6c 7a |.w.v.5C...Zh..lz| +00000210 43 27 37 cd d9 55 76 69 bd 78 47 4e 2e 25 96 e6 |C'7..Uvi.xGN.%..| +00000220 8f 46 a3 70 ff b8 55 f2 66 46 2c 59 ad b9 b7 9a |.F.p..U.fF,Y....| +00000230 a1 dc a4 8b 2b fa 14 17 dd bf 46 c6 9a ef 50 54 |....+.....F...PT| +00000240 6e b8 d3 d7 13 d4 74 dd a5 ef 16 5f 2a fa ea 9b |n.....t...._*...| +00000250 59 7c 41 f8 6d 00 b5 01 9d c8 35 34 1e 1c 3f 64 |Y|A.m.....54..?d| +00000260 6a da 1e c4 64 4d e5 2e c7 28 f8 14 70 e6 72 4b |j...dM...(..p.rK| +00000270 ab 8a 22 5e 2b 5c aa b3 02 72 80 0c 80 11 cd 18 |.."^+\...r......| +00000280 b8 e1 8c 54 54 72 fd 68 71 66 ef bc 3e 03 ca a4 |...TTr.hqf..>...| +00000290 ae f4 ad 7b 29 08 ff 49 07 09 bc a1 cd e3 14 69 |...{)..I.......i| +000002a0 47 0e b0 c0 a8 89 3a 7b 71 e5 ba 32 36 e8 b5 0a |G.....:{q..26...| +000002b0 9e f6 9f 6f 12 89 f5 36 5c 96 28 e1 2d 6b b3 06 |...o...6\.(.-k..| +000002c0 d6 68 d3 99 f4 3d 27 b2 61 df 75 29 a0 24 8a ba |.h...='.a.u).$..| +000002d0 48 c4 5c 8c 36 21 3a 3e bf 92 4f 73 cc bd a1 b1 |H.\.6!:>..Os....| +000002e0 e7 00 c6 05 94 1e 8e 73 d3 52 aa 4d 02 40 3b 50 |.......s.R.M.@;P| +000002f0 5f f0 37 b6 61 43 9f 39 63 64 ad 37 12 97 2a 0c |_.7.aC.9cd.7..*.| +00000300 5e d9 20 e0 78 da f3 80 d8 29 ea b3 c5 52 55 cc |^. .x....)...RU.| +00000310 3d e0 91 b7 f8 f9 b0 29 5a b3 e9 65 04 31 5c 6c |=......)Z..e.1\l| +00000320 17 03 03 00 99 7d d6 2e 45 d8 e2 5b f8 c1 21 86 |.....}..E..[..!.| +00000330 8a 31 78 88 5d 61 ca 8c e5 23 07 d7 85 da cb 04 |.1x.]a...#......| +00000340 be c3 24 2b 27 42 bb a1 1e 4f 8b bb a2 5d 3b 1e |..$+'B...O...];.| +00000350 8a 64 f0 2a 2f 79 51 cc 1b 34 99 b6 33 75 31 c9 |.d.*/yQ..4..3u1.| +00000360 2e ea 70 ef 97 c4 bb 4c ec aa cf 11 6c 88 96 c4 |..p....L....l...| +00000370 9b b9 df b9 ef 10 bb 36 65 1f 8d 7e 22 e8 67 80 |.......6e..~".g.| +00000380 80 6e 2b 34 94 a4 5f b1 5d 88 11 2e bf 22 f9 fe |.n+4.._.]...."..| +00000390 be 76 e8 86 da 40 76 8c 9c 40 b6 b4 50 41 92 f5 |.v...@v..@..PA..| +000003a0 ce 8c bd 13 ea f0 6f 56 c2 1c c6 ed 08 33 71 36 |......oV.....3q6| +000003b0 a4 16 b6 ca bf ba 0e 65 b0 a2 2b 35 39 c7 17 03 |.......e..+59...| +000003c0 03 00 45 3b 7a 67 26 15 b4 9b 0f ba 61 5d d0 4c |..E;zg&.....a].L| +000003d0 60 27 29 03 fb da 90 ea 0c 64 22 24 ac 60 74 02 |`')......d"$.`t.| +000003e0 0e 99 e0 e1 55 35 da c2 75 19 82 0c fa f8 f0 09 |....U5..u.......| +000003f0 35 1e ca de d1 e1 17 8e d2 f7 fb f9 94 d1 03 fb |5...............| +00000400 b5 8a 32 f6 8f 02 5f fa 17 03 03 00 a3 21 96 04 |..2..._......!..| +00000410 46 58 eb 83 db 06 a7 ba f2 9e 5c 8a 35 0d 87 78 |FX........\.5..x| +00000420 29 17 4f 7a 95 21 1f b4 f3 fa bb de 93 b7 e7 1c |).Oz.!..........| +00000430 24 40 06 6b 9f b5 12 49 36 39 01 b9 17 cb 5c 99 |$@.k...I69....\.| +00000440 93 71 dc 8f c5 54 c0 dd ff 36 92 24 cd b3 ac 40 |.q...T...6.$...@| +00000450 c0 57 76 c3 2a a0 d3 07 af 00 4b df c5 f9 34 77 |.Wv.*.....K...4w| +00000460 ed cc 14 e1 50 bf 41 1e b5 39 5d 92 a8 e4 f5 a6 |....P.A..9].....| +00000470 b2 12 08 56 b6 43 cf dc eb a9 0e 9e 0e 8a 97 63 |...V.C.........c| +00000480 f8 92 a8 1b 74 f3 65 60 6a f3 f0 e7 54 fd d3 08 |....t.e`j...T...| +00000490 20 ce b4 16 ab c9 e1 7a 49 9c bf d6 3a a7 2b 5c | ......zI...:.+\| +000004a0 1b 1c a7 89 f3 6a 6d 3d 0a 07 16 b4 c1 c2 4b 2e |.....jm=......K.| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 00 45 90 6e 35 6d 4e |..........E.n5mN| +00000010 3b 8a 39 88 85 99 ac 05 fe 2c e3 a8 31 46 4e c2 |;.9......,..1FN.| +00000020 ea fe a2 ff 41 5b 64 77 bc 0c 6d 72 f7 c8 f3 07 |....A[dw..mr....| +00000030 ce 29 c2 6e 7c b5 88 13 35 f8 c0 90 98 ab 0f f9 |.).n|...5.......| +00000040 e2 8e 57 7e 23 7b 57 17 b6 13 11 9e 52 67 44 26 |..W~#{W.....RgD&| +>>> Flow 4 (server to client) +00000000 17 03 03 00 1e 98 55 d6 42 d5 d4 01 c9 be 70 27 |......U.B.....p'| +00000010 9e 5a d5 7d fc 41 1e ec fe fd d5 0f 01 16 56 82 |.Z.}.A........V.| +00000020 13 13 c7 17 03 03 00 13 bb 71 20 65 f8 af 42 ea |.........q e..B.| +00000030 42 73 b8 24 d8 dc 79 7c 71 32 35 |Bs.$..y|q25| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv13-ALPN-NoMatch b/libgo/go/crypto/tls/testdata/Server-TLSv13-ALPN-NoMatch new file mode 100644 index 00000000000..84c38acbeb0 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Server-TLSv13-ALPN-NoMatch @@ -0,0 +1,104 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 f8 01 00 00 f4 03 03 b6 62 6e 7c 66 |............bn|f| +00000010 e0 73 6f bc ce d7 e3 5c 3a 39 c5 c9 5e f3 8f 76 |.so....\:9..^..v| +00000020 f0 ed 0e 30 fd 80 a0 79 74 fd d4 20 6b 6e f8 9d |...0...yt.. kn..| +00000030 30 1b ee fa 7c 5f 64 e0 da 81 26 7a 85 d2 f9 79 |0...|_d...&z...y| +00000040 e7 09 71 f8 2a 4c 41 74 02 a9 0c d2 00 08 13 02 |..q.*LAt........| +00000050 13 03 13 01 00 ff 01 00 00 a3 00 00 00 0e 00 0c |................| +00000060 00 00 09 31 32 37 2e 30 2e 30 2e 31 00 0b 00 04 |...127.0.0.1....| +00000070 03 00 01 02 00 0a 00 0c 00 0a 00 1d 00 17 00 1e |................| +00000080 00 19 00 18 00 23 00 00 00 10 00 10 00 0e 06 70 |.....#.........p| +00000090 72 6f 74 6f 32 06 70 72 6f 74 6f 31 00 16 00 00 |roto2.proto1....| +000000a0 00 17 00 00 00 0d 00 1e 00 1c 04 03 05 03 06 03 |................| +000000b0 08 07 08 08 08 09 08 0a 08 0b 08 04 08 05 08 06 |................| +000000c0 04 01 05 01 06 01 00 2b 00 03 02 03 04 00 2d 00 |.......+......-.| +000000d0 02 01 01 00 33 00 26 00 24 00 1d 00 20 8d 7d e2 |....3.&.$... .}.| +000000e0 55 da a7 1b 29 fc a4 d3 b0 62 51 43 d9 d6 cd 79 |U...)....bQC...y| +000000f0 a4 f9 3c f2 4e 03 87 1f 38 29 35 c3 36 |..<.N...8)5.6| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 00 00 00 00 00 |....z...v.......| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 6b 6e f8 9d |........... kn..| +00000030 30 1b ee fa 7c 5f 64 e0 da 81 26 7a 85 d2 f9 79 |0...|_d...&z...y| +00000040 e7 09 71 f8 2a 4c 41 74 02 a9 0c d2 13 02 00 00 |..q.*LAt........| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 2f |..+.....3.$... /| +00000060 e5 7d a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 |.}.G.bC.(.._.).0| +00000070 ff f6 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 14 |.........._X.;t.| +00000080 03 03 00 01 01 17 03 03 00 17 4c a1 99 6c 86 b8 |..........L..l..| +00000090 1a 1a eb ec 89 37 bf 5a ae 87 3c 81 ce cf b2 49 |.....7.Z..<....I| +000000a0 66 17 03 03 02 6d 40 06 a4 17 6a 48 78 76 a5 63 |f....m@...jHxv.c| +000000b0 82 c4 5b e9 6e dc 54 de 95 12 15 a7 3d 83 94 4d |..[.n.T.....=..M| +000000c0 57 26 82 ea f3 d5 e1 4a d7 6e dc 27 f6 02 1c 16 |W&.....J.n.'....| +000000d0 21 68 c5 32 ff 02 e9 b5 44 2c f4 e9 4d b2 9d 3d |!h.2....D,..M..=| +000000e0 34 e1 6a db 73 61 eb 5c 00 e9 e8 00 bc 82 2a 17 |4.j.sa.\......*.| +000000f0 25 f7 c4 09 2f 6c 3e c6 09 5a 33 61 49 df 4d 47 |%.../l>..Z3aI.MG| +00000100 95 16 c5 6e a4 b3 94 44 4c 8b 5d d6 2c c9 26 a1 |...n...DL.].,.&.| +00000110 01 e8 cc 20 9c 19 d3 3e eb d5 7c 97 4e 1e af 7b |... ...>..|.N..{| +00000120 68 0e 7b eb bb 91 81 60 a2 c8 37 96 84 f2 cd fe |h.{....`..7.....| +00000130 7f 22 7f 7f 22 6a c7 23 68 79 48 ae 35 47 27 4b |.".."j.#hyH.5G'K| +00000140 c0 ce e7 9c 7f 23 fd 44 e1 a5 da 9f 61 94 46 1f |.....#.D....a.F.| +00000150 6c ea b9 50 53 c2 35 70 d4 77 d7 2d d5 54 fb d7 |l..PS.5p.w.-.T..| +00000160 90 4b f9 bb 98 67 cc 5b 97 56 ef ff 5d c9 08 9c |.K...g.[.V..]...| +00000170 26 cd cf ba 51 6f a5 f4 20 34 83 85 ef 71 98 1b |&...Qo.. 4...q..| +00000180 dd 41 f9 51 f3 59 77 d7 b5 f5 98 40 fd 78 ef b6 |.A.Q.Yw....@.x..| +00000190 47 8c 27 e3 c8 ae 9d c3 47 92 dc 97 23 82 2f 80 |G.'.....G...#./.| +000001a0 2f 0f 17 17 17 f1 49 ec c3 1c 73 02 38 b3 a6 6d |/.....I...s.8..m| +000001b0 89 5f 55 30 ea 10 5d fe a7 6e 88 fb cc fd 9a 01 |._U0..]..n......| +000001c0 10 f8 4e 6a 7f ba 62 ab 15 85 7a 8d fc de 92 f7 |..Nj..b...z.....| +000001d0 91 9a d8 dc f3 de 3e 36 19 45 44 8c d7 03 67 c8 |......>6.ED...g.| +000001e0 14 24 09 33 1b f3 2f 2d a6 a5 9a 6c e2 04 da 4b |.$.3../-...l...K| +000001f0 18 13 57 12 83 86 46 8f af 35 f4 0a 1b 09 1c 25 |..W...F..5.....%| +00000200 bb 1e 22 fb 71 48 3f 34 47 d4 52 ec 3c 81 dd 5b |..".qH?4G.R.<..[| +00000210 0d a0 b4 74 a7 60 5f 60 14 ee d3 08 54 92 45 42 |...t.`_`....T.EB| +00000220 52 82 8d 54 84 ee c0 1d a7 a9 b4 a0 13 82 75 cd |R..T..........u.| +00000230 f6 a7 bc aa 0a e9 0a c5 36 ea 6f c1 8b 56 22 81 |........6.o..V".| +00000240 0a 8e 81 3d bf 34 f4 cc 80 02 d2 01 b5 2c b8 6b |...=.4.......,.k| +00000250 4b e8 06 06 cf e1 69 50 59 ea b2 a5 b0 06 96 02 |K.....iPY.......| +00000260 0e 45 8c 8c 46 ae 24 a0 80 92 75 46 7b cd 9e de |.E..F.$...uF{...| +00000270 a2 a0 d5 f4 68 ef 34 82 37 08 64 62 e8 eb 41 a4 |....h.4.7.db..A.| +00000280 32 a8 d4 c3 ee 16 67 2c 47 08 ef 23 c7 27 4a 21 |2.....g,G..#.'J!| +00000290 5c 66 36 93 6c 8c 8c fd 04 9a d9 84 e0 be 45 50 |\f6.l.........EP| +000002a0 0c 42 a2 d3 ba 5a 92 14 86 75 d2 33 6f 8b 69 a3 |.B...Z...u.3o.i.| +000002b0 b2 da 7e 19 e0 a6 0d 8e cb 21 bf f6 fa 5c 41 de |..~......!...\A.| +000002c0 d8 56 f7 d0 53 66 54 d2 5c e7 b5 20 af 0d 01 5a |.V..SfT.\.. ...Z| +000002d0 09 d0 ed 7f f1 1d d7 32 55 a8 c2 5a ba d8 e1 46 |.......2U..Z...F| +000002e0 fb 32 39 8b 8c 94 73 44 85 64 d6 c7 9f 6a d5 4e |.29...sD.d...j.N| +000002f0 fc 16 a2 10 cb 06 43 10 da a5 b2 71 e7 04 a6 3f |......C....q...?| +00000300 83 79 2c cb 2e 40 ab c8 53 18 11 95 3a f5 b9 b7 |.y,..@..S...:...| +00000310 df 99 d7 17 03 03 00 99 c0 29 f3 15 df b1 dc 36 |.........).....6| +00000320 a9 78 21 ed ba 5a 85 11 51 23 3f e9 b4 b3 bb b3 |.x!..Z..Q#?.....| +00000330 27 92 8e 9c a0 f8 b3 38 35 ef 9f bf 2b 31 82 cd |'......85...+1..| +00000340 de 3a 0c 0c b1 09 65 77 00 4c af 8c fe ff 2c 75 |.:....ew.L....,u| +00000350 62 48 13 96 63 5c 73 00 13 1f ef 27 f5 b2 4c fe |bH..c\s....'..L.| +00000360 8e 2a ff ab 94 68 5e 7c 02 19 d5 f3 68 07 b8 a1 |.*...h^|....h...| +00000370 2a 48 fc 4e ad b9 1c 95 13 d9 19 9d 47 7f 07 4d |*H.N........G..M| +00000380 b8 75 79 e7 da 6f 46 3e eb 27 c4 6f da ab bb fd |.uy..oF>.'.o....| +00000390 0a 04 08 15 c4 45 c4 1a 09 db 48 ca 3d 8e 63 af |.....E....H.=.c.| +000003a0 d8 0d 6b a2 04 22 eb 6d ed bf b6 45 d2 c8 b9 ee |..k..".m...E....| +000003b0 02 17 03 03 00 45 5c ef 9a 1c 12 95 25 da 79 21 |.....E\.....%.y!| +000003c0 6c 74 a2 64 cf bf aa cd 53 a4 43 48 d7 f3 b2 35 |lt.d....S.CH...5| +000003d0 da f2 0e d4 1c 14 23 63 8f 7a e5 5a 98 46 71 ad |......#c.z.Z.Fq.| +000003e0 19 a2 8f 22 b1 c5 93 89 0b 7f cd 38 09 9a ea f1 |...".......8....| +000003f0 51 6b 46 0f 8b 00 8d c2 1a 97 de 17 03 03 00 a3 |QkF.............| +00000400 32 88 68 5e f9 90 07 5d 4d 04 3d 1d 26 ac a2 1b |2.h^...]M.=.&...| +00000410 54 d0 37 7c 9f e7 8f ee c5 a6 bc b6 a9 78 08 40 |T.7|.........x.@| +00000420 f3 07 2f f5 b4 1f 08 c6 af 2d 4f 2e 87 4e 5f 95 |../......-O..N_.| +00000430 c9 b7 42 3a b5 ef ff 43 41 05 7c 7d 64 3f 56 ec |..B:...CA.|}d?V.| +00000440 ee b6 04 61 0a 56 79 77 5f 1c be e2 24 a2 cb 81 |...a.Vyw_...$...| +00000450 96 6f 95 6e a7 5a 2c 9e a0 e6 30 e5 f7 02 ff 10 |.o.n.Z,...0.....| +00000460 33 28 6e d7 ec 34 98 bf 26 2e 56 1d 99 e9 50 94 |3(n..4..&.V...P.| +00000470 71 be 0e 05 d3 86 95 db b9 4f 42 80 8a 12 2e ff |q........OB.....| +00000480 b6 be 81 f2 6f 4c 6a 00 a0 b8 53 c7 d7 fa 94 c6 |....oLj...S.....| +00000490 b2 b5 80 4b 3e e9 88 42 36 52 23 ca e4 48 b6 03 |...K>..B6R#..H..| +000004a0 13 7d 69 |.}i| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 00 45 1d 07 22 a7 34 |..........E..".4| +00000010 0d a7 a0 e5 8c ed 58 d4 5c 39 d2 96 43 73 eb 8c |......X.\9..Cs..| +00000020 5f c1 0c 90 67 6f ae b1 ae ee 6c dd cd 47 31 83 |_...go....l..G1.| +00000030 be b1 f2 50 ec 31 54 ba 21 82 c4 bd aa 51 0a 7a |...P.1T.!....Q.z| +00000040 0d 25 18 68 00 18 8b 51 c3 ca ae b1 fa 20 e0 0b |.%.h...Q..... ..| +>>> Flow 4 (server to client) +00000000 17 03 03 00 1e 1a 08 af cf 27 80 23 d8 94 0a fe |.........'.#....| +00000010 44 1c 78 f2 76 ac 9b 90 db 5c b6 8d c0 73 36 62 |D.x.v....\...s6b| +00000020 82 5d 8a 17 03 03 00 13 1a 2b 70 c9 14 dc c8 df |.].......+p.....| +00000030 e2 01 4e 69 e8 d7 13 0c 94 96 75 |..Ni......u| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv13-CHACHA20-SHA256 b/libgo/go/crypto/tls/testdata/Server-TLSv13-CHACHA20-SHA256 new file mode 100644 index 00000000000..760c5970035 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Server-TLSv13-CHACHA20-SHA256 @@ -0,0 +1,100 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 dc 01 00 00 d8 03 03 7f d6 02 2f 2d |............../-| +00000010 ed b1 3c f2 c2 48 5e d5 f4 57 c9 8c ba 81 36 52 |..<..H^..W....6R| +00000020 85 3e 79 de 79 cc 36 6a f9 88 89 20 db e1 89 a5 |.>y.y.6j... ....| +00000030 26 4c 2a 2d 0f 33 e2 3f 57 05 cc 74 cd 4c 96 be |&L*-.3.?W..t.L..| +00000040 91 94 ef 54 1c 1f 01 ef d4 36 75 2f 00 04 13 03 |...T.....6u/....| +00000050 00 ff 01 00 00 8b 00 00 00 0e 00 0c 00 00 09 31 |...............1| +00000060 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000070 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 00 18 |................| +00000080 00 16 00 00 00 17 00 00 00 0d 00 1e 00 1c 04 03 |................| +00000090 05 03 06 03 08 07 08 08 08 09 08 0a 08 0b 08 04 |................| +000000a0 08 05 08 06 04 01 05 01 06 01 00 2b 00 03 02 03 |...........+....| +000000b0 04 00 2d 00 02 01 01 00 33 00 26 00 24 00 1d 00 |..-.....3.&.$...| +000000c0 20 30 20 a8 d0 3d ea df 38 aa 65 6f dd c8 25 13 | 0 ..=..8.eo..%.| +000000d0 03 c4 a2 24 d4 a8 0d 1a a6 65 32 75 83 ef 71 70 |...$.....e2u..qp| +000000e0 30 |0| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 00 00 00 00 00 |....z...v.......| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 db e1 89 a5 |........... ....| +00000030 26 4c 2a 2d 0f 33 e2 3f 57 05 cc 74 cd 4c 96 be |&L*-.3.?W..t.L..| +00000040 91 94 ef 54 1c 1f 01 ef d4 36 75 2f 13 03 00 00 |...T.....6u/....| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 2f |..+.....3.$... /| +00000060 e5 7d a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 |.}.G.bC.(.._.).0| +00000070 ff f6 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 14 |.........._X.;t.| +00000080 03 03 00 01 01 17 03 03 00 17 f4 9a 6e ea 99 81 |............n...| +00000090 59 33 26 a6 6a 40 1d a9 59 67 31 35 09 b0 ed 15 |Y3&.j@..Yg15....| +000000a0 83 17 03 03 02 6d 56 59 69 c8 6d 45 c6 2f 58 3d |.....mVYi.mE./X=| +000000b0 db 87 dd 56 0f 2d d9 21 1b 97 94 77 f2 72 28 0d |...V.-.!...w.r(.| +000000c0 48 04 79 83 7e 2e a1 c9 30 56 d7 9c c8 0a 37 65 |H.y.~...0V....7e| +000000d0 b6 6b 31 ae 9a 5f ff 13 15 94 99 7c 92 e1 32 80 |.k1.._.....|..2.| +000000e0 28 3c ab b1 cc fe ba 92 3c 03 bb fd b8 55 f5 f2 |(<......<....U..| +000000f0 ba be 28 90 c5 7e 07 48 d5 45 b6 84 80 02 2d cd |..(..~.H.E....-.| +00000100 14 27 81 b6 4e b4 7f 5f 78 a3 26 c2 0c af 12 d6 |.'..N.._x.&.....| +00000110 e9 14 22 c8 ee 2e 5e fc c3 ca 8f 01 9b 37 6a b0 |.."...^......7j.| +00000120 f8 53 b2 8e 31 d7 1f 34 f6 35 ed 81 e0 f7 6f e1 |.S..1..4.5....o.| +00000130 90 cf 1a 4f 44 50 d5 cd 96 c3 4a 22 7a 54 28 bd |...ODP....J"zT(.| +00000140 88 56 5c 77 67 eb a6 78 5c 8b 82 39 03 13 55 c3 |.V\wg..x\..9..U.| +00000150 20 68 45 26 7a 96 fe 1c f9 33 14 1e 1d 8a 5f 51 | hE&z....3...._Q| +00000160 c3 2f 17 91 ba 37 63 49 e1 65 89 bf e8 a1 27 5f |./...7cI.e....'_| +00000170 fd 59 46 80 f7 9b 45 89 50 ab cd 9b aa b4 45 04 |.YF...E.P.....E.| +00000180 b5 1b 85 88 1c 59 ba b2 d6 50 0b fd 5c d9 59 83 |.....Y...P..\.Y.| +00000190 7a 6c 9b ad 27 33 a0 49 74 eb a6 cd a8 e8 4b d7 |zl..'3.It.....K.| +000001a0 71 ef 63 64 ff 24 a7 09 2e b7 f6 6f 9d 9f 75 84 |q.cd.$.....o..u.| +000001b0 97 0a 76 bf 72 ed ff e8 1a 49 ca 0b 0d f5 2c fb |..v.r....I....,.| +000001c0 69 c2 5c fe db 58 0a a1 9c d4 47 6a 8f a6 bd ec |i.\..X....Gj....| +000001d0 32 fb 40 6a 71 9d 19 37 e6 fd d4 3d fa 5b f3 53 |2.@jq..7...=.[.S| +000001e0 43 df d5 fa 53 29 40 70 77 a6 9e f7 03 7d 08 8b |C...S)@pw....}..| +000001f0 5a 71 73 e5 af 45 58 56 9f 56 ad 73 aa d2 b3 7c |Zqs..EXV.V.s...|| +00000200 92 99 c8 04 16 bf ca f2 81 2e 29 c3 79 21 f1 11 |..........).y!..| +00000210 92 f4 1d 34 24 73 e3 82 28 5a 31 70 45 da 8d 94 |...4$s..(Z1pE...| +00000220 38 75 31 bc f9 e5 2b 11 7e fd bc 19 fe 65 ad 53 |8u1...+.~....e.S| +00000230 e5 e6 17 b8 69 ea 54 fd 92 a9 41 7a 8c 7f da 4f |....i.T...Az...O| +00000240 ba f1 9f a2 e2 5b e7 7a 23 17 9e 29 95 7e 72 79 |.....[.z#..).~ry| +00000250 22 67 c5 68 0a 4d fb e9 64 61 3a 53 18 e7 dd 7d |"g.h.M..da:S...}| +00000260 5b 16 b9 fa 69 95 82 eb ee 1a 30 97 93 97 fc ee |[...i.....0.....| +00000270 9e 2b 22 64 08 7d 25 05 77 5e d7 bd 0e c3 9f a4 |.+"d.}%.w^......| +00000280 f4 bf 77 3d 56 84 c8 a1 10 1c e0 5b da 39 3d 2d |..w=V......[.9=-| +00000290 92 80 9a 07 b2 29 c5 ab e0 e1 1c ad ba 3e fa 4e |.....).......>.N| +000002a0 65 4f 31 63 de 33 6a 5c af e0 88 70 fc 6e 6a a2 |eO1c.3j\...p.nj.| +000002b0 ca da 2f 14 1d 4f 8c 7d 8d da 36 9b ea 7f 7e 79 |../..O.}..6...~y| +000002c0 9c dc 4a 3b 69 d9 50 31 bb f2 f8 8a 7f 6e 73 bc |..J;i.P1.....ns.| +000002d0 41 7c 3a 86 10 91 9b 3a 8e 3e c8 bc 6a c4 4d f2 |A|:....:.>..j.M.| +000002e0 45 87 49 49 d2 2f aa 4d d0 6f e9 1e a4 d6 06 63 |E.II./.M.o.....c| +000002f0 ac 90 ce 9a cb f7 97 55 2b e8 8c 8d 55 f6 32 26 |.......U+...U.2&| +00000300 55 d4 60 0e c0 0b da 0e ac c9 4c c3 95 03 54 d7 |U.`.......L...T.| +00000310 99 ec e1 17 03 03 00 99 c4 65 5e 67 e3 a1 98 d6 |.........e^g....| +00000320 f8 34 15 ed a9 55 80 c7 c0 e7 ca 67 f1 cb 58 e2 |.4...U.....g..X.| +00000330 6e 4d d4 9e 18 c3 37 c2 ff 72 bc cb 8e 6a 97 e2 |nM....7..r...j..| +00000340 b5 83 75 34 2a 75 9f 7f 8e 1e 47 e6 cd 53 85 c5 |..u4*u....G..S..| +00000350 69 b6 c0 46 9f 46 a8 09 6a 21 d5 af 36 d2 d0 ba |i..F.F..j!..6...| +00000360 65 0f da a5 af eb 3a 0c 8b 85 00 2a dd 11 71 28 |e.....:....*..q(| +00000370 5b 71 a9 df 69 20 8a d9 27 1e 4f 02 89 03 6f 27 |[q..i ..'.O...o'| +00000380 20 e1 37 17 69 c2 62 3e 46 39 43 2d 64 43 f3 cc | .7.i.b>F9C-dC..| +00000390 14 5f a0 73 06 bf 42 cb da 79 21 28 b1 a1 c4 de |._.s..B..y!(....| +000003a0 39 98 83 ad 3a d6 05 fd 58 b0 2c 97 bf 48 74 0e |9...:...X.,..Ht.| +000003b0 25 17 03 03 00 35 69 10 76 25 e3 9e 63 10 76 73 |%....5i.v%..c.vs| +000003c0 f5 fc 90 2c 95 e5 dc 29 79 a0 ed 0a 3a 72 58 38 |...,...)y...:rX8| +000003d0 bf b9 17 af 77 9f 05 92 af d4 a7 c7 d6 56 77 01 |....w........Vw.| +000003e0 da 94 31 d2 be be 95 e1 b1 95 75 17 03 03 00 93 |..1.......u.....| +000003f0 f9 fa a9 41 89 d3 e8 3b cb 11 63 76 56 fe 28 86 |...A...;..cvV.(.| +00000400 87 b0 0f d0 4d a8 fb 22 e9 89 f6 40 8a db 51 be |....M.."...@..Q.| +00000410 2c 9f 9c 39 f4 43 bc 1f b0 32 9b 9c 8e a6 6e e1 |,..9.C...2....n.| +00000420 f3 f7 f0 91 ed 56 6f 2d be 37 6b 3b ed f7 5b a6 |.....Vo-.7k;..[.| +00000430 d3 14 0a f9 58 b8 7b 37 fc 15 97 57 79 16 8c 0c |....X.{7...Wy...| +00000440 d2 93 7a 58 b8 48 51 f7 58 82 7d a0 4b e1 41 f6 |..zX.HQ.X.}.K.A.| +00000450 e1 44 12 1e ea 80 f3 b6 d0 72 ec 5c 84 01 6a b3 |.D.......r.\..j.| +00000460 f7 83 b5 47 22 0b e7 03 60 09 a7 23 23 20 5e 6b |...G"...`..## ^k| +00000470 f6 25 34 64 11 ad 46 90 db cb 13 f5 10 0a 75 e8 |.%4d..F.......u.| +00000480 3e c8 03 |>..| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 00 35 27 f0 39 68 fc |..........5'.9h.| +00000010 9f 6c a4 fd a7 cf 1f 25 67 54 3c e6 9e 7c 99 5a |.l.....%gT<..|.Z| +00000020 e9 b7 3c 0c f2 dc b6 22 36 0d 43 a3 ee 76 4b a9 |..<...."6.C..vK.| +00000030 6a cb b8 f6 8a c8 58 91 79 19 95 7c 83 a0 87 57 |j.....X.y..|...W| +>>> Flow 4 (server to client) +00000000 17 03 03 00 1e d5 8a ef 04 f9 6c 27 62 0a f1 a4 |..........l'b...| +00000010 4b 7f e4 e4 ff 53 f3 61 20 b9 56 96 30 f9 06 c9 |K....S.a .V.0...| +00000020 cc 9c ed 17 03 03 00 13 4a 83 cd 86 98 97 20 45 |........J..... E| +00000030 ab 2f c5 72 15 f6 ed a8 8c 8c 0e |./.r.......| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv13-ClientAuthRequestedAndECDSAGiven b/libgo/go/crypto/tls/testdata/Server-TLSv13-ClientAuthRequestedAndECDSAGiven new file mode 100644 index 00000000000..c26e3c2ed57 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Server-TLSv13-ClientAuthRequestedAndECDSAGiven @@ -0,0 +1,184 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 e0 01 00 00 dc 03 03 93 c7 00 24 7c |..............$|| +00000010 18 0f ec 3a 26 e2 8c 6b 54 d4 34 c0 5d 1e 0d 37 |...:&..kT.4.]..7| +00000020 d1 cd 67 7a 48 59 0a 11 c3 bf d6 20 f3 37 6c 43 |..gzHY..... .7lC| +00000030 00 91 4d e9 b4 27 39 77 6e 75 4b bf 41 68 b8 0c |..M..'9wnuK.Ah..| +00000040 31 53 bc 48 55 a6 27 71 09 30 01 36 00 08 13 02 |1S.HU.'q.0.6....| +00000050 13 03 13 01 00 ff 01 00 00 8b 00 00 00 0e 00 0c |................| +00000060 00 00 09 31 32 37 2e 30 2e 30 2e 31 00 0b 00 04 |...127.0.0.1....| +00000070 03 00 01 02 00 0a 00 0c 00 0a 00 1d 00 17 00 1e |................| +00000080 00 19 00 18 00 16 00 00 00 17 00 00 00 0d 00 1e |................| +00000090 00 1c 04 03 05 03 06 03 08 07 08 08 08 09 08 0a |................| +000000a0 08 0b 08 04 08 05 08 06 04 01 05 01 06 01 00 2b |...............+| +000000b0 00 03 02 03 04 00 2d 00 02 01 01 00 33 00 26 00 |......-.....3.&.| +000000c0 24 00 1d 00 20 95 28 2e 63 cf 81 4b cd 4b 64 73 |$... .(.c..K.Kds| +000000d0 19 19 82 2d b7 f5 54 08 4d f4 72 70 21 3e a0 d6 |...-..T.M.rp!>..| +000000e0 7d 96 92 ac 63 |}...c| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 00 00 00 00 00 |....z...v.......| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 f3 37 6c 43 |........... .7lC| +00000030 00 91 4d e9 b4 27 39 77 6e 75 4b bf 41 68 b8 0c |..M..'9wnuK.Ah..| +00000040 31 53 bc 48 55 a6 27 71 09 30 01 36 13 02 00 00 |1S.HU.'q.0.6....| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 2f |..+.....3.$... /| +00000060 e5 7d a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 |.}.G.bC.(.._.).0| +00000070 ff f6 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 14 |.........._X.;t.| +00000080 03 03 00 01 01 17 03 03 00 17 db 3b a3 78 48 c0 |...........;.xH.| +00000090 4e d1 ad 99 4d 73 e3 84 27 ff 42 de f6 c9 c9 b5 |N...Ms..'.B.....| +000000a0 49 17 03 03 00 3c 77 b8 16 13 1d cb 0a 6b 3e 41 |I....A| +000000b0 24 8a 03 b9 88 48 6f b3 d7 61 66 f4 33 67 86 8c |$....Ho..af.3g..| +000000c0 2f ad 4f f1 40 ad 63 10 35 ee f7 15 d2 0e e9 31 |/.O.@.c.5......1| +000000d0 b8 d9 b2 32 28 05 1e 73 3d bd a2 12 26 32 5a bc |...2(..s=...&2Z.| +000000e0 0c ea 17 03 03 02 6d e0 8f 50 e0 54 85 74 f0 b8 |......m..P.T.t..| +000000f0 31 25 df 87 fd 8b 5b 52 d4 fe b0 8e 61 44 b5 28 |1%....[R....aD.(| +00000100 1d 0e 8a 07 56 bb 77 5d 60 d8 c1 a0 95 ff 5c e9 |....V.w]`.....\.| +00000110 a2 ca 17 20 3d b1 b1 8e 76 31 2f 0d c9 e3 ee b5 |... =...v1/.....| +00000120 e6 fe fd dc 2e b9 e5 44 77 d3 fe 7a d5 9f 0e ab |.......Dw..z....| +00000130 75 b0 ff 2a 7b aa 64 75 62 ec 15 bd 2e 0c a4 54 |u..*{.dub......T| +00000140 e6 12 cd 31 13 83 6c 98 e8 00 b3 b6 c6 7b cb 87 |...1..l......{..| +00000150 82 3a f9 15 50 6b 4d c2 5b 6a 91 42 ce e8 25 14 |.:..PkM.[j.B..%.| +00000160 0d 5d 17 04 c3 cf d6 23 ad 9e 0e 3b 1c aa 2e 88 |.].....#...;....| +00000170 02 dc 63 12 3e 33 29 3d f8 b2 ec f2 15 d6 13 d3 |..c.>3)=........| +00000180 c9 88 a1 ad a9 27 fd 7c c4 5e f9 73 eb 45 a7 5f |.....'.|.^.s.E._| +00000190 a1 4f be d7 0f e9 d0 da 30 67 3b 9d 63 2d ef b4 |.O......0g;.c-..| +000001a0 89 3e de 19 20 af 62 52 7c e7 80 96 93 6e ca bf |.>.. .bR|....n..| +000001b0 c3 48 e2 c5 23 8d cf b0 a2 e5 dd a8 51 21 6f 99 |.H..#.......Q!o.| +000001c0 24 03 c8 d8 e0 dd e6 d4 ef 7f 74 17 85 14 ca 81 |$.........t.....| +000001d0 91 4e c6 5d 80 86 63 6f 97 55 ab 80 1c ab 63 c8 |.N.]..co.U....c.| +000001e0 01 ca df 11 28 68 b8 75 06 22 33 ba 9c b8 14 a1 |....(h.u."3.....| +000001f0 7a 1d cb 24 7c 90 44 b1 ed 33 e7 9d 80 6d ce b7 |z..$|.D..3...m..| +00000200 0a 74 bd 29 53 a2 bb 06 67 4d 4d 53 cc 1c 66 76 |.t.)S...gMMS..fv| +00000210 a9 4f 86 be 7a da ba 35 23 b6 6f c4 7d 02 2a 9f |.O..z..5#.o.}.*.| +00000220 2d 81 3d e2 16 3d 4b 78 ba cb f3 91 c7 39 9c 3d |-.=..=Kx.....9.=| +00000230 2e 4d a0 f6 6d 3d ba 15 bd cf 60 3b 8a 4a 18 9f |.M..m=....`;.J..| +00000240 87 e4 ee 1a ac f2 b2 bc a6 9f af b2 9e ca be 60 |...............`| +00000250 3f 36 54 84 d0 cd 31 d8 60 3b 4e 7e 6c 80 d5 25 |?6T...1.`;N~l..%| +00000260 1c 1b 1e fb 0f e7 ad b0 30 0d 13 be 27 f8 c3 6a |........0...'..j| +00000270 93 d3 f0 55 cb e9 73 6b e9 72 aa bb ea 24 05 f7 |...U..sk.r...$..| +00000280 c7 51 d5 66 77 32 53 82 fb 6c 2e fc fb 83 2d f4 |.Q.fw2S..l....-.| +00000290 5d a1 cc 75 fa d1 ee c2 5b 5d 48 e5 6d 69 87 54 |]..u....[]H.mi.T| +000002a0 1c b1 03 bd 06 66 7b 6d b7 46 33 56 b9 1c 62 a1 |.....f{m.F3V..b.| +000002b0 fd d3 61 50 42 ef 66 f8 97 26 5b 17 82 52 89 09 |..aPB.f..&[..R..| +000002c0 48 b8 68 50 63 d6 d4 83 7e 1f 5d 9d ad 69 2a 3c |H.hPc...~.]..i*<| +000002d0 d6 ab b7 33 1b 07 bc 44 92 d7 23 07 00 64 3f 64 |...3...D..#..d?d| +000002e0 98 e9 52 11 69 fc 21 04 65 1d f8 0d 06 dd 54 14 |..R.i.!.e.....T.| +000002f0 93 ae ca 30 06 db 4b 70 00 0b 3a cb 11 19 1a c6 |...0..Kp..:.....| +00000300 a7 f0 1c 9f 31 f9 30 ec 5f 1c 4e 74 d0 1c 9b 49 |....1.0._.Nt...I| +00000310 ab 42 c3 72 7d 11 e0 07 3d 3f 51 7a 99 07 32 0f |.B.r}...=?Qz..2.| +00000320 d6 b7 b7 ac 83 2e 3b c4 ce 81 1d 1a e0 e8 ba d7 |......;.........| +00000330 12 d1 14 a9 62 c3 58 30 0d ac 30 6c 7d 06 be 96 |....b.X0..0l}...| +00000340 e1 e4 14 6b 56 16 17 84 52 32 4c aa ec 83 1d 6c |...kV...R2L....l| +00000350 d1 b0 1f 63 17 03 03 00 99 c9 7d 79 9c 0f 73 20 |...c......}y..s | +00000360 0b 93 09 a6 6e 46 fd 56 12 08 0a 8c 1b 9c b0 9f |....nF.V........| +00000370 0a d4 d9 33 e9 22 0e 90 d4 7c b3 4d 5a 95 e9 90 |...3."...|.MZ...| +00000380 14 69 e5 d2 ad 2e b4 f1 a0 98 7d 24 fa b2 a4 2a |.i........}$...*| +00000390 f8 af 6a e3 9d a7 64 cc ea 51 73 d1 40 23 98 df |..j...d..Qs.@#..| +000003a0 9f cc 70 bb c5 3b 8b fc 95 6f ca 04 6d 7d cd 77 |..p..;...o..m}.w| +000003b0 ba b3 d3 e1 50 38 9c 16 60 d7 2b be 82 b3 a5 70 |....P8..`.+....p| +000003c0 76 c4 fb ba 7e 78 5c 97 a3 47 fe 23 80 b7 d4 f1 |v...~x\..G.#....| +000003d0 1f a6 dc 08 68 b4 d7 bb 09 6f 45 37 e5 1d 2b 2f |....h....oE7..+/| +000003e0 e1 57 84 4e 95 c1 bc b4 14 a4 45 04 69 ae 79 01 |.W.N......E.i.y.| +000003f0 07 42 17 03 03 00 45 00 a8 d1 03 76 56 7f b3 7e |.B....E....vV..~| +00000400 ec 82 94 7f b7 66 8a 01 c3 ab 50 13 20 f3 ea 3e |.....f....P. ..>| +00000410 27 56 e7 49 14 6a d0 2e f4 04 d1 54 c0 b1 4d 5e |'V.I.j.....T..M^| +00000420 2a a5 f1 89 55 f6 b0 ee e2 15 26 13 ec a4 4c ca |*...U.....&...L.| +00000430 ef 1a c7 ff 3e 5e f3 88 15 57 47 43 |....>^...WGC| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 02 1e cd 5f bd ff 6b |............_..k| +00000010 f7 c8 70 4b cc c8 84 44 c2 d0 7d ea 39 78 5a 6f |..pK...D..}.9xZo| +00000020 7a 72 0e 55 d0 76 7c 48 d8 cc 32 b4 08 bf f7 a8 |zr.U.v|H..2.....| +00000030 32 99 4a c5 83 79 4d 39 ea 0d 63 33 da 89 57 30 |2.J..yM9..c3..W0| +00000040 ab 31 95 90 f4 8d 4a 63 34 13 c6 4e d6 80 37 b8 |.1....Jc4..N..7.| +00000050 9b 28 8b 8f e5 b5 2a 16 e1 82 63 6f 1b ca 3a b4 |.(....*...co..:.| +00000060 b3 0b 36 56 09 d8 1e ab b4 fb aa 07 df 76 d3 b2 |..6V.........v..| +00000070 07 8d 56 38 f9 15 c2 1b c9 97 50 6a c4 23 6f 39 |..V8......Pj.#o9| +00000080 7b b3 69 b5 c2 6e 29 b4 14 17 9c 3d b7 c5 5f 12 |{.i..n)....=.._.| +00000090 25 73 89 22 99 1f 77 9d 9c a4 f6 fc 0a 8b af 24 |%s."..w........$| +000000a0 9b fc c1 b3 c3 cd 88 55 b5 81 8a 6e 73 83 cc da |.......U...ns...| +000000b0 fa 64 fe 3b 20 31 75 9a ce 35 ad a6 4b 3f 6f 49 |.d.; 1u..5..K?oI| +000000c0 e0 ae 21 23 ac c5 86 bb ec 91 13 37 76 d9 06 40 |..!#.......7v..@| +000000d0 ce 32 84 41 3e c0 5c 6d 93 0c 2f af ac af 5e ef |.2.A>.\m../...^.| +000000e0 ab 65 fc cc 00 a4 11 94 27 0e 11 ac 2a 00 dc c3 |.e......'...*...| +000000f0 dc fc 68 ff b3 32 bf 75 ff d0 35 e1 a3 44 68 6e |..h..2.u..5..Dhn| +00000100 21 39 ab 68 93 11 50 3b 30 1c 32 2a 03 9a 2a 9c |!9.h..P;0.2*..*.| +00000110 ff 2a bf 10 b3 ae 28 33 43 3c b2 04 a3 5d 49 21 |.*....(3C<...]I!| +00000120 db c4 4e 90 2f bd 20 03 d1 99 78 48 1a fd f2 a8 |..N./. ...xH....| +00000130 1b 06 1b 4e d1 5f 7c ed ba 04 3c ad 9c 20 4f 5e |...N._|...<.. O^| +00000140 37 5b 75 8e fc 40 2a 09 1c 78 f7 b2 15 ad a6 24 |7[u..@*..x.....$| +00000150 29 98 74 42 e2 80 28 80 0b 78 22 72 75 e3 33 75 |).tB..(..x"ru.3u| +00000160 a0 57 37 00 f1 69 bd ab 22 74 2d 6c 4a 1e 46 5b |.W7..i.."t-lJ.F[| +00000170 64 e0 47 d7 77 85 18 6b 10 67 6f 83 eb 98 e4 31 |d.G.w..k.go....1| +00000180 00 35 1d c3 1f d9 7a 86 27 27 3f 2d 0d cb 53 8f |.5....z.''?-..S.| +00000190 f4 52 e7 5a ba 02 67 44 a8 19 71 1a 7b f2 b1 80 |.R.Z..gD..q.{...| +000001a0 c9 82 d0 4b 63 0e d0 e0 bd a1 cc 5e 55 80 9a 51 |...Kc......^U..Q| +000001b0 21 bf 32 ce 8f 74 ea ed a6 cd ee b4 8f 3b 8f 6c |!.2..t.......;.l| +000001c0 41 5e 3d 1f 00 0b d4 a4 09 9a 8e c3 3f b1 b7 4c |A^=.........?..L| +000001d0 7b 6b 57 3f 94 3d ed d7 60 5c d4 04 b0 7b 62 06 |{kW?.=..`\...{b.| +000001e0 f7 06 f6 f0 f8 44 80 55 97 22 60 e6 dc f3 ec 7d |.....D.U."`....}| +000001f0 d2 22 e0 07 5d 52 0c 63 4d 77 f8 c5 16 06 67 5b |."..]R.cMw....g[| +00000200 9e 96 f4 1e fa 8e dd f8 42 85 7f 1e dc f9 dc b8 |........B.......| +00000210 b1 91 b0 c3 04 0d e1 dd c9 c4 0d fb b7 74 cb e5 |.............t..| +00000220 57 38 b7 82 8c d1 20 d1 0f 17 03 03 00 a4 79 ad |W8.... .......y.| +00000230 66 39 e1 10 c9 96 2c d3 7f 11 c6 7e c4 36 56 4c |f9....,....~.6VL| +00000240 70 c3 8f a4 da c2 a5 53 9b 28 25 82 69 d8 90 f0 |p......S.(%.i...| +00000250 79 52 29 cb e1 d4 48 49 dd 00 82 37 b1 ac 3b 1c |yR)...HI...7..;.| +00000260 2c b9 a7 c4 08 ac 08 fd 42 47 79 1f 64 82 57 2a |,.......BGy.d.W*| +00000270 63 c0 78 54 55 69 f2 05 9e 8d 81 6e d9 b5 31 08 |c.xTUi.....n..1.| +00000280 d3 0d 61 61 4f 70 a4 57 67 eb 9d 09 ca 51 01 ff |..aaOp.Wg....Q..| +00000290 53 d2 6d 9e 49 ce 40 1f c9 ab a2 52 e6 56 0c d3 |S.m.I.@....R.V..| +000002a0 63 b4 44 d7 fe 97 1d d2 55 8d 13 df 23 71 68 b6 |c.D.....U...#qh.| +000002b0 79 26 a8 a6 cd ca a1 19 6b 21 e8 b6 30 34 b6 6f |y&......k!..04.o| +000002c0 66 2d ab 1d 16 7f c6 b1 53 c9 2a 40 87 9d 7d 48 |f-......S.*@..}H| +000002d0 c9 6a 17 03 03 00 45 43 bf 6e f3 e2 76 56 69 2f |.j....EC.n..vVi/| +000002e0 9b c5 d2 46 4f 24 d2 e2 61 13 2b ad b6 3e d8 89 |...FO$..a.+..>..| +000002f0 1b 31 7c ec 14 44 39 7c b4 08 44 9d 31 d9 a1 5f |.1|..D9|..D.1.._| +00000300 2e 8f a9 8e 5b 5a 91 e2 f5 61 f5 63 be 5c 14 e3 |....[Z...a.c.\..| +00000310 70 8e 2e 9e fd 6c 54 85 ba ef 85 b7 |p....lT.....| +>>> Flow 4 (server to client) +00000000 17 03 03 02 a8 02 f0 98 42 d8 ab 9d 92 8c 11 ac |........B.......| +00000010 16 4d b1 c0 2e 3b 0f ac 53 f8 aa 15 01 36 03 fd |.M...;..S....6..| +00000020 1b e1 0f 87 62 5f d4 4e fc 0d 88 13 30 4f 5e fc |....b_.N....0O^.| +00000030 46 1b 3a 22 cc ff a9 5e 29 24 15 67 08 1b 28 18 |F.:"...^)$.g..(.| +00000040 d3 70 46 fa 92 89 de 69 62 f1 c7 47 d1 24 a2 98 |.pF....ib..G.$..| +00000050 8d 78 d0 f2 cc 3f fb 4c 3c 5e 03 0c 4e a8 a3 b7 |.x...?.L<^..N...| +00000060 c5 69 49 19 43 da 07 b4 be 6e 7d cd 12 c3 bf d7 |.iI.C....n}.....| +00000070 74 9a 3e 30 cd 9d 8e a4 27 bb 66 d1 95 50 ad f7 |t.>0....'.f..P..| +00000080 91 52 e4 be d5 61 fc 28 fb 33 02 bc f4 fb fb 7f |.R...a.(.3......| +00000090 0c 9a dc e4 63 86 c6 f8 f6 bc 67 60 c6 ac b2 52 |....c.....g`...R| +000000a0 65 3e 0d f7 15 e0 d4 f2 7b 36 ed e2 2e c3 ab 44 |e>......{6.....D| +000000b0 e4 06 d1 09 e6 c6 9e c3 dd df e9 3b 9c 22 cb 48 |...........;.".H| +000000c0 1a 18 22 da 8c e7 11 e0 36 0b a9 73 be d8 22 db |..".....6..s..".| +000000d0 8b 95 f5 3e cc c0 11 6f db 40 57 4c 07 14 2b fc |...>...o.@WL..+.| +000000e0 9e 6b f8 07 96 9f 3d 8e cc d2 c3 b5 a8 e1 64 33 |.k....=.......d3| +000000f0 b6 ab 17 4b aa b2 e0 b6 fe b6 49 69 7d 0b 8e cd |...K......Ii}...| +00000100 19 a3 d8 5e 22 5a 02 64 c2 68 ec 69 55 2d fd aa |...^"Z.d.h.iU-..| +00000110 1f f6 35 bf b2 14 a5 f9 a0 49 59 a4 84 ff 41 a5 |..5......IY...A.| +00000120 fb a1 e4 97 72 88 00 98 dd 5a 6f 7b 00 a7 59 fa |....r....Zo{..Y.| +00000130 83 73 e7 ca 8f dd 31 e8 ca 02 13 c9 fa 2b 8c 5e |.s....1......+.^| +00000140 b5 7b 85 da 2b 1a 75 da e3 db b7 34 58 c4 da 15 |.{..+.u....4X...| +00000150 b3 3a f9 a7 b3 7f 15 d2 01 b2 26 b4 c1 fe 83 af |.:........&.....| +00000160 d6 f7 8b fb 92 3d 32 ae 4a 1b a2 50 60 70 a6 34 |.....=2.J..P`p.4| +00000170 98 3f 2d bf 27 2e d3 a0 91 d9 c8 f9 a9 27 f2 23 |.?-.'........'.#| +00000180 7c 3c 17 96 19 99 6f 09 a7 bd da 2d 94 9e f9 6b ||<....o....-...k| +00000190 bb 93 fd bb b1 c0 89 6f b4 8f 90 86 e1 85 59 98 |.......o......Y.| +000001a0 ba 98 7c 6c 26 be 98 30 5f cf 46 bf e9 c6 a4 bd |..|l&..0_.F.....| +000001b0 08 14 2a 5c 05 d8 c2 0e ba 46 af 23 e8 f0 71 77 |..*\.....F.#..qw| +000001c0 78 78 ec c2 af 4a 63 93 2e b1 ed 56 3d b7 7c a5 |xx...Jc....V=.|.| +000001d0 63 99 2f df 15 d3 ce 79 0e 49 d0 16 ac 3e f3 fa |c./....y.I...>..| +000001e0 cd e7 0e e5 ee 4a cd 49 20 f6 9f fa d1 df cb cc |.....J.I .......| +000001f0 1b 73 83 12 47 52 69 3c 93 bb 1f 65 64 1e 79 15 |.s..GRi<...ed.y.| +00000200 72 85 e8 fd fa d6 be d5 61 44 35 bb 75 a7 17 1f |r.......aD5.u...| +00000210 dd 7b 60 17 78 1f 11 72 7f ac e7 52 1e 94 13 35 |.{`.x..r...R...5| +00000220 ab 97 69 17 09 6c 4b 46 cd 34 2d 7e 55 8a 16 d3 |..i..lKF.4-~U...| +00000230 c2 59 e8 d8 67 9b 29 af bc f1 31 39 d9 ff 06 d5 |.Y..g.)...19....| +00000240 80 b8 8d 50 80 5f 2c 0a 30 84 28 32 3d 4c 45 f2 |...P._,.0.(2=LE.| +00000250 2f 8b b5 d9 3a 7a 47 05 55 22 7a a4 61 c8 8c d1 |/...:zG.U"z.a...| +00000260 1c 1b 78 e0 87 37 5e 36 88 5c 32 ca 7a d3 76 63 |..x..7^6.\2.z.vc| +00000270 ee 94 83 9c 9e 5e 9b 01 42 03 e1 e5 0f a8 43 53 |.....^..B.....CS| +00000280 cd 3d 76 01 88 ba bf 78 b8 d7 b2 e9 8f 69 d1 35 |.=v....x.....i.5| +00000290 88 44 f1 ef 20 cd 42 c6 99 99 0c a5 25 ec dc 88 |.D.. .B.....%...| +000002a0 1e b5 28 dd e4 a1 12 20 03 fa ce 38 8a 17 03 03 |..(.... ...8....| +000002b0 00 1e bc 9a e0 0d 88 a2 71 15 c3 0d 54 d3 13 d8 |........q...T...| +000002c0 d9 96 ad 95 ee 47 2c c6 ba e9 f9 50 b1 8e 1e 0b |.....G,....P....| +000002d0 17 03 03 00 13 d2 56 e3 48 c0 fa 0f 9a 95 22 e9 |......V.H.....".| +000002e0 51 c1 98 64 b4 03 09 5a |Q..d...Z| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv13-ClientAuthRequestedAndGiven b/libgo/go/crypto/tls/testdata/Server-TLSv13-ClientAuthRequestedAndGiven new file mode 100644 index 00000000000..cbd8c75e9fb --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Server-TLSv13-ClientAuthRequestedAndGiven @@ -0,0 +1,180 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 c6 01 00 00 c2 03 03 9f dd 5a e8 c2 |.............Z..| +00000010 fa 2f 38 45 33 8d f2 ab 67 03 f6 cc ba 9d 8b 33 |./8E3...g......3| +00000020 69 c8 c6 50 f4 2e 1b 2b dc 2b 2d 20 ab eb f9 db |i..P...+.+- ....| +00000030 71 a7 b4 eb 9a e0 17 04 2e a8 d2 c7 65 51 71 a3 |q...........eQq.| +00000040 9a a3 5a 64 38 45 49 dc e9 e9 e2 96 00 08 13 02 |..Zd8EI.........| +00000050 13 03 13 01 00 ff 01 00 00 71 00 00 00 0e 00 0c |.........q......| +00000060 00 00 09 31 32 37 2e 30 2e 30 2e 31 00 0b 00 04 |...127.0.0.1....| +00000070 03 00 01 02 00 0a 00 0c 00 0a 00 1d 00 17 00 1e |................| +00000080 00 19 00 18 00 16 00 00 00 17 00 00 00 0d 00 04 |................| +00000090 00 02 08 04 00 2b 00 03 02 03 04 00 2d 00 02 01 |.....+......-...| +000000a0 01 00 33 00 26 00 24 00 1d 00 20 08 a9 6d 37 e7 |..3.&.$... ..m7.| +000000b0 3b e8 ab 4c d3 81 41 6e ac 3d dc 45 94 72 9c 9d |;..L..An.=.E.r..| +000000c0 43 32 f7 d0 de 5a e0 6b b3 11 23 |C2...Z.k..#| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 00 00 00 00 00 |....z...v.......| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 ab eb f9 db |........... ....| +00000030 71 a7 b4 eb 9a e0 17 04 2e a8 d2 c7 65 51 71 a3 |q...........eQq.| +00000040 9a a3 5a 64 38 45 49 dc e9 e9 e2 96 13 02 00 00 |..Zd8EI.........| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 2f |..+.....3.$... /| +00000060 e5 7d a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 |.}.G.bC.(.._.).0| +00000070 ff f6 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 14 |.........._X.;t.| +00000080 03 03 00 01 01 17 03 03 00 17 0f f6 f3 45 0e 04 |.............E..| +00000090 df 70 96 7c 7a a6 a7 31 7a 7f b8 43 53 ab 02 32 |.p.|z..1z..CS..2| +000000a0 23 17 03 03 00 3c bc 1f 27 c5 81 3d d3 25 22 34 |#....<..'..=.%"4| +000000b0 af e3 a4 6f 22 14 e0 e8 2b 9e 91 6b b5 a5 19 b7 |...o"...+..k....| +000000c0 32 5d a9 2a 7a ff 30 71 7b a8 32 01 00 b8 52 cc |2].*z.0q{.2...R.| +000000d0 5e 46 ab 4d c0 10 a6 8d 0d 04 8a 26 5c d1 3a 62 |^F.M.......&\.:b| +000000e0 67 07 17 03 03 02 6d 54 af e4 20 90 dd 21 b4 04 |g.....mT.. ..!..| +000000f0 46 0c 01 7f 5c c4 4b 08 87 4f f0 fd 9f 64 34 55 |F...\.K..O...d4U| +00000100 3e 30 81 52 3a c7 a6 3c 7a 0d 3e e8 b0 9c 38 df |>0.R:.....8.| +00000110 2a bf 29 e0 cb 13 04 0a d0 ab 65 fc d1 0c 6a ae |*.).......e...j.| +00000120 36 03 81 56 7b dd 1d 15 a8 81 de e2 85 25 5c e5 |6..V{........%\.| +00000130 a8 38 44 dd 04 d7 52 18 0e 27 8c a3 be c3 54 f7 |.8D...R..'....T.| +00000140 54 a2 ec df 6d cb ae cf dd 77 78 01 e0 0c 02 76 |T...m....wx....v| +00000150 65 e3 da da 5b 96 2c 57 fa c5 a2 6e 3f 9f 93 f5 |e...[.,W...n?...| +00000160 af b3 fa 27 d5 46 94 c1 8c 4e 0b d5 c7 f8 21 07 |...'.F...N....!.| +00000170 08 09 27 87 a6 19 5c b1 a8 d5 c1 66 3d 0a d9 bb |..'...\....f=...| +00000180 80 77 2b 24 cf 2e 7a 51 84 37 e1 e7 05 cb e9 90 |.w+$..zQ.7......| +00000190 47 0e 5f 32 25 60 81 2c 93 43 a5 1a f5 b0 84 13 |G._2%`.,.C......| +000001a0 2f e8 37 d6 b6 4b bc 4a ad 23 41 77 b0 b7 7e a7 |/.7..K.J.#Aw..~.| +000001b0 74 db d2 13 e5 12 ab 43 51 68 da 9a d6 68 f2 82 |t......CQh...h..| +000001c0 aa 73 49 6e e4 2e 24 41 e3 5c 22 c4 88 8b 03 8b |.sIn..$A.\".....| +000001d0 2d 14 b9 55 12 60 50 a2 d3 8a a9 8f 7c c5 d9 f6 |-..U.`P.....|...| +000001e0 f2 23 93 a2 a6 55 eb 27 3a c5 f5 f8 82 0e 23 43 |.#...U.':.....#C| +000001f0 bd 3a 2d b5 e3 e3 8f d3 a6 eb 30 56 a4 7f 1c 08 |.:-.......0V....| +00000200 72 85 77 22 36 f5 7a b8 d4 b8 9c e2 1f 47 f6 81 |r.w"6.z......G..| +00000210 d6 c7 76 4e 97 51 dd 1e 89 b5 b5 12 88 f9 2d ca |..vN.Q........-.| +00000220 2e 85 c8 cc cc 95 0d 7e a8 7e c3 59 85 b2 ca 14 |.......~.~.Y....| +00000230 d7 cc 50 3b 5e 03 52 77 d3 50 8d e4 50 76 e2 36 |..P;^.Rw.P..Pv.6| +00000240 82 df b2 69 a2 cf ee 1b fb 1d 5c a1 83 8b c9 97 |...i......\.....| +00000250 23 a6 7f 85 87 df d5 59 fc d5 ad 86 c7 2c 9a 92 |#......Y.....,..| +00000260 b6 1d d1 ee 92 83 92 f9 d8 9e dd e7 d7 05 c5 c8 |................| +00000270 a5 c2 10 b3 2f 99 4a 4b fb 8a 5b c7 26 06 18 7a |..../.JK..[.&..z| +00000280 1b d4 c1 f4 d4 2c cf a1 5e d2 f0 90 3d a4 2c b7 |.....,..^...=.,.| +00000290 d4 0a 7b e4 7f 16 29 1a ad d1 45 d5 b8 9b 07 4a |..{...)...E....J| +000002a0 ab 61 32 bb 27 ac 61 c6 74 56 ec fd 93 01 a0 53 |.a2.'.a.tV.....S| +000002b0 6b 0c 8b 3f 55 3d 53 fd cf f6 da d7 5a c6 8e 8f |k..?U=S.....Z...| +000002c0 c9 e1 fd 79 6c 85 22 08 2a a4 bc 82 ea f6 53 d6 |...yl.".*.....S.| +000002d0 80 02 a7 f5 49 0c 1f c3 4c 44 f2 7f 56 3a 5f 65 |....I...LD..V:_e| +000002e0 d1 4e 62 17 61 6b f9 75 94 e7 f9 5b da 8f 65 dd |.Nb.ak.u...[..e.| +000002f0 d0 98 99 72 35 b7 0e 79 3c b5 94 2b a2 19 94 e3 |...r5..y<..+....| +00000300 7b 31 cb 74 e4 41 c6 c3 92 0b 7a 2e 48 b5 50 2b |{1.t.A....z.H.P+| +00000310 23 b6 c1 de 6c 5e 57 c9 36 e8 a1 07 4d d1 73 a8 |#...l^W.6...M.s.| +00000320 c0 7b 67 1f fb 70 01 da 86 fb e0 73 ad 79 8c 9f |.{g..p.....s.y..| +00000330 7f 28 61 e9 2c d5 f0 d5 85 e4 e9 db 87 26 f9 dc |.(a.,........&..| +00000340 af e1 ed 4d 79 f0 5d 14 10 08 70 70 66 6d 5b 32 |...My.]...ppfm[2| +00000350 22 09 7f 78 17 03 03 00 99 16 32 bb fc 9a 38 88 |"..x......2...8.| +00000360 17 0f d1 03 15 b2 70 f3 ee d7 86 ec 67 f0 f6 aa |......p.....g...| +00000370 df 63 cf 4e 4c e3 f5 7f 67 3f ef 80 b0 68 b3 d2 |.c.NL...g?...h..| +00000380 a6 91 59 1a dd 9c 9b 26 7a 4e f1 e4 cb df cf 9f |..Y....&zN......| +00000390 51 26 76 88 02 73 e7 99 15 58 06 af cb 14 52 1e |Q&v..s...X....R.| +000003a0 18 4f 81 f9 62 2b 4b bd dc e6 3b fc 5f ff e6 4b |.O..b+K...;._..K| +000003b0 b7 4b 47 39 70 69 69 89 2b ca 9a 5e 32 91 7d e9 |.KG9pii.+..^2.}.| +000003c0 2f ae d4 b2 f8 13 89 57 4c 59 55 1e e5 41 66 34 |/......WLYU..Af4| +000003d0 b3 1e c3 e9 b0 79 7b 14 f8 c0 b5 16 c9 e3 7e ce |.....y{.......~.| +000003e0 3a 2c 38 85 ea ca 91 3f cf c0 fb 61 4d 24 b4 c5 |:,8....?...aM$..| +000003f0 b5 6a 17 03 03 00 45 3a 7a af a4 51 1c f9 07 39 |.j....E:z..Q...9| +00000400 73 d5 ca e2 6f ab 7c f3 ef b0 16 ea 17 0d 03 cb |s...o.|.........| +00000410 07 fb 40 1b ae 9a 5c e9 1f c1 aa c9 e5 f5 1b 4d |..@...\........M| +00000420 1b 4b 2c 0b 8d 86 24 06 9a 64 ba a5 fd e3 69 dd |.K,...$..d....i.| +00000430 53 e5 ac 9a 2f 37 fc fd e3 c1 b4 b7 |S.../7......| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 02 11 1c af 9f 29 61 |..............)a| +00000010 e3 1f bf c8 44 89 cf 28 10 cb e5 63 05 0c fa cf |....D..(...c....| +00000020 38 79 7c 63 5d 1d 6b 40 68 ea 54 41 3d 3a 39 83 |8y|c].k@h.TA=:9.| +00000030 8b e2 29 e9 f6 4d 4e e4 14 33 36 78 b2 bb 01 e1 |..)..MN..36x....| +00000040 84 c4 59 30 01 65 9b 6b b1 35 2d 3e 02 fa 9b db |..Y0.e.k.5->....| +00000050 51 d1 25 bc 4d fa a1 e8 24 e9 7e cc 97 b0 f2 40 |Q.%.M...$.~....@| +00000060 92 0f b0 1c 0a 0a 24 3e 77 d5 4f 0f c0 54 e7 f5 |......$>w.O..T..| +00000070 56 87 ff 46 0a 12 7f 49 18 76 40 3d ce 64 53 a8 |V..F...I.v@=.dS.| +00000080 f8 1a 95 70 dc 8f 1c b0 2d ba 55 42 89 1d fa 9a |...p....-.UB....| +00000090 cf d5 ba f0 fb f8 fe ad c8 5f e0 47 28 ce 48 2f |........._.G(.H/| +000000a0 a3 6c 7c 05 04 5f 3f 0a 95 ca 04 2f 6a b3 02 9c |.l|.._?..../j...| +000000b0 f3 23 d9 fd 13 75 45 5d a6 22 3f 72 6d 7e 35 60 |.#...uE]."?rm~5`| +000000c0 bd c1 b3 8d d4 42 4a b8 69 31 82 0c 83 94 84 76 |.....BJ.i1.....v| +000000d0 77 5e ca 19 8c d2 4f b1 94 71 2d 3d e9 34 3b 39 |w^....O..q-=.4;9| +000000e0 7f f0 b1 0b 8c e7 18 7e 37 89 c9 98 38 31 21 39 |.......~7...81!9| +000000f0 a4 52 b8 d0 0e 09 fb eb c1 e2 ef f1 37 4f d2 29 |.R..........7O.)| +00000100 13 4b 87 f9 88 19 71 bd d7 48 c9 8f 94 a3 51 4e |.K....q..H....QN| +00000110 65 4b 66 8a 48 9b 33 bf 14 70 24 24 e3 1c b3 6c |eKf.H.3..p$$...l| +00000120 0d f3 b1 74 5a bd a6 a4 f3 e9 1f 95 81 88 6d cb |...tZ.........m.| +00000130 19 44 67 b6 ee f7 65 af bf ec 0a 55 13 a6 65 41 |.Dg...e....U..eA| +00000140 49 4f be 8f c5 f2 a7 7c 27 ac ad fa 02 a5 75 54 |IO.....|'.....uT| +00000150 53 a5 a9 b5 7f b9 7d 70 2e 2d 48 27 fe 63 e6 ab |S.....}p.-H'.c..| +00000160 ea 13 47 0e 8f a5 8d 19 42 0f 8c 26 ba cd a2 98 |..G.....B..&....| +00000170 f5 e3 28 a7 a1 6d 56 95 0b 7f a1 c2 5e 77 56 81 |..(..mV.....^wV.| +00000180 5d c8 7f a8 00 4c a4 09 c1 ed 43 0e a2 65 8f 66 |]....L....C..e.f| +00000190 47 02 0f 0d 46 d5 42 d8 f5 e8 a7 f2 50 1b 09 02 |G...F.B.....P...| +000001a0 4d a9 39 78 6b fc 24 23 4b 2a 49 ef b7 60 70 78 |M.9xk.$#K*I..`px| +000001b0 f3 6f a0 2e 8f e3 20 b6 b9 76 ce 4d e4 56 e0 f3 |.o.... ..v.M.V..| +000001c0 b8 9f d2 02 f7 63 e9 80 ed 43 16 49 c9 3a c2 41 |.....c...C.I.:.A| +000001d0 8c f9 98 b7 3a 31 cb e6 78 3b ad ee 5f 52 c3 0a |....:1..x;.._R..| +000001e0 d7 dc 5f 67 89 6a 0a db 1f 7f 4b fc 08 0e a2 e1 |.._g.j....K.....| +000001f0 23 4b d6 a0 36 10 c7 e5 95 71 86 cb 1a 70 89 55 |#K..6....q...p.U| +00000200 2c 58 8a 55 f8 26 89 b1 40 1e 11 b0 b5 3e 0d eb |,X.U.&..@....>..| +00000210 33 cb 37 1c 80 6c b7 0e 84 96 a0 67 17 03 03 00 |3.7..l.....g....| +00000220 99 ae 4c b5 06 1e 69 cb 7d 28 42 7f 47 c8 1b bf |..L...i.}(B.G...| +00000230 8c 0a af 18 fc 5a 4d db 2c c5 b3 7d cc e5 28 be |.....ZM.,..}..(.| +00000240 ec 3a f7 e4 ec b1 11 01 67 f6 3b 0e a6 55 03 67 |.:......g.;..U.g| +00000250 76 8c 3f d3 0a cc 97 90 f2 51 d4 ee 58 3e 9c 78 |v.?......Q..X>.x| +00000260 e1 b4 57 4d 42 c1 fd e1 4c c5 6e 1f 5e 8e d9 fd |..WMB...L.n.^...| +00000270 f9 71 86 c9 63 7c 42 df 53 b0 99 06 3d 21 3e 06 |.q..c|B.S...=!>.| +00000280 d7 56 2f 90 b8 09 f5 77 8b 8a 4b 7e f5 78 05 73 |.V/....w..K~.x.s| +00000290 85 10 e7 b4 71 02 77 a0 2c cb db 76 53 0b b4 34 |....q.w.,..vS..4| +000002a0 56 37 7f 45 13 b4 72 f0 24 24 e4 47 1b ce b2 78 |V7.E..r.$$.G...x| +000002b0 44 82 73 f6 3a 77 68 5c ce 02 17 03 03 00 45 17 |D.s.:wh\......E.| +000002c0 d8 40 a5 44 fe 96 82 bc 27 1c 2f c6 c5 6e 0c 47 |.@.D....'./..n.G| +000002d0 52 9d 90 cd f6 43 03 d5 f0 1b 4a 11 38 56 f3 0b |R....C....J.8V..| +000002e0 73 cb 01 d3 69 33 1a 95 4b 5e 75 55 99 a9 a2 fe |s...i3..K^uU....| +000002f0 28 58 4e 54 92 5e 08 71 4b 40 42 a1 e6 94 ec c0 |(XNT.^.qK@B.....| +00000300 bc ac 82 8e |....| +>>> Flow 4 (server to client) +00000000 17 03 03 02 9b bf 6f 39 51 ff 9a ee ff 16 51 98 |......o9Q.....Q.| +00000010 49 e5 88 3d b3 ea b4 14 1d a7 8c ae 11 da 7b 08 |I..=..........{.| +00000020 99 ad 7d 23 e7 3a 78 8f b1 ca c1 2c b5 f7 84 bf |..}#.:x....,....| +00000030 0d 48 0b 1e 3f 6d 56 d7 7c 84 df f0 39 ee 77 ff |.H..?mV.|...9.w.| +00000040 af 7b f5 f2 6e 59 dc 4e 92 a8 b5 d0 64 03 5a 87 |.{..nY.N....d.Z.| +00000050 9d 4b 0c d7 00 0c e7 7e 2d 4a e0 da 63 10 cc a6 |.K.....~-J..c...| +00000060 a0 8e 8b ff 04 e2 49 75 01 4f b9 6a cd 5c 90 82 |......Iu.O.j.\..| +00000070 3c e3 67 d0 a0 93 b7 9b 4d f3 f8 b6 67 d3 fd f6 |<.g.....M...g...| +00000080 e3 d2 d0 dd 0f 6c 89 92 95 4f b6 74 56 5c f8 f5 |.....l...O.tV\..| +00000090 a1 33 3d e6 31 05 93 d8 09 d8 3c 0b e3 a7 9f b9 |.3=.1.....<.....| +000000a0 4b c7 0a de 1c 71 8a d6 63 44 b8 7d 11 6f 1e 8d |K....q..cD.}.o..| +000000b0 d8 7f 3f 9f 39 77 8b 2d 7a fd 01 e1 9e 45 58 b6 |..?.9w.-z....EX.| +000000c0 f8 eb f6 48 9b f2 fc 95 ba 75 56 42 5c 01 22 39 |...H.....uVB\."9| +000000d0 ab df c2 2d 32 9c de f6 fa 51 00 d0 77 a8 47 34 |...-2....Q..w.G4| +000000e0 b2 cf dd 9e d5 d6 c2 fd 0e db 98 71 6a 30 82 4e |...........qj0.N| +000000f0 4a 36 ce 6c c8 27 a0 92 77 ec 04 e8 ed 20 0d f4 |J6.l.'..w.... ..| +00000100 1e 9a 5c ae 71 db 06 6a ed ba 18 0e 65 94 dc f1 |..\.q..j....e...| +00000110 60 67 34 d4 6a 9d 4b ed 4b 80 69 2e 52 8b e2 ba |`g4.j.K.K.i.R...| +00000120 17 aa b7 75 0f 02 bf b9 95 f1 05 83 2c 2a e8 7d |...u........,*.}| +00000130 62 17 0e 89 c5 40 fb bb 98 14 98 f4 68 09 af 73 |b....@......h..s| +00000140 e2 f9 35 68 19 d7 56 66 dd 36 1f 8e 6e 1c 73 e4 |..5h..Vf.6..n.s.| +00000150 98 ef b0 f3 31 ae 58 de 91 56 a6 eb ee 4c f6 57 |....1.X..V...L.W| +00000160 5b 6c e7 f9 c3 51 c7 2c 78 40 c0 37 14 0d c4 12 |[l...Q.,x@.7....| +00000170 18 4c 96 24 69 19 53 de 07 a3 50 b4 00 fa cd 47 |.L.$i.S...P....G| +00000180 e4 a3 4f 3a 0c 44 82 b7 90 7d 55 6d 6f b1 68 04 |..O:.D...}Umo.h.| +00000190 02 3d 60 14 80 8b 4b 7d 13 55 5c 1b d2 73 f2 03 |.=`...K}.U\..s..| +000001a0 31 a1 12 f3 cc df 5f 2e 14 5d 15 7b 6c a8 66 10 |1....._..].{l.f.| +000001b0 3d ee 11 e0 bd 0f ff b6 d9 9d 2b b8 59 0c b5 f5 |=.........+.Y...| +000001c0 ec 78 80 bd 11 85 6b b7 67 01 25 5d 1f 14 26 4c |.x....k.g.%]..&L| +000001d0 60 48 0e 40 7f 2e a5 d9 09 25 e9 45 87 6e b3 a9 |`H.@.....%.E.n..| +000001e0 e2 19 5a 58 4c 3e 53 0e 1f d1 55 42 3f bc d0 26 |..ZXL>S...UB?..&| +000001f0 4e 9a dc 00 ac 2e 8b ac 4d e2 76 d0 80 80 09 87 |N.......M.v.....| +00000200 8b fe c6 9b c5 43 2d 56 b6 13 e2 eb 91 94 d9 0c |.....C-V........| +00000210 40 4f e6 96 af b2 c5 fb 75 9d 51 24 09 b0 8d 4f |@O......u.Q$...O| +00000220 68 c5 b1 7a 0e 22 03 84 21 14 b5 db f7 97 d4 60 |h..z."..!......`| +00000230 c9 ee 49 a0 9a 14 d4 bb 3c 54 91 61 ac 78 40 0f |..I......j.c9| +000002c0 64 e8 05 17 03 03 00 13 3b b0 06 df 04 01 7a 90 |d.......;.....z.| +000002d0 46 4a 2e 57 1c 66 26 f0 d8 4c ea |FJ.W.f&..L.| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv13-ClientAuthRequestedNotGiven b/libgo/go/crypto/tls/testdata/Server-TLSv13-ClientAuthRequestedNotGiven new file mode 100644 index 00000000000..c9c8728b6e3 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Server-TLSv13-ClientAuthRequestedNotGiven @@ -0,0 +1,109 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 e0 01 00 00 dc 03 03 d7 9c 79 99 50 |.............y.P| +00000010 c9 4b 3a e0 a1 36 a8 fc 40 bb 51 a9 71 a6 ba 2f |.K:..6..@.Q.q../| +00000020 1b ba 13 f3 b6 8b 2b 77 f1 60 27 20 a6 a3 e8 5a |......+w.`' ...Z| +00000030 4b cb 7c 64 05 b4 77 3b af 66 4b e3 5a b3 cb 57 |K.|d..w;.fK.Z..W| +00000040 84 d3 fa 5d 7f 5a cd 94 62 79 31 4a 00 08 13 02 |...].Z..by1J....| +00000050 13 03 13 01 00 ff 01 00 00 8b 00 00 00 0e 00 0c |................| +00000060 00 00 09 31 32 37 2e 30 2e 30 2e 31 00 0b 00 04 |...127.0.0.1....| +00000070 03 00 01 02 00 0a 00 0c 00 0a 00 1d 00 17 00 1e |................| +00000080 00 19 00 18 00 16 00 00 00 17 00 00 00 0d 00 1e |................| +00000090 00 1c 04 03 05 03 06 03 08 07 08 08 08 09 08 0a |................| +000000a0 08 0b 08 04 08 05 08 06 04 01 05 01 06 01 00 2b |...............+| +000000b0 00 03 02 03 04 00 2d 00 02 01 01 00 33 00 26 00 |......-.....3.&.| +000000c0 24 00 1d 00 20 c6 c0 3a af 99 9f ef 6d 59 6b bd |$... ..:....mYk.| +000000d0 c3 b0 8a 94 02 c8 fb 13 7d cb a8 3a f4 f1 e0 40 |........}..:...@| +000000e0 03 15 7a 95 06 |..z..| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 00 00 00 00 00 |....z...v.......| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 a6 a3 e8 5a |........... ...Z| +00000030 4b cb 7c 64 05 b4 77 3b af 66 4b e3 5a b3 cb 57 |K.|d..w;.fK.Z..W| +00000040 84 d3 fa 5d 7f 5a cd 94 62 79 31 4a 13 02 00 00 |...].Z..by1J....| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 2f |..+.....3.$... /| +00000060 e5 7d a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 |.}.G.bC.(.._.).0| +00000070 ff f6 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 14 |.........._X.;t.| +00000080 03 03 00 01 01 17 03 03 00 17 d8 15 a1 e7 a9 00 |................| +00000090 bf 9d 8d 63 5d ba b1 5a 08 c2 de 57 7e 73 61 5d |...c]..Z...W~sa]| +000000a0 2f 17 03 03 00 3c 59 ed f4 2a 62 56 2a 02 73 4f |/.......r....4| +00000350 2f 45 81 fe 17 03 03 00 99 ef 4a 43 25 8d dd 0d |/E........JC%...| +00000360 e5 af 9e e3 46 e1 84 de f1 68 5f 9b f6 70 17 6f |....F....h_..p.o| +00000370 7e 86 33 45 b6 13 f0 a8 a2 fd 08 1b 4a 4f 92 3f |~.3E........JO.?| +00000380 45 ef db 03 ff 1f 54 55 28 cc de 0e f5 6c af 5c |E.....TU(....l.\| +00000390 86 cc b1 e2 c7 0e ea 24 47 fb e0 37 e8 a2 e7 47 |.......$G..7...G| +000003a0 cd 9e da 02 e5 37 1f a9 b2 ea 57 f8 6f 63 be 5e |.....7....W.oc.^| +000003b0 38 be 1a 09 38 23 46 52 df cf 79 bc ce c1 da 23 |8...8#FR..y....#| +000003c0 34 97 c8 ce 81 74 d5 03 f4 71 ff 4b 17 e0 99 7c |4....t...q.K...|| +000003d0 31 bd c9 1e d5 2b d3 d4 ff dc 56 82 07 f5 a6 57 |1....+....V....W| +000003e0 0e ab 18 cf db 38 26 ff d9 51 c2 8f 70 b8 5b 84 |.....8&..Q..p.[.| +000003f0 80 27 17 03 03 00 45 95 7b 2b 46 29 0a 03 4f c6 |.'....E.{+F)..O.| +00000400 37 0c 31 e8 72 8a aa 00 db 90 e8 d3 1f c1 e1 eb |7.1.r...........| +00000410 03 02 bc ae dd 03 a7 28 55 7e 19 0d 5f 76 e6 fa |.......(U~.._v..| +00000420 03 91 c2 5a 10 1d c0 a0 85 3d d2 32 ec 65 af 83 |...Z.....=.2.e..| +00000430 25 d1 77 0f 41 d9 e7 43 56 04 4e fe |%.w.A..CV.N.| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 00 19 6c b2 53 5f 6e |...........l.S_n| +00000010 a9 6a b2 48 da d7 d5 b2 56 81 47 a9 7d a8 5c 6d |.j.H....V.G.}.\m| +00000020 7a a8 23 db 17 03 03 00 45 88 80 32 38 19 22 fd |z.#.....E..28.".| +00000030 09 5c a2 40 50 ba 9c 34 ad 4e 4c 70 7c 4d f0 0e |.\.@P..4.NLp|M..| +00000040 68 3f da d6 c0 6e 6e 29 fa ec d8 11 2e 20 94 38 |h?...nn)..... .8| +00000050 12 b9 08 27 3c e3 0a 8f 9a da cb 1f ab c9 f5 0e |...'<...........| +00000060 da a9 8c 66 24 de 2f b2 92 22 68 53 2f 68 |...f$./.."hS/h| +>>> Flow 4 (server to client) +00000000 17 03 03 00 a3 38 95 dc 12 b1 b8 df 96 ef 91 88 |.....8..........| +00000010 d4 d5 dc 35 ec 19 32 a3 2d 90 0b d5 03 f4 b2 b9 |...5..2.-.......| +00000020 4e 5f 4d b2 18 ae 44 d6 21 f1 7f ef a2 ab 3a 60 |N_M...D.!.....:`| +00000030 df a3 f3 6c 90 68 66 12 8c 3c c2 25 13 36 6c 1d |...l.hf..<.%.6l.| +00000040 51 e7 7e 75 f1 ac 54 fd ae 1b e0 b3 03 6f 0e 96 |Q.~u..T......o..| +00000050 91 5e 88 f5 a7 b6 f0 c5 3c ec a4 e1 3a 46 cd 41 |.^......<...:F.A| +00000060 60 dc 6f 13 d0 eb 76 7e b4 46 31 0f 23 22 0f b1 |`.o...v~.F1.#"..| +00000070 c8 91 14 42 ac 67 6f 83 92 a7 5b 2c 88 16 fc cf |...B.go...[,....| +00000080 ef 97 56 2f 2b 64 92 7d 1a ae a7 94 66 5d 35 f3 |..V/+d.}....f]5.| +00000090 77 63 c2 ef 82 d7 33 6d 0e 60 b2 a3 6b 01 aa 84 |wc....3m.`..k...| +000000a0 32 d0 df 47 e1 01 52 15 17 03 03 00 1e 05 90 37 |2..G..R........7| +000000b0 26 ed e0 a9 8d b1 07 26 42 6d 77 7c 19 aa c2 56 |&......&Bmw|...V| +000000c0 f1 92 eb de 96 46 f2 25 d9 93 df 17 03 03 00 13 |.....F.%........| +000000d0 ed b0 6c 70 1e 85 32 0d 8b ef 55 32 8c d6 fe 1d |..lp..2...U2....| +000000e0 c5 b0 4f |..O| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv13-ECDHE-ECDSA-AES b/libgo/go/crypto/tls/testdata/Server-TLSv13-ECDHE-ECDSA-AES new file mode 100644 index 00000000000..d2b02504a5d --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Server-TLSv13-ECDHE-ECDSA-AES @@ -0,0 +1,96 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 dc 01 00 00 d8 03 03 90 bc cf 62 d0 |..............b.| +00000010 bc 89 6b 84 ad 18 87 f5 9c 96 0e 02 3f ae a5 4b |..k.........?..K| +00000020 80 70 f8 54 47 b1 78 03 48 4d 06 20 ae 9e 3c 17 |.p.TG.x.HM. ..<.| +00000030 1a c6 fa 52 84 da ea a9 9c 08 e7 10 65 3a 65 4e |...R........e:eN| +00000040 d1 65 61 40 bf 7c ee db d4 f2 73 ff 00 04 13 01 |.ea@.|....s.....| +00000050 00 ff 01 00 00 8b 00 00 00 0e 00 0c 00 00 09 31 |...............1| +00000060 32 37 2e 30 2e 30 2e 31 00 0b 00 04 03 00 01 02 |27.0.0.1........| +00000070 00 0a 00 0c 00 0a 00 1d 00 17 00 1e 00 19 00 18 |................| +00000080 00 16 00 00 00 17 00 00 00 0d 00 1e 00 1c 04 03 |................| +00000090 05 03 06 03 08 07 08 08 08 09 08 0a 08 0b 08 04 |................| +000000a0 08 05 08 06 04 01 05 01 06 01 00 2b 00 03 02 03 |...........+....| +000000b0 04 00 2d 00 02 01 01 00 33 00 26 00 24 00 1d 00 |..-.....3.&.$...| +000000c0 20 ad 11 a7 07 20 9c cb 33 96 f4 0d 78 a1 89 55 | .... ..3...x..U| +000000d0 6c af 70 f4 ac d6 cb d9 0d 1b 13 fa 50 de 68 17 |l.p.........P.h.| +000000e0 1d |.| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 00 00 00 00 00 |....z...v.......| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 ae 9e 3c 17 |........... ..<.| +00000030 1a c6 fa 52 84 da ea a9 9c 08 e7 10 65 3a 65 4e |...R........e:eN| +00000040 d1 65 61 40 bf 7c ee db d4 f2 73 ff 13 01 00 00 |.ea@.|....s.....| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 2f |..+.....3.$... /| +00000060 e5 7d a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 |.}.G.bC.(.._.).0| +00000070 ff f6 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 14 |.........._X.;t.| +00000080 03 03 00 01 01 17 03 03 00 17 f1 16 14 8f 0a b5 |................| +00000090 92 fa 55 d7 fb 6c 33 04 ae c6 ed 3b 90 27 e9 ae |..U..l3....;.'..| +000000a0 e8 17 03 03 02 22 ca b1 97 19 9d da 2e 1d 12 f4 |....."..........| +000000b0 05 af 35 28 1e 85 9d 28 81 f0 5a 83 46 9c df f7 |..5(...(..Z.F...| +000000c0 58 2e 30 fa b9 07 00 cf fe 69 37 5e f2 75 a0 ef |X.0......i7^.u..| +000000d0 f3 ab 60 0b c5 09 72 bd b4 42 2f 45 24 3e 82 d0 |..`...r..B/E$>..| +000000e0 f1 a1 dd 3a de 6a b9 9d 85 2b 83 75 47 c9 d2 c3 |...:.j...+.uG...| +000000f0 25 91 85 c2 a1 97 6a 62 dd aa 19 11 94 e2 6b f9 |%.....jb......k.| +00000100 7d 5a bc 5e d4 64 bc 74 44 85 d1 7a eb 3a ef d5 |}Z.^.d.tD..z.:..| +00000110 96 f4 22 64 61 2b 79 77 ac 8b 61 69 cc eb ad fd |.."da+yw..ai....| +00000120 38 5e 61 74 d9 4f 70 82 06 3b 3e f8 a8 53 7c e8 |8^at.Op..;>..S|.| +00000130 9d 98 43 a1 af 86 ba d9 64 64 f0 e0 b0 8f 39 6b |..C.....dd....9k| +00000140 16 d6 92 09 8d 5b d0 34 f4 14 60 69 a0 28 73 3a |.....[.4..`i.(s:| +00000150 24 7f 81 4e 8b d1 50 49 1a c0 60 92 fd 02 47 6d |$..N..PI..`...Gm| +00000160 d8 97 62 b2 b4 57 8b d7 d1 b6 bf 19 40 cb 13 09 |..b..W......@...| +00000170 ef d6 55 66 39 88 29 e0 14 2d 06 98 d6 b6 bf a6 |..Uf9.)..-......| +00000180 04 10 47 d5 64 fe 38 69 db 33 a4 fc 12 de 83 5b |..G.d.8i.3.....[| +00000190 c9 8e 76 56 bc f7 dd ac 96 c6 a0 ed e5 43 0b 13 |..vV.........C..| +000001a0 1e 78 94 18 fd 57 50 79 08 91 18 aa 84 63 4e 46 |.x...WPy.....cNF| +000001b0 53 db e0 f3 9a 0b d6 13 20 36 aa 56 dd 7a 62 d9 |S....... 6.V.zb.| +000001c0 3f f6 bd 87 74 3c 86 d1 94 a1 04 79 a8 54 e4 8e |?...t<.....y.T..| +000001d0 11 d6 52 42 5c 4b 77 18 b9 d7 db f7 48 9a 69 e1 |..RB\Kw.....H.i.| +000001e0 2d b9 38 38 e4 e8 94 5e b1 7e 2c 81 96 6a a0 ed |-.88...^.~,..j..| +000001f0 bb 35 6a 8c 93 f2 6d 38 70 df 79 54 d9 45 c8 b8 |.5j...m8p.yT.E..| +00000200 b2 9c 0f 9f 70 34 8f ac b3 08 f5 3e b1 d2 5a d7 |....p4.....>..Z.| +00000210 7b ee f3 dc 9a d1 12 c3 77 24 76 9b bf 09 50 a7 |{.......w$v...P.| +00000220 3c ab 7f 1f 99 b5 02 8c ac 5e 85 cc 53 fd ca e0 |<........^..S...| +00000230 c7 e2 41 08 fd cb b0 79 0c 8b 02 4f 80 92 c2 cd |..A....y...O....| +00000240 6c a1 aa 75 d2 4c d1 25 40 7c 14 41 a7 15 20 a3 |l..u.L.%@|.A.. .| +00000250 a6 81 64 7c c0 c7 2d dd 82 84 ad 2a f4 06 f9 61 |..d|..-....*...a| +00000260 23 1c dd c6 ef 72 da 6b eb be 41 f0 b4 5f 9a 02 |#....r.k..A.._..| +00000270 ee a8 f3 bb 05 48 ec 50 a3 ff f3 94 bb d8 a9 6d |.....H.P.......m| +00000280 92 49 7c bf a1 eb 55 26 08 26 d3 80 d6 cb 05 ea |.I|...U&.&......| +00000290 d1 db bf 97 3d 10 ff 4e f6 05 33 23 68 95 31 42 |....=..N..3#h.1B| +000002a0 5a d5 30 61 79 c4 88 7f e1 be 28 ad 72 bb 78 36 |Z.0ay.....(.r.x6| +000002b0 ba bb 38 75 fb 97 33 b6 28 8c a2 f4 46 fe 37 d8 |..8u..3.(...F.7.| +000002c0 b0 67 63 97 c1 51 0c 61 17 03 03 00 a4 20 15 70 |.gc..Q.a..... .p| +000002d0 7a 69 b1 33 c2 e1 f5 9c 2b b2 06 1e 01 a6 7f 03 |zi.3....+.......| +000002e0 cd 00 13 02 3b 0c 2b 3f 85 d8 ed 6d 81 7e e9 b2 |....;.+?...m.~..| +000002f0 b6 be 7b 77 51 30 dd b5 fc 93 08 91 9e 46 e2 85 |..{wQ0.......F..| +00000300 74 3c 9a 04 26 86 b8 6c 98 99 57 7e 36 54 0d 90 |t<..&..l..W~6T..| +00000310 4c 55 65 77 69 59 b2 e5 5b a3 19 4a b0 72 3d 91 |LUewiY..[..J.r=.| +00000320 2e 5d 9b 8c 52 a1 e6 f5 22 c6 3c 0d 9b d8 9c b9 |.]..R...".<.....| +00000330 cb 90 51 bc 16 69 06 30 22 16 62 08 3b 3f 05 99 |..Q..i.0".b.;?..| +00000340 60 2a cc cf 29 f5 e1 b0 84 81 c8 63 00 d4 d4 13 |`*..)......c....| +00000350 b5 5d 4c 63 8a 60 3e 44 24 03 30 85 91 4c 3d f2 |.]Lc.`>D$.0..L=.| +00000360 2c c2 78 f2 c3 4c bb 90 60 0b 66 18 02 e7 5c 85 |,.x..L..`.f...\.| +00000370 19 17 03 03 00 35 49 76 5f ff 32 3a 09 7a 4b f2 |.....5Iv_.2:.zK.| +00000380 fe f3 38 b6 76 f4 12 f2 aa a3 ed b6 02 ab 0b b9 |..8.v...........| +00000390 3b 9d 00 51 f1 5c 96 23 6b 49 f8 32 9f 74 30 32 |;..Q.\.#kI.2.t02| +000003a0 4d af af ef d5 55 2c ff 2b a0 45 17 03 03 00 93 |M....U,.+.E.....| +000003b0 6e e0 6a f9 44 af c0 af 95 ab 1e ff fd 97 38 f5 |n.j.D.........8.| +000003c0 7b 24 70 da e2 4e 8b dc 9b 49 84 fe 73 0a b0 7e |{$p..N...I..s..~| +000003d0 cf 14 f7 8a 67 e7 74 bd ee 82 93 c6 27 a2 bd 1e |....g.t.....'...| +000003e0 cb 71 06 af 65 dd f0 d9 91 81 b0 f8 21 34 48 d1 |.q..e.......!4H.| +000003f0 c4 e0 e3 19 a8 b4 48 b7 3a be 52 e5 7c a8 a3 c2 |......H.:.R.|...| +00000400 08 6c ac 66 4d 36 cf a1 9d 1f 72 c5 09 20 db 05 |.l.fM6....r.. ..| +00000410 e5 0a 44 af 4a d8 32 38 19 7d 28 e3 05 23 99 66 |..D.J.28.}(..#.f| +00000420 f6 ad 77 02 7e 00 67 c1 71 58 b9 89 3c 93 15 95 |..w.~.g.qX..<...| +00000430 ee 38 e2 ea c0 73 fe da e4 75 6d 38 ca 54 0b bf |.8...s...um8.T..| +00000440 f0 af 86 |...| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 00 35 23 02 12 13 f1 |..........5#....| +00000010 db fa 70 c0 92 85 8a d3 fa 80 1b 5c a6 22 ff 20 |..p........\.". | +00000020 5d bf 1d 61 58 34 c0 48 6f e1 26 a6 bf bc 76 c7 |]..aX4.Ho.&...v.| +00000030 8b da ee 54 64 30 c4 5c b1 61 67 82 29 bb 3f 4b |...Td0.\.ag.).?K| +>>> Flow 4 (server to client) +00000000 17 03 03 00 1e 95 c0 53 e2 37 94 09 83 1e 7e 23 |.......S.7....~#| +00000010 dc 9f 02 5e 91 19 b6 f9 72 0d 38 3f 25 ae b2 5f |...^....r.8?%.._| +00000020 4b f2 78 17 03 03 00 13 d2 ad 73 d6 f3 21 ab 7c |K.x.......s..!.|| +00000030 02 dd 63 ff cf d7 34 ca 71 3d 70 |..c...4.q=p| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv13-ExportKeyingMaterial b/libgo/go/crypto/tls/testdata/Server-TLSv13-ExportKeyingMaterial new file mode 100644 index 00000000000..078739c7502 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Server-TLSv13-ExportKeyingMaterial @@ -0,0 +1,103 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 e4 01 00 00 e0 03 03 40 53 50 a3 f5 |...........@SP..| +00000010 3a 20 4f 16 ef 9c a4 1c a3 10 1d 93 cb ea 1f 69 |: O............i| +00000020 6b aa 50 ae a8 01 7e 65 d9 7b 5c 20 8c 9b cc d4 |k.P...~e.{\ ....| +00000030 6b 07 4d 1e d9 69 d2 d8 a0 a0 d5 b7 75 d8 e3 d8 |k.M..i......u...| +00000040 c4 ac f7 d2 6f e5 f5 8f 46 9a bf 85 00 08 13 02 |....o...F.......| +00000050 13 03 13 01 00 ff 01 00 00 8f 00 00 00 0e 00 0c |................| +00000060 00 00 09 31 32 37 2e 30 2e 30 2e 31 00 0b 00 04 |...127.0.0.1....| +00000070 03 00 01 02 00 0a 00 0c 00 0a 00 1d 00 17 00 1e |................| +00000080 00 19 00 18 00 23 00 00 00 16 00 00 00 17 00 00 |.....#..........| +00000090 00 0d 00 1e 00 1c 04 03 05 03 06 03 08 07 08 08 |................| +000000a0 08 09 08 0a 08 0b 08 04 08 05 08 06 04 01 05 01 |................| +000000b0 06 01 00 2b 00 03 02 03 04 00 2d 00 02 01 01 00 |...+......-.....| +000000c0 33 00 26 00 24 00 1d 00 20 81 67 45 ec b4 08 4d |3.&.$... .gE...M| +000000d0 a6 50 79 b4 d4 a9 d1 35 51 2b db 8d b7 e7 7c 3c |.Py....5Q+....|<| +000000e0 fd 0f 4b 47 87 e1 bb fb 2d |..KG....-| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 00 00 00 00 00 |....z...v.......| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 8c 9b cc d4 |........... ....| +00000030 6b 07 4d 1e d9 69 d2 d8 a0 a0 d5 b7 75 d8 e3 d8 |k.M..i......u...| +00000040 c4 ac f7 d2 6f e5 f5 8f 46 9a bf 85 13 02 00 00 |....o...F.......| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 2f |..+.....3.$... /| +00000060 e5 7d a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 |.}.G.bC.(.._.).0| +00000070 ff f6 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 14 |.........._X.;t.| +00000080 03 03 00 01 01 17 03 03 00 17 d2 bf e0 2f ba e9 |............./..| +00000090 84 f5 8b 96 93 ac de 94 3b 92 03 ca db 43 f4 55 |........;....C.U| +000000a0 12 17 03 03 02 6d 54 36 b6 78 fb bf 9f 36 02 78 |.....mT6.x...6.x| +000000b0 b3 92 50 c9 ab 85 b6 57 69 18 10 c1 fe da d4 05 |..P....Wi.......| +000000c0 89 db 62 bd 83 b0 82 38 29 5f ce 53 88 2d f2 cd |..b....8)_.S.-..| +000000d0 6a d7 1d c0 c5 03 e7 e4 4b ec eb bf 95 8e d5 9b |j.......K.......| +000000e0 65 45 09 52 ef 29 60 7b 22 61 6f ca 1b 3d 30 a4 |eE.R.)`{"ao..=0.| +000000f0 c4 c4 06 55 39 5e 3a ef a2 62 61 35 6c c4 fc 8b |...U9^:..ba5l...| +00000100 19 dc c1 b0 8d dd ba d0 9e 87 65 1c 8d 73 6c 82 |..........e..sl.| +00000110 e4 45 e9 a9 53 94 20 ba 19 7e 4e 7e fb 14 dc 5d |.E..S. ..~N~...]| +00000120 86 19 0b fe f8 9c 7e 61 8e 17 e6 59 12 c2 e0 6a |......~a...Y...j| +00000130 52 c0 25 05 30 c8 f7 d6 54 69 15 ca c9 8e 96 1d |R.%.0...Ti......| +00000140 42 55 1f 9a 9b 03 95 af 74 05 be 5e 51 35 8b 1f |BU......t..^Q5..| +00000150 24 0a 13 03 90 fc c0 c4 22 c3 f0 8a f2 60 a8 ff |$......."....`..| +00000160 7b 04 48 10 3e 42 da e5 c2 7b 72 9c e1 d6 b5 56 |{.H.>B...{r....V| +00000170 f7 69 ce 46 67 33 e4 d3 e5 61 43 b2 57 e8 b2 43 |.i.Fg3...aC.W..C| +00000180 84 ac 75 15 d1 cb 70 53 99 1c 29 9a 21 bb c0 d3 |..u...pS..).!...| +00000190 66 8a be 16 b1 67 1b 60 d3 2f c6 a3 7e f3 3b 4f |f....g.`./..~.;O| +000001a0 78 4d ec 1f 9f 6d 46 1c 43 2f 50 ad 44 75 93 49 |xM...mF.C/P.Du.I| +000001b0 e2 29 c4 be aa 22 51 f1 17 1a 20 97 8a 23 06 2c |.)..."Q... ..#.,| +000001c0 93 b6 9d 11 5a 55 34 d9 f1 a4 c6 5b 84 f6 bb 0c |....ZU4....[....| +000001d0 a0 7c a2 25 47 df a6 22 c8 df e5 ae 74 1c f3 db |.|.%G.."....t...| +000001e0 3c 04 6f fa 86 76 c9 be ae 2a e0 64 65 d2 8f 9a |<.o..v...*.de...| +000001f0 7b a2 38 4d 74 8d 44 ad ef c1 12 0b ca 64 6c b5 |{.8Mt.D......dl.| +00000200 13 03 2c b4 6a e8 78 ba 57 d5 ef 9a d1 1d 7e 92 |..,.j.x.W.....~.| +00000210 58 52 78 c2 c5 e2 f8 e9 2d 06 28 88 19 d4 19 7b |XRx.....-.(....{| +00000220 7f 41 ea ed f9 9e 14 f1 9b 3f dc f7 bc 35 20 ca |.A.......?...5 .| +00000230 fc 8f b8 df ee ef 83 50 c4 41 91 ae 83 4b bd d1 |.......P.A...K..| +00000240 00 e1 3f 70 5d cb 40 a6 77 70 cd 9a 09 5b 05 14 |..?p].@.wp...[..| +00000250 83 b9 7c 8d 1c e1 7f 6e 41 1a b9 8c 70 2a 95 01 |..|....nA...p*..| +00000260 ef 19 0c 59 7d 47 b4 64 7b 91 5e 9b 02 c5 ed ee |...Y}G.d{.^.....| +00000270 d4 9b ad 12 70 d1 d9 6b 02 26 b5 48 4e 23 bb 61 |....p..k.&.HN#.a| +00000280 ae c7 82 74 a9 68 59 b1 66 07 b8 e3 93 0f 2c 9f |...t.hY.f.....,.| +00000290 8d 8d f1 e8 3f b7 2c 64 90 4f 88 7f 41 78 66 ba |....?.,d.O..Axf.| +000002a0 26 eb 1c 8b 70 47 f5 78 cb fe 66 34 6f 74 b1 98 |&...pG.x..f4ot..| +000002b0 ca 12 f5 91 8c cb 15 85 eb 77 ad af 76 f8 3f 3f |.........w..v.??| +000002c0 cb 86 82 fe 1e 78 1e d3 16 c2 b7 e6 a6 2b a0 6c |.....x.......+.l| +000002d0 da 99 3f dd 3b 0b 10 3b 16 bd d9 4f 45 c3 12 b5 |..?.;..;...OE...| +000002e0 14 1b 53 33 56 c1 f4 7c 4a 47 b9 c2 b0 bd 4e 78 |..S3V..|JG....Nx| +000002f0 e1 6f 76 05 d1 e3 af 01 f8 b4 e6 23 12 11 cf 43 |.ov........#...C| +00000300 91 9d eb be d8 6b 9c d2 fd 3b b5 3b 8c 52 4e 12 |.....k...;.;.RN.| +00000310 df 26 42 17 03 03 00 99 fc fb 50 ba e0 83 07 bb |.&B.......P.....| +00000320 13 4f 7c 1e 5f 35 e5 2f b9 c0 40 cb 51 9a 38 a6 |.O|._5./..@.Q.8.| +00000330 bf 1a 22 e3 ea 8b 5e 30 e0 b2 2b 40 aa 76 62 bc |.."...^0..+@.vb.| +00000340 c5 e3 3c f3 2a 10 2e 35 58 2b 5e c1 56 da 78 a9 |..<.*..5X+^.V.x.| +00000350 57 b5 46 1f d8 ad 59 3c 5a b8 37 be 66 86 d0 ad |W.F...Y..]_V| +000003b0 05 17 03 03 00 45 81 1e e7 bb e8 81 f4 41 12 af |.....E.......A..| +000003c0 fb f0 8f bd d0 d6 b3 10 a5 1e d6 0c f7 aa 01 15 |................| +000003d0 9d 30 5b 65 e1 fd 3e 72 3d 43 62 21 02 0e ec da |.0[e..>r=Cb!....| +000003e0 ec 74 2c e2 22 84 c9 90 18 71 f8 ef db 3f 05 d6 |.t,."....q...?..| +000003f0 91 09 46 c2 5c 2b f7 03 39 2b 3e 17 03 03 00 a3 |..F.\+..9+>.....| +00000400 53 cc 75 04 8c c5 25 70 1f 4b 9c 04 92 af 1a 3f |S.u...%p.K.....?| +00000410 26 1e 00 98 fa e3 c2 25 63 ca d4 03 fd 6c 94 a0 |&......%c....l..| +00000420 0a 87 5f 68 63 52 72 25 69 3f 21 66 f6 a6 00 2a |.._hcRr%i?!f...*| +00000430 25 e3 1e 95 f3 bd a8 22 bc 9a 74 f0 41 5d b1 30 |%......"..t.A].0| +00000440 36 ff 13 09 d9 69 7f 16 35 11 34 0e 65 2e e7 52 |6....i..5.4.e..R| +00000450 b4 6e a1 dc 06 fe a3 3e 3b eb 79 fe d0 e1 e8 76 |.n.....>;.y....v| +00000460 e2 0e 49 78 c3 cf c5 31 ce 7f 9b d6 c5 6d 3f 7b |..Ix...1.....m?{| +00000470 79 9a 5d a7 c3 3b 58 eb a2 43 55 c6 42 7a a8 34 |y.]..;X..CU.Bz.4| +00000480 6e c9 47 aa 5e 44 4a bd 4b 89 28 ab ac 5a 95 dc |n.G.^DJ.K.(..Z..| +00000490 96 99 28 dc 29 04 10 f3 8c 49 45 b7 29 69 3d 9e |..(.)....IE.)i=.| +000004a0 dd fe 4a |..J| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 00 45 3f e6 f9 73 13 |..........E?..s.| +00000010 98 fa c1 e1 84 7a 0c 10 eb 9a bf 2b df c1 44 26 |.....z.....+..D&| +00000020 36 1a 95 02 b4 12 67 7c e2 7d f3 1e 54 79 7b 51 |6.....g|.}..Ty{Q| +00000030 e6 13 94 cb 00 cc 25 fb 6e 8a 35 4e f0 f0 95 34 |......%.n.5N...4| +00000040 53 fd 7e 37 d2 a8 0a 71 a7 2d 8d 58 2e ae 27 34 |S.~7...q.-.X..'4| +>>> Flow 4 (server to client) +00000000 17 03 03 00 1e 07 34 2c 55 6a c5 14 e7 0a 51 94 |......4,Uj....Q.| +00000010 74 ad e1 c0 4d e8 1c 3e ad 3e 8e 71 e5 60 9c d8 |t...M..>.>.q.`..| +00000020 6a 44 ac 17 03 03 00 13 09 9e 97 ff 3d b8 f1 a6 |jD..........=...| +00000030 5d f9 8f b0 65 93 31 6b 9d 81 76 |]...e.1k..v| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv13-HelloRetryRequest b/libgo/go/crypto/tls/testdata/Server-TLSv13-HelloRetryRequest new file mode 100644 index 00000000000..96a5488c730 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Server-TLSv13-HelloRetryRequest @@ -0,0 +1,129 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 da 01 00 00 d6 03 03 ab e7 6d 22 09 |.............m".| +00000010 bf 08 ef a1 7e 7c 8d ea fd a5 39 43 62 84 67 a8 |....~|....9Cb.g.| +00000020 df b1 a1 3a d7 37 dc 0d ef 27 54 20 20 f3 5b 41 |...:.7...'T .[A| +00000030 67 3e 30 d8 8e 2d 0f a1 c2 df 86 48 8c 05 bb d7 |g>0..-.....H....| +00000040 73 30 80 86 cf 2c 85 d1 2a fe 21 36 00 08 13 02 |s0...,..*.!6....| +00000050 13 03 13 01 00 ff 01 00 00 85 00 00 00 0e 00 0c |................| +00000060 00 00 09 31 32 37 2e 30 2e 30 2e 31 00 0b 00 04 |...127.0.0.1....| +00000070 03 00 01 02 00 0a 00 06 00 04 00 1d 00 17 00 16 |................| +00000080 00 00 00 17 00 00 00 0d 00 1e 00 1c 04 03 05 03 |................| +00000090 06 03 08 07 08 08 08 09 08 0a 08 0b 08 04 08 05 |................| +000000a0 08 06 04 01 05 01 06 01 00 2b 00 03 02 03 04 00 |.........+......| +000000b0 2d 00 02 01 01 00 33 00 26 00 24 00 1d 00 20 1a |-.....3.&.$... .| +000000c0 ae 88 dd 6c 7c 4c fb e5 65 ca 8e 63 a1 97 4c d3 |...l|L..e..c..L.| +000000d0 33 ff 00 95 db 0b ce 67 62 26 78 27 52 f0 5c |3......gb&x'R.\| +>>> Flow 2 (server to client) +00000000 16 03 03 00 58 02 00 00 54 03 03 cf 21 ad 74 e5 |....X...T...!.t.| +00000010 9a 61 11 be 1d 8c 02 1e 65 b8 91 c2 a2 11 16 7a |.a......e......z| +00000020 bb 8c 5e 07 9e 09 e2 c8 a8 33 9c 20 20 f3 5b 41 |..^......3. .[A| +00000030 67 3e 30 d8 8e 2d 0f a1 c2 df 86 48 8c 05 bb d7 |g>0..-.....H....| +00000040 73 30 80 86 cf 2c 85 d1 2a fe 21 36 13 02 00 00 |s0...,..*.!6....| +00000050 0c 00 2b 00 02 03 04 00 33 00 02 00 17 14 03 03 |..+.....3.......| +00000060 00 01 01 |...| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 16 03 03 00 fb 01 00 00 f7 03 |................| +00000010 03 ab e7 6d 22 09 bf 08 ef a1 7e 7c 8d ea fd a5 |...m".....~|....| +00000020 39 43 62 84 67 a8 df b1 a1 3a d7 37 dc 0d ef 27 |9Cb.g....:.7...'| +00000030 54 20 20 f3 5b 41 67 3e 30 d8 8e 2d 0f a1 c2 df |T .[Ag>0..-....| +00000040 86 48 8c 05 bb d7 73 30 80 86 cf 2c 85 d1 2a fe |.H....s0...,..*.| +00000050 21 36 00 08 13 02 13 03 13 01 00 ff 01 00 00 a6 |!6..............| +00000060 00 00 00 0e 00 0c 00 00 09 31 32 37 2e 30 2e 30 |.........127.0.0| +00000070 2e 31 00 0b 00 04 03 00 01 02 00 0a 00 06 00 04 |.1..............| +00000080 00 1d 00 17 00 16 00 00 00 17 00 00 00 0d 00 1e |................| +00000090 00 1c 04 03 05 03 06 03 08 07 08 08 08 09 08 0a |................| +000000a0 08 0b 08 04 08 05 08 06 04 01 05 01 06 01 00 2b |...............+| +000000b0 00 03 02 03 04 00 2d 00 02 01 01 00 33 00 47 00 |......-.....3.G.| +000000c0 45 00 17 00 41 04 22 3e 1f 4b 0f 2e f4 af bf 6c |E...A.">.K.....l| +000000d0 d7 35 69 72 23 00 3f 16 6a 8e 00 3e 2b 8f f8 60 |.5ir#.?.j..>+..`| +000000e0 17 e8 e8 80 f3 28 5d cd 1f f7 99 88 59 01 a5 d7 |.....(].....Y...| +000000f0 34 d0 d9 38 5b 73 3e d6 3c c8 9e 39 8f 45 d0 37 |4..8[s>.<..9.E.7| +00000100 aa 5b 8e 59 2f 0c |.[.Y/.| +>>> Flow 4 (server to client) +00000000 16 03 03 00 9b 02 00 00 97 03 03 00 00 00 00 00 |................| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 20 f3 5b 41 |........... .[A| +00000030 67 3e 30 d8 8e 2d 0f a1 c2 df 86 48 8c 05 bb d7 |g>0..-.....H....| +00000040 73 30 80 86 cf 2c 85 d1 2a fe 21 36 13 02 00 00 |s0...,..*.!6....| +00000050 4f 00 2b 00 02 03 04 00 33 00 45 00 17 00 41 04 |O.+.....3.E...A.| +00000060 1e 18 37 ef 0d 19 51 88 35 75 71 b5 e5 54 5b 12 |..7...Q.5uq..T[.| +00000070 2e 8f 09 67 fd a7 24 20 3e b2 56 1c ce 97 28 5e |...g..$ >.V...(^| +00000080 f8 2b 2d 4f 9e f1 07 9f 6c 4b 5b 83 56 e2 32 42 |.+-O....lK[.V.2B| +00000090 e9 58 b6 d7 49 a6 b5 68 1a 41 03 56 6b dc 5a 89 |.X..I..h.A.Vk.Z.| +000000a0 17 03 03 00 17 4c 08 ad d8 7f 86 a1 1f b2 dc 89 |.....L..........| +000000b0 38 bf d4 75 ff 9e db 74 59 3c 86 5c 17 03 03 02 |8..u...tY<.\....| +000000c0 6d f3 65 9c 3b 80 4f c0 c4 a6 e5 e1 32 49 06 13 |m.e.;.O.....2I..| +000000d0 b8 60 18 50 c4 1c 38 f7 1a 42 89 49 14 40 4c fc |.`.P..8..B.I.@L.| +000000e0 7c 3c 2b 70 2d 8b e7 99 f8 2e 1d 50 c8 b3 8b cd ||<+p-......P....| +000000f0 59 a8 f7 89 4d 93 c6 1e f9 94 e3 69 25 92 48 61 |Y...M......i%.Ha| +00000100 06 4a 89 f5 4b 57 93 a7 20 23 0b bb e5 00 8a 43 |.J..KW.. #.....C| +00000110 fb 98 29 08 df 32 89 1a d6 87 f0 97 dc 8b f5 3f |..)..2.........?| +00000120 e2 54 32 2e 23 04 c4 87 0a 0f 99 ef c5 28 64 13 |.T2.#........(d.| +00000130 6c 62 29 e1 3a 21 84 bb 56 f9 92 24 58 75 48 8b |lb).:!..V..$XuH.| +00000140 25 59 9f e1 a5 aa ee 44 3e 64 e5 af ac 0e 6e 18 |%Y.....D>d....n.| +00000150 6e dc 43 87 4d bd 26 1e c1 0a 5f 8b a7 2d 8c cc |n.C.M.&..._..-..| +00000160 94 25 60 59 33 ef 38 93 a3 d1 63 5b 9b ae 10 2f |.%`Y3.8...c[.../| +00000170 63 af 27 32 35 b8 db 75 e8 e6 19 09 8e f3 b1 4d |c.'25..u.......M| +00000180 b6 8a 83 6c 88 41 3a d9 1e da ad b3 06 3b ba 41 |...l.A:......;.A| +00000190 f9 fd 23 46 a5 9e 8a 11 31 d9 f6 8c 56 32 eb a8 |..#F....1...V2..| +000001a0 7f c1 0a d1 78 c7 46 cb b5 f7 3f 7e 56 39 75 45 |....x.F...?~V9uE| +000001b0 5b fb 84 b4 16 28 14 4c 45 9d f4 8d 65 38 5d 93 |[....(.LE...e8].| +000001c0 53 ab 5e ae bc 9c 73 4b cb d2 85 cd d8 a7 00 67 |S.^...sK.......g| +000001d0 f8 0c c3 81 0b fc 5b f8 74 4f 6a 2f 3c 57 68 22 |......[.tOj/......,b..x.L| +00000450 99 cb 38 ad ef a4 00 42 51 04 3b b8 4b 06 89 ee |..8....BQ.;.K...| +00000460 33 48 3e c7 72 9c de f2 e4 23 5f 76 33 db cb 92 |3H>.r....#_v3...| +00000470 92 b0 90 ea 25 4f 05 68 b3 8e 59 9c 36 8b 1b b0 |....%O.h..Y.6...| +00000480 02 73 96 bf e6 fe 80 2c 32 26 ac 91 33 af cd 86 |.s.....,2&..3...| +00000490 57 cc de d3 a2 eb 9e 43 ea 5b d4 56 f0 1b 95 3b |W......C.[.V...;| +000004a0 a1 da 33 21 cb 0b 48 92 35 73 0c 33 01 c4 6d 79 |..3!..H.5s.3..my| +000004b0 7a bb 39 a1 32 3a 85 18 9f 91 a7 e1 42 0a |z.9.2:......B.| +>>> Flow 5 (client to server) +00000000 17 03 03 00 45 b7 e2 1a d9 6a aa c1 54 e3 9a 42 |....E....j..T..B| +00000010 11 cd 13 c2 dc 5a b0 fa e3 62 09 a1 4b 9a a1 b3 |.....Z...b..K...| +00000020 84 7b 63 29 69 47 5c bf ca c6 36 2f ae e0 2f 6e |.{c)iG\...6/../n| +00000030 1b 42 c4 c9 65 17 e8 bd c4 97 5b e4 5f 27 86 d2 |.B..e.....[._'..| +00000040 1f 97 1f 68 9a 1f ee 09 04 82 |...h......| +>>> Flow 6 (server to client) +00000000 17 03 03 00 1e ed fb 39 62 34 b9 5d a3 db 30 fe |.......9b4.]..0.| +00000010 ed 5e 92 77 44 7e fb 77 84 5e 54 6b 11 7c 27 99 |.^.wD~.w.^Tk.|'.| +00000020 80 66 a5 17 03 03 00 13 9b 78 92 3b 84 3d cb 69 |.f.......x.;.=.i| +00000030 86 2b d1 db cc 91 d3 00 55 43 2f |.+......UC/| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv13-IssueTicket b/libgo/go/crypto/tls/testdata/Server-TLSv13-IssueTicket new file mode 100644 index 00000000000..1a8b3846997 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Server-TLSv13-IssueTicket @@ -0,0 +1,103 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 e4 01 00 00 e0 03 03 26 46 4d 2d 7d |...........&FM-}| +00000010 5c dc ef fb 2b 8b f7 15 4b ba 8b 1a 26 da f6 9b |\...+...K...&...| +00000020 e6 3c c6 8c a0 f9 6c 60 f6 11 81 20 53 f8 00 fb |.<....l`... S...| +00000030 8b be ff 98 74 c9 d9 3d aa 40 4d 0e 05 96 f9 30 |....t..=.@M....0| +00000040 d6 f5 7b f1 bc 31 18 30 5f 24 03 a8 00 08 13 02 |..{..1.0_$......| +00000050 13 03 13 01 00 ff 01 00 00 8f 00 00 00 0e 00 0c |................| +00000060 00 00 09 31 32 37 2e 30 2e 30 2e 31 00 0b 00 04 |...127.0.0.1....| +00000070 03 00 01 02 00 0a 00 0c 00 0a 00 1d 00 17 00 1e |................| +00000080 00 19 00 18 00 23 00 00 00 16 00 00 00 17 00 00 |.....#..........| +00000090 00 0d 00 1e 00 1c 04 03 05 03 06 03 08 07 08 08 |................| +000000a0 08 09 08 0a 08 0b 08 04 08 05 08 06 04 01 05 01 |................| +000000b0 06 01 00 2b 00 03 02 03 04 00 2d 00 02 01 01 00 |...+......-.....| +000000c0 33 00 26 00 24 00 1d 00 20 b6 ad 52 4d 37 b1 eb |3.&.$... ..RM7..| +000000d0 1e 57 2b a8 5d e7 43 b9 a0 98 47 8b ff 40 a9 14 |.W+.].C...G..@..| +000000e0 9e 23 26 c7 47 a7 cb f6 47 |.#&.G...G| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 00 00 00 00 00 |....z...v.......| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 53 f8 00 fb |........... S...| +00000030 8b be ff 98 74 c9 d9 3d aa 40 4d 0e 05 96 f9 30 |....t..=.@M....0| +00000040 d6 f5 7b f1 bc 31 18 30 5f 24 03 a8 13 02 00 00 |..{..1.0_$......| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 2f |..+.....3.$... /| +00000060 e5 7d a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 |.}.G.bC.(.._.).0| +00000070 ff f6 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 14 |.........._X.;t.| +00000080 03 03 00 01 01 17 03 03 00 17 b9 4a b7 2a b5 48 |...........J.*.H| +00000090 bc ba 18 3e 1a 99 bd fa 0d fc 2a 5d 52 93 b5 97 |...>......*]R...| +000000a0 5c 17 03 03 02 6d 30 8f 19 00 1c fa 90 a7 6c 08 |\....m0.......l.| +000000b0 6f 5a e8 d8 e0 3e 81 30 f1 11 85 7e 35 47 b3 d0 |oZ...>.0...~5G..| +000000c0 48 95 ce af e6 2f fc 22 0a 5f 56 bd 1c 7d 8c 48 |H..../."._V..}.H| +000000d0 f3 ad b7 5b 2e 4b d8 d1 16 46 7a ba c3 71 02 3c |...[.K...Fz..q.<| +000000e0 54 75 b8 92 02 b1 b9 cc 15 c4 fa d1 2d ba 0d 9f |Tu..........-...| +000000f0 65 a1 78 0d 8f d6 1c be fa 42 1f d7 48 1a 8e 11 |e.x......B..H...| +00000100 64 4c 12 ef bd 65 9d b4 31 18 4f 2a 77 c4 1f 1b |dL...e..1.O*w...| +00000110 90 90 37 ea 59 aa 05 bf 45 04 fb e8 a9 3f f9 11 |..7.Y...E....?..| +00000120 f9 25 95 fc d4 8e 5c 84 19 f3 4c e4 05 c3 db 8c |.%....\...L.....| +00000130 07 f9 b3 b0 6d ce d3 14 aa 78 17 f9 2f 14 1b bc |....m....x../...| +00000140 4b 23 29 f1 2e 7c 3b 71 9b cf 0b d5 02 48 5e ce |K#)..|;q.....H^.| +00000150 9c 43 dd 29 17 42 0b 9d 0e a7 a7 93 e1 37 cc 97 |.C.).B.......7..| +00000160 df 0f 2d d3 f7 01 08 34 5f bd ad 12 12 6f 87 56 |..-....4_....o.V| +00000170 4e 99 16 f6 6e 61 5c f0 0e 30 0b d5 38 37 70 97 |N...na\..0..87p.| +00000180 ed e1 79 74 00 cc 55 be a9 32 7d 72 50 27 42 c9 |..yt..U..2}rP'B.| +00000190 99 64 ea bd 3e c8 4f b0 cc 31 ef 10 57 9f c1 02 |.d..>.O..1..W...| +000001a0 ca db f6 d6 53 94 d2 83 57 71 e9 06 7a dd 46 3b |....S...Wq..z.F;| +000001b0 b1 2c f8 87 1c 8b 8a 04 05 2f d0 32 54 9a 80 33 |.,......./.2T..3| +000001c0 b2 95 e5 62 71 e9 1a 3b ea 64 ee 81 29 c4 ea 53 |...bq..;.d..)..S| +000001d0 de 6b 27 b1 04 48 27 ba 7f 28 aa 9e 15 82 49 a9 |.k'..H'..(....I.| +000001e0 43 3d d3 33 82 50 a9 4e 38 ed 8d f8 e8 0e 11 ab |C=.3.P.N8.......| +000001f0 8b 6e 63 e9 c1 cf ee 45 4f a0 62 e7 2e 00 b8 61 |.nc....EO.b....a| +00000200 2a 29 5e 04 e2 81 11 b3 64 f3 b5 b0 ec ae 63 6c |*)^.....d.....cl| +00000210 27 56 ac f2 09 d3 a4 c8 18 4a 55 c8 ff fd 8b 42 |'V.......JU....B| +00000220 63 00 3a c9 25 40 b7 8d 17 f3 95 76 7b 01 cf bc |c.:.%@.....v{...| +00000230 9b a7 4c 03 4a 7d 3c 54 16 8f 84 ca 2f 1a f5 12 |..L.J}.| +00000330 f1 1e 11 c7 72 f5 65 b4 03 38 f2 48 16 a9 20 31 |....r.e..8.H.. 1| +00000340 c2 52 4c 33 92 70 45 91 19 f4 5c 08 77 49 af 25 |.RL3.pE...\.wI.%| +00000350 8e b5 bd 3f e3 93 dc e6 26 b0 8a 30 69 f1 86 17 |...?....&..0i...| +00000360 72 31 66 87 2f d4 42 70 4c e0 58 61 6e b2 38 0b |r1f./.BpL.Xan.8.| +00000370 13 ad 32 83 14 81 d4 af dd 9f 17 09 af 3b 64 78 |..2..........;dx| +00000380 c8 63 da 05 70 47 54 f9 c6 f5 f8 e6 97 e1 d0 87 |.c..pGT.........| +00000390 aa 5a e7 5b d3 a3 b3 ce be 56 30 e7 4d ad 43 bd |.Z.[.....V0.M.C.| +000003a0 5e 88 9a ef 34 78 06 eb 6f 8f 04 39 47 6a c2 3d |^...4x..o..9Gj.=| +000003b0 ba 17 03 03 00 45 89 37 db 55 b2 9e 6e 31 a0 9b |.....E.7.U..n1..| +000003c0 97 51 27 13 b0 7e 2e 85 4a 9b 72 b0 fe c5 e4 12 |.Q'..~..J.r.....| +000003d0 fd ea 29 d5 bb ae a2 24 e2 0d b4 cd 28 92 5c 88 |..)....$....(.\.| +000003e0 98 b4 e4 8e a8 46 c6 a0 0e c0 73 ba f7 62 3a 43 |.....F....s..b:C| +000003f0 1a c7 d3 4b 5b 47 7b 44 8b bb 7b 17 03 03 00 a3 |...K[G{D..{.....| +00000400 f1 5f 26 2b 1c 99 6d 1d 55 bc a7 2f ae c8 3a ed |._&+..m.U../..:.| +00000410 5a 16 3c 83 e8 d4 18 7e 84 fa ba 21 0f 30 b0 05 |Z.<....~...!.0..| +00000420 ec 45 92 53 80 7a 78 d4 9e e0 02 e9 11 74 a6 e2 |.E.S.zx......t..| +00000430 87 7e 43 26 c0 18 46 6b 28 e5 f4 92 89 5c 0d b5 |.~C&..Fk(....\..| +00000440 8d 90 55 4f 3b 0a f4 ba 1b fb 60 54 46 23 03 28 |..UO;.....`TF#.(| +00000450 6e c3 3b 4d 69 62 65 d5 4e 95 46 c9 f2 8d ae f9 |n.;Mibe.N.F.....| +00000460 53 a6 65 da ca 1e b7 f7 80 a8 97 97 ca 38 14 a5 |S.e..........8..| +00000470 34 81 e2 68 12 fb 45 90 c2 f9 c9 70 fe 28 b8 b5 |4..h..E....p.(..| +00000480 6c 1d 2c d4 07 69 1d eb 1f 4b df ba ca 5e e0 65 |l.,..i...K...^.e| +00000490 ad ee be 41 02 78 23 19 b9 ea 1d 65 20 43 0e 3d |...A.x#....e C.=| +000004a0 11 03 b3 |...| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 00 45 88 0d 45 f0 61 |..........E..E.a| +00000010 a3 d0 7b 33 9e 17 c5 c3 6f 8f f6 67 b8 03 65 5f |..{3....o..g..e_| +00000020 bf 94 e9 1d 58 eb 4d 12 68 8a 96 42 6f 08 08 b8 |....X.M.h..Bo...| +00000030 be ce 2c f0 c4 00 d4 22 e6 94 09 05 f2 a7 77 0f |..,...."......w.| +00000040 48 e9 5c 6c e9 b2 9a d6 ff 48 2b 08 9a ea 23 1a |H.\l.....H+...#.| +>>> Flow 4 (server to client) +00000000 17 03 03 00 1e 2a f5 09 7f 7b 5f 8a ff d3 cc 16 |.....*...{_.....| +00000010 d1 d3 38 76 5c f7 e3 ee f3 72 b5 92 8e f9 bf 37 |..8v\....r.....7| +00000020 7e dc 61 17 03 03 00 13 66 ba 9e ff 3a 9f 25 74 |~.a.....f...:.%t| +00000030 44 35 70 f4 cf ae dc b0 3c 28 44 |D5p.....<(D| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv13-IssueTicketPreDisable b/libgo/go/crypto/tls/testdata/Server-TLSv13-IssueTicketPreDisable new file mode 100644 index 00000000000..ed3f55ad372 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Server-TLSv13-IssueTicketPreDisable @@ -0,0 +1,103 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 e4 01 00 00 e0 03 03 4a ec fd a5 c5 |...........J....| +00000010 ef 77 88 18 25 40 50 c8 24 60 45 85 e6 3e 55 86 |.w..%@P.$`E..>U.| +00000020 d1 ea 0e 5f 0b d1 66 7a 1c 90 ad 20 a3 63 23 52 |..._..fz... .c#R| +00000030 d8 c8 f6 79 20 04 8d 07 eb 2f 78 a3 1a 0d 58 af |...y ..../x...X.| +00000040 70 3c ef 4b 90 43 42 67 57 39 bf fa 00 08 13 02 |p<.K.CBgW9......| +00000050 13 03 13 01 00 ff 01 00 00 8f 00 00 00 0e 00 0c |................| +00000060 00 00 09 31 32 37 2e 30 2e 30 2e 31 00 0b 00 04 |...127.0.0.1....| +00000070 03 00 01 02 00 0a 00 0c 00 0a 00 1d 00 17 00 1e |................| +00000080 00 19 00 18 00 23 00 00 00 16 00 00 00 17 00 00 |.....#..........| +00000090 00 0d 00 1e 00 1c 04 03 05 03 06 03 08 07 08 08 |................| +000000a0 08 09 08 0a 08 0b 08 04 08 05 08 06 04 01 05 01 |................| +000000b0 06 01 00 2b 00 03 02 03 04 00 2d 00 02 01 01 00 |...+......-.....| +000000c0 33 00 26 00 24 00 1d 00 20 23 61 a3 8f f6 41 bc |3.&.$... #a...A.| +000000d0 08 52 ef 97 01 0e ba 95 f4 33 b6 8d 15 d0 ff ed |.R.......3......| +000000e0 a4 d1 84 23 3b f3 ef 3a 2d |...#;..:-| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 00 00 00 00 00 |....z...v.......| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 a3 63 23 52 |........... .c#R| +00000030 d8 c8 f6 79 20 04 8d 07 eb 2f 78 a3 1a 0d 58 af |...y ..../x...X.| +00000040 70 3c ef 4b 90 43 42 67 57 39 bf fa 13 02 00 00 |p<.K.CBgW9......| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 2f |..+.....3.$... /| +00000060 e5 7d a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 |.}.G.bC.(.._.).0| +00000070 ff f6 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 14 |.........._X.;t.| +00000080 03 03 00 01 01 17 03 03 00 17 80 72 6f c7 2d 22 |...........ro.-"| +00000090 40 51 35 22 9b 97 51 33 60 fa c1 2c d3 0f 25 6a |@Q5"..Q3`..,..%j| +000000a0 4d 17 03 03 02 6d f3 3a 89 a6 9a 1f 2b f4 1a 48 |M....m.:....+..H| +000000b0 e9 bd ef da 9d 7b f0 6c 61 ca 21 82 1b 30 6f 60 |.....{.la.!..0o`| +000000c0 01 72 24 4f ea 66 ef 3b 35 b7 ae d9 45 c9 2a 00 |.r$O.f.;5...E.*.| +000000d0 99 da 50 ae ac 8f 77 a4 e7 b4 de f6 c8 dd b8 f3 |..P...w.........| +000000e0 bc cb 7c c8 cf 2f 63 61 66 16 7f 7f 61 2c 52 c9 |..|../caf...a,R.| +000000f0 8f af 0d e2 55 d7 a4 ed 7e 12 b0 0d ec e9 a4 47 |....U...~......G| +00000100 03 e6 fa d1 6b 2f e3 22 a8 f5 c5 e6 e6 78 63 a1 |....k/.".....xc.| +00000110 b7 00 98 04 e8 fd ff 67 62 dc 89 f4 0d 97 93 4e |.......gb......N| +00000120 85 ec e0 68 f0 04 94 02 49 95 f9 08 99 30 37 d8 |...h....I....07.| +00000130 ad 31 52 1d 1d 23 09 9e 7a 97 45 d3 95 2f 03 2d |.1R..#..z.E../.-| +00000140 64 f7 5b cb 53 f5 89 ef 45 90 72 38 33 aa 62 1e |d.[.S...E.r83.b.| +00000150 b8 3e 00 b2 7f 89 0b 3a e6 17 93 ac 19 7d 09 bd |.>.....:.....}..| +00000160 ca ca 83 87 33 f9 f0 63 f3 4e 7b 47 56 0d cb b5 |....3..c.N{GV...| +00000170 90 81 88 cd 02 78 bf 96 64 c0 ba 58 b5 06 18 04 |.....x..d..X....| +00000180 d9 14 8b 92 74 81 76 b3 23 d9 ad 4c 8b 73 61 36 |....t.v.#..L.sa6| +00000190 64 d9 b6 2e 98 7e 7f d4 14 6e 4c a4 b4 71 35 5b |d....~...nL..q5[| +000001a0 4d e7 10 a8 b3 bb 40 5d 9f de 67 bb ae 0c 97 8b |M.....@]..g.....| +000001b0 25 cf cb aa 13 44 9f cb ff 2e 1c 54 ca de cb 13 |%....D.....T....| +000001c0 f9 c7 0e 49 9d d0 b3 d5 0e 29 3c 50 b9 2b 56 1f |...I.....).1{........| +00000430 06 d6 19 09 44 c2 8f 7c ef bd ea 06 a6 8f 38 42 |....D..|......8B| +00000440 1b a1 be 12 1f 72 38 49 96 e4 74 2f 42 19 2c 55 |.....r8I..t/B.,U| +00000450 16 45 a9 e0 a8 76 6d 36 68 84 fd 0e 40 44 df 93 |.E...vm6h...@D..| +00000460 ae 12 79 78 4c ec 72 16 fe 54 c0 14 ac 47 ed 88 |..yxL.r..T...G..| +00000470 78 98 c8 cb ca 49 de fd 12 e1 96 d0 c7 89 ee 89 |x....I..........| +00000480 df d5 71 98 8a 42 7e 3e 24 5a 64 44 19 96 cc e4 |..q..B~>$ZdD....| +00000490 9c f2 8e 52 8b 1d 39 15 af c7 cd 54 d9 84 01 ef |...R..9....T....| +000004a0 fc ac 54 |..T| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 00 45 a6 fe 34 ee 91 |..........E..4..| +00000010 b0 c5 35 55 cf 70 3f d4 5d 06 76 28 c3 b5 a9 26 |..5U.p?.].v(...&| +00000020 38 18 ed bb bb bb be e7 4b 6d 61 3e 8f 65 e9 e3 |8.......Kma>.e..| +00000030 b6 4f 5d 50 46 2c 81 a8 fd 47 aa c8 c4 e8 f9 a4 |.O]PF,...G......| +00000040 e7 c7 f0 c5 fa e3 9c b7 be 09 c9 37 c1 7f 1c ff |...........7....| +>>> Flow 4 (server to client) +00000000 17 03 03 00 1e 1b 5e f2 20 7a 1c 27 36 12 e7 9a |......^. z.'6...| +00000010 05 9f fb 12 38 df 1d a0 3e 90 9a 42 4d ca 3a 54 |....8...>..BM.:T| +00000020 db 2c f0 17 03 03 00 13 b1 e4 a6 eb ad 47 ba 4c |.,...........G.L| +00000030 38 2c ee ee f9 a5 8a 41 2f ce 3d |8,.....A/.=| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv13-P256 b/libgo/go/crypto/tls/testdata/Server-TLSv13-P256 new file mode 100644 index 00000000000..86085b05612 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Server-TLSv13-P256 @@ -0,0 +1,106 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 f9 01 00 00 f5 03 03 3f 2f 76 da 5e |...........?/v.^| +00000010 bc ca 96 5b e3 c5 ff 45 18 e9 dc 7e b3 e8 97 f5 |...[...E...~....| +00000020 d1 d5 19 c0 4d a4 5d ce 34 1b e4 20 5f fe 5f 0c |....M.].4.. _._.| +00000030 88 92 65 b9 c6 ac 7f 3e dc a3 f7 ad e2 21 08 41 |..e....>.....!.A| +00000040 f8 36 e4 61 67 71 69 56 7f 6b d1 fc 00 08 13 02 |.6.agqiV.k......| +00000050 13 03 13 01 00 ff 01 00 00 a4 00 00 00 0e 00 0c |................| +00000060 00 00 09 31 32 37 2e 30 2e 30 2e 31 00 0b 00 04 |...127.0.0.1....| +00000070 03 00 01 02 00 0a 00 04 00 02 00 17 00 16 00 00 |................| +00000080 00 17 00 00 00 0d 00 1e 00 1c 04 03 05 03 06 03 |................| +00000090 08 07 08 08 08 09 08 0a 08 0b 08 04 08 05 08 06 |................| +000000a0 04 01 05 01 06 01 00 2b 00 03 02 03 04 00 2d 00 |.......+......-.| +000000b0 02 01 01 00 33 00 47 00 45 00 17 00 41 04 d3 57 |....3.G.E...A..W| +000000c0 de 53 6a 81 d5 e8 c2 68 cd 05 90 9b 0e b2 7e 5d |.Sj....h......~]| +000000d0 43 4c 66 f1 28 53 53 00 1a a5 9b b3 ae e0 3e b7 |CLf.(SS.......>.| +000000e0 72 4b 29 c6 2d 96 39 3a 1c a2 ef 04 96 22 df ea |rK).-.9:....."..| +000000f0 15 f5 ff bb 36 ed 3a 3f 67 55 ba 48 10 45 |....6.:?gU.H.E| +>>> Flow 2 (server to client) +00000000 16 03 03 00 9b 02 00 00 97 03 03 00 00 00 00 00 |................| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 5f fe 5f 0c |........... _._.| +00000030 88 92 65 b9 c6 ac 7f 3e dc a3 f7 ad e2 21 08 41 |..e....>.....!.A| +00000040 f8 36 e4 61 67 71 69 56 7f 6b d1 fc 13 02 00 00 |.6.agqiV.k......| +00000050 4f 00 2b 00 02 03 04 00 33 00 45 00 17 00 41 04 |O.+.....3.E...A.| +00000060 1e 18 37 ef 0d 19 51 88 35 75 71 b5 e5 54 5b 12 |..7...Q.5uq..T[.| +00000070 2e 8f 09 67 fd a7 24 20 3e b2 56 1c ce 97 28 5e |...g..$ >.V...(^| +00000080 f8 2b 2d 4f 9e f1 07 9f 6c 4b 5b 83 56 e2 32 42 |.+-O....lK[.V.2B| +00000090 e9 58 b6 d7 49 a6 b5 68 1a 41 03 56 6b dc 5a 89 |.X..I..h.A.Vk.Z.| +000000a0 14 03 03 00 01 01 17 03 03 00 17 e2 0e 2c fc 9b |.............,..| +000000b0 61 70 e2 5f b9 e5 a5 ad ce fb df fa be ae 9a 5b |ap._...........[| +000000c0 cc 99 17 03 03 02 6d 87 74 85 83 f2 51 98 a5 75 |......m.t...Q..u| +000000d0 09 f0 6d 0f dd 16 a7 12 12 fb ec 98 6e 56 a4 ed |..m.........nV..| +000000e0 94 18 6b 28 6b ef 80 bd 28 3b f4 ee 05 80 d2 ff |..k(k...(;......| +000000f0 2f d4 6b b5 d3 b6 91 61 b7 8e 1b db 60 cf f5 4b |/.k....a....`..K| +00000100 3b 68 78 4a 09 2d a3 49 c0 8a 06 e5 2c 62 08 5d |;hxJ.-.I....,b.]| +00000110 c4 5d 03 04 5e 3e 25 9d 30 24 af b0 a3 2e 8c 65 |.]..^>%.0$.....e| +00000120 fb 6f 34 94 e9 d9 d6 34 0e a9 44 8a 9e b7 1a 13 |.o4....4..D.....| +00000130 26 b7 b2 16 c2 79 05 e8 0e 99 bd 7a cc c8 83 a4 |&....y.....z....| +00000140 60 1d cb 5c 02 8a 1f b7 4f c4 2d cd 96 e4 7b 39 |`..\....O.-...{9| +00000150 5a 45 60 30 82 9f 8f 30 56 11 7b 0d 6e 7e 95 54 |ZE`0...0V.{.n~.T| +00000160 d0 ac 09 8e 3b 49 14 de d3 8b a1 e4 4d f7 65 8d |....;I......M.e.| +00000170 88 46 71 7a 29 ea 05 b4 66 e6 76 db b7 7d 56 ce |.Fqz)...f.v..}V.| +00000180 e0 ba 47 b5 75 c1 14 42 7e af 87 f3 94 bf 75 e3 |..G.u..B~.....u.| +00000190 ee 54 ea 4c 8c 69 fd 63 01 1c 0e 38 84 e6 04 c3 |.T.L.i.c...8....| +000001a0 a8 3d 42 18 87 a2 f0 b4 4d ef 29 8d 48 01 b9 f4 |.=B.....M.).H...| +000001b0 8b 1e b1 72 bf e4 9a 6d 80 d7 c2 e0 a7 a7 0a 3f |...r...m.......?| +000001c0 45 f4 72 94 56 19 6b f3 4c 3e a6 1e 87 cd d3 a2 |E.r.V.k.L>......| +000001d0 49 b6 e7 56 b9 dd 2b f6 66 0a 6a 55 75 63 f9 c3 |I..V..+.f.jUuc..| +000001e0 d2 a6 ea a0 04 09 6b 75 eb 77 6b 9e 4b a4 6d f5 |......ku.wk.K.m.| +000001f0 44 01 37 ee 21 15 f7 3e 6e 6f fc dc be 44 43 26 |D.7.!..>no...DC&| +00000200 dd 7a ab 13 67 58 8d cb 02 78 b9 71 07 22 12 d2 |.z..gX...x.q."..| +00000210 cf 87 50 ff 04 d9 7a f2 73 8c 77 9e 5b 17 b2 aa |..P...z.s.w.[...| +00000220 2a db b2 a2 f4 5b c4 0d e2 84 a3 fe 4d b1 02 26 |*....[......M..&| +00000230 7d ba 76 2a 0e d1 87 52 c7 5f 97 07 fd b7 25 1b |}.v*...R._....%.| +00000240 2a 52 0d 30 59 84 73 a0 d7 db 75 6d 74 05 a2 3b |*R.0Y.s...umt..;| +00000250 91 69 f3 a3 43 bc 44 f9 ce f4 85 a1 38 5a e2 55 |.i..C.D.....8Z.U| +00000260 f6 e8 e2 ca 3b c2 fd 39 0f f4 ae 86 08 24 d4 c7 |....;..9.....$..| +00000270 10 44 c0 bf 9b 47 d9 da 07 52 4d 88 71 d4 14 69 |.D...G...RM.q..i| +00000280 66 8b cc 44 09 1b 90 b0 a5 7c 96 3c 94 99 cd c2 |f..D.....|.<....| +00000290 ca 0b af 53 c0 31 a2 5a df 54 76 e4 af 66 5d ff |...S.1.Z.Tv..f].| +000002a0 7c 21 c9 06 b8 d9 7e 1f 46 97 c8 ea e0 90 f2 db ||!....~.F.......| +000002b0 9b 52 04 a8 91 20 15 c8 fc 24 09 d7 f9 48 20 dc |.R... ...$...H .| +000002c0 18 22 d1 e2 19 3d 53 dd e4 21 db 8c 87 7d d7 bf |."...=S..!...}..| +000002d0 f7 93 a6 a5 81 b5 53 59 15 a8 80 2e 3b 4f b0 d4 |......SY....;O..| +000002e0 f3 66 56 14 6e a1 6b 3e 75 b1 8e fa 0d 52 96 b1 |.fV.n.k>u....R..| +000002f0 08 b1 b0 ce 0c c6 0a 5e 54 0f a3 5a cd 6c db 6a |.......^T..Z.l.j| +00000300 0a 6a 52 11 b5 97 7b 67 e3 3e 84 22 76 3a f1 96 |.jR...{g.>."v:..| +00000310 70 bf 9c a6 62 03 30 a7 69 46 ec 9a 61 1e 37 6f |p...b.0.iF..a.7o| +00000320 7d 24 d6 6c 8a e5 72 3a 0a ef e8 d3 d6 fe 28 c8 |}$.l..r:......(.| +00000330 60 ff d7 2e 17 03 03 00 99 ca f3 5e cb 8c b2 0b |`..........^....| +00000340 87 4e 59 89 38 f5 f1 3c c4 e1 6a 11 2d f3 ef 7d |.NY.8..<..j.-..}| +00000350 b6 85 ff bb 84 8f cb db 7f 02 50 23 93 db b3 0a |..........P#....| +00000360 2c 32 cb ed 08 ae 6a 3e 30 b8 a5 c2 9c 85 0c 87 |,2....j>0.......| +00000370 44 68 8b 47 31 75 a0 c3 2c 32 2e 61 40 da 4b 0a |Dh.G1u..,2.a@.K.| +00000380 07 ef 2b 6b fa 2f 66 87 ff f1 0e 5e b0 db 44 3d |..+k./f....^..D=| +00000390 3c fc a7 94 17 f3 0b a5 50 68 7b 65 48 8e 78 ce |<.......Ph{eH.x.| +000003a0 d7 71 fa ae 58 50 62 33 98 b2 a2 27 b1 e0 66 fb |.q..XPb3...'..f.| +000003b0 65 6a 94 21 38 e8 40 aa 4f d7 02 31 45 e8 d3 e0 |ej.!8.@.O..1E...| +000003c0 5f 66 d4 2f 26 9f b2 72 b7 bc 43 ce f1 2a 0e 61 |_f./&..r..C..*.a| +000003d0 f1 91 17 03 03 00 45 c0 25 ac 1e 0b 4e 2c 61 9c |......E.%...N,a.| +000003e0 c7 80 f1 f7 bf d4 c6 a9 29 3f 0c 08 8d f0 70 7c |........)?....p|| +000003f0 6f 96 2c 3e 32 7f a6 10 17 19 81 49 2d a7 f7 3f |o.,>2......I-..?| +00000400 04 20 7d 52 c2 e8 cc 61 b2 16 5b 8b 3e 1a a9 2f |. }R...a..[.>../| +00000410 9c 5e a7 74 88 3d 8a c8 90 df 9a 17 17 03 03 00 |.^.t.=..........| +00000420 a3 cf b5 d2 52 49 27 95 5f dd 9b 37 ed 74 7b 17 |....RI'._..7.t{.| +00000430 8b 7f f3 67 3c 91 2f 1e b6 17 4f ba a7 b1 92 99 |...g<./...O.....| +00000440 32 32 7e 72 95 90 a0 92 08 c3 da 30 31 85 ee bb |22~r.......01...| +00000450 8f 8d d4 d8 c5 28 19 10 71 f0 b3 15 45 86 e0 09 |.....(..q...E...| +00000460 ee e4 96 a0 90 c5 df 81 8f d1 38 b2 e0 33 95 3b |..........8..3.;| +00000470 33 9d e0 3e 93 3d 6a 12 60 44 43 9e b0 5c 16 82 |3..>.=j.`DC..\..| +00000480 92 b8 84 0e 56 19 b9 b6 eb 3c 37 3e 9b ee 2a 6a |....V....<7>..*j| +00000490 13 4a bb 3d 78 21 79 0e 6f cc 34 89 91 95 03 a6 |.J.=x!y.o.4.....| +000004a0 19 e2 81 37 a6 9d 30 28 42 da f4 69 4e 42 4b e4 |...7..0(B..iNBK.| +000004b0 ca 23 c5 1e 56 24 cc ba b0 85 21 ef 44 04 cb d8 |.#..V$....!.D...| +000004c0 aa cd 5d 55 |..]U| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 00 45 43 65 76 31 fa |..........ECev1.| +00000010 2c a7 2e 96 92 82 cf eb 91 3d 8b eb 01 d3 af da |,........=......| +00000020 67 ea 4d 75 47 8f 42 34 7a 2d 0a b0 d1 4c 08 c0 |g.MuG.B4z-...L..| +00000030 c7 76 7e 99 93 4a 06 b2 d9 95 df f9 c1 29 25 e6 |.v~..J.......)%.| +00000040 24 6d ea 73 00 24 36 a9 62 30 9d a4 aa 6c 2f c8 |$m.s.$6.b0...l/.| +>>> Flow 4 (server to client) +00000000 17 03 03 00 1e 6e bb 52 84 cf a6 71 d5 b9 ac c2 |.....n.R...q....| +00000010 29 1a 0b db be a4 bb bd 6c f4 2e c8 eb f0 bb eb |).......l.......| +00000020 d3 f8 69 17 03 03 00 13 19 ad 85 21 63 f6 38 df |..i........!c.8.| +00000030 35 41 af 12 75 63 e8 fa 38 5e 50 |5A..uc..8^P| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv13-RSA-RSAPSS b/libgo/go/crypto/tls/testdata/Server-TLSv13-RSA-RSAPSS new file mode 100644 index 00000000000..21f57b7b632 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Server-TLSv13-RSA-RSAPSS @@ -0,0 +1,101 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 c6 01 00 00 c2 03 03 39 95 ab cc 1c |...........9....| +00000010 64 13 9d 19 2e 3e 73 33 48 b1 a9 f7 88 14 5a 83 |d....>s3H.....Z.| +00000020 19 f7 b5 08 8d e4 80 09 72 21 99 20 23 ad 4c 2c |........r!. #.L,| +00000030 66 84 1e e8 c3 0c 9f 66 19 76 df a3 e0 62 cd 7d |f......f.v...b.}| +00000040 95 85 70 4f 37 fb 39 58 50 b1 d5 7b 00 08 13 02 |..pO7.9XP..{....| +00000050 13 03 13 01 00 ff 01 00 00 71 00 00 00 0e 00 0c |.........q......| +00000060 00 00 09 31 32 37 2e 30 2e 30 2e 31 00 0b 00 04 |...127.0.0.1....| +00000070 03 00 01 02 00 0a 00 0c 00 0a 00 1d 00 17 00 1e |................| +00000080 00 19 00 18 00 16 00 00 00 17 00 00 00 0d 00 04 |................| +00000090 00 02 08 04 00 2b 00 03 02 03 04 00 2d 00 02 01 |.....+......-...| +000000a0 01 00 33 00 26 00 24 00 1d 00 20 be 29 89 8d 44 |..3.&.$... .)..D| +000000b0 4d e5 51 88 7a 1a 56 52 a8 86 74 13 0e e9 a5 a7 |M.Q.z.VR..t.....| +000000c0 b6 7f 38 b3 ef 62 e6 b0 c5 2a 0a |..8..b...*.| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 00 00 00 00 00 |....z...v.......| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 23 ad 4c 2c |........... #.L,| +00000030 66 84 1e e8 c3 0c 9f 66 19 76 df a3 e0 62 cd 7d |f......f.v...b.}| +00000040 95 85 70 4f 37 fb 39 58 50 b1 d5 7b 13 02 00 00 |..pO7.9XP..{....| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 2f |..+.....3.$... /| +00000060 e5 7d a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 |.}.G.bC.(.._.).0| +00000070 ff f6 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 14 |.........._X.;t.| +00000080 03 03 00 01 01 17 03 03 00 17 49 c6 88 9c 3b 2f |..........I...;/| +00000090 3a 0a e6 8e 75 d0 39 11 ad 08 87 17 2c 14 96 28 |:...u.9.....,..(| +000000a0 85 17 03 03 02 6d 2a d6 89 4d 5d f3 6c 28 97 dd |.....m*..M].l(..| +000000b0 4e 45 88 e8 90 a4 f3 45 86 cf 59 d6 61 6e 1a a7 |NE.....E..Y.an..| +000000c0 b7 35 7e 9c 6e 11 19 c4 1b 89 b9 5a 7c aa 1f 96 |.5~.n......Z|...| +000000d0 e2 36 6d 54 09 12 2f 28 12 20 a3 41 06 bd 44 3c |.6mT../(. .A..D<| +000000e0 73 be d3 8c 78 18 a1 63 ad f9 9d 41 20 5e 32 55 |s...x..c...A ^2U| +000000f0 8e 18 c1 d8 b0 93 13 7e 88 a0 af 8a 59 e2 af 43 |.......~....Y..C| +00000100 d2 82 66 ba c5 a1 97 94 e8 63 40 1b 8f c4 eb 49 |..f......c@....I| +00000110 19 91 65 e9 54 d3 90 76 d6 f8 ff 15 20 31 3c 86 |..e.T..v.... 1<.| +00000120 88 8a 43 be 77 a0 28 de fa 9f d5 30 14 a8 35 2f |..C.w.(....0..5/| +00000130 5e ee 9d cf b5 69 d1 f5 f6 55 d1 1a 61 3f 4c a1 |^....i...U..a?L.| +00000140 97 38 5b 87 7e ce 88 23 8a d0 bd fc 4b c5 da f7 |.8[.~..#....K...| +00000150 25 6c 6c 0b ec 61 50 72 97 6b f7 fe 9b 5b 5a f9 |%ll..aPr.k...[Z.| +00000160 59 19 71 10 74 2d 14 8c 1b 52 8b 39 1c 56 ea 7e |Y.q.t-...R.9.V.~| +00000170 7a c9 8f 7c bd db 1e c5 02 9f 42 8b 63 ee 13 52 |z..|......B.c..R| +00000180 fe 46 40 de 7b 97 27 b0 16 87 75 96 c7 1c 88 5d |.F@.{.'...u....]| +00000190 2e 64 7f a8 df e0 16 b9 ee 27 7e b3 98 99 f7 4a |.d.......'~....J| +000001a0 83 05 78 bb 59 07 8e 1a 46 1d 0f 45 87 ae d9 ae |..x.Y...F..E....| +000001b0 6f 42 ed b1 72 14 8c 9d 33 72 95 ac 12 bb a0 20 |oB..r...3r..... | +000001c0 56 a8 8a 23 e4 51 6a 89 f5 8e bc 55 5a e2 8d 78 |V..#.Qj....UZ..x| +000001d0 84 24 55 99 cf 37 61 8c 7e 46 17 f3 26 ca 27 ec |.$U..7a.~F..&.'.| +000001e0 f4 04 f6 76 1d cf 82 0c bd 85 82 81 06 f1 96 ce |...v............| +000001f0 78 54 6c eb a0 f8 cf 30 6a 10 17 08 e6 94 83 4f |xTl....0j......O| +00000200 56 34 80 ef ac fa ab e7 59 9e 6b f9 f8 38 76 cc |V4......Y.k..8v.| +00000210 3b 09 b0 16 3f 3f 5c d3 6a ad d9 2c 65 d8 ce b4 |;...??\.j..,e...| +00000220 19 53 c4 c9 d1 82 e8 19 72 ec bc 85 ef 3a 6e e5 |.S......r....:n.| +00000230 ba 3c f8 37 98 98 80 47 5f 47 4f cd ed f5 0e bc |.<.7...G_GO.....| +00000240 4e 14 a2 7d 8d 43 0b 18 ba 3b 10 50 e4 18 fc ac |N..}.C...;.P....| +00000250 0e 01 21 73 68 da 50 51 8a 64 b6 18 28 ca e3 a4 |..!sh.PQ.d..(...| +00000260 aa d2 5c 28 ff 64 fd cb 28 00 db b1 5c bf 75 81 |..\(.d..(...\.u.| +00000270 bb d2 8c df 5c 26 70 1d d6 fe 7a 94 65 27 93 72 |....\&p...z.e'.r| +00000280 bc ba 17 92 8f be 61 ec f5 88 04 ed fb cc f3 5c |......a........\| +00000290 71 d0 a4 5d 13 a6 a3 82 89 e8 9e 1a 8e 31 fd 2f |q..].........1./| +000002a0 57 53 98 d5 1f c4 3f 8e 92 7f 1b 90 a3 ad 6c 96 |WS....?.......l.| +000002b0 42 cc f2 f0 1c 8d 3f 31 fd b2 53 29 79 16 9a 96 |B.....?1..S)y...| +000002c0 fd d6 fe d4 3f 13 aa 39 73 d4 73 6d 9a ff f6 db |....?..9s.sm....| +000002d0 52 0a 1e 76 71 0f d3 ee de a8 b3 05 3b 24 c4 72 |R..vq.......;$.r| +000002e0 67 78 f1 be df c5 c0 87 32 60 28 96 8e b2 2e 3f |gx......2`(....?| +000002f0 7d e9 aa b7 66 57 ee 67 e6 ac 70 da 60 ce c2 00 |}...fW.g..p.`...| +00000300 55 2f 20 25 39 a5 5e b9 65 c3 00 63 c7 5a a9 31 |U/ %9.^.e..c.Z.1| +00000310 de fe 65 17 03 03 00 99 95 83 6d be 56 ef 4f a3 |..e.......m.V.O.| +00000320 96 5f a8 3d d5 a1 f3 8e 9a 8c 40 35 f4 12 2c 0a |._.=......@5..,.| +00000330 b3 02 3b d2 14 d8 a4 f1 12 01 be e1 8a 6b 5f 01 |..;..........k_.| +00000340 71 de ac 70 e9 7a 90 78 2e 2a a8 29 64 20 85 dd |q..p.z.x.*.)d ..| +00000350 57 09 cf 48 29 d0 63 42 bc 9b ec 0c e2 2d 41 d0 |W..H).cB.....-A.| +00000360 cb d8 68 46 b7 17 fc 1d 95 12 5a 4c c3 10 67 32 |..hF......ZL..g2| +00000370 f7 7a 14 55 63 fb 57 6e 59 ee b6 66 b8 65 e1 37 |.z.Uc.WnY..f.e.7| +00000380 e6 7c 6c 07 8b d1 84 80 01 11 ce 7f 20 f0 4d 42 |.|l......... .MB| +00000390 a7 67 01 12 e6 b5 9b d4 6a fe 38 37 71 ca 60 d6 |.g......j.87q.`.| +000003a0 12 d7 00 b5 26 c3 97 1d 9f 37 6a 82 31 ef c3 12 |....&....7j.1...| +000003b0 bc 17 03 03 00 45 65 1e cf 1f 1e 73 93 8d 66 54 |.....Ee....s..fT| +000003c0 47 b0 73 9f d1 a4 9d 3b b0 72 b4 f2 5f 06 e1 d2 |G.s....;.r.._...| +000003d0 1f bb 3d 13 48 7c 7a e0 19 15 9f aa a5 ed 09 18 |..=.H|z.........| +000003e0 2e 4e 8a cd 66 2b 9c b3 fe 99 b0 57 06 2e b3 a0 |.N..f+.....W....| +000003f0 79 92 c1 bb 0e 29 44 02 f1 b0 43 17 03 03 00 a3 |y....)D...C.....| +00000400 52 cd d9 d7 60 1c f5 06 83 aa 2f e0 0c 0f 5e 6d |R...`...../...^m| +00000410 0f 29 93 b9 ae 50 04 c6 f7 d3 ff c7 d1 ac 9d 43 |.)...P.........C| +00000420 d7 b5 76 7a 16 b7 2c b7 79 48 a4 c3 28 2a 86 10 |..vz..,.yH..(*..| +00000430 d1 24 7c 04 ed af 1f 8a 0b 18 29 97 7a 7a 47 3f |.$|.......).zzG?| +00000440 1f fe ba 9c 72 d9 9b ae 9b 83 5f f4 5a 4f 10 b8 |....r....._.ZO..| +00000450 e5 45 35 76 77 a2 ac 99 1c bc 78 cf 6f 62 ef ef |.E5vw.....x.ob..| +00000460 9b 1b 90 eb 95 6b a1 25 82 b7 c1 1b 6f da 10 4c |.....k.%....o..L| +00000470 aa 3e a8 ba dd 77 b1 39 a0 b2 6a 11 18 44 2a 8d |.>...w.9..j..D*.| +00000480 58 9a 53 31 e1 d1 ec 8b 47 95 63 67 44 67 8d 09 |X.S1....G.cgDg..| +00000490 2f 16 f5 19 cd 65 1d 52 d7 bd 19 f0 bb ec 7b 55 |/....e.R......{U| +000004a0 33 4f 84 |3O.| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 00 45 07 3f db d9 c7 |..........E.?...| +00000010 05 fd c4 0c 2d ae ee d8 d7 e7 ac 46 19 a2 17 e5 |....-......F....| +00000020 5e 10 30 65 05 be e0 c7 1e b3 e2 16 a4 d6 69 e1 |^.0e..........i.| +00000030 2c ff 18 ba e4 8f d0 3d 12 45 df c3 d4 08 0d e6 |,......=.E......| +00000040 94 6e 83 6d 99 9d f3 f1 02 48 6b 6f d1 2d f0 c6 |.n.m.....Hko.-..| +>>> Flow 4 (server to client) +00000000 17 03 03 00 1e 2a 3d 96 b4 6a 9e 7f 7f ca e0 8e |.....*=..j......| +00000010 41 4e bd 82 86 61 b8 59 19 e4 97 02 c2 00 7e 69 |AN...a.Y......~i| +00000020 81 b0 64 17 03 03 00 13 63 91 94 1a a3 51 bf 95 |..d.....c....Q..| +00000030 9e 09 a2 a1 f0 01 57 93 00 71 49 |......W..qI| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv13-Resume b/libgo/go/crypto/tls/testdata/Server-TLSv13-Resume new file mode 100644 index 00000000000..fa10f3e0c43 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Server-TLSv13-Resume @@ -0,0 +1,66 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 01 a4 01 00 01 a0 03 03 92 e8 fa 14 82 |................| +00000010 03 7c cd fe 01 82 55 99 8b fd 04 ff 88 82 98 c9 |.|....U.........| +00000020 72 18 3b 2e 0a de fc a4 44 9f 1d 20 c0 df df c9 |r.;.....D.. ....| +00000030 1d ed 19 9e 2d ce 57 f6 95 54 67 76 77 64 c7 f4 |....-.W..Tgvwd..| +00000040 ad 18 7d d8 58 6f 08 30 a5 a4 50 cd 00 08 13 02 |..}.Xo.0..P.....| +00000050 13 03 13 01 00 ff 01 00 01 4f 00 00 00 0e 00 0c |.........O......| +00000060 00 00 09 31 32 37 2e 30 2e 30 2e 31 00 0b 00 04 |...127.0.0.1....| +00000070 03 00 01 02 00 0a 00 0c 00 0a 00 1d 00 17 00 1e |................| +00000080 00 19 00 18 00 23 00 00 00 16 00 00 00 17 00 00 |.....#..........| +00000090 00 0d 00 1e 00 1c 04 03 05 03 06 03 08 07 08 08 |................| +000000a0 08 09 08 0a 08 0b 08 04 08 05 08 06 04 01 05 01 |................| +000000b0 06 01 00 2b 00 03 02 03 04 00 2d 00 02 01 01 00 |...+......-.....| +000000c0 33 00 26 00 24 00 1d 00 20 94 44 cd ce 27 a8 43 |3.&.$... .D..'.C| +000000d0 8a ef cd ef d4 74 d4 e4 62 82 00 e6 46 96 e5 aa |.....t..b...F...| +000000e0 d1 44 8a 55 6b d7 25 06 6f 00 29 00 bc 00 87 00 |.D.Uk.%.o.).....| +000000f0 81 50 46 ad c1 db a8 38 86 7b 2b bb fd d0 c3 42 |.PF....8.{+....B| +00000100 3e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |>...............| +00000110 00 94 68 2c a3 81 51 ed 14 ef 68 ca 42 c5 4c 1f |..h,..Q...h.B.L.| +00000120 90 bf 3c 07 2b e5 52 22 a0 c0 46 db cb f6 b9 a0 |..<.+.R"..F.....| +00000130 b5 56 b0 d6 7f 03 b7 2d 9f a5 2a 25 8e 65 d2 b9 |.V.....-..*%.e..| +00000140 6a f3 e4 7e 79 d7 3d cc b2 3d b6 24 a9 31 82 49 |j..~y.=..=.$.1.I| +00000150 38 16 92 f0 49 97 e2 07 e2 cd 1c 77 d3 e0 00 de |8...I......w....| +00000160 56 11 17 40 00 63 13 00 48 39 8e fd 09 96 08 f3 |V..@.c..H9......| +00000170 81 7c 00 00 00 00 00 31 30 a4 22 35 6e 4a 09 af |.|.....10."5nJ..| +00000180 08 22 97 92 e0 8a eb c0 e0 28 32 f4 8f ed 1e 02 |.".......(2.....| +00000190 a9 b3 43 de f3 04 cb 7b db 01 51 88 46 02 c1 4b |..C....{..Q.F..K| +000001a0 ec fa a8 05 42 a4 00 ae ed |....B....| +>>> Flow 2 (server to client) +00000000 16 03 03 00 80 02 00 00 7c 03 03 00 00 00 00 00 |........|.......| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 c0 df df c9 |........... ....| +00000030 1d ed 19 9e 2d ce 57 f6 95 54 67 76 77 64 c7 f4 |....-.W..Tgvwd..| +00000040 ad 18 7d d8 58 6f 08 30 a5 a4 50 cd 13 02 00 00 |..}.Xo.0..P.....| +00000050 34 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 2f |4.+.....3.$... /| +00000060 e5 7d a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 |.}.G.bC.(.._.).0| +00000070 ff f6 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 00 |.........._X.;t.| +00000080 29 00 02 00 00 14 03 03 00 01 01 17 03 03 00 17 |)...............| +00000090 cc 35 3b 89 bc fe dc df 02 d3 00 f8 ef 56 74 6a |.5;..........Vtj| +000000a0 ee af 35 9e d6 91 e1 17 03 03 00 45 07 24 33 da |..5........E.$3.| +000000b0 63 9a eb 15 28 dc e8 60 dc 36 97 12 5e 54 a5 48 |c...(..`.6..^T.H| +000000c0 aa e3 07 35 e7 f0 7c 60 93 d4 4c 24 d7 0d 01 66 |...5..|`..L$...f| +000000d0 d9 b6 e3 c5 ab 9d cf 47 49 f6 4f 87 7a c4 ab 34 |.......GI.O.z..4| +000000e0 df 37 19 a6 f9 36 c8 ea 04 af 9a d7 21 dd 89 e2 |.7...6......!...| +000000f0 79 17 03 03 00 a3 60 8e 39 7e 5d 21 e2 e4 8a 0e |y.....`.9~]!....| +00000100 73 4a 96 09 49 fb 55 b4 68 60 88 0d 01 73 5b d0 |sJ..I.U.h`...s[.| +00000110 42 4d 9a af 22 ae 33 83 16 60 3e 25 e2 fd 76 10 |BM..".3..`>%..v.| +00000120 6e 92 0d 6b 88 c7 54 46 51 bf 86 a4 f4 11 d3 e8 |n..k..TFQ.......| +00000130 29 54 16 31 b2 44 4b 45 5d 3f 97 d9 33 10 ef 92 |)T.1.DKE]?..3...| +00000140 e5 aa 3b 2d 3d 36 ef 85 04 2d 17 66 2a 00 ea 87 |..;-=6...-.f*...| +00000150 9a 95 5e 54 1b 01 f8 5d 34 96 83 cf 28 d4 24 ed |..^T...]4...(.$.| +00000160 c6 9b da 7a 1c d4 a3 5a 53 bb 2f cf 56 f3 ef 99 |...z...ZS./.V...| +00000170 40 e2 34 31 ca 55 c9 7a 02 47 14 8b 7e 04 5a ff |@.41.U.z.G..~.Z.| +00000180 17 f7 95 f0 46 e0 ce cf 8f b0 9f 6b 51 96 d5 f7 |....F......kQ...| +00000190 0b 33 e2 0a 62 4e 05 28 66 |.3..bN.(f| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 00 45 66 00 e2 3f 07 |..........Ef..?.| +00000010 02 a4 1d 71 27 2a fe c7 00 1e 2d bc 50 b6 bc 35 |...q'*....-.P..5| +00000020 22 c4 a4 d8 a1 5f fa 10 d7 48 c8 20 94 50 b1 ae |"...._...H. .P..| +00000030 47 8c 62 26 15 79 33 6b 06 0d 19 67 7e 22 7c a5 |G.b&.y3k...g~"|.| +00000040 ca 05 c9 ae c8 66 6b ca 8e f7 7c 35 de 5e c3 25 |.....fk...|5.^.%| +>>> Flow 4 (server to client) +00000000 17 03 03 00 1e 6a 89 ce e3 1d 13 60 f3 8b 26 97 |.....j.....`..&.| +00000010 3e 5d 9f a8 47 c9 74 f5 66 ad 75 87 57 ec ef b1 |>]..G.t.f.u.W...| +00000020 66 da f0 17 03 03 00 13 95 bd 2d ef d5 30 c1 1b |f.........-..0..| +00000030 bd 54 3d f6 16 02 28 78 a4 4a 24 |.T=...(x.J$| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv13-Resume-HelloRetryRequest b/libgo/go/crypto/tls/testdata/Server-TLSv13-Resume-HelloRetryRequest new file mode 100644 index 00000000000..2e1cbaf1354 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Server-TLSv13-Resume-HelloRetryRequest @@ -0,0 +1,106 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 01 9e 01 00 01 9a 03 03 75 28 78 ec 6f |...........u(x.o| +00000010 3d d0 60 09 8e 23 dd 91 67 4b e4 2f b0 b7 93 60 |=.`..#..gK./...`| +00000020 3a 4f 92 38 6b 5e 67 ab 49 f4 b8 20 46 e8 0a c4 |:O.8k^g.I.. F...| +00000030 bd 13 ce 09 13 27 a4 5d a4 3b e2 9b 9d ff 17 30 |.....'.].;.....0| +00000040 96 e3 06 1a d6 c6 04 9c f3 9a 15 76 00 08 13 02 |...........v....| +00000050 13 03 13 01 00 ff 01 00 01 49 00 00 00 0e 00 0c |.........I......| +00000060 00 00 09 31 32 37 2e 30 2e 30 2e 31 00 0b 00 04 |...127.0.0.1....| +00000070 03 00 01 02 00 0a 00 06 00 04 00 1d 00 17 00 23 |...............#| +00000080 00 00 00 16 00 00 00 17 00 00 00 0d 00 1e 00 1c |................| +00000090 04 03 05 03 06 03 08 07 08 08 08 09 08 0a 08 0b |................| +000000a0 08 04 08 05 08 06 04 01 05 01 06 01 00 2b 00 03 |.............+..| +000000b0 02 03 04 00 2d 00 02 01 01 00 33 00 26 00 24 00 |....-.....3.&.$.| +000000c0 1d 00 20 a0 26 2f f2 a2 ca d0 ff 0d 5d 9e cc 84 |.. .&/......]...| +000000d0 52 51 07 86 4c 28 44 4e 65 7e 0c a1 9d 50 9c 77 |RQ..L(DNe~...P.w| +000000e0 8a 54 48 00 29 00 bc 00 87 00 81 50 46 ad c1 db |.TH.)......PF...| +000000f0 a8 38 86 7b 2b bb fd d0 c3 42 3e 00 00 00 00 00 |.8.{+....B>.....| +00000100 00 00 00 00 00 00 00 00 00 00 00 94 68 2c a3 81 |............h,..| +00000110 51 ed 14 ef 68 ca 42 c5 4c 1f 90 bf 3c 07 2b e5 |Q...h.B.L...<.+.| +00000120 52 22 a0 c0 46 db cb f6 b9 a0 b5 56 b0 d6 7f 03 |R"..F......V....| +00000130 b7 2d 9f a5 2a 25 8e 65 d2 b9 6a f3 e4 7e 79 d7 |.-..*%.e..j..~y.| +00000140 3d cc b2 3d b6 24 a9 31 82 49 38 16 92 f0 49 97 |=..=.$.1.I8...I.| +00000150 e2 07 e2 cd 1c 77 d3 e0 00 de 56 11 17 40 00 63 |.....w....V..@.c| +00000160 13 00 48 39 8e fd 09 96 08 f3 81 7c 00 00 00 00 |..H9.......|....| +00000170 00 31 30 da 3c 92 3d 0f 55 c9 9e bb 99 c6 e0 ac |.10.<.=.U.......| +00000180 fe 5a 3a 94 7e d6 2a 0a 81 c0 be 8a 4e 1d da 5e |.Z:.~.*.....N..^| +00000190 31 80 97 2d 2a 6a fc 96 03 d2 aa 07 45 f1 78 33 |1..-*j......E.x3| +000001a0 c4 1d 1c |...| +>>> Flow 2 (server to client) +00000000 16 03 03 00 58 02 00 00 54 03 03 cf 21 ad 74 e5 |....X...T...!.t.| +00000010 9a 61 11 be 1d 8c 02 1e 65 b8 91 c2 a2 11 16 7a |.a......e......z| +00000020 bb 8c 5e 07 9e 09 e2 c8 a8 33 9c 20 46 e8 0a c4 |..^......3. F...| +00000030 bd 13 ce 09 13 27 a4 5d a4 3b e2 9b 9d ff 17 30 |.....'.].;.....0| +00000040 96 e3 06 1a d6 c6 04 9c f3 9a 15 76 13 02 00 00 |...........v....| +00000050 0c 00 2b 00 02 03 04 00 33 00 02 00 17 14 03 03 |..+.....3.......| +00000060 00 01 01 |...| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 16 03 03 01 bf 01 00 01 bb 03 |................| +00000010 03 75 28 78 ec 6f 3d d0 60 09 8e 23 dd 91 67 4b |.u(x.o=.`..#..gK| +00000020 e4 2f b0 b7 93 60 3a 4f 92 38 6b 5e 67 ab 49 f4 |./...`:O.8k^g.I.| +00000030 b8 20 46 e8 0a c4 bd 13 ce 09 13 27 a4 5d a4 3b |. F........'.].;| +00000040 e2 9b 9d ff 17 30 96 e3 06 1a d6 c6 04 9c f3 9a |.....0..........| +00000050 15 76 00 08 13 02 13 03 13 01 00 ff 01 00 01 6a |.v.............j| +00000060 00 00 00 0e 00 0c 00 00 09 31 32 37 2e 30 2e 30 |.........127.0.0| +00000070 2e 31 00 0b 00 04 03 00 01 02 00 0a 00 06 00 04 |.1..............| +00000080 00 1d 00 17 00 23 00 00 00 16 00 00 00 17 00 00 |.....#..........| +00000090 00 0d 00 1e 00 1c 04 03 05 03 06 03 08 07 08 08 |................| +000000a0 08 09 08 0a 08 0b 08 04 08 05 08 06 04 01 05 01 |................| +000000b0 06 01 00 2b 00 03 02 03 04 00 2d 00 02 01 01 00 |...+......-.....| +000000c0 33 00 47 00 45 00 17 00 41 04 79 db 79 c8 0b 77 |3.G.E...A.y.y..w| +000000d0 8b 37 30 65 85 ce 72 49 ab a1 cb 6a 06 00 a6 65 |.70e..rI...j...e| +000000e0 22 51 63 63 16 45 7b 85 ee c3 2e 09 25 d9 a3 49 |"Qcc.E{.....%..I| +000000f0 91 07 35 c4 b6 61 23 9c 91 c1 03 07 ad a2 77 02 |..5..a#.......w.| +00000100 61 93 05 cf 74 36 7a 66 ad 24 00 29 00 bc 00 87 |a...t6zf.$.)....| +00000110 00 81 50 46 ad c1 db a8 38 86 7b 2b bb fd d0 c3 |..PF....8.{+....| +00000120 42 3e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |B>..............| +00000130 00 00 94 68 2c a3 81 51 ed 14 ef 68 ca 42 c5 4c |...h,..Q...h.B.L| +00000140 1f 90 bf 3c 07 2b e5 52 22 a0 c0 46 db cb f6 b9 |...<.+.R"..F....| +00000150 a0 b5 56 b0 d6 7f 03 b7 2d 9f a5 2a 25 8e 65 d2 |..V.....-..*%.e.| +00000160 b9 6a f3 e4 7e 79 d7 3d cc b2 3d b6 24 a9 31 82 |.j..~y.=..=.$.1.| +00000170 49 38 16 92 f0 49 97 e2 07 e2 cd 1c 77 d3 e0 00 |I8...I......w...| +00000180 de 56 11 17 40 00 63 13 00 48 39 8e fd 09 96 08 |.V..@.c..H9.....| +00000190 f3 81 7c 00 00 00 00 00 31 30 e0 ac 7a 74 d9 50 |..|.....10..zt.P| +000001a0 c1 3b 1b 67 7b 5a 74 b0 39 db dd 92 6f 75 38 31 |.;.g{Zt.9...ou81| +000001b0 10 f4 98 dc ad af eb ac ef 11 0d 96 48 01 f8 10 |............H...| +000001c0 d6 e1 68 bf 88 a3 33 b9 9a b9 |..h...3...| +>>> Flow 4 (server to client) +00000000 16 03 03 00 a1 02 00 00 9d 03 03 00 00 00 00 00 |................| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 46 e8 0a c4 |........... F...| +00000030 bd 13 ce 09 13 27 a4 5d a4 3b e2 9b 9d ff 17 30 |.....'.].;.....0| +00000040 96 e3 06 1a d6 c6 04 9c f3 9a 15 76 13 02 00 00 |...........v....| +00000050 55 00 2b 00 02 03 04 00 33 00 45 00 17 00 41 04 |U.+.....3.E...A.| +00000060 1e 18 37 ef 0d 19 51 88 35 75 71 b5 e5 54 5b 12 |..7...Q.5uq..T[.| +00000070 2e 8f 09 67 fd a7 24 20 3e b2 56 1c ce 97 28 5e |...g..$ >.V...(^| +00000080 f8 2b 2d 4f 9e f1 07 9f 6c 4b 5b 83 56 e2 32 42 |.+-O....lK[.V.2B| +00000090 e9 58 b6 d7 49 a6 b5 68 1a 41 03 56 6b dc 5a 89 |.X..I..h.A.Vk.Z.| +000000a0 00 29 00 02 00 00 17 03 03 00 17 48 f2 b1 a7 11 |.).........H....| +000000b0 68 36 e4 67 b8 e8 d0 6d b8 76 fa 4b 7e bc d0 63 |h6.g...m.v.K~..c| +000000c0 6a 8c 17 03 03 00 45 49 37 80 89 e3 4d b5 60 4a |j.....EI7...M.`J| +000000d0 7c 52 a0 f5 e9 32 85 ad 8a 59 0b 27 66 c7 2f ec ||R...2...Y.'f./.| +000000e0 55 7f 2c 9b 1e ef 0a 11 e1 72 1f 72 b2 10 9f 3f |U.,......r.r...?| +000000f0 bb 51 8f d0 fe e8 62 fd 93 e4 0d e1 57 7f 3a 3c |.Q....b.....W.:<| +00000100 22 b4 ca 20 04 cd 65 94 44 df 1a 1c 17 03 03 00 |".. ..e.D.......| +00000110 a3 38 02 96 5e c2 6d ad 2d 17 79 63 15 bd 06 af |.8..^.m.-.yc....| +00000120 e3 ae 5a 94 66 b5 2d 12 d1 bc 9c 16 56 ac 71 fe |..Z.f.-.....V.q.| +00000130 d7 af 1f 27 9a 22 1a d2 de da 90 ca d5 7f 79 d1 |...'."........y.| +00000140 8a 6e c6 76 e7 76 b4 cc 9b d5 b5 ed b5 b2 9d 4e |.n.v.v.........N| +00000150 f8 88 a0 b1 14 91 8b 6b d9 b8 5d 34 61 8a a3 b3 |.......k..]4a...| +00000160 c8 db e9 c9 8d a7 53 d8 46 f0 bd 4b 30 bf 49 3d |......S.F..K0.I=| +00000170 cc 42 d3 fb b7 f3 ad 78 5b 01 38 5d c3 22 d0 51 |.B.....x[.8].".Q| +00000180 cb a3 d9 fe 61 f9 4a ee 7d 89 8b 88 22 2b 9b fe |....a.J.}..."+..| +00000190 19 cd 17 b7 9e 81 57 f6 cb 14 29 cb 3b 87 0e 83 |......W...).;...| +000001a0 5a 84 7c 13 2d c8 d4 a7 6a db 1d 10 c6 04 ed 0d |Z.|.-...j.......| +000001b0 1d d7 06 bb |....| +>>> Flow 5 (client to server) +00000000 17 03 03 00 45 44 0b 11 40 bf 4b b4 2b 12 76 b3 |....ED..@.K.+.v.| +00000010 e4 59 b3 91 bb 45 21 b3 78 aa dc 76 66 dd d6 3c |.Y...E!.x..vf..<| +00000020 21 cf 32 5c 37 85 ef fb c7 53 cb 55 9c a5 40 0a |!.2\7....S.U..@.| +00000030 9d f8 aa b4 e3 e4 51 bf d8 cb 15 44 f0 02 19 52 |......Q....D...R| +00000040 62 73 82 f2 c2 ae d2 03 0e dc |bs........| +>>> Flow 6 (server to client) +00000000 17 03 03 00 1e fe e8 25 be 32 b9 ce db 3d 36 54 |.......%.2...=6T| +00000010 78 7c 70 50 0e 8e f4 04 ec a9 2e 88 7b e5 23 23 |x|pP........{.##| +00000020 72 f4 04 17 03 03 00 13 cc 7c 8e 1b 85 30 16 57 |r........|...0.W| +00000030 b0 39 6a 3a b3 ee 57 82 17 03 c9 |.9j:..W....| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv13-ResumeDisabled b/libgo/go/crypto/tls/testdata/Server-TLSv13-ResumeDisabled new file mode 100644 index 00000000000..1ba7ca1578b --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Server-TLSv13-ResumeDisabled @@ -0,0 +1,104 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 01 a4 01 00 01 a0 03 03 96 06 be 39 9a |..............9.| +00000010 6b 71 35 ab f4 2a d2 66 4d 8f 2c 86 c9 b6 7b e1 |kq5..*.fM.,...{.| +00000020 85 55 81 f5 90 49 20 c9 d7 5d ea 20 a2 da 4f 31 |.U...I ..]. ..O1| +00000030 a6 7a bd 07 5d 24 2e 88 1c 88 0e 19 1e 33 51 51 |.z..]$.......3QQ| +00000040 a1 14 df d7 70 b5 62 6d 28 a8 5f 0e 00 08 13 02 |....p.bm(._.....| +00000050 13 03 13 01 00 ff 01 00 01 4f 00 00 00 0e 00 0c |.........O......| +00000060 00 00 09 31 32 37 2e 30 2e 30 2e 31 00 0b 00 04 |...127.0.0.1....| +00000070 03 00 01 02 00 0a 00 0c 00 0a 00 1d 00 17 00 1e |................| +00000080 00 19 00 18 00 23 00 00 00 16 00 00 00 17 00 00 |.....#..........| +00000090 00 0d 00 1e 00 1c 04 03 05 03 06 03 08 07 08 08 |................| +000000a0 08 09 08 0a 08 0b 08 04 08 05 08 06 04 01 05 01 |................| +000000b0 06 01 00 2b 00 03 02 03 04 00 2d 00 02 01 01 00 |...+......-.....| +000000c0 33 00 26 00 24 00 1d 00 20 6d b7 14 7e 1b 7e c5 |3.&.$... m..~.~.| +000000d0 2b 54 1e 88 bd 64 23 49 84 31 73 f0 b8 55 6c 23 |+T...d#I.1s..Ul#| +000000e0 9e 77 b9 c5 53 a5 7f 1d 15 00 29 00 bc 00 87 00 |.w..S.....).....| +000000f0 81 50 46 ad c1 db a8 38 86 7b 2b bb fd d0 c3 42 |.PF....8.{+....B| +00000100 3e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |>...............| +00000110 00 94 68 2c a3 81 51 ed 14 ef 68 ca 42 c5 4c e2 |..h,..Q...h.B.L.| +00000120 e9 ab 5a 10 63 08 88 5d 47 1a 77 c1 7c 72 14 12 |..Z.c..]G.w.|r..| +00000130 24 5f 79 c4 ce 1a 7c 08 bf 81 6d 0e 55 e6 2d 0d |$_y...|...m.U.-.| +00000140 00 68 79 bc 2d ea f4 19 fd 43 ef 51 3f b5 5f 49 |.hy.-....C.Q?._I| +00000150 38 16 e0 74 43 a4 e9 95 f6 6d eb bf 6d e2 57 79 |8..tC....m..m.Wy| +00000160 7a 6e 53 12 bd a2 e0 32 98 1d 4e cb ae 72 1f 4c |znS....2..N..r.L| +00000170 38 4c 00 00 00 00 00 31 30 b6 c5 6e 26 02 64 56 |8L.....10..n&.dV| +00000180 65 ab 95 9c 16 62 d0 c5 57 41 c7 4c 78 72 44 c7 |e....b..WA.LxrD.| +00000190 4f a4 dc e1 d3 ef 49 af 7d a1 e5 ce 6f 22 f9 ec |O.....I.}...o"..| +000001a0 f4 b3 e4 32 e3 99 b0 85 39 |...2....9| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 00 00 00 00 00 |....z...v.......| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 a2 da 4f 31 |........... ..O1| +00000030 a6 7a bd 07 5d 24 2e 88 1c 88 0e 19 1e 33 51 51 |.z..]$.......3QQ| +00000040 a1 14 df d7 70 b5 62 6d 28 a8 5f 0e 13 02 00 00 |....p.bm(._.....| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 2f |..+.....3.$... /| +00000060 e5 7d a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 |.}.G.bC.(.._.).0| +00000070 ff f6 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 14 |.........._X.;t.| +00000080 03 03 00 01 01 17 03 03 00 17 5a 35 3d 19 9b a7 |..........Z5=...| +00000090 a4 45 2c c3 09 ae 85 be 08 fe 1d e2 9a 5d 7a 4b |.E,..........]zK| +000000a0 8e 17 03 03 02 6d 87 db fb 18 21 96 c7 2b fb ff |.....m....!..+..| +000000b0 89 b9 25 f6 0d 89 0f b4 17 bb 17 e1 ba 95 b7 cd |..%.............| +000000c0 c2 75 b5 8b d8 64 ff 7c dc e2 97 32 0c 2f e0 9f |.u...d.|...2./..| +000000d0 db b9 ef 14 9d cc e4 68 44 f7 0a 55 d2 b1 a0 f7 |.......hD..U....| +000000e0 fc de a5 99 f0 5d 0c 60 7b c3 25 85 f6 79 8f e6 |.....].`{.%..y..| +000000f0 cd 43 1c 43 d9 cd 28 ea ce 10 1c 16 68 b8 d7 3d |.C.C..(.....h..=| +00000100 b4 d4 db b4 bf 76 f8 45 23 d8 9f d1 be d1 bd db |.....v.E#.......| +00000110 9c 45 dd 28 3b 68 22 57 6c b7 65 fc 5e 66 f6 cb |.E.(;h"Wl.e.^f..| +00000120 a2 88 bd 96 e4 00 b5 85 ae 00 95 b9 da 42 16 c9 |.............B..| +00000130 c9 63 c2 67 ec 22 65 6e 66 0e cf de 68 ad e7 87 |.c.g."enf...h...| +00000140 ae 63 b4 e9 1c c0 2f 1e 79 7e a3 3f 6d 2b 68 c1 |.c..../.y~.?m+h.| +00000150 e8 60 cd 26 e0 05 de fa 7b 77 45 71 d8 f9 03 d7 |.`.&....{wEq....| +00000160 d3 50 51 15 cf fc 39 fa 07 19 28 5e e8 2d 31 00 |.PQ...9...(^.-1.| +00000170 2a e1 a4 21 31 83 4e 7d 51 e7 53 eb 33 22 51 fe |*..!1.N}Q.S.3"Q.| +00000180 15 04 e9 3d 73 89 3b 56 3f c6 ec 6e 0a 71 68 a6 |...=s.;V?..n.qh.| +00000190 76 f3 f1 aa 4e d0 9f 85 45 3f 7b aa ae ad 42 b9 |v...N...E?{...B.| +000001a0 07 64 ab ad 03 b1 33 78 93 f0 49 95 65 fb 81 8c |.d....3x..I.e...| +000001b0 04 ee e7 f3 2c 0a 99 51 e5 ef 05 14 d3 93 37 2b |....,..Q......7+| +000001c0 73 96 81 6f f5 9b a3 9a 20 95 5c 13 fc 97 3e c0 |s..o.... .\...>.| +000001d0 87 e4 ec 00 84 0b f2 09 29 63 dd 54 03 ce e0 43 |........)c.T...C| +000001e0 e9 16 a0 98 32 3e fa 58 1d 81 1e 56 ef 64 ff f7 |....2>.X...V.d..| +000001f0 b0 aa fc 5f 8c 89 48 76 ef d2 f1 d0 9c 16 f9 57 |..._..Hv.......W| +00000200 ac a6 4a a4 a8 75 ae fc 4b 9f ef 3c 28 a5 0c c1 |..J..u..K..<(...| +00000210 c8 72 82 bf e9 93 f2 42 00 0a 49 5d be c7 09 91 |.r.....B..I]....| +00000220 29 40 5e a6 ad ae 9c 69 6f d8 33 53 0a 50 5b 48 |)@^....io.3S.P[H| +00000230 7d d7 7e 1e 3b d3 ec e6 cf fe 1e 6a 27 a2 83 35 |}.~.;......j'..5| +00000240 28 13 2f 00 e5 29 c3 10 46 53 a1 17 15 59 5d 74 |(./..)..FS...Y]t| +00000250 f5 7c fa a5 71 34 32 75 48 e6 2c 1d 90 e8 c1 87 |.|..q42uH.,.....| +00000260 50 ac 17 27 b8 f7 a9 8e 59 58 d6 b8 d9 ef b6 57 |P..'....YX.....W| +00000270 b8 13 41 d0 eb 80 1c 48 66 1d 41 a5 b5 0d 12 17 |..A....Hf.A.....| +00000280 52 96 62 29 0e 4a 09 b4 50 b8 37 c3 8f 85 67 27 |R.b).J..P.7...g'| +00000290 d9 6f 33 11 95 ca 0a 36 75 ef 15 45 81 d3 ad 7d |.o3....6u..E...}| +000002a0 1a ff a7 0c 47 21 37 24 27 ce 42 68 5f 5d 7c fe |....G!7$'.Bh_]|.| +000002b0 0c f2 0b 81 ea f9 25 c9 99 c2 56 72 54 bd 2f 4c |......%...VrT./L| +000002c0 40 17 f0 54 a0 6e 1d 14 80 9c 3c d3 f9 81 0d 9d |@..T.n....<.....| +000002d0 e1 47 55 24 e4 62 0e 14 0d 46 3f 52 1b ef ab 45 |.GU$.b...F?R...E| +000002e0 d8 86 c7 ef aa e2 ea e6 5e 2e d8 89 33 46 a0 d0 |........^...3F..| +000002f0 39 e2 cc 13 1d 62 11 ae c0 73 71 b8 ef 4b 43 71 |9....b...sq..KCq| +00000300 dd 14 42 09 c9 10 4e bc b9 93 78 d6 83 02 40 c0 |..B...N...x...@.| +00000310 62 56 40 17 03 03 00 99 6e 03 4b 38 20 98 d7 3e |bV@.....n.K8 ..>| +00000320 52 33 e0 be 26 9b 38 4c 7f 2b c1 cc 84 22 7e 86 |R3..&.8L.+..."~.| +00000330 1d 39 f6 0a c0 ff e9 d9 4d 81 24 26 8d e1 c5 c0 |.9......M.$&....| +00000340 78 18 59 e0 6a ac 35 ad a0 6d 32 09 63 75 88 10 |x.Y.j.5..m2.cu..| +00000350 2b 6b d1 36 ea f9 03 41 a9 a7 26 82 38 37 aa 81 |+k.6...A..&.87..| +00000360 a1 7a 81 5c 0b db 63 32 06 e7 cb a8 1c 0a ff be |.z.\..c2........| +00000370 a2 e5 00 42 59 61 78 40 2e e2 85 0a ad 6b ea ae |...BYax@.....k..| +00000380 17 5a 92 f6 d3 8e 97 a2 18 a5 28 8a 41 1d 70 26 |.Z........(.A.p&| +00000390 bc d8 e7 38 ba c5 68 b9 ae f9 c6 27 bc 5b 3b 9f |...8..h....'.[;.| +000003a0 db ae 38 84 6f 18 3c e6 1d 30 cb 57 b1 95 63 1d |..8.o.<..0.W..c.| +000003b0 ef 17 03 03 00 45 40 43 00 0c 81 0a ed cf 35 9d |.....E@C......5.| +000003c0 45 0f 2b 66 ad b6 bd f9 72 9f 77 aa 87 9a 4f 9a |E.+f....r.w...O.| +000003d0 f4 1b 08 bd 33 aa f7 dc f1 78 58 d7 53 aa 82 12 |....3....xX.S...| +000003e0 b1 f7 c2 dd 8b 0d 90 81 e9 a9 7b 7c 17 52 fe ab |..........{|.R..| +000003f0 e4 94 06 d4 44 b4 7d 81 61 97 6b |....D.}.a.k| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 00 45 0e e9 bb 83 d4 |..........E.....| +00000010 41 da c6 75 69 c2 5c 74 0c 86 c7 b9 08 2f 35 da |A..ui.\t...../5.| +00000020 19 6f cf 43 a4 23 2f fe 59 5d 0f 1f 1e 0f ca e4 |.o.C.#/.Y]......| +00000030 7f 4e 7d bc ce 77 76 f2 ce 1c c4 e8 4e a9 80 a8 |.N}..wv.....N...| +00000040 72 16 5b 3c 97 8f 55 cb 76 cf fa 02 29 41 af 6d |r.[<..U.v...)A.m| +>>> Flow 4 (server to client) +00000000 17 03 03 00 1e f2 5e b6 bd bc c3 c2 58 fe 90 e9 |......^.....X...| +00000010 07 07 a2 ab 66 41 f7 c4 1f 48 48 01 c9 38 d2 c7 |....fA...HH..8..| +00000020 c0 ab b5 17 03 03 00 13 db 6e 0e f9 4a 94 12 a3 |.........n..J...| +00000030 2a 86 3f d1 a7 ac c3 58 20 0d 09 |*.?....X ..| diff --git a/libgo/go/crypto/tls/testdata/Server-TLSv13-X25519 b/libgo/go/crypto/tls/testdata/Server-TLSv13-X25519 new file mode 100644 index 00000000000..244651268a6 --- /dev/null +++ b/libgo/go/crypto/tls/testdata/Server-TLSv13-X25519 @@ -0,0 +1,102 @@ +>>> Flow 1 (client to server) +00000000 16 03 01 00 d8 01 00 00 d4 03 03 3d 42 5b bc 55 |...........=B[.U| +00000010 6c e3 e9 9a db 07 85 ca 18 fb f3 e0 56 18 b5 39 |l...........V..9| +00000020 9d 43 91 41 38 a0 ea c1 eb db ec 20 ca b8 c3 6e |.C.A8...... ...n| +00000030 c8 78 18 88 ab cf c3 cb 7e ff 7d e5 7e d5 55 94 |.x......~.}.~.U.| +00000040 f8 b2 01 ad 8c 95 82 f0 8e d8 61 8e 00 08 13 02 |..........a.....| +00000050 13 03 13 01 00 ff 01 00 00 83 00 00 00 0e 00 0c |................| +00000060 00 00 09 31 32 37 2e 30 2e 30 2e 31 00 0b 00 04 |...127.0.0.1....| +00000070 03 00 01 02 00 0a 00 04 00 02 00 1d 00 16 00 00 |................| +00000080 00 17 00 00 00 0d 00 1e 00 1c 04 03 05 03 06 03 |................| +00000090 08 07 08 08 08 09 08 0a 08 0b 08 04 08 05 08 06 |................| +000000a0 04 01 05 01 06 01 00 2b 00 03 02 03 04 00 2d 00 |.......+......-.| +000000b0 02 01 01 00 33 00 26 00 24 00 1d 00 20 e8 82 c0 |....3.&.$... ...| +000000c0 e9 dc b5 e1 3f 74 c9 42 e9 98 d1 1b fb 68 52 5d |....?t.B.....hR]| +000000d0 3e c1 65 56 6c 12 2b 3b ad 02 7c 80 42 |>.eVl.+;..|.B| +>>> Flow 2 (server to client) +00000000 16 03 03 00 7a 02 00 00 76 03 03 00 00 00 00 00 |....z...v.......| +00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +00000020 00 00 00 00 00 00 00 00 00 00 00 20 ca b8 c3 6e |........... ...n| +00000030 c8 78 18 88 ab cf c3 cb 7e ff 7d e5 7e d5 55 94 |.x......~.}.~.U.| +00000040 f8 b2 01 ad 8c 95 82 f0 8e d8 61 8e 13 02 00 00 |..........a.....| +00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 2f |..+.....3.$... /| +00000060 e5 7d a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 |.}.G.bC.(.._.).0| +00000070 ff f6 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 14 |.........._X.;t.| +00000080 03 03 00 01 01 17 03 03 00 17 09 03 3f 82 c1 8c |............?...| +00000090 42 42 8d be 40 51 f5 ba 5d b8 60 d9 87 0f d5 ca |BB..@Q..].`.....| +000000a0 3d 17 03 03 02 6d 95 e6 a7 87 7a 4a fb 68 16 3b |=....m....zJ.h.;| +000000b0 38 cb b0 7c 97 39 1e 00 46 7b 2c 32 00 02 6c 34 |8..|.9..F{,2..l4| +000000c0 de df 5a 3d 11 1b bc 28 d4 c1 05 fc 0c ca 28 e3 |..Z=...(......(.| +000000d0 90 c7 ad 88 43 45 12 fd 43 f5 be 7d 46 f8 d2 ec |....CE..C..}F...| +000000e0 00 8e 06 6f 09 0d ce 84 15 5a e7 59 1c f7 10 d4 |...o.....Z.Y....| +000000f0 2d 37 f2 71 a7 11 7e cb 3b 75 ec 8f d1 7a 8c d0 |-7.q..~.;u...z..| +00000100 f0 b1 18 aa 2f 3b e8 18 ff ae 0f 63 6b 41 3e 4a |..../;.....ckA>J| +00000110 04 56 72 1b e0 60 74 a2 ef 1d 81 61 eb 94 56 25 |.Vr..`t....a..V%| +00000120 e6 46 03 9a 2f 57 85 ca 3a f4 17 81 e3 cf 6c 2e |.F../W..:.....l.| +00000130 63 66 48 0f 5f f7 7b 5a 55 25 4b cc 24 c9 71 dd |cfH._.{ZU%K.$.q.| +00000140 42 32 d8 77 6f c5 69 bb 6b c5 c9 51 cb 37 97 ae |B2.wo.i.k..Q.7..| +00000150 c3 a3 87 5c 50 e1 f3 19 84 d6 9a 7c 56 0d 63 cc |...\P......|V.c.| +00000160 57 66 17 c8 a6 e2 f0 31 bb 20 3b 7e 9e 4e 30 fe |Wf.....1. ;~.N0.| +00000170 1e 22 07 71 29 76 c0 a2 7e da 3c 1d 04 31 f8 54 |.".q)v..~.<..1.T| +00000180 95 3a 84 71 d8 6b ed 43 e9 ad e9 45 c9 72 ad 0e |.:.q.k.C...E.r..| +00000190 8d 02 21 a6 89 6f 4b 83 5f fd 7f ff 3e cb d0 f7 |..!..oK._...>...| +000001a0 d3 94 54 7a 82 47 d3 8f 21 2f 1b f8 bf 95 e9 34 |..Tz.G..!/.....4| +000001b0 cd 06 d6 77 04 c8 57 49 df 0a c0 84 c7 ec 86 ed |...w..WI........| +000001c0 75 ca 33 56 b4 e8 d3 7c 45 e7 b4 c8 92 9a 73 c8 |u.3V...|E.....s.| +000001d0 eb 30 df 76 d2 61 70 9a 31 c5 a1 d8 4f 3a 1f dc |.0.v.ap.1...O:..| +000001e0 df 3d 85 9f b8 48 ed 78 aa 9e c1 ba 07 84 30 ec |.=...H.x......0.| +000001f0 e5 83 1c 63 47 53 2c 06 85 40 a9 78 ea 4e a0 e3 |...cGS,..@.x.N..| +00000200 2f 7d 67 39 38 c2 80 66 ff 62 8e 68 1f 67 17 b8 |/}g98..f.b.h.g..| +00000210 6b af 3c cc 81 46 5a 83 bf 1e ed 65 0e 81 05 fa |k.<..FZ....e....| +00000220 ac 06 df 63 4e af 9e 02 7f 16 2b 5f b4 0a 5e d9 |...cN.....+_..^.| +00000230 e5 d1 39 4a 42 d5 34 43 9b 32 ba d8 b7 ad c8 b0 |..9JB.4C.2......| +00000240 38 81 6f 93 8e 5e ee b7 86 75 d8 f4 bb 15 33 5e |8.o..^...u....3^| +00000250 a8 39 e4 ee 7f ef 15 7b ec e1 d7 95 31 e1 83 db |.9.....{....1...| +00000260 00 34 2e 22 02 59 33 2a a6 b5 73 f7 04 4d f5 40 |.4.".Y3*..s..M.@| +00000270 b7 97 97 33 a0 e2 c3 cf 4b 0a bd 27 84 a1 bb 0b |...3....K..'....| +00000280 2c 59 bd 3e 2c 82 48 b6 a5 b8 a9 20 00 37 8a 8e |,Y.>,.H.... .7..| +00000290 f8 f2 4e e2 16 5c fb bf 92 94 37 6a 82 b8 b1 35 |..N..\....7j...5| +000002a0 4f 77 9e dd 78 1a 07 85 42 3d de fc dc 7f 8c f4 |Ow..x...B=......| +000002b0 fa 30 de 15 a4 dd c2 08 d5 3d 08 f4 a8 0f f0 df |.0.......=......| +000002c0 6c 18 40 65 49 ce ce 78 99 5c bc 96 f2 02 2a 1b |l.@eI..x.\....*.| +000002d0 5f e7 3d 50 ea 9c b4 39 84 33 05 df 3d 1c 3c f7 |_.=P...9.3..=.<.| +000002e0 3e 55 b6 08 1b 51 b2 87 2b bb 0e 78 1d 7c 19 16 |>U...Q..+..x.|..| +000002f0 1f 8c ab 6c 56 2b 08 8b 57 2e f9 90 d9 50 a1 30 |...lV+..W....P.0| +00000300 14 05 54 26 3b 03 0c 46 ec b3 bd c7 eb ce b7 d7 |..T&;..F........| +00000310 31 64 40 17 03 03 00 99 d5 7d 3d d2 c0 c4 23 6b |1d@......}=...#k| +00000320 2c 1b 87 70 62 8c c5 63 6b 34 5b 69 e6 2d 61 7a |,..pb..ck4[i.-az| +00000330 7f 8d 36 96 68 30 71 4b 5c 60 3a dc 28 58 80 ef |..6.h0qK\`:.(X..| +00000340 09 60 e0 fd 64 d4 fb e5 d3 2f 0a 03 52 78 e4 0b |.`..d..../..Rx..| +00000350 c8 03 d2 0d 13 36 19 46 50 41 ee 07 44 f8 cc 0b |.....6.FPA..D...| +00000360 53 f9 42 0d 75 88 6f d0 52 02 67 22 bf df 4b a3 |S.B.u.o.R.g"..K.| +00000370 0a 43 10 54 27 53 49 5d b3 41 37 df 5b 22 7b b4 |.C.T'SI].A7.["{.| +00000380 52 21 c7 55 bd 99 a9 0a 0e 46 07 99 b0 38 dc 53 |R!.U.....F...8.S| +00000390 0e f2 76 82 d9 15 35 62 bb 6d 87 10 a9 91 74 ad |..v...5b.m....t.| +000003a0 b6 8e 4f 22 b8 72 05 5e de 06 e4 de 70 b3 7b 72 |..O".r.^....p.{r| +000003b0 3e 17 03 03 00 45 ae 7c de bb a6 79 ca fd 6c fa |>....E.|...y..l.| +000003c0 26 8b b2 6a eb 40 c0 b0 a7 98 e8 7a 0c e9 ea b3 |&..j.@.....z....| +000003d0 30 5f b7 fd 52 85 c8 56 93 dc 3a b0 e8 bd 5a d1 |0_..R..V..:...Z.| +000003e0 2d 94 87 27 c9 4c 57 66 35 bb e7 a5 d2 bf fd 27 |-..'.LWf5......'| +000003f0 f7 bd e1 8c a7 50 35 64 cc d5 26 17 03 03 00 a3 |.....P5d..&.....| +00000400 0d a3 74 9e 7e 5c bf d9 cb 27 e0 d2 c6 25 bd 29 |..t.~\...'...%.)| +00000410 49 23 76 24 91 a8 d0 58 28 60 1d 68 75 ec f8 05 |I#v$...X(`.hu...| +00000420 18 dd 0d b3 a8 27 98 82 78 81 e1 ee 03 69 8f 26 |.....'..x....i.&| +00000430 00 94 59 63 ef 9b c9 24 0f c8 99 97 64 4c a3 41 |..Yc...$....dL.A| +00000440 71 71 88 55 cd a2 61 e9 47 ed 9b e0 5b a8 f9 dc |qq.U..a.G...[...| +00000450 e6 25 8a 1d e8 18 12 1a 3c b7 d6 86 cc 4b 9f 70 |.%......<....K.p| +00000460 93 53 cf 8e d2 98 99 74 2a 37 96 07 a9 d5 bd 8e |.S.....t*7......| +00000470 eb 09 01 a4 4d 46 c8 7b ab 2c 2d 25 7c fc 89 e6 |....MF.{.,-%|...| +00000480 ac 23 92 98 de 38 1b e4 70 b3 ee 95 9b 83 03 ce |.#...8..p.......| +00000490 bb 17 df 13 1d 5a 9f be 55 3f dc 28 4b 43 4e fd |.....Z..U?.(KCN.| +000004a0 74 00 19 |t..| +>>> Flow 3 (client to server) +00000000 14 03 03 00 01 01 17 03 03 00 45 b0 11 eb 24 17 |..........E...$.| +00000010 1c a4 d5 68 80 b2 21 4b 6d 12 fd 67 c9 8a a8 87 |...h..!Km..g....| +00000020 27 e9 39 fd 9f 5f e4 ce 82 4f 9f 8d 2f d3 b9 04 |'.9.._...O../...| +00000030 d0 a8 00 33 5c 58 3f 75 be d5 8b ff 9a e4 30 cb |...3\X?u......0.| +00000040 4b e2 4d d3 0a e8 3f bb 89 98 1e 87 25 0f 4e 67 |K.M...?.....%.Ng| +>>> Flow 4 (server to client) +00000000 17 03 03 00 1e 1e 07 ae 09 4a 05 7b ee f6 ce a5 |.........J.{....| +00000010 18 11 76 89 e8 67 ed 22 41 d2 a3 b6 cc bc c8 e9 |..v..g."A.......| +00000020 73 02 7c 17 03 03 00 13 c2 87 1e 19 ea 01 63 5a |s.|...........cZ| +00000030 aa 72 b2 95 f0 05 08 71 95 0c 75 |.r.....q..u| diff --git a/libgo/go/crypto/tls/ticket.go b/libgo/go/crypto/tls/ticket.go index 3e7aa93c82a..9560176259e 100644 --- a/libgo/go/crypto/tls/ticket.go +++ b/libgo/go/crypto/tls/ticket.go @@ -12,6 +12,7 @@ import ( "crypto/sha256" "crypto/subtle" "errors" + "internal/x/crypto/cryptobyte" "io" ) @@ -27,31 +28,6 @@ type sessionState struct { usedOldKey bool } -func (s *sessionState) equal(i interface{}) bool { - s1, ok := i.(*sessionState) - if !ok { - return false - } - - if s.vers != s1.vers || - s.cipherSuite != s1.cipherSuite || - !bytes.Equal(s.masterSecret, s1.masterSecret) { - return false - } - - if len(s.certificates) != len(s1.certificates) { - return false - } - - for i := range s.certificates { - if !bytes.Equal(s.certificates[i], s1.certificates[i]) { - return false - } - } - - return true -} - func (s *sessionState) marshal() []byte { length := 2 + 2 + 2 + len(s.masterSecret) + 2 for _, cert := range s.certificates { @@ -129,9 +105,50 @@ func (s *sessionState) unmarshal(data []byte) bool { return len(data) == 0 } -func (c *Conn) encryptTicket(state *sessionState) ([]byte, error) { - serialized := state.marshal() - encrypted := make([]byte, ticketKeyNameLen+aes.BlockSize+len(serialized)+sha256.Size) +// sessionStateTLS13 is the content of a TLS 1.3 session ticket. Its first +// version (revision = 0) doesn't carry any of the information needed for 0-RTT +// validation and the nonce is always empty. +type sessionStateTLS13 struct { + // uint8 version = 0x0304; + // uint8 revision = 0; + cipherSuite uint16 + createdAt uint64 + resumptionSecret []byte // opaque resumption_master_secret<1..2^8-1>; + certificate Certificate // CertificateEntry certificate_list<0..2^24-1>; +} + +func (m *sessionStateTLS13) marshal() []byte { + var b cryptobyte.Builder + b.AddUint16(VersionTLS13) + b.AddUint8(0) // revision + b.AddUint16(m.cipherSuite) + addUint64(&b, m.createdAt) + b.AddUint8LengthPrefixed(func(b *cryptobyte.Builder) { + b.AddBytes(m.resumptionSecret) + }) + marshalCertificate(&b, m.certificate) + return b.BytesOrPanic() +} + +func (m *sessionStateTLS13) unmarshal(data []byte) bool { + *m = sessionStateTLS13{} + s := cryptobyte.String(data) + var version uint16 + var revision uint8 + return s.ReadUint16(&version) && + version == VersionTLS13 && + s.ReadUint8(&revision) && + revision == 0 && + s.ReadUint16(&m.cipherSuite) && + readUint64(&s, &m.createdAt) && + readUint8LengthPrefixed(&s, &m.resumptionSecret) && + len(m.resumptionSecret) != 0 && + unmarshalCertificate(&s, &m.certificate) && + s.Empty() +} + +func (c *Conn) encryptTicket(state []byte) ([]byte, error) { + encrypted := make([]byte, ticketKeyNameLen+aes.BlockSize+len(state)+sha256.Size) keyName := encrypted[:ticketKeyNameLen] iv := encrypted[ticketKeyNameLen : ticketKeyNameLen+aes.BlockSize] macBytes := encrypted[len(encrypted)-sha256.Size:] @@ -145,7 +162,7 @@ func (c *Conn) encryptTicket(state *sessionState) ([]byte, error) { if err != nil { return nil, errors.New("tls: failed to create cipher while encrypting ticket: " + err.Error()) } - cipher.NewCTR(block, iv).XORKeyStream(encrypted[ticketKeyNameLen+aes.BlockSize:], serialized) + cipher.NewCTR(block, iv).XORKeyStream(encrypted[ticketKeyNameLen+aes.BlockSize:], state) mac := hmac.New(sha256.New, key.hmacKey[:]) mac.Write(encrypted[:len(encrypted)-sha256.Size]) @@ -154,15 +171,15 @@ func (c *Conn) encryptTicket(state *sessionState) ([]byte, error) { return encrypted, nil } -func (c *Conn) decryptTicket(encrypted []byte) (*sessionState, bool) { - if c.config.SessionTicketsDisabled || - len(encrypted) < ticketKeyNameLen+aes.BlockSize+sha256.Size { +func (c *Conn) decryptTicket(encrypted []byte) (plaintext []byte, usedOldKey bool) { + if len(encrypted) < ticketKeyNameLen+aes.BlockSize+sha256.Size { return nil, false } keyName := encrypted[:ticketKeyNameLen] iv := encrypted[ticketKeyNameLen : ticketKeyNameLen+aes.BlockSize] macBytes := encrypted[len(encrypted)-sha256.Size:] + ciphertext := encrypted[ticketKeyNameLen+aes.BlockSize : len(encrypted)-sha256.Size] keys := c.config.ticketKeys() keyIndex := -1 @@ -190,11 +207,8 @@ func (c *Conn) decryptTicket(encrypted []byte) (*sessionState, bool) { if err != nil { return nil, false } - ciphertext := encrypted[ticketKeyNameLen+aes.BlockSize : len(encrypted)-sha256.Size] - plaintext := ciphertext + plaintext = make([]byte, len(ciphertext)) cipher.NewCTR(block, iv).XORKeyStream(plaintext, ciphertext) - state := &sessionState{usedOldKey: keyIndex > 0} - ok := state.unmarshal(plaintext) - return state, ok + return plaintext, keyIndex > 0 } diff --git a/libgo/go/crypto/tls/tls.go b/libgo/go/crypto/tls/tls.go index 8fd42943159..f8e32ab4951 100644 --- a/libgo/go/crypto/tls/tls.go +++ b/libgo/go/crypto/tls/tls.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Package tls partially implements TLS 1.2, as specified in RFC 5246. +// Package tls partially implements TLS 1.2, as specified in RFC 5246, +// and TLS 1.3, as specified in RFC 8446. package tls // BUG(agl): The crypto/tls package only implements some countermeasures diff --git a/libgo/go/crypto/tls/tls_test.go b/libgo/go/crypto/tls/tls_test.go index 7542699bdc9..00bb6e4ef37 100644 --- a/libgo/go/crypto/tls/tls_test.go +++ b/libgo/go/crypto/tls/tls_test.go @@ -253,6 +253,9 @@ func testConnReadNonzeroAndEOF(t *testing.T, delay time.Duration) error { }() clientConfig := testConfig.Clone() + // In TLS 1.3, alerts are encrypted and disguised as application data, so + // the opportunistic peek won't work. + clientConfig.MaxVersion = VersionTLS12 conn, err := Dial("tcp", ln.Addr().String(), clientConfig) if err != nil { t.Fatal(err) @@ -298,6 +301,7 @@ func TestTLSUniqueMatches(t *testing.T) { return } serverConfig := testConfig.Clone() + serverConfig.MaxVersion = VersionTLS12 // TLSUnique is not defined in TLS 1.3 srv := Server(sconn, serverConfig) if err := srv.Handshake(); err != nil { t.Error(err) @@ -352,19 +356,22 @@ func TestVerifyHostname(t *testing.T) { if err := c.VerifyHostname("www.google.com"); err == nil { t.Fatalf("verify www.google.com succeeded with InsecureSkipVerify=true") } - if err := c.VerifyHostname("www.yahoo.com"); err == nil { - t.Fatalf("verify www.google.com succeeded with InsecureSkipVerify=true") - } } func TestVerifyHostnameResumed(t *testing.T) { + t.Run("TLSv12", func(t *testing.T) { testVerifyHostnameResumed(t, VersionTLS12) }) + t.Run("TLSv13", func(t *testing.T) { testVerifyHostnameResumed(t, VersionTLS13) }) +} + +func testVerifyHostnameResumed(t *testing.T, version uint16) { testenv.MustHaveExternalNetwork(t) config := &Config{ + MaxVersion: version, ClientSessionCache: NewLRUClientSessionCache(32), } for i := 0; i < 2; i++ { - c, err := Dial("tcp", "www.google.com:https", config) + c, err := Dial("tcp", "mail.google.com:https", config) if err != nil { t.Fatalf("Dial #%d: %v", i, err) } @@ -372,11 +379,21 @@ func TestVerifyHostnameResumed(t *testing.T) { if i > 0 && !cs.DidResume { t.Fatalf("Subsequent connection unexpectedly didn't resume") } + if cs.Version != version { + t.Fatalf("Unexpectedly negotiated version %x", cs.Version) + } if cs.VerifiedChains == nil { t.Fatalf("Dial #%d: cs.VerifiedChains == nil", i) } - if err := c.VerifyHostname("www.google.com"); err != nil { - t.Fatalf("verify www.google.com #%d: %v", i, err) + if err := c.VerifyHostname("mail.google.com"); err != nil { + t.Fatalf("verify mail.google.com #%d: %v", i, err) + } + // Give the client a chance to read the server session tickets. + c.SetReadDeadline(time.Now().Add(500 * time.Millisecond)) + if _, err := c.Read(make([]byte, 1)); err != nil { + if err, ok := err.(net.Error); !ok || !err.Timeout() { + t.Fatal(err) + } } c.Close() } @@ -589,7 +606,7 @@ func TestWarningAlertFlood(t *testing.T) { if err == nil { return errors.New("unexpected lack of error from server") } - const expected = "too many warn" + const expected = "too many ignored" if str := err.Error(); !strings.Contains(str, expected) { return fmt.Errorf("expected error containing %q, but saw: %s", expected, str) } @@ -601,6 +618,7 @@ func TestWarningAlertFlood(t *testing.T) { go func() { errChan <- server() }() clientConfig := testConfig.Clone() + clientConfig.MaxVersion = VersionTLS12 // there are no warning alerts in TLS 1.3 conn, err := Dial("tcp", ln.Addr().String(), clientConfig) if err != nil { t.Fatal(err) @@ -610,7 +628,7 @@ func TestWarningAlertFlood(t *testing.T) { t.Fatal(err) } - for i := 0; i < maxWarnAlertCount+1; i++ { + for i := 0; i < maxUselessRecords+1; i++ { conn.sendAlert(alertNoRenegotiation) } @@ -749,7 +767,7 @@ func (w *changeImplConn) Close() error { return w.Conn.Close() } -func throughput(b *testing.B, totalBytes int64, dynamicRecordSizingDisabled bool) { +func throughput(b *testing.B, version uint16, totalBytes int64, dynamicRecordSizingDisabled bool) { ln := newLocalListener(b) defer ln.Close() @@ -785,6 +803,7 @@ func throughput(b *testing.B, totalBytes int64, dynamicRecordSizingDisabled bool clientConfig := testConfig.Clone() clientConfig.CipherSuites = nil // the defaults may prefer faster ciphers clientConfig.DynamicRecordSizingDisabled = dynamicRecordSizingDisabled + clientConfig.MaxVersion = version buf := make([]byte, bufsize) chunks := int(math.Ceil(float64(totalBytes) / float64(len(buf)))) @@ -812,7 +831,12 @@ func BenchmarkThroughput(b *testing.B) { for size := 1; size <= 64; size <<= 1 { name := fmt.Sprintf("%sPacket/%dMB", mode, size) b.Run(name, func(b *testing.B) { - throughput(b, int64(size<<20), mode == "Max") + b.Run("TLSv12", func(b *testing.B) { + throughput(b, VersionTLS12, int64(size<<20), mode == "Max") + }) + b.Run("TLSv13", func(b *testing.B) { + throughput(b, VersionTLS13, int64(size<<20), mode == "Max") + }) }) } } @@ -846,7 +870,7 @@ func (c *slowConn) Write(p []byte) (int, error) { return len(p), nil } -func latency(b *testing.B, bps int, dynamicRecordSizingDisabled bool) { +func latency(b *testing.B, version uint16, bps int, dynamicRecordSizingDisabled bool) { ln := newLocalListener(b) defer ln.Close() @@ -872,6 +896,7 @@ func latency(b *testing.B, bps int, dynamicRecordSizingDisabled bool) { clientConfig := testConfig.Clone() clientConfig.DynamicRecordSizingDisabled = dynamicRecordSizingDisabled + clientConfig.MaxVersion = version buf := make([]byte, 16384) peek := make([]byte, 1) @@ -903,7 +928,12 @@ func BenchmarkLatency(b *testing.B) { for _, kbps := range []int{200, 500, 1000, 2000, 5000} { name := fmt.Sprintf("%sPacket/%dkbps", mode, kbps) b.Run(name, func(b *testing.B) { - latency(b, kbps*1000, mode == "Max") + b.Run("TLSv12", func(b *testing.B) { + latency(b, VersionTLS12, kbps*1000, mode == "Max") + }) + b.Run("TLSv13", func(b *testing.B) { + latency(b, VersionTLS13, kbps*1000, mode == "Max") + }) }) } } @@ -916,3 +946,166 @@ func TestConnectionStateMarshal(t *testing.T) { t.Errorf("json.Marshal failed on ConnectionState: %v", err) } } + +func TestConnectionState(t *testing.T) { + issuer, err := x509.ParseCertificate(testRSACertificateIssuer) + if err != nil { + panic(err) + } + rootCAs := x509.NewCertPool() + rootCAs.AddCert(issuer) + + now := func() time.Time { return time.Unix(1476984729, 0) } + + const alpnProtocol = "golang" + const serverName = "example.golang" + var scts = [][]byte{[]byte("dummy sct 1"), []byte("dummy sct 2")} + var ocsp = []byte("dummy ocsp") + + for _, v := range []uint16{VersionTLS12, VersionTLS13} { + var name string + switch v { + case VersionTLS12: + name = "TLSv12" + case VersionTLS13: + name = "TLSv13" + } + t.Run(name, func(t *testing.T) { + config := &Config{ + Time: now, + Rand: zeroSource{}, + Certificates: make([]Certificate, 1), + MaxVersion: v, + RootCAs: rootCAs, + ClientCAs: rootCAs, + ClientAuth: RequireAndVerifyClientCert, + NextProtos: []string{alpnProtocol}, + ServerName: serverName, + } + config.Certificates[0].Certificate = [][]byte{testRSACertificate} + config.Certificates[0].PrivateKey = testRSAPrivateKey + config.Certificates[0].SignedCertificateTimestamps = scts + config.Certificates[0].OCSPStaple = ocsp + + ss, cs, err := testHandshake(t, config, config) + if err != nil { + t.Fatalf("Handshake failed: %v", err) + } + + if ss.Version != v || cs.Version != v { + t.Errorf("Got versions %x (server) and %x (client), expected %x", ss.Version, cs.Version, v) + } + + if !ss.HandshakeComplete || !cs.HandshakeComplete { + t.Errorf("Got HandshakeComplete %v (server) and %v (client), expected true", ss.HandshakeComplete, cs.HandshakeComplete) + } + + if ss.DidResume || cs.DidResume { + t.Errorf("Got DidResume %v (server) and %v (client), expected false", ss.DidResume, cs.DidResume) + } + + if ss.CipherSuite == 0 || cs.CipherSuite == 0 { + t.Errorf("Got invalid cipher suite: %v (server) and %v (client)", ss.CipherSuite, cs.CipherSuite) + } + + if ss.NegotiatedProtocol != alpnProtocol || cs.NegotiatedProtocol != alpnProtocol { + t.Errorf("Got negotiated protocol %q (server) and %q (client), expected %q", ss.NegotiatedProtocol, cs.NegotiatedProtocol, alpnProtocol) + } + + if !cs.NegotiatedProtocolIsMutual { + t.Errorf("Got false NegotiatedProtocolIsMutual on the client side") + } + // NegotiatedProtocolIsMutual on the server side is unspecified. + + if ss.ServerName != serverName { + t.Errorf("Got server name %q, expected %q", ss.ServerName, serverName) + } + if cs.ServerName != "" { + t.Errorf("Got unexpected server name on the client side") + } + + if len(ss.PeerCertificates) != 1 || len(cs.PeerCertificates) != 1 { + t.Errorf("Got %d (server) and %d (client) peer certificates, expected %d", len(ss.PeerCertificates), len(cs.PeerCertificates), 1) + } + + if len(ss.VerifiedChains) != 1 || len(cs.VerifiedChains) != 1 { + t.Errorf("Got %d (server) and %d (client) verified chains, expected %d", len(ss.VerifiedChains), len(cs.VerifiedChains), 1) + } else if len(ss.VerifiedChains[0]) != 2 || len(cs.VerifiedChains[0]) != 2 { + t.Errorf("Got %d (server) and %d (client) long verified chain, expected %d", len(ss.VerifiedChains[0]), len(cs.VerifiedChains[0]), 2) + } + + if len(cs.SignedCertificateTimestamps) != 2 { + t.Errorf("Got %d SCTs, expected %d", len(cs.SignedCertificateTimestamps), 2) + } + if !bytes.Equal(cs.OCSPResponse, ocsp) { + t.Errorf("Got OCSPs %x, expected %x", cs.OCSPResponse, ocsp) + } + // Only TLS 1.3 supports OCSP and SCTs on client certs. + if v == VersionTLS13 { + if len(ss.SignedCertificateTimestamps) != 2 { + t.Errorf("Got %d client SCTs, expected %d", len(ss.SignedCertificateTimestamps), 2) + } + if !bytes.Equal(ss.OCSPResponse, ocsp) { + t.Errorf("Got client OCSPs %x, expected %x", ss.OCSPResponse, ocsp) + } + } + + if v == VersionTLS13 { + if ss.TLSUnique != nil || cs.TLSUnique != nil { + t.Errorf("Got TLSUnique %x (server) and %x (client), expected nil in TLS 1.3", ss.TLSUnique, cs.TLSUnique) + } + } else { + if ss.TLSUnique == nil || cs.TLSUnique == nil { + t.Errorf("Got TLSUnique %x (server) and %x (client), expected non-nil", ss.TLSUnique, cs.TLSUnique) + } + } + }) + } +} + +// TestEscapeRoute tests that the library will still work if support for TLS 1.3 +// is dropped later in the Go 1.12 cycle. +func TestEscapeRoute(t *testing.T) { + defer func(savedSupportedVersions []uint16) { + supportedVersions = savedSupportedVersions + }(supportedVersions) + supportedVersions = []uint16{ + VersionTLS12, + VersionTLS11, + VersionTLS10, + VersionSSL30, + } + + ss, cs, err := testHandshake(t, testConfig, testConfig) + if err != nil { + t.Fatalf("Handshake failed when support for TLS 1.3 was dropped: %v", err) + } + if ss.Version != VersionTLS12 { + t.Errorf("Server negotiated version %x, expected %x", cs.Version, VersionTLS12) + } + if cs.Version != VersionTLS12 { + t.Errorf("Client negotiated version %x, expected %x", cs.Version, VersionTLS12) + } +} + +// Issue 28744: Ensure that we don't modify memory +// that Config doesn't own such as Certificates. +func TestBuildNameToCertificate_doesntModifyCertificates(t *testing.T) { + c0 := Certificate{ + Certificate: [][]byte{testRSACertificate}, + PrivateKey: testRSAPrivateKey, + } + c1 := Certificate{ + Certificate: [][]byte{testSNICertificate}, + PrivateKey: testRSAPrivateKey, + } + config := testConfig.Clone() + config.Certificates = []Certificate{c0, c1} + + config.BuildNameToCertificate() + got := config.Certificates + want := []Certificate{c0, c1} + if !reflect.DeepEqual(got, want) { + t.Fatalf("Certificates were mutated by BuildNameToCertificate\nGot: %#v\nWant: %#v\n", got, want) + } +} diff --git a/libgo/go/crypto/x509/cert_pool.go b/libgo/go/crypto/x509/cert_pool.go index a1646b98261..7c55c3b4a32 100644 --- a/libgo/go/crypto/x509/cert_pool.go +++ b/libgo/go/crypto/x509/cert_pool.go @@ -48,9 +48,9 @@ func (s *CertPool) copy() *CertPool { // SystemCertPool returns a copy of the system cert pool. // // Any mutations to the returned pool are not written to disk and do -// not affect any other pool. +// not affect any other pool returned by SystemCertPool. // -// New changes in the the system cert pool might not be reflected +// New changes in the system cert pool might not be reflected // in subsequent calls. func SystemCertPool() (*CertPool, error) { if runtime.GOOS == "windows" { @@ -65,32 +65,16 @@ func SystemCertPool() (*CertPool, error) { return loadSystemRoots() } -// findVerifiedParents attempts to find certificates in s which have signed the -// given certificate. If any candidates were rejected then errCert will be set -// to one of them, arbitrarily, and err will contain the reason that it was -// rejected. -func (s *CertPool) findVerifiedParents(cert *Certificate) (parents []int, errCert *Certificate, err error) { +// findPotentialParents returns the indexes of certificates in s which might +// have signed cert. The caller must not modify the returned slice. +func (s *CertPool) findPotentialParents(cert *Certificate) []int { if s == nil { - return + return nil } - var candidates []int - if len(cert.AuthorityKeyId) > 0 { - candidates = s.bySubjectKeyId[string(cert.AuthorityKeyId)] - } - if len(candidates) == 0 { - candidates = s.byName[string(cert.RawIssuer)] + return s.bySubjectKeyId[string(cert.AuthorityKeyId)] } - - for _, c := range candidates { - if err = cert.CheckSignatureFrom(s.certs[c]); err == nil { - parents = append(parents, c) - } else { - errCert = s.certs[c] - } - } - - return + return s.byName[string(cert.RawIssuer)] } func (s *CertPool) contains(cert *Certificate) bool { diff --git a/libgo/go/crypto/x509/pem_decrypt.go b/libgo/go/crypto/x509/pem_decrypt.go index 0388d63e149..93d1e4a922d 100644 --- a/libgo/go/crypto/x509/pem_decrypt.go +++ b/libgo/go/crypto/x509/pem_decrypt.go @@ -203,7 +203,7 @@ func EncryptPEMBlock(rand io.Reader, blockType string, data, password []byte, al // the data separately, but it doesn't seem worth the additional // code. copy(encrypted, data) - // See RFC 1423, section 1.1 + // See RFC 1423, Section 1.1. for i := 0; i < pad; i++ { encrypted = append(encrypted, byte(pad)) } diff --git a/libgo/go/crypto/x509/pkix/pkix.go b/libgo/go/crypto/x509/pkix/pkix.go index 3cc4d587e36..0f595780874 100644 --- a/libgo/go/crypto/x509/pkix/pkix.go +++ b/libgo/go/crypto/x509/pkix/pkix.go @@ -95,7 +95,7 @@ func (r RDNSequence) String() string { type RelativeDistinguishedNameSET []AttributeTypeAndValue // AttributeTypeAndValue mirrors the ASN.1 structure of the same name in -// https://tools.ietf.org/html/rfc5280#section-4.1.2.4 +// RFC 5280, Section 4.1.2.4. type AttributeTypeAndValue struct { Type asn1.ObjectIdentifier Value interface{} @@ -227,7 +227,7 @@ func (n Name) String() string { return n.ToRDNSequence().String() } -// oidInAttributeTypeAndValue returns whether a type with the given OID exists +// oidInAttributeTypeAndValue reports whether a type with the given OID exists // in atv. func oidInAttributeTypeAndValue(oid asn1.ObjectIdentifier, atv []AttributeTypeAndValue) bool { for _, a := range atv { diff --git a/libgo/go/crypto/x509/root_aix.go b/libgo/go/crypto/x509/root_aix.go index 4e7e9dde953..6d427739a43 100644 --- a/libgo/go/crypto/x509/root_aix.go +++ b/libgo/go/crypto/x509/root_aix.go @@ -1,4 +1,4 @@ -// Copyright 2017 The Go Authors. All rights reserved. +// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/libgo/go/crypto/x509/root_cgo_darwin.go b/libgo/go/crypto/x509/root_cgo_darwin.go index a02ac3cfe83..e6332072d62 100644 --- a/libgo/go/crypto/x509/root_cgo_darwin.go +++ b/libgo/go/crypto/x509/root_cgo_darwin.go @@ -16,7 +16,135 @@ package x509 #include #include -// FetchPEMRoots fetches the system's list of trusted X.509 root certificates. +static bool isSSLPolicy(SecPolicyRef policyRef) { + if (!policyRef) { + return false; + } + CFDictionaryRef properties = SecPolicyCopyProperties(policyRef); + if (properties == NULL) { + return false; + } + CFTypeRef value = NULL; + if (CFDictionaryGetValueIfPresent(properties, kSecPolicyOid, (const void **)&value)) { + CFRelease(properties); + return CFEqual(value, kSecPolicyAppleSSL); + } + CFRelease(properties); + return false; +} + +// sslTrustSettingsResult obtains the final kSecTrustSettingsResult value +// for a certificate in the user or admin domain, combining usage constraints +// for the SSL SecTrustSettingsPolicy, ignoring SecTrustSettingsKeyUsage and +// kSecTrustSettingsAllowedError. +// https://developer.apple.com/documentation/security/1400261-sectrustsettingscopytrustsetting +static SInt32 sslTrustSettingsResult(SecCertificateRef cert) { + CFArrayRef trustSettings = NULL; + OSStatus err = SecTrustSettingsCopyTrustSettings(cert, kSecTrustSettingsDomainUser, &trustSettings); + + // According to Apple's SecTrustServer.c, "user trust settings overrule admin trust settings", + // but the rules of the override are unclear. Let's assume admin trust settings are applicable + // if and only if user trust settings fail to load or are NULL. + if (err != errSecSuccess || trustSettings == NULL) { + if (trustSettings != NULL) CFRelease(trustSettings); + err = SecTrustSettingsCopyTrustSettings(cert, kSecTrustSettingsDomainAdmin, &trustSettings); + } + + // > no trust settings [...] means "this certificate must be verified to a known trusted certificate” + if (err != errSecSuccess || trustSettings == NULL) { + if (trustSettings != NULL) CFRelease(trustSettings); + return kSecTrustSettingsResultUnspecified; + } + + // > An empty trust settings array means "always trust this certificate” with an + // > overall trust setting for the certificate of kSecTrustSettingsResultTrustRoot. + if (CFArrayGetCount(trustSettings) == 0) { + CFRelease(trustSettings); + return kSecTrustSettingsResultTrustRoot; + } + + // kSecTrustSettingsResult is defined as CFSTR("kSecTrustSettingsResult"), + // but the Go linker's internal linking mode can't handle CFSTR relocations. + // Create our own dynamic string instead and release it below. + CFStringRef _kSecTrustSettingsResult = CFStringCreateWithCString( + NULL, "kSecTrustSettingsResult", kCFStringEncodingUTF8); + CFStringRef _kSecTrustSettingsPolicy = CFStringCreateWithCString( + NULL, "kSecTrustSettingsPolicy", kCFStringEncodingUTF8); + CFStringRef _kSecTrustSettingsPolicyString = CFStringCreateWithCString( + NULL, "kSecTrustSettingsPolicyString", kCFStringEncodingUTF8); + + CFIndex m; SInt32 result = 0; + for (m = 0; m < CFArrayGetCount(trustSettings); m++) { + CFDictionaryRef tSetting = (CFDictionaryRef)CFArrayGetValueAtIndex(trustSettings, m); + + // First, check if this trust setting applies to our policy. We assume + // only one will. The docs suggest that there might be multiple applying + // but don't explain how to combine them. + SecPolicyRef policyRef; + if (CFDictionaryGetValueIfPresent(tSetting, _kSecTrustSettingsPolicy, (const void**)&policyRef)) { + if (!isSSLPolicy(policyRef)) { + continue; + } + } else { + continue; + } + + if (CFDictionaryContainsKey(tSetting, _kSecTrustSettingsPolicyString)) { + // Restricted to a hostname, not a root. + continue; + } + + CFNumberRef cfNum; + if (CFDictionaryGetValueIfPresent(tSetting, _kSecTrustSettingsResult, (const void**)&cfNum)) { + CFNumberGetValue(cfNum, kCFNumberSInt32Type, &result); + } else { + // > If the value of the kSecTrustSettingsResult component is not + // > kSecTrustSettingsResultUnspecified for a usage constraints dictionary that has + // > no constraints, the default value kSecTrustSettingsResultTrustRoot is assumed. + result = kSecTrustSettingsResultTrustRoot; + } + + break; + } + + // If trust settings are present, but none of them match the policy... + // the docs don't tell us what to do. + // + // "Trust settings for a given use apply if any of the dictionaries in the + // certificate’s trust settings array satisfies the specified use." suggests + // that it's as if there were no trust settings at all, so we should probably + // fallback to the admin trust settings. TODO. + if (result == 0) { + result = kSecTrustSettingsResultUnspecified; + } + + CFRelease(_kSecTrustSettingsPolicy); + CFRelease(_kSecTrustSettingsPolicyString); + CFRelease(_kSecTrustSettingsResult); + CFRelease(trustSettings); + + return result; +} + +// isRootCertificate reports whether Subject and Issuer match. +static Boolean isRootCertificate(SecCertificateRef cert, CFErrorRef *errRef) { + CFDataRef subjectName = SecCertificateCopyNormalizedSubjectContent(cert, errRef); + if (*errRef != NULL) { + return false; + } + CFDataRef issuerName = SecCertificateCopyNormalizedIssuerContent(cert, errRef); + if (*errRef != NULL) { + CFRelease(subjectName); + return false; + } + Boolean equal = CFEqual(subjectName, issuerName); + CFRelease(subjectName); + CFRelease(issuerName); + return equal; +} + +// FetchPEMRoots fetches the system's list of trusted X.509 root certificates +// for the kSecTrustSettingsPolicy SSL. // // On success it returns 0 and fills pemRoots with a CFDataRef that contains the extracted root // certificates of the system. On failure, the function returns -1. @@ -24,26 +152,28 @@ package x509 // // Note: The CFDataRef returned in pemRoots and untrustedPemRoots must // be released (using CFRelease) after we've consumed its content. -int FetchPEMRoots(CFDataRef *pemRoots, CFDataRef *untrustedPemRoots) { +int FetchPEMRoots(CFDataRef *pemRoots, CFDataRef *untrustedPemRoots, bool debugDarwinRoots) { int i; + if (debugDarwinRoots) { + printf("crypto/x509: kSecTrustSettingsResultInvalid = %d\n", kSecTrustSettingsResultInvalid); + printf("crypto/x509: kSecTrustSettingsResultTrustRoot = %d\n", kSecTrustSettingsResultTrustRoot); + printf("crypto/x509: kSecTrustSettingsResultTrustAsRoot = %d\n", kSecTrustSettingsResultTrustAsRoot); + printf("crypto/x509: kSecTrustSettingsResultDeny = %d\n", kSecTrustSettingsResultDeny); + printf("crypto/x509: kSecTrustSettingsResultUnspecified = %d\n", kSecTrustSettingsResultUnspecified); + } + // Get certificates from all domains, not just System, this lets // the user add CAs to their "login" keychain, and Admins to add // to the "System" keychain SecTrustSettingsDomain domains[] = { kSecTrustSettingsDomainSystem, - kSecTrustSettingsDomainAdmin, - kSecTrustSettingsDomainUser }; + kSecTrustSettingsDomainAdmin, kSecTrustSettingsDomainUser }; int numDomains = sizeof(domains)/sizeof(SecTrustSettingsDomain); if (pemRoots == NULL) { return -1; } - // kSecTrustSettingsResult is defined as CFSTR("kSecTrustSettingsResult"), - // but the Go linker's internal linking mode can't handle CFSTR relocations. - // Create our own dynamic string instead and release it below. - CFStringRef policy = CFStringCreateWithCString(NULL, "kSecTrustSettingsResult", kCFStringEncodingUTF8); - CFMutableDataRef combinedData = CFDataCreateMutable(kCFAllocatorDefault, 0); CFMutableDataRef combinedUntrustedData = CFDataCreateMutable(kCFAllocatorDefault, 0); for (i = 0; i < numDomains; i++) { @@ -57,102 +187,81 @@ int FetchPEMRoots(CFDataRef *pemRoots, CFDataRef *untrustedPemRoots) { CFIndex numCerts = CFArrayGetCount(certs); for (j = 0; j < numCerts; j++) { CFDataRef data = NULL; - CFErrorRef errRef = NULL; CFArrayRef trustSettings = NULL; SecCertificateRef cert = (SecCertificateRef)CFArrayGetValueAtIndex(certs, j); if (cert == NULL) { continue; } - // We only want trusted certs. - int untrusted = 0; - int trustAsRoot = 0; - int trustRoot = 0; - if (i == 0) { - trustAsRoot = 1; - } else { - int k; - CFIndex m; + SInt32 result; + if (domains[i] == kSecTrustSettingsDomainSystem) { // Certs found in the system domain are always trusted. If the user // configures "Never Trust" on such a cert, it will also be found in the // admin or user domain, causing it to be added to untrustedPemRoots. The // Go code will then clean this up. - - // Trust may be stored in any of the domains. According to Apple's - // SecTrustServer.c, "user trust settings overrule admin trust settings", - // so take the last trust settings array we find. - // Skip the system domain since it is always trusted. - for (k = i; k < numDomains; k++) { - CFArrayRef domainTrustSettings = NULL; - err = SecTrustSettingsCopyTrustSettings(cert, domains[k], &domainTrustSettings); - if (err == errSecSuccess && domainTrustSettings != NULL) { - if (trustSettings) { - CFRelease(trustSettings); - } - trustSettings = domainTrustSettings; + result = kSecTrustSettingsResultTrustRoot; + } else { + result = sslTrustSettingsResult(cert); + if (debugDarwinRoots) { + CFErrorRef errRef = NULL; + CFStringRef summary = SecCertificateCopyShortDescription(NULL, cert, &errRef); + if (errRef != NULL) { + printf("crypto/x509: SecCertificateCopyShortDescription failed\n"); + CFRelease(errRef); + continue; } - } - if (trustSettings == NULL) { - // "this certificate must be verified to a known trusted certificate"; aka not a root. - continue; - } - for (m = 0; m < CFArrayGetCount(trustSettings); m++) { - CFNumberRef cfNum; - CFDictionaryRef tSetting = (CFDictionaryRef)CFArrayGetValueAtIndex(trustSettings, m); - if (CFDictionaryGetValueIfPresent(tSetting, policy, (const void**)&cfNum)){ - SInt32 result = 0; - CFNumberGetValue(cfNum, kCFNumberSInt32Type, &result); - // TODO: The rest of the dictionary specifies conditions for evaluation. - if (result == kSecTrustSettingsResultDeny) { - untrusted = 1; - } else if (result == kSecTrustSettingsResultTrustAsRoot) { - trustAsRoot = 1; - } else if (result == kSecTrustSettingsResultTrustRoot) { - trustRoot = 1; - } + + CFIndex length = CFStringGetLength(summary); + CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8) + 1; + char *buffer = malloc(maxSize); + if (CFStringGetCString(summary, buffer, maxSize, kCFStringEncodingUTF8)) { + printf("crypto/x509: %s returned %d\n", buffer, (int)result); } + free(buffer); + CFRelease(summary); } - CFRelease(trustSettings); } - if (trustRoot) { - // We only want to add Root CAs, so make sure Subject and Issuer Name match - CFDataRef subjectName = SecCertificateCopyNormalizedSubjectContent(cert, &errRef); - if (errRef != NULL) { - CFRelease(errRef); - continue; - } - CFDataRef issuerName = SecCertificateCopyNormalizedIssuerContent(cert, &errRef); - if (errRef != NULL) { - CFRelease(subjectName); - CFRelease(errRef); + CFMutableDataRef appendTo; + // > Note the distinction between the results kSecTrustSettingsResultTrustRoot + // > and kSecTrustSettingsResultTrustAsRoot: The former can only be applied to + // > root (self-signed) certificates; the latter can only be applied to + // > non-root certificates. + if (result == kSecTrustSettingsResultTrustRoot) { + CFErrorRef errRef = NULL; + if (!isRootCertificate(cert, &errRef) || errRef != NULL) { + if (errRef != NULL) CFRelease(errRef); continue; } - Boolean equal = CFEqual(subjectName, issuerName); - CFRelease(subjectName); - CFRelease(issuerName); - if (!equal) { + + appendTo = combinedData; + } else if (result == kSecTrustSettingsResultTrustAsRoot) { + CFErrorRef errRef = NULL; + if (isRootCertificate(cert, &errRef) || errRef != NULL) { + if (errRef != NULL) CFRelease(errRef); continue; } + + appendTo = combinedData; + } else if (result == kSecTrustSettingsResultDeny) { + appendTo = combinedUntrustedData; + } else if (result == kSecTrustSettingsResultUnspecified) { + continue; + } else { + continue; } err = SecItemExport(cert, kSecFormatX509Cert, kSecItemPemArmour, NULL, &data); if (err != noErr) { continue; } - if (data != NULL) { - if (!trustRoot && !trustAsRoot) { - untrusted = 1; - } - CFMutableDataRef appendTo = untrusted ? combinedUntrustedData : combinedData; CFDataAppendBytes(appendTo, CFDataGetBytePtr(data), CFDataGetLength(data)); CFRelease(data); } } CFRelease(certs); } - CFRelease(policy); *pemRoots = combinedData; *untrustedPemRoots = combinedUntrustedData; return 0; @@ -169,9 +278,8 @@ func loadSystemRoots() (*CertPool, error) { var data C.CFDataRef = 0 var untrustedData C.CFDataRef = 0 - err := C.FetchPEMRoots(&data, &untrustedData) + err := C.FetchPEMRoots(&data, &untrustedData, C.bool(debugDarwinRoots)) if err == -1 { - // TODO: better error message return nil, errors.New("crypto/x509: failed to load darwin system roots with cgo") } diff --git a/libgo/go/crypto/x509/root_darwin.go b/libgo/go/crypto/x509/root_darwin.go index 9d7b3a6ffb6..9b8a1cca7de 100644 --- a/libgo/go/crypto/x509/root_darwin.go +++ b/libgo/go/crypto/x509/root_darwin.go @@ -16,13 +16,12 @@ import ( "io/ioutil" "os" "os/exec" - "os/user" "path/filepath" "strings" "sync" ) -var debugExecDarwinRoots = strings.Contains(os.Getenv("GODEBUG"), "x509roots=1") +var debugDarwinRoots = strings.Contains(os.Getenv("GODEBUG"), "x509roots=1") func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate, err error) { return nil, nil @@ -40,8 +39,8 @@ func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate // // 1. Run "security trust-settings-export" and "security // trust-settings-export -d" to discover the set of certs with some -// user-tweaked trust policy. We're too lazy to parse the XML (at -// least at this stage of Go 1.8) to understand what the trust +// user-tweaked trust policy. We're too lazy to parse the XML +// (Issue 26830) to understand what the trust // policy actually is. We just learn that there is _some_ policy. // // 2. Run "security find-certificate" to dump the list of system root @@ -58,44 +57,41 @@ func execSecurityRoots() (*CertPool, error) { if err != nil { return nil, err } - if debugExecDarwinRoots { - println(fmt.Sprintf("crypto/x509: %d certs have a trust policy", len(hasPolicy))) + if debugDarwinRoots { + fmt.Printf("crypto/x509: %d certs have a trust policy\n", len(hasPolicy)) } - args := []string{"find-certificate", "-a", "-p", - "/System/Library/Keychains/SystemRootCertificates.keychain", - "/Library/Keychains/System.keychain", - } + keychains := []string{"/Library/Keychains/System.keychain"} - u, err := user.Current() + // Note that this results in trusting roots from $HOME/... (the environment + // variable), which might not be expected. + home, err := os.UserHomeDir() if err != nil { - if debugExecDarwinRoots { - println(fmt.Sprintf("crypto/x509: get current user: %v", err)) + if debugDarwinRoots { + fmt.Printf("crypto/x509: can't get user home directory: %v\n", err) } } else { - args = append(args, - filepath.Join(u.HomeDir, "/Library/Keychains/login.keychain"), + keychains = append(keychains, + filepath.Join(home, "/Library/Keychains/login.keychain"), // Fresh installs of Sierra use a slightly different path for the login keychain - filepath.Join(u.HomeDir, "/Library/Keychains/login.keychain-db"), + filepath.Join(home, "/Library/Keychains/login.keychain-db"), ) } - cmd := exec.Command("/usr/bin/security", args...) - data, err := cmd.Output() - if err != nil { - return nil, err + type rootCandidate struct { + c *Certificate + system bool } var ( mu sync.Mutex roots = NewCertPool() numVerified int // number of execs of 'security verify-cert', for debug stats + wg sync.WaitGroup + verifyCh = make(chan rootCandidate) ) - blockCh := make(chan *pem.Block) - var wg sync.WaitGroup - // Using 4 goroutines to pipe into verify-cert seems to be // about the best we can do. The verify-cert binary seems to // just RPC to another server with coarse locking anyway, so @@ -109,31 +105,62 @@ func execSecurityRoots() (*CertPool, error) { wg.Add(1) go func() { defer wg.Done() - for block := range blockCh { - cert, err := ParseCertificate(block.Bytes) - if err != nil { - continue - } - sha1CapHex := fmt.Sprintf("%X", sha1.Sum(block.Bytes)) + for cert := range verifyCh { + sha1CapHex := fmt.Sprintf("%X", sha1.Sum(cert.c.Raw)) - valid := true + var valid bool verifyChecks := 0 if hasPolicy[sha1CapHex] { verifyChecks++ - if !verifyCertWithSystem(block, cert) { - valid = false - } + valid = verifyCertWithSystem(cert.c) + } else { + // Certificates not in SystemRootCertificates without user + // or admin trust settings are not trusted. + valid = cert.system } mu.Lock() numVerified += verifyChecks if valid { - roots.AddCert(cert) + roots.AddCert(cert.c) } mu.Unlock() } }() } + err = forEachCertInKeychains(keychains, func(cert *Certificate) { + verifyCh <- rootCandidate{c: cert, system: false} + }) + if err != nil { + close(verifyCh) + return nil, err + } + err = forEachCertInKeychains([]string{ + "/System/Library/Keychains/SystemRootCertificates.keychain", + }, func(cert *Certificate) { + verifyCh <- rootCandidate{c: cert, system: true} + }) + if err != nil { + close(verifyCh) + return nil, err + } + close(verifyCh) + wg.Wait() + + if debugDarwinRoots { + fmt.Printf("crypto/x509: ran security verify-cert %d times\n", numVerified) + } + + return roots, nil +} + +func forEachCertInKeychains(paths []string, f func(*Certificate)) error { + args := append([]string{"find-certificate", "-a", "-p"}, paths...) + cmd := exec.Command("/usr/bin/security", args...) + data, err := cmd.Output() + if err != nil { + return err + } for len(data) > 0 { var block *pem.Block block, data = pem.Decode(data) @@ -143,22 +170,19 @@ func execSecurityRoots() (*CertPool, error) { if block.Type != "CERTIFICATE" || len(block.Headers) != 0 { continue } - blockCh <- block - } - close(blockCh) - wg.Wait() - - if debugExecDarwinRoots { - mu.Lock() - defer mu.Unlock() - println(fmt.Sprintf("crypto/x509: ran security verify-cert %d times", numVerified)) + cert, err := ParseCertificate(block.Bytes) + if err != nil { + continue + } + f(cert) } - - return roots, nil + return nil } -func verifyCertWithSystem(block *pem.Block, cert *Certificate) bool { - data := pem.EncodeToMemory(block) +func verifyCertWithSystem(cert *Certificate) bool { + data := pem.EncodeToMemory(&pem.Block{ + Type: "CERTIFICATE", Bytes: cert.Raw, + }) f, err := ioutil.TempFile("", "cert") if err != nil { @@ -174,19 +198,19 @@ func verifyCertWithSystem(block *pem.Block, cert *Certificate) bool { fmt.Fprintf(os.Stderr, "can't write temporary file for cert: %v", err) return false } - cmd := exec.Command("/usr/bin/security", "verify-cert", "-c", f.Name(), "-l", "-L") + cmd := exec.Command("/usr/bin/security", "verify-cert", "-p", "ssl", "-c", f.Name(), "-l", "-L") var stderr bytes.Buffer - if debugExecDarwinRoots { + if debugDarwinRoots { cmd.Stderr = &stderr } if err := cmd.Run(); err != nil { - if debugExecDarwinRoots { - println(fmt.Sprintf("crypto/x509: verify-cert rejected %s: %q", cert.Subject, bytes.TrimSpace(stderr.Bytes()))) + if debugDarwinRoots { + fmt.Printf("crypto/x509: verify-cert rejected %s: %q\n", cert.Subject, bytes.TrimSpace(stderr.Bytes())) } return false } - if debugExecDarwinRoots { - println(fmt.Sprintf("crypto/x509: verify-cert approved %s", cert.Subject)) + if debugDarwinRoots { + fmt.Printf("crypto/x509: verify-cert approved %s\n", cert.Subject) } return true } @@ -218,8 +242,8 @@ func getCertsWithTrustPolicy() (map[string]bool, error) { // Rather than match on English substrings that are probably // localized on macOS, just interpret any failure to mean that // there are no trust settings. - if debugExecDarwinRoots { - println(fmt.Sprintf("crypto/x509: exec %q: %v, %s", cmd.Args, err, stderr.Bytes())) + if debugDarwinRoots { + fmt.Printf("crypto/x509: exec %q: %v, %s\n", cmd.Args, err, stderr.Bytes()) } return nil } diff --git a/libgo/go/crypto/x509/root_darwin_arm_gen.go b/libgo/go/crypto/x509/root_darwin_arm_gen.go index b5580d6f02a..bc44124a785 100644 --- a/libgo/go/crypto/x509/root_darwin_arm_gen.go +++ b/libgo/go/crypto/x509/root_darwin_arm_gen.go @@ -154,9 +154,9 @@ func fetchCertIDs() ([]certID, error) { values := regexp.MustCompile("(?s)(.*?)").FindAllStringSubmatch(row, -1) name := values[cols["Certificate name"]][1] fingerprint := values[cols["Fingerprint (SHA-256)"]][1] - fingerprint = strings.Replace(fingerprint, "
", "", -1) - fingerprint = strings.Replace(fingerprint, "\n", "", -1) - fingerprint = strings.Replace(fingerprint, " ", "", -1) + fingerprint = strings.ReplaceAll(fingerprint, "
", "") + fingerprint = strings.ReplaceAll(fingerprint, "\n", "") + fingerprint = strings.ReplaceAll(fingerprint, " ", "") fingerprint = strings.ToLower(fingerprint) ids = append(ids, certID{ diff --git a/libgo/go/crypto/x509/verify.go b/libgo/go/crypto/x509/verify.go index 0b75778a038..56b7948c415 100644 --- a/libgo/go/crypto/x509/verify.go +++ b/libgo/go/crypto/x509/verify.go @@ -222,10 +222,9 @@ type rfc2821Mailbox struct { } // parseRFC2821Mailbox parses an email address into local and domain parts, -// based on the ABNF for a “Mailbox” from RFC 2821. According to -// https://tools.ietf.org/html/rfc5280#section-4.2.1.6 that's correct for an -// rfc822Name from a certificate: “The format of an rfc822Name is a "Mailbox" -// as defined in https://tools.ietf.org/html/rfc2821#section-4.1.2”. +// based on the ABNF for a “Mailbox” from RFC 2821. According to RFC 5280, +// Section 4.2.1.6 that's correct for an rfc822Name from a certificate: “The +// format of an rfc822Name is a "Mailbox" as defined in RFC 2821, Section 4.1.2”. func parseRFC2821Mailbox(in string) (mailbox rfc2821Mailbox, ok bool) { if len(in) == 0 { return mailbox, false @@ -242,9 +241,8 @@ func parseRFC2821Mailbox(in string) (mailbox rfc2821Mailbox, ok bool) { // quoted-pair = ("\" text) / obs-qp // text = %d1-9 / %d11 / %d12 / %d14-127 / obs-text // - // (Names beginning with “obs-” are the obsolete syntax from - // https://tools.ietf.org/html/rfc2822#section-4. Since it has - // been 16 years, we no longer accept that.) + // (Names beginning with “obs-” are the obsolete syntax from RFC 2822, + // Section 4. Since it has been 16 years, we no longer accept that.) in = in[1:] QuotedString: for { @@ -298,7 +296,7 @@ func parseRFC2821Mailbox(in string) (mailbox rfc2821Mailbox, ok bool) { // Atom ("." Atom)* NextChar: for len(in) > 0 { - // atext from https://tools.ietf.org/html/rfc2822#section-3.2.4 + // atext from RFC 2822, Section 3.2.4 c := in[0] switch { @@ -334,7 +332,7 @@ func parseRFC2821Mailbox(in string) (mailbox rfc2821Mailbox, ok bool) { return mailbox, false } - // https://tools.ietf.org/html/rfc3696#section-3 + // From RFC 3696, Section 3: // “period (".") may also appear, but may not be used to start // or end the local part, nor may two or more consecutive // periods appear.” @@ -415,7 +413,7 @@ func matchEmailConstraint(mailbox rfc2821Mailbox, constraint string) (bool, erro } func matchURIConstraint(uri *url.URL, constraint string) (bool, error) { - // https://tools.ietf.org/html/rfc5280#section-4.2.1.10 + // From RFC 5280, Section 4.2.1.10: // “a uniformResourceIdentifier that does not include an authority // component with a host name specified as a fully qualified domain // name (e.g., if the URI either does not include an authority @@ -765,7 +763,7 @@ func (c *Certificate) Verify(opts VerifyOptions) (chains [][]*Certificate, err e if opts.Roots.contains(c) { candidateChains = append(candidateChains, []*Certificate{c}) } else { - if candidateChains, err = c.buildChains(make(map[int][][]*Certificate), []*Certificate{c}, &opts); err != nil { + if candidateChains, err = c.buildChains(nil, []*Certificate{c}, nil, &opts); err != nil { return nil, err } } @@ -802,66 +800,82 @@ func appendToFreshChain(chain []*Certificate, cert *Certificate) []*Certificate return n } -func (c *Certificate) buildChains(cache map[int][][]*Certificate, currentChain []*Certificate, opts *VerifyOptions) (chains [][]*Certificate, err error) { - possibleRoots, failedRoot, rootErr := opts.Roots.findVerifiedParents(c) -nextRoot: - for _, rootNum := range possibleRoots { - root := opts.Roots.certs[rootNum] +// maxChainSignatureChecks is the maximum number of CheckSignatureFrom calls +// that an invocation of buildChains will (tranistively) make. Most chains are +// less than 15 certificates long, so this leaves space for multiple chains and +// for failed checks due to different intermediates having the same Subject. +const maxChainSignatureChecks = 100 +func (c *Certificate) buildChains(cache map[*Certificate][][]*Certificate, currentChain []*Certificate, sigChecks *int, opts *VerifyOptions) (chains [][]*Certificate, err error) { + var ( + hintErr error + hintCert *Certificate + ) + + considerCandidate := func(certType int, candidate *Certificate) { for _, cert := range currentChain { - if cert.Equal(root) { - continue nextRoot + if cert.Equal(candidate) { + return } } - err = root.isValid(rootCertificate, currentChain, opts) - if err != nil { - continue + if sigChecks == nil { + sigChecks = new(int) + } + *sigChecks++ + if *sigChecks > maxChainSignatureChecks { + err = errors.New("x509: signature check attempts limit reached while verifying certificate chain") + return } - chains = append(chains, appendToFreshChain(currentChain, root)) - } - possibleIntermediates, failedIntermediate, intermediateErr := opts.Intermediates.findVerifiedParents(c) -nextIntermediate: - for _, intermediateNum := range possibleIntermediates { - intermediate := opts.Intermediates.certs[intermediateNum] - for _, cert := range currentChain { - if cert.Equal(intermediate) { - continue nextIntermediate + if err := c.CheckSignatureFrom(candidate); err != nil { + if hintErr == nil { + hintErr = err + hintCert = candidate } + return } - err = intermediate.isValid(intermediateCertificate, currentChain, opts) + + err = candidate.isValid(certType, currentChain, opts) if err != nil { - continue + return } - var childChains [][]*Certificate - childChains, ok := cache[intermediateNum] - if !ok { - childChains, err = intermediate.buildChains(cache, appendToFreshChain(currentChain, intermediate), opts) - cache[intermediateNum] = childChains + + switch certType { + case rootCertificate: + chains = append(chains, appendToFreshChain(currentChain, candidate)) + case intermediateCertificate: + if cache == nil { + cache = make(map[*Certificate][][]*Certificate) + } + childChains, ok := cache[candidate] + if !ok { + childChains, err = candidate.buildChains(cache, appendToFreshChain(currentChain, candidate), sigChecks, opts) + cache[candidate] = childChains + } + chains = append(chains, childChains...) } - chains = append(chains, childChains...) + } + + for _, rootNum := range opts.Roots.findPotentialParents(c) { + considerCandidate(rootCertificate, opts.Roots.certs[rootNum]) + } + for _, intermediateNum := range opts.Intermediates.findPotentialParents(c) { + considerCandidate(intermediateCertificate, opts.Intermediates.certs[intermediateNum]) } if len(chains) > 0 { err = nil } - if len(chains) == 0 && err == nil { - hintErr := rootErr - hintCert := failedRoot - if hintErr == nil { - hintErr = intermediateErr - hintCert = failedIntermediate - } err = UnknownAuthorityError{c, hintErr, hintCert} } return } -// validHostname returns whether host is a valid hostname that can be matched or -// matched against according to RFC 6125 2.2, with some leniency to accomodate +// validHostname reports whether host is a valid hostname that can be matched or +// matched against according to RFC 6125 2.2, with some leniency to accommodate // legacy values. func validHostname(host string) bool { host = strings.TrimSuffix(host, ".") @@ -987,7 +1001,7 @@ func (c *Certificate) VerifyHostname(h string) error { } if ip := net.ParseIP(candidateIP); ip != nil { // We only match IP addresses against IP SANs. - // https://tools.ietf.org/html/rfc6125#appendix-B.2 + // See RFC 6125, Appendix B.2. for _, candidate := range c.IPAddresses { if ip.Equal(candidate) { return nil diff --git a/libgo/go/crypto/x509/verify_test.go b/libgo/go/crypto/x509/verify_test.go index 0e24d3b5da3..85f4703d4c3 100644 --- a/libgo/go/crypto/x509/verify_test.go +++ b/libgo/go/crypto/x509/verify_test.go @@ -5,10 +5,15 @@ package x509 import ( + "crypto" + "crypto/ecdsa" + "crypto/elliptic" + "crypto/rand" "crypto/x509/pkix" "encoding/pem" "errors" "fmt" + "math/big" "runtime" "strings" "testing" @@ -1889,3 +1894,117 @@ func TestValidHostname(t *testing.T) { } } } + +func generateCert(cn string, isCA bool, issuer *Certificate, issuerKey crypto.PrivateKey) (*Certificate, crypto.PrivateKey, error) { + priv, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) + if err != nil { + return nil, nil, err + } + + serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) + serialNumber, _ := rand.Int(rand.Reader, serialNumberLimit) + + template := &Certificate{ + SerialNumber: serialNumber, + Subject: pkix.Name{CommonName: cn}, + NotBefore: time.Now().Add(-1 * time.Hour), + NotAfter: time.Now().Add(24 * time.Hour), + + KeyUsage: KeyUsageKeyEncipherment | KeyUsageDigitalSignature | KeyUsageCertSign, + ExtKeyUsage: []ExtKeyUsage{ExtKeyUsageServerAuth}, + BasicConstraintsValid: true, + IsCA: isCA, + } + if issuer == nil { + issuer = template + issuerKey = priv + } + + derBytes, err := CreateCertificate(rand.Reader, template, issuer, priv.Public(), issuerKey) + if err != nil { + return nil, nil, err + } + cert, err := ParseCertificate(derBytes) + if err != nil { + return nil, nil, err + } + + return cert, priv, nil +} + +func TestPathologicalChain(t *testing.T) { + if testing.Short() { + t.Skip("skipping generation of a long chain of certificates in short mode") + } + + // Build a chain where all intermediates share the same subject, to hit the + // path building worst behavior. + roots, intermediates := NewCertPool(), NewCertPool() + + parent, parentKey, err := generateCert("Root CA", true, nil, nil) + if err != nil { + t.Fatal(err) + } + roots.AddCert(parent) + + for i := 1; i < 100; i++ { + parent, parentKey, err = generateCert("Intermediate CA", true, parent, parentKey) + if err != nil { + t.Fatal(err) + } + intermediates.AddCert(parent) + } + + leaf, _, err := generateCert("Leaf", false, parent, parentKey) + if err != nil { + t.Fatal(err) + } + + start := time.Now() + _, err = leaf.Verify(VerifyOptions{ + Roots: roots, + Intermediates: intermediates, + }) + t.Logf("verification took %v", time.Since(start)) + + if err == nil || !strings.Contains(err.Error(), "signature check attempts limit") { + t.Errorf("expected verification to fail with a signature checks limit error; got %v", err) + } +} + +func TestLongChain(t *testing.T) { + if testing.Short() { + t.Skip("skipping generation of a long chain of certificates in short mode") + } + + roots, intermediates := NewCertPool(), NewCertPool() + + parent, parentKey, err := generateCert("Root CA", true, nil, nil) + if err != nil { + t.Fatal(err) + } + roots.AddCert(parent) + + for i := 1; i < 15; i++ { + name := fmt.Sprintf("Intermediate CA #%d", i) + parent, parentKey, err = generateCert(name, true, parent, parentKey) + if err != nil { + t.Fatal(err) + } + intermediates.AddCert(parent) + } + + leaf, _, err := generateCert("Leaf", false, parent, parentKey) + if err != nil { + t.Fatal(err) + } + + start := time.Now() + if _, err := leaf.Verify(VerifyOptions{ + Roots: roots, + Intermediates: intermediates, + }); err != nil { + t.Error(err) + } + t.Logf("verification took %v", time.Since(start)) +} diff --git a/libgo/go/crypto/x509/x509.go b/libgo/go/crypto/x509/x509.go index 2e72471de28..08681a6ee28 100644 --- a/libgo/go/crypto/x509/x509.go +++ b/libgo/go/crypto/x509/x509.go @@ -24,6 +24,8 @@ import ( "encoding/pem" "errors" "fmt" + "internal/x/crypto/cryptobyte" + cryptobyte_asn1 "internal/x/crypto/cryptobyte/asn1" "io" "math/big" "net" @@ -32,9 +34,6 @@ import ( "strings" "time" "unicode/utf8" - - "golang_org/x/crypto/cryptobyte" - cryptobyte_asn1 "golang_org/x/crypto/cryptobyte/asn1" ) // pkixPublicKey reflects a PKIX public key structure. See SubjectPublicKeyInfo @@ -78,7 +77,7 @@ func marshalPublicKey(pub interface{}) (publicKeyBytes []byte, publicKeyAlgorith } publicKeyAlgorithm.Algorithm = oidPublicKeyRSA // This is a NULL parameters value which is required by - // https://tools.ietf.org/html/rfc3279#section-2.3.1. + // RFC 3279, Section 2.3.1. publicKeyAlgorithm.Parameters = asn1.NullRawValue case *ecdsa.PublicKey: publicKeyBytes = elliptic.Marshal(pub.Curve, pub.X, pub.Y) @@ -334,7 +333,7 @@ var signatureAlgorithmDetails = []struct { } // pssParameters reflects the parameters in an AlgorithmIdentifier that -// specifies RSA PSS. See https://tools.ietf.org/html/rfc3447#appendix-A.2.3 +// specifies RSA PSS. See RFC 3447, Appendix A.2.3. type pssParameters struct { // The following three fields are not marked as // optional because the default values specify SHA-1, @@ -413,13 +412,11 @@ func getSignatureAlgorithmFromAI(ai pkix.AlgorithmIdentifier) SignatureAlgorithm return UnknownSignatureAlgorithm } - // PSS is greatly overburdened with options. This code forces - // them into three buckets by requiring that the MGF1 hash - // function always match the message hash function (as - // recommended in - // https://tools.ietf.org/html/rfc3447#section-8.1), that the - // salt length matches the hash length, and that the trailer - // field has the default value. + // PSS is greatly overburdened with options. This code forces them into + // three buckets by requiring that the MGF1 hash function always match the + // message hash function (as recommended in RFC 3447, Section 8.1), that the + // salt length matches the hash length, and that the trailer field has the + // default value. if (len(params.Hash.Parameters.FullBytes) != 0 && !bytes.Equal(params.Hash.Parameters.FullBytes, asn1.NullBytes)) || !params.MGF.Algorithm.Equal(oidMGF1) || !mgf1HashFunc.Algorithm.Equal(params.Hash.Algorithm) || @@ -987,8 +984,8 @@ func parsePublicKey(algo PublicKeyAlgorithm, keyData *publicKeyInfo) (interface{ asn1Data := keyData.PublicKey.RightAlign() switch algo { case RSA: - // RSA public keys must have a NULL in the parameters - // (https://tools.ietf.org/html/rfc3279#section-2.3.1). + // RSA public keys must have a NULL in the parameters. + // See RFC 3279, Section 2.3.1. if !bytes.Equal(keyData.Algorithm.Parameters.FullBytes, asn1.NullBytes) { return nil, errors.New("x509: RSA key missing NULL parameters") } @@ -1150,7 +1147,7 @@ func parseSANExtension(value []byte) (dnsNames, emailAddresses []string, ipAddre return } -// isValidIPMask returns true iff mask consists of zero or more 1 bits, followed by zero bits. +// isValidIPMask reports whether mask consists of zero or more 1 bits, followed by zero bits. func isValidIPMask(mask []byte) bool { seenZero := false @@ -1203,7 +1200,7 @@ func parseNameConstraintsExtension(out *Certificate, e pkix.Extension) (unhandle } if !havePermitted && !haveExcluded || len(permitted) == 0 && len(excluded) == 0 { - // https://tools.ietf.org/html/rfc5280#section-4.2.1.10: + // From RFC 5280, Section 4.2.1.10: // “either the permittedSubtrees field // or the excludedSubtrees MUST be // present” @@ -1644,7 +1641,7 @@ var ( oidAuthorityInfoAccessIssuers = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 48, 2} ) -// oidNotInExtensions returns whether an extension with the given oid exists in +// oidNotInExtensions reports whether an extension with the given oid exists in // extensions. func oidInExtensions(oid asn1.ObjectIdentifier, extensions []pkix.Extension) bool { for _, e := range extensions { @@ -1798,7 +1795,7 @@ func buildExtensions(template *Certificate, subjectIsEmpty bool, authorityKeyId if (len(template.DNSNames) > 0 || len(template.EmailAddresses) > 0 || len(template.IPAddresses) > 0 || len(template.URIs) > 0) && !oidInExtensions(oidExtensionSubjectAltName, template.ExtraExtensions) { ret[n].Id = oidExtensionSubjectAltName - // https://tools.ietf.org/html/rfc5280#section-4.2.1.6 + // From RFC 5280, Section 4.2.1.6: // “If the subject field contains an empty sequence ... then // subjectAltName extension ... is marked as critical” ret[n].Critical = subjectIsEmpty @@ -2357,8 +2354,7 @@ func parseRawAttributes(rawAttributes []asn1.RawValue) []pkix.AttributeTypeAndVa // parseCSRExtensions parses the attributes from a CSR and extracts any // requested extensions. func parseCSRExtensions(rawAttributes []asn1.RawValue) ([]pkix.Extension, error) { - // pkcs10Attribute reflects the Attribute structure from section 4.1 of - // https://tools.ietf.org/html/rfc2986. + // pkcs10Attribute reflects the Attribute structure from RFC 2986, Section 4.1. type pkcs10Attribute struct { Id asn1.ObjectIdentifier Values []asn1.RawValue `asn1:"set"` diff --git a/libgo/go/database/sql/convert.go b/libgo/go/database/sql/convert.go index 92a2ebe0e99..c450d987a46 100644 --- a/libgo/go/database/sql/convert.go +++ b/libgo/go/database/sql/convert.go @@ -203,10 +203,18 @@ func driverArgsConnLocked(ci driver.Conn, ds *driverStmt, args []interface{}) ([ } -// convertAssign copies to dest the value in src, converting it if possible. -// An error is returned if the copy would result in loss of information. -// dest should be a pointer type. +// convertAssign is the same as convertAssignRows, but without the optional +// rows argument. func convertAssign(dest, src interface{}) error { + return convertAssignRows(dest, src, nil) +} + +// convertAssignRows copies to dest the value in src, converting it if possible. +// An error is returned if the copy would result in loss of information. +// dest should be a pointer type. If rows is passed in, the rows will +// be used as the parent for any cursor values converted from a +// driver.Rows to a *Rows. +func convertAssignRows(dest, src interface{}, rows *Rows) error { // Common cases, without reflect. switch s := src.(type) { case string: @@ -299,6 +307,35 @@ func convertAssign(dest, src interface{}) error { *d = nil return nil } + // The driver is returning a cursor the client may iterate over. + case driver.Rows: + switch d := dest.(type) { + case *Rows: + if d == nil { + return errNilPtr + } + if rows == nil { + return errors.New("invalid context to convert cursor rows, missing parent *Rows") + } + rows.closemu.Lock() + *d = Rows{ + dc: rows.dc, + releaseConn: func(error) {}, + rowsi: s, + } + // Chain the cancel function. + parentCancel := rows.cancel + rows.cancel = func() { + // When Rows.cancel is called, the closemu will be locked as well. + // So we can access rs.lasterr. + d.close(rows.lasterr) + if parentCancel != nil { + parentCancel() + } + } + rows.closemu.Unlock() + return nil + } } var sv reflect.Value @@ -381,7 +418,7 @@ func convertAssign(dest, src interface{}) error { return nil } dv.Set(reflect.New(dv.Type().Elem())) - return convertAssign(dv.Interface(), src) + return convertAssignRows(dv.Interface(), src, rows) case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: s := asString(src) i64, err := strconv.ParseInt(s, 10, dv.Type().Bits()) diff --git a/libgo/go/database/sql/driver/driver.go b/libgo/go/database/sql/driver/driver.go index 1e54b4cf2cf..5ff2bc97350 100644 --- a/libgo/go/database/sql/driver/driver.go +++ b/libgo/go/database/sql/driver/driver.go @@ -24,6 +24,11 @@ import ( // []byte // string // time.Time +// +// If the driver supports cursors, a returned Value may also implement the Rows interface +// in this package. This is used when, for example, when a user selects a cursor +// such as "select cursor(select * from my_table) from dual". If the Rows +// from the select is closed, the cursor Rows will also be closed. type Value interface{} // NamedValue holds both the value name and value. @@ -469,7 +474,7 @@ type RowsAffected int64 var _ Result = RowsAffected(0) func (RowsAffected) LastInsertId() (int64, error) { - return 0, errors.New("no LastInsertId available") + return 0, errors.New("LastInsertId is not supported by this driver") } func (v RowsAffected) RowsAffected() (int64, error) { diff --git a/libgo/go/database/sql/example_cli_test.go b/libgo/go/database/sql/example_cli_test.go new file mode 100644 index 00000000000..c87c508a141 --- /dev/null +++ b/libgo/go/database/sql/example_cli_test.go @@ -0,0 +1,88 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +package sql_test + +import ( + "context" + "database/sql" + "flag" + "log" + "os" + "os/signal" + "time" +) + +var pool *sql.DB // Database connection pool. + +func Example_openDBCLI() { + id := flag.Int64("id", 0, "person ID to find") + dsn := flag.String("dsn", os.Getenv("DSN"), "connection data source name") + flag.Parse() + + if len(*dsn) == 0 { + log.Fatal("missing dsn flag") + } + if *id == 0 { + log.Fatal("missing person ID") + } + var err error + + // Opening a driver typically will not attempt to connect to the database. + pool, err = sql.Open("driver-name", *dsn) + if err != nil { + // This will not be a connection error, but a DSN parse error or + // another initialization error. + log.Fatal("unable to use data source name", err) + } + defer pool.Close() + + pool.SetConnMaxLifetime(0) + pool.SetMaxIdleConns(3) + pool.SetMaxOpenConns(3) + + ctx, stop := context.WithCancel(context.Background()) + defer stop() + + appSignal := make(chan os.Signal, 3) + signal.Notify(appSignal, os.Interrupt) + + go func() { + select { + case <-appSignal: + stop() + } + }() + + Ping(ctx) + + Query(ctx, *id) +} + +// Ping the database to verify DSN provided by the user is valid and the +// server accessible. If the ping fails exit the program with an error. +func Ping(ctx context.Context) { + ctx, cancel := context.WithTimeout(ctx, 1*time.Second) + defer cancel() + + if err := pool.PingContext(ctx); err != nil { + log.Fatalf("unable to connect to database: %v", err) + } +} + +// Query the database for the information requested and prints the results. +// If the query fails exit the program with an error. +func Query(ctx context.Context, id int64) { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + var name string + err := pool.QueryRowContext(ctx, "select p.name from people as p where p.id = :id;", sql.Named("id", id)).Scan(&name) + if err != nil { + log.Fatal("unable to execute search query", err) + } + log.Println("name=", name) +} diff --git a/libgo/go/database/sql/example_service_test.go b/libgo/go/database/sql/example_service_test.go new file mode 100644 index 00000000000..7605e2f75d3 --- /dev/null +++ b/libgo/go/database/sql/example_service_test.go @@ -0,0 +1,160 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +package sql_test + +import ( + "context" + "database/sql" + "encoding/json" + "fmt" + "io" + "log" + "net/http" + "time" +) + +func Example_openDBService() { + // Opening a driver typically will not attempt to connect to the database. + db, err := sql.Open("driver-name", "database=test1") + if err != nil { + // This will not be a connection error, but a DSN parse error or + // another initialization error. + log.Fatal(err) + } + db.SetConnMaxLifetime(0) + db.SetMaxIdleConns(50) + db.SetMaxOpenConns(50) + + s := &Service{db: db} + + http.ListenAndServe(":8080", s) +} + +type Service struct { + db *sql.DB +} + +func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request) { + db := s.db + switch r.URL.Path { + default: + http.Error(w, "not found", http.StatusNotFound) + return + case "/healthz": + ctx, cancel := context.WithTimeout(r.Context(), 1*time.Second) + defer cancel() + + err := s.db.PingContext(ctx) + if err != nil { + http.Error(w, fmt.Sprintf("db down: %v", err), http.StatusFailedDependency) + return + } + w.WriteHeader(http.StatusOK) + return + case "/quick-action": + // This is a short SELECT. Use the request context as the base of + // the context timeout. + ctx, cancel := context.WithTimeout(r.Context(), 3*time.Second) + defer cancel() + + id := 5 + org := 10 + var name string + err := db.QueryRowContext(ctx, ` +select + p.name +from + people as p + join organization as o on p.organization = o.id +where + p.id = :id + and o.id = :org +;`, + sql.Named("id", id), + sql.Named("org", org), + ).Scan(&name) + if err != nil { + if err == sql.ErrNoRows { + http.Error(w, "not found", http.StatusNotFound) + return + } + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + io.WriteString(w, name) + return + case "/long-action": + // This is a long SELECT. Use the request context as the base of + // the context timeout, but give it some time to finish. If + // the client cancels before the query is done the query will also + // be canceled. + ctx, cancel := context.WithTimeout(r.Context(), 60*time.Second) + defer cancel() + + var names []string + rows, err := db.QueryContext(ctx, "select p.name from people as p where p.active = true;") + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + for rows.Next() { + var name string + err = rows.Scan(&name) + if err != nil { + break + } + names = append(names, name) + } + // Check for errors during rows "Close". + // This may be more important if multiple statements are executed + // in a single batch and rows were written as well as read. + if closeErr := rows.Close(); closeErr != nil { + http.Error(w, closeErr.Error(), http.StatusInternalServerError) + return + } + + // Check for row scan error. + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + // Check for errors during row iteration. + if err = rows.Err(); err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + json.NewEncoder(w).Encode(names) + return + case "/async-action": + // This action has side effects that we want to preserve + // even if the client cancels the HTTP request part way through. + // For this we do not use the http request context as a base for + // the timeout. + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + var orderRef = "ABC123" + tx, err := db.BeginTx(ctx, &sql.TxOptions{Isolation: sql.LevelSerializable}) + _, err = tx.ExecContext(ctx, "stored_proc_name", orderRef) + + if err != nil { + tx.Rollback() + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + err = tx.Commit() + if err != nil { + http.Error(w, "action in unknown state, check state before attempting again", http.StatusInternalServerError) + return + } + w.WriteHeader(http.StatusOK) + return + } +} diff --git a/libgo/go/database/sql/fakedb_test.go b/libgo/go/database/sql/fakedb_test.go index a21bae61bac..dcdd264baa8 100644 --- a/libgo/go/database/sql/fakedb_test.go +++ b/libgo/go/database/sql/fakedb_test.go @@ -539,7 +539,7 @@ func (c *fakeConn) prepareCreate(stmt *fakeStmt, parts []string) (*fakeStmt, err } // parts are table|col=?,col2=val -func (c *fakeConn) prepareInsert(stmt *fakeStmt, parts []string) (*fakeStmt, error) { +func (c *fakeConn) prepareInsert(ctx context.Context, stmt *fakeStmt, parts []string) (*fakeStmt, error) { if len(parts) != 2 { stmt.Close() return nil, errf("invalid INSERT syntax with %d parts; want 2", len(parts)) @@ -574,6 +574,20 @@ func (c *fakeConn) prepareInsert(stmt *fakeStmt, parts []string) (*fakeStmt, err return nil, errf("invalid conversion to int32 from %q", value) } subsetVal = int64(i) // int64 is a subset type, but not int32 + case "table": // For testing cursor reads. + c.skipDirtySession = true + vparts := strings.Split(value, "!") + + substmt, err := c.PrepareContext(ctx, fmt.Sprintf("SELECT|%s|%s|", vparts[0], strings.Join(vparts[1:], ","))) + if err != nil { + return nil, err + } + cursor, err := (substmt.(driver.StmtQueryContext)).QueryContext(ctx, []driver.NamedValue{}) + substmt.Close() + if err != nil { + return nil, err + } + subsetVal = cursor default: stmt.Close() return nil, errf("unsupported conversion for pre-bound parameter %q to type %q", value, ctype) @@ -658,11 +672,11 @@ func (c *fakeConn) PrepareContext(ctx context.Context, query string) (driver.Stm case "CREATE": stmt, err = c.prepareCreate(stmt, parts) case "INSERT": - stmt, err = c.prepareInsert(stmt, parts) + stmt, err = c.prepareInsert(ctx, stmt, parts) case "NOSERT": // Do all the prep-work like for an INSERT but don't actually insert the row. // Used for some of the concurrent tests. - stmt, err = c.prepareInsert(stmt, parts) + stmt, err = c.prepareInsert(ctx, stmt, parts) default: stmt.Close() return nil, errf("unsupported command type %q", cmd) diff --git a/libgo/go/database/sql/sql.go b/libgo/go/database/sql/sql.go index 36179855db2..b0353ab4dc7 100644 --- a/libgo/go/database/sql/sql.go +++ b/libgo/go/database/sql/sql.go @@ -133,6 +133,7 @@ const ( LevelLinearizable ) +// String returns the name of the transaction isolation level. func (i IsolationLevel) String() string { switch i { case LevelDefault: @@ -567,7 +568,6 @@ type finalCloser interface { // addDep notes that x now depends on dep, and x's finalClose won't be // called until all of x's dependencies are removed with removeDep. func (db *DB) addDep(x finalCloser, dep interface{}) { - //println(fmt.Sprintf("addDep(%T %p, %T %p)", x, x, dep, dep)) db.mu.Lock() defer db.mu.Unlock() db.addDepLocked(x, dep) @@ -597,7 +597,6 @@ func (db *DB) removeDep(x finalCloser, dep interface{}) error { } func (db *DB) removeDepLocked(x finalCloser, dep interface{}) func() error { - //println(fmt.Sprintf("removeDep(%T %p, %T %p)", x, x, dep, dep)) xdep, ok := db.dep[x] if !ok { @@ -1322,11 +1321,13 @@ func (db *DB) putConnDBLocked(dc *driverConn, err error) bool { err: err, } return true - } else if err == nil && !db.closed && db.maxIdleConnsLocked() > len(db.freeConn) { - db.freeConn = append(db.freeConn, dc) + } else if err == nil && !db.closed { + if db.maxIdleConnsLocked() > len(db.freeConn) { + db.freeConn = append(db.freeConn, dc) + db.startCleanerLocked() + return true + } db.maxIdleClosed++ - db.startCleanerLocked() - return true } return false } @@ -2605,6 +2606,15 @@ type Rows struct { lastcols []driver.Value } +// lasterrOrErrLocked returns either lasterr or the provided err. +// rs.closemu must be read-locked. +func (rs *Rows) lasterrOrErrLocked(err error) error { + if rs.lasterr != nil && rs.lasterr != io.EOF { + return rs.lasterr + } + return err +} + func (rs *Rows) initContextClose(ctx, txctx context.Context) { if ctx.Done() == nil && (txctx == nil || txctx.Done() == nil) { return @@ -2681,7 +2691,7 @@ func (rs *Rows) nextLocked() (doClose, ok bool) { return false, true } -// NextResultSet prepares the next result set for reading. It returns true if +// NextResultSet prepares the next result set for reading. It reports whether // there is further result sets, or false if there is no further result set // or if there is an error advancing to it. The Err method should be consulted // to distinguish between the two cases. @@ -2728,23 +2738,22 @@ func (rs *Rows) NextResultSet() bool { func (rs *Rows) Err() error { rs.closemu.RLock() defer rs.closemu.RUnlock() - if rs.lasterr == io.EOF { - return nil - } - return rs.lasterr + return rs.lasterrOrErrLocked(nil) } +var errRowsClosed = errors.New("sql: Rows are closed") +var errNoRows = errors.New("sql: no Rows available") + // Columns returns the column names. -// Columns returns an error if the rows are closed, or if the rows -// are from QueryRow and there was a deferred error. +// Columns returns an error if the rows are closed. func (rs *Rows) Columns() ([]string, error) { rs.closemu.RLock() defer rs.closemu.RUnlock() if rs.closed { - return nil, errors.New("sql: Rows are closed") + return nil, rs.lasterrOrErrLocked(errRowsClosed) } if rs.rowsi == nil { - return nil, errors.New("sql: no Rows available") + return nil, rs.lasterrOrErrLocked(errNoRows) } rs.dc.Lock() defer rs.dc.Unlock() @@ -2758,10 +2767,10 @@ func (rs *Rows) ColumnTypes() ([]*ColumnType, error) { rs.closemu.RLock() defer rs.closemu.RUnlock() if rs.closed { - return nil, errors.New("sql: Rows are closed") + return nil, rs.lasterrOrErrLocked(errRowsClosed) } if rs.rowsi == nil { - return nil, errors.New("sql: no Rows available") + return nil, rs.lasterrOrErrLocked(errNoRows) } rs.dc.Lock() defer rs.dc.Unlock() @@ -2812,7 +2821,7 @@ func (ci *ColumnType) ScanType() reflect.Type { return ci.scanType } -// Nullable returns whether the column may be null. +// Nullable reports whether the column may be null. // If a driver does not support this property ok will be false. func (ci *ColumnType) Nullable() (nullable, ok bool) { return ci.nullable, ci.hasNullable @@ -2873,6 +2882,7 @@ func rowsColumnInfoSetupConnLocked(rowsi driver.Rows) []*ColumnType { // *float32, *float64 // *interface{} // *RawBytes +// *Rows (cursor value) // any type implementing Scanner (see Scanner docs) // // In the most simple case, if the type of the value from the source @@ -2909,6 +2919,11 @@ func rowsColumnInfoSetupConnLocked(rowsi driver.Rows) []*ColumnType { // // For scanning into *bool, the source may be true, false, 1, 0, or // string inputs parseable by strconv.ParseBool. +// +// Scan can also convert a cursor returned from a query, such as +// "select cursor(select * from my_table) from dual", into a +// *Rows value that can itself be scanned from. The parent +// select query will close any cursor *Rows if the parent *Rows is closed. func (rs *Rows) Scan(dest ...interface{}) error { rs.closemu.RLock() @@ -2917,8 +2932,9 @@ func (rs *Rows) Scan(dest ...interface{}) error { return rs.lasterr } if rs.closed { + err := rs.lasterrOrErrLocked(errRowsClosed) rs.closemu.RUnlock() - return errors.New("sql: Rows are closed") + return err } rs.closemu.RUnlock() @@ -2929,7 +2945,7 @@ func (rs *Rows) Scan(dest ...interface{}) error { return fmt.Errorf("sql: expected %d destination arguments in Scan, not %d", len(rs.lastcols), len(dest)) } for i, sv := range rs.lastcols { - err := convertAssign(dest[i], sv) + err := convertAssignRows(dest[i], sv, rs) if err != nil { return fmt.Errorf(`sql: Scan error on column index %d, name %q: %v`, i, rs.rowsi.Columns()[i], err) } diff --git a/libgo/go/database/sql/sql_test.go b/libgo/go/database/sql/sql_test.go index f194744aefe..64b9dfea5c2 100644 --- a/libgo/go/database/sql/sql_test.go +++ b/libgo/go/database/sql/sql_test.go @@ -397,7 +397,7 @@ func TestQueryContextWait(t *testing.T) { prepares0 := numPrepares(t, db) // TODO(kardianos): convert this from using a timeout to using an explicit - // cancel when the query signals that is is "executing" the query. + // cancel when the query signals that it is "executing" the query. ctx, cancel := context.WithTimeout(context.Background(), 300*time.Millisecond) defer cancel() @@ -597,7 +597,7 @@ func TestPoolExhaustOnCancel(t *testing.T) { state := 0 // waiter will be called for all queries, including - // initial setup queries. The state is only assigned when no + // initial setup queries. The state is only assigned when // no queries are made. // // Only allow the first batch of queries to finish once the @@ -1338,6 +1338,52 @@ func TestConnQuery(t *testing.T) { } } +func TestCursorFake(t *testing.T) { + db := newTestDB(t, "people") + defer closeDB(t, db) + + ctx, cancel := context.WithTimeout(context.Background(), time.Second*30) + defer cancel() + + exec(t, db, "CREATE|peoplecursor|list=table") + exec(t, db, "INSERT|peoplecursor|list=people!name!age") + + rows, err := db.QueryContext(ctx, `SELECT|peoplecursor|list|`) + if err != nil { + t.Fatal(err) + } + defer rows.Close() + + if !rows.Next() { + t.Fatal("no rows") + } + var cursor = &Rows{} + err = rows.Scan(cursor) + if err != nil { + t.Fatal(err) + } + defer cursor.Close() + + const expectedRows = 3 + var currentRow int64 + + var n int64 + var s string + for cursor.Next() { + currentRow++ + err = cursor.Scan(&s, &n) + if err != nil { + t.Fatal(err) + } + if n != currentRow { + t.Errorf("expected number(Age)=%d, got %d", currentRow, n) + } + } + if currentRow != expectedRows { + t.Errorf("expected %d rows, got %d rows", expectedRows, currentRow) + } +} + func TestInvalidNilValues(t *testing.T) { var date1 time.Time var date2 int @@ -3415,6 +3461,58 @@ func TestConnectionLeak(t *testing.T) { wg.Wait() } +func TestStatsMaxIdleClosedZero(t *testing.T) { + db := newTestDB(t, "people") + defer closeDB(t, db) + + db.SetMaxOpenConns(1) + db.SetMaxIdleConns(1) + db.SetConnMaxLifetime(0) + + preMaxIdleClosed := db.Stats().MaxIdleClosed + + for i := 0; i < 10; i++ { + rows, err := db.Query("SELECT|people|name|") + if err != nil { + t.Fatal(err) + } + rows.Close() + } + + st := db.Stats() + maxIdleClosed := st.MaxIdleClosed - preMaxIdleClosed + t.Logf("MaxIdleClosed: %d", maxIdleClosed) + if maxIdleClosed != 0 { + t.Fatal("expected 0 max idle closed conns, got: ", maxIdleClosed) + } +} + +func TestStatsMaxIdleClosedTen(t *testing.T) { + db := newTestDB(t, "people") + defer closeDB(t, db) + + db.SetMaxOpenConns(1) + db.SetMaxIdleConns(0) + db.SetConnMaxLifetime(0) + + preMaxIdleClosed := db.Stats().MaxIdleClosed + + for i := 0; i < 10; i++ { + rows, err := db.Query("SELECT|people|name|") + if err != nil { + t.Fatal(err) + } + rows.Close() + } + + st := db.Stats() + maxIdleClosed := st.MaxIdleClosed - preMaxIdleClosed + t.Logf("MaxIdleClosed: %d", maxIdleClosed) + if maxIdleClosed != 10 { + t.Fatal("expected 0 max idle closed conns, got: ", maxIdleClosed) + } +} + type nvcDriver struct { fakeDriver skipNamedValueCheck bool diff --git a/libgo/go/debug/dwarf/line.go b/libgo/go/debug/dwarf/line.go index 4e6e1429d93..b862b49d627 100644 --- a/libgo/go/debug/dwarf/line.go +++ b/libgo/go/debug/dwarf/line.go @@ -590,7 +590,7 @@ func (r *LineReader) SeekPC(pc uint64, entry *LineEntry) error { } } -// pathIsAbs returns whether path is an absolute path (or "full path +// pathIsAbs reports whether path is an absolute path (or "full path // name" in DWARF parlance). This is in "whatever form makes sense for // the host system", so this accepts both UNIX-style and DOS-style // absolute paths. We avoid the filepath package because we want this diff --git a/libgo/go/debug/elf/elf.go b/libgo/go/debug/elf/elf.go index 07c03e79996..96a67ce7327 100644 --- a/libgo/go/debug/elf/elf.go +++ b/libgo/go/debug/elf/elf.go @@ -2424,6 +2424,7 @@ const ( R_RISCV_SET8 R_RISCV = 54 /* Local label subtraction */ R_RISCV_SET16 R_RISCV = 55 /* Local label subtraction */ R_RISCV_SET32 R_RISCV = 56 /* Local label subtraction */ + R_RISCV_32_PCREL R_RISCV = 57 /* 32-bit PC relative */ ) var rriscvStrings = []intName{ @@ -2480,6 +2481,7 @@ var rriscvStrings = []intName{ {54, "R_RISCV_SET8"}, {55, "R_RISCV_SET16"}, {56, "R_RISCV_SET32"}, + {57, "R_RISCV_32_PCREL"}, } func (i R_RISCV) String() string { return stringName(uint32(i), rriscvStrings, false) } diff --git a/libgo/go/debug/elf/file_test.go b/libgo/go/debug/elf/file_test.go index 11d8992b714..d7c1e9f800d 100644 --- a/libgo/go/debug/elf/file_test.go +++ b/libgo/go/debug/elf/file_test.go @@ -784,7 +784,7 @@ func TestCompressedSection(t *testing.T) { func TestNoSectionOverlaps(t *testing.T) { // Ensure cmd/link outputs sections without overlaps. switch runtime.GOOS { - case "android", "darwin", "js", "nacl", "plan9", "windows": + case "aix", "android", "darwin", "js", "nacl", "plan9", "windows": t.Skipf("cmd/link doesn't produce ELF binaries on %s", runtime.GOOS) } _ = net.ResolveIPAddr // force dynamic linkage diff --git a/libgo/go/debug/gosym/pclntab_test.go b/libgo/go/debug/gosym/pclntab_test.go index 7e7cee67934..d21f0e24a83 100644 --- a/libgo/go/debug/gosym/pclntab_test.go +++ b/libgo/go/debug/gosym/pclntab_test.go @@ -5,7 +5,6 @@ package gosym import ( - "bytes" "debug/elf" "internal/testenv" "io/ioutil" @@ -33,33 +32,10 @@ func dotest(t *testing.T) { if err != nil { t.Fatal(err) } - // This command builds pclinetest from pclinetest.asm; - // the resulting binary looks like it was built from pclinetest.s, - // but we have renamed it to keep it away from the go tool. pclinetestBinary = filepath.Join(pclineTempDir, "pclinetest") - cmd := exec.Command(testenv.GoToolPath(t), "tool", "asm", "-o", pclinetestBinary+".o", "pclinetest.asm") - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - if err := cmd.Run(); err != nil { - t.Fatal(err) - } - - // stamp .o file as being 'package main' so that go tool link will accept it - data, err := ioutil.ReadFile(pclinetestBinary + ".o") - if err != nil { - t.Fatal(err) - } - i := bytes.IndexByte(data, '\n') - if i < 0 { - t.Fatal("bad binary") - } - data = append(append(data[:i:i], "\nmain"...), data[i:]...) - if err := ioutil.WriteFile(pclinetestBinary+".o", data, 0666); err != nil { - t.Fatal(err) - } - - cmd = exec.Command(testenv.GoToolPath(t), "tool", "link", "-H", "linux", - "-o", pclinetestBinary, pclinetestBinary+".o") + cmd := exec.Command(testenv.GoToolPath(t), "build", "-o", pclinetestBinary) + cmd.Dir = "testdata" + cmd.Env = append(os.Environ(), "GOOS=linux") cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { @@ -232,7 +208,7 @@ func TestPCLine(t *testing.T) { } // Test PCToLine - sym := tab.LookupFunc("linefrompc") + sym := tab.LookupFunc("main.linefrompc") wantLine := 0 for pc := sym.Entry; pc < sym.End; pc++ { off := pc - text.Addr // TODO(rsc): should not need off; bug in 8g @@ -244,13 +220,13 @@ func TestPCLine(t *testing.T) { file, line, fn := tab.PCToLine(pc) if fn == nil { t.Errorf("failed to get line of PC %#x", pc) - } else if !strings.HasSuffix(file, "pclinetest.asm") || line != wantLine || fn != sym { - t.Errorf("PCToLine(%#x) = %s:%d (%s), want %s:%d (%s)", pc, file, line, fn.Name, "pclinetest.asm", wantLine, sym.Name) + } else if !strings.HasSuffix(file, "pclinetest.s") || line != wantLine || fn != sym { + t.Errorf("PCToLine(%#x) = %s:%d (%s), want %s:%d (%s)", pc, file, line, fn.Name, "pclinetest.s", wantLine, sym.Name) } } // Test LineToPC - sym = tab.LookupFunc("pcfromline") + sym = tab.LookupFunc("main.pcfromline") lookupline := -1 wantLine = 0 off := uint64(0) // TODO(rsc): should not need off; bug in 8g diff --git a/libgo/go/debug/gosym/symtab.go b/libgo/go/debug/gosym/symtab.go index a995209934f..a84b7f6def1 100644 --- a/libgo/go/debug/gosym/symtab.go +++ b/libgo/go/debug/gosym/symtab.go @@ -7,11 +7,6 @@ // by the gc compilers. package gosym -// The table format is a variant of the format used in Plan 9's a.out -// format, documented at https://9p.io/magic/man2html/6/a.out. -// The best reference for the differences between the Plan 9 format -// and the Go format is the runtime source, specifically ../../runtime/symtab.c. - import ( "bytes" "encoding/binary" diff --git a/libgo/go/debug/gosym/testdata/main.go b/libgo/go/debug/gosym/testdata/main.go new file mode 100644 index 00000000000..b7702184cde --- /dev/null +++ b/libgo/go/debug/gosym/testdata/main.go @@ -0,0 +1,10 @@ +package main + +func linefrompc() +func pcfromline() + +func main() { + // Prevent GC of our test symbols + linefrompc() + pcfromline() +} diff --git a/libgo/go/debug/gosym/testdata/pclinetest.h b/libgo/go/debug/gosym/testdata/pclinetest.h new file mode 100644 index 00000000000..156c0b87b00 --- /dev/null +++ b/libgo/go/debug/gosym/testdata/pclinetest.h @@ -0,0 +1,9 @@ +// +build ignore + +// Empty include file to generate z symbols + + + + + +// EOF diff --git a/libgo/go/debug/gosym/testdata/pclinetest.s b/libgo/go/debug/gosym/testdata/pclinetest.s new file mode 100644 index 00000000000..53461cdfc1a --- /dev/null +++ b/libgo/go/debug/gosym/testdata/pclinetest.s @@ -0,0 +1,48 @@ +TEXT ·linefrompc(SB),4,$0 // Each byte stores its line delta +BYTE $2; +BYTE $1; +BYTE $1; BYTE $0; +BYTE $1; BYTE $0; BYTE $0; +BYTE $1; BYTE $0; BYTE $0; BYTE $0; BYTE $0; +BYTE $1; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; +BYTE $1; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; +BYTE $1; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; +BYTE $1; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; +BYTE $1; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; +BYTE $1; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; +BYTE $1; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; +BYTE $1; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; +BYTE $1; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; +BYTE $1; +BYTE $1; +BYTE $1; BYTE $0; +BYTE $1; BYTE $0; BYTE $0; +BYTE $1; BYTE $0; BYTE $0; BYTE $0; BYTE $0; +BYTE $1; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; +BYTE $1; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; +BYTE $1; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; +BYTE $1; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; BYTE $0; +#include "pclinetest.h" +BYTE $2; +#include "pclinetest.h" +BYTE $2; +BYTE $255; + +TEXT ·pcfromline(SB),4,$0 // Each record stores its line delta, then n, then n more bytes +BYTE $32; BYTE $0; +BYTE $1; BYTE $1; BYTE $0; +BYTE $1; BYTE $0; + +BYTE $2; BYTE $4; BYTE $0; BYTE $0; BYTE $0; BYTE $0; + + +#include "pclinetest.h" +BYTE $4; BYTE $0; + + +BYTE $3; BYTE $3; BYTE $0; BYTE $0; BYTE $0; +#include "pclinetest.h" + + +BYTE $4; BYTE $3; BYTE $0; BYTE $0; BYTE $0; +BYTE $255; diff --git a/libgo/go/debug/pe/file.go b/libgo/go/debug/pe/file.go index 2f5efae4e67..1c308b3dc3b 100644 --- a/libgo/go/debug/pe/file.go +++ b/libgo/go/debug/pe/file.go @@ -91,7 +91,7 @@ func NewFile(r io.ReaderAt) (*File, error) { return nil, err } switch f.FileHeader.Machine { - case IMAGE_FILE_MACHINE_UNKNOWN, IMAGE_FILE_MACHINE_AMD64, IMAGE_FILE_MACHINE_I386: + case IMAGE_FILE_MACHINE_UNKNOWN, IMAGE_FILE_MACHINE_ARMNT, IMAGE_FILE_MACHINE_AMD64, IMAGE_FILE_MACHINE_I386: default: return nil, fmt.Errorf("Unrecognised COFF file header machine value of 0x%x.", f.FileHeader.Machine) } diff --git a/libgo/go/debug/pe/file_test.go b/libgo/go/debug/pe/file_test.go index 24cd673254e..9613af3a3c3 100644 --- a/libgo/go/debug/pe/file_test.go +++ b/libgo/go/debug/pe/file_test.go @@ -298,6 +298,17 @@ const ( linkCgoExternal ) +func getImageBase(f *File) uintptr { + switch oh := f.OptionalHeader.(type) { + case *OptionalHeader32: + return uintptr(oh.ImageBase) + case *OptionalHeader64: + return uintptr(oh.ImageBase) + default: + panic("unexpected optionalheader type") + } +} + func testDWARF(t *testing.T, linktype int) { if runtime.GOOS != "windows" { t.Skip("skipping windows only test") @@ -347,14 +358,15 @@ func testDWARF(t *testing.T, linktype int) { if err != nil { t.Fatalf("running test executable failed: %s %s", err, out) } + t.Logf("Testprog output:\n%s", string(out)) - matches := regexp.MustCompile("main=(.*)\n").FindStringSubmatch(string(out)) + matches := regexp.MustCompile("offset=(.*)\n").FindStringSubmatch(string(out)) if len(matches) < 2 { t.Fatalf("unexpected program output: %s", out) } - wantaddr, err := strconv.ParseUint(matches[1], 0, 64) + wantoffset, err := strconv.ParseUint(matches[1], 0, 64) if err != nil { - t.Fatalf("unexpected main address %q: %s", matches[1], err) + t.Fatalf("unexpected main offset %q: %s", matches[1], err) } f, err := Open(exe) @@ -363,6 +375,8 @@ func testDWARF(t *testing.T, linktype int) { } defer f.Close() + imageBase := getImageBase(f) + var foundDebugGDBScriptsSection bool for _, sect := range f.Sections { if sect.Name == ".debug_gdb_scripts" { @@ -389,10 +403,20 @@ func testDWARF(t *testing.T, linktype int) { break } if e.Tag == dwarf.TagSubprogram { - if name, ok := e.Val(dwarf.AttrName).(string); ok && name == "main.main" { - if addr, ok := e.Val(dwarf.AttrLowpc).(uint64); ok && addr == wantaddr { - return + name, ok := e.Val(dwarf.AttrName).(string) + if ok && name == "main.main" { + t.Logf("Found main.main") + addr, ok := e.Val(dwarf.AttrLowpc).(uint64) + if !ok { + t.Fatal("Failed to get AttrLowpc") + } + offset := uintptr(addr) - imageBase + if offset != uintptr(wantoffset) { + t.Fatal("Runtime offset (0x%x) did "+ + "not match dwarf offset "+ + "(0x%x)", wantoffset, offset) } + return } } } @@ -479,11 +503,52 @@ const testprog = ` package main import "fmt" +import "syscall" +import "unsafe" {{if .}}import "C" {{end}} +// struct MODULEINFO from the Windows SDK +type moduleinfo struct { + BaseOfDll uintptr + SizeOfImage uint32 + EntryPoint uintptr +} + +func add(p unsafe.Pointer, x uintptr) unsafe.Pointer { + return unsafe.Pointer(uintptr(p) + x) +} + +func funcPC(f interface{}) uintptr { + var a uintptr + return **(**uintptr)(add(unsafe.Pointer(&f), unsafe.Sizeof(a))) +} + func main() { + kernel32 := syscall.MustLoadDLL("kernel32.dll") + psapi := syscall.MustLoadDLL("psapi.dll") + getModuleHandle := kernel32.MustFindProc("GetModuleHandleW") + getCurrentProcess := kernel32.MustFindProc("GetCurrentProcess") + getModuleInformation := psapi.MustFindProc("GetModuleInformation") + + procHandle, _, _ := getCurrentProcess.Call() + moduleHandle, _, err := getModuleHandle.Call(0) + if moduleHandle == 0 { + panic(fmt.Sprintf("GetModuleHandle() failed: %d", err)) + } + + var info moduleinfo + ret, _, err := getModuleInformation.Call(procHandle, moduleHandle, + uintptr(unsafe.Pointer(&info)), unsafe.Sizeof(info)) + + if ret == 0 { + panic(fmt.Sprintf("GetModuleInformation() failed: %d", err)) + } + + offset := funcPC(main) - info.BaseOfDll + fmt.Printf("base=0x%x\n", info.BaseOfDll) fmt.Printf("main=%p\n", main) + fmt.Printf("offset=0x%x\n", offset) } ` @@ -535,13 +600,15 @@ func TestBuildingWindowsGUI(t *testing.T) { func TestImportTableInUnknownSection(t *testing.T) { if runtime.GOOS != "windows" { - t.Skip("skipping windows only test") + t.Skip("skipping Windows-only test") } - // first we need to find this font driver - path, err := exec.LookPath("atmfd.dll") + // ws2_32.dll import table is located in ".rdata" section, + // so it is good enough to test issue #16103. + const filename = "ws2_32.dll" + path, err := exec.LookPath(filename) if err != nil { - t.Fatalf("unable to locate required file %q in search path: %s", "atmfd.dll", err) + t.Fatalf("unable to locate required file %q in search path: %s", filename, err) } f, err := Open(path) diff --git a/libgo/go/debug/pe/pe.go b/libgo/go/debug/pe/pe.go index e933ae1c2aa..3f8099dfab1 100644 --- a/libgo/go/debug/pe/pe.go +++ b/libgo/go/debug/pe/pe.go @@ -91,6 +91,7 @@ const ( IMAGE_FILE_MACHINE_AM33 = 0x1d3 IMAGE_FILE_MACHINE_AMD64 = 0x8664 IMAGE_FILE_MACHINE_ARM = 0x1c0 + IMAGE_FILE_MACHINE_ARMNT = 0x1c4 IMAGE_FILE_MACHINE_ARM64 = 0xaa64 IMAGE_FILE_MACHINE_EBC = 0xebc IMAGE_FILE_MACHINE_I386 = 0x14c diff --git a/libgo/go/debug/plan9obj/file.go b/libgo/go/debug/plan9obj/file.go index c78e35d0008..314608da610 100644 --- a/libgo/go/debug/plan9obj/file.go +++ b/libgo/go/debug/plan9obj/file.go @@ -274,7 +274,7 @@ func newTable(symtab []byte, ptrsz int) ([]Sym, error) { ts.Value = s.value switch s.typ { default: - ts.Name = string(s.name[:]) + ts.Name = string(s.name) case 'z', 'Z': for i := 0; i < len(s.name); i += 2 { eltIdx := binary.BigEndian.Uint16(s.name[i : i+2]) diff --git a/libgo/go/encoding/asn1/asn1.go b/libgo/go/encoding/asn1/asn1.go index 1ed357adfff..3cfd9d12764 100644 --- a/libgo/go/encoding/asn1/asn1.go +++ b/libgo/go/encoding/asn1/asn1.go @@ -633,7 +633,7 @@ var ( bigIntType = reflect.TypeOf(new(big.Int)) ) -// invalidLength returns true iff offset + length > sliceLength, or if the +// invalidLength reports whether offset + length > sliceLength, or if the // addition would overflow. func invalidLength(offset, length, sliceLength int) bool { return offset+length < offset || offset+length > sliceLength diff --git a/libgo/go/encoding/base32/base32_test.go b/libgo/go/encoding/base32/base32_test.go index c5506ed4de7..b74054ba402 100644 --- a/libgo/go/encoding/base32/base32_test.go +++ b/libgo/go/encoding/base32/base32_test.go @@ -425,7 +425,7 @@ IZJAOZSWY2LUEBSXG43FEBRWS3DMOVWSAZDPNRXXEZJAMV2SAZTVM5UWC5BANZ2WY3DBBJYGC4TJMF NZ2CYIDTOVXHIIDJNYFGG5LMOBQSA4LVNEQG6ZTGNFRWSYJAMRSXGZLSOVXHIIDNN5WGY2LUEBQW42 LNEBUWIIDFON2CA3DBMJXXE5LNFY== ====` - encodedShort := strings.Replace(encoded, "\n", "", -1) + encodedShort := strings.ReplaceAll(encoded, "\n", "") dec := NewDecoder(StdEncoding, strings.NewReader(encoded)) res1, err := ioutil.ReadAll(dec) @@ -465,7 +465,7 @@ func TestWithCustomPadding(t *testing.T) { for _, testcase := range pairs { defaultPadding := StdEncoding.EncodeToString([]byte(testcase.decoded)) customPadding := StdEncoding.WithPadding('@').EncodeToString([]byte(testcase.decoded)) - expected := strings.Replace(defaultPadding, "=", "@", -1) + expected := strings.ReplaceAll(defaultPadding, "=", "@") if expected != customPadding { t.Errorf("Expected custom %s, got %s", expected, customPadding) @@ -675,7 +675,7 @@ func TestWithoutPaddingClose(t *testing.T) { expected := testpair.encoded if encoding.padChar == NoPadding { - expected = strings.Replace(expected, "=", "", -1) + expected = strings.ReplaceAll(expected, "=", "") } res := buf.String() @@ -697,7 +697,7 @@ func TestDecodeReadAll(t *testing.T) { for encIndex, encoding := range encodings { encoded := pair.encoded if encoding.padChar == NoPadding { - encoded = strings.Replace(encoded, "=", "", -1) + encoded = strings.ReplaceAll(encoded, "=", "") } decReader, err := ioutil.ReadAll(NewDecoder(encoding, strings.NewReader(encoded))) @@ -723,7 +723,7 @@ func TestDecodeSmallBuffer(t *testing.T) { for encIndex, encoding := range encodings { encoded := pair.encoded if encoding.padChar == NoPadding { - encoded = strings.Replace(encoded, "=", "", -1) + encoded = strings.ReplaceAll(encoded, "=", "") } decoder := NewDecoder(encoding, strings.NewReader(encoded)) diff --git a/libgo/go/encoding/base64/base64.go b/libgo/go/encoding/base64/base64.go index 9a99370f1e5..0bb37b311a0 100644 --- a/libgo/go/encoding/base64/base64.go +++ b/libgo/go/encoding/base64/base64.go @@ -270,7 +270,7 @@ func (e CorruptInputError) Error() string { return "illegal base64 data at input byte " + strconv.FormatInt(int64(e), 10) } -// decodeQuantum decodes up to 4 base64 bytes. It takes for parameters +// decodeQuantum decodes up to 4 base64 bytes. The received parameters are // the destination buffer dst, the source buffer src and an index in the // source buffer si. // It returns the number of bytes read from src, the number of bytes written @@ -465,10 +465,9 @@ func (enc *Encoding) Decode(dst, src []byte) (n int, err error) { } si := 0 - ilen := len(src) - olen := len(dst) - for strconv.IntSize >= 64 && ilen-si >= 8 && olen-n >= 8 { - if ok := enc.decode64(dst[n:], src[si:]); ok { + for strconv.IntSize >= 64 && len(src)-si >= 8 && len(dst)-n >= 8 { + if dn, ok := enc.decode64(src[si:]); ok { + binary.BigEndian.PutUint64(dst[n:], dn) n += 6 si += 8 } else { @@ -481,8 +480,9 @@ func (enc *Encoding) Decode(dst, src []byte) (n int, err error) { } } - for ilen-si >= 4 && olen-n >= 4 { - if ok := enc.decode32(dst[n:], src[si:]); ok { + for len(src)-si >= 4 && len(dst)-n >= 4 { + if dn, ok := enc.decode32(src[si:]); ok { + binary.BigEndian.PutUint32(dst[n:], dn) n += 3 si += 4 } else { @@ -506,72 +506,70 @@ func (enc *Encoding) Decode(dst, src []byte) (n int, err error) { return n, err } -// decode32 tries to decode 4 base64 char into 3 bytes. -// len(dst) and len(src) must both be >= 4. -// Returns true if decode succeeded. -func (enc *Encoding) decode32(dst, src []byte) bool { - var dn, n uint32 +// decode32 tries to decode 4 base64 characters into 3 bytes, and returns those +// bytes. len(src) must be >= 4. +// Returns (0, false) if decoding failed. +func (enc *Encoding) decode32(src []byte) (dn uint32, ok bool) { + var n uint32 + _ = src[3] if n = uint32(enc.decodeMap[src[0]]); n == 0xff { - return false + return 0, false } dn |= n << 26 if n = uint32(enc.decodeMap[src[1]]); n == 0xff { - return false + return 0, false } dn |= n << 20 if n = uint32(enc.decodeMap[src[2]]); n == 0xff { - return false + return 0, false } dn |= n << 14 if n = uint32(enc.decodeMap[src[3]]); n == 0xff { - return false + return 0, false } dn |= n << 8 - - binary.BigEndian.PutUint32(dst, dn) - return true + return dn, true } -// decode64 tries to decode 8 base64 char into 6 bytes. -// len(dst) and len(src) must both be >= 8. -// Returns true if decode succeeded. -func (enc *Encoding) decode64(dst, src []byte) bool { - var dn, n uint64 +// decode64 tries to decode 8 base64 characters into 6 bytes, and returns those +// bytes. len(src) must be >= 8. +// Returns (0, false) if decoding failed. +func (enc *Encoding) decode64(src []byte) (dn uint64, ok bool) { + var n uint64 + _ = src[7] if n = uint64(enc.decodeMap[src[0]]); n == 0xff { - return false + return 0, false } dn |= n << 58 if n = uint64(enc.decodeMap[src[1]]); n == 0xff { - return false + return 0, false } dn |= n << 52 if n = uint64(enc.decodeMap[src[2]]); n == 0xff { - return false + return 0, false } dn |= n << 46 if n = uint64(enc.decodeMap[src[3]]); n == 0xff { - return false + return 0, false } dn |= n << 40 if n = uint64(enc.decodeMap[src[4]]); n == 0xff { - return false + return 0, false } dn |= n << 34 if n = uint64(enc.decodeMap[src[5]]); n == 0xff { - return false + return 0, false } dn |= n << 28 if n = uint64(enc.decodeMap[src[6]]); n == 0xff { - return false + return 0, false } dn |= n << 22 if n = uint64(enc.decodeMap[src[7]]); n == 0xff { - return false + return 0, false } dn |= n << 16 - - binary.BigEndian.PutUint64(dst, dn) - return true + return dn, true } type newlineFilteringReader struct { diff --git a/libgo/go/encoding/base64/base64_test.go b/libgo/go/encoding/base64/base64_test.go index f019654f5b5..f7f312ca393 100644 --- a/libgo/go/encoding/base64/base64_test.go +++ b/libgo/go/encoding/base64/base64_test.go @@ -53,8 +53,8 @@ func stdRef(ref string) string { // Convert a reference string to URL-encoding func urlRef(ref string) string { - ref = strings.Replace(ref, "+", "-", -1) - ref = strings.Replace(ref, "/", "_", -1) + ref = strings.ReplaceAll(ref, "+", "-") + ref = strings.ReplaceAll(ref, "/", "_") return ref } @@ -72,7 +72,7 @@ func rawURLRef(ref string) string { var funnyEncoding = NewEncoding(encodeStd).WithPadding(rune('@')) func funnyRef(ref string) string { - return strings.Replace(ref, "=", "@", -1) + return strings.ReplaceAll(ref, "=", "@") } type encodingTest struct { @@ -418,7 +418,7 @@ j+mSARB/17pKVXYWHXjsj7yIex0PadzXMO1zT5KHoNA3HT8ietoGhgjsfA+CSnvvqh/jJtqsrwOv 2b6NGNzXfTYexzJ+nU7/ALkf4P8Awv6P9KvTQQ4AgyDqCF85Pho3CTB7eHwXoH+LT65uZbX9X+o2 bqbPb06551Y4 ` - encodedShort := strings.Replace(encoded, "\n", "", -1) + encodedShort := strings.ReplaceAll(encoded, "\n", "") dec := NewDecoder(StdEncoding, strings.NewReader(encoded)) res1, err := ioutil.ReadAll(dec) diff --git a/libgo/go/encoding/binary/binary.go b/libgo/go/encoding/binary/binary.go index 85b3bc2295d..8c2d1d9da47 100644 --- a/libgo/go/encoding/binary/binary.go +++ b/libgo/go/encoding/binary/binary.go @@ -161,23 +161,17 @@ func (bigEndian) GoString() string { return "binary.BigEndian" } func Read(r io.Reader, order ByteOrder, data interface{}) error { // Fast path for basic types and slices. if n := intDataSize(data); n != 0 { - var b [8]byte - var bs []byte - if n > len(b) { - bs = make([]byte, n) - } else { - bs = b[:n] - } + bs := make([]byte, n) if _, err := io.ReadFull(r, bs); err != nil { return err } switch data := data.(type) { case *bool: - *data = b[0] != 0 + *data = bs[0] != 0 case *int8: - *data = int8(b[0]) + *data = int8(bs[0]) case *uint8: - *data = b[0] + *data = bs[0] case *int16: *data = int16(order.Uint16(bs)) case *uint16: @@ -260,25 +254,19 @@ func Read(r io.Reader, order ByteOrder, data interface{}) error { func Write(w io.Writer, order ByteOrder, data interface{}) error { // Fast path for basic types and slices. if n := intDataSize(data); n != 0 { - var b [8]byte - var bs []byte - if n > len(b) { - bs = make([]byte, n) - } else { - bs = b[:n] - } + bs := make([]byte, n) switch v := data.(type) { case *bool: if *v { - b[0] = 1 + bs[0] = 1 } else { - b[0] = 0 + bs[0] = 0 } case bool: if v { - b[0] = 1 + bs[0] = 1 } else { - b[0] = 0 + bs[0] = 0 } case []bool: for i, x := range v { @@ -289,19 +277,19 @@ func Write(w io.Writer, order ByteOrder, data interface{}) error { } } case *int8: - b[0] = byte(*v) + bs[0] = byte(*v) case int8: - b[0] = byte(v) + bs[0] = byte(v) case []int8: for i, x := range v { bs[i] = byte(x) } case *uint8: - b[0] = *v + bs[0] = *v case uint8: - b[0] = v + bs[0] = v case []uint8: - bs = v + bs = v // TODO(josharian): avoid allocating bs in this case? case *int16: order.PutUint16(bs, uint16(*v)) case int16: diff --git a/libgo/go/encoding/gob/decoder.go b/libgo/go/encoding/gob/decoder.go index 5ef03888621..b52aabe54b5 100644 --- a/libgo/go/encoding/gob/decoder.go +++ b/libgo/go/encoding/gob/decoder.go @@ -12,13 +12,14 @@ import ( "sync" ) -// tooBig provides a sanity check for sizes; used in several places. -// Upper limit of 1GB, allowing room to grow a little without overflow. -// TODO: make this adjustable? -const tooBig = 1 << 30 +// tooBig provides a sanity check for sizes; used in several places. Upper limit +// of is 1GB on 32-bit systems, 8GB on 64-bit, allowing room to grow a little +// without overflow. +const tooBig = (1 << 30) << (^uint(0) >> 62) // A Decoder manages the receipt of type and data information read from the -// remote side of a connection. +// remote side of a connection. It is safe for concurrent use by multiple +// goroutines. // // The Decoder does only basic sanity checking on decoded input sizes, // and its limits are not configurable. Take caution when decoding gob data diff --git a/libgo/go/encoding/gob/encoder.go b/libgo/go/encoding/gob/encoder.go index 40ec81b6e69..53e2cace166 100644 --- a/libgo/go/encoding/gob/encoder.go +++ b/libgo/go/encoding/gob/encoder.go @@ -12,7 +12,8 @@ import ( ) // An Encoder manages the transmission of type and data information to the -// other side of a connection. +// other side of a connection. It is safe for concurrent use by multiple +// goroutines. type Encoder struct { mutex sync.Mutex // each item must be sent atomically w []io.Writer // where to send the data diff --git a/libgo/go/encoding/gob/encoder_test.go b/libgo/go/encoding/gob/encoder_test.go index dc9bbcf35d8..825f0d6f03e 100644 --- a/libgo/go/encoding/gob/encoder_test.go +++ b/libgo/go/encoding/gob/encoder_test.go @@ -10,7 +10,6 @@ import ( "fmt" "io/ioutil" "reflect" - "runtime" "strings" "testing" ) @@ -1128,24 +1127,3 @@ func TestBadData(t *testing.T) { } } } - -// TestHugeWriteFails tests that enormous messages trigger an error. -func TestHugeWriteFails(t *testing.T) { - if runtime.GOARCH == "wasm" { - t.Skip("out of memory on wasm") - } - if testing.Short() { - // Requires allocating a monster, so don't do this from all.bash. - t.Skip("skipping huge allocation in short mode") - } - huge := make([]byte, tooBig) - huge[0] = 7 // Make sure it's not all zeros. - buf := new(bytes.Buffer) - err := NewEncoder(buf).Encode(huge) - if err == nil { - t.Fatalf("expected error for huge slice") - } - if !strings.Contains(err.Error(), "message too big") { - t.Fatalf("expected 'too big' error; got %s\n", err.Error()) - } -} diff --git a/libgo/go/encoding/hex/hex.go b/libgo/go/encoding/hex/hex.go index aee5aecb1a7..2bb2b57df9c 100644 --- a/libgo/go/encoding/hex/hex.go +++ b/libgo/go/encoding/hex/hex.go @@ -6,10 +6,10 @@ package hex import ( - "bytes" "errors" "fmt" "io" + "strings" ) const hextable = "0123456789abcdef" @@ -116,7 +116,16 @@ func DecodeString(s string) ([]byte, error) { // Dump returns a string that contains a hex dump of the given data. The format // of the hex dump matches the output of `hexdump -C` on the command line. func Dump(data []byte) string { - var buf bytes.Buffer + if len(data) == 0 { + return "" + } + + var buf strings.Builder + // Dumper will write 79 bytes per complete 16 byte chunk, and at least + // 64 bytes for whatever remains. Round the allocation up, since only a + // maximum of 15 bytes will be wasted. + buf.Grow((1 + ((len(data) - 1) / 16)) * 79) + dumper := Dumper(&buf) dumper.Write(data) dumper.Close() diff --git a/libgo/go/encoding/hex/hex_test.go b/libgo/go/encoding/hex/hex_test.go index 6ba054ef9a0..e9f4b3a53ad 100644 --- a/libgo/go/encoding/hex/hex_test.go +++ b/libgo/go/encoding/hex/hex_test.go @@ -248,3 +248,16 @@ func BenchmarkEncode(b *testing.B) { }) } } + +func BenchmarkDump(b *testing.B) { + for _, size := range []int{256, 1024, 4096, 16384} { + src := bytes.Repeat([]byte{2, 3, 5, 7, 9, 11, 13, 17}, size/8) + sink = make([]byte, 2*size) + + b.Run(fmt.Sprintf("%v", size), func(b *testing.B) { + for i := 0; i < b.N; i++ { + Dump(src) + } + }) + } +} diff --git a/libgo/go/encoding/json/bench_test.go b/libgo/go/encoding/json/bench_test.go index bd322db2e6f..72cb349062c 100644 --- a/libgo/go/encoding/json/bench_test.go +++ b/libgo/go/encoding/json/bench_test.go @@ -114,6 +114,34 @@ func BenchmarkCodeMarshal(b *testing.B) { b.SetBytes(int64(len(codeJSON))) } +func benchMarshalBytes(n int) func(*testing.B) { + sample := []byte("hello world") + // Use a struct pointer, to avoid an allocation when passing it as an + // interface parameter to Marshal. + v := &struct { + Bytes []byte + }{ + bytes.Repeat(sample, (n/len(sample))+1)[:n], + } + return func(b *testing.B) { + for i := 0; i < b.N; i++ { + if _, err := Marshal(v); err != nil { + b.Fatal("Marshal:", err) + } + } + } +} + +func BenchmarkMarshalBytes(b *testing.B) { + // 32 fits within encodeState.scratch. + b.Run("32", benchMarshalBytes(32)) + // 256 doesn't fit in encodeState.scratch, but is small enough to + // allocate and avoid the slower base64.NewEncoder. + b.Run("256", benchMarshalBytes(256)) + // 4096 is large enough that we want to avoid allocating for it. + b.Run("4096", benchMarshalBytes(4096)) +} + func BenchmarkCodeDecoder(b *testing.B) { if codeJSON == nil { b.StopTimer() diff --git a/libgo/go/encoding/json/decode.go b/libgo/go/encoding/json/decode.go index 7d235087e60..731553dca6b 100644 --- a/libgo/go/encoding/json/decode.go +++ b/libgo/go/encoding/json/decode.go @@ -11,7 +11,6 @@ import ( "bytes" "encoding" "encoding/base64" - "errors" "fmt" "reflect" "strconv" @@ -179,7 +178,7 @@ func (d *decodeState) unmarshal(v interface{}) error { // test must be applied at the top level of the value. err := d.value(rv) if err != nil { - return err + return d.addErrorContext(err) } return d.savedError } @@ -267,7 +266,7 @@ type decodeState struct { opcode int // last read result scan scanner errorContext struct { // provides context for type errors - Struct string + Struct reflect.Type Field string } savedError error @@ -280,16 +279,16 @@ func (d *decodeState) readIndex() int { return d.off - 1 } -// errPhase is used for errors that should not happen unless -// there is a bug in the JSON decoder or something is editing -// the data slice while the decoder executes. -var errPhase = errors.New("JSON decoder out of sync - data changing underfoot?") +// phasePanicMsg is used as a panic message when we end up with something that +// shouldn't happen. It can indicate a bug in the JSON decoder, or that +// something is editing the data slice while the decoder executes. +const phasePanicMsg = "JSON decoder out of sync - data changing underfoot?" func (d *decodeState) init(data []byte) *decodeState { d.data = data d.off = 0 d.savedError = nil - d.errorContext.Struct = "" + d.errorContext.Struct = nil d.errorContext.Field = "" return d } @@ -304,10 +303,10 @@ func (d *decodeState) saveError(err error) { // addErrorContext returns a new error enhanced with information from d.errorContext func (d *decodeState) addErrorContext(err error) error { - if d.errorContext.Struct != "" || d.errorContext.Field != "" { + if d.errorContext.Struct != nil || d.errorContext.Field != "" { switch err := err.(type) { case *UnmarshalTypeError: - err.Struct = d.errorContext.Struct + err.Struct = d.errorContext.Struct.Name() err.Field = d.errorContext.Field return err } @@ -332,13 +331,12 @@ func (d *decodeState) skip() { // scanNext processes the byte at d.data[d.off]. func (d *decodeState) scanNext() { - s, data, i := &d.scan, d.data, d.off - if i < len(data) { - d.opcode = s.step(s, data[i]) - d.off = i + 1 + if d.off < len(d.data) { + d.opcode = d.scan.step(&d.scan, d.data[d.off]) + d.off++ } else { - d.opcode = s.eof() - d.off = len(data) + 1 // mark processed EOF with len+1 + d.opcode = d.scan.eof() + d.off = len(d.data) + 1 // mark processed EOF with len+1 } } @@ -346,7 +344,7 @@ func (d *decodeState) scanNext() { // receives a scan code not equal to op. func (d *decodeState) scanWhile(op int) { s, data, i := &d.scan, d.data, d.off - for i < len(d.data) { + for i < len(data) { newOp := s.step(s, data[i]) i++ if newOp != op { @@ -356,7 +354,7 @@ func (d *decodeState) scanWhile(op int) { } } - d.off = len(d.data) + 1 // mark processed EOF with len+1 + d.off = len(data) + 1 // mark processed EOF with len+1 d.opcode = d.scan.eof() } @@ -366,7 +364,7 @@ func (d *decodeState) scanWhile(op int) { func (d *decodeState) value(v reflect.Value) error { switch d.opcode { default: - return errPhase + panic(phasePanicMsg) case scanBeginArray: if v.IsValid() { @@ -408,30 +406,23 @@ type unquotedValue struct{} // quoted string literal or literal null into an interface value. // If it finds anything other than a quoted string literal or null, // valueQuoted returns unquotedValue{}. -func (d *decodeState) valueQuoted() (interface{}, error) { +func (d *decodeState) valueQuoted() interface{} { switch d.opcode { default: - return nil, errPhase + panic(phasePanicMsg) - case scanBeginArray: - d.skip() - d.scanNext() - - case scanBeginObject: + case scanBeginArray, scanBeginObject: d.skip() d.scanNext() case scanBeginLiteral: - v, err := d.literalInterface() - if err != nil { - return nil, err - } + v := d.literalInterface() switch v.(type) { case nil, string: - return v, nil + return v } } - return unquotedValue{}, nil + return unquotedValue{} } // indirect walks down v allocating pointers as needed, @@ -482,7 +473,7 @@ func indirect(v reflect.Value, decodingNull bool) (Unmarshaler, encoding.TextUnm if v.IsNil() { v.Set(reflect.New(v.Type().Elem())) } - if v.Type().NumMethod() > 0 { + if v.Type().NumMethod() > 0 && v.CanInterface() { if u, ok := v.Interface().(Unmarshaler); ok { return u, nil, reflect.Value{} } @@ -525,10 +516,7 @@ func (d *decodeState) array(v reflect.Value) error { case reflect.Interface: if v.NumMethod() == 0 { // Decoding into nil interface? Switch to non-reflect code. - ai, err := d.arrayInterface() - if err != nil { - return err - } + ai := d.arrayInterface() v.Set(reflect.ValueOf(ai)) return nil } @@ -538,8 +526,7 @@ func (d *decodeState) array(v reflect.Value) error { d.saveError(&UnmarshalTypeError{Value: "array", Type: v.Type(), Offset: int64(d.off)}) d.skip() return nil - case reflect.Array: - case reflect.Slice: + case reflect.Array, reflect.Slice: break } @@ -589,7 +576,7 @@ func (d *decodeState) array(v reflect.Value) error { break } if d.opcode != scanArrayValue { - return errPhase + panic(phasePanicMsg) } } @@ -611,7 +598,7 @@ func (d *decodeState) array(v reflect.Value) error { } var nullLiteral = []byte("null") -var textUnmarshalerType = reflect.TypeOf(new(encoding.TextUnmarshaler)).Elem() +var textUnmarshalerType = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem() // object consumes an object from d.data[d.off-1:], decoding into v. // The first byte ('{') of the object has been read already. @@ -629,17 +616,17 @@ func (d *decodeState) object(v reflect.Value) error { return nil } v = pv + t := v.Type() // Decoding into nil interface? Switch to non-reflect code. if v.Kind() == reflect.Interface && v.NumMethod() == 0 { - oi, err := d.objectInterface() - if err != nil { - return err - } + oi := d.objectInterface() v.Set(reflect.ValueOf(oi)) return nil } + var fields []field + // Check type of target: // struct or // map[T1]T2 where T1 is string, an integer type, @@ -648,14 +635,13 @@ func (d *decodeState) object(v reflect.Value) error { case reflect.Map: // Map key must either have string kind, have an integer kind, // or be an encoding.TextUnmarshaler. - t := v.Type() switch t.Key().Kind() { case reflect.String, reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: default: if !reflect.PtrTo(t.Key()).Implements(textUnmarshalerType) { - d.saveError(&UnmarshalTypeError{Value: "object", Type: v.Type(), Offset: int64(d.off)}) + d.saveError(&UnmarshalTypeError{Value: "object", Type: t, Offset: int64(d.off)}) d.skip() return nil } @@ -664,9 +650,10 @@ func (d *decodeState) object(v reflect.Value) error { v.Set(reflect.MakeMap(t)) } case reflect.Struct: + fields = cachedTypeFields(t) // ok default: - d.saveError(&UnmarshalTypeError{Value: "object", Type: v.Type(), Offset: int64(d.off)}) + d.saveError(&UnmarshalTypeError{Value: "object", Type: t, Offset: int64(d.off)}) d.skip() return nil } @@ -682,7 +669,7 @@ func (d *decodeState) object(v reflect.Value) error { break } if d.opcode != scanBeginLiteral { - return errPhase + panic(phasePanicMsg) } // Read key. @@ -691,7 +678,7 @@ func (d *decodeState) object(v reflect.Value) error { item := d.data[start:d.readIndex()] key, ok := unquoteBytes(item) if !ok { - return errPhase + panic(phasePanicMsg) } // Figure out field corresponding to key. @@ -699,7 +686,7 @@ func (d *decodeState) object(v reflect.Value) error { destring := false // whether the value is wrapped in a string to be decoded first if v.Kind() == reflect.Map { - elemType := v.Type().Elem() + elemType := t.Elem() if !mapElem.IsValid() { mapElem = reflect.New(elemType).Elem() } else { @@ -708,7 +695,6 @@ func (d *decodeState) object(v reflect.Value) error { subv = mapElem } else { var f *field - fields := cachedTypeFields(v.Type()) for i := range fields { ff := &fields[i] if bytes.Equal(ff.nameBytes, key) { @@ -745,7 +731,7 @@ func (d *decodeState) object(v reflect.Value) error { subv = subv.Field(i) } d.errorContext.Field = f.name - d.errorContext.Struct = v.Type().Name() + d.errorContext.Struct = t } else if d.disallowUnknownFields { d.saveError(fmt.Errorf("json: unknown field %q", key)) } @@ -756,16 +742,12 @@ func (d *decodeState) object(v reflect.Value) error { d.scanWhile(scanSkipSpace) } if d.opcode != scanObjectKey { - return errPhase + panic(phasePanicMsg) } d.scanWhile(scanSkipSpace) if destring { - q, err := d.valueQuoted() - if err != nil { - return err - } - switch qv := q.(type) { + switch qv := d.valueQuoted().(type) { case nil: if err := d.literalStore(nullLiteral, subv, false); err != nil { return err @@ -786,13 +768,13 @@ func (d *decodeState) object(v reflect.Value) error { // Write value back to map; // if using struct, subv points into struct already. if v.Kind() == reflect.Map { - kt := v.Type().Key() + kt := t.Key() var kv reflect.Value switch { case kt.Kind() == reflect.String: kv = reflect.ValueOf(key).Convert(kt) case reflect.PtrTo(kt).Implements(textUnmarshalerType): - kv = reflect.New(v.Type().Key()) + kv = reflect.New(kt) if err := d.literalStore(item, kv, true); err != nil { return err } @@ -804,7 +786,7 @@ func (d *decodeState) object(v reflect.Value) error { n, err := strconv.ParseInt(s, 10, 64) if err != nil || reflect.Zero(kt).OverflowInt(n) { d.saveError(&UnmarshalTypeError{Value: "number " + s, Type: kt, Offset: int64(start + 1)}) - return nil + break } kv = reflect.ValueOf(n).Convert(kt) case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: @@ -812,14 +794,16 @@ func (d *decodeState) object(v reflect.Value) error { n, err := strconv.ParseUint(s, 10, 64) if err != nil || reflect.Zero(kt).OverflowUint(n) { d.saveError(&UnmarshalTypeError{Value: "number " + s, Type: kt, Offset: int64(start + 1)}) - return nil + break } kv = reflect.ValueOf(n).Convert(kt) default: panic("json: Unexpected key type") // should never occur } } - v.SetMapIndex(kv, subv) + if kv.IsValid() { + v.SetMapIndex(kv, subv) + } } // Next token must be , or }. @@ -830,7 +814,7 @@ func (d *decodeState) object(v reflect.Value) error { break } if d.opcode != scanObjectValue { - return errPhase + panic(phasePanicMsg) } d.errorContext = originalErrorContext @@ -874,18 +858,16 @@ func (d *decodeState) literalStore(item []byte, v reflect.Value, fromQuoted bool if item[0] != '"' { if fromQuoted { d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type())) - } else { - var val string - switch item[0] { - case 'n': - val = "null" - case 't', 'f': - val = "bool" - default: - val = "number" - } - d.saveError(&UnmarshalTypeError{Value: val, Type: v.Type(), Offset: int64(d.readIndex())}) + return nil + } + val := "number" + switch item[0] { + case 'n': + val = "null" + case 't', 'f': + val = "bool" } + d.saveError(&UnmarshalTypeError{Value: val, Type: v.Type(), Offset: int64(d.readIndex())}) return nil } s, ok := unquoteBytes(item) @@ -893,7 +875,7 @@ func (d *decodeState) literalStore(item []byte, v reflect.Value, fromQuoted bool if fromQuoted { return fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type()) } - return errPhase + panic(phasePanicMsg) } return ut.UnmarshalText(s) } @@ -944,7 +926,7 @@ func (d *decodeState) literalStore(item []byte, v reflect.Value, fromQuoted bool if fromQuoted { return fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type()) } - return errPhase + panic(phasePanicMsg) } switch v.Kind() { default: @@ -976,7 +958,7 @@ func (d *decodeState) literalStore(item []byte, v reflect.Value, fromQuoted bool if fromQuoted { return fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type()) } - return errPhase + panic(phasePanicMsg) } s := string(item) switch v.Kind() { @@ -1037,24 +1019,24 @@ func (d *decodeState) literalStore(item []byte, v reflect.Value, fromQuoted bool // but they avoid the weight of reflection in this common case. // valueInterface is like value but returns interface{} -func (d *decodeState) valueInterface() (val interface{}, err error) { +func (d *decodeState) valueInterface() (val interface{}) { switch d.opcode { default: - err = errPhase + panic(phasePanicMsg) case scanBeginArray: - val, err = d.arrayInterface() + val = d.arrayInterface() d.scanNext() case scanBeginObject: - val, err = d.objectInterface() + val = d.objectInterface() d.scanNext() case scanBeginLiteral: - val, err = d.literalInterface() + val = d.literalInterface() } return } // arrayInterface is like array but returns []interface{}. -func (d *decodeState) arrayInterface() ([]interface{}, error) { +func (d *decodeState) arrayInterface() []interface{} { var v = make([]interface{}, 0) for { // Look ahead for ] - can only happen on first iteration. @@ -1063,11 +1045,7 @@ func (d *decodeState) arrayInterface() ([]interface{}, error) { break } - vi, err := d.valueInterface() - if err != nil { - return nil, err - } - v = append(v, vi) + v = append(v, d.valueInterface()) // Next token must be , or ]. if d.opcode == scanSkipSpace { @@ -1077,14 +1055,14 @@ func (d *decodeState) arrayInterface() ([]interface{}, error) { break } if d.opcode != scanArrayValue { - return nil, errPhase + panic(phasePanicMsg) } } - return v, nil + return v } // objectInterface is like object but returns map[string]interface{}. -func (d *decodeState) objectInterface() (map[string]interface{}, error) { +func (d *decodeState) objectInterface() map[string]interface{} { m := make(map[string]interface{}) for { // Read opening " of string key or closing }. @@ -1094,7 +1072,7 @@ func (d *decodeState) objectInterface() (map[string]interface{}, error) { break } if d.opcode != scanBeginLiteral { - return nil, errPhase + panic(phasePanicMsg) } // Read string key. @@ -1103,7 +1081,7 @@ func (d *decodeState) objectInterface() (map[string]interface{}, error) { item := d.data[start:d.readIndex()] key, ok := unquote(item) if !ok { - return nil, errPhase + panic(phasePanicMsg) } // Read : before value. @@ -1111,16 +1089,12 @@ func (d *decodeState) objectInterface() (map[string]interface{}, error) { d.scanWhile(scanSkipSpace) } if d.opcode != scanObjectKey { - return nil, errPhase + panic(phasePanicMsg) } d.scanWhile(scanSkipSpace) // Read value. - vi, err := d.valueInterface() - if err != nil { - return nil, err - } - m[key] = vi + m[key] = d.valueInterface() // Next token must be , or }. if d.opcode == scanSkipSpace { @@ -1130,16 +1104,16 @@ func (d *decodeState) objectInterface() (map[string]interface{}, error) { break } if d.opcode != scanObjectValue { - return nil, errPhase + panic(phasePanicMsg) } } - return m, nil + return m } // literalInterface consumes and returns a literal from d.data[d.off-1:] and // it reads the following byte ahead. The first byte of the literal has been // read already (that's how the caller knows it's a literal). -func (d *decodeState) literalInterface() (interface{}, error) { +func (d *decodeState) literalInterface() interface{} { // All bytes inside literal return scanContinue op code. start := d.readIndex() d.scanWhile(scanContinue) @@ -1148,27 +1122,27 @@ func (d *decodeState) literalInterface() (interface{}, error) { switch c := item[0]; c { case 'n': // null - return nil, nil + return nil case 't', 'f': // true, false - return c == 't', nil + return c == 't' case '"': // string s, ok := unquote(item) if !ok { - return nil, errPhase + panic(phasePanicMsg) } - return s, nil + return s default: // number if c != '-' && (c < '0' || c > '9') { - return nil, errPhase + panic(phasePanicMsg) } n, err := d.convertNumber(string(item)) if err != nil { d.saveError(err) } - return n, nil + return n } } diff --git a/libgo/go/encoding/json/decode_test.go b/libgo/go/encoding/json/decode_test.go index 5746ddf9861..54432600a53 100644 --- a/libgo/go/encoding/json/decode_test.go +++ b/libgo/go/encoding/json/decode_test.go @@ -41,6 +41,16 @@ type VOuter struct { V V } +type W struct { + S SS +} + +type SS string + +func (*SS) UnmarshalJSON(data []byte) error { + return &UnmarshalTypeError{Value: "number", Type: reflect.TypeOf(SS(""))} +} + // ifaceNumAsFloat64/ifaceNumAsNumber are used to test unmarshaling with and // without UseNumber var ifaceNumAsFloat64 = map[string]interface{}{ @@ -142,7 +152,7 @@ var ( umstructXY = ustructText{unmarshalerText{"x", "y"}} ummapType = map[unmarshalerText]bool{} - ummapXY = map[unmarshalerText]bool{unmarshalerText{"x", "y"}: true} + ummapXY = map[unmarshalerText]bool{{"x", "y"}: true} ) // Test data structures for anonymous fields. @@ -256,6 +266,10 @@ type XYZ struct { Z interface{} } +type unexportedWithMethods struct{} + +func (unexportedWithMethods) F() {} + func sliceAddr(x []int) *[]int { return &x } func mapAddr(x map[string]int) *map[string]int { return &x } @@ -408,6 +422,7 @@ var unmarshalTests = []unmarshalTest{ {in: `{"X": 23}`, ptr: new(T), out: T{}, err: &UnmarshalTypeError{"number", reflect.TypeOf(""), 8, "T", "X"}}, {in: `{"x": 1}`, ptr: new(tx), out: tx{}}, {in: `{"x": 1}`, ptr: new(tx), out: tx{}}, {in: `{"x": 1}`, ptr: new(tx), err: fmt.Errorf("json: unknown field \"x\""), disallowUnknownFields: true}, + {in: `{"S": 23}`, ptr: new(W), out: W{}, err: &UnmarshalTypeError{"number", reflect.TypeOf(SS("")), 0, "W", "S"}}, {in: `{"F1":1,"F2":2,"F3":3}`, ptr: new(V), out: V{F1: float64(1), F2: int32(2), F3: Number("3")}}, {in: `{"F1":1,"F2":2,"F3":3}`, ptr: new(V), out: V{F1: Number("1"), F2: int32(2), F3: Number("3")}, useNumber: true}, {in: `{"k1":1,"k2":"s","k3":[1,2.0,3e-3],"k4":{"kk1":"s","kk2":2}}`, ptr: new(interface{}), out: ifaceNumAsFloat64}, @@ -434,6 +449,7 @@ var unmarshalTests = []unmarshalTest{ {in: `{"X": "foo", "Y"}`, err: &SyntaxError{"invalid character '}' after object key", 17}}, {in: `[1, 2, 3+]`, err: &SyntaxError{"invalid character '+' after array element", 9}}, {in: `{"X":12x}`, err: &SyntaxError{"invalid character 'x' after object key:value pair", 8}, useNumber: true}, + {in: `[2, 3`, err: &SyntaxError{msg: "unexpected end of JSON input", Offset: 5}}, // raw value errors {in: "\x01 42", err: &SyntaxError{"invalid character '\\x01' looking for beginning of value", 1}}, @@ -449,6 +465,7 @@ var unmarshalTests = []unmarshalTest{ {in: `[1, 2, 3]`, ptr: new([3]int), out: [3]int{1, 2, 3}}, {in: `[1, 2, 3]`, ptr: new([1]int), out: [1]int{1}}, {in: `[1, 2, 3]`, ptr: new([5]int), out: [5]int{1, 2, 3, 0, 0}}, + {in: `[1, 2, 3]`, ptr: new(MustNotUnmarshalJSON), err: errors.New("MustNotUnmarshalJSON was used")}, // empty array to interface test {in: `[]`, ptr: new([]interface{}), out: []interface{}{}}, @@ -541,6 +558,16 @@ var unmarshalTests = []unmarshalTest{ ptr: new(map[uint8]string), err: &UnmarshalTypeError{Value: "number -1", Type: reflect.TypeOf(uint8(0)), Offset: 2}, }, + { + in: `{"F":{"a":2,"3":4}}`, + ptr: new(map[string]map[int]int), + err: &UnmarshalTypeError{Value: "number a", Type: reflect.TypeOf(int(0)), Offset: 7}, + }, + { + in: `{"F":{"a":2,"3":4}}`, + ptr: new(map[string]map[uint]int), + err: &UnmarshalTypeError{Value: "number a", Type: reflect.TypeOf(uint(0)), Offset: 7}, + }, // Map keys can be encoding.TextUnmarshalers. {in: `{"x:y":true}`, ptr: &ummapType, out: ummapXY}, @@ -815,6 +842,7 @@ var unmarshalTests = []unmarshalTest{ {in: `{"B": "False"}`, ptr: new(B), err: errors.New(`json: invalid use of ,string struct tag, trying to unmarshal "False" into bool`)}, {in: `{"B": "null"}`, ptr: new(B), out: B{false}}, {in: `{"B": "nul"}`, ptr: new(B), err: errors.New(`json: invalid use of ,string struct tag, trying to unmarshal "nul" into bool`)}, + {in: `{"B": [2, 3]}`, ptr: new(B), err: errors.New(`json: invalid use of ,string struct tag, trying to unmarshal unquoted value into bool`)}, // additional tests for disallowUnknownFields { @@ -883,6 +911,18 @@ var unmarshalTests = []unmarshalTest{ ptr: new(mapStringToStringData), err: &UnmarshalTypeError{Value: "number", Type: reflect.TypeOf(""), Offset: 21, Struct: "mapStringToStringData", Field: "data"}, }, + + // trying to decode JSON arrays or objects via TextUnmarshaler + { + in: `[1, 2, 3]`, + ptr: new(MustNotUnmarshalText), + err: &UnmarshalTypeError{Value: "array", Type: reflect.TypeOf(&MustNotUnmarshalText{}), Offset: 1}, + }, + { + in: `{"foo": "bar"}`, + ptr: new(MustNotUnmarshalText), + err: &UnmarshalTypeError{Value: "object", Type: reflect.TypeOf(&MustNotUnmarshalText{}), Offset: 1}, + }, } func TestMarshal(t *testing.T) { @@ -1944,10 +1984,12 @@ type unexportedFields struct { Name string m map[string]interface{} `json:"-"` m2 map[string]interface{} `json:"abcd"` + + s []int `json:"-"` } func TestUnmarshalUnexported(t *testing.T) { - input := `{"Name": "Bob", "m": {"x": 123}, "m2": {"y": 456}, "abcd": {"z": 789}}` + input := `{"Name": "Bob", "m": {"x": 123}, "m2": {"y": 456}, "abcd": {"z": 789}, "s": [2, 3]}` want := &unexportedFields{Name: "Bob"} out := &unexportedFields{} @@ -2113,6 +2155,9 @@ func TestInvalidStringOption(t *testing.T) { // // (Issue 24152) If the embedded struct is given an explicit name, // ensure that the normal unmarshal logic does not panic in reflect. +// +// (Issue 28145) If the embedded struct is given an explicit name and has +// exported methods, don't cause a panic trying to get its value. func TestUnmarshalEmbeddedUnexported(t *testing.T) { type ( embed1 struct{ Q int } @@ -2152,6 +2197,9 @@ func TestUnmarshalEmbeddedUnexported(t *testing.T) { embed2 `json:"embed2"` Q int } + S9 struct { + unexportedWithMethods `json:"embed"` + } ) tests := []struct { @@ -2213,6 +2261,11 @@ func TestUnmarshalEmbeddedUnexported(t *testing.T) { in: `{"embed1": {"Q": 1}, "embed2": {"Q": 2}, "Q": 3}`, ptr: new(S8), out: &S8{embed1{1}, embed2{2}, 3}, + }, { + // Issue 228145, similar to the cases above. + in: `{"embed": {}}`, + ptr: new(S9), + out: &S9{}, }} for i, tt := range tests { diff --git a/libgo/go/encoding/json/encode.go b/libgo/go/encoding/json/encode.go index 28ca5fe9e00..f10124e67d1 100644 --- a/libgo/go/encoding/json/encode.go +++ b/libgo/go/encoding/json/encode.go @@ -381,8 +381,8 @@ func typeEncoder(t reflect.Type) encoderFunc { } var ( - marshalerType = reflect.TypeOf(new(Marshaler)).Elem() - textMarshalerType = reflect.TypeOf(new(encoding.TextMarshaler)).Elem() + marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem() + textMarshalerType = reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem() ) // newTypeEncoder constructs an encoderFunc for a type. @@ -624,40 +624,49 @@ func unsupportedTypeEncoder(e *encodeState, v reflect.Value, _ encOpts) { } type structEncoder struct { - fields []field - fieldEncs []encoderFunc + fields []field } -func (se *structEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) { - e.WriteByte('{') - first := true - for i, f := range se.fields { - fv := fieldByIndex(v, f.index) - if !fv.IsValid() || f.omitEmpty && isEmptyValue(fv) { +func (se structEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) { + next := byte('{') +FieldLoop: + for i := range se.fields { + f := &se.fields[i] + + // Find the nested struct field by following f.index. + fv := v + for _, i := range f.index { + if fv.Kind() == reflect.Ptr { + if fv.IsNil() { + continue FieldLoop + } + fv = fv.Elem() + } + fv = fv.Field(i) + } + + if f.omitEmpty && isEmptyValue(fv) { continue } - if first { - first = false + e.WriteByte(next) + next = ',' + if opts.escapeHTML { + e.WriteString(f.nameEscHTML) } else { - e.WriteByte(',') + e.WriteString(f.nameNonEsc) } - e.string(f.name, opts.escapeHTML) - e.WriteByte(':') opts.quoted = f.quoted - se.fieldEncs[i](e, fv, opts) + f.encoder(e, fv, opts) + } + if next == '{' { + e.WriteString("{}") + } else { + e.WriteByte('}') } - e.WriteByte('}') } func newStructEncoder(t reflect.Type) encoderFunc { - fields := cachedTypeFields(t) - se := &structEncoder{ - fields: fields, - fieldEncs: make([]encoderFunc, len(fields)), - } - for i, f := range fields { - se.fieldEncs[i] = typeEncoder(typeByIndex(t, f.index)) - } + se := structEncoder{fields: cachedTypeFields(t)} return se.encode } @@ -665,7 +674,7 @@ type mapEncoder struct { elemEnc encoderFunc } -func (me *mapEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) { +func (me mapEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) { if v.IsNil() { e.WriteString("null") return @@ -704,7 +713,7 @@ func newMapEncoder(t reflect.Type) encoderFunc { return unsupportedTypeEncoder } } - me := &mapEncoder{typeEncoder(t.Elem())} + me := mapEncoder{typeEncoder(t.Elem())} return me.encode } @@ -715,14 +724,22 @@ func encodeByteSlice(e *encodeState, v reflect.Value, _ encOpts) { } s := v.Bytes() e.WriteByte('"') - if len(s) < 1024 { - // for small buffers, using Encode directly is much faster. - dst := make([]byte, base64.StdEncoding.EncodedLen(len(s))) + encodedLen := base64.StdEncoding.EncodedLen(len(s)) + if encodedLen <= len(e.scratch) { + // If the encoded bytes fit in e.scratch, avoid an extra + // allocation and use the cheaper Encoding.Encode. + dst := e.scratch[:encodedLen] + base64.StdEncoding.Encode(dst, s) + e.Write(dst) + } else if encodedLen <= 1024 { + // The encoded bytes are short enough to allocate for, and + // Encoding.Encode is still cheaper. + dst := make([]byte, encodedLen) base64.StdEncoding.Encode(dst, s) e.Write(dst) } else { - // for large buffers, avoid unnecessary extra temporary - // buffer space. + // The encoded bytes are too long to cheaply allocate, and + // Encoding.Encode is no longer noticeably cheaper. enc := base64.NewEncoder(base64.StdEncoding, e) enc.Write(s) enc.Close() @@ -735,7 +752,7 @@ type sliceEncoder struct { arrayEnc encoderFunc } -func (se *sliceEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) { +func (se sliceEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) { if v.IsNil() { e.WriteString("null") return @@ -751,7 +768,7 @@ func newSliceEncoder(t reflect.Type) encoderFunc { return encodeByteSlice } } - enc := &sliceEncoder{newArrayEncoder(t)} + enc := sliceEncoder{newArrayEncoder(t)} return enc.encode } @@ -759,7 +776,7 @@ type arrayEncoder struct { elemEnc encoderFunc } -func (ae *arrayEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) { +func (ae arrayEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) { e.WriteByte('[') n := v.Len() for i := 0; i < n; i++ { @@ -772,7 +789,7 @@ func (ae *arrayEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) { } func newArrayEncoder(t reflect.Type) encoderFunc { - enc := &arrayEncoder{typeEncoder(t.Elem())} + enc := arrayEncoder{typeEncoder(t.Elem())} return enc.encode } @@ -780,7 +797,7 @@ type ptrEncoder struct { elemEnc encoderFunc } -func (pe *ptrEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) { +func (pe ptrEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) { if v.IsNil() { e.WriteString("null") return @@ -789,7 +806,7 @@ func (pe *ptrEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) { } func newPtrEncoder(t reflect.Type) encoderFunc { - enc := &ptrEncoder{typeEncoder(t.Elem())} + enc := ptrEncoder{typeEncoder(t.Elem())} return enc.encode } @@ -797,7 +814,7 @@ type condAddrEncoder struct { canAddrEnc, elseEnc encoderFunc } -func (ce *condAddrEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) { +func (ce condAddrEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) { if v.CanAddr() { ce.canAddrEnc(e, v, opts) } else { @@ -808,7 +825,7 @@ func (ce *condAddrEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) // newCondAddrEncoder returns an encoder that checks whether its value // CanAddr and delegates to canAddrEnc if so, else to elseEnc. func newCondAddrEncoder(canAddrEnc, elseEnc encoderFunc) encoderFunc { - enc := &condAddrEncoder{canAddrEnc: canAddrEnc, elseEnc: elseEnc} + enc := condAddrEncoder{canAddrEnc: canAddrEnc, elseEnc: elseEnc} return enc.encode } @@ -822,28 +839,13 @@ func isValidTag(s string) bool { // Backslash and quote chars are reserved, but // otherwise any punctuation chars are allowed // in a tag name. - default: - if !unicode.IsLetter(c) && !unicode.IsDigit(c) { - return false - } + case !unicode.IsLetter(c) && !unicode.IsDigit(c): + return false } } return true } -func fieldByIndex(v reflect.Value, index []int) reflect.Value { - for _, i := range index { - if v.Kind() == reflect.Ptr { - if v.IsNil() { - return reflect.Value{} - } - v = v.Elem() - } - v = v.Field(i) - } - return v -} - func typeByIndex(t reflect.Type, index []int) reflect.Type { for _, i := range index { if t.Kind() == reflect.Ptr { @@ -893,18 +895,15 @@ func (e *encodeState) string(s string, escapeHTML bool) { if start < i { e.WriteString(s[start:i]) } + e.WriteByte('\\') switch b { case '\\', '"': - e.WriteByte('\\') e.WriteByte(b) case '\n': - e.WriteByte('\\') e.WriteByte('n') case '\r': - e.WriteByte('\\') e.WriteByte('r') case '\t': - e.WriteByte('\\') e.WriteByte('t') default: // This encodes bytes < 0x20 except for \t, \n and \r. @@ -912,7 +911,7 @@ func (e *encodeState) string(s string, escapeHTML bool) { // because they can lead to security holes when // user-controlled strings are rendered into JSON // and served to some browsers. - e.WriteString(`\u00`) + e.WriteString(`u00`) e.WriteByte(hex[b>>4]) e.WriteByte(hex[b&0xF]) } @@ -968,18 +967,15 @@ func (e *encodeState) stringBytes(s []byte, escapeHTML bool) { if start < i { e.Write(s[start:i]) } + e.WriteByte('\\') switch b { case '\\', '"': - e.WriteByte('\\') e.WriteByte(b) case '\n': - e.WriteByte('\\') e.WriteByte('n') case '\r': - e.WriteByte('\\') e.WriteByte('r') case '\t': - e.WriteByte('\\') e.WriteByte('t') default: // This encodes bytes < 0x20 except for \t, \n and \r. @@ -987,7 +983,7 @@ func (e *encodeState) stringBytes(s []byte, escapeHTML bool) { // because they can lead to security holes when // user-controlled strings are rendered into JSON // and served to some browsers. - e.WriteString(`\u00`) + e.WriteString(`u00`) e.WriteByte(hex[b>>4]) e.WriteByte(hex[b&0xF]) } @@ -1036,17 +1032,16 @@ type field struct { nameBytes []byte // []byte(name) equalFold func(s, t []byte) bool // bytes.EqualFold or equivalent + nameNonEsc string // `"` + name + `":` + nameEscHTML string // `"` + HTMLEscape(name) + `":` + tag bool index []int typ reflect.Type omitEmpty bool quoted bool -} -func fillField(f field) field { - f.nameBytes = []byte(f.name) - f.equalFold = foldFunc(f.nameBytes) - return f + encoder encoderFunc } // byIndex sorts field by index sequence. @@ -1086,6 +1081,9 @@ func typeFields(t reflect.Type) []field { // Fields found. var fields []field + // Buffer to run HTMLEscape on field names. + var nameEscBuf bytes.Buffer + for len(next) > 0 { current, next = next, current[:0] count, nextCount = nextCount, map[reflect.Type]int{} @@ -1152,14 +1150,26 @@ func typeFields(t reflect.Type) []field { if name == "" { name = sf.Name } - fields = append(fields, fillField(field{ + field := field{ name: name, tag: tagged, index: index, typ: ft, omitEmpty: opts.Contains("omitempty"), quoted: quoted, - })) + } + field.nameBytes = []byte(field.name) + field.equalFold = foldFunc(field.nameBytes) + + // Build nameEscHTML and nameNonEsc ahead of time. + nameEscBuf.Reset() + nameEscBuf.WriteString(`"`) + HTMLEscape(&nameEscBuf, field.nameBytes) + nameEscBuf.WriteString(`":`) + field.nameEscHTML = nameEscBuf.String() + field.nameNonEsc = `"` + field.name + `":` + + fields = append(fields, field) if count[f.typ] > 1 { // If there were multiple instances, add a second, // so that the annihilation code will see a duplicate. @@ -1173,7 +1183,7 @@ func typeFields(t reflect.Type) []field { // Record new anonymous struct to explore in next round. nextCount[ft]++ if nextCount[ft] == 1 { - next = append(next, fillField(field{name: ft.Name(), index: index, typ: ft})) + next = append(next, field{name: ft.Name(), index: index, typ: ft}) } } } @@ -1227,6 +1237,10 @@ func typeFields(t reflect.Type) []field { fields = out sort.Sort(byIndex(fields)) + for i := range fields { + f := &fields[i] + f.encoder = typeEncoder(typeByIndex(t, f.index)) + } return fields } diff --git a/libgo/go/encoding/json/encode_test.go b/libgo/go/encoding/json/encode_test.go index b90483cf35f..cd5eadf3c1c 100644 --- a/libgo/go/encoding/json/encode_test.go +++ b/libgo/go/encoding/json/encode_test.go @@ -405,6 +405,19 @@ func TestAnonymousFields(t *testing.T) { return S{s1{1, 2, s2{3, 4}}, 6} }, want: `{"MyInt1":1,"MyInt2":3}`, + }, { + // If an anonymous struct pointer field is nil, we should ignore + // the embedded fields behind it. Not properly doing so may + // result in the wrong output or reflect panics. + label: "EmbeddedFieldBehindNilPointer", + makeInput: func() interface{} { + type ( + S2 struct{ Field string } + S struct{ *S2 } + ) + return S{} + }, + want: `{}`, }} for _, tt := range tests { @@ -995,3 +1008,18 @@ func TestMarshalPanic(t *testing.T) { Marshal(&marshalPanic{}) t.Error("Marshal should have panicked") } + +func TestMarshalUncommonFieldNames(t *testing.T) { + v := struct { + A0, À, Aβ int + }{} + b, err := Marshal(v) + if err != nil { + t.Fatal("Marshal:", err) + } + want := `{"A0":0,"À":0,"Aβ":0}` + got := string(b) + if got != want { + t.Fatalf("Marshal: got %s want %s", got, want) + } +} diff --git a/libgo/go/encoding/json/example_text_marshaling_test.go b/libgo/go/encoding/json/example_text_marshaling_test.go new file mode 100644 index 00000000000..a8a3f830f68 --- /dev/null +++ b/libgo/go/encoding/json/example_text_marshaling_test.go @@ -0,0 +1,69 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +package json_test + +import ( + "encoding/json" + "fmt" + "log" + "strings" +) + +type Size int + +const ( + Unrecognized Size = iota + Small + Large +) + +func (s *Size) UnmarshalText(text []byte) error { + switch strings.ToLower(string(text)) { + default: + *s = Unrecognized + case "small": + *s = Small + case "large": + *s = Large + } + return nil +} + +func (s Size) MarshalText() ([]byte, error) { + var name string + switch s { + default: + name = "unrecognized" + case Small: + name = "small" + case Large: + name = "large" + } + return []byte(name), nil +} + +func Example_textMarshalJSON() { + blob := `["small","regular","large","unrecognized","small","normal","small","large"]` + var inventory []Size + if err := json.Unmarshal([]byte(blob), &inventory); err != nil { + log.Fatal(err) + } + + counts := make(map[Size]int) + for _, size := range inventory { + counts[size] += 1 + } + + fmt.Printf("Inventory Counts:\n* Small: %d\n* Large: %d\n* Unrecognized: %d\n", + counts[Small], counts[Large], counts[Unrecognized]) + + // Output: + // Inventory Counts: + // * Small: 3 + // * Large: 2 + // * Unrecognized: 3 +} diff --git a/libgo/go/encoding/json/scanner.go b/libgo/go/encoding/json/scanner.go index 9e6d482e168..88572245fc7 100644 --- a/libgo/go/encoding/json/scanner.go +++ b/libgo/go/encoding/json/scanner.go @@ -289,7 +289,7 @@ func stateEndValue(s *scanner, c byte) int { // such as after reading `{}` or `[1,2,3]`. // Only space characters should be seen now. func stateEndTop(s *scanner, c byte) int { - if c != ' ' && c != '\t' && c != '\r' && c != '\n' { + if !isSpace(c) { // Complain about non-space byte on next call. s.error(c, "after top-level value") } diff --git a/libgo/go/encoding/json/stream.go b/libgo/go/encoding/json/stream.go index 75a4270df7d..7d5137fbc71 100644 --- a/libgo/go/encoding/json/stream.go +++ b/libgo/go/encoding/json/stream.go @@ -96,19 +96,19 @@ Input: // Look in the buffer for a new value. for i, c := range dec.buf[scanp:] { dec.scan.bytes++ - v := dec.scan.step(&dec.scan, c) - if v == scanEnd { + switch dec.scan.step(&dec.scan, c) { + case scanEnd: scanp += i break Input - } - // scanEnd is delayed one byte. - // We might block trying to get that byte from src, - // so instead invent a space byte. - if (v == scanEndObject || v == scanEndArray) && dec.scan.step(&dec.scan, ' ') == scanEnd { - scanp += i + 1 - break Input - } - if v == scanError { + case scanEndObject, scanEndArray: + // scanEnd is delayed one byte. + // We might block trying to get that byte from src, + // so instead invent a space byte. + if stateEndValue(&dec.scan, ' ') == scanEnd { + scanp += i + 1 + break Input + } + case scanError: dec.err = dec.scan.err return 0, dec.scan.err } @@ -471,7 +471,7 @@ func (dec *Decoder) tokenError(c byte) (Token, error) { case tokenObjectComma: context = " after object key:value pair" } - return nil, &SyntaxError{"invalid character " + quoteChar(c) + " " + context, dec.offset()} + return nil, &SyntaxError{"invalid character " + quoteChar(c) + context, dec.offset()} } // More reports whether there is another element in the diff --git a/libgo/go/encoding/json/stream_test.go b/libgo/go/encoding/json/stream_test.go index 83c01d170c0..aaf32e0a24c 100644 --- a/libgo/go/encoding/json/stream_test.go +++ b/libgo/go/encoding/json/stream_test.go @@ -93,6 +93,10 @@ func TestEncoderIndent(t *testing.T) { func TestEncoderSetEscapeHTML(t *testing.T) { var c C var ct CText + var tagStruct struct { + Valid int `json:"<>&#! "` + Invalid int `json:"\\"` + } for _, tt := range []struct { name string v interface{} @@ -102,6 +106,11 @@ func TestEncoderSetEscapeHTML(t *testing.T) { {"c", c, `"\u003c\u0026\u003e"`, `"<&>"`}, {"ct", ct, `"\"\u003c\u0026\u003e\""`, `"\"<&>\""`}, {`"<&>"`, "<&>", `"\u003c\u0026\u003e"`, `"<&>"`}, + { + "tagStruct", tagStruct, + `{"\u003c\u003e\u0026#! ":0,"Invalid":0}`, + `{"<>&#! ":0,"Invalid":0}`, + }, } { var buf bytes.Buffer enc := NewEncoder(&buf) @@ -192,10 +201,9 @@ func nlines(s string, n int) string { } func TestRawMessage(t *testing.T) { - // TODO(rsc): Should not need the * in *RawMessage var data struct { X float64 - Id *RawMessage + Id RawMessage Y float32 } const raw = `["\u0056",null]` @@ -204,8 +212,8 @@ func TestRawMessage(t *testing.T) { if err != nil { t.Fatalf("Unmarshal: %v", err) } - if string([]byte(*data.Id)) != raw { - t.Fatalf("Raw mismatch: have %#q want %#q", []byte(*data.Id), raw) + if string([]byte(data.Id)) != raw { + t.Fatalf("Raw mismatch: have %#q want %#q", []byte(data.Id), raw) } b, err := Marshal(&data) if err != nil { @@ -217,20 +225,22 @@ func TestRawMessage(t *testing.T) { } func TestNullRawMessage(t *testing.T) { - // TODO(rsc): Should not need the * in *RawMessage var data struct { - X float64 - Id *RawMessage - Y float32 + X float64 + Id RawMessage + IdPtr *RawMessage + Y float32 } - data.Id = new(RawMessage) - const msg = `{"X":0.1,"Id":null,"Y":0.2}` + const msg = `{"X":0.1,"Id":null,"IdPtr":null,"Y":0.2}` err := Unmarshal([]byte(msg), &data) if err != nil { t.Fatalf("Unmarshal: %v", err) } - if data.Id != nil { - t.Fatalf("Raw mismatch: have non-nil, want nil") + if want, got := "null", string(data.Id); want != got { + t.Fatalf("Raw mismatch: have %q, want %q", got, want) + } + if data.IdPtr != nil { + t.Fatalf("Raw pointer mismatch: have non-nil, want nil") } b, err := Marshal(&data) if err != nil { diff --git a/libgo/go/encoding/pem/pem_test.go b/libgo/go/encoding/pem/pem_test.go index 6a175162183..204611bda02 100644 --- a/libgo/go/encoding/pem/pem_test.go +++ b/libgo/go/encoding/pem/pem_test.go @@ -26,6 +26,10 @@ var getLineTests = []GetLineTest{ {"abc\r\nd", "abc", "d"}, {"\nabc", "", "abc"}, {"\r\nabc", "", "abc"}, + {"abc\t \nd", "abc", "d"}, + {"\t abc\nd", "\t abc", "d"}, + {"abc\n\t d", "abc", "\t d"}, + {"abc\nd\t ", "abc", "d\t "}, } func TestGetLine(t *testing.T) { @@ -213,7 +217,9 @@ func TestFuzz(t *testing.T) { } testRoundtrip := func(block Block) bool { - if isBad(block.Type) { + // Reject bad Type + // Type with colons will proceed as key/val pair and cause an error. + if isBad(block.Type) || strings.Contains(block.Type, ":") { return true } for key, val := range block.Headers { diff --git a/libgo/go/encoding/xml/example_marshaling_test.go b/libgo/go/encoding/xml/example_marshaling_test.go new file mode 100644 index 00000000000..04d3470cac0 --- /dev/null +++ b/libgo/go/encoding/xml/example_marshaling_test.go @@ -0,0 +1,86 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +package xml_test + +import ( + "encoding/xml" + "fmt" + "log" + "strings" +) + +type Animal int + +const ( + Unknown Animal = iota + Gopher + Zebra +) + +func (a *Animal) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + var s string + if err := d.DecodeElement(&s, &start); err != nil { + return err + } + switch strings.ToLower(s) { + default: + *a = Unknown + case "gopher": + *a = Gopher + case "zebra": + *a = Zebra + } + + return nil +} + +func (a Animal) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + var s string + switch a { + default: + s = "unknown" + case Gopher: + s = "gopher" + case Zebra: + s = "zebra" + } + return e.EncodeElement(s, start) +} + +func Example_customMarshalXML() { + blob := ` + + gopher + armadillo + zebra + unknown + gopher + bee + gopher + zebra + ` + var zoo struct { + Animals []Animal `xml:"animal"` + } + if err := xml.Unmarshal([]byte(blob), &zoo); err != nil { + log.Fatal(err) + } + + census := make(map[Animal]int) + for _, animal := range zoo.Animals { + census[animal] += 1 + } + + fmt.Printf("Zoo Census:\n* Gophers: %d\n* Zebras: %d\n* Unknown: %d\n", + census[Gopher], census[Zebra], census[Unknown]) + + // Output: + // Zoo Census: + // * Gophers: 3 + // * Zebras: 2 + // * Unknown: 3 +} diff --git a/libgo/go/encoding/xml/example_text_marshaling_test.go b/libgo/go/encoding/xml/example_text_marshaling_test.go new file mode 100644 index 00000000000..8d1f3325783 --- /dev/null +++ b/libgo/go/encoding/xml/example_text_marshaling_test.go @@ -0,0 +1,81 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +package xml_test + +import ( + "encoding/xml" + "fmt" + "log" + "strings" +) + +type Size int + +const ( + Unrecognized Size = iota + Small + Large +) + +func (s *Size) UnmarshalText(text []byte) error { + switch strings.ToLower(string(text)) { + default: + *s = Unrecognized + case "small": + *s = Small + case "large": + *s = Large + } + return nil +} + +func (s Size) MarshalText() ([]byte, error) { + var name string + switch s { + default: + name = "unrecognized" + case Small: + name = "small" + case Large: + name = "large" + } + return []byte(name), nil +} + +func Example_textMarshalXML() { + blob := ` + + small + regular + large + unrecognized + small + normal + small + large + ` + var inventory struct { + Sizes []Size `xml:"size"` + } + if err := xml.Unmarshal([]byte(blob), &inventory); err != nil { + log.Fatal(err) + } + + counts := make(map[Size]int) + for _, size := range inventory.Sizes { + counts[size] += 1 + } + + fmt.Printf("Inventory Counts:\n* Small: %d\n* Large: %d\n* Unrecognized: %d\n", + counts[Small], counts[Large], counts[Unrecognized]) + + // Output: + // Inventory Counts: + // * Small: 3 + // * Large: 2 + // * Unrecognized: 3 +} diff --git a/libgo/go/encoding/xml/marshal.go b/libgo/go/encoding/xml/marshal.go index d393d0610bf..add5ece7821 100644 --- a/libgo/go/encoding/xml/marshal.go +++ b/libgo/go/encoding/xml/marshal.go @@ -61,6 +61,10 @@ const ( // string of length zero. // - an anonymous struct field is handled as if the fields of its // value were part of the outer struct. +// - a field implementing Marshaler is written by calling its MarshalXML +// method. +// - a field implementing encoding.TextMarshaler is written by encoding the +// result of its MarshalText method as text. // // If a field uses a tag "a>b>c", then the element c will be nested inside // parent elements a and b. Fields that appear next to each other that name diff --git a/libgo/go/encoding/xml/read.go b/libgo/go/encoding/xml/read.go index 36c7ba63111..12102bc804e 100644 --- a/libgo/go/encoding/xml/read.go +++ b/libgo/go/encoding/xml/read.go @@ -92,6 +92,11 @@ import ( // // * A struct field with tag "-" is never unmarshaled into. // +// If Unmarshal encounters a field type that implements the Unmarshaler +// interface, Unmarshal calls its UnmarshalXML method to produce the value from +// the XML element. Otherwise, if the value implements +// encoding.TextUnmarshaler, Unmarshal calls that value's UnmarshalText method. +// // Unmarshal maps an XML element to a string or []byte by saving the // concatenation of that element's character data in the string or // []byte. The saved []byte is never nil. diff --git a/libgo/go/expvar/expvar.go b/libgo/go/expvar/expvar.go index 174873a7d47..976b300d637 100644 --- a/libgo/go/expvar/expvar.go +++ b/libgo/go/expvar/expvar.go @@ -137,7 +137,7 @@ func (v *Map) Init() *Map { return v } -// updateKeys updates the sorted list of keys in v.keys. +// addKey updates the sorted list of keys in v.keys. func (v *Map) addKey(key string) { v.keysMu.Lock() defer v.keysMu.Unlock() @@ -199,6 +199,17 @@ func (v *Map) AddFloat(key string, delta float64) { } } +// Deletes the given key from the map. +func (v *Map) Delete(key string) { + v.keysMu.Lock() + defer v.keysMu.Unlock() + i := sort.SearchStrings(v.keys, key) + if i < len(v.keys) && key == v.keys[i] { + v.keys = append(v.keys[:i], v.keys[i+1:]...) + v.m.Delete(key) + } +} + // Do calls f for each entry in the map. // The map is locked during the iteration, // but existing entries may be concurrently updated. @@ -221,7 +232,7 @@ func (v *String) Value() string { return p } -// String implements the Val interface. To get the unquoted string +// String implements the Var interface. To get the unquoted string // use Value. func (v *String) String() string { s := v.Value() diff --git a/libgo/go/expvar/expvar_test.go b/libgo/go/expvar/expvar_test.go index 728e763896c..804b56c1aaa 100644 --- a/libgo/go/expvar/expvar_test.go +++ b/libgo/go/expvar/expvar_test.go @@ -183,6 +183,43 @@ func TestMapInit(t *testing.T) { } } +func TestMapDelete(t *testing.T) { + RemoveAll() + colors := NewMap("bike-shed-colors") + + colors.Add("red", 1) + colors.Add("red", 2) + colors.Add("blue", 4) + + n := 0 + colors.Do(func(KeyValue) { n++ }) + if n != 2 { + t.Errorf("after two Add calls with distinct keys, Do should invoke f 2 times; got %v", n) + } + + colors.Delete("red") + n = 0 + colors.Do(func(KeyValue) { n++ }) + if n != 1 { + t.Errorf("removed red, Do should invoke f 1 times; got %v", n) + } + + colors.Delete("notfound") + n = 0 + colors.Do(func(KeyValue) { n++ }) + if n != 1 { + t.Errorf("attempted to remove notfound, Do should invoke f 1 times; got %v", n) + } + + colors.Delete("blue") + colors.Delete("blue") + n = 0 + colors.Do(func(KeyValue) { n++ }) + if n != 0 { + t.Errorf("all keys removed, Do should invoke f 0 times; got %v", n) + } +} + func TestMapCounter(t *testing.T) { RemoveAll() colors := NewMap("bike-shed-colors") diff --git a/libgo/go/flag/flag.go b/libgo/go/flag/flag.go index 2cd7829c1a6..2eef9d6ab9a 100644 --- a/libgo/go/flag/flag.go +++ b/libgo/go/flag/flag.go @@ -83,6 +83,28 @@ import ( // but no such flag is defined. var ErrHelp = errors.New("flag: help requested") +// errParse is returned by Set if a flag's value fails to parse, such as with an invalid integer for Int. +// It then gets wrapped through failf to provide more information. +var errParse = errors.New("parse error") + +// errRange is returned by Set if a flag's value is out of range. +// It then gets wrapped through failf to provide more information. +var errRange = errors.New("value out of range") + +func numError(err error) error { + ne, ok := err.(*strconv.NumError) + if !ok { + return err + } + if ne.Err == strconv.ErrSyntax { + return errParse + } + if ne.Err == strconv.ErrRange { + return errRange + } + return err +} + // -- bool Value type boolValue bool @@ -93,6 +115,9 @@ func newBoolValue(val bool, p *bool) *boolValue { func (b *boolValue) Set(s string) error { v, err := strconv.ParseBool(s) + if err != nil { + err = errParse + } *b = boolValue(v) return err } @@ -120,6 +145,9 @@ func newIntValue(val int, p *int) *intValue { func (i *intValue) Set(s string) error { v, err := strconv.ParseInt(s, 0, strconv.IntSize) + if err != nil { + err = numError(err) + } *i = intValue(v) return err } @@ -138,6 +166,9 @@ func newInt64Value(val int64, p *int64) *int64Value { func (i *int64Value) Set(s string) error { v, err := strconv.ParseInt(s, 0, 64) + if err != nil { + err = numError(err) + } *i = int64Value(v) return err } @@ -156,6 +187,9 @@ func newUintValue(val uint, p *uint) *uintValue { func (i *uintValue) Set(s string) error { v, err := strconv.ParseUint(s, 0, strconv.IntSize) + if err != nil { + err = numError(err) + } *i = uintValue(v) return err } @@ -174,6 +208,9 @@ func newUint64Value(val uint64, p *uint64) *uint64Value { func (i *uint64Value) Set(s string) error { v, err := strconv.ParseUint(s, 0, 64) + if err != nil { + err = numError(err) + } *i = uint64Value(v) return err } @@ -209,6 +246,9 @@ func newFloat64Value(val float64, p *float64) *float64Value { func (f *float64Value) Set(s string) error { v, err := strconv.ParseFloat(s, 64) + if err != nil { + err = numError(err) + } *f = float64Value(v) return err } @@ -227,6 +267,9 @@ func newDurationValue(val time.Duration, p *time.Duration) *durationValue { func (d *durationValue) Set(s string) error { v, err := time.ParseDuration(s) + if err != nil { + err = errParse + } *d = durationValue(v) return err } @@ -472,7 +515,7 @@ func (f *FlagSet) PrintDefaults() { // for both 4- and 8-space tab stops. s += "\n \t" } - s += strings.Replace(usage, "\n", "\n \t", -1) + s += strings.ReplaceAll(usage, "\n", "\n \t") if !isZeroValue(flag, flag.DefValue) { if _, ok := flag.Value.(*stringValue); ok { diff --git a/libgo/go/flag/flag_test.go b/libgo/go/flag/flag_test.go index c7f0c07d448..0d9491c0208 100644 --- a/libgo/go/flag/flag_test.go +++ b/libgo/go/flag/flag_test.go @@ -9,6 +9,7 @@ import ( . "flag" "fmt" "io" + "io/ioutil" "os" "sort" "strconv" @@ -491,3 +492,55 @@ func TestGetters(t *testing.T) { t.Errorf("unexpected output: got %v, expected %v", fs.Output(), expectedOutput) } } + +func TestParseError(t *testing.T) { + for _, typ := range []string{"bool", "int", "int64", "uint", "uint64", "float64", "duration"} { + fs := NewFlagSet("parse error test", ContinueOnError) + fs.SetOutput(ioutil.Discard) + _ = fs.Bool("bool", false, "") + _ = fs.Int("int", 0, "") + _ = fs.Int64("int64", 0, "") + _ = fs.Uint("uint", 0, "") + _ = fs.Uint64("uint64", 0, "") + _ = fs.Float64("float64", 0, "") + _ = fs.Duration("duration", 0, "") + // Strings cannot give errors. + args := []string{"-" + typ + "=x"} + err := fs.Parse(args) // x is not a valid setting for any flag. + if err == nil { + t.Errorf("Parse(%q)=%v; expected parse error", args, err) + continue + } + if !strings.Contains(err.Error(), "invalid") || !strings.Contains(err.Error(), "parse error") { + t.Errorf("Parse(%q)=%v; expected parse error", args, err) + } + } +} + +func TestRangeError(t *testing.T) { + bad := []string{ + "-int=123456789012345678901", + "-int64=123456789012345678901", + "-uint=123456789012345678901", + "-uint64=123456789012345678901", + "-float64=1e1000", + } + for _, arg := range bad { + fs := NewFlagSet("parse error test", ContinueOnError) + fs.SetOutput(ioutil.Discard) + _ = fs.Int("int", 0, "") + _ = fs.Int64("int64", 0, "") + _ = fs.Uint("uint", 0, "") + _ = fs.Uint64("uint64", 0, "") + _ = fs.Float64("float64", 0, "") + // Strings cannot give errors, and bools and durations do not return strconv.NumError. + err := fs.Parse([]string{arg}) + if err == nil { + t.Errorf("Parse(%q)=%v; expected range error", arg, err) + continue + } + if !strings.Contains(err.Error(), "invalid") || !strings.Contains(err.Error(), "value out of range") { + t.Errorf("Parse(%q)=%v; expected range error", arg, err) + } + } +} diff --git a/libgo/go/fmt/example_test.go b/libgo/go/fmt/example_test.go index aa3cd05e3ef..64821e0dacc 100644 --- a/libgo/go/fmt/example_test.go +++ b/libgo/go/fmt/example_test.go @@ -8,24 +8,360 @@ package fmt_test import ( "fmt" + "io" + "math" + "os" + "strings" + "time" ) -// Animal has a Name and an Age to represent an animal. -type Animal struct { - Name string - Age uint +// The Errorf function lets us use formatting features +// to create descriptive error messages. +func ExampleErrorf() { + const name, id = "bueller", 17 + err := fmt.Errorf("user %q (id %d) not found", name, id) + fmt.Println(err.Error()) + + // Output: user "bueller" (id 17) not found +} + +func ExampleFscanf() { + var ( + i int + b bool + s string + ) + r := strings.NewReader("5 true gophers") + n, err := fmt.Fscanf(r, "%d %t %s", &i, &b, &s) + if err != nil { + fmt.Fprintf(os.Stderr, "Fscanf: %v\n", err) + } + fmt.Println(i, b, s) + fmt.Println(n) + // Output: + // 5 true gophers + // 3 +} + +func ExampleFscanln() { + s := `dmr 1771 1.61803398875 + ken 271828 3.14159` + r := strings.NewReader(s) + var a string + var b int + var c float64 + for { + n, err := fmt.Fscanln(r, &a, &b, &c) + if err == io.EOF { + break + } + if err != nil { + panic(err) + } + fmt.Printf("%d: %s, %d, %f\n", n, a, b, c) + } + // Output: + // 3: dmr, 1771, 1.618034 + // 3: ken, 271828, 3.141590 +} + +func ExampleSscanf() { + var name string + var age int + n, err := fmt.Sscanf("Kim is 22 years old", "%s is %d years old", &name, &age) + if err != nil { + panic(err) + } + fmt.Printf("%d: %s, %d\n", n, name, age) + + // Output: + // 2: Kim, 22 +} + +func ExamplePrint() { + const name, age = "Kim", 22 + fmt.Print(name, " is ", age, " years old.\n") + + // It is conventional not to worry about any + // error returned by Print. + + // Output: + // Kim is 22 years old. +} + +func ExamplePrintln() { + const name, age = "Kim", 22 + fmt.Println(name, "is", age, "years old.") + + // It is conventional not to worry about any + // error returned by Println. + + // Output: + // Kim is 22 years old. +} + +func ExamplePrintf() { + const name, age = "Kim", 22 + fmt.Printf("%s is %d years old.\n", name, age) + + // It is conventional not to worry about any + // error returned by Printf. + + // Output: + // Kim is 22 years old. +} + +func ExampleSprint() { + const name, age = "Kim", 22 + s := fmt.Sprint(name, " is ", age, " years old.\n") + + io.WriteString(os.Stdout, s) // Ignoring error for simplicity. + + // Output: + // Kim is 22 years old. +} + +func ExampleSprintln() { + const name, age = "Kim", 22 + s := fmt.Sprintln(name, "is", age, "years old.") + + io.WriteString(os.Stdout, s) // Ignoring error for simplicity. + + // Output: + // Kim is 22 years old. +} + +func ExampleSprintf() { + const name, age = "Kim", 22 + s := fmt.Sprintf("%s is %d years old.\n", name, age) + + io.WriteString(os.Stdout, s) // Ignoring error for simplicity. + + // Output: + // Kim is 22 years old. } -// String makes Animal satisfy the Stringer interface. -func (a Animal) String() string { - return fmt.Sprintf("%v (%d)", a.Name, a.Age) +func ExampleFprint() { + const name, age = "Kim", 22 + n, err := fmt.Fprint(os.Stdout, name, " is ", age, " years old.\n") + + // The n and err return values from Fprint are + // those returned by the underlying io.Writer. + if err != nil { + fmt.Fprintf(os.Stderr, "Fprint: %v\n", err) + } + fmt.Print(n, " bytes written.\n") + + // Output: + // Kim is 22 years old. + // 21 bytes written. } -func ExampleStringer() { - a := Animal{ - Name: "Gopher", - Age: 2, +func ExampleFprintln() { + const name, age = "Kim", 22 + n, err := fmt.Fprintln(os.Stdout, name, "is", age, "years old.") + + // The n and err return values from Fprintln are + // those returned by the underlying io.Writer. + if err != nil { + fmt.Fprintf(os.Stderr, "Fprintln: %v\n", err) + } + fmt.Println(n, "bytes written.") + + // Output: + // Kim is 22 years old. + // 21 bytes written. +} + +func ExampleFprintf() { + const name, age = "Kim", 22 + n, err := fmt.Fprintf(os.Stdout, "%s is %d years old.\n", name, age) + + // The n and err return values from Fprintf are + // those returned by the underlying io.Writer. + if err != nil { + fmt.Fprintf(os.Stderr, "Fprintf: %v\n", err) } - fmt.Println(a) - // Output: Gopher (2) + fmt.Printf("%d bytes written.\n", n) + + // Output: + // Kim is 22 years old. + // 21 bytes written. +} + +// Print, Println, and Printf lay out their arguments differently. In this example +// we can compare their behaviors. Println always adds blanks between the items it +// prints, while Print adds blanks only between non-string arguments and Printf +// does exactly what it is told. +// Sprint, Sprintln, Sprintf, Fprint, Fprintln, and Fprintf behave the same as +// their corresponding Print, Println, and Printf functions shown here. +func Example_printers() { + a, b := 3.0, 4.0 + h := math.Hypot(a, b) + + // Print inserts blanks between arguments when neither is a string. + // It does not add a newline to the output, so we add one explicitly. + fmt.Print("The vector (", a, b, ") has length ", h, ".\n") + + // Println always inserts spaces between its arguments, + // so it cannot be used to produce the same output as Print in this case; + // its output has extra spaces. + // Also, Println always adds a newline to the output. + fmt.Println("The vector (", a, b, ") has length", h, ".") + + // Printf provides complete control but is more complex to use. + // It does not add a newline to the output, so we add one explicitly + // at the end of the format specifier string. + fmt.Printf("The vector (%g %g) has length %g.\n", a, b, h) + + // Output: + // The vector (3 4) has length 5. + // The vector ( 3 4 ) has length 5 . + // The vector (3 4) has length 5. +} + +// These examples demonstrate the basics of printing using a format string. Printf, +// Sprintf, and Fprintf all take a format string that specifies how to format the +// subsequent arguments. For example, %d (we call that a 'verb') says to print the +// corresponding argument, which must be an integer (or something containing an +// integer, such as a slice of ints) in decimal. The verb %v ('v' for 'value') +// always formats the argument in its default form, just how Print or Println would +// show it. The special verb %T ('T' for 'Type') prints the type of the argument +// rather than its value. The examples are not exhaustive; see the package comment +// for all the details. +func Example_formats() { + // A basic set of examples showing that %v is the default format, in this + // case decimal for integers, which can be explicitly requested with %d; + // the output is just what Println generates. + integer := 23 + // Each of these prints "23" (without the quotes). + fmt.Println(integer) + fmt.Printf("%v\n", integer) + fmt.Printf("%d\n", integer) + + // The special verb %T shows the type of an item rather than its value. + fmt.Printf("%T %T\n", integer, &integer) + // Result: int *int + + // Println(x) is the same as Printf("%v\n", x) so we will use only Printf + // in the following examples. Each one demonstrates how to format values of + // a particular type, such as integers or strings. We start each format + // string with %v to show the default output and follow that with one or + // more custom formats. + + // Booleans print as "true" or "false" with %v or %t. + truth := true + fmt.Printf("%v %t\n", truth, truth) + // Result: true true + + // Integers print as decimals with %v and %d, + // or in hex with %x, octal with %o, or binary with %b. + answer := 42 + fmt.Printf("%v %d %x %o %b\n", answer, answer, answer, answer, answer) + // Result: 42 42 2a 52 101010 + + // Floats have multiple formats: %v and %g print a compact representation, + // while %f prints a decimal point and %e uses exponential notation. The + // format %6.2f used here shows how to set the width and precision to + // control the appearance of a floating-point value. In this instance, 6 is + // the total width of the printed text for the value (note the extra spaces + // in the output) and 2 is the number of decimal places to show. + pi := math.Pi + fmt.Printf("%v %g %.2f (%6.2f) %e\n", pi, pi, pi, pi, pi) + // Result: 3.141592653589793 3.141592653589793 3.14 ( 3.14) 3.141593e+00 + + // Complex numbers format as parenthesized pairs of floats, with an 'i' + // after the imaginary part. + point := 110.7 + 22.5i + fmt.Printf("%v %g %.2f %.2e\n", point, point, point, point) + // Result: (110.7+22.5i) (110.7+22.5i) (110.70+22.50i) (1.11e+02+2.25e+01i) + + // Runes are integers but when printed with %c show the character with that + // Unicode value. The %q verb shows them as quoted characters, %U as a + // hex Unicode code point, and %#U as both a code point and a quoted + // printable form if the rune is printable. + smile := '😀' + fmt.Printf("%v %d %c %q %U %#U\n", smile, smile, smile, smile, smile, smile) + // Result: 128512 128512 😀 '😀' U+1F600 U+1F600 '😀' + + // Strings are formatted with %v and %s as-is, with %q as quoted strings, + // and %#q as backquoted strings. + placeholders := `foo "bar"` + fmt.Printf("%v %s %q %#q\n", placeholders, placeholders, placeholders, placeholders) + // Result: foo "bar" foo "bar" "foo \"bar\"" `foo "bar"` + + // Maps formatted with %v show keys and values in their default formats. + // The %#v form (the # is called a "flag" in this context) shows the map in + // the Go source format. Maps are printed in a consistent order, sorted + // by the values of the keys. + isLegume := map[string]bool{ + "peanut": true, + "dachshund": false, + } + fmt.Printf("%v %#v\n", isLegume, isLegume) + // Result: map[dachshund:false peanut:true] map[string]bool{"dachshund":false, "peanut":true} + + // Structs formatted with %v show field values in their default formats. + // The %+v form shows the fields by name, while %#v formats the struct in + // Go source format. + person := struct { + Name string + Age int + }{"Kim", 22} + fmt.Printf("%v %+v %#v\n", person, person, person) + // Result: {Kim 22} {Name:Kim Age:22} struct { Name string; Age int }{Name:"Kim", Age:22} + + // The default format for a pointer shows the underlying value preceded by + // an ampersand. The %p verb prints the pointer value in hex. We use a + // typed nil for the argument to %p here because the value of any non-nil + // pointer would change from run to run; run the commented-out Printf + // call yourself to see. + pointer := &person + fmt.Printf("%v %p\n", pointer, (*int)(nil)) + // Result: &{Kim 22} 0x0 + // fmt.Printf("%v %p\n", pointer, pointer) + // Result: &{Kim 22} 0x010203 // See comment above. + + // Arrays and slices are formatted by applying the format to each element. + greats := [5]string{"Katano", "Kobayashi", "Kurosawa", "Miyazaki", "Ozu"} + fmt.Printf("%v %q\n", greats, greats) + // Result: [Katano Kobayashi Kurosawa Miyazaki Ozu] ["Katano" "Kobayashi" "Kurosawa" "Miyazaki" "Ozu"] + + kGreats := greats[:3] + fmt.Printf("%v %q %#v\n", kGreats, kGreats, kGreats) + // Result: [Katano Kobayashi Kurosawa] ["Katano" "Kobayashi" "Kurosawa"] []string{"Katano", "Kobayashi", "Kurosawa"} + + // Byte slices are special. Integer verbs like %d print the elements in + // that format. The %s and %q forms treat the slice like a string. The %x + // verb has a special form with the space flag that puts a space between + // the bytes. + cmd := []byte("a⌘") + fmt.Printf("%v %d %s %q %x % x\n", cmd, cmd, cmd, cmd, cmd, cmd) + // Result: [97 226 140 152] [97 226 140 152] a⌘ "a⌘" 61e28c98 61 e2 8c 98 + + // Types that implement Stringer are printed the same as strings. Because + // Stringers return a string, we can print them using a string-specific + // verb such as %q. + now := time.Unix(123456789, 0).UTC() // time.Time implements fmt.Stringer. + fmt.Printf("%v %q\n", now, now) + // Result: 1973-11-29 21:33:09 +0000 UTC "1973-11-29 21:33:09 +0000 UTC" + + // Output: + // 23 + // 23 + // 23 + // int *int + // true true + // 42 42 2a 52 101010 + // 3.141592653589793 3.141592653589793 3.14 ( 3.14) 3.141593e+00 + // (110.7+22.5i) (110.7+22.5i) (110.70+22.50i) (1.11e+02+2.25e+01i) + // 128512 128512 😀 '😀' U+1F600 U+1F600 '😀' + // foo "bar" foo "bar" "foo \"bar\"" `foo "bar"` + // map[dachshund:false peanut:true] map[string]bool{"dachshund":false, "peanut":true} + // {Kim 22} {Name:Kim Age:22} struct { Name string; Age int }{Name:"Kim", Age:22} + // &{Kim 22} 0x0 + // [Katano Kobayashi Kurosawa Miyazaki Ozu] ["Katano" "Kobayashi" "Kurosawa" "Miyazaki" "Ozu"] + // [Katano Kobayashi Kurosawa] ["Katano" "Kobayashi" "Kurosawa"] []string{"Katano", "Kobayashi", "Kurosawa"} + // [97 226 140 152] [97 226 140 152] a⌘ "a⌘" 61e28c98 61 e2 8c 98 + // 1973-11-29 21:33:09 +0000 UTC "1973-11-29 21:33:09 +0000 UTC" } diff --git a/libgo/go/fmt/fmt_test.go b/libgo/go/fmt/fmt_test.go index b56b84fd9c0..bc184c307ea 100644 --- a/libgo/go/fmt/fmt_test.go +++ b/libgo/go/fmt/fmt_test.go @@ -131,15 +131,10 @@ func (byteFormatter) Format(f State, _ rune) { var byteFormatterSlice = []byteFormatter{'h', 'e', 'l', 'l', 'o'} -// Copy of io.stringWriter interface used by writeStringFormatter for type assertion. -type stringWriter interface { - WriteString(s string) (n int, err error) -} - type writeStringFormatter string func (sf writeStringFormatter) Format(f State, c rune) { - if sw, ok := f.(stringWriter); ok { + if sw, ok := f.(io.StringWriter); ok { sw.WriteString("***" + string(sf) + "***") } } @@ -303,20 +298,30 @@ var fmtTests = []struct { // width {"%5s", "abc", " abc"}, + {"%5s", []byte("abc"), " abc"}, {"%2s", "\u263a", " ☺"}, + {"%2s", []byte("\u263a"), " ☺"}, {"%-5s", "abc", "abc "}, - {"%-8q", "abc", `"abc" `}, + {"%-5s", []byte("abc"), "abc "}, {"%05s", "abc", "00abc"}, - {"%08q", "abc", `000"abc"`}, + {"%05s", []byte("abc"), "00abc"}, {"%5s", "abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz"}, + {"%5s", []byte("abcdefghijklmnopqrstuvwxyz"), "abcdefghijklmnopqrstuvwxyz"}, {"%.5s", "abcdefghijklmnopqrstuvwxyz", "abcde"}, + {"%.5s", []byte("abcdefghijklmnopqrstuvwxyz"), "abcde"}, {"%.0s", "日本語日本語", ""}, + {"%.0s", []byte("日本語日本語"), ""}, {"%.5s", "日本語日本語", "日本語日本"}, - {"%.10s", "日本語日本語", "日本語日本語"}, {"%.5s", []byte("日本語日本語"), "日本語日本"}, + {"%.10s", "日本語日本語", "日本語日本語"}, + {"%.10s", []byte("日本語日本語"), "日本語日本語"}, + {"%08q", "abc", `000"abc"`}, + {"%08q", []byte("abc"), `000"abc"`}, + {"%-8q", "abc", `"abc" `}, + {"%-8q", []byte("abc"), `"abc" `}, {"%.5q", "abcdefghijklmnopqrstuvwxyz", `"abcde"`}, - {"%.5x", "abcdefghijklmnopqrstuvwxyz", "6162636465"}, {"%.5q", []byte("abcdefghijklmnopqrstuvwxyz"), `"abcde"`}, + {"%.5x", "abcdefghijklmnopqrstuvwxyz", "6162636465"}, {"%.5x", []byte("abcdefghijklmnopqrstuvwxyz"), "6162636465"}, {"%.3q", "日本語日本語", `"日本語"`}, {"%.3q", []byte("日本語日本語"), `"日本語"`}, @@ -325,6 +330,7 @@ var fmtTests = []struct { {"%.1x", "日本語", "e6"}, {"%.1X", []byte("日本語"), "E6"}, {"%10.1q", "日本語日本語", ` "日"`}, + {"%10.1q", []byte("日本語日本語"), ` "日"`}, {"%10v", nil, " "}, {"%-10v", nil, " "}, @@ -690,6 +696,13 @@ var fmtTests = []struct { {"%#v", []int32(nil), "[]int32(nil)"}, {"%#v", 1.2345678, "1.2345678"}, {"%#v", float32(1.2345678), "1.2345678"}, + + // Whole number floats are printed without decimals. See Issue 27634. + {"%#v", 1.0, "1"}, + {"%#v", 1000000.0, "1e+06"}, + {"%#v", float32(1.0), "1"}, + {"%#v", float32(1000000.0), "1e+06"}, + // Only print []byte and []uint8 as type []byte if they appear at the top level. {"%#v", []byte(nil), "[]byte(nil)"}, {"%#v", []uint8(nil), "[]byte(nil)"}, @@ -861,13 +874,8 @@ var fmtTests = []struct { // Extra argument errors should format without flags set. {"%010.2", "12345", "%!(NOVERB)%!(EXTRA string=12345)"}, - // The "" show up because maps are printed by - // first obtaining a list of keys and then looking up - // each key. Since NaNs can be map keys but cannot - // be fetched directly, the lookup fails and returns a - // zero reflect.Value, which formats as . - // This test is just to check that it shows the two NaNs at all. - {"%v", map[float64]int{NaN: 1, NaN: 2}, "map[NaN: NaN:]"}, + // Test that maps with non-reflexive keys print all keys and values. + {"%v", map[float64]int{NaN: 1, NaN: 1}, "map[NaN:1 NaN:1]"}, // Comparison of padding rules with C printf. /* @@ -1033,7 +1041,7 @@ var fmtTests = []struct { {"%☠", &[]interface{}{I(1), G(2)}, "&[%!☠(fmt_test.I=1) %!☠(fmt_test.G=2)]"}, {"%☠", SI{&[]interface{}{I(1), G(2)}}, "{%!☠(*[]interface {}=&[1 2])}"}, {"%☠", reflect.Value{}, ""}, - {"%☠", map[float64]int{NaN: 1}, "map[%!☠(float64=NaN):%!☠()]"}, + {"%☠", map[float64]int{NaN: 1}, "map[%!☠(float64=NaN):%!☠(int=1)]"}, } // zeroFill generates zero-filled strings of the specified width. The length @@ -1214,7 +1222,16 @@ func BenchmarkSprintfString(b *testing.B) { func BenchmarkSprintfTruncateString(b *testing.B) { b.RunParallel(func(pb *testing.PB) { for pb.Next() { - Sprintf("%.3s", "日本語日本語日本語") + Sprintf("%.3s", "日本語日本語日本語日本語") + } + }) +} + +func BenchmarkSprintfTruncateBytes(b *testing.B) { + var bytes interface{} = []byte("日本語日本語日本語日本語") + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + Sprintf("%.3s", bytes) } }) } @@ -1668,18 +1685,18 @@ var panictests = []struct { }{ // String {"%s", (*PanicS)(nil), ""}, // nil pointer special case - {"%s", PanicS{io.ErrUnexpectedEOF}, "%!s(PANIC=unexpected EOF)"}, - {"%s", PanicS{3}, "%!s(PANIC=3)"}, + {"%s", PanicS{io.ErrUnexpectedEOF}, "%!s(PANIC=String method: unexpected EOF)"}, + {"%s", PanicS{3}, "%!s(PANIC=String method: 3)"}, // GoString {"%#v", (*PanicGo)(nil), ""}, // nil pointer special case - {"%#v", PanicGo{io.ErrUnexpectedEOF}, "%!v(PANIC=unexpected EOF)"}, - {"%#v", PanicGo{3}, "%!v(PANIC=3)"}, + {"%#v", PanicGo{io.ErrUnexpectedEOF}, "%!v(PANIC=GoString method: unexpected EOF)"}, + {"%#v", PanicGo{3}, "%!v(PANIC=GoString method: 3)"}, // Issue 18282. catchPanic should not clear fmtFlags permanently. - {"%#v", []interface{}{PanicGo{3}, PanicGo{3}}, "[]interface {}{%!v(PANIC=3), %!v(PANIC=3)}"}, + {"%#v", []interface{}{PanicGo{3}, PanicGo{3}}, "[]interface {}{%!v(PANIC=GoString method: 3), %!v(PANIC=GoString method: 3)}"}, // Format {"%s", (*PanicF)(nil), ""}, // nil pointer special case - {"%s", PanicF{io.ErrUnexpectedEOF}, "%!s(PANIC=unexpected EOF)"}, - {"%s", PanicF{3}, "%!s(PANIC=3)"}, + {"%s", PanicF{io.ErrUnexpectedEOF}, "%!s(PANIC=Format method: unexpected EOF)"}, + {"%s", PanicF{3}, "%!s(PANIC=Format method: 3)"}, } func TestPanics(t *testing.T) { diff --git a/libgo/go/fmt/format.go b/libgo/go/fmt/format.go index 91103f2c07f..d6da8aed1e3 100644 --- a/libgo/go/fmt/format.go +++ b/libgo/go/fmt/format.go @@ -308,8 +308,8 @@ func (f *fmt) fmtInteger(u uint64, base int, isSigned bool, digits string) { f.zero = oldZero } -// truncate truncates the string to the specified precision, if present. -func (f *fmt) truncate(s string) string { +// truncate truncates the string s to the specified precision, if present. +func (f *fmt) truncateString(s string) string { if f.precPresent { n := f.prec for i := range s { @@ -322,12 +322,37 @@ func (f *fmt) truncate(s string) string { return s } +// truncate truncates the byte slice b as a string of the specified precision, if present. +func (f *fmt) truncate(b []byte) []byte { + if f.precPresent { + n := f.prec + for i := 0; i < len(b); { + n-- + if n < 0 { + return b[:i] + } + wid := 1 + if b[i] >= utf8.RuneSelf { + _, wid = utf8.DecodeRune(b[i:]) + } + i += wid + } + } + return b +} + // fmtS formats a string. func (f *fmt) fmtS(s string) { - s = f.truncate(s) + s = f.truncateString(s) f.padString(s) } +// fmtBs formats the byte slice b as if it was formatted as string with fmtS. +func (f *fmt) fmtBs(b []byte) { + b = f.truncate(b) + f.pad(b) +} + // fmtSbx formats a string or byte slice as a hexadecimal encoding of its bytes. func (f *fmt) fmtSbx(s string, b []byte, digits string) { length := len(b) @@ -408,7 +433,7 @@ func (f *fmt) fmtBx(b []byte, digits string) { // If f.sharp is set a raw (backquoted) string may be returned instead // if the string does not contain any control characters other than tab. func (f *fmt) fmtQ(s string) { - s = f.truncate(s) + s = f.truncateString(s) if f.sharp && strconv.CanBackquote(s) { f.padString("`" + s + "`") return diff --git a/libgo/go/fmt/gostringer_example_test.go b/libgo/go/fmt/gostringer_example_test.go new file mode 100644 index 00000000000..7c6b9f05453 --- /dev/null +++ b/libgo/go/fmt/gostringer_example_test.go @@ -0,0 +1,61 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +package fmt_test + +import ( + "fmt" +) + +// Address has a City, State and a Country. +type Address struct { + City string + State string + Country string +} + +// Person has a Name, Age and Address. +type Person struct { + Name string + Age uint + Addr *Address +} + +// GoString makes Person satisfy the GoStringer interface. +// The return value is valid Go code that can be used to reproduce the Person struct. +func (p Person) GoString() string { + if p.Addr != nil { + return fmt.Sprintf("Person{Name: %q, Age: %d, Addr: &Address{City: %q, State: %q, Country: %q}}", p.Name, int(p.Age), p.Addr.City, p.Addr.State, p.Addr.Country) + } + return fmt.Sprintf("Person{Name: %q, Age: %d}", p.Name, int(p.Age)) +} + +func ExampleGoStringer() { + p1 := Person{ + Name: "Warren", + Age: 31, + Addr: &Address{ + City: "Denver", + State: "CO", + Country: "U.S.A.", + }, + } + // If GoString() wasn't implemented, the output of `fmt.Printf("%#v", p1)` would be similar to + // Person{Name:"Warren", Age:0x1f, Addr:(*main.Address)(0x10448240)} + fmt.Printf("%#v\n", p1) + + p2 := Person{ + Name: "Theia", + Age: 4, + } + // If GoString() wasn't implemented, the output of `fmt.Printf("%#v", p2)` would be similar to + // Person{Name:"Theia", Age:0x4, Addr:(*main.Address)(nil)} + fmt.Printf("%#v\n", p2) + + // Output: + // Person{Name: "Warren", Age: 31, Addr: &Address{City: "Denver", State: "CO", Country: "U.S.A."}} + // Person{Name: "Theia", Age: 4} +} diff --git a/libgo/go/fmt/print.go b/libgo/go/fmt/print.go index f67f8056037..42fcd8b979b 100644 --- a/libgo/go/fmt/print.go +++ b/libgo/go/fmt/print.go @@ -6,6 +6,7 @@ package fmt import ( "errors" + "internal/fmtsort" "io" "os" "reflect" @@ -139,6 +140,16 @@ func newPrinter() *pp { // free saves used pp structs in ppFree; avoids an allocation per invocation. func (p *pp) free() { + // Proper usage of a sync.Pool requires each entry to have approximately + // the same memory cost. To obtain this property when the stored type + // contains a variably-sized buffer, we add a hard limit on the maximum buffer + // to place back in the pool. + // + // See https://golang.org/issue/23199 + if cap(p.buf) > 64<<10 { + return + } + p.buf = p.buf[:0] p.arg = nil p.value = reflect.Value{} @@ -477,7 +488,7 @@ func (p *pp) fmtBytes(v []byte, verb rune, typeString string) { p.buf.WriteByte(']') } case 's': - p.fmt.fmtS(string(v)) + p.fmt.fmtBs(v) case 'x': p.fmt.fmtBx(v, ldigits) case 'X': @@ -527,7 +538,7 @@ func (p *pp) fmtPointer(value reflect.Value, verb rune) { } } -func (p *pp) catchPanic(arg interface{}, verb rune) { +func (p *pp) catchPanic(arg interface{}, verb rune, method string) { if err := recover(); err != nil { // If it's a nil pointer, just say "". The likeliest causes are a // Stringer that fails to guard against nil or a nil pointer for a @@ -550,6 +561,8 @@ func (p *pp) catchPanic(arg interface{}, verb rune) { p.buf.WriteString(percentBangString) p.buf.WriteRune(verb) p.buf.WriteString(panicString) + p.buf.WriteString(method) + p.buf.WriteString(" method: ") p.panicking = true p.printArg(err, 'v') p.panicking = false @@ -566,7 +579,7 @@ func (p *pp) handleMethods(verb rune) (handled bool) { // Is it a Formatter? if formatter, ok := p.arg.(Formatter); ok { handled = true - defer p.catchPanic(p.arg, verb) + defer p.catchPanic(p.arg, verb, "Format") formatter.Format(p, verb) return } @@ -575,7 +588,7 @@ func (p *pp) handleMethods(verb rune) (handled bool) { if p.fmt.sharpV { if stringer, ok := p.arg.(GoStringer); ok { handled = true - defer p.catchPanic(p.arg, verb) + defer p.catchPanic(p.arg, verb, "GoString") // Print the result of GoString unadorned. p.fmt.fmtS(stringer.GoString()) return @@ -593,13 +606,13 @@ func (p *pp) handleMethods(verb rune) (handled bool) { switch v := p.arg.(type) { case error: handled = true - defer p.catchPanic(p.arg, verb) + defer p.catchPanic(p.arg, verb, "Error") p.fmtString(v.Error(), verb) return case Stringer: handled = true - defer p.catchPanic(p.arg, verb) + defer p.catchPanic(p.arg, verb, "String") p.fmtString(v.String(), verb) return } @@ -743,8 +756,8 @@ func (p *pp) printValue(value reflect.Value, verb rune, depth int) { } else { p.buf.WriteString(mapString) } - keys := f.MapKeys() - for i, key := range keys { + sorted := fmtsort.Sort(f) + for i, key := range sorted.Key { if i > 0 { if p.fmt.sharpV { p.buf.WriteString(commaSpaceString) @@ -754,7 +767,7 @@ func (p *pp) printValue(value reflect.Value, verb rune, depth int) { } p.printValue(key, verb, depth+1) p.buf.WriteByte(':') - p.printValue(f.MapIndex(key), verb, depth+1) + p.printValue(sorted.Value[i], verb, depth+1) } if p.fmt.sharpV { p.buf.WriteByte('}') diff --git a/libgo/go/fmt/stringer_example_test.go b/libgo/go/fmt/stringer_example_test.go new file mode 100644 index 00000000000..aa3cd05e3ef --- /dev/null +++ b/libgo/go/fmt/stringer_example_test.go @@ -0,0 +1,31 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +package fmt_test + +import ( + "fmt" +) + +// Animal has a Name and an Age to represent an animal. +type Animal struct { + Name string + Age uint +} + +// String makes Animal satisfy the Stringer interface. +func (a Animal) String() string { + return fmt.Sprintf("%v (%d)", a.Name, a.Age) +} + +func ExampleStringer() { + a := Animal{ + Name: "Gopher", + Age: 2, + } + fmt.Println(a) + // Output: Gopher (2) +} diff --git a/libgo/go/go/build/build.go b/libgo/go/go/build/build.go index e067fd094f7..84c26d9074b 100644 --- a/libgo/go/go/build/build.go +++ b/libgo/go/go/build/build.go @@ -34,7 +34,7 @@ type Context struct { GOOS string // target operating system GOROOT string // Go root GOPATH string // Go path - CgoEnabled bool // whether cgo can be used + CgoEnabled bool // whether cgo files are included UseAllFiles bool // use files regardless of +build lines, file names Compiler string // compiler to assume when computing target paths @@ -43,8 +43,10 @@ type Context struct { // Clients creating a new context may customize BuildTags, which // defaults to empty, but it is usually an error to customize ReleaseTags, // which defaults to the list of Go releases the current release is compatible with. + // BuildTags is not set for the Default build Context. // In addition to the BuildTags and ReleaseTags, build constraints // consider the values of GOARCH and GOOS as satisfied tags. + // The last element in ReleaseTags is assumed to be the current release. BuildTags []string ReleaseTags []string @@ -296,7 +298,8 @@ func defaultContext() Context { // say "+build go1.x", and code that should only be built before Go 1.x // (perhaps it is the stub to use in that case) should say "+build !go1.x". // NOTE: If you add to this list, also update the doc comment in doc.go. - const version = 11 // go1.11 + // NOTE: The last element in ReleaseTags should be the current release. + const version = 12 // go1.12 for i := 1; i <= version; i++ { c.ReleaseTags = append(c.ReleaseTags, "go1."+strconv.Itoa(i)) } diff --git a/libgo/go/go/build/build_test.go b/libgo/go/go/build/build_test.go index f21bc32b520..19b544746ff 100644 --- a/libgo/go/go/build/build_test.go +++ b/libgo/go/go/build/build_test.go @@ -353,12 +353,16 @@ func TestImportDirNotExist(t *testing.T) { func TestImportVendor(t *testing.T) { testenv.MustHaveGoBuild(t) // really must just have source ctxt := Default - ctxt.GOPATH = "" - p, err := ctxt.Import("golang_org/x/net/http2/hpack", filepath.Join(ctxt.GOROOT, "src/net/http"), 0) + wd, err := os.Getwd() + if err != nil { + t.Fatal(err) + } + ctxt.GOPATH = filepath.Join(wd, "testdata/withvendor") + p, err := ctxt.Import("c/d", filepath.Join(ctxt.GOPATH, "src/a/b"), 0) if err != nil { - t.Fatalf("cannot find vendored golang_org/x/net/http2/hpack from net/http directory: %v", err) + t.Fatalf("cannot find vendored c/d from testdata src/a/b directory: %v", err) } - want := "vendor/golang_org/x/net/http2/hpack" + want := "a/vendor/c/d" if p.ImportPath != want { t.Fatalf("Import succeeded but found %q, want %q", p.ImportPath, want) } @@ -367,8 +371,12 @@ func TestImportVendor(t *testing.T) { func TestImportVendorFailure(t *testing.T) { testenv.MustHaveGoBuild(t) // really must just have source ctxt := Default - ctxt.GOPATH = "" - p, err := ctxt.Import("x.com/y/z", filepath.Join(ctxt.GOROOT, "src/net/http"), 0) + wd, err := os.Getwd() + if err != nil { + t.Fatal(err) + } + ctxt.GOPATH = filepath.Join(wd, "testdata/withvendor") + p, err := ctxt.Import("x.com/y/z", filepath.Join(ctxt.GOPATH, "src/a/b"), 0) if err == nil { t.Fatalf("found made-up package x.com/y/z in %s", p.Dir) } @@ -382,9 +390,13 @@ func TestImportVendorFailure(t *testing.T) { func TestImportVendorParentFailure(t *testing.T) { testenv.MustHaveGoBuild(t) // really must just have source ctxt := Default - ctxt.GOPATH = "" - // This import should fail because the vendor/golang.org/x/net/http2 directory has no source code. - p, err := ctxt.Import("golang_org/x/net/http2", filepath.Join(ctxt.GOROOT, "src/net/http"), 0) + wd, err := os.Getwd() + if err != nil { + t.Fatal(err) + } + ctxt.GOPATH = filepath.Join(wd, "testdata/withvendor") + // This import should fail because the vendor/c directory has no source code. + p, err := ctxt.Import("c", filepath.Join(ctxt.GOPATH, "src/a/b"), 0) if err == nil { t.Fatalf("found empty parent in %s", p.Dir) } diff --git a/libgo/go/go/build/deps_test.go b/libgo/go/go/build/deps_test.go index b9593787e07..2c29a3e6018 100644 --- a/libgo/go/go/build/deps_test.go +++ b/libgo/go/go/build/deps_test.go @@ -36,9 +36,10 @@ var pkgDeps = map[string][]string{ // L0 is the lowest level, core, nearly unavoidable packages. "errors": {}, "io": {"errors", "sync", "sync/atomic"}, - "runtime": {"unsafe", "runtime/internal/atomic", "runtime/internal/sys", "internal/cpu", "internal/bytealg"}, + "runtime": {"unsafe", "runtime/internal/atomic", "runtime/internal/sys", "runtime/internal/math", "internal/cpu", "internal/bytealg"}, "runtime/internal/sys": {}, - "runtime/internal/atomic": {"unsafe", "runtime/internal/sys"}, + "runtime/internal/atomic": {"unsafe", "internal/cpu"}, + "runtime/internal/math": {"runtime/internal/sys"}, "internal/race": {"runtime", "unsafe"}, "sync": {"internal/race", "runtime", "sync/atomic", "unsafe"}, "sync/atomic": {"unsafe"}, @@ -60,8 +61,8 @@ var pkgDeps = map[string][]string{ // L1 adds simple functions and strings processing, // but not Unicode tables. - "math": {"internal/cpu", "unsafe"}, - "math/bits": {}, + "math": {"internal/cpu", "unsafe", "math/bits"}, + "math/bits": {"unsafe"}, "math/cmplx": {"math"}, "math/rand": {"L0", "math"}, "strconv": {"L0", "unicode/utf8", "math", "math/bits"}, @@ -100,7 +101,7 @@ var pkgDeps = map[string][]string{ // and interface definitions, but nothing that makes // system calls. "crypto": {"L2", "hash"}, // interfaces - "crypto/cipher": {"L2", "crypto/subtle", "crypto/internal/subtle"}, + "crypto/cipher": {"L2", "crypto/subtle", "crypto/internal/subtle", "encoding/binary"}, "crypto/internal/subtle": {"unsafe", "reflect"}, // reflect behind a appengine tag "crypto/subtle": {}, "encoding/base32": {"L2"}, @@ -114,6 +115,7 @@ var pkgDeps = map[string][]string{ "image": {"L2", "image/color"}, // interfaces "image/color": {"L2"}, // interfaces "image/color/palette": {"L2", "image/color"}, + "internal/fmtsort": {"reflect", "sort"}, "reflect": {"L2"}, "sort": {"reflect"}, @@ -134,6 +136,7 @@ var pkgDeps = map[string][]string{ "image", "image/color", "image/color/palette", + "internal/fmtsort", "reflect", }, @@ -156,6 +159,7 @@ var pkgDeps = map[string][]string{ // Other time dependencies: "internal/syscall/windows/registry", "syscall", + "syscall/js", }, "internal/poll": {"L0", "internal/race", "syscall", "time", "unicode/utf16", "unicode/utf8", "internal/syscall/windows"}, @@ -176,8 +180,8 @@ var pkgDeps = map[string][]string{ "time", }, - // Formatted I/O: few dependencies (L1) but we must add reflect. - "fmt": {"L1", "os", "reflect"}, + // Formatted I/O: few dependencies (L1) but we must add reflect and internal/fmtsort. + "fmt": {"L1", "os", "reflect", "internal/fmtsort"}, "log": {"L1", "os", "fmt", "time"}, // Packages used by testing must be low-level (L2+fmt). @@ -204,7 +208,7 @@ var pkgDeps = map[string][]string{ // Go parser. "go/ast": {"L4", "OS", "go/scanner", "go/token"}, - "go/doc": {"L4", "go/ast", "go/token", "regexp", "text/template"}, + "go/doc": {"L4", "OS", "go/ast", "go/token", "regexp", "text/template"}, "go/parser": {"L4", "OS", "go/ast", "go/scanner", "go/token"}, "go/printer": {"L4", "OS", "go/ast", "go/scanner", "go/token", "text/tabwriter"}, "go/scanner": {"L4", "OS", "go/token"}, @@ -226,7 +230,7 @@ var pkgDeps = map[string][]string{ "go/constant": {"L4", "go/token", "math/big"}, "go/importer": {"L4", "go/build", "go/internal/gccgoimporter", "go/internal/gcimporter", "go/internal/srcimporter", "go/token", "go/types"}, "go/internal/gcimporter": {"L4", "OS", "go/build", "go/constant", "go/token", "go/types", "text/scanner"}, - "go/internal/gccgoimporter": {"L4", "OS", "debug/elf", "debug/xcoff", "go/constant", "go/token", "go/types", "text/scanner"}, + "go/internal/gccgoimporter": {"L4", "OS", "debug/elf", "go/constant", "go/token", "go/types", "internal/xcoff", "text/scanner"}, "go/internal/srcimporter": {"L4", "OS", "fmt", "go/ast", "go/build", "go/parser", "go/token", "go/types", "path/filepath"}, "go/types": {"L4", "GOPARSER", "container/heap", "go/constant"}, @@ -248,7 +252,6 @@ var pkgDeps = map[string][]string{ "debug/macho": {"L4", "OS", "debug/dwarf", "compress/zlib"}, "debug/pe": {"L4", "OS", "debug/dwarf", "compress/zlib"}, "debug/plan9obj": {"L4", "OS"}, - "debug/xcoff": {"L4", "OS", "debug/dwarf"}, "encoding": {"L4"}, "encoding/ascii85": {"L4"}, "encoding/asn1": {"L4", "math/big"}, @@ -259,7 +262,7 @@ var pkgDeps = map[string][]string{ "encoding/pem": {"L4"}, "encoding/xml": {"L4", "encoding"}, "flag": {"L4", "OS"}, - "go/build": {"L4", "OS", "GOPARSER"}, + "go/build": {"L4", "OS", "GOPARSER", "internal/goroot"}, "html": {"L4"}, "image/draw": {"L4", "image/internal/imageutil"}, "image/gif": {"L4", "compress/lzw", "image/color/palette", "image/draw"}, @@ -267,8 +270,10 @@ var pkgDeps = map[string][]string{ "image/jpeg": {"L4", "image/internal/imageutil"}, "image/png": {"L4", "compress/zlib"}, "index/suffixarray": {"L4", "regexp"}, + "internal/goroot": {"L4", "OS"}, "internal/singleflight": {"sync"}, - "internal/trace": {"L4", "OS"}, + "internal/trace": {"L4", "OS", "container/heap"}, + "internal/xcoff": {"L4", "OS", "debug/dwarf"}, "math/big": {"L4"}, "mime": {"L4", "OS", "syscall", "internal/syscall/windows/registry"}, "mime/quotedprintable": {"L4"}, @@ -314,9 +319,9 @@ var pkgDeps = map[string][]string{ "net": { "L0", "CGO", "context", "math/rand", "os", "reflect", "sort", "syscall", "time", - "internal/nettrace", "internal/poll", + "internal/nettrace", "internal/poll", "internal/syscall/unix", "internal/syscall/windows", "internal/singleflight", "internal/race", - "golang_org/x/net/dns/dnsmessage", "golang_org/x/net/lif", "golang_org/x/net/route", + "internal/x/net/dns/dnsmessage", "internal/x/net/lif", "internal/x/net/route", }, // NET enables use of basic network-related packages. @@ -353,9 +358,9 @@ var pkgDeps = map[string][]string{ "crypto/sha1", "crypto/sha256", "crypto/sha512", - "golang_org/x/crypto/chacha20poly1305", - "golang_org/x/crypto/curve25519", - "golang_org/x/crypto/poly1305", + "internal/x/crypto/chacha20poly1305", + "internal/x/crypto/curve25519", + "internal/x/crypto/poly1305", }, // Random byte, number generation. @@ -383,13 +388,13 @@ var pkgDeps = map[string][]string{ // SSL/TLS. "crypto/tls": { - "L4", "CRYPTO-MATH", "OS", + "L4", "CRYPTO-MATH", "OS", "internal/x/crypto/cryptobyte", "internal/x/crypto/hkdf", "container/list", "crypto/x509", "encoding/pem", "net", "syscall", }, "crypto/x509": { "L4", "CRYPTO-MATH", "OS", "CGO", "crypto/x509/pkix", "encoding/pem", "encoding/hex", "net", "os/user", "syscall", "net/url", - "golang_org/x/crypto/cryptobyte", "golang_org/x/crypto/cryptobyte/asn1", + "internal/x/crypto/cryptobyte", "internal/x/crypto/cryptobyte/asn1", }, "crypto/x509/pkix": {"L4", "CRYPTO-MATH", "encoding/hex"}, @@ -405,12 +410,12 @@ var pkgDeps = map[string][]string{ "context", "crypto/rand", "crypto/tls", - "golang_org/x/net/http/httpguts", - "golang_org/x/net/http/httpproxy", - "golang_org/x/net/http2/hpack", - "golang_org/x/net/idna", - "golang_org/x/text/unicode/norm", - "golang_org/x/text/width", + "internal/x/net/http/httpguts", + "internal/x/net/http/httpproxy", + "internal/x/net/http2/hpack", + "internal/x/net/idna", + "internal/x/text/unicode/norm", + "internal/x/text/width", "internal/nettrace", "mime/multipart", "net/http/httptrace", @@ -428,9 +433,9 @@ var pkgDeps = map[string][]string{ "net/http/fcgi": {"L4", "NET", "OS", "context", "net/http", "net/http/cgi"}, "net/http/httptest": { "L4", "NET", "OS", "crypto/tls", "flag", "net/http", "net/http/internal", "crypto/x509", - "golang_org/x/net/http/httpguts", + "internal/x/net/http/httpguts", }, - "net/http/httputil": {"L4", "NET", "OS", "context", "net/http", "net/http/internal"}, + "net/http/httputil": {"L4", "NET", "OS", "context", "net/http", "net/http/internal", "internal/x/net/http/httpguts"}, "net/http/pprof": {"L4", "OS", "html/template", "net/http", "runtime/pprof", "runtime/trace"}, "net/rpc": {"L4", "NET", "encoding/gob", "html/template", "net/http"}, "net/rpc/jsonrpc": {"L4", "NET", "encoding/json", "net/rpc"}, @@ -481,7 +486,7 @@ func listStdPkgs(goroot string) ([]string, error) { } name := filepath.ToSlash(path[len(src):]) - if name == "builtin" || name == "cmd" || strings.Contains(name, "golang_org") { + if name == "builtin" || name == "cmd" || strings.Contains(name, "internal/x/") { return filepath.SkipDir } diff --git a/libgo/go/go/build/doc.go b/libgo/go/go/build/doc.go index 69613e359c2..8e3858feea9 100644 --- a/libgo/go/go/build/doc.go +++ b/libgo/go/go/build/doc.go @@ -108,8 +108,11 @@ // - "go1.9", from Go version 1.9 onward // - "go1.10", from Go version 1.10 onward // - "go1.11", from Go version 1.11 onward +// - "go1.12", from Go version 1.12 onward // - any additional words listed in ctxt.BuildTags // +// There are no build tags for beta or minor releases. +// // If a file's name, after stripping the extension and a possible _test suffix, // matches any of the following patterns: // *_GOOS diff --git a/libgo/go/go/build/read_test.go b/libgo/go/go/build/read_test.go index 9cef657e13f..8636533f697 100644 --- a/libgo/go/go/build/read_test.go +++ b/libgo/go/go/build/read_test.go @@ -110,15 +110,12 @@ func testRead(t *testing.T, tests []readTest, read func(io.Reader) ([]byte, erro if err != nil { if tt.err == "" { t.Errorf("#%d: err=%q, expected success (%q)", i, err, string(buf)) - continue - } - if !strings.Contains(err.Error(), tt.err) { + } else if !strings.Contains(err.Error(), tt.err) { t.Errorf("#%d: err=%q, expected %q", i, err, tt.err) - continue } continue } - if err == nil && tt.err != "" { + if tt.err != "" { t.Errorf("#%d: success, expected %q", i, tt.err) continue } diff --git a/libgo/go/go/build/syslist.go b/libgo/go/go/build/syslist.go index baa957212ea..b3f2c8615be 100644 --- a/libgo/go/go/build/syslist.go +++ b/libgo/go/go/build/syslist.go @@ -4,5 +4,5 @@ package build -const goosList = "aix android darwin dragonfly freebsd js linux nacl netbsd openbsd plan9 solaris windows zos " -const goarchList = "386 amd64 amd64p32 arm armbe arm64 arm64be alpha m68k ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32le nios2 ppc riscv riscv64 s390 s390x sh shbe sparc sparc64 wasm " +const goosList = "aix android darwin dragonfly freebsd hurd js linux nacl netbsd openbsd plan9 solaris windows zos " +const goarchList = "386 amd64 amd64p32 arm armbe arm64 arm64be ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32le ppc riscv riscv64 s390 s390x sparc sparc64 wasm alpha m68k nios2 sh shbe " diff --git a/libgo/go/go/build/testdata/withvendor/src/a/b/b.go b/libgo/go/go/build/testdata/withvendor/src/a/b/b.go new file mode 100644 index 00000000000..4405d547a62 --- /dev/null +++ b/libgo/go/go/build/testdata/withvendor/src/a/b/b.go @@ -0,0 +1,3 @@ +package b + +import _ "c/d" diff --git a/libgo/go/go/build/testdata/withvendor/src/a/c/d/d.go b/libgo/go/go/build/testdata/withvendor/src/a/c/d/d.go new file mode 100644 index 00000000000..142fb423f66 --- /dev/null +++ b/libgo/go/go/build/testdata/withvendor/src/a/c/d/d.go @@ -0,0 +1 @@ +package d diff --git a/libgo/go/go/constant/value.go b/libgo/go/go/constant/value.go index 64f8eb660a8..0982243edbf 100644 --- a/libgo/go/go/constant/value.go +++ b/libgo/go/go/constant/value.go @@ -170,7 +170,7 @@ func (x int64Val) String() string { return strconv.FormatInt(int64(x), 10) } func (x intVal) String() string { return x.val.String() } func (x ratVal) String() string { return rtof(x).String() } -// String returns returns a decimal approximation of the Float value. +// String returns a decimal approximation of the Float value. func (x floatVal) String() string { f := x.val diff --git a/libgo/go/go/constant/value_test.go b/libgo/go/go/constant/value_test.go index e6fca76e182..68b87eaa557 100644 --- a/libgo/go/go/constant/value_test.go +++ b/libgo/go/go/constant/value_test.go @@ -296,7 +296,7 @@ func val(lit string) Value { switch first, last := lit[0], lit[len(lit)-1]; { case first == '"' || first == '`': tok = token.STRING - lit = strings.Replace(lit, "_", " ", -1) + lit = strings.ReplaceAll(lit, "_", " ") case first == '\'': tok = token.CHAR case last == 'i': diff --git a/libgo/go/go/doc/comment.go b/libgo/go/go/doc/comment.go index a7430f45cb9..0ec42643fdf 100644 --- a/libgo/go/go/doc/comment.go +++ b/libgo/go/go/doc/comment.go @@ -7,40 +7,46 @@ package doc import ( + "bytes" "io" - "regexp" "strings" "text/template" // for HTMLEscape "unicode" "unicode/utf8" ) +const ( + ldquo = "“" + rdquo = "”" + ulquo = "“" + urquo = "”" +) + var ( - ldquo = []byte("“") - rdquo = []byte("”") + htmlQuoteReplacer = strings.NewReplacer(ulquo, ldquo, urquo, rdquo) + unicodeQuoteReplacer = strings.NewReplacer("``", ulquo, "''", urquo) ) // Escape comment text for HTML. If nice is set, // also turn `` into “ and '' into ”. func commentEscape(w io.Writer, text string, nice bool) { - last := 0 if nice { - for i := 0; i < len(text)-1; i++ { - ch := text[i] - if ch == text[i+1] && (ch == '`' || ch == '\'') { - template.HTMLEscape(w, []byte(text[last:i])) - last = i + 2 - switch ch { - case '`': - w.Write(ldquo) - case '\'': - w.Write(rdquo) - } - i++ // loop will add one more - } - } + // In the first pass, we convert `` and '' into their unicode equivalents. + // This prevents them from being escaped in HTMLEscape. + text = convertQuotes(text) + var buf bytes.Buffer + template.HTMLEscape(&buf, []byte(text)) + // Now we convert the unicode quotes to their HTML escaped entities to maintain old behavior. + // We need to use a temp buffer to read the string back and do the conversion, + // otherwise HTMLEscape will escape & to & + htmlQuoteReplacer.WriteString(w, buf.String()) + return } - template.HTMLEscape(w, []byte(text[last:])) + template.HTMLEscape(w, []byte(text)) +} + +func convertQuotes(text string) string { + return unicodeQuoteReplacer.Replace(text) } const ( @@ -48,7 +54,7 @@ const ( identRx = `[\pL_][\pL_0-9]*` // Regexp for URLs - // Match parens, and check in pairedParensPrefixLen for balance - see #5043 + // Match parens, and check later for balance - see #5043, #22285 // Match .,:;?! within path, but not at end - see #18139, #16565 // This excludes some rare yet valid urls ending in common punctuation // in order to allow sentences ending in URLs. @@ -63,7 +69,7 @@ const ( urlRx = protoPart + `://` + hostPart + pathPart ) -var matchRx = regexp.MustCompile(`(` + urlRx + `)|(` + identRx + `)`) +var matchRx = newLazyRE(`(` + urlRx + `)|(` + identRx + `)`) var ( html_a = []byte(`\n") ) -// pairedParensPrefixLen returns the length of the longest prefix of s containing paired parentheses. -func pairedParensPrefixLen(s string) int { - parens := 0 - l := len(s) - for i, ch := range s { - switch ch { - case '(': - if parens == 0 { - l = i - } - parens++ - case ')': - parens-- - if parens == 0 { - l = len(s) - } else if parens < 0 { - return i - } - } - } - return l -} - // Emphasize and escape a line of text for HTML. URLs are converted into links; // if the URL also appears in the words map, the link is taken from the map (if // the corresponding map value is the empty string, the URL is not converted @@ -122,13 +105,27 @@ func emphasize(w io.Writer, line string, words map[string]string, nice bool) { // write text before match commentEscape(w, line[0:m[0]], nice) - // adjust match if necessary + // adjust match for URLs match := line[m[0]:m[1]] - if n := pairedParensPrefixLen(match); n < len(match) { - // match contains unpaired parentheses (rare); - // redo matching with shortened line for correct indices - m = matchRx.FindStringSubmatchIndex(line[:m[0]+n]) - match = match[:n] + if strings.Contains(match, "://") { + m0, m1 := m[0], m[1] + for _, s := range []string{"()", "{}", "[]"} { + open, close := s[:1], s[1:] // E.g., "(" and ")" + // require opening parentheses before closing parentheses (#22285) + if i := strings.Index(match, close); i >= 0 && i < strings.Index(match, open) { + m1 = m0 + i + match = line[m0:m1] + } + // require balanced pairs of parentheses (#5043) + for i := 0; strings.Count(match, open) != strings.Count(match, close) && i < 10; i++ { + m1 = strings.LastIndexAny(line[:m1], s) + match = line[m0:m1] + } + } + if m1 != m[1] { + // redo matching with shortened line for correct indices + m = matchRx.FindStringSubmatchIndex(line[:m[0]+len(match)]) + } } // analyze match @@ -276,7 +273,7 @@ type block struct { lines []string } -var nonAlphaNumRx = regexp.MustCompile(`[^a-zA-Z0-9]`) +var nonAlphaNumRx = newLazyRE(`[^a-zA-Z0-9]`) func anchorID(line string) string { // Add a "hdr-" prefix to avoid conflicting with IDs used for package symbols. @@ -430,12 +427,14 @@ func ToText(w io.Writer, text string, indent, preIndent string, width int) { case opPara: // l.write will add leading newline if required for _, line := range b.lines { + line = convertQuotes(line) l.write(line) } l.flush() case opHead: w.Write(nl) for _, line := range b.lines { + line = convertQuotes(line) l.write(line + "\n") } l.flush() @@ -446,6 +445,7 @@ func ToText(w io.Writer, text string, indent, preIndent string, width int) { w.Write([]byte("\n")) } else { w.Write([]byte(preIndent)) + line = convertQuotes(line) w.Write([]byte(line)) } } diff --git a/libgo/go/go/doc/comment_test.go b/libgo/go/go/doc/comment_test.go index 0523ab899ee..e0adeb2f5cf 100644 --- a/libgo/go/go/doc/comment_test.go +++ b/libgo/go/go/doc/comment_test.go @@ -7,6 +7,7 @@ package doc import ( "bytes" "reflect" + "strings" "testing" ) @@ -150,6 +151,7 @@ func TestToText(t *testing.T) { var emphasizeTests = []struct { in, out string }{ + {"", ""}, {"http://[::1]:8080/foo.txt", `http://[::1]:8080/foo.txt`}, {"before (https://www.google.com) after", `before (https://www.google.com) after`}, {"before https://www.google.com:30/x/y/z:b::c. After", `before https://www.google.com:30/x/y/z:b::c. After`}, @@ -168,7 +170,13 @@ var emphasizeTests = []struct { {"Hello http://example.com/%2f/ /world.", `Hello http://example.com/%2f/ /world.`}, {"Lorem http: ipsum //host/path", "Lorem http: ipsum //host/path"}, {"javascript://is/not/linked", "javascript://is/not/linked"}, + {"http://foo", `http://foo`}, + {"art by [[https://www.example.com/person/][Person Name]]", `art by [[https://www.example.com/person/][Person Name]]`}, + {"please visit (http://golang.org/)", `please visit (http://golang.org/)`}, + {"please visit http://golang.org/hello())", `please visit http://golang.org/hello())`}, {"http://git.qemu.org/?p=qemu.git;a=blob;f=qapi-schema.json;hb=HEAD", `http://git.qemu.org/?p=qemu.git;a=blob;f=qapi-schema.json;hb=HEAD`}, + {"https://foo.bar/bal/x(])", `https://foo.bar/bal/x(])`}, // inner ] causes (]) to be cut off from URL + {"foo [ http://bar(])", `foo [ http://bar(])`}, // outer [ causes ]) to be cut off from URL } func TestEmphasize(t *testing.T) { @@ -182,32 +190,18 @@ func TestEmphasize(t *testing.T) { } } -var pairedParensPrefixLenTests = []struct { - in, out string -}{ - {"", ""}, - {"foo", "foo"}, - {"()", "()"}, - {"foo()", "foo()"}, - {"foo()()()", "foo()()()"}, - {"foo()((()()))", "foo()((()()))"}, - {"foo()((()()))bar", "foo()((()()))bar"}, - {"foo)", "foo"}, - {"foo))", "foo"}, - {"foo)))))", "foo"}, - {"(foo", ""}, - {"((foo", ""}, - {"(((((foo", ""}, - {"(foo)", "(foo)"}, - {"((((foo))))", "((((foo))))"}, - {"foo()())", "foo()()"}, - {"foo((()())", "foo"}, - {"foo((()())) (() foo ", "foo((()())) "}, -} - -func TestPairedParensPrefixLen(t *testing.T) { - for i, tt := range pairedParensPrefixLenTests { - if out := tt.in[:pairedParensPrefixLen(tt.in)]; out != tt.out { +func TestCommentEscape(t *testing.T) { + commentTests := []struct { + in, out string + }{ + {"typically invoked as ``go tool asm'',", "typically invoked as " + ldquo + "go tool asm" + rdquo + ","}, + {"For more detail, run ``go help test'' and ``go help testflag''", "For more detail, run " + ldquo + "go help test" + rdquo + " and " + ldquo + "go help testflag" + rdquo}, + } + for i, tt := range commentTests { + var buf strings.Builder + commentEscape(&buf, tt.in, true) + out := buf.String() + if out != tt.out { t.Errorf("#%d: mismatch\nhave: %q\nwant: %q", i, out, tt.out) } } diff --git a/libgo/go/go/doc/doc.go b/libgo/go/go/doc/doc.go index 3c3e28d48fb..d0d4d3265b6 100644 --- a/libgo/go/go/doc/doc.go +++ b/libgo/go/go/doc/doc.go @@ -79,13 +79,18 @@ type Note struct { type Mode int const ( - // extract documentation for all package-level declarations, - // not just exported ones + // AllDecls says to extract documentation for all package-level + // declarations, not just exported ones. AllDecls Mode = 1 << iota - // show all embedded methods, not just the ones of - // invisible (unexported) anonymous fields + // AllMethods says to show all embedded methods, not just the ones of + // invisible (unexported) anonymous fields. AllMethods + + // PreserveAST says to leave the AST unmodified. Originally, pieces of + // the AST such as function bodies were nil-ed out to save memory in + // godoc, but not all programs want that behavior. + PreserveAST ) // New computes the package documentation for the given package AST. diff --git a/libgo/go/go/doc/doc_test.go b/libgo/go/go/doc/doc_test.go index ad8ba5378f3..0b2d2b63ccc 100644 --- a/libgo/go/go/doc/doc_test.go +++ b/libgo/go/go/doc/doc_test.go @@ -40,7 +40,7 @@ func readTemplate(filename string) *template.Template { func nodeFmt(node interface{}, fset *token.FileSet) string { var buf bytes.Buffer printer.Fprint(&buf, fset, node) - return strings.Replace(strings.TrimSpace(buf.String()), "\n", "\n\t", -1) + return strings.ReplaceAll(strings.TrimSpace(buf.String()), "\n", "\n\t") } func synopsisFmt(s string) string { @@ -53,7 +53,7 @@ func synopsisFmt(s string) string { } s = strings.TrimSpace(s) + " ..." } - return "// " + strings.Replace(s, "\n", " ", -1) + return "// " + strings.ReplaceAll(s, "\n", " ") } func indentFmt(indent, s string) string { @@ -62,7 +62,7 @@ func indentFmt(indent, s string) string { end = "\n" s = s[:len(s)-1] } - return indent + strings.Replace(s, "\n", "\n"+indent, -1) + end + return indent + strings.ReplaceAll(s, "\n", "\n"+indent) + end } func isGoFile(fi os.FileInfo) bool { @@ -144,3 +144,12 @@ func Test(t *testing.T) { test(t, AllDecls) test(t, AllMethods) } + +func TestAnchorID(t *testing.T) { + const in = "Important Things 2 Know & Stuff" + const want = "hdr-Important_Things_2_Know___Stuff" + got := anchorID(in) + if got != want { + t.Errorf("anchorID(%q) = %q; want %q", in, got, want) + } +} diff --git a/libgo/go/go/doc/example.go b/libgo/go/go/doc/example.go index 5b40bb0fb25..81956f2fdbf 100644 --- a/libgo/go/go/doc/example.go +++ b/libgo/go/go/doc/example.go @@ -68,6 +68,9 @@ func Examples(files ...*ast.File) []*Example { if !isTest(name, "Example") { continue } + if f.Body == nil { // ast.File.Body nil dereference (see issue 28044) + continue + } var doc string if f.Doc != nil { doc = f.Doc.Text() @@ -216,6 +219,18 @@ func playExample(file *ast.File, f *ast.FuncDecl) *ast.File { for i := 0; i < len(depDecls); i++ { switch d := depDecls[i].(type) { case *ast.FuncDecl: + // Inspect types of parameters and results. See #28492. + if d.Type.Params != nil { + for _, p := range d.Type.Params.List { + ast.Inspect(p.Type, inspectFunc) + } + } + if d.Type.Results != nil { + for _, r := range d.Type.Results.List { + ast.Inspect(r.Type, inspectFunc) + } + } + ast.Inspect(d.Body, inspectFunc) case *ast.GenDecl: for _, spec := range d.Specs { @@ -253,6 +268,11 @@ func playExample(file *ast.File, f *ast.FuncDecl) *ast.File { if err != nil { continue } + if p == "syscall/js" { + // We don't support examples that import syscall/js, + // because the package syscall/js is not available in the playground. + return nil + } n := path.Base(p) if s.Name != nil { n = s.Name.Name @@ -406,6 +426,9 @@ func stripOutputComment(body *ast.BlockStmt, comments []*ast.CommentGroup) (*ast // lastComment returns the last comment inside the provided block. func lastComment(b *ast.BlockStmt, c []*ast.CommentGroup) (i int, last *ast.CommentGroup) { + if b == nil { + return + } pos, end := b.Pos(), b.End() for j, cg := range c { if cg.Pos() < pos { diff --git a/libgo/go/go/doc/example_test.go b/libgo/go/go/doc/example_test.go index 552a51bf742..74fd10626d2 100644 --- a/libgo/go/go/doc/example_test.go +++ b/libgo/go/go/doc/example_test.go @@ -351,6 +351,103 @@ func TestExamplesWholeFile(t *testing.T) { } } +const exampleInspectSignature = `package foo_test + +import ( + "bytes" + "io" +) + +func getReader() io.Reader { return nil } + +func do(b bytes.Reader) {} + +func Example() { + getReader() + do() + // Output: +} + +func ExampleIgnored() { +} +` + +const exampleInspectSignatureOutput = `package main + +import ( + "bytes" + "io" +) + +func getReader() io.Reader { return nil } + +func do(b bytes.Reader) {} + +func main() { + getReader() + do() +} +` + +func TestExampleInspectSignature(t *testing.T) { + // Verify that "bytes" and "io" are imported. See issue #28492. + fset := token.NewFileSet() + file, err := parser.ParseFile(fset, "test.go", strings.NewReader(exampleInspectSignature), parser.ParseComments) + if err != nil { + t.Fatal(err) + } + es := doc.Examples(file) + if len(es) != 2 { + t.Fatalf("wrong number of examples; got %d want 2", len(es)) + } + // We are interested in the first example only. + e := es[0] + if e.Name != "" { + t.Errorf("got Name == %q, want %q", e.Name, "") + } + if g, w := formatFile(t, fset, e.Play), exampleInspectSignatureOutput; g != w { + t.Errorf("got Play == %q, want %q", g, w) + } + if g, w := e.Output, ""; g != w { + t.Errorf("got Output == %q, want %q", g, w) + } +} + +const exampleEmpty = ` +package p +func Example() {} +func Example_a() +` + +const exampleEmptyOutput = `package main + +func main() {} +func main() +` + +func TestExampleEmpty(t *testing.T) { + fset := token.NewFileSet() + file, err := parser.ParseFile(fset, "test.go", strings.NewReader(exampleEmpty), parser.ParseComments) + if err != nil { + t.Fatal(err) + } + + es := doc.Examples(file) + if len(es) != 1 { + t.Fatalf("wrong number of examples; got %d want 1", len(es)) + } + e := es[0] + if e.Name != "" { + t.Errorf("got Name == %q, want %q", e.Name, "") + } + if g, w := formatFile(t, fset, e.Play), exampleEmptyOutput; g != w { + t.Errorf("got Play == %q, want %q", g, w) + } + if g, w := e.Output, ""; g != w { + t.Errorf("got Output == %q, want %q", g, w) + } +} + func formatFile(t *testing.T, fset *token.FileSet, n *ast.File) string { if n == nil { return "" diff --git a/libgo/go/go/doc/lazyre.go b/libgo/go/go/doc/lazyre.go new file mode 100644 index 00000000000..3fd97d42de6 --- /dev/null +++ b/libgo/go/go/doc/lazyre.go @@ -0,0 +1,51 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package doc + +import ( + "os" + "regexp" + "strings" + "sync" +) + +type lazyRE struct { + str string + once sync.Once + rx *regexp.Regexp +} + +func (r *lazyRE) re() *regexp.Regexp { + r.once.Do(r.build) + return r.rx +} + +func (r *lazyRE) build() { + r.rx = regexp.MustCompile(r.str) + r.str = "" +} + +func (r *lazyRE) FindStringSubmatchIndex(s string) []int { + return r.re().FindStringSubmatchIndex(s) +} + +func (r *lazyRE) ReplaceAllString(src, repl string) string { + return r.re().ReplaceAllString(src, repl) +} + +func (r *lazyRE) MatchString(s string) bool { + return r.re().MatchString(s) +} + +var inTest = len(os.Args) > 0 && strings.HasSuffix(strings.TrimSuffix(os.Args[0], ".exe"), ".test") + +func newLazyRE(str string) *lazyRE { + lr := &lazyRE{str: str} + if inTest { + // In tests, always compile the regexps early. + lr.re() + } + return lr +} diff --git a/libgo/go/go/doc/reader.go b/libgo/go/go/doc/reader.go index 21c02920aba..6db5c21c4a2 100644 --- a/libgo/go/go/doc/reader.go +++ b/libgo/go/go/doc/reader.go @@ -7,7 +7,6 @@ package doc import ( "go/ast" "go/token" - "regexp" "sort" "strconv" ) @@ -37,9 +36,10 @@ func recvString(recv ast.Expr) string { // set creates the corresponding Func for f and adds it to mset. // If there are multiple f's with the same name, set keeps the first -// one with documentation; conflicts are ignored. +// one with documentation; conflicts are ignored. The boolean +// specifies whether to leave the AST untouched. // -func (mset methodSet) set(f *ast.FuncDecl) { +func (mset methodSet) set(f *ast.FuncDecl, preserveAST bool) { name := f.Name.Name if g := mset[name]; g != nil && g.Doc != "" { // A function with the same name has already been registered; @@ -66,7 +66,9 @@ func (mset methodSet) set(f *ast.FuncDecl) { Recv: recv, Orig: recv, } - f.Doc = nil // doc consumed - remove from AST + if !preserveAST { + f.Doc = nil // doc consumed - remove from AST + } } // add adds method m to the method set; m is ignored if the method set @@ -79,7 +81,7 @@ func (mset methodSet) add(m *Func) { mset[m.Name] = m return } - if old != nil && m.Level == old.Level { + if m.Level == old.Level { // conflict - mark it using a method with nil Decl mset[m.Name] = &Func{ Name: m.Name, @@ -300,8 +302,9 @@ func (r *reader) readValue(decl *ast.GenDecl) { Decl: decl, order: r.order, }) - decl.Doc = nil // doc consumed - remove from AST - + if r.mode&PreserveAST == 0 { + decl.Doc = nil // doc consumed - remove from AST + } // Note: It's important that the order used here is global because the cleanupTypes // methods may move values associated with types back into the global list. If the // order is list-specific, sorting is not deterministic because the same order value @@ -340,12 +343,14 @@ func (r *reader) readType(decl *ast.GenDecl, spec *ast.TypeSpec) { // compute documentation doc := spec.Doc - spec.Doc = nil // doc consumed - remove from AST if doc == nil { // no doc associated with the spec, use the declaration doc, if any doc = decl.Doc } - decl.Doc = nil // doc consumed - remove from AST + if r.mode&PreserveAST == 0 { + spec.Doc = nil // doc consumed - remove from AST + decl.Doc = nil // doc consumed - remove from AST + } typ.doc = doc.Text() // record anonymous fields (they may contribute methods) @@ -360,11 +365,19 @@ func (r *reader) readType(decl *ast.GenDecl, spec *ast.TypeSpec) { } } +// isPredeclared reports whether n denotes a predeclared type. +// +func (r *reader) isPredeclared(n string) bool { + return predeclaredTypes[n] && r.types[n] == nil +} + // readFunc processes a func or method declaration. // func (r *reader) readFunc(fun *ast.FuncDecl) { - // strip function body - fun.Body = nil + // strip function body if requested. + if r.mode&PreserveAST == 0 { + fun.Body = nil + } // associate methods with the receiver type, if any if fun.Recv != nil { @@ -381,7 +394,7 @@ func (r *reader) readFunc(fun *ast.FuncDecl) { return } if typ := r.lookupType(recvTypeName); typ != nil { - typ.methods.set(fun) + typ.methods.set(fun, r.mode&PreserveAST != 0) } // otherwise ignore the method // TODO(gri): There may be exported methods of non-exported types @@ -391,43 +404,44 @@ func (r *reader) readFunc(fun *ast.FuncDecl) { return } - // Associate factory functions with the first visible result type, if that - // is the only type returned. + // Associate factory functions with the first visible result type, as long as + // others are predeclared types. if fun.Type.Results.NumFields() >= 1 { var typ *namedType // type to associate the function with numResultTypes := 0 for _, res := range fun.Type.Results.List { - // exactly one (named or anonymous) result associated - // with the first type in result signature (there may - // be more than one result) factoryType := res.Type if t, ok := factoryType.(*ast.ArrayType); ok { // We consider functions that return slices or arrays of type // T (or pointers to T) as factory functions of T. factoryType = t.Elt } - if n, imp := baseTypeName(factoryType); !imp && r.isVisible(n) { + if n, imp := baseTypeName(factoryType); !imp && r.isVisible(n) && !r.isPredeclared(n) { if t := r.lookupType(n); t != nil { typ = t numResultTypes++ + if numResultTypes > 1 { + break + } } } } - // If there is exactly one result type, associate the function with that type. + // If there is exactly one result type, + // associate the function with that type. if numResultTypes == 1 { - typ.funcs.set(fun) + typ.funcs.set(fun, r.mode&PreserveAST != 0) return } } // just an ordinary function - r.funcs.set(fun) + r.funcs.set(fun, r.mode&PreserveAST != 0) } var ( - noteMarker = `([A-Z][A-Z]+)\(([^)]+)\):?` // MARKER(uid), MARKER at least 2 chars, uid at least 1 char - noteMarkerRx = regexp.MustCompile(`^[ \t]*` + noteMarker) // MARKER(uid) at text start - noteCommentRx = regexp.MustCompile(`^/[/*][ \t]*` + noteMarker) // MARKER(uid) at comment start + noteMarker = `([A-Z][A-Z]+)\(([^)]+)\):?` // MARKER(uid), MARKER at least 2 chars, uid at least 1 char + noteMarkerRx = newLazyRE(`^[ \t]*` + noteMarker) // MARKER(uid) at text start + noteCommentRx = newLazyRE(`^/[/*][ \t]*` + noteMarker) // MARKER(uid) at comment start ) // readNote collects a single note from a sequence of comments. @@ -482,10 +496,12 @@ func (r *reader) readFile(src *ast.File) { // add package documentation if src.Doc != nil { r.readDoc(src.Doc) - src.Doc = nil // doc consumed - remove from AST + if r.mode&PreserveAST == 0 { + src.Doc = nil // doc consumed - remove from AST + } } - // add all declarations + // add all declarations but for functions which are processed in a separate pass for _, decl := range src.Decls { switch d := decl.(type) { case *ast.GenDecl: @@ -539,14 +555,14 @@ func (r *reader) readFile(src *ast.File) { } } } - case *ast.FuncDecl: - r.readFunc(d) } } // collect MARKER(...): annotations r.readNotes(src.Comments) - src.Comments = nil // consumed unassociated comments - remove from AST + if r.mode&PreserveAST == 0 { + src.Comments = nil // consumed unassociated comments - remove from AST + } } func (r *reader) readPackage(pkg *ast.Package, mode Mode) { @@ -575,6 +591,15 @@ func (r *reader) readPackage(pkg *ast.Package, mode Mode) { } r.readFile(f) } + + // process functions now that we have better type information + for _, f := range pkg.Files { + for _, decl := range f.Decls { + if d, ok := decl.(*ast.FuncDecl); ok { + r.readFunc(d) + } + } + } } // ---------------------------------------------------------------------------- diff --git a/libgo/go/go/doc/synopsis.go b/libgo/go/go/doc/synopsis.go index c90080b7cc1..3fa1616cd14 100644 --- a/libgo/go/go/doc/synopsis.go +++ b/libgo/go/go/doc/synopsis.go @@ -72,6 +72,7 @@ func Synopsis(s string) string { return "" } } + s = convertQuotes(s) return s } diff --git a/libgo/go/go/doc/synopsis_test.go b/libgo/go/go/doc/synopsis_test.go index 59b253cb8dc..3f443dc7578 100644 --- a/libgo/go/go/doc/synopsis_test.go +++ b/libgo/go/go/doc/synopsis_test.go @@ -35,6 +35,7 @@ var tests = []struct { {"All Rights reserved. Package foo does bar.", 20, ""}, {"All rights reserved. Package foo does bar.", 20, ""}, {"Authors: foo@bar.com. Package foo does bar.", 21, ""}, + {"typically invoked as ``go tool asm'',", 37, "typically invoked as " + ulquo + "go tool asm" + urquo + ","}, } func TestSynopsis(t *testing.T) { diff --git a/libgo/go/go/doc/testdata/issue12839.0.golden b/libgo/go/go/doc/testdata/issue12839.0.golden index 76c28555602..6b59774fb93 100644 --- a/libgo/go/go/doc/testdata/issue12839.0.golden +++ b/libgo/go/go/doc/testdata/issue12839.0.golden @@ -14,9 +14,15 @@ FUNCTIONS // F1 should not be associated with T1 func F1() (*T1, *T2) + // F10 should not be associated with T1. + func F10() (T1, T2, error) + // F4 should not be associated with a type (same as F1) func F4() (a T1, b T2) + // F9 should not be associated with T1. + func F9() (int, T1, T2) + TYPES // @@ -28,6 +34,18 @@ TYPES // F3 should be associated with T1 because b.T3 is from a ... func F3() (a T1, b p.T3) + // F5 should be associated with T1. + func F5() (T1, error) + + // F6 should be associated with T1. + func F6() (*T1, error) + + // F7 should be associated with T1. + func F7() (T1, string) + + // F8 should be associated with T1. + func F8() (int, T1, string) + // type T2 struct{} diff --git a/libgo/go/go/doc/testdata/issue12839.1.golden b/libgo/go/go/doc/testdata/issue12839.1.golden index b0a327ffd64..4b9b9f64770 100644 --- a/libgo/go/go/doc/testdata/issue12839.1.golden +++ b/libgo/go/go/doc/testdata/issue12839.1.golden @@ -14,9 +14,15 @@ FUNCTIONS // F1 should not be associated with T1 func F1() (*T1, *T2) + // F10 should not be associated with T1. + func F10() (T1, T2, error) + // F4 should not be associated with a type (same as F1) func F4() (a T1, b T2) + // F9 should not be associated with T1. + func F9() (int, T1, T2) + TYPES // @@ -28,6 +34,18 @@ TYPES // F3 should be associated with T1 because b.T3 is from a ... func F3() (a T1, b p.T3) + // F5 should be associated with T1. + func F5() (T1, error) + + // F6 should be associated with T1. + func F6() (*T1, error) + + // F7 should be associated with T1. + func F7() (T1, string) + + // F8 should be associated with T1. + func F8() (int, T1, string) + // func (t T1) hello() string diff --git a/libgo/go/go/doc/testdata/issue12839.2.golden b/libgo/go/go/doc/testdata/issue12839.2.golden index 76c28555602..6b59774fb93 100644 --- a/libgo/go/go/doc/testdata/issue12839.2.golden +++ b/libgo/go/go/doc/testdata/issue12839.2.golden @@ -14,9 +14,15 @@ FUNCTIONS // F1 should not be associated with T1 func F1() (*T1, *T2) + // F10 should not be associated with T1. + func F10() (T1, T2, error) + // F4 should not be associated with a type (same as F1) func F4() (a T1, b T2) + // F9 should not be associated with T1. + func F9() (int, T1, T2) + TYPES // @@ -28,6 +34,18 @@ TYPES // F3 should be associated with T1 because b.T3 is from a ... func F3() (a T1, b p.T3) + // F5 should be associated with T1. + func F5() (T1, error) + + // F6 should be associated with T1. + func F6() (*T1, error) + + // F7 should be associated with T1. + func F7() (T1, string) + + // F8 should be associated with T1. + func F8() (int, T1, string) + // type T2 struct{} diff --git a/libgo/go/go/doc/testdata/issue12839.go b/libgo/go/go/doc/testdata/issue12839.go index 500d49511b5..51c7ac12681 100644 --- a/libgo/go/go/doc/testdata/issue12839.go +++ b/libgo/go/go/doc/testdata/issue12839.go @@ -5,6 +5,7 @@ // Package issue12839 is a go/doc test to test association of a function // that returns multiple types. // See golang.org/issue/12839. +// (See also golang.org/issue/27928.) package issue12839 import "p" @@ -36,3 +37,33 @@ func F3() (a T1, b p.T3) { func F4() (a T1, b T2) { return T1{}, T2{} } + +// F5 should be associated with T1. +func F5() (T1, error) { + return T1{}, nil +} + +// F6 should be associated with T1. +func F6() (*T1, error) { + return &T1{}, nil +} + +// F7 should be associated with T1. +func F7() (T1, string) { + return T1{}, nil +} + +// F8 should be associated with T1. +func F8() (int, T1, string) { + return 0, T1{}, nil +} + +// F9 should not be associated with T1. +func F9() (int, T1, T2) { + return 0, T1{}, T2{} +} + +// F10 should not be associated with T1. +func F10() (T1, T2, error) { + return T1{}, T2{}, nil +} diff --git a/libgo/go/go/format/benchmark_test.go b/libgo/go/go/format/benchmark_test.go new file mode 100644 index 00000000000..7bd45c0e95b --- /dev/null +++ b/libgo/go/go/format/benchmark_test.go @@ -0,0 +1,91 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file provides a simple framework to add benchmarks +// based on generated input (source) files. + +package format_test + +import ( + "bytes" + "flag" + "fmt" + "go/format" + "io/ioutil" + "testing" +) + +var debug = flag.Bool("debug", false, "write .src files containing formatting input; for debugging") + +// array1 generates an array literal with n elements of the form: +// +// var _ = [...]byte{ +// // 0 +// 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, +// 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, +// 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, +// 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, +// 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, +// // 40 +// 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, +// 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, +// ... +// +func array1(buf *bytes.Buffer, n int) { + buf.WriteString("var _ = [...]byte{\n") + for i := 0; i < n; { + if i%10 == 0 { + fmt.Fprintf(buf, "\t// %d\n", i) + } + buf.WriteByte('\t') + for j := 0; j < 8; j++ { + fmt.Fprintf(buf, "0x%02x, ", byte(i)) + i++ + } + buf.WriteString("\n") + } + buf.WriteString("}\n") +} + +var tests = []struct { + name string + gen func(*bytes.Buffer, int) + n int +}{ + {"array1", array1, 10000}, + // add new test cases here as needed +} + +func BenchmarkFormat(b *testing.B) { + var src bytes.Buffer + for _, t := range tests { + src.Reset() + src.WriteString("package p\n") + t.gen(&src, t.n) + data := src.Bytes() + + if *debug { + filename := t.name + ".src" + err := ioutil.WriteFile(filename, data, 0660) + if err != nil { + b.Fatalf("couldn't write %s: %v", filename, err) + } + } + + b.Run(fmt.Sprintf("%s-%d", t.name, t.n), func(b *testing.B) { + b.SetBytes(int64(len(data))) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + var err error + sink, err = format.Source(data) + if err != nil { + b.Fatal(err) + } + } + }) + } +} + +var sink []byte diff --git a/libgo/go/go/importer/importer.go b/libgo/go/go/importer/importer.go index f99dd65f3de..7882963506c 100644 --- a/libgo/go/go/importer/importer.go +++ b/libgo/go/go/importer/importer.go @@ -21,7 +21,7 @@ import ( // a given import path, or an error if no matching package is found. type Lookup func(path string) (io.ReadCloser, error) -// For returns an Importer for importing from installed packages +// ForCompiler returns an Importer for importing from installed packages // for the compilers "gc" and "gccgo", or for importing directly // from the source if the compiler argument is "source". In this // latter case, importing may fail under circumstances where the @@ -40,10 +40,11 @@ type Lookup func(path string) (io.ReadCloser, error) // (not relative or absolute ones); it is assumed that the translation // to canonical import paths is being done by the client of the // importer. -func For(compiler string, lookup Lookup) types.Importer { +func ForCompiler(fset *token.FileSet, compiler string, lookup Lookup) types.Importer { switch compiler { case "gc": return &gcimports{ + fset: fset, packages: make(map[string]*types.Package), lookup: lookup, } @@ -68,13 +69,21 @@ func For(compiler string, lookup Lookup) types.Importer { panic("source importer for custom import path lookup not supported (issue #13847).") } - return srcimporter.New(&build.Default, token.NewFileSet(), make(map[string]*types.Package)) + return srcimporter.New(&build.Default, fset, make(map[string]*types.Package)) } // compiler not supported return nil } +// For calls ForCompiler with a new FileSet. +// +// Deprecated: use ForCompiler, which populates a FileSet +// with the positions of objects created by the importer. +func For(compiler string, lookup Lookup) types.Importer { + return ForCompiler(token.NewFileSet(), compiler, lookup) +} + // Default returns an Importer for the compiler that built the running binary. // If available, the result implements types.ImporterFrom. func Default() types.Importer { @@ -84,6 +93,7 @@ func Default() types.Importer { // gc importer type gcimports struct { + fset *token.FileSet packages map[string]*types.Package lookup Lookup } @@ -96,7 +106,7 @@ func (m *gcimports) ImportFrom(path, srcDir string, mode types.ImportMode) (*typ if mode != 0 { panic("mode must be 0") } - return gcimporter.Import(m.packages, path, srcDir, m.lookup) + return gcimporter.Import(m.fset, m.packages, path, srcDir, m.lookup) } // gccgo importer diff --git a/libgo/go/go/importer/importer_test.go b/libgo/go/go/importer/importer_test.go index 56e83136fb1..ff6e12c0da5 100644 --- a/libgo/go/go/importer/importer_test.go +++ b/libgo/go/go/importer/importer_test.go @@ -5,15 +5,18 @@ package importer import ( + "go/token" "internal/testenv" "io" + "io/ioutil" "os" "os/exec" + "runtime" "strings" "testing" ) -func TestFor(t *testing.T) { +func TestForCompiler(t *testing.T) { testenv.MustHaveGoBuild(t) const thePackage = "math/big" @@ -32,8 +35,10 @@ func TestFor(t *testing.T) { t.Skip("golang.org/issue/22500") } + fset := token.NewFileSet() + t.Run("LookupDefault", func(t *testing.T) { - imp := For(compiler, nil) + imp := ForCompiler(fset, compiler, nil) pkg, err := imp.Import(thePackage) if err != nil { t.Fatal(err) @@ -41,6 +46,21 @@ func TestFor(t *testing.T) { if pkg.Path() != thePackage { t.Fatalf("Path() = %q, want %q", pkg.Path(), thePackage) } + + // Check that the fileset positions are accurate. + // https://github.com/golang/go#28995 + mathBigInt := pkg.Scope().Lookup("Int") + posn := fset.Position(mathBigInt.Pos()) // "$GOROOT/src/math/big/int.go:25:1" + filename := strings.Replace(posn.Filename, "$GOROOT", runtime.GOROOT(), 1) + data, err := ioutil.ReadFile(filename) + if err != nil { + t.Fatalf("can't read file containing declaration of math/big.Int: %v", err) + } + lines := strings.Split(string(data), "\n") + if posn.Line > len(lines) || !strings.HasPrefix(lines[posn.Line-1], "type Int") { + t.Fatalf("Object %v position %s does not contain its declaration", + mathBigInt, posn) + } }) t.Run("LookupCustom", func(t *testing.T) { @@ -54,7 +74,7 @@ func TestFor(t *testing.T) { } return f, nil } - imp := For(compiler, lookup) + imp := ForCompiler(fset, compiler, lookup) pkg, err := imp.Import("math/bigger") if err != nil { t.Fatal(err) diff --git a/libgo/go/go/internal/gccgoimporter/ar.go b/libgo/go/go/internal/gccgoimporter/ar.go index ebd08b8f359..443aa26a0cd 100644 --- a/libgo/go/go/internal/gccgoimporter/ar.go +++ b/libgo/go/go/internal/gccgoimporter/ar.go @@ -9,6 +9,7 @@ import ( "debug/elf" "errors" "fmt" + "internal/xcoff" "io" "strconv" "strings" @@ -65,13 +66,13 @@ func arExportData(archive io.ReadSeeker) (io.ReadSeeker, error) { case armagt: return nil, errors.New("unsupported thin archive") case armagb: - return nil, errors.New("unsupported AIX big archive") + return aixBigArExportData(archive) default: return nil, fmt.Errorf("unrecognized archive file format %q", buf[:]) } } -// standardArExportData returns export data form a standard archive. +// standardArExportData returns export data from a standard archive. func standardArExportData(archive io.ReadSeeker) (io.ReadSeeker, error) { off := int64(len(armag)) for { @@ -126,6 +127,28 @@ func elfFromAr(member *io.SectionReader) (io.ReadSeeker, error) { return sec.Open(), nil } +// aixBigArExportData returns export data from an AIX big archive. +func aixBigArExportData(archive io.ReadSeeker) (io.ReadSeeker, error) { + archiveAt := readerAtFromSeeker(archive) + arch, err := xcoff.NewArchive(archiveAt) + if err != nil { + return nil, err + } + + for _, mem := range arch.Members { + f, err := arch.GetFile(mem.Name) + if err != nil { + return nil, err + } + sdat := f.CSect(".go_export") + if sdat != nil { + return bytes.NewReader(sdat), nil + } + } + + return nil, fmt.Errorf(".go_export not found in this archive") +} + // readerAtFromSeeker turns an io.ReadSeeker into an io.ReaderAt. // This is only safe because there won't be any concurrent seeks // while this code is executing. diff --git a/libgo/go/go/internal/gccgoimporter/gccgoinstallation.go b/libgo/go/go/internal/gccgoimporter/gccgoinstallation.go index 622dfc8b696..8fc7ce32321 100644 --- a/libgo/go/go/internal/gccgoimporter/gccgoinstallation.go +++ b/libgo/go/go/internal/gccgoimporter/gccgoinstallation.go @@ -26,8 +26,10 @@ type GccgoInstallation struct { } // Ask the driver at the given path for information for this GccgoInstallation. -func (inst *GccgoInstallation) InitFromDriver(gccgoPath string) (err error) { - cmd := exec.Command(gccgoPath, "-###", "-S", "-x", "go", "-") +// The given arguments are passed directly to the call of the driver. +func (inst *GccgoInstallation) InitFromDriver(gccgoPath string, args ...string) (err error) { + argv := append([]string{"-###", "-S", "-x", "go", "-"}, args...) + cmd := exec.Command(gccgoPath, argv...) stderr, err := cmd.StderrPipe() if err != nil { return @@ -55,7 +57,8 @@ func (inst *GccgoInstallation) InitFromDriver(gccgoPath string) (err error) { } } - stdout, err := exec.Command(gccgoPath, "-dumpversion").Output() + argv = append([]string{"-dumpversion"}, args...) + stdout, err := exec.Command(gccgoPath, argv...).Output() if err != nil { return } diff --git a/libgo/go/go/internal/gccgoimporter/gccgoinstallation_test.go b/libgo/go/go/internal/gccgoimporter/gccgoinstallation_test.go index 299910de284..745ef900f6b 100644 --- a/libgo/go/go/internal/gccgoimporter/gccgoinstallation_test.go +++ b/libgo/go/go/internal/gccgoimporter/gccgoinstallation_test.go @@ -6,10 +6,14 @@ package gccgoimporter import ( "go/types" - "runtime" "testing" ) +// importablePackages is a list of packages that we verify that we can +// import. This should be all standard library packages in all relevant +// versions of gccgo. Note that since gccgo follows a different release +// cycle, and since different systems have different versions installed, +// we can't use the last-two-versions rule of the gc toolchain. var importablePackages = [...]string{ "archive/tar", "archive/zip", @@ -56,7 +60,7 @@ var importablePackages = [...]string{ "encoding/binary", "encoding/csv", "encoding/gob", - "encoding", + // "encoding", // Added in GCC 4.9. "encoding/hex", "encoding/json", "encoding/pem", @@ -68,7 +72,7 @@ var importablePackages = [...]string{ "go/ast", "go/build", "go/doc", - "go/format", + // "go/format", // Added in GCC 4.8. "go/parser", "go/printer", "go/scanner", @@ -81,7 +85,7 @@ var importablePackages = [...]string{ "html", "html/template", "image/color", - "image/color/palette", + // "image/color/palette", // Added in GCC 4.9. "image/draw", "image/gif", "image", @@ -100,7 +104,7 @@ var importablePackages = [...]string{ "mime/multipart", "net", "net/http/cgi", - "net/http/cookiejar", + // "net/http/cookiejar", // Added in GCC 4.8. "net/http/fcgi", "net/http", "net/http/httptest", @@ -144,9 +148,9 @@ var importablePackages = [...]string{ } func TestInstallationImporter(t *testing.T) { - // This test relies on gccgo being around, which it most likely will be if we - // were compiled with gccgo. - if runtime.Compiler != "gccgo" { + // This test relies on gccgo being around. + gpath := gccgoPath() + if gpath == "" { t.Skip("This test needs gccgo") } @@ -155,7 +159,7 @@ func TestInstallationImporter(t *testing.T) { t.Skip("gccgo is not necessarily available") var inst GccgoInstallation - err := inst.InitFromDriver("gccgo") + err := inst.InitFromDriver(gpath) if err != nil { t.Fatal(err) } @@ -180,12 +184,12 @@ func TestInstallationImporter(t *testing.T) { // Test for certain specific entities in the imported data. for _, test := range [...]importerTest{ - {pkgpath: "io", name: "Reader", want: "type Reader interface{Read(p []uint8) (n int, err error)}"}, + {pkgpath: "io", name: "Reader", want: "type Reader interface{Read(p []byte) (n int, err error)}"}, {pkgpath: "io", name: "ReadWriter", want: "type ReadWriter interface{Reader; Writer}"}, {pkgpath: "math", name: "Pi", want: "const Pi untyped float"}, {pkgpath: "math", name: "Sin", want: "func Sin(x float64) float64"}, {pkgpath: "sort", name: "Ints", want: "func Ints(a []int)"}, - {pkgpath: "unsafe", name: "Pointer", want: "type Pointer unsafe.Pointer"}, + {pkgpath: "unsafe", name: "Pointer", want: "type Pointer"}, } { runImporterTest(t, imp, nil, &test) } diff --git a/libgo/go/go/internal/gccgoimporter/importer.go b/libgo/go/go/internal/gccgoimporter/importer.go index d3ce10cb0ca..ff484a72fc9 100644 --- a/libgo/go/go/internal/gccgoimporter/importer.go +++ b/libgo/go/go/internal/gccgoimporter/importer.go @@ -8,9 +8,9 @@ package gccgoimporter // import "go/internal/gccgoimporter" import ( "bytes" "debug/elf" - "debug/xcoff" "fmt" "go/types" + "internal/xcoff" "io" "os" "path/filepath" @@ -99,7 +99,7 @@ func openExportFile(fpath string) (reader io.ReadSeeker, closer io.Closer, err e reader = f return - case archiveMagic: + case archiveMagic, aixbigafMagic: reader, err = arExportData(f) return @@ -129,6 +129,7 @@ func openExportFile(fpath string) (reader io.ReadSeeker, closer io.Closer, err e return } + err = fmt.Errorf("%s: unrecognized file format", fpath) return } diff --git a/libgo/go/go/internal/gccgoimporter/importer_test.go b/libgo/go/go/internal/gccgoimporter/importer_test.go index 5a699687bd4..7a21c5f2f48 100644 --- a/libgo/go/go/internal/gccgoimporter/importer_test.go +++ b/libgo/go/go/internal/gccgoimporter/importer_test.go @@ -11,7 +11,8 @@ import ( "os" "os/exec" "path/filepath" - "runtime" + "regexp" + "strconv" "testing" ) @@ -53,9 +54,6 @@ func runImporterTest(t *testing.T, imp Importer, initmap map[*types.Package]Init // Check that the package's own init function has the package's priority for _, pkginit := range initdata.Inits { if pkginit.InitFunc == test.wantinits[0] { - if initdata.Priority != pkginit.Priority { - t.Errorf("%s: got self priority %d; want %d", test.pkgpath, pkginit.Priority, initdata.Priority) - } found = true break } @@ -65,27 +63,11 @@ func runImporterTest(t *testing.T, imp Importer, initmap map[*types.Package]Init t.Errorf("%s: could not find expected function %q", test.pkgpath, test.wantinits[0]) } - // Each init function in the list other than the first one is a - // dependency of the function immediately before it. Check that - // the init functions appear in descending priority order. - priority := initdata.Priority - for _, wantdepinit := range test.wantinits[1:] { - found = false - for _, pkginit := range initdata.Inits { - if pkginit.InitFunc == wantdepinit { - if priority <= pkginit.Priority { - t.Errorf("%s: got dep priority %d; want less than %d", test.pkgpath, pkginit.Priority, priority) - } - found = true - priority = pkginit.Priority - break - } - } - - if !found { - t.Errorf("%s: could not find expected function %q", test.pkgpath, wantdepinit) - } - } + // FIXME: the original version of this test was written against + // the v1 export data scheme for capturing init functions, so it + // verified the priority values. We moved away from the priority + // scheme some time ago; it is not clear how much work it would be + // to validate the new init export data. } } @@ -100,15 +82,19 @@ var importerTests = [...]importerTest{ {pkgpath: "time", name: "Nanosecond", want: "const Nanosecond Duration", wantval: "1"}, {pkgpath: "unicode", name: "IsUpper", want: "func IsUpper(r rune) bool"}, {pkgpath: "unicode", name: "MaxRune", want: "const MaxRune untyped rune", wantval: "1114111"}, - {pkgpath: "imports", wantinits: []string{"imports..import", "fmt..import", "math..import"}}, + {pkgpath: "imports", wantinits: []string{"imports..import", "fmt..import"}}, {pkgpath: "importsar", name: "Hello", want: "var Hello string"}, - {pkgpath: "alias", name: "IntAlias2", want: "type IntAlias2 = Int"}, + {pkgpath: "aliases", name: "A14", want: "type A14 = func(int, T0) chan T2"}, + {pkgpath: "aliases", name: "C0", want: "type C0 struct{f1 C1; f2 C1}"}, {pkgpath: "escapeinfo", name: "NewT", want: "func NewT(data []byte) *T"}, + {pkgpath: "issue27856", name: "M", want: "type M struct{E F}"}, + {pkgpath: "v1reflect", name: "Type", want: "type Type interface{Align() int; AssignableTo(u Type) bool; Bits() int; ChanDir() ChanDir; Elem() Type; Field(i int) StructField; FieldAlign() int; FieldByIndex(index []int) StructField; FieldByName(name string) (StructField, bool); FieldByNameFunc(match func(string) bool) (StructField, bool); Implements(u Type) bool; In(i int) Type; IsVariadic() bool; Key() Type; Kind() Kind; Len() int; Method(int) Method; MethodByName(string) (Method, bool); Name() string; NumField() int; NumIn() int; NumMethod() int; NumOut() int; Out(i int) Type; PkgPath() string; Size() uintptr; String() string; common() *commonType; rawString() string; runtimeType() *runtimeType; uncommon() *uncommonType}"}, + {pkgpath: "nointerface", name: "I", want: "type I int"}, + {pkgpath: "issue29198", name: "FooServer", want: "type FooServer struct{FooServer *FooServer; user string; ctx context.Context}"}, } func TestGoxImporter(t *testing.T) { - testenv.MustHaveGoBuild(t) - + testenv.MustHaveExec(t) // this is to skip nacl, js initmap := make(map[*types.Package]InitData) imp := GetImporter([]string{"testdata"}, initmap) @@ -117,15 +103,46 @@ func TestGoxImporter(t *testing.T) { } } -func TestObjImporter(t *testing.T) { - testenv.MustHaveGoBuild(t) +// gccgoPath returns a path to gccgo if it is present (either in +// path or specified via GCCGO environment variable), or an +// empty string if no gccgo is available. +func gccgoPath() string { + gccgoname := os.Getenv("GCCGO") + if gccgoname == "" { + gccgoname = "gccgo" + } + if gpath, gerr := exec.LookPath(gccgoname); gerr == nil { + return gpath + } + return "" +} - // This test relies on gccgo being around, which it most likely will be if we - // were compiled with gccgo. - if runtime.Compiler != "gccgo" { +func TestObjImporter(t *testing.T) { + // This test relies on gccgo being around. + gpath := gccgoPath() + if gpath == "" { t.Skip("This test needs gccgo") } + verout, err := exec.Command(gpath, "--version").CombinedOutput() + if err != nil { + t.Logf("%s", verout) + t.Fatal(err) + } + vers := regexp.MustCompile(`([0-9]+)\.([0-9]+)`).FindSubmatch(verout) + if len(vers) == 0 { + t.Fatalf("could not find version number in %s", verout) + } + major, err := strconv.Atoi(string(vers[1])) + if err != nil { + t.Fatal(err) + } + minor, err := strconv.Atoi(string(vers[2])) + if err != nil { + t.Fatal(err) + } + t.Logf("gccgo version %d.%d", major, minor) + tmpdir, err := ioutil.TempDir("", "") if err != nil { t.Fatal(err) @@ -141,11 +158,22 @@ func TestObjImporter(t *testing.T) { arimp := GetImporter([]string{artmpdir}, arinitmap) for _, test := range importerTests { + // Support for type aliases was added in GCC 7. + if test.pkgpath == "aliases" || test.pkgpath == "issue27856" || test.pkgpath == "issue29198" { + if major < 7 { + t.Logf("skipping %q: not supported before gccgo version 7", test.pkgpath) + continue + } + } + gofile := filepath.Join("testdata", test.pkgpath+".go") + if _, err := os.Stat(gofile); os.IsNotExist(err) { + continue + } ofile := filepath.Join(tmpdir, test.pkgpath+".o") afile := filepath.Join(artmpdir, "lib"+test.pkgpath+".a") - cmd := exec.Command("gccgo", "-fgo-pkgpath="+test.pkgpath, "-c", "-o", ofile, gofile) + cmd := exec.Command(gpath, "-fgo-pkgpath="+test.pkgpath, "-c", "-o", ofile, gofile) out, err := cmd.CombinedOutput() if err != nil { t.Logf("%s", out) diff --git a/libgo/go/go/internal/gccgoimporter/parser.go b/libgo/go/go/internal/gccgoimporter/parser.go index 6f010105d7e..42f43a19fb7 100644 --- a/libgo/go/go/internal/gccgoimporter/parser.go +++ b/libgo/go/go/internal/gccgoimporter/parser.go @@ -27,16 +27,37 @@ type parser struct { pkgname string // name of imported package pkg *types.Package // reference to imported package imports map[string]*types.Package // package path -> package object - typeMap map[int]types.Type // type number -> type - typeData []string // unparsed type data + typeList []types.Type // type number -> type + typeData []string // unparsed type data (v3 and later) + fixups []fixupRecord // fixups to apply at end of parsing initdata InitData // package init priority data } +// When reading export data it's possible to encounter a defined type +// N1 with an underlying defined type N2 while we are still reading in +// that defined type N2; see issues #29006 and #29198 for instances +// of this. Example: +// +// type N1 N2 +// type N2 struct { +// ... +// p *N1 +// } +// +// To handle such cases, the parser generates a fixup record (below) and +// delays setting of N1's underlying type until parsing is complete, at +// which point fixups are applied. + +type fixupRecord struct { + toUpdate *types.Named // type to modify when fixup is processed + target types.Type // type that was incomplete when fixup was created +} + func (p *parser) init(filename string, src io.Reader, imports map[string]*types.Package) { p.scanner = new(scanner.Scanner) p.initScanner(filename, src) p.imports = imports - p.typeMap = make(map[int]types.Type) + p.typeList = make([]types.Type, 1 /* type numbers start at 1 */, 16) } func (p *parser) initScanner(filename string, src io.Reader) { @@ -401,57 +422,115 @@ func (p *parser) parseConst(pkg *types.Package) *types.Const { return types.NewConst(token.NoPos, pkg, name, typ, val) } +// reserved is a singleton type used to fill type map slots that have +// been reserved (i.e., for which a type number has been parsed) but +// which don't have their actual type yet. When the type map is updated, +// the actual type must replace a reserved entry (or we have an internal +// error). Used for self-verification only - not required for correctness. +var reserved = new(struct{ types.Type }) + +// reserve reserves the type map entry n for future use. +func (p *parser) reserve(n int) { + // Notes: + // - for pre-V3 export data, the type numbers we see are + // guaranteed to be in increasing order, so we append a + // reserved entry onto the list. + // - for V3+ export data, type numbers can appear in + // any order, however the 'types' section tells us the + // total number of types, hence typeList is pre-allocated. + if len(p.typeData) == 0 { + if n != len(p.typeList) { + p.errorf("invalid type number %d (out of sync)", n) + } + p.typeList = append(p.typeList, reserved) + } else { + if p.typeList[n] != nil { + p.errorf("previously visited type number %d", n) + } + p.typeList[n] = reserved + } +} + +// update sets the type map entries for the given type numbers nlist to t. +func (p *parser) update(t types.Type, nlist []int) { + if len(nlist) != 0 { + if t == reserved { + p.errorf("internal error: update(%v) invoked on reserved", nlist) + } + if t == nil { + p.errorf("internal error: update(%v) invoked on nil", nlist) + } + } + for _, n := range nlist { + if p.typeList[n] == t { + continue + } + if p.typeList[n] != reserved { + p.errorf("internal error: update(%v): %d not reserved", nlist, n) + } + p.typeList[n] = t + } +} + // NamedType = TypeName [ "=" ] Type { Method } . // TypeName = ExportedName . // Method = "func" "(" Param ")" Name ParamList ResultList [InlineBody] ";" . -func (p *parser) parseNamedType(n int) types.Type { +func (p *parser) parseNamedType(nlist []int) types.Type { pkg, name := p.parseExportedName() scope := pkg.Scope() + obj := scope.Lookup(name) + if obj != nil && obj.Type() == nil { + p.errorf("%v has nil type", obj) + } + // type alias if p.tok == '=' { - // type alias p.next() - typ := p.parseType(pkg) - if obj := scope.Lookup(name); obj != nil { - typ = obj.Type() // use previously imported type - if typ == nil { - p.errorf("%v (type alias) used in cycle", obj) - } - } else { - obj = types.NewTypeName(token.NoPos, pkg, name, typ) - scope.Insert(obj) + if obj != nil { + // use the previously imported (canonical) type + t := obj.Type() + p.update(t, nlist) + p.parseType(pkg) // discard + return t } - p.typeMap[n] = typ - return typ + t := p.parseType(pkg, nlist...) + obj = types.NewTypeName(token.NoPos, pkg, name, t) + scope.Insert(obj) + return t } - // named type - obj := scope.Lookup(name) + // defined type if obj == nil { - // a named type may be referred to before the underlying type - // is known - set it up + // A named type may be referred to before the underlying type + // is known - set it up. tname := types.NewTypeName(token.NoPos, pkg, name, nil) types.NewNamed(tname, nil, nil) scope.Insert(tname) obj = tname } - typ := obj.Type() - p.typeMap[n] = typ + // use the previously imported (canonical), or newly created type + t := obj.Type() + p.update(t, nlist) - nt, ok := typ.(*types.Named) + nt, ok := t.(*types.Named) if !ok { // This can happen for unsafe.Pointer, which is a TypeName holding a Basic type. pt := p.parseType(pkg) - if pt != typ { + if pt != t { p.error("unexpected underlying type for non-named TypeName") } - return typ + return t } underlying := p.parseType(pkg) if nt.Underlying() == nil { - nt.SetUnderlying(underlying.Underlying()) + if underlying.Underlying() == nil { + fix := fixupRecord{toUpdate: nt, target: underlying} + p.fixups = append(p.fixups, fix) + } else { + nt.SetUnderlying(underlying.Underlying()) + } } if p.tok == '\n' { @@ -459,6 +538,14 @@ func (p *parser) parseNamedType(n int) types.Type { // collect associated methods for p.tok == scanner.Ident { p.expectKeyword("func") + if p.tok == '/' { + // Skip a /*nointerface*/ comment. + p.expect('/') + p.expect('*') + p.expect(scanner.Ident) + p.expect('*') + p.expect('/') + } p.expect('(') receiver, _ := p.parseParam(pkg) p.expect(')') @@ -476,41 +563,70 @@ func (p *parser) parseNamedType(n int) types.Type { return nt } -func (p *parser) parseInt() int64 { +func (p *parser) parseInt64() int64 { lit := p.expect(scanner.Int) - n, err := strconv.ParseInt(lit, 10, 0) + n, err := strconv.ParseInt(lit, 10, 64) if err != nil { p.error(err) } return n } +func (p *parser) parseInt() int { + lit := p.expect(scanner.Int) + n, err := strconv.ParseInt(lit, 10, 0 /* int */) + if err != nil { + p.error(err) + } + return int(n) +} + // ArrayOrSliceType = "[" [ int ] "]" Type . -func (p *parser) parseArrayOrSliceType(pkg *types.Package) types.Type { +func (p *parser) parseArrayOrSliceType(pkg *types.Package, nlist []int) types.Type { p.expect('[') if p.tok == ']' { p.next() - return types.NewSlice(p.parseType(pkg)) + + t := new(types.Slice) + p.update(t, nlist) + + *t = *types.NewSlice(p.parseType(pkg)) + return t } - n := p.parseInt() + t := new(types.Array) + p.update(t, nlist) + + len := p.parseInt64() p.expect(']') - return types.NewArray(p.parseType(pkg), n) + + *t = *types.NewArray(p.parseType(pkg), len) + return t } // MapType = "map" "[" Type "]" Type . -func (p *parser) parseMapType(pkg *types.Package) types.Type { +func (p *parser) parseMapType(pkg *types.Package, nlist []int) types.Type { p.expectKeyword("map") + + t := new(types.Map) + p.update(t, nlist) + p.expect('[') key := p.parseType(pkg) p.expect(']') elem := p.parseType(pkg) - return types.NewMap(key, elem) + + *t = *types.NewMap(key, elem) + return t } // ChanType = "chan" ["<-" | "-<"] Type . -func (p *parser) parseChanType(pkg *types.Package) types.Type { +func (p *parser) parseChanType(pkg *types.Package, nlist []int) types.Type { p.expectKeyword("chan") + + t := new(types.Chan) + p.update(t, nlist) + dir := types.SendRecv switch p.tok { case '-': @@ -527,13 +643,17 @@ func (p *parser) parseChanType(pkg *types.Package) types.Type { } } - return types.NewChan(dir, p.parseType(pkg)) + *t = *types.NewChan(dir, p.parseType(pkg)) + return t } // StructType = "struct" "{" { Field } "}" . -func (p *parser) parseStructType(pkg *types.Package) types.Type { +func (p *parser) parseStructType(pkg *types.Package, nlist []int) types.Type { p.expectKeyword("struct") + t := new(types.Struct) + p.update(t, nlist) + var fields []*types.Var var tags []string @@ -546,7 +666,8 @@ func (p *parser) parseStructType(pkg *types.Package) types.Type { } p.expect('}') - return types.NewStruct(fields, tags) + *t = *types.NewStruct(fields, tags) + return t } // ParamList = "(" [ { Parameter "," } Parameter ] ")" . @@ -593,10 +714,15 @@ func (p *parser) parseResultList(pkg *types.Package) *types.Tuple { } // FunctionType = ParamList ResultList . -func (p *parser) parseFunctionType(pkg *types.Package) *types.Signature { +func (p *parser) parseFunctionType(pkg *types.Package, nlist []int) *types.Signature { + t := new(types.Signature) + p.update(t, nlist) + params, isVariadic := p.parseParamList(pkg) results := p.parseResultList(pkg) - return types.NewSignature(nil, params, results, isVariadic) + + *t = *types.NewSignature(nil, params, results, isVariadic) + return t } // Func = Name FunctionType [InlineBody] . @@ -608,15 +734,18 @@ func (p *parser) parseFunc(pkg *types.Package) *types.Func { p.discardDirectiveWhileParsingTypes(pkg) return nil } - f := types.NewFunc(token.NoPos, pkg, name, p.parseFunctionType(pkg)) + f := types.NewFunc(token.NoPos, pkg, name, p.parseFunctionType(pkg, nil)) p.skipInlineBody() return f } // InterfaceType = "interface" "{" { ("?" Type | Func) ";" } "}" . -func (p *parser) parseInterfaceType(pkg *types.Package) types.Type { +func (p *parser) parseInterfaceType(pkg *types.Package, nlist []int) types.Type { p.expectKeyword("interface") + t := new(types.Interface) + p.update(t, nlist) + var methods []*types.Func var embeddeds []types.Type @@ -633,53 +762,61 @@ func (p *parser) parseInterfaceType(pkg *types.Package) types.Type { } p.expect('}') - return types.NewInterfaceType(methods, embeddeds) + *t = *types.NewInterfaceType(methods, embeddeds) + return t } // PointerType = "*" ("any" | Type) . -func (p *parser) parsePointerType(pkg *types.Package) types.Type { +func (p *parser) parsePointerType(pkg *types.Package, nlist []int) types.Type { p.expect('*') if p.tok == scanner.Ident { p.expectKeyword("any") - return types.Typ[types.UnsafePointer] + t := types.Typ[types.UnsafePointer] + p.update(t, nlist) + return t } - return types.NewPointer(p.parseType(pkg)) + + t := new(types.Pointer) + p.update(t, nlist) + + *t = *types.NewPointer(p.parseType(pkg)) + + return t } -// TypeDefinition = NamedType | MapType | ChanType | StructType | InterfaceType | PointerType | ArrayOrSliceType | FunctionType . -func (p *parser) parseTypeDefinition(pkg *types.Package, n int) types.Type { - var t types.Type +// TypeSpec = NamedType | MapType | ChanType | StructType | InterfaceType | PointerType | ArrayOrSliceType | FunctionType . +func (p *parser) parseTypeSpec(pkg *types.Package, nlist []int) types.Type { switch p.tok { case scanner.String: - t = p.parseNamedType(n) + return p.parseNamedType(nlist) case scanner.Ident: switch p.lit { case "map": - t = p.parseMapType(pkg) + return p.parseMapType(pkg, nlist) case "chan": - t = p.parseChanType(pkg) + return p.parseChanType(pkg, nlist) case "struct": - t = p.parseStructType(pkg) + return p.parseStructType(pkg, nlist) case "interface": - t = p.parseInterfaceType(pkg) + return p.parseInterfaceType(pkg, nlist) } case '*': - t = p.parsePointerType(pkg) + return p.parsePointerType(pkg, nlist) case '[': - t = p.parseArrayOrSliceType(pkg) + return p.parseArrayOrSliceType(pkg, nlist) case '(': - t = p.parseFunctionType(pkg) + return p.parseFunctionType(pkg, nlist) } - p.typeMap[n] = t - return t + p.errorf("expected type name or literal, got %s", scanner.TokenString(p.tok)) + return nil } const ( @@ -733,39 +870,51 @@ func lookupBuiltinType(typ int) types.Type { }[typ] } -// Type = "<" "type" ( "-" int | int [ TypeDefinition ] ) ">" . -func (p *parser) parseType(pkg *types.Package) types.Type { +// Type = "<" "type" ( "-" int | int [ TypeSpec ] ) ">" . +// +// parseType updates the type map to t for all type numbers n. +// +func (p *parser) parseType(pkg *types.Package, n ...int) types.Type { p.expect('<') - return p.parseTypeAfterAngle(pkg) + return p.parseTypeAfterAngle(pkg, n...) } // (*parser).Type after reading the "<". -func (p *parser) parseTypeAfterAngle(pkg *types.Package) (t types.Type) { +func (p *parser) parseTypeAfterAngle(pkg *types.Package, n ...int) (t types.Type) { p.expectKeyword("type") switch p.tok { case scanner.Int: - n := p.parseInt() - + n1 := p.parseInt() if p.tok == '>' { - if len(p.typeData) > 0 && p.typeMap[int(n)] == nil { - p.parseSavedType(pkg, int(n)) + if len(p.typeData) > 0 && p.typeList[n1] == nil { + p.parseSavedType(pkg, n1, n) + } + t = p.typeList[n1] + if len(p.typeData) == 0 && t == reserved { + p.errorf("invalid type cycle, type %d not yet defined (nlist=%v)", n1, n) } - t = p.typeMap[int(n)] + p.update(t, n) } else { - t = p.parseTypeDefinition(pkg, int(n)) + p.reserve(n1) + t = p.parseTypeSpec(pkg, append(n, n1)) } case '-': p.next() - n := p.parseInt() - t = lookupBuiltinType(int(n)) + n1 := p.parseInt() + t = lookupBuiltinType(n1) + p.update(t, n) default: p.errorf("expected type number, got %s (%q)", scanner.TokenString(p.tok), p.lit) return nil } + if t == nil || t == reserved { + p.errorf("internal error: bad return from parseType(%v)", n) + } + p.expect('>') return } @@ -793,13 +942,13 @@ func (p *parser) skipInlineBody() { }(p.scanner.Whitespace) p.scanner.Whitespace = 0 - got := int64(0) + got := 0 for got < want { r := p.scanner.Next() if r == scanner.EOF { p.error("unexpected EOF") } - got += int64(utf8.RuneLen(r)) + got += utf8.RuneLen(r) } } @@ -807,6 +956,7 @@ func (p *parser) skipInlineBody() { func (p *parser) parseTypes(pkg *types.Package) { maxp1 := p.parseInt() exportedp1 := p.parseInt() + p.typeList = make([]types.Type, maxp1, maxp1) type typeOffset struct { offset int @@ -815,8 +965,8 @@ func (p *parser) parseTypes(pkg *types.Package) { var typeOffsets []typeOffset total := 0 - for i := 1; i < int(maxp1); i++ { - len := int(p.parseInt()) + for i := 1; i < maxp1; i++ { + len := p.parseInt() typeOffsets = append(typeOffsets, typeOffset{total, len}) total += len } @@ -845,12 +995,12 @@ func (p *parser) parseTypes(pkg *types.Package) { } for i := 1; i < int(exportedp1); i++ { - p.parseSavedType(pkg, i) + p.parseSavedType(pkg, i, []int{}) } } // parseSavedType parses one saved type definition. -func (p *parser) parseSavedType(pkg *types.Package, i int) { +func (p *parser) parseSavedType(pkg *types.Package, i int, nlist []int) { defer func(s *scanner.Scanner, tok rune, lit string) { p.scanner = s p.tok = tok @@ -860,12 +1010,19 @@ func (p *parser) parseSavedType(pkg *types.Package, i int) { p.scanner = new(scanner.Scanner) p.initScanner(p.scanner.Filename, strings.NewReader(p.typeData[i])) p.expectKeyword("type") - id := int(p.parseInt()) + id := p.parseInt() if id != i { p.errorf("type ID mismatch: got %d, want %d", id, i) } - if p.typeMap[i] == nil { - p.typeMap[i] = p.parseTypeDefinition(pkg, i) + if p.typeList[i] == reserved { + p.errorf("internal error: %d already reserved in parseSavedType", i) + } + if p.typeList[i] == nil { + p.reserve(i) + p.parseTypeSpec(pkg, append(nlist, i)) + } + if p.typeList[i] == nil || p.typeList[i] == reserved { + p.errorf("internal error: parseSavedType(%d,%v) reserved/nil", i, nlist) } } @@ -875,7 +1032,7 @@ func (p *parser) parsePackageInit() PackageInit { initfunc := p.parseUnquotedString() priority := -1 if p.version == "v1" { - priority = int(p.parseInt()) + priority = p.parseInt() } return PackageInit{Name: name, InitFunc: initfunc, Priority: priority} } @@ -923,7 +1080,7 @@ func (p *parser) parseInitDataDirective() { case "priority": p.next() - p.initdata.Priority = int(p.parseInt()) + p.initdata.Priority = p.parseInt() p.expectEOL() case "init": @@ -937,8 +1094,8 @@ func (p *parser) parseInitDataDirective() { p.next() // The graph data is thrown away for now. for p.tok != '\n' && p.tok != ';' && p.tok != scanner.EOF { - p.parseInt() - p.parseInt() + p.parseInt64() + p.parseInt64() } p.expectEOL() @@ -1053,7 +1210,14 @@ func (p *parser) parsePackage() *types.Package { for p.tok != scanner.EOF { p.parseDirective() } - for _, typ := range p.typeMap { + for _, f := range p.fixups { + if f.target.Underlying() == nil { + p.errorf("internal error: fixup can't be applied, loop required") + } + f.toUpdate.SetUnderlying(f.target.Underlying()) + } + p.fixups = nil + for _, typ := range p.typeList { if it, ok := typ.(*types.Interface); ok { it.Complete() } diff --git a/libgo/go/go/internal/gccgoimporter/parser_test.go b/libgo/go/go/internal/gccgoimporter/parser_test.go index 4d3568afc3d..00128b44d26 100644 --- a/libgo/go/go/internal/gccgoimporter/parser_test.go +++ b/libgo/go/go/internal/gccgoimporter/parser_test.go @@ -19,7 +19,7 @@ var typeParserTests = []struct { {id: "foo", typ: ">", want: "*error"}, {id: "foo", typ: "", want: "unsafe.Pointer"}, {id: "foo", typ: ">>", want: "foo.Bar", underlying: "*foo.Bar"}, - {id: "foo", typ: "\n func (? ) M ()\n>", want: "bar.Foo", underlying: "int8", methods: "func (bar.Foo).M()"}, + {id: "foo", typ: "\nfunc (? ) M ();\n>", want: "bar.Foo", underlying: "int8", methods: "func (bar.Foo).M()"}, {id: "foo", typ: ">", want: "bar.foo", underlying: "int8"}, {id: "foo", typ: ">", want: "[]int8"}, {id: "foo", typ: ">", want: "[42]int8"}, @@ -36,6 +36,7 @@ func TestTypeParser(t *testing.T) { for _, test := range typeParserTests { var p parser p.init("test.gox", strings.NewReader(test.typ), make(map[string]*types.Package)) + p.version = "v2" p.pkgname = test.id p.pkgpath = test.id p.maybeCreatePackage() diff --git a/libgo/go/go/internal/gccgoimporter/testdata/alias.gox b/libgo/go/go/internal/gccgoimporter/testdata/alias.gox deleted file mode 100644 index ced7d84c4f6..00000000000 --- a/libgo/go/go/internal/gccgoimporter/testdata/alias.gox +++ /dev/null @@ -1,4 +0,0 @@ -v1; -package alias; -pkgpath alias; -type >>>) < type 114>; M2 () ; }>>; diff --git a/libgo/go/go/internal/gccgoimporter/testdata/aliases.go b/libgo/go/go/internal/gccgoimporter/testdata/aliases.go new file mode 100644 index 00000000000..cfb59b3e315 --- /dev/null +++ b/libgo/go/go/internal/gccgoimporter/testdata/aliases.go @@ -0,0 +1,65 @@ +package aliases + +type ( + T0 [10]int + T1 []byte + T2 struct { + x int + } + T3 interface { + m() T2 + } + T4 func(int, T0) chan T2 +) + +// basic aliases +type ( + Ai = int + A0 = T0 + A1 = T1 + A2 = T2 + A3 = T3 + A4 = T4 + + A10 = [10]int + A11 = []byte + A12 = struct { + x int + } + A13 = interface { + m() A2 + } + A14 = func(int, A0) chan A2 +) + +// alias receiver types +func (T0) m1() {} +func (A0) m2() {} + +// alias receiver types (long type declaration chains) +type ( + V0 = V1 + V1 = (V2) + V2 = (V3) + V3 = T0 +) + +func (V1) n() {} + +// cycles +type C0 struct { + f1 C1 + f2 C2 +} + +type ( + C1 *C0 + C2 = C1 +) + +type ( + C5 struct { + f *C6 + } + C6 = C5 +) diff --git a/libgo/go/go/internal/gccgoimporter/testdata/aliases.gox b/libgo/go/go/internal/gccgoimporter/testdata/aliases.gox new file mode 100644 index 00000000000..2428c068743 --- /dev/null +++ b/libgo/go/go/internal/gccgoimporter/testdata/aliases.gox @@ -0,0 +1,33 @@ +v2; +package aliases; +prefix go; +package aliases go.aliases go.aliases; +type > + func (? ) .go.aliases.m1 (); + func (? ) .go.aliases.m2 (); + func (? >>>) .go.aliases.n (); +>>; +type >>>; +type >>; +type >>; +type ; }>>; +type ; }>>>; }>>; +type , ? ) >>>; +type ; +type ; }>>>; +type , ? ) >>>>; +type >; +type >>; .go.aliases.f2 >; }>>; +type ; +type ; +type >>; }>>; +type ; +type ; +type ; +type ; +type ; +type ; +type >; +type ; +type ; +type ; diff --git a/libgo/go/go/internal/gccgoimporter/testdata/issue27856.go b/libgo/go/go/internal/gccgoimporter/testdata/issue27856.go new file mode 100644 index 00000000000..bf361e1cd80 --- /dev/null +++ b/libgo/go/go/internal/gccgoimporter/testdata/issue27856.go @@ -0,0 +1,9 @@ +package lib + +type M struct { + E E +} +type F struct { + _ *M +} +type E = F diff --git a/libgo/go/go/internal/gccgoimporter/testdata/issue27856.gox b/libgo/go/go/internal/gccgoimporter/testdata/issue27856.gox new file mode 100644 index 00000000000..6665e64021b --- /dev/null +++ b/libgo/go/go/internal/gccgoimporter/testdata/issue27856.gox @@ -0,0 +1,9 @@ +v2; +package main; +pkgpath main; +import runtime runtime "runtime"; +init runtime runtime..import sys runtime_internal_sys..import; +init_graph 0 1; +type ; }>>>; }>>>; +type ; +type ; diff --git a/libgo/go/go/internal/gccgoimporter/testdata/issue29198.go b/libgo/go/go/internal/gccgoimporter/testdata/issue29198.go new file mode 100644 index 00000000000..75c2162d204 --- /dev/null +++ b/libgo/go/go/internal/gccgoimporter/testdata/issue29198.go @@ -0,0 +1,37 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package server + +import ( + "context" + "errors" +) + +type A struct { + x int +} + +func (a *A) AMethod(y int) *Server { + return nil +} + +// FooServer is a server that provides Foo services +type FooServer Server + +func (f *FooServer) WriteEvents(ctx context.Context, x int) error { + return errors.New("hey!") +} + +type Server struct { + FooServer *FooServer + user string + ctx context.Context +} + +func New(sctx context.Context, u string) (*Server, error) { + s := &Server{user: u, ctx: sctx} + s.FooServer = (*FooServer)(s) + return s, nil +} diff --git a/libgo/go/go/internal/gccgoimporter/testdata/issue29198.gox b/libgo/go/go/internal/gccgoimporter/testdata/issue29198.gox new file mode 100644 index 00000000000..905c86637eb --- /dev/null +++ b/libgo/go/go/internal/gccgoimporter/testdata/issue29198.gox @@ -0,0 +1,86 @@ +v2; +package server; +pkgpath issue29198; +import context context "context"; +import errors errors "errors"; +init context context..import fmt fmt..import poll internal_poll..import testlog internal_testlog..import io io..import os os..import reflect reflect..import runtime runtime..import sys runtime_internal_sys..import strconv strconv..import sync sync..import syscall syscall..import time time..import unicode unicode..import; +init_graph 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 2 4 2 7 2 8 2 10 2 11 2 12 4 7 4 8 4 10 5 2 5 3 5 4 5 7 5 8 5 10 5 11 5 12 6 7 6 8 6 9 6 10 6 13 7 8 9 7 9 8 10 7 10 8 11 7 11 8 11 10 12 7 12 8 12 10 12 11; +type ; }> + func (a >) AMethod (y ) + func (f >) WriteEvents (ctx ; .time.ext ; .time.loc ; .time.zone ; .time.offset ; .time.isDST ; }>>>; .time.tx ; .time.index ; .time.isstd ; .time.isutc ; }>>>; .time.cacheStart ; .time.cacheEnd ; .time.cacheZone >; }> + func (l >) String () ; + func (l ) .time.lookupFirstZone () ; + func (l ) .time.get () ; + func (l ) .time.lookup (sec ) (name , offset , isDST , start , end ); + func (l ) .time.lookupName (name , unix ) (offset , ok ); + func (l ) .time.firstZoneUsed () ; +>>; }> + func (t ) In (loc ) ; + func (t ) .time.date (full ) (year , month + func (m ) String () ; +>, day , yday ); + func (t ) Sub (u ) + func (d ) Truncate (m ) ; + func (d ) String () ; + func (d ) Round (m ) ; + func (d ) Seconds () ; + func (d ) Nanoseconds () ; + func (d ) Minutes () ; + func (d ) Hours () ; +>; + func (t ) Add (d ) ; + func (t ) UTC () ; + func (t ) AddDate (years , months , days ) ; + func (t ) MarshalBinary () (? >, ? ); + func (t ) Nanosecond () ; + func (t ) Round (d ) ; + func (t ) Minute () ; + func (t ) Clock () (hour , min , sec ); + func (t ) ISOWeek () (year , week ); + func (t ) Day () ; + func (t >) .time.mono () ; + func (t ) UnixNano () ; + func (t ) .time.sec () ; + func (t ) Second () ; + func (t ) Before (u ) ; + func (t ) UnmarshalBinary (data >) ; + func (t ) Month () ; + func (t ) YearDay () ; + func (t ) Location () ; + func (t ) Zone () (name , offset ); + func (t ) Local () ; + func (t ) .time.setLoc (loc ); + func (t ) Truncate (d ) ; + func (t ) MarshalJSON () (? >, ? ); + func (t ) AppendFormat (b >, layout ) >; + func (t ) GobDecode (data >) ; + func (t ) UnmarshalJSON (data >) ; + func (t ) MarshalText () (? >, ? ); + func (t ) GobEncode () (? >, ? ); + func (t ) .time.stripMono (); + func (t ) After (u ) ; + func (t ) Hour () ; + func (t ) UnmarshalText (data >) ; + func (t ) Equal (u ) ; + func (t ) .time.setMono (m ); + func (t ) Year () ; + func (t ) IsZero () ; + func (t ) .time.addSec (d ); + func (t ) Weekday () + func (d ) String () ; +>; + func (t ) String () ; + func (t ) .time.nsec () ; + func (t ) Format (layout ) ; + func (t ) .time.unixSec () ; + func (t ) Unix () ; + func (t ) .time.abs () ; + func (t ) .time.locabs () (name , offset , abs ); + func (t ) Date () (year , month , day ); +>, ok ); Done () >; Err () ; Value (key ) ; }>>, x ) ; +>>; .issue29198.user ; .issue29198.ctx ; }>>>; +>; +type ; +func New (sctx , u ) (? >, ? ); +type ; +checksum 86C8D76B2582F55A8BD2CA9E00060358EC1CE214; diff --git a/libgo/go/go/internal/gccgoimporter/testdata/libimportsar.a b/libgo/go/go/internal/gccgoimporter/testdata/libimportsar.a new file mode 100644 index 0000000000000000000000000000000000000000..6f30758151dbc3ebbf037c54b55f4e84fb055277 GIT binary patch literal 9302 zcmb_iU5p!76~6ZDCeCiN%}*%_r7#HzB%wQN?|OIbZj^d=o5U4q8Aoy96D~k)& zpyfCVWf813UB_`Ut-!A~Dk2n)vm~nZrsqSc=+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N_(vGa z_=bH-CAzBg>H6vY+>HNQU~%#7!O*Z6im0`tUf6jBA};=U75}o*r}*^ifEoWyU=-gx zKj&5aH0E@&^#S^?gX7kJi+U)qJ;kRzH{<^c7{xc~c@^KpP2KGPOpI*U{wIb5Q+EVF zT>b@>|I^BV@~2vF=KoR5n?5PzvU;F=l?ED_y5oK9-%|Fxe(b`u9|aJX|L@gLN^DR0 z)2}gR{zv-6zjb36@ktJ>q#1v{ zu#f#`RiFd!V85*F4K;Cr6E!9{F2j#0d*k*OPb&KYD=KNaJqP=^{j+1%Z!dhXJ+CX} zW5%XXSC!&6cdX-UlR#^soW#F)r8`%6Gpw`<%-EDZ{`RiW2?Wzf@h~ zzr(-N-{3Rp%#S5?6G+$OP9uisU=r?%!DFBgv;nY;h~yT?zAojyEw zdTrv)puOs6?{ymw=e$!*X>m>B6+*}#ydZV~e)Mkeppo^0bzC7<)>$Qg*%h{`ZYBCa|8 cYQ_$gl$o13rbnx}_T+!3QhbO88kzS01LaMjO#lD@ literal 0 HcmV?d00001 diff --git a/libgo/go/go/internal/gccgoimporter/testdata/nointerface.go b/libgo/go/go/internal/gccgoimporter/testdata/nointerface.go new file mode 100644 index 00000000000..6a545f24933 --- /dev/null +++ b/libgo/go/go/internal/gccgoimporter/testdata/nointerface.go @@ -0,0 +1,12 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package nointerface + +type I int + +//go:nointerface +func (p *I) Get() int { return int(*p) } + +func (p *I) Set(v int) { *p = I(v) } diff --git a/libgo/go/go/internal/gccgoimporter/testdata/nointerface.gox b/libgo/go/go/internal/gccgoimporter/testdata/nointerface.gox new file mode 100644 index 00000000000..7b73d179e39 --- /dev/null +++ b/libgo/go/go/internal/gccgoimporter/testdata/nointerface.gox @@ -0,0 +1,8 @@ +v3; +package nointerface +pkgpath nointerface +types 3 2 133 17 +type 1 "I" + func /*nointerface*/ (p ) Get () + func (p ) Set (v ) +type 2 * diff --git a/libgo/go/go/internal/gccgoimporter/testdata/v1reflect.gox b/libgo/go/go/internal/gccgoimporter/testdata/v1reflect.gox new file mode 100644 index 0000000000000000000000000000000000000000..ea468414d9fa8ad66e978799a8ff5d2f90eb4961 GIT binary patch literal 10872 zcmb^%U2o&KF?-iOG*9hwUkIZpoI?^sl4Zxp)kVIx4es^>P3|6A6br2*Cqit=mE>&P z!=itnKcx@-iJc)i=IOMCfv1OMQa`eRGAqigUW@2#KU*w|vK9+Okbipk zw`Tz5DzCEzP}9$z{$Vkyx||mIv!G{B|6myFd@3sZ)5E_Ou*$1smJ0posV9Q-tR`{k zd3>xzjjXU{EHLtE@fd{U(oX{k&-Q04km-E6O!Iruuf(_YdYOtq^nOg{tF))zLtNQv zT8p2=vDWD^AZlnNzERT#qG!O^SnVJUpXH>_lYJqBtzYZqhbC}>a56ct zWXVpVe_&82XYJ`Q=e;(9!9*+hQQx9bcffli?Irq|=6w_dz^K0nRvTe5OJ~z5(hwAt7gqiI#k6iCLuP4dFWQfGaE%r<6vd-$&c|J zCQdUeJQY10A&VS=Ly@~Yk)}^!jb38=!0~3WoTrO4uPf1C(G1iI*$va_c~wDHPCm}l zyJ7>{MTS)DR8-UDW0GHGr5z5(qNfL~)Pa$jszNy4D0TH?QfA40HnoJ00u=QcR%6FP zRH}5FrdzA!MJJ*Ms(}h8kw~B@uu1649UEBQC6uZoNGys2j1hf|RWeh}P+`e`N^8-7 zO4mmJ+!nAJwAs7atO7K$5W3S%exJVRktnj67JU`K=XsH@7sZN_vCrqlxmz)j(nd2J}pW|^=hHrr8SPkTZ8XbU@mu54rRtVm_yYHBu^XRs;QJI z(NKtnRNX?T3@jh0`fXW7BSM7A#PHe`B!c!t@yB8#ixLXk4 zh{m63wa@}J(r(*JY;6HADJWy1cLH~3VavL_EAAdM^577YOS`m2rab_?u*zB&uA5m9ax-H(k}vtF(3n^rGoB=c-nv z1kCTzObfvnQf{w-U+SRGiRbRlyB7IrHSyyU0 zXXy8hLO0F4e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y;BVoLf5(a6Z-)9? zPDCWwZ{YXWIH3Q{0O$Ag0#Cxj=T~g}-+(9J{TF&1pTCCxzk>gq-hTj(XaLCk{vXU8 BTEYMT literal 0 HcmV?d00001 diff --git a/libgo/go/go/internal/gcimporter/gcimporter.go b/libgo/go/go/internal/gcimporter/gcimporter.go index d117f6fe4d3..3aed6de6ae0 100644 --- a/libgo/go/go/internal/gcimporter/gcimporter.go +++ b/libgo/go/go/internal/gcimporter/gcimporter.go @@ -85,7 +85,7 @@ func FindPkg(path, srcDir string) (filename, id string) { // the corresponding package object to the packages map, and returns the object. // The packages map must contain all packages already imported. // -func Import(packages map[string]*types.Package, path, srcDir string, lookup func(path string) (io.ReadCloser, error)) (pkg *types.Package, err error) { +func Import(fset *token.FileSet, packages map[string]*types.Package, path, srcDir string, lookup func(path string) (io.ReadCloser, error)) (pkg *types.Package, err error) { var rc io.ReadCloser var id string if lookup != nil { @@ -152,10 +152,6 @@ func Import(packages map[string]*types.Package, path, srcDir string, lookup func break } - // TODO(gri): allow clients of go/importer to provide a FileSet. - // Or, define a new standard go/types/gcexportdata package. - fset := token.NewFileSet() - // The indexed export format starts with an 'i'; the older // binary export format starts with a 'c', 'd', or 'v' // (from "version"). Select appropriate importer. diff --git a/libgo/go/go/internal/gcimporter/gcimporter_test.go b/libgo/go/go/internal/gcimporter/gcimporter_test.go index d496f2e57d3..3b7636806e7 100644 --- a/libgo/go/go/internal/gcimporter/gcimporter_test.go +++ b/libgo/go/go/internal/gcimporter/gcimporter_test.go @@ -17,6 +17,7 @@ import ( "testing" "time" + "go/token" "go/types" ) @@ -34,21 +35,29 @@ func skipSpecialPlatforms(t *testing.T) { } } -func compile(t *testing.T, dirname, filename string) string { - cmd := exec.Command(testenv.GoToolPath(t), "tool", "compile", filename) +// compile runs the compiler on filename, with dirname as the working directory, +// and writes the output file to outdirname. +func compile(t *testing.T, dirname, filename, outdirname string) string { + // filename must end with ".go" + if !strings.HasSuffix(filename, ".go") { + t.Fatalf("filename doesn't end in .go: %s", filename) + } + basename := filepath.Base(filename) + outname := filepath.Join(outdirname, basename[:len(basename)-2]+"o") + cmd := exec.Command(testenv.GoToolPath(t), "tool", "compile", "-o", outname, filename) cmd.Dir = dirname out, err := cmd.CombinedOutput() if err != nil { t.Logf("%s", out) t.Fatalf("go tool compile %s failed: %s", filename, err) } - // filename should end with ".go" - return filepath.Join(dirname, filename[:len(filename)-2]+"o") + return outname } func testPath(t *testing.T, path, srcDir string) *types.Package { t0 := time.Now() - pkg, err := Import(make(map[string]*types.Package), path, srcDir, nil) + fset := token.NewFileSet() + pkg, err := Import(fset, make(map[string]*types.Package), path, srcDir, nil) if err != nil { t.Errorf("testPath(%s): %s", path, err) return nil @@ -88,17 +97,30 @@ func testDir(t *testing.T, dir string, endTime time.Time) (nimports int) { return } +func mktmpdir(t *testing.T) string { + tmpdir, err := ioutil.TempDir("", "gcimporter_test") + if err != nil { + t.Fatal("mktmpdir:", err) + } + if err := os.Mkdir(filepath.Join(tmpdir, "testdata"), 0700); err != nil { + os.RemoveAll(tmpdir) + t.Fatal("mktmpdir:", err) + } + return tmpdir +} + func TestImportTestdata(t *testing.T) { // This package only handles gc export data. if runtime.Compiler != "gc" { t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler) } - if outFn := compile(t, "testdata", "exports.go"); outFn != "" { - defer os.Remove(outFn) - } + tmpdir := mktmpdir(t) + defer os.RemoveAll(tmpdir) - if pkg := testPath(t, "./testdata/exports", "."); pkg != nil { + compile(t, "testdata", "exports.go", filepath.Join(tmpdir, "testdata")) + + if pkg := testPath(t, "./testdata/exports", tmpdir); pkg != nil { // The package's Imports list must include all packages // explicitly imported by exports.go, plus all packages // referenced indirectly via exported objects in exports.go. @@ -131,6 +153,15 @@ func TestVersionHandling(t *testing.T) { t.Fatal(err) } + tmpdir := mktmpdir(t) + defer os.RemoveAll(tmpdir) + corruptdir := filepath.Join(tmpdir, "testdata", "versions") + if err := os.Mkdir(corruptdir, 0700); err != nil { + t.Fatal(err) + } + + fset := token.NewFileSet() + for _, f := range list { name := f.Name() if !strings.HasSuffix(name, ".a") { @@ -146,7 +177,7 @@ func TestVersionHandling(t *testing.T) { } // test that export data can be imported - _, err := Import(make(map[string]*types.Package), pkgpath, dir, nil) + _, err := Import(fset, make(map[string]*types.Package), pkgpath, dir, nil) if err != nil { // ok to fail if it fails with a newer version error for select files if strings.Contains(err.Error(), "newer version") { @@ -178,12 +209,11 @@ func TestVersionHandling(t *testing.T) { } // 4) write the file pkgpath += "_corrupted" - filename := filepath.Join(dir, pkgpath) + ".a" + filename := filepath.Join(corruptdir, pkgpath) + ".a" ioutil.WriteFile(filename, data, 0666) - defer os.Remove(filename) // test that importing the corrupted file results in an error - _, err = Import(make(map[string]*types.Package), pkgpath, dir, nil) + _, err = Import(fset, make(map[string]*types.Package), pkgpath, corruptdir, nil) if err == nil { t.Errorf("import corrupted %q succeeded", pkgpath) } else if msg := err.Error(); !strings.Contains(msg, "version skew") { @@ -240,6 +270,7 @@ func TestImportedTypes(t *testing.T) { t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler) } + fset := token.NewFileSet() for _, test := range importedObjectTests { s := strings.Split(test.name, ".") if len(s) != 2 { @@ -248,7 +279,7 @@ func TestImportedTypes(t *testing.T) { importPath := s[0] objName := s[1] - pkg, err := Import(make(map[string]*types.Package), importPath, ".", nil) + pkg, err := Import(fset, make(map[string]*types.Package), importPath, ".", nil) if err != nil { t.Error(err) continue @@ -315,7 +346,7 @@ func TestIssue5815(t *testing.T) { t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler) } - pkg := importPkg(t, "strings") + pkg := importPkg(t, "strings", ".") scope := pkg.Scope() for _, name := range scope.Names() { @@ -345,7 +376,8 @@ func TestCorrectMethodPackage(t *testing.T) { } imports := make(map[string]*types.Package) - _, err := Import(imports, "net/http", ".", nil) + fset := token.NewFileSet() + _, err := Import(fset, imports, "net/http", ".", nil) if err != nil { t.Fatal(err) } @@ -373,15 +405,22 @@ func TestIssue13566(t *testing.T) { t.Skip("avoid dealing with relative paths/drive letters on windows") } - if f := compile(t, "testdata", "a.go"); f != "" { - defer os.Remove(f) - } - if f := compile(t, "testdata", "b.go"); f != "" { - defer os.Remove(f) + tmpdir := mktmpdir(t) + defer os.RemoveAll(tmpdir) + testoutdir := filepath.Join(tmpdir, "testdata") + + // b.go needs to be compiled from the output directory so that the compiler can + // find the compiled package a. We pass the full path to compile() so that we + // don't have to copy the file to that directory. + bpath, err := filepath.Abs(filepath.Join("testdata", "b.go")) + if err != nil { + t.Fatal(err) } + compile(t, "testdata", "a.go", testoutdir) + compile(t, testoutdir, bpath, testoutdir) // import must succeed (test for issue at hand) - pkg := importPkg(t, "./testdata/b") + pkg := importPkg(t, "./testdata/b", tmpdir) // make sure all indirectly imported packages have names for _, imp := range pkg.Imports() { @@ -400,8 +439,9 @@ func TestIssue13898(t *testing.T) { } // import go/internal/gcimporter which imports go/types partially + fset := token.NewFileSet() imports := make(map[string]*types.Package) - _, err := Import(imports, "go/internal/gcimporter", ".", nil) + _, err := Import(fset, imports, "go/internal/gcimporter", ".", nil) if err != nil { t.Fatal(err) } @@ -451,9 +491,10 @@ func TestIssue15517(t *testing.T) { t.Skip("avoid dealing with relative paths/drive letters on windows") } - if f := compile(t, "testdata", "p.go"); f != "" { - defer os.Remove(f) - } + tmpdir := mktmpdir(t) + defer os.RemoveAll(tmpdir) + + compile(t, "testdata", "p.go", filepath.Join(tmpdir, "testdata")) // Multiple imports of p must succeed without redeclaration errors. // We use an import path that's not cleaned up so that the eventual @@ -468,8 +509,9 @@ func TestIssue15517(t *testing.T) { // file and package path are different, exposing the problem if present. // The same issue occurs with vendoring.) imports := make(map[string]*types.Package) + fset := token.NewFileSet() for i := 0; i < 3; i++ { - if _, err := Import(imports, "./././testdata/p", ".", nil); err != nil { + if _, err := Import(fset, imports, "./././testdata/p", tmpdir, nil); err != nil { t.Fatal(err) } } @@ -489,11 +531,7 @@ func TestIssue15920(t *testing.T) { t.Skip("avoid dealing with relative paths/drive letters on windows") } - if f := compile(t, "testdata", "issue15920.go"); f != "" { - defer os.Remove(f) - } - - importPkg(t, "./testdata/issue15920") + compileAndImportPkg(t, "issue15920") } func TestIssue20046(t *testing.T) { @@ -510,12 +548,8 @@ func TestIssue20046(t *testing.T) { t.Skip("avoid dealing with relative paths/drive letters on windows") } - if f := compile(t, "testdata", "issue20046.go"); f != "" { - defer os.Remove(f) - } - // "./issue20046".V.M must exist - pkg := importPkg(t, "./testdata/issue20046") + pkg := compileAndImportPkg(t, "issue20046") obj := lookupObj(t, pkg.Scope(), "V") if m, index, indirect := types.LookupFieldOrMethod(obj.Type(), false, nil, "M"); m == nil { t.Fatalf("V.M not found (index = %v, indirect = %v)", index, indirect) @@ -535,11 +569,7 @@ func TestIssue25301(t *testing.T) { t.Skip("avoid dealing with relative paths/drive letters on windows") } - if f := compile(t, "testdata", "issue25301.go"); f != "" { - defer os.Remove(f) - } - - importPkg(t, "./testdata/issue25301") + compileAndImportPkg(t, "issue25301") } func TestIssue25596(t *testing.T) { @@ -556,21 +586,25 @@ func TestIssue25596(t *testing.T) { t.Skip("avoid dealing with relative paths/drive letters on windows") } - if f := compile(t, "testdata", "issue25596.go"); f != "" { - defer os.Remove(f) - } - - importPkg(t, "./testdata/issue25596") + compileAndImportPkg(t, "issue25596") } -func importPkg(t *testing.T, path string) *types.Package { - pkg, err := Import(make(map[string]*types.Package), path, ".", nil) +func importPkg(t *testing.T, path, srcDir string) *types.Package { + fset := token.NewFileSet() + pkg, err := Import(fset, make(map[string]*types.Package), path, srcDir, nil) if err != nil { t.Fatal(err) } return pkg } +func compileAndImportPkg(t *testing.T, name string) *types.Package { + tmpdir := mktmpdir(t) + defer os.RemoveAll(tmpdir) + compile(t, "testdata", name+".go", filepath.Join(tmpdir, "testdata")) + return importPkg(t, "./testdata/"+name, tmpdir) +} + func lookupObj(t *testing.T, scope *types.Scope, name string) types.Object { if obj := scope.Lookup(name); obj != nil { return obj diff --git a/libgo/go/go/internal/srcimporter/srcimporter_test.go b/libgo/go/go/internal/srcimporter/srcimporter_test.go index b9caa90fc58..b84672610c6 100644 --- a/libgo/go/go/internal/srcimporter/srcimporter_test.go +++ b/libgo/go/go/internal/srcimporter/srcimporter_test.go @@ -99,7 +99,7 @@ var importedObjectTests = []struct { {"math.Pi", "const Pi untyped float"}, {"math.Sin", "func Sin(x float64) float64"}, {"math/big.Int", "type Int struct{neg bool; abs nat}"}, - {"golang_org/x/text/unicode/norm.MaxSegmentSize", "const MaxSegmentSize untyped int"}, + {"internal/x/text/unicode/norm.MaxSegmentSize", "const MaxSegmentSize untyped int"}, } func TestImportedTypes(t *testing.T) { diff --git a/libgo/go/go/parser/parser.go b/libgo/go/go/parser/parser.go index 189bfb42236..ba16b652246 100644 --- a/libgo/go/go/parser/parser.go +++ b/libgo/go/go/parser/parser.go @@ -300,7 +300,7 @@ func (p *parser) consumeCommentGroup(n int) (comments *ast.CommentGroup, endline // Advance to the next non-comment token. In the process, collect // any comment groups encountered, and remember the last lead and -// and line comments. +// line comments. // // A lead comment is a comment group that starts and ends in a // line without any other tokens and that is followed by a non-comment diff --git a/libgo/go/go/printer/nodes.go b/libgo/go/go/printer/nodes.go index 1de7cd81b2c..0f2029cadaa 100644 --- a/libgo/go/go/printer/nodes.go +++ b/libgo/go/go/printer/nodes.go @@ -976,7 +976,7 @@ func (p *printer) possibleSelectorExpr(expr ast.Expr, prec1, depth int) bool { return false } -// selectorExpr handles an *ast.SelectorExpr node and returns whether x spans +// selectorExpr handles an *ast.SelectorExpr node and reports whether x spans // multiple lines. func (p *printer) selectorExpr(x *ast.SelectorExpr, depth int, isMethod bool) bool { p.expr1(x.X, token.HighestPrec, depth) @@ -1134,7 +1134,7 @@ func (p *printer) controlClause(isForStmt bool, init ast.Stmt, expr ast.Expr, po // than starting at the first line break). // func (p *printer) indentList(list []ast.Expr) bool { - // Heuristic: indentList returns true if there are more than one multi- + // Heuristic: indentList reports whether there are more than one multi- // line element in the list, or if there is any element that is not // starting on the same line as the previous one ends. if len(list) >= 2 { @@ -1537,7 +1537,7 @@ func (p *printer) genDecl(d *ast.GenDecl) { p.setComment(d.Doc) p.print(d.Pos(), d.Tok, blank) - if d.Lparen.IsValid() { + if d.Lparen.IsValid() || len(d.Specs) > 1 { // group of parenthesized declarations p.print(d.Lparen, token.LPAREN) if n := len(d.Specs); n > 0 { diff --git a/libgo/go/go/printer/printer_test.go b/libgo/go/go/printer/printer_test.go index 27d46df6b18..91eca585c09 100644 --- a/libgo/go/go/printer/printer_test.go +++ b/libgo/go/go/printer/printer_test.go @@ -736,3 +736,35 @@ func TestIssue11151(t *testing.T) { t.Errorf("%v\norig: %q\ngot : %q", err, src, got) } } + +// If a declaration has multiple specifications, a parenthesized +// declaration must be printed even if Lparen is token.NoPos. +func TestParenthesizedDecl(t *testing.T) { + // a package with multiple specs in a single declaration + const src = "package p; var ( a float64; b int )" + fset := token.NewFileSet() + f, err := parser.ParseFile(fset, "", src, 0) + + // print the original package + var buf bytes.Buffer + err = Fprint(&buf, fset, f) + if err != nil { + t.Fatal(err) + } + original := buf.String() + + // now remove parentheses from the declaration + for i := 0; i != len(f.Decls); i++ { + f.Decls[i].(*ast.GenDecl).Lparen = token.NoPos + } + buf.Reset() + err = Fprint(&buf, fset, f) + if err != nil { + t.Fatal(err) + } + noparen := buf.String() + + if noparen != original { + t.Errorf("got %q, want %q", noparen, original) + } +} diff --git a/libgo/go/go/printer/testdata/parser.go b/libgo/go/go/printer/testdata/parser.go index 44dfa19ff35..80b476cf2ee 100644 --- a/libgo/go/go/printer/testdata/parser.go +++ b/libgo/go/go/printer/testdata/parser.go @@ -290,7 +290,7 @@ func (p *parser) consumeCommentGroup() (comments *ast.CommentGroup, endline int) // Advance to the next non-comment token. In the process, collect // any comment groups encountered, and remember the last lead and -// and line comments. +// line comments. // // A lead comment is a comment group that starts and ends in a // line without any other tokens and that is followed by a non-comment diff --git a/libgo/go/go/scanner/scanner.go b/libgo/go/go/scanner/scanner.go index 23bbb2885fb..e78abf12a27 100644 --- a/libgo/go/go/scanner/scanner.go +++ b/libgo/go/go/scanner/scanner.go @@ -85,6 +85,15 @@ func (s *Scanner) next() { } } +// peek returns the byte following the most recently read character without +// advancing the scanner. If the scanner is at EOF, peek returns 0. +func (s *Scanner) peek() byte { + if s.rdOffset < len(s.src) { + return s.src[s.rdOffset] + } + return 0 +} + // A mode value is a set of flags (or 0). // They control scanner behavior. // @@ -735,14 +744,13 @@ scanAgain: if '0' <= s.ch && s.ch <= '9' { insertSemi = true tok, lit = s.scanNumber(true) - } else if s.ch == '.' { - s.next() - if s.ch == '.' { + } else { + tok = token.PERIOD + if s.ch == '.' && s.peek() == '.' { s.next() + s.next() // consume last '.' tok = token.ELLIPSIS } - } else { - tok = token.PERIOD } case ',': tok = token.COMMA diff --git a/libgo/go/go/scanner/scanner_test.go b/libgo/go/go/scanner/scanner_test.go index 0aad3680990..36c962209ce 100644 --- a/libgo/go/go/scanner/scanner_test.go +++ b/libgo/go/go/scanner/scanner_test.go @@ -757,6 +757,7 @@ var errors = []struct { {"\a", token.ILLEGAL, 0, "", "illegal character U+0007"}, {`#`, token.ILLEGAL, 0, "", "illegal character U+0023 '#'"}, {`…`, token.ILLEGAL, 0, "", "illegal character U+2026 '…'"}, + {"..", token.PERIOD, 0, "", ""}, // two periods, not invalid token (issue #28112) {`' '`, token.CHAR, 0, `' '`, ""}, {`''`, token.CHAR, 0, `''`, "illegal rune literal"}, {`'12'`, token.CHAR, 0, `'12'`, "illegal rune literal"}, @@ -822,7 +823,7 @@ func TestScanErrors(t *testing.T) { // Verify that no comments show up as literal values when skipping comments. func TestIssue10213(t *testing.T) { - var src = ` + const src = ` var ( A = 1 // foo ) @@ -855,6 +856,23 @@ func TestIssue10213(t *testing.T) { } } +func TestIssue28112(t *testing.T) { + const src = "... .. 0.. .." // make sure to have stand-alone ".." immediately before EOF to test EOF behavior + tokens := []token.Token{token.ELLIPSIS, token.PERIOD, token.PERIOD, token.FLOAT, token.PERIOD, token.PERIOD, token.PERIOD, token.EOF} + var s Scanner + s.Init(fset.AddFile("", fset.Base(), len(src)), []byte(src), nil, 0) + for _, want := range tokens { + pos, got, lit := s.Scan() + if got != want { + t.Errorf("%s: got %s, want %s", fset.Position(pos), got, want) + } + // literals expect to have a (non-empty) literal string and we don't care about other tokens for this test + if tokenclass(got) == literal && lit == "" { + t.Errorf("%s: for %s got empty literal string", fset.Position(pos), got) + } + } +} + func BenchmarkScan(b *testing.B) { b.StopTimer() fset := token.NewFileSet() diff --git a/libgo/go/go/token/position.go b/libgo/go/go/token/position.go index 241133fe263..3f5a390078d 100644 --- a/libgo/go/go/token/position.go +++ b/libgo/go/go/token/position.go @@ -146,7 +146,7 @@ func (f *File) AddLine(offset int) { // MergeLine will panic if given an invalid line number. // func (f *File) MergeLine(line int) { - if line <= 0 { + if line < 1 { panic("illegal line number (line numbering starts at 1)") } f.mutex.Lock() @@ -209,6 +209,21 @@ func (f *File) SetLinesForContent(content []byte) { f.mutex.Unlock() } +// LineStart returns the Pos value of the start of the specified line. +// It ignores any alternative positions set using AddLineColumnInfo. +// LineStart panics if the 1-based line number is invalid. +func (f *File) LineStart(line int) Pos { + if line < 1 { + panic("illegal line number (line numbering starts at 1)") + } + f.mutex.Lock() + defer f.mutex.Unlock() + if line > len(f.lines) { + panic("illegal line number") + } + return Pos(f.base + f.lines[line-1]) +} + // A lineInfo object describes alternative file, line, and column // number information (such as provided via a //line directive) // for a given file offset. diff --git a/libgo/go/go/token/position_test.go b/libgo/go/go/token/position_test.go index 63984bc872c..7d465dffa62 100644 --- a/libgo/go/go/token/position_test.go +++ b/libgo/go/go/token/position_test.go @@ -324,3 +324,18 @@ done checkPos(t, "3. Position", got3, want) } } + +func TestLineStart(t *testing.T) { + const src = "one\ntwo\nthree\n" + fset := NewFileSet() + f := fset.AddFile("input", -1, len(src)) + f.SetLinesForContent([]byte(src)) + + for line := 1; line <= 3; line++ { + pos := f.LineStart(line) + position := fset.Position(pos) + if position.Line != line || position.Column != 1 { + t.Errorf("LineStart(%d) returned wrong pos %d: %s", line, pos, position) + } + } +} diff --git a/libgo/go/go/types/api.go b/libgo/go/go/types/api.go index fcefddf4883..1252aade35f 100644 --- a/libgo/go/go/types/api.go +++ b/libgo/go/go/types/api.go @@ -180,7 +180,7 @@ type Info struct { // // *ast.ImportSpec *PkgName for imports without renames // *ast.CaseClause type-specific *Var for each type switch case clause (incl. default) - // *ast.Field anonymous parameter *Var + // *ast.Field anonymous parameter *Var (incl. unnamed results) // Implicits map[ast.Node]Object @@ -240,7 +240,7 @@ func (info *Info) TypeOf(e ast.Expr) Type { // or nil if not found. // // If id is an embedded struct field, ObjectOf returns the field (*Var) -// it uses, not the type (*TypeName) it defines. +// it defines, not the type (*TypeName) it uses. // // Precondition: the Uses and Defs maps are populated. // @@ -353,20 +353,20 @@ func (conf *Config) Check(path string, fset *token.FileSet, files []*ast.File, i // AssertableTo reports whether a value of type V can be asserted to have type T. func AssertableTo(V *Interface, T Type) bool { - m, _ := assertableTo(V, T) + m, _ := (*Checker)(nil).assertableTo(V, T) return m == nil } // AssignableTo reports whether a value of type V is assignable to a variable of type T. func AssignableTo(V, T Type) bool { x := operand{mode: value, typ: V} - return x.assignableTo(nil, T, nil) // config not needed for non-constant x + return x.assignableTo(nil, T, nil) // check not needed for non-constant x } // ConvertibleTo reports whether a value of type V is convertible to a value of type T. func ConvertibleTo(V, T Type) bool { x := operand{mode: value, typ: V} - return x.convertibleTo(nil, T) // config not needed for non-constant x + return x.convertibleTo(nil, T) // check not needed for non-constant x } // Implements reports whether type V implements interface T. diff --git a/libgo/go/go/types/api_test.go b/libgo/go/go/types/api_test.go index 35050e1b9eb..36296125414 100644 --- a/libgo/go/go/types/api_test.go +++ b/libgo/go/go/types/api_test.go @@ -258,12 +258,23 @@ func TestTypesInfo(t *testing.T) { `(string, bool)`, }, + // issue 28277 + {`package issue28277_a; func f(...int)`, + `...int`, + `[]int`, + }, + {`package issue28277_b; func f(a, b int, c ...[]struct{})`, + `...[]struct{}`, + `[][]struct{}`, + }, + // tests for broken code that doesn't parse or type-check {`package x0; func _() { var x struct {f string}; x.f := 0 }`, `x.f`, `string`}, {`package x1; func _() { var z string; type x struct {f string}; y := &x{q: z}}`, `z`, `string`}, {`package x2; func _() { var a, b string; type x struct {f string}; z := &x{f: a; f: b;}}`, `b`, `string`}, {`package x3; var x = panic("");`, `panic`, `func(interface{})`}, {`package x4; func _() { panic("") }`, `panic`, `func(interface{})`}, + {`package x5; func _() { var x map[string][...]int; x = map[string][...]int{"": {1,2,3}} }`, `x`, `map[string][-1]int`}, } for _, test := range tests { @@ -389,6 +400,8 @@ func TestPredicatesInfo(t *testing.T) { {`package t0; type _ int`, `int`, `type`}, {`package t1; type _ []int`, `[]int`, `type`}, {`package t2; type _ func()`, `func()`, `type`}, + {`package t3; type _ func(int)`, `int`, `type`}, + {`package t3; type _ func(...int)`, `...int`, `type`}, // built-ins {`package b0; var _ = len("")`, `len`, `builtin`}, diff --git a/libgo/go/go/types/assignments.go b/libgo/go/go/types/assignments.go index 27002f66994..efa0cbba502 100644 --- a/libgo/go/go/types/assignments.go +++ b/libgo/go/go/types/assignments.go @@ -57,7 +57,7 @@ func (check *Checker) assignment(x *operand, T Type, context string) { return } - if reason := ""; !x.assignableTo(check.conf, T, &reason) { + if reason := ""; !x.assignableTo(check, T, &reason) { if reason != "" { check.errorf(x.pos(), "cannot use %s as %s value in %s: %s", x, T, context, reason) } else { diff --git a/libgo/go/go/types/builtins.go b/libgo/go/go/types/builtins.go index d3f0c4d40df..ece6d4f530c 100644 --- a/libgo/go/go/types/builtins.go +++ b/libgo/go/go/types/builtins.go @@ -13,7 +13,7 @@ import ( ) // builtin type-checks a call to the built-in specified by id and -// returns true if the call is valid, with *x holding the result; +// reports whether the call is valid, with *x holding the result; // but x.expr is not set. If the call is invalid, the result is // false, and *x is undefined. // @@ -95,7 +95,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b // spec: "As a special case, append also accepts a first argument assignable // to type []byte with a second argument of string type followed by ... . // This form appends the bytes of the string. - if nargs == 2 && call.Ellipsis.IsValid() && x.assignableTo(check.conf, NewSlice(universeByte), nil) { + if nargs == 2 && call.Ellipsis.IsValid() && x.assignableTo(check, NewSlice(universeByte), nil) { arg(x, 1) if x.mode == invalid { return @@ -345,7 +345,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b return } - if !x.assignableTo(check.conf, m.key, nil) { + if !x.assignableTo(check, m.key, nil) { check.invalidArg(x.pos(), "%s is not assignable to %s", x, m.key) return } diff --git a/libgo/go/go/types/call.go b/libgo/go/go/types/call.go index d5c196afe84..1abc1d8a5e4 100644 --- a/libgo/go/go/types/call.go +++ b/libgo/go/go/types/call.go @@ -233,6 +233,7 @@ func (check *Checker) arguments(x *operand, call *ast.CallExpr, sig *Signature, } // evaluate arguments + context := check.sprintf("argument to %s", call.Fun) for i := 0; i < n; i++ { arg(x, i) if x.mode != invalid { @@ -240,7 +241,7 @@ func (check *Checker) arguments(x *operand, call *ast.CallExpr, sig *Signature, if i == n-1 && call.Ellipsis.IsValid() { ellipsis = call.Ellipsis } - check.argument(call.Fun, sig, i, x, ellipsis) + check.argument(call.Fun, sig, i, x, ellipsis, context) } } @@ -258,7 +259,7 @@ func (check *Checker) arguments(x *operand, call *ast.CallExpr, sig *Signature, // argument checks passing of argument x to the i'th parameter of the given signature. // If ellipsis is valid, the argument is followed by ... at that position in the call. -func (check *Checker) argument(fun ast.Expr, sig *Signature, i int, x *operand, ellipsis token.Pos) { +func (check *Checker) argument(fun ast.Expr, sig *Signature, i int, x *operand, ellipsis token.Pos, context string) { check.singleValue(x) if x.mode == invalid { return @@ -298,7 +299,7 @@ func (check *Checker) argument(fun ast.Expr, sig *Signature, i int, x *operand, typ = typ.(*Slice).elem } - check.assignment(x, typ, check.sprintf("argument to %s", fun)) + check.assignment(x, typ, context) } func (check *Checker) selector(x *operand, e *ast.SelectorExpr) { @@ -374,20 +375,28 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr) { switch { case index != nil: // TODO(gri) should provide actual type where the conflict happens - check.invalidOp(e.Sel.Pos(), "ambiguous selector %s", sel) + check.errorf(e.Sel.Pos(), "ambiguous selector %s", sel) case indirect: - check.invalidOp(e.Sel.Pos(), "%s is not in method set of %s", sel, x.typ) + // TODO(gri) be more specific with this error message + check.errorf(e.Sel.Pos(), "%s is not in method set of %s", sel, x.typ) default: - check.invalidOp(e.Sel.Pos(), "%s has no field or method %s", x, sel) + // TODO(gri) should check if capitalization of sel matters and provide better error message in that case + check.errorf(e.Sel.Pos(), "%s.%s undefined (type %s has no field or method %s)", x.expr, sel, x.typ, sel) } goto Error } + // methods may not have a fully set up signature yet + if m, _ := obj.(*Func); m != nil { + check.objDecl(m, nil) + } + if x.mode == typexpr { // method expression m, _ := obj.(*Func) if m == nil { - check.invalidOp(e.Sel.Pos(), "%s has no method %s", x, sel) + // TODO(gri) should check if capitalization of sel matters and provide better error message in that case + check.errorf(e.Sel.Pos(), "%s.%s undefined (type %s has no method %s)", x.expr, sel, x.typ, sel) goto Error } diff --git a/libgo/go/go/types/check.go b/libgo/go/go/types/check.go index 76d9c8917cb..b48d09de22a 100644 --- a/libgo/go/go/types/check.go +++ b/libgo/go/go/types/check.go @@ -76,7 +76,7 @@ type Checker struct { fset *token.FileSet pkg *Package *Info - objMap map[Object]*declInfo // maps package-level object to declaration info + objMap map[Object]*declInfo // maps package-level objects and (non-interface) methods to declaration info impMap map[importKey]*Package // maps (import path, source directory) to (complete or fake) package // information collected during type-checking of a set of package files @@ -85,8 +85,9 @@ type Checker struct { files []*ast.File // package files unusedDotImports map[*Scope]map[*Package]token.Pos // positions of unused dot-imported packages for each file scope - firstErr error // first error encountered - methods map[*TypeName][]*Func // maps package scope type names to associated non-blank, non-interface methods + firstErr error // first error encountered + methods map[*TypeName][]*Func // maps package scope type names to associated non-blank, non-interface methods + // TODO(gri) move interfaces up to the group of fields persistent across check.Files invocations (see also comment in Checker.initFiles) interfaces map[*TypeName]*ifaceInfo // maps interface type names to corresponding interface infos untyped map[ast.Expr]exprInfo // map of expressions without final type delayed []func() // stack of delayed actions @@ -160,11 +161,6 @@ func (check *Checker) pop() Object { return obj } -// pathString returns a string of the form a->b-> ... ->g for an object path [a, b, ... g]. -func (check *Checker) pathString() string { - return objPathString(check.objPath) -} - // NewChecker returns a new Checker instance for a given package. // Package files may be added incrementally via checker.Files. func NewChecker(conf *Config, fset *token.FileSet, pkg *Package, info *Info) *Checker { @@ -197,7 +193,15 @@ func (check *Checker) initFiles(files []*ast.File) { check.firstErr = nil check.methods = nil - check.interfaces = nil + // Don't clear the interfaces cache! It's important that we don't recompute + // ifaceInfos repeatedly (due to multiple check.Files calls) because when + // they are recomputed, they are not used in the context of their original + // declaration (because those types are already type-checked, typically) and + // then they will get the wrong receiver types, which matters for go/types + // clients. It is also safe to not reset the interfaces cache because files + // added to a package cannot change (add methods to) existing interface types; + // they can only add new interfaces. See also the respective comment in + // checker.infoFromTypeName (interfaces.go). Was bug - see issue #29029. check.untyped = nil check.delayed = nil diff --git a/libgo/go/go/types/check_test.go b/libgo/go/go/types/check_test.go index 2bdfc150f41..45e1fcb6056 100644 --- a/libgo/go/go/types/check_test.go +++ b/libgo/go/go/types/check_test.go @@ -92,6 +92,9 @@ var tests = [][]string{ {"testdata/blank.src"}, {"testdata/issue25008b.src", "testdata/issue25008a.src"}, // order (b before a) is crucial! {"testdata/issue26390.src"}, // stand-alone test to ensure case is triggered + {"testdata/issue23203a.src"}, + {"testdata/issue23203b.src"}, + {"testdata/issue28251.src"}, } var fset = token.NewFileSet() diff --git a/libgo/go/go/types/conversions.go b/libgo/go/go/types/conversions.go index 81a65838fe0..fecb7b617ff 100644 --- a/libgo/go/go/types/conversions.go +++ b/libgo/go/go/types/conversions.go @@ -18,7 +18,7 @@ func (check *Checker) conversion(x *operand, T Type) { case constArg && isConstType(T): // constant conversion switch t := T.Underlying().(*Basic); { - case representableConst(x.val, check.conf, t, &x.val): + case representableConst(x.val, check, t, &x.val): ok = true case isInteger(x.typ) && isString(t): codepoint := int64(-1) @@ -31,7 +31,7 @@ func (check *Checker) conversion(x *operand, T Type) { x.val = constant.MakeString(string(codepoint)) ok = true } - case x.convertibleTo(check.conf, T): + case x.convertibleTo(check, T): // non-constant conversion x.mode = value ok = true @@ -76,9 +76,12 @@ func (check *Checker) conversion(x *operand, T Type) { // is tricky because we'd have to run updateExprType on the argument first. // (Issue #21982.) -func (x *operand) convertibleTo(conf *Config, T Type) bool { +// convertibleTo reports whether T(x) is valid. +// The check parameter may be nil if convertibleTo is invoked through an +// exported API call, i.e., when all methods have been type-checked. +func (x *operand) convertibleTo(check *Checker, T Type) bool { // "x is assignable to T" - if x.assignableTo(conf, T, nil) { + if x.assignableTo(check, T, nil) { return true } diff --git a/libgo/go/go/types/decl.go b/libgo/go/go/types/decl.go index 11b68583e38..1e2790a1711 100644 --- a/libgo/go/go/types/decl.go +++ b/libgo/go/go/types/decl.go @@ -64,18 +64,11 @@ func objPathString(path []Object) string { return s } -// useCycleMarking enables the new coloring-based cycle marking scheme -// for package-level objects. Set this flag to false to disable this -// code quickly and revert to the existing mechanism (and comment out -// some of the new tests in cycles5.src that will fail again). -// TODO(gri) remove this for Go 1.12 -const useCycleMarking = true - // objDecl type-checks the declaration of obj in its respective (file) context. -// See check.typ for the details on def and path. -func (check *Checker) objDecl(obj Object, def *Named, path []*TypeName) { +// For the meaning of def, see Checker.definedType, in typexpr.go. +func (check *Checker) objDecl(obj Object, def *Named) { if trace { - check.trace(obj.Pos(), "-- checking %s %s (path = %s, objPath = %s)", obj.color(), obj, pathString(path), check.pathString()) + check.trace(obj.Pos(), "-- checking %s %s (objPath = %s)", obj.color(), obj, objPathString(check.objPath)) check.indent++ defer func() { check.indent-- @@ -147,50 +140,17 @@ func (check *Checker) objDecl(obj Object, def *Named, path []*TypeName) { // order code. switch obj := obj.(type) { case *Const: - if useCycleMarking && check.typeCycle(obj) { - obj.typ = Typ[Invalid] - break - } - if obj.typ == nil { + if check.typeCycle(obj) || obj.typ == nil { obj.typ = Typ[Invalid] } case *Var: - if useCycleMarking && check.typeCycle(obj) { - obj.typ = Typ[Invalid] - break - } - if obj.typ == nil { + if check.typeCycle(obj) || obj.typ == nil { obj.typ = Typ[Invalid] } case *TypeName: - // fixFor26390 enables a temporary work-around to handle alias type names - // that have not been given a type yet even though the underlying type - // is already known. See testdata/issue26390.src for a simple example. - // Set this flag to false to disable this code quickly (and comment - // out the new test in decls4.src that will fail again). - // TODO(gri) remove this for Go 1.12 in favor of a more comprehensive fix - const fixFor26390 = true - if fixFor26390 { - // If we have a package-level alias type name that has not been - // given a type yet but the underlying type is a type name that - // has been given a type already, don't report a cycle but use - // the underlying type name's type instead. The cycle shouldn't - // exist in the first place in this case and is due to the way - // methods are type-checked at the moment. See also the comment - // at the end of Checker.typeDecl below. - if d := check.objMap[obj]; d != nil && d.alias && obj.typ == Typ[Invalid] { - // If we can find the underlying type name syntactically - // and it has a type, use that type. - if tname := check.resolveBaseTypeName(ast.NewIdent(obj.name)); tname != nil && tname.typ != nil { - obj.typ = tname.typ - break - } - } - } - - if useCycleMarking && check.typeCycle(obj) { + if check.typeCycle(obj) { // break cycle // (without this, calling underlying() // below may lead to an endless loop @@ -200,7 +160,7 @@ func (check *Checker) objDecl(obj Object, def *Named, path []*TypeName) { } case *Func: - if useCycleMarking && check.typeCycle(obj) { + if check.typeCycle(obj) { // Don't set obj.typ to Typ[Invalid] here // because plenty of code type-asserts that // functions have a *Signature type. Grey @@ -244,7 +204,7 @@ func (check *Checker) objDecl(obj Object, def *Named, path []*TypeName) { check.varDecl(obj, d.lhs, d.typ, d.init) case *TypeName: // invalid recursive types are detected via path - check.typeDecl(obj, d.typ, def, path, d.alias) + check.typeDecl(obj, d.typ, def, d.alias) case *Func: // functions may be recursive - no need to track dependencies check.funcDecl(obj, d) @@ -260,23 +220,20 @@ func (check *Checker) objDecl(obj Object, def *Named, path []*TypeName) { // Indirections are used to break type cycles. var indir = NewTypeName(token.NoPos, nil, "*", nil) -// cutCycle is a sentinel type name that is pushed onto the object path -// to indicate that a cycle doesn't actually exist. This is currently -// needed to break cycles formed via method declarations because they -// are type-checked together with their receiver base types. Once methods -// are type-checked separately (see also TODO in Checker.typeDecl), we -// can get rid of this. -var cutCycle = NewTypeName(token.NoPos, nil, "!", nil) - // typeCycle checks if the cycle starting with obj is valid and // reports an error if it is not. // TODO(gri) rename s/typeCycle/cycle/ once we don't need the other // cycle method anymore. func (check *Checker) typeCycle(obj Object) (isCycle bool) { - d := check.objMap[obj] - if d == nil { - check.dump("%v: %s should have been declared", obj.Pos(), obj) - unreachable() + // The object map contains the package scope objects and the non-interface methods. + if debug { + info := check.objMap[obj] + inObjMap := info != nil && (info.fdecl == nil || info.fdecl.Recv == nil) // exclude methods + isPkgObj := obj.Parent() == check.pkg.scope + if isPkgObj != inObjMap { + check.dump("%v: inconsistent object map for %s (isPkgObj = %v, inObjMap = %v)", obj.Pos(), obj, isPkgObj, inObjMap) + unreachable() + } } // Given the number of constants and variables (nval) in the cycle @@ -303,17 +260,28 @@ func (check *Checker) typeCycle(obj Object) (isCycle bool) { case *Const, *Var: nval++ case *TypeName: - switch { - case obj == indir: + if obj == indir { ncycle-- // don't count (indirections are not objects) hasIndir = true - case obj == cutCycle: - // The cycle is not real and only caused by the fact - // that we type-check methods when we type-check their - // receiver base types. - return false - case !check.objMap[obj].alias: - hasTDef = true + } else { + // Determine if the type name is an alias or not. For + // package-level objects, use the object map which + // provides syntactic information (which doesn't rely + // on the order in which the objects are set up). For + // local objects, we can rely on the order, so use + // the object's predicate. + // TODO(gri) It would be less fragile to always access + // the syntactic information. We should consider storing + // this information explicitly in the object. + var alias bool + if d := check.objMap[obj]; d != nil { + alias = d.alias // package-level object + } else { + alias = obj.IsAlias() // function local object + } + if !alias { + hasTDef = true + } } case *Func: // ignored for now @@ -373,7 +341,7 @@ func (check *Checker) constDecl(obj *Const, typ, init ast.Expr) { // determine type, if any if typ != nil { - t := check.typExpr(typ, nil, nil) + t := check.typ(typ) if !isConstType(t) { // don't report an error if the type is an invalid C (defined) type // (issue #22090) @@ -399,7 +367,7 @@ func (check *Checker) varDecl(obj *Var, lhs []*Var, typ, init ast.Expr) { // determine type, if any if typ != nil { - obj.typ = check.typExpr(typ, nil, nil) + obj.typ = check.typ(typ) // We cannot spread the type to all lhs variables if there // are more than one since that would mark them as checked // (see Checker.objDecl) and the assignment of init exprs, @@ -474,13 +442,13 @@ func (n *Named) setUnderlying(typ Type) { } } -func (check *Checker) typeDecl(obj *TypeName, typ ast.Expr, def *Named, path []*TypeName, alias bool) { +func (check *Checker) typeDecl(obj *TypeName, typ ast.Expr, def *Named, alias bool) { assert(obj.typ == nil) if alias { obj.typ = Typ[Invalid] - obj.typ = check.typExpr(typ, nil, append(path, obj)) + obj.typ = check.typ(typ) } else { @@ -489,7 +457,7 @@ func (check *Checker) typeDecl(obj *TypeName, typ ast.Expr, def *Named, path []* obj.typ = named // make sure recursive type declarations terminate // determine underlying type of named - check.typExpr(typ, named, append(path, obj)) + check.definedType(typ, named) // The underlying type of named may be itself a named type that is // incomplete: @@ -508,11 +476,6 @@ func (check *Checker) typeDecl(obj *TypeName, typ ast.Expr, def *Named, path []* } - // check and add associated methods - // TODO(gri) It's easy to create pathological cases where the - // current approach is incorrect: In general we need to know - // and add all methods _before_ type-checking the type. - // See https://play.golang.org/p/WMpE0q2wK8 check.addMethodDecls(obj) } @@ -552,17 +515,7 @@ func (check *Checker) addMethodDecls(obj *TypeName) { } } - if useCycleMarking { - // Suppress detection of type cycles occurring through method - // declarations - they wouldn't exist if methods were type- - // checked separately from their receiver base types. See also - // comment at the end of Checker.typeDecl. - // TODO(gri) Remove this once methods are type-checked separately. - check.push(cutCycle) - defer check.pop() - } - - // type-check methods + // add valid methods for _, m := range methods { // spec: "For a base type, the non-blank names of methods bound // to it must be unique." @@ -580,9 +533,6 @@ func (check *Checker) addMethodDecls(obj *TypeName) { continue } - // type-check - check.objDecl(m, nil, nil) - if base != nil { base.methods = append(base.methods, m) } @@ -730,8 +680,10 @@ func (check *Checker) declStmt(decl ast.Decl) { // the innermost containing block." scopePos := s.Name.Pos() check.declare(check.scope, s.Name, obj, scopePos) - check.typeDecl(obj, s.Type, nil, nil, s.Assign.IsValid()) - + // mark and unmark type before calling typeDecl; its type is still nil (see Checker.objDecl) + obj.setColor(grey + color(check.push(obj))) + check.typeDecl(obj, s.Type, nil, s.Assign.IsValid()) + check.pop().setColor(black) default: check.invalidAST(s.Pos(), "const, type, or var declaration expected") } diff --git a/libgo/go/go/types/errors.go b/libgo/go/go/types/errors.go index 4c8d8537ee6..68c96c037ea 100644 --- a/libgo/go/go/types/errors.go +++ b/libgo/go/go/types/errors.go @@ -10,6 +10,7 @@ import ( "fmt" "go/ast" "go/token" + "path" "strings" ) @@ -25,7 +26,7 @@ func unreachable() { func (check *Checker) qualifier(pkg *Package) string { if pkg != check.pkg { - return pkg.path + return path.Base(pkg.path) // avoid excessively long path names in error messages } return "" } diff --git a/libgo/go/go/types/example_test.go b/libgo/go/go/types/example_test.go index a0c9c217ff9..a2e481bd300 100644 --- a/libgo/go/go/types/example_test.go +++ b/libgo/go/go/types/example_test.go @@ -51,6 +51,7 @@ type Celsius float64 func (c Celsius) String() string { return fmt.Sprintf("%g°C", c) } func FToC(f float64) Celsius { return Celsius(f - 32 / 9 * 5) } const Boiling Celsius = 100 +func Unused() { {}; {{ var x int; _ = x }} } // make sure empty block scopes get printed `}, } { f, err := parser.ParseFile(fset, file.name, file.input, 0) @@ -81,23 +82,33 @@ const Boiling Celsius = 100 // . const temperature.Boiling temperature.Celsius // . type temperature.Celsius float64 // . func temperature.FToC(f float64) temperature.Celsius + // . func temperature.Unused() // . func temperature.main() - // // . main.go scope { // . . package fmt - // // . . function scope { // . . . var freezing temperature.Celsius - // . . }. } + // . . } + // . } // . celsius.go scope { // . . package fmt - // // . . function scope { // . . . var c temperature.Celsius // . . } // . . function scope { // . . . var f float64 - // . . }. }} + // . . } + // . . function scope { + // . . . block scope { + // . . . } + // . . . block scope { + // . . . . block scope { + // . . . . . var x int + // . . . . } + // . . . } + // . . } + // . } + // } } // ExampleMethodSet prints the method sets of various types. diff --git a/libgo/go/go/types/expr.go b/libgo/go/go/types/expr.go index c1deaf8325a..0dc007069fa 100644 --- a/libgo/go/go/types/expr.go +++ b/libgo/go/go/types/expr.go @@ -187,11 +187,20 @@ func roundFloat64(x constant.Value) constant.Value { // representable floating-point and complex values, and to an Int // value for integer values; it is left alone otherwise. // It is ok to provide the addressof the first argument for rounded. -func representableConst(x constant.Value, conf *Config, typ *Basic, rounded *constant.Value) bool { +// +// The check parameter may be nil if representableConst is invoked +// (indirectly) through an exported API call (AssignableTo, ConvertibleTo) +// because we don't need the Checker's config for those calls. +func representableConst(x constant.Value, check *Checker, typ *Basic, rounded *constant.Value) bool { if x.Kind() == constant.Unknown { return true // avoid follow-up errors } + var conf *Config + if check != nil { + conf = check.conf + } + switch { case isInteger(typ): x := constant.ToInt(x) @@ -323,7 +332,7 @@ func representableConst(x constant.Value, conf *Config, typ *Basic, rounded *con // representable checks that a constant operand is representable in the given basic type. func (check *Checker) representable(x *operand, typ *Basic) { assert(x.mode == constant_) - if !representableConst(x.val, check.conf, typ, &x.val) { + if !representableConst(x.val, check, typ, &x.val) { var msg string if isNumeric(x.typ) && isNumeric(typ) { // numeric conversion : error msg @@ -452,7 +461,11 @@ func (check *Checker) updateExprType(x ast.Expr, typ Type, final bool) { check.invalidOp(x.Pos(), "shifted operand %s (type %s) must be integer", x, typ) return } - } else if old.val != nil { + // Even if we have an integer, if the value is a constant we + // still must check that it is representable as the specific + // int type requested (was issue #22969). Fall through here. + } + if old.val != nil { // If x is a constant, it must be representable as a value of typ. c := operand{old.mode, x, old.typ, old.val, 0} check.convertUntyped(&c, typ) @@ -576,15 +589,15 @@ func (check *Checker) comparison(x, y *operand, op token.Token) { // spec: "In any comparison, the first operand must be assignable // to the type of the second operand, or vice versa." err := "" - if x.assignableTo(check.conf, y.typ, nil) || y.assignableTo(check.conf, x.typ, nil) { + if x.assignableTo(check, y.typ, nil) || y.assignableTo(check, x.typ, nil) { defined := false switch op { case token.EQL, token.NEQ: // spec: "The equality operators == and != apply to operands that are comparable." - defined = Comparable(x.typ) || x.isNil() && hasNil(y.typ) || y.isNil() && hasNil(x.typ) + defined = Comparable(x.typ) && Comparable(y.typ) || x.isNil() && hasNil(y.typ) || y.isNil() && hasNil(x.typ) case token.LSS, token.LEQ, token.GTR, token.GEQ: // spec: The ordering operators <, <=, >, and >= apply to operands that are ordered." - defined = isOrdered(x.typ) + defined = isOrdered(x.typ) && isOrdered(y.typ) default: unreachable() } @@ -1010,7 +1023,7 @@ func (check *Checker) exprInternal(x *operand, e ast.Expr, hint Type) exprKind { goto Error // error was reported before case *ast.Ident: - check.ident(x, e, nil, nil) + check.ident(x, e, nil, false) case *ast.Ellipsis: // ellipses are handled explicitly where they are legal @@ -1064,7 +1077,7 @@ func (check *Checker) exprInternal(x *operand, e ast.Expr, hint Type) exprKind { break } } - typ = check.typExpr(e.Type, nil, nil) + typ = check.typ(e.Type) base = typ case hint != nil: @@ -1156,12 +1169,23 @@ func (check *Checker) exprInternal(x *operand, e ast.Expr, hint Type) exprKind { goto Error } n := check.indexedElts(e.Elts, utyp.elem, utyp.len) - // If we have an "open" [...]T array, set the length now that we know it - // and record the type for [...] (usually done by check.typExpr which is - // not called for [...]). + // If we have an array of unknown length (usually [...]T arrays, but also + // arrays [n]T where n is invalid) set the length now that we know it and + // record the type for the array (usually done by check.typ which is not + // called for [...]T). We handle [...]T arrays and arrays with invalid + // length the same here because it makes sense to "guess" the length for + // the latter if we have a composite literal; e.g. for [n]int{1, 2, 3} + // where n is invalid for some reason, it seems fair to assume it should + // be 3 (see also Checked.arrayLength and issue #27346). if utyp.len < 0 { utyp.len = n - check.recordTypeAndValue(e.Type, typexpr, utyp, nil) + // e.Type is missing if we have a composite literal element + // that is itself a composite literal with omitted type. In + // that case there is nothing to record (there is no type in + // the source at that point). + if e.Type != nil { + check.recordTypeAndValue(e.Type, typexpr, utyp, nil) + } } case *Slice: @@ -1433,7 +1457,7 @@ func (check *Checker) exprInternal(x *operand, e ast.Expr, hint Type) exprKind { check.invalidAST(e.Pos(), "use of .(type) outside type switch") goto Error } - T := check.typExpr(e.Type, nil, nil) + T := check.typ(e.Type) if T == Typ[Invalid] { goto Error } @@ -1536,7 +1560,7 @@ func keyVal(x constant.Value) interface{} { // typeAssertion checks that x.(T) is legal; xtyp must be the type of x. func (check *Checker) typeAssertion(pos token.Pos, x *operand, xtyp *Interface, T Type) { - method, wrongType := assertableTo(xtyp, T) + method, wrongType := check.assertableTo(xtyp, T) if method == nil { return } diff --git a/libgo/go/go/types/gotype.go b/libgo/go/go/types/gotype.go index cde373f3556..19dd702c451 100644 --- a/libgo/go/go/types/gotype.go +++ b/libgo/go/go/types/gotype.go @@ -297,7 +297,7 @@ func checkPkgFiles(files []*ast.File) { } report(err) }, - Importer: importer.For(*compiler, nil), + Importer: importer.ForCompiler(fset, *compiler, nil), Sizes: types.SizesFor(build.Default.Compiler, build.Default.GOARCH), } diff --git a/libgo/go/go/types/interfaces.go b/libgo/go/go/types/interfaces.go index e4b42dc5a36..e0ef83adcc5 100644 --- a/libgo/go/go/types/interfaces.go +++ b/libgo/go/go/types/interfaces.go @@ -144,7 +144,7 @@ func (check *Checker) infoFromTypeLit(scope *Scope, iface *ast.InterfaceType, tn } if trace { - check.trace(iface.Pos(), "-- collect methods for %v (path = %s, objPath = %s)", iface, pathString(path), check.pathString()) + check.trace(iface.Pos(), "-- collect methods for %v (path = %s, objPath = %s)", iface, pathString(path), objPathString(check.objPath)) check.indent++ defer func() { check.indent-- @@ -336,6 +336,14 @@ typenameLoop: return check.infoFromQualifiedTypeName(decl.file, typ) case *ast.InterfaceType: // type tname interface{...} + // If tname is fully type-checked at this point (tname.color() == black) + // we could use infoFromType here. But in this case, the interface must + // be in the check.interfaces cache as well, which will be hit when we + // call infoFromTypeLit below, and which will be faster. It is important + // that we use that previously computed interface because its methods + // have the correct receiver type (for go/types clients). Thus, the + // check.interfaces cache must be up-to-date across even across multiple + // check.Files calls (was bug - see issue #29029). return check.infoFromTypeLit(decl.file, typ, tname, path) } // type tname X // and X is not an interface type diff --git a/libgo/go/go/types/issues_test.go b/libgo/go/go/types/issues_test.go index 6e0d4063f32..c9f54139206 100644 --- a/libgo/go/go/types/issues_test.go +++ b/libgo/go/go/types/issues_test.go @@ -7,6 +7,7 @@ package types_test import ( + "bytes" "fmt" "go/ast" "go/importer" @@ -19,17 +20,17 @@ import ( . "go/types" ) -func TestIssue5770(t *testing.T) { - t.Skip("skipping for gccgo--no importer") - - src := `package p; type S struct{T}` +func mustParse(t *testing.T, src string) *ast.File { f, err := parser.ParseFile(fset, "", src, 0) if err != nil { t.Fatal(err) } - + return f +} +func TestIssue5770(t *testing.T) { + f := mustParse(t, `package p; type S struct{T}`) conf := Config{Importer: importer.Default()} - _, err = conf.Check(f.Name.Name, fset, []*ast.File{f}, nil) // do not crash + _, err := conf.Check(f.Name.Name, fset, []*ast.File{f}, nil) // do not crash want := "undeclared name: T" if err == nil || !strings.Contains(err.Error(), want) { t.Errorf("got: %v; want: %s", err, want) @@ -48,14 +49,11 @@ var ( _ = (interface{})("foo") _ = (interface{})(nil) )` - f, err := parser.ParseFile(fset, "", src, 0) - if err != nil { - t.Fatal(err) - } + f := mustParse(t, src) var conf Config types := make(map[ast.Expr]TypeAndValue) - _, err = conf.Check(f.Name.Name, fset, []*ast.File{f}, &Info{Types: types}) + _, err := conf.Check(f.Name.Name, fset, []*ast.File{f}, &Info{Types: types}) if err != nil { t.Fatal(err) } @@ -96,14 +94,11 @@ func f() int { return 0 } ` - f, err := parser.ParseFile(fset, "", src, 0) - if err != nil { - t.Fatal(err) - } + f := mustParse(t, src) var conf Config types := make(map[ast.Expr]TypeAndValue) - _, err = conf.Check(f.Name.Name, fset, []*ast.File{f}, &Info{Types: types}) + _, err := conf.Check(f.Name.Name, fset, []*ast.File{f}, &Info{Types: types}) if err != nil { t.Fatal(err) } @@ -130,14 +125,11 @@ package p func (T) m() (res bool) { return } type T struct{} // receiver type after method declaration ` - f, err := parser.ParseFile(fset, "", src, 0) - if err != nil { - t.Fatal(err) - } + f := mustParse(t, src) var conf Config defs := make(map[*ast.Ident]Object) - _, err = conf.Check(f.Name.Name, fset, []*ast.File{f}, &Info{Defs: defs}) + _, err := conf.Check(f.Name.Name, fset, []*ast.File{f}, &Info{Defs: defs}) if err != nil { t.Fatal(err) } @@ -164,6 +156,8 @@ func _() { _, _, _ = x, y, z // uses x, y, z } ` + f := mustParse(t, src) + const want = `L3 defs func p._() L4 defs const w untyped int L5 defs var x int @@ -175,16 +169,11 @@ L7 uses var x int L7 uses var y int L7 uses var z int` - f, err := parser.ParseFile(fset, "", src, 0) - if err != nil { - t.Fatal(err) - } - // don't abort at the first error conf := Config{Error: func(err error) { t.Log(err) }} defs := make(map[*ast.Ident]Object) uses := make(map[*ast.Ident]Object) - _, err = conf.Check(f.Name.Name, fset, []*ast.File{f}, &Info{Defs: defs, Uses: uses}) + _, err := conf.Check(f.Name.Name, fset, []*ast.File{f}, &Info{Defs: defs, Uses: uses}) if s := fmt.Sprint(err); !strings.HasSuffix(s, "cannot assign to w") { t.Errorf("Check: unexpected error: %s", s) } @@ -263,13 +252,10 @@ func main() { } ` f := func(test, src string) { - f, err := parser.ParseFile(fset, "", src, 0) - if err != nil { - t.Fatal(err) - } + f := mustParse(t, src) cfg := Config{Importer: importer.Default()} info := Info{Uses: make(map[*ast.Ident]Object)} - _, err = cfg.Check("main", fset, []*ast.File{f}, &info) + _, err := cfg.Check("main", fset, []*ast.File{f}, &info) if err != nil { t.Fatal(err) } @@ -296,11 +282,7 @@ func main() { } func TestIssue22525(t *testing.T) { - src := `package p; func f() { var a, b, c, d, e int }` - f, err := parser.ParseFile(fset, "", src, 0) - if err != nil { - t.Fatal(err) - } + f := mustParse(t, `package p; func f() { var a, b, c, d, e int }`) got := "\n" conf := Config{Error: func(err error) { got += err.Error() + "\n" }} @@ -330,14 +312,11 @@ func TestIssue25627(t *testing.T) { `struct { *I }`, `struct { a int; b Missing; *Missing }`, } { - f, err := parser.ParseFile(fset, "", prefix+src, 0) - if err != nil { - t.Fatal(err) - } + f := mustParse(t, prefix+src) cfg := Config{Importer: importer.Default(), Error: func(err error) {}} info := &Info{Types: make(map[ast.Expr]TypeAndValue)} - _, err = cfg.Check(f.Name.Name, fset, []*ast.File{f}, info) + _, err := cfg.Check(f.Name.Name, fset, []*ast.File{f}, info) if err != nil { if _, ok := err.(Error); !ok { t.Fatal(err) @@ -357,3 +336,132 @@ func TestIssue25627(t *testing.T) { }) } } + +func TestIssue28005(t *testing.T) { + // method names must match defining interface name for this test + // (see last comment in this function) + sources := [...]string{ + "package p; type A interface{ A() }", + "package p; type B interface{ B() }", + "package p; type X interface{ A; B }", + } + + // compute original file ASTs + var orig [len(sources)]*ast.File + for i, src := range sources { + orig[i] = mustParse(t, src) + } + + // run the test for all order permutations of the incoming files + for _, perm := range [][len(sources)]int{ + {0, 1, 2}, + {0, 2, 1}, + {1, 0, 2}, + {1, 2, 0}, + {2, 0, 1}, + {2, 1, 0}, + } { + // create file order permutation + files := make([]*ast.File, len(sources)) + for i := range perm { + files[i] = orig[perm[i]] + } + + // type-check package with given file order permutation + var conf Config + info := &Info{Defs: make(map[*ast.Ident]Object)} + _, err := conf.Check("", fset, files, info) + if err != nil { + t.Fatal(err) + } + + // look for interface object X + var obj Object + for name, def := range info.Defs { + if name.Name == "X" { + obj = def + break + } + } + if obj == nil { + t.Fatal("interface not found") + } + iface := obj.Type().Underlying().(*Interface) // I must be an interface + + // Each iface method m is embedded; and m's receiver base type name + // must match the method's name per the choice in the source file. + for i := 0; i < iface.NumMethods(); i++ { + m := iface.Method(i) + recvName := m.Type().(*Signature).Recv().Type().(*Named).Obj().Name() + if recvName != m.Name() { + t.Errorf("perm %v: got recv %s; want %s", perm, recvName, m.Name()) + } + } + } +} + +func TestIssue28282(t *testing.T) { + // create type interface { error } + et := Universe.Lookup("error").Type() + it := NewInterfaceType(nil, []Type{et}) + it.Complete() + // verify that after completing the interface, the embedded method remains unchanged + want := et.Underlying().(*Interface).Method(0) + got := it.Method(0) + if got != want { + t.Fatalf("%s.Method(0): got %q (%p); want %q (%p)", it, got, got, want, want) + } + // verify that lookup finds the same method in both interfaces (redundant check) + obj, _, _ := LookupFieldOrMethod(et, false, nil, "Error") + if obj != want { + t.Fatalf("%s.Lookup: got %q (%p); want %q (%p)", et, obj, obj, want, want) + } + obj, _, _ = LookupFieldOrMethod(it, false, nil, "Error") + if obj != want { + t.Fatalf("%s.Lookup: got %q (%p); want %q (%p)", it, obj, obj, want, want) + } +} + +func TestIssue29029(t *testing.T) { + f1 := mustParse(t, `package p; type A interface { M() }`) + f2 := mustParse(t, `package p; var B interface { A }`) + + // printInfo prints the *Func definitions recorded in info, one *Func per line. + printInfo := func(info *Info) string { + var buf bytes.Buffer + for _, obj := range info.Defs { + if fn, ok := obj.(*Func); ok { + fmt.Fprintln(&buf, fn) + } + } + return buf.String() + } + + // The *Func (method) definitions for package p must be the same + // independent on whether f1 and f2 are type-checked together, or + // incrementally. + + // type-check together + var conf Config + info := &Info{Defs: make(map[*ast.Ident]Object)} + check := NewChecker(&conf, fset, NewPackage("", "p"), info) + if err := check.Files([]*ast.File{f1, f2}); err != nil { + t.Fatal(err) + } + want := printInfo(info) + + // type-check incrementally + info = &Info{Defs: make(map[*ast.Ident]Object)} + check = NewChecker(&conf, fset, NewPackage("", "p"), info) + if err := check.Files([]*ast.File{f1}); err != nil { + t.Fatal(err) + } + if err := check.Files([]*ast.File{f2}); err != nil { + t.Fatal(err) + } + got := printInfo(info) + + if got != want { + t.Errorf("\ngot : %swant: %s", got, want) + } +} diff --git a/libgo/go/go/types/lookup.go b/libgo/go/go/types/lookup.go index f31ef9cfe94..e6764f45a0e 100644 --- a/libgo/go/go/types/lookup.go +++ b/libgo/go/go/types/lookup.go @@ -6,6 +6,11 @@ package types +// Internal use of LookupFieldOrMethod: If the obj result is a method +// associated with a concrete (non-interface) type, the method's signature +// may not be fully set up. Call Checker.objDecl(obj, nil) before accessing +// the method's type. + // LookupFieldOrMethod looks up a field or method with given package and name // in T and returns the corresponding *Var or *Func, an index sequence, and a // bool indicating if there were any pointer indirections on the path to the @@ -112,7 +117,7 @@ func lookupFieldOrMethod(T Type, addressable bool, pkg *Package, name string) (o // look for a matching attached method if i, m := lookupMethod(named.methods, pkg, name); m != nil { // potential match - assert(m.typ != nil) + // caution: method may not have a proper signature yet index = concat(e.index, i) if obj != nil || e.multiples { return nil, index, false // collision @@ -248,6 +253,14 @@ func lookupType(m map[Type]int, typ Type) (int, bool) { // x is of interface type V). // func MissingMethod(V Type, T *Interface, static bool) (method *Func, wrongType bool) { + return (*Checker)(nil).missingMethod(V, T, static) +} + +// missingMethod is like MissingMethod but accepts a receiver. +// The receiver may be nil if missingMethod is invoked through +// an exported API call (such as MissingMethod), i.e., when all +// methods have been type-checked. +func (check *Checker) missingMethod(V Type, T *Interface, static bool) (method *Func, wrongType bool) { // fast path for common case if T.Empty() { return @@ -275,11 +288,17 @@ func MissingMethod(V Type, T *Interface, static bool) (method *Func, wrongType b for _, m := range T.allMethods { obj, _, _ := lookupFieldOrMethod(V, false, m.pkg, m.name) + // we must have a method (not a field of matching function type) f, _ := obj.(*Func) if f == nil { return m, false } + // methods may not have a fully set up signature yet + if check != nil { + check.objDecl(f, nil) + } + if !Identical(f.typ, m.typ) { return m, true } @@ -291,14 +310,16 @@ func MissingMethod(V Type, T *Interface, static bool) (method *Func, wrongType b // assertableTo reports whether a value of type V can be asserted to have type T. // It returns (nil, false) as affirmative answer. Otherwise it returns a missing // method required by V and whether it is missing or just has the wrong type. -func assertableTo(V *Interface, T Type) (method *Func, wrongType bool) { +// The receiver may be nil if assertableTo is invoked through an exported API call +// (such as AssertableTo), i.e., when all methods have been type-checked. +func (check *Checker) assertableTo(V *Interface, T Type) (method *Func, wrongType bool) { // no static check is required if T is an interface // spec: "If T is an interface type, x.(T) asserts that the // dynamic type of x implements the interface T." if _, ok := T.Underlying().(*Interface); ok && !strict { return } - return MissingMethod(T, V, false) + return check.missingMethod(T, V, false) } // deref dereferences typ if it is a *Pointer and returns its base and true. diff --git a/libgo/go/go/types/methodset.go b/libgo/go/go/types/methodset.go index 2b810da7283..619c4484923 100644 --- a/libgo/go/go/types/methodset.go +++ b/libgo/go/go/types/methodset.go @@ -255,8 +255,20 @@ func (s methodSet) add(list []*Func, index []int, indirect bool, multiples bool) } // ptrRecv reports whether the receiver is of the form *T. -// The receiver must exist. func ptrRecv(f *Func) bool { - _, isPtr := deref(f.typ.(*Signature).recv.typ) - return isPtr + // If a method's receiver type is set, use that as the source of truth for the receiver. + // Caution: Checker.funcDecl (decl.go) marks a function by setting its type to an empty + // signature. We may reach here before the signature is fully set up: we must explicitly + // check if the receiver is set (we cannot just look for non-nil f.typ). + if sig, _ := f.typ.(*Signature); sig != nil && sig.recv != nil { + _, isPtr := deref(sig.recv.typ) + return isPtr + } + + // If a method's type is not set it may be a method/function that is: + // 1) client-supplied (via NewFunc with no signature), or + // 2) internally created but not yet type-checked. + // For case 1) we can't do anything; the client must know what they are doing. + // For case 2) we can use the information gathered by the resolver. + return f.hasPtrRecv } diff --git a/libgo/go/go/types/object.go b/libgo/go/go/types/object.go index 07adfbc34c3..cf773238a0d 100644 --- a/libgo/go/go/types/object.go +++ b/libgo/go/go/types/object.go @@ -294,6 +294,7 @@ func (*Var) isDependency() {} // a variable may be a dependency of an initializa // An abstract method may belong to many interfaces due to embedding. type Func struct { object + hasPtrRecv bool // only valid for methods that don't have a type yet } // NewFunc returns a new function with the given signature, representing @@ -304,7 +305,7 @@ func NewFunc(pos token.Pos, pkg *Package, name string, sig *Signature) *Func { if sig != nil { typ = sig } - return &Func{object{nil, pos, pkg, name, typ, 0, colorFor(typ), token.NoPos}} + return &Func{object{nil, pos, pkg, name, typ, 0, colorFor(typ), token.NoPos}, false} } // FullName returns the package- or receiver-type-qualified name of diff --git a/libgo/go/go/types/operand.go b/libgo/go/go/types/operand.go index 07247bd6f58..97ca6c622fd 100644 --- a/libgo/go/go/types/operand.go +++ b/libgo/go/go/types/operand.go @@ -201,7 +201,9 @@ func (x *operand) isNil() bool { // assignableTo reports whether x is assignable to a variable of type T. // If the result is false and a non-nil reason is provided, it may be set // to a more detailed explanation of the failure (result != ""). -func (x *operand) assignableTo(conf *Config, T Type, reason *string) bool { +// The check parameter may be nil if assignableTo is invoked through +// an exported API call, i.e., when all methods have been type-checked. +func (x *operand) assignableTo(check *Checker, T Type, reason *string) bool { if x.mode == invalid || T == Typ[Invalid] { return true // avoid spurious errors } @@ -226,7 +228,7 @@ func (x *operand) assignableTo(conf *Config, T Type, reason *string) bool { return true } if x.mode == constant_ { - return representableConst(x.val, conf, t, nil) + return representableConst(x.val, check, t, nil) } // The result of a comparison is an untyped boolean, // but may not be a constant. @@ -249,7 +251,7 @@ func (x *operand) assignableTo(conf *Config, T Type, reason *string) bool { // T is an interface type and x implements T if Ti, ok := Tu.(*Interface); ok { - if m, wrongType := MissingMethod(x.typ, Ti, true); m != nil /* Implements(x.typ, Ti) */ { + if m, wrongType := check.missingMethod(x.typ, Ti, true); m != nil /* Implements(x.typ, Ti) */ { if reason != nil { if wrongType { *reason = "wrong type for method " + m.Name() diff --git a/libgo/go/go/types/resolver.go b/libgo/go/go/types/resolver.go index 5cbaba187b9..41741e5882d 100644 --- a/libgo/go/go/types/resolver.go +++ b/libgo/go/go/types/resolver.go @@ -420,6 +420,10 @@ func (check *Checker) collectObjects() { check.recordDef(d.Name, obj) } info := &declInfo{file: fileScope, fdecl: d} + // Methods are not package-level objects but we still track them in the + // object map so that we can handle them like regular functions (if the + // receiver is invalid); also we need their fdecl info when associating + // them with their receiver base type, below. check.objMap[obj] = info obj.setOrder(uint32(len(check.objMap))) @@ -456,67 +460,98 @@ func (check *Checker) collectObjects() { for _, f := range methods { fdecl := check.objMap[f].fdecl if list := fdecl.Recv.List; len(list) > 0 { - // f is a method - // receiver may be of the form T or *T, possibly with parentheses - typ := unparen(list[0].Type) - if ptr, _ := typ.(*ast.StarExpr); ptr != nil { - typ = unparen(ptr.X) - } - if base, _ := typ.(*ast.Ident); base != nil { - // base is a potential base type name; determine - // "underlying" defined type and associate f with it - if tname := check.resolveBaseTypeName(base); tname != nil { - check.methods[tname] = append(check.methods[tname], f) - } + // f is a method. + // Determine the receiver base type and associate f with it. + ptr, base := check.resolveBaseTypeName(list[0].Type) + if base != nil { + f.hasPtrRecv = ptr + check.methods[base] = append(check.methods[base], f) } } } } -// resolveBaseTypeName returns the non-alias receiver base type name, -// explicitly declared in the package scope, for the given receiver -// type name; or nil. -func (check *Checker) resolveBaseTypeName(name *ast.Ident) *TypeName { +// resolveBaseTypeName returns the non-alias base type name for typ, and whether +// there was a pointer indirection to get to it. The base type name must be declared +// in package scope, and there can be at most one pointer indirection. If no such type +// name exists, the returned base is nil. +func (check *Checker) resolveBaseTypeName(typ ast.Expr) (ptr bool, base *TypeName) { + // Algorithm: Starting from a type expression, which may be a name, + // we follow that type through alias declarations until we reach a + // non-alias type name. If we encounter anything but pointer types or + // parentheses we're done. If we encounter more than one pointer type + // we're done. var path []*TypeName for { + typ = unparen(typ) + + // check if we have a pointer type + if pexpr, _ := typ.(*ast.StarExpr); pexpr != nil { + // if we've already seen a pointer, we're done + if ptr { + return false, nil + } + ptr = true + typ = unparen(pexpr.X) // continue with pointer base type + } + + // typ must be the name + name, _ := typ.(*ast.Ident) + if name == nil { + return false, nil + } + // name must denote an object found in the current package scope // (note that dot-imported objects are not in the package scope!) obj := check.pkg.scope.Lookup(name.Name) if obj == nil { - return nil + return false, nil } + // the object must be a type name... tname, _ := obj.(*TypeName) if tname == nil { - return nil + return false, nil } // ... which we have not seen before if check.cycle(tname, path, false) { - return nil + return false, nil } // we're done if tdecl defined tname as a new type // (rather than an alias) tdecl := check.objMap[tname] // must exist for objects in package scope if !tdecl.alias { - return tname + return ptr, tname } - // Otherwise, if tdecl defined an alias for a (possibly parenthesized) - // type which is not an (unqualified) named type, we're done because - // receiver base types must be named types declared in this package. - typ := unparen(tdecl.typ) // a type may be parenthesized - name, _ = typ.(*ast.Ident) - if name == nil { - return nil - } - - // continue resolving name + // otherwise, continue resolving + typ = tdecl.typ path = append(path, tname) } } +// cycle reports whether obj appears in path or not. +// If it does, and report is set, it also reports a cycle error. +func (check *Checker) cycle(obj *TypeName, path []*TypeName, report bool) bool { + // (it's ok to iterate forward because each named type appears at most once in path) + for i, prev := range path { + if prev == obj { + if report { + check.errorf(obj.pos, "illegal cycle in declaration of %s", obj.name) + // print cycle + for _, obj := range path[i:] { + check.errorf(obj.Pos(), "\t%s refers to", obj.Name()) // secondary error, \t indented + } + check.errorf(obj.Pos(), "\t%s", obj.Name()) + } + return true + } + } + return false +} + // packageObjects typechecks all package objects, but not function bodies. func (check *Checker) packageObjects() { // process package objects in source order for reproducible results @@ -535,11 +570,26 @@ func (check *Checker) packageObjects() { } } - // pre-allocate space for type declaration paths so that the underlying array is reused - typePath := make([]*TypeName, 0, 8) - + // We process non-alias declarations first, in order to avoid situations where + // the type of an alias declaration is needed before it is available. In general + // this is still not enough, as it is possible to create sufficiently convoluted + // recursive type definitions that will cause a type alias to be needed before it + // is available (see issue #25838 for examples). + // As an aside, the cmd/compiler suffers from the same problem (#25838). + var aliasList []*TypeName + // phase 1 for _, obj := range objList { - check.objDecl(obj, nil, typePath) + // If we have a type alias, collect it for the 2nd phase. + if tname, _ := obj.(*TypeName); tname != nil && check.objMap[tname].alias { + aliasList = append(aliasList, tname) + continue + } + + check.objDecl(obj, nil) + } + // phase 2 + for _, obj := range aliasList { + check.objDecl(obj, nil) } // At this point we may have a non-empty check.methods map; this means that not all diff --git a/libgo/go/go/types/scope.go b/libgo/go/go/types/scope.go index 39e42d758ad..b50ee2fd5f3 100644 --- a/libgo/go/go/types/scope.go +++ b/libgo/go/go/types/scope.go @@ -15,9 +15,6 @@ import ( "strings" ) -// TODO(gri) Provide scopes with a name or other mechanism so that -// objects can use that information for better printing. - // A Scope maintains a set of objects and links to its containing // (parent) and contained (children) scopes. Objects may be inserted // and looked up by name. The zero value for Scope is a ready-to-use @@ -118,7 +115,7 @@ func (s *Scope) Insert(obj Object) Object { func (s *Scope) Pos() token.Pos { return s.pos } func (s *Scope) End() token.Pos { return s.end } -// Contains returns true if pos is within the scope's extent. +// Contains reports whether pos is within the scope's extent. // The result is guaranteed to be valid only if the type-checked // AST has complete position information. func (s *Scope) Contains(pos token.Pos) bool { @@ -161,13 +158,8 @@ func (s *Scope) WriteTo(w io.Writer, n int, recurse bool) { const ind = ". " indn := strings.Repeat(ind, n) - fmt.Fprintf(w, "%s%s scope %p {", indn, s.comment, s) - if len(s.elems) == 0 { - fmt.Fprintf(w, "}\n") - return - } + fmt.Fprintf(w, "%s%s scope %p {\n", indn, s.comment, s) - fmt.Fprintln(w) indn1 := indn + ind for _, name := range s.Names() { fmt.Fprintf(w, "%s%s\n", indn1, s.elems[name]) @@ -175,12 +167,11 @@ func (s *Scope) WriteTo(w io.Writer, n int, recurse bool) { if recurse { for _, s := range s.children { - fmt.Fprintln(w) s.WriteTo(w, n+1, recurse) } } - fmt.Fprintf(w, "%s}", indn) + fmt.Fprintf(w, "%s}\n", indn) } // String returns a string representation of the scope, for debugging. diff --git a/libgo/go/go/types/sizes.go b/libgo/go/go/types/sizes.go index 300f5211f15..6ab6157b82d 100644 --- a/libgo/go/go/types/sizes.go +++ b/libgo/go/go/types/sizes.go @@ -169,6 +169,7 @@ var gcArchSizes = map[string]*StdSizes{ "ppc64le": {8, 8}, "riscv64": {8, 8}, "s390x": {8, 8}, + "sparc64": {8, 8}, "wasm": {8, 8}, // When adding more architectures here, // update the doc string of SizesFor below. @@ -179,7 +180,7 @@ var gcArchSizes = map[string]*StdSizes{ // // Supported architectures for compiler "gc": // "386", "arm", "arm64", "amd64", "amd64p32", "mips", "mipsle", -// "mips64", "mips64le", "ppc64", "ppc64le", "riscv64", "s390x", "wasm". +// "mips64", "mips64le", "ppc64", "ppc64le", "riscv64", "s390x", "sparc64", "wasm". func SizesFor(compiler, arch string) Sizes { var m map[string]*StdSizes switch compiler { diff --git a/libgo/go/go/types/stdlib_test.go b/libgo/go/go/types/stdlib_test.go index b2f31efba6b..fde44950dd9 100644 --- a/libgo/go/go/types/stdlib_test.go +++ b/libgo/go/go/types/stdlib_test.go @@ -49,8 +49,11 @@ func TestStdlib(t *testing.T) { } } -// firstComment returns the contents of the first comment in -// the given file, assuming there's one within the first KB. +// firstComment returns the contents of the first non-empty comment in +// the given file, "skip", or the empty string. No matter the present +// comments, if any of them contains a build tag, the result is always +// "skip". Only comments before the "package" token and within the first +// 4K of the file are considered. func firstComment(filename string) string { f, err := os.Open(filename) if err != nil { @@ -58,11 +61,12 @@ func firstComment(filename string) string { } defer f.Close() - var src [1 << 10]byte // read at most 1KB + var src [4 << 10]byte // read at most 4KB n, _ := f.Read(src[:]) + var first string var s scanner.Scanner - s.Init(fset.AddFile("", fset.Base(), n), src[:n], nil, scanner.ScanComments) + s.Init(fset.AddFile("", fset.Base(), n), src[:n], nil /* ignore errors */, scanner.ScanComments) for { _, tok, lit := s.Scan() switch tok { @@ -71,9 +75,17 @@ func firstComment(filename string) string { if lit[1] == '*' { lit = lit[:len(lit)-2] } - return strings.TrimSpace(lit[2:]) - case token.EOF: - return "" + contents := strings.TrimSpace(lit[2:]) + if strings.HasPrefix(contents, "+build ") { + return "skip" + } + if first == "" { + first = contents // contents may be "" but that's ok + } + // continue as we may still see build tags + + case token.PACKAGE, token.EOF: + return first } } } @@ -147,15 +159,8 @@ func TestStdTest(t *testing.T) { t.Skip("skipping in short mode") } - // test/recover4.go is only built for Linux and Darwin. - // TODO(gri) Remove once tests consider +build tags (issue 10370). - if runtime.GOOS != "linux" && runtime.GOOS != "darwin" { - return - } - testTestDir(t, filepath.Join(runtime.GOROOT(), "test"), "cmplxdivide.go", // also needs file cmplxdivide1.go - ignore - "sigchld.go", // don't work on Windows; testTestDir should consult build tags ) } @@ -171,7 +176,6 @@ func TestStdFixed(t *testing.T) { "issue6889.go", // gc-specific test "issue7746.go", // large constants - consumes too much memory "issue11362.go", // canonical import path check - "issue15002.go", // uses Mmap; testTestDir should consult build tags "issue16369.go", // go/types handles this correctly - not an issue "issue18459.go", // go/types doesn't check validity of //go:xxx directives "issue18882.go", // go/types doesn't check validity of //go:xxx directives diff --git a/libgo/go/go/types/testdata/cycles.src b/libgo/go/go/types/testdata/cycles.src index 59f112dba1d..a9af46a9337 100644 --- a/libgo/go/go/types/testdata/cycles.src +++ b/libgo/go/go/types/testdata/cycles.src @@ -158,6 +158,8 @@ type T20 chan [unsafe.Sizeof(func(ch T20){ _ = <-ch })]byte type T22 = chan [unsafe.Sizeof(func(ch T20){ _ = <-ch })]byte func _() { - type T1 chan [unsafe.Sizeof(func(ch T1){ _ = <-ch })]byte - type T2 = chan [unsafe.Sizeof(func(ch T2){ _ = <-ch })]byte + type T0 func(T0) + type T1 /* ERROR cycle */ = func(T1) + type T2 chan [unsafe.Sizeof(func(ch T2){ _ = <-ch })]byte + type T3 /* ERROR cycle */ = chan [unsafe.Sizeof(func(ch T3){ _ = <-ch })]byte } diff --git a/libgo/go/go/types/testdata/cycles2.src b/libgo/go/go/types/testdata/cycles2.src index a7f4bc60f5b..fd0df4bf272 100644 --- a/libgo/go/go/types/testdata/cycles2.src +++ b/libgo/go/go/types/testdata/cycles2.src @@ -88,22 +88,10 @@ type T3 /* ERROR cycle */ interface { var x3 T3 type T4 /* ERROR cycle */ interface { - m() [unsafe.Sizeof(cast4(x4.m))]int + m() [unsafe.Sizeof(cast4(x4.m))]int // cast is invalid but we have a cycle, so all bets are off } var x4 T4 var _ = cast4(x4.m) type cast4 func() - -// This test is symmetric to the T4 case: Here the cast is -// "correct", but it doesn't work inside the T5 interface. - -type T5 /* ERROR cycle */ interface { - m() [unsafe.Sizeof(cast5(x5.m))]int -} - -var x5 T5 -var _ = cast5(x5.m) - -type cast5 func() [0]int diff --git a/libgo/go/go/types/testdata/decls0.src b/libgo/go/go/types/testdata/decls0.src index 162dfeda04e..56adbbfaae6 100644 --- a/libgo/go/go/types/testdata/decls0.src +++ b/libgo/go/go/types/testdata/decls0.src @@ -183,16 +183,16 @@ type ( ) // cycles in function/method declarations -// (test cases for issue 5217 and variants) -func f1 /* ERROR cycle */ (x f1 /* ERROR "not a type" */ ) {} -func f2 /* ERROR cycle */ (x *f2 /* ERROR "not a type" */ ) {} -func f3 /* ERROR cycle */ () (x f3 /* ERROR "not a type" */ ) { return } -func f4 /* ERROR cycle */ () (x *f4 /* ERROR "not a type" */ ) { return } - -func (S0) m1(x S0.m1 /* ERROR "field or method" */ ) {} -func (S0) m2(x *S0.m2 /* ERROR "field or method" */ ) {} -func (S0) m3() (x S0.m3 /* ERROR "field or method" */ ) { return } -func (S0) m4() (x *S0.m4 /* ERROR "field or method" */ ) { return } +// (test cases for issues #5217, #25790 and variants) +func f1(x f1 /* ERROR "not a type" */ ) {} +func f2(x *f2 /* ERROR "not a type" */ ) {} +func f3() (x f3 /* ERROR "not a type" */ ) { return } +func f4() (x *f4 /* ERROR "not a type" */ ) { return } + +func (S0) m1 /* ERROR illegal cycle */ (x S0 /* ERROR value .* is not a type */ .m1) {} +func (S0) m2 /* ERROR illegal cycle */ (x *S0 /* ERROR value .* is not a type */ .m2) {} +func (S0) m3 /* ERROR illegal cycle */ () (x S0 /* ERROR value .* is not a type */ .m3) { return } +func (S0) m4 /* ERROR illegal cycle */ () (x *S0 /* ERROR value .* is not a type */ .m4) { return } // interfaces may not have any blank methods type BlankI interface { diff --git a/libgo/go/go/types/testdata/expr2.src b/libgo/go/go/types/testdata/expr2.src index 31dc5f021c0..0c959e80119 100644 --- a/libgo/go/go/types/testdata/expr2.src +++ b/libgo/go/go/types/testdata/expr2.src @@ -208,6 +208,19 @@ func interfaces() { _ = i /* ERROR mismatched types */ == s2 _ = i /* ERROR mismatched types */ == &s2 + + // issue #28164 + // testcase from issue + _ = interface /* ERROR cannot compare */ {}(nil) == []int(nil) + + // related cases + var e interface{} + var s []int + var x int + _ = e /* ERROR cannot compare */ == s + _ = s /* ERROR cannot compare */ == e + _ = e /* ERROR cannot compare */ < x + _ = x /* ERROR cannot compare */ < e } func slices() { diff --git a/libgo/go/go/types/testdata/expr3.src b/libgo/go/go/types/testdata/expr3.src index b4c81633246..d562f0b16b6 100644 --- a/libgo/go/go/types/testdata/expr3.src +++ b/libgo/go/go/types/testdata/expr3.src @@ -497,7 +497,7 @@ func _calls() { f1(x ... /* ERROR "cannot use ..." */ ) f1(g0 /* ERROR "used as value" */ ()) f1(g1()) - // f1(g2()) // TODO(gri) missing position in error message + f1(g2 /* ERROR "cannot use g2" */ /* ERROR "too many arguments" */ ()) f2() /* ERROR "too few arguments" */ f2(3.14) /* ERROR "too few arguments" */ diff --git a/libgo/go/go/types/testdata/issues.src b/libgo/go/go/types/testdata/issues.src index d85e04e68cb..d0203011093 100644 --- a/libgo/go/go/types/testdata/issues.src +++ b/libgo/go/go/types/testdata/issues.src @@ -5,6 +5,7 @@ package issues import "fmt" +import syn "cmd/compile/internal/syntax" func issue7035() { type T struct{ X int } @@ -294,3 +295,46 @@ type registry struct { type allocator struct { _ [int(preloadLimit)]int } + +// Test that we don't crash when type-checking composite literals +// containing errors in the type. +var issue27346 = [][n /* ERROR undeclared */ ]int{ + 0: {}, +} + +var issue22467 = map[int][... /* ERROR invalid use of ... */ ]int{0: {}} + +// Test that invalid use of ... in parameter lists is recognized +// (issue #28281). +func issue28281a(int, int, ...int) +func issue28281b(a, b int, c ...int) +func issue28281c(a, b, c ... /* ERROR can only use ... with final parameter */ int) +func issue28281d(... /* ERROR can only use ... with final parameter */ int, int) +func issue28281e(a, b, c ... /* ERROR can only use ... with final parameter */ int, d int) +func issue28281f(... /* ERROR can only use ... with final parameter */ int, ... /* ERROR can only use ... with final parameter */ int, int) +func (... /* ERROR expected type */ TT) f() +func issue28281g() (... /* ERROR expected type */ TT) + +// Issue #26234: Make various field/method lookup errors easier to read by matching cmd/compile's output +func issue26234a(f *syn.File) { + // The error message below should refer to the actual package path base (syntax) + // not the local package name (syn). + f.foo /* ERROR f.foo undefined \(type \*syntax.File has no field or method foo\) */ +} + +type T struct { + x int + E1 + E2 +} + +type E1 struct{ f int } +type E2 struct{ f int } + +func issue26234b(x T) { + _ = x.f /* ERROR ambiguous selector f */ +} + +func issue26234c() { + T.x /* ERROR T.x undefined \(type T has no method x\) */ () +} diff --git a/libgo/go/go/types/testdata/shifts.src b/libgo/go/go/types/testdata/shifts.src index ca288290d69..52e340ec65c 100644 --- a/libgo/go/go/types/testdata/shifts.src +++ b/libgo/go/go/types/testdata/shifts.src @@ -354,3 +354,15 @@ func issue21727() { var _ = string(1 << s) var _ = string(1.0 /* ERROR "cannot convert" */ << s) } + +func issue22969() { + var s uint + var a []byte + _ = a[0xffffffffffffffff /* ERROR "overflows int" */ <= 0 { return n } @@ -438,14 +414,14 @@ func (check *Checker) collectParams(scope *Scope, list *ast.FieldList, variadicO ftype := field.Type if t, _ := ftype.(*ast.Ellipsis); t != nil { ftype = t.Elt - if variadicOk && i == len(list.List)-1 { + if variadicOk && i == len(list.List)-1 && len(field.Names) <= 1 { variadic = true } else { - check.invalidAST(field.Pos(), "... not permitted") + check.softErrorf(t.Pos(), "can only use ... with final parameter in list") // ignore ... and continue } } - typ := check.typ(ftype) + typ := check.indirectType(ftype) // The parser ensures that f.Tag is nil and we don't // care if a constructed AST contains a non-nil tag. if len(field.Names) > 0 { @@ -475,9 +451,12 @@ func (check *Checker) collectParams(scope *Scope, list *ast.FieldList, variadicO } // For a variadic function, change the last parameter's type from T to []T. - if variadic && len(params) > 0 { + // Since we type-checked T rather than ...T, we also need to retro-actively + // record the type for ...T. + if variadic { last := params[len(params)-1] last.typ = &Slice{elem: last.typ} + check.recordTypeAndValue(list.List[len(list.List)-1].Type, typexpr, last.typ, nil) } return @@ -492,7 +471,7 @@ func (check *Checker) declareInSet(oset *objset, pos token.Pos, obj Object) bool return true } -func (check *Checker) interfaceType(ityp *Interface, iface *ast.InterfaceType, def *Named, path []*TypeName) { +func (check *Checker) interfaceType(ityp *Interface, iface *ast.InterfaceType, def *Named) { // fast-track empty interface if iface.Methods.List == nil { ityp.allMethods = markComplete @@ -525,7 +504,7 @@ func (check *Checker) interfaceType(ityp *Interface, iface *ast.InterfaceType, d for _, f := range iface.Methods.List { if len(f.Names) == 0 { - typ := check.typ(f.Type) + typ := check.indirectType(f.Type) // typ should be a named type denoting an interface // (the parser will make sure it's a named type but // constructed ASTs may be wrong). @@ -555,12 +534,14 @@ func (check *Checker) interfaceType(ityp *Interface, iface *ast.InterfaceType, d // compute method set var tname *TypeName + var path []*TypeName if def != nil { tname = def.obj + path = []*TypeName{tname} } info := check.infoFromTypeLit(check.scope, iface, tname, path) if info == nil || info == &emptyIfaceInfo { - // error or empty interface - exit early + // we got an error or the empty interface - exit early ityp.allMethods = markComplete return } @@ -571,6 +552,15 @@ func (check *Checker) interfaceType(ityp *Interface, iface *ast.InterfaceType, d recvTyp = def } + // Correct receiver type for all methods explicitly declared + // by this interface after we're done with type-checking at + // this level. See comment below for details. + check.later(func() { + for _, m := range ityp.methods { + m.typ.(*Signature).recv.typ = recvTyp + } + }) + // collect methods var sigfix []*methodInfo for i, minfo := range info.methods { @@ -580,9 +570,27 @@ func (check *Checker) interfaceType(ityp *Interface, iface *ast.InterfaceType, d pos := name.Pos() // Don't type-check signature yet - use an // empty signature now and update it later. - // Since we know the receiver, set it up now - // (required to avoid crash in ptrRecv; see - // e.g. test case for issue 6638). + // But set up receiver since we know it and + // its position, and because interface method + // signatures don't get a receiver via regular + // type-checking (there isn't a receiver in the + // method's AST). Setting the receiver type is + // also important for ptrRecv() (see methodset.go). + // + // Note: For embedded methods, the receiver type + // should be the type of the interface that declared + // the methods in the first place. Since we get the + // methods here via methodInfo, which may be computed + // before we have all relevant interface types, we use + // the current interface's type (recvType). This may be + // the type of the interface embedding the interface that + // declared the methods. This doesn't matter for type- + // checking (we only care about the receiver type for + // the ptrRecv predicate, and it's never a pointer recv + // for interfaces), but it matters for go/types clients + // and for printing. We correct the receiver after type- + // checking. + // // TODO(gri) Consider marking methods signatures // as incomplete, for better error messages. See // also the T4 and T5 tests in testdata/cycles2.src. @@ -606,7 +614,7 @@ func (check *Checker) interfaceType(ityp *Interface, iface *ast.InterfaceType, d // (possibly embedded) methods must be type-checked within their scope and // type-checking them must not affect the current context (was issue #23914) check.context = context{scope: minfo.scope} - typ := check.typ(minfo.src.Type) + typ := check.indirectType(minfo.src.Type) sig, _ := typ.(*Signature) if sig == nil { if typ != Typ[Invalid] { @@ -665,7 +673,7 @@ func (check *Checker) tag(t *ast.BasicLit) string { return "" } -func (check *Checker) structType(styp *Struct, e *ast.StructType, path []*TypeName) { +func (check *Checker) structType(styp *Struct, e *ast.StructType) { list := e.Fields if list == nil { return @@ -709,7 +717,7 @@ func (check *Checker) structType(styp *Struct, e *ast.StructType, path []*TypeNa } for _, f := range list.List { - typ = check.typExpr(f.Type, nil, path) + typ = check.typ(f.Type) tag = check.tag(f.Tag) if len(f.Names) > 0 { // named fields diff --git a/libgo/go/golang.org/x/tools/LICENSE b/libgo/go/golang.org/x/tools/LICENSE new file mode 100644 index 00000000000..6a66aea5eaf --- /dev/null +++ b/libgo/go/golang.org/x/tools/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/libgo/go/golang.org/x/tools/PATENTS b/libgo/go/golang.org/x/tools/PATENTS new file mode 100644 index 00000000000..733099041f8 --- /dev/null +++ b/libgo/go/golang.org/x/tools/PATENTS @@ -0,0 +1,22 @@ +Additional IP Rights Grant (Patents) + +"This implementation" means the copyrightable works distributed by +Google as part of the Go project. + +Google hereby grants to You a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable (except as stated in this section) +patent license to make, have made, use, offer to sell, sell, import, +transfer and otherwise run, modify and propagate the contents of this +implementation of Go, where such license applies only to those patent +claims, both currently owned or controlled by Google and acquired in +the future, licensable by Google that are necessarily infringed by this +implementation of Go. This grant does not include claims that would be +infringed only as a consequence of further modification of this +implementation. If you or your agent or exclusive licensee institute or +order or agree to the institution of patent litigation against any +entity (including a cross-claim or counterclaim in a lawsuit) alleging +that this implementation of Go or any code incorporated within this +implementation of Go constitutes direct or contributory patent +infringement, or inducement of patent infringement, then any patent +rights granted to you under this License for this implementation of Go +shall terminate as of the date such litigation is filed. diff --git a/libgo/go/golang.org/x/tools/go/analysis/analysis.go b/libgo/go/golang.org/x/tools/go/analysis/analysis.go new file mode 100644 index 00000000000..21baa02a8de --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/analysis.go @@ -0,0 +1,192 @@ +package analysis + +import ( + "flag" + "fmt" + "go/ast" + "go/token" + "go/types" + "reflect" +) + +// An Analyzer describes an analysis function and its options. +type Analyzer struct { + // The Name of the analyzer must be a valid Go identifier + // as it may appear in command-line flags, URLs, and so on. + Name string + + // Doc is the documentation for the analyzer. + // The part before the first "\n\n" is the title + // (no capital or period, max ~60 letters). + Doc string + + // Flags defines any flags accepted by the analyzer. + // The manner in which these flags are exposed to the user + // depends on the driver which runs the analyzer. + Flags flag.FlagSet + + // Run applies the analyzer to a package. + // It returns an error if the analyzer failed. + // + // On success, the Run function may return a result + // computed by the Analyzer; its type must match ResultType. + // The driver makes this result available as an input to + // another Analyzer that depends directly on this one (see + // Requires) when it analyzes the same package. + // + // To pass analysis results between packages (and thus + // potentially between address spaces), use Facts, which are + // serializable. + Run func(*Pass) (interface{}, error) + + // RunDespiteErrors allows the driver to invoke + // the Run method of this analyzer even on a + // package that contains parse or type errors. + RunDespiteErrors bool + + // Requires is a set of analyzers that must run successfully + // before this one on a given package. This analyzer may inspect + // the outputs produced by each analyzer in Requires. + // The graph over analyzers implied by Requires edges must be acyclic. + // + // Requires establishes a "horizontal" dependency between + // analysis passes (different analyzers, same package). + Requires []*Analyzer + + // ResultType is the type of the optional result of the Run function. + ResultType reflect.Type + + // FactTypes indicates that this analyzer imports and exports + // Facts of the specified concrete types. + // An analyzer that uses facts may assume that its import + // dependencies have been similarly analyzed before it runs. + // Facts must be pointers. + // + // FactTypes establishes a "vertical" dependency between + // analysis passes (same analyzer, different packages). + FactTypes []Fact +} + +func (a *Analyzer) String() string { return a.Name } + +// A Pass provides information to the Run function that +// applies a specific analyzer to a single Go package. +// +// It forms the interface between the analysis logic and the driver +// program, and has both input and an output components. +// +// As in a compiler, one pass may depend on the result computed by another. +// +// The Run function should not call any of the Pass functions concurrently. +type Pass struct { + Analyzer *Analyzer // the identity of the current analyzer + + // syntax and type information + Fset *token.FileSet // file position information + Files []*ast.File // the abstract syntax tree of each file + OtherFiles []string // names of non-Go files of this package + Pkg *types.Package // type information about the package + TypesInfo *types.Info // type information about the syntax trees + + // Report reports a Diagnostic, a finding about a specific location + // in the analyzed source code such as a potential mistake. + // It may be called by the Run function. + Report func(Diagnostic) + + // ResultOf provides the inputs to this analysis pass, which are + // the corresponding results of its prerequisite analyzers. + // The map keys are the elements of Analysis.Required, + // and the type of each corresponding value is the required + // analysis's ResultType. + ResultOf map[*Analyzer]interface{} + + // -- facts -- + + // ImportObjectFact retrieves a fact associated with obj. + // Given a value ptr of type *T, where *T satisfies Fact, + // ImportObjectFact copies the value to *ptr. + // + // ImportObjectFact panics if called after the pass is complete. + // ImportObjectFact is not concurrency-safe. + ImportObjectFact func(obj types.Object, fact Fact) bool + + // ImportPackageFact retrieves a fact associated with package pkg, + // which must be this package or one of its dependencies. + // See comments for ImportObjectFact. + ImportPackageFact func(pkg *types.Package, fact Fact) bool + + // ExportObjectFact associates a fact of type *T with the obj, + // replacing any previous fact of that type. + // + // ExportObjectFact panics if it is called after the pass is + // complete, or if obj does not belong to the package being analyzed. + // ExportObjectFact is not concurrency-safe. + ExportObjectFact func(obj types.Object, fact Fact) + + // ExportPackageFact associates a fact with the current package. + // See comments for ExportObjectFact. + ExportPackageFact func(fact Fact) + + /* Further fields may be added in future. */ + // For example, suggested or applied refactorings. +} + +// Reportf is a helper function that reports a Diagnostic using the +// specified position and formatted error message. +func (pass *Pass) Reportf(pos token.Pos, format string, args ...interface{}) { + msg := fmt.Sprintf(format, args...) + pass.Report(Diagnostic{Pos: pos, Message: msg}) +} + +func (pass *Pass) String() string { + return fmt.Sprintf("%s@%s", pass.Analyzer.Name, pass.Pkg.Path()) +} + +// A Fact is an intermediate fact produced during analysis. +// +// Each fact is associated with a named declaration (a types.Object) or +// with a package as a whole. A single object or package may have +// multiple associated facts, but only one of any particular fact type. +// +// A Fact represents a predicate such as "never returns", but does not +// represent the subject of the predicate such as "function F" or "package P". +// +// Facts may be produced in one analysis pass and consumed by another +// analysis pass even if these are in different address spaces. +// If package P imports Q, all facts about Q produced during +// analysis of that package will be available during later analysis of P. +// Facts are analogous to type export data in a build system: +// just as export data enables separate compilation of several passes, +// facts enable "separate analysis". +// +// Each pass (a, p) starts with the set of facts produced by the +// same analyzer a applied to the packages directly imported by p. +// The analysis may add facts to the set, and they may be exported in turn. +// An analysis's Run function may retrieve facts by calling +// Pass.Import{Object,Package}Fact and update them using +// Pass.Export{Object,Package}Fact. +// +// A fact is logically private to its Analysis. To pass values +// between different analyzers, use the results mechanism; +// see Analyzer.Requires, Analyzer.ResultType, and Pass.ResultOf. +// +// A Fact type must be a pointer. +// Facts are encoded and decoded using encoding/gob. +// A Fact may implement the GobEncoder/GobDecoder interfaces +// to customize its encoding. Fact encoding should not fail. +// +// A Fact should not be modified once exported. +type Fact interface { + AFact() // dummy method to avoid type errors +} + +// A Diagnostic is a message associated with a source location. +// +// An Analyzer may return a variety of diagnostics; the optional Category, +// which should be a constant, may be used to classify them. +// It is primarily intended to make it easy to look up documentation. +type Diagnostic struct { + Pos token.Pos + Category string // optional + Message string +} diff --git a/libgo/go/golang.org/x/tools/go/analysis/doc.go b/libgo/go/golang.org/x/tools/go/analysis/doc.go new file mode 100644 index 00000000000..f925849ab50 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/doc.go @@ -0,0 +1,336 @@ +/* + +The analysis package defines the interface between a modular static +analysis and an analysis driver program. + +Background + +A static analysis is a function that inspects a package of Go code and +reports a set of diagnostics (typically mistakes in the code), and +perhaps produces other results as well, such as suggested refactorings +or other facts. An analysis that reports mistakes is informally called a +"checker". For example, the printf checker reports mistakes in +fmt.Printf format strings. + +A "modular" analysis is one that inspects one package at a time but can +save information from a lower-level package and use it when inspecting a +higher-level package, analogous to separate compilation in a toolchain. +The printf checker is modular: when it discovers that a function such as +log.Fatalf delegates to fmt.Printf, it records this fact, and checks +calls to that function too, including calls made from another package. + +By implementing a common interface, checkers from a variety of sources +can be easily selected, incorporated, and reused in a wide range of +driver programs including command-line tools (such as vet), text editors and +IDEs, build and test systems (such as go build, Bazel, or Buck), test +frameworks, code review tools, code-base indexers (such as SourceGraph), +documentation viewers (such as godoc), batch pipelines for large code +bases, and so on. + + +Analyzer + +The primary type in the API is Analyzer. An Analyzer statically +describes an analysis function: its name, documentation, flags, +relationship to other analyzers, and of course, its logic. + +To define an analysis, a user declares a (logically constant) variable +of type Analyzer. Here is a typical example from one of the analyzers in +the go/analysis/passes/ subdirectory: + + package unusedresult + + var Analyzer = &analysis.Analyzer{ + Name: "unusedresult", + Doc: "check for unused results of calls to some functions", + Run: run, + ... + } + + func run(pass *analysis.Pass) (interface{}, error) { + ... + } + + +An analysis driver is a program such as vet that runs a set of +analyses and prints the diagnostics that they report. +The driver program must import the list of Analyzers it needs. +Typically each Analyzer resides in a separate package. +To add a new Analyzer to an existing driver, add another item to the list: + + import ( "unusedresult"; "nilness"; "printf" ) + + var analyses = []*analysis.Analyzer{ + unusedresult.Analyzer, + nilness.Analyzer, + printf.Analyzer, + } + +A driver may use the name, flags, and documentation to provide on-line +help that describes the analyses its performs. +The doc comment contains a brief one-line summary, +optionally followed by paragraphs of explanation. +The vet command, shown below, is an example of a driver that runs +multiple analyzers. It is based on the multichecker package +(see the "Standalone commands" section for details). + + $ go build golang.org/x/tools/go/analysis/cmd/vet + $ ./vet help + vet is a tool for static analysis of Go programs. + + Usage: vet [-flag] [package] + + Registered analyzers: + + asmdecl report mismatches between assembly files and Go declarations + assign check for useless assignments + atomic check for common mistakes using the sync/atomic package + ... + unusedresult check for unused results of calls to some functions + + $ ./vet help unusedresult + unusedresult: check for unused results of calls to some functions + + Analyzer flags: + + -unusedresult.funcs value + comma-separated list of functions whose results must be used (default Error,String) + -unusedresult.stringmethods value + comma-separated list of names of methods of type func() string whose results must be used + + Some functions like fmt.Errorf return a result and have no side effects, + so it is always a mistake to discard the result. This analyzer reports + calls to certain functions in which the result of the call is ignored. + + The set of functions may be controlled using flags. + +The Analyzer type has more fields besides those shown above: + + type Analyzer struct { + Name string + Doc string + Flags flag.FlagSet + Run func(*Pass) (interface{}, error) + RunDespiteErrors bool + ResultType reflect.Type + Requires []*Analyzer + FactTypes []Fact + } + +The Flags field declares a set of named (global) flag variables that +control analysis behavior. Unlike vet, analysis flags are not declared +directly in the command line FlagSet; it is up to the driver to set the +flag variables. A driver for a single analysis, a, might expose its flag +f directly on the command line as -f, whereas a driver for multiple +analyses might prefix the flag name by the analysis name (-a.f) to avoid +ambiguity. An IDE might expose the flags through a graphical interface, +and a batch pipeline might configure them from a config file. +See the "findcall" analyzer for an example of flags in action. + +The RunDespiteErrors flag indicates whether the analysis is equipped to +handle ill-typed code. If not, the driver will skip the analysis if +there were parse or type errors. +The optional ResultType field specifies the type of the result value +computed by this analysis and made available to other analyses. +The Requires field specifies a list of analyses upon which +this one depends and whose results it may access, and it constrains the +order in which a driver may run analyses. +The FactTypes field is discussed in the section on Modularity. +The analysis package provides a Validate function to perform basic +sanity checks on an Analyzer, such as that its Requires graph is +acyclic, its fact and result types are unique, and so on. + +Finally, the Run field contains a function to be called by the driver to +execute the analysis on a single package. The driver passes it an +instance of the Pass type. + + +Pass + +A Pass describes a single unit of work: the application of a particular +Analyzer to a particular package of Go code. +The Pass provides information to the Analyzer's Run function about the +package being analyzed, and provides operations to the Run function for +reporting diagnostics and other information back to the driver. + + type Pass struct { + Fset *token.FileSet + Files []*ast.File + OtherFiles []string + Pkg *types.Package + TypesInfo *types.Info + ResultOf map[*Analyzer]interface{} + Report func(Diagnostic) + ... + } + +The Fset, Files, Pkg, and TypesInfo fields provide the syntax trees, +type information, and source positions for a single package of Go code. + +The OtherFiles field provides the names, but not the contents, of non-Go +files such as assembly that are part of this package. See the "asmdecl" +or "buildtags" analyzers for examples of loading non-Go files and report +diagnostics against them. + +The ResultOf field provides the results computed by the analyzers +required by this one, as expressed in its Analyzer.Requires field. The +driver runs the required analyzers first and makes their results +available in this map. Each Analyzer must return a value of the type +described in its Analyzer.ResultType field. +For example, the "ctrlflow" analyzer returns a *ctrlflow.CFGs, which +provides a control-flow graph for each function in the package (see +golang.org/x/tools/go/cfg); the "inspect" analyzer returns a value that +enables other Analyzers to traverse the syntax trees of the package more +efficiently; and the "buildssa" analyzer constructs an SSA-form +intermediate representation. +Each of these Analyzers extends the capabilities of later Analyzers +without adding a dependency to the core API, so an analysis tool pays +only for the extensions it needs. + +The Report function emits a diagnostic, a message associated with a +source position. For most analyses, diagnostics are their primary +result. +For convenience, Pass provides a helper method, Reportf, to report a new +diagnostic by formatting a string. +Diagnostic is defined as: + + type Diagnostic struct { + Pos token.Pos + Category string // optional + Message string + } + +The optional Category field is a short identifier that classifies the +kind of message when an analysis produces several kinds of diagnostic. + +Most Analyzers inspect typed Go syntax trees, but a few, such as asmdecl +and buildtag, inspect the raw text of Go source files or even non-Go +files such as assembly. To report a diagnostic against a line of a +raw text file, use the following sequence: + + content, err := ioutil.ReadFile(filename) + if err != nil { ... } + tf := fset.AddFile(filename, -1, len(content)) + tf.SetLinesForContent(content) + ... + pass.Reportf(tf.LineStart(line), "oops") + + +Modular analysis with Facts + +To improve efficiency and scalability, large programs are routinely +built using separate compilation: units of the program are compiled +separately, and recompiled only when one of their dependencies changes; +independent modules may be compiled in parallel. The same technique may +be applied to static analyses, for the same benefits. Such analyses are +described as "modular". + +A compiler’s type checker is an example of a modular static analysis. +Many other checkers we would like to apply to Go programs can be +understood as alternative or non-standard type systems. For example, +vet's printf checker infers whether a function has the "printf wrapper" +type, and it applies stricter checks to calls of such functions. In +addition, it records which functions are printf wrappers for use by +later analysis units to identify other printf wrappers by induction. +A result such as “f is a printf wrapper” that is not interesting by +itself but serves as a stepping stone to an interesting result (such as +a diagnostic) is called a "fact". + +The analysis API allows an analysis to define new types of facts, to +associate facts of these types with objects (named entities) declared +within the current package, or with the package as a whole, and to query +for an existing fact of a given type associated with an object or +package. + +An Analyzer that uses facts must declare their types: + + var Analyzer = &analysis.Analyzer{ + Name: "printf", + FactTypes: []reflect.Type{reflect.TypeOf(new(isWrapper))}, + ... + } + + type isWrapper struct{} // => *types.Func f “is a printf wrapper” + +A driver program ensures that facts for a pass’s dependencies are +generated before analyzing the pass and are responsible for propagating +facts between from one pass to another, possibly across address spaces. +Consequently, Facts must be serializable. The API requires that drivers +use the gob encoding, an efficient, robust, self-describing binary +protocol. A fact type may implement the GobEncoder/GobDecoder interfaces +if the default encoding is unsuitable. Facts should be stateless. + +The Pass type has functions to import and export facts, +associated either with an object or with a package: + + type Pass struct { + ... + ExportObjectFact func(types.Object, Fact) + ImportObjectFact func(types.Object, Fact) bool + + ExportPackageFact func(fact Fact) + ImportPackageFact func(*types.Package, Fact) bool + } + +An Analyzer may only export facts associated with the current package or +its objects, though it may import facts from any package or object that +is an import dependency of the current package. + +Conceptually, ExportObjectFact(obj, fact) inserts fact into a hidden map keyed by +the pair (obj, TypeOf(fact)), and the ImportObjectFact function +retrieves the entry from this map and copies its value into the variable +pointed to by fact. This scheme assumes that the concrete type of fact +is a pointer; this assumption is checked by the Validate function. +See the "printf" analyzer for an example of object facts in action. + +Some driver implementations (such as those based on Bazel and Blaze) do +not currently apply analyzers to packages of the standard library. +Therefore, for best results, analyzer authors should not rely on +analysis facts being available for standard packages. +For example, although the printf checker is capable of deducing during +analysis of the log package that log.Printf is a printf-wrapper, +this fact is built in to the analyzer so that it correctly checks +calls to log.Printf even when run in a driver that does not apply +it to standard packages. We plan to remove this limitation in future. + + +Testing an Analyzer + +The analysistest subpackage provides utilities for testing an Analyzer. +In a few lines of code, it is possible to run an analyzer on a package +of testdata files and check that it reported all the expected +diagnostics and facts (and no more). Expectations are expressed using +"// want ..." comments in the input code. + + +Standalone commands + +Analyzers are provided in the form of packages that a driver program is +expected to import. The vet command imports a set of several analyzers, +but users may wish to define their own analysis commands that perform +additional checks. To simplify the task of creating an analysis command, +either for a single analyzer or for a whole suite, we provide the +singlechecker and multichecker subpackages. + +The singlechecker package provides the main function for a command that +runs one analyzer. By convention, each analyzer such as +go/passes/findcall should be accompanied by a singlechecker-based +command such as go/analysis/passes/findcall/cmd/findcall, defined in its +entirety as: + + package main + + import ( + "golang.org/x/tools/go/analysis/passes/findcall" + "golang.org/x/tools/go/analysis/singlechecker" + ) + + func main() { singlechecker.Main(findcall.Analyzer) } + +A tool that provides multiple analyzers can use multichecker in a +similar way, giving it the list of Analyzers. + + + +*/ +package analysis diff --git a/libgo/go/golang.org/x/tools/go/analysis/internal/analysisflags/flags.go b/libgo/go/golang.org/x/tools/go/analysis/internal/analysisflags/flags.go new file mode 100644 index 00000000000..729ac3b4176 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/internal/analysisflags/flags.go @@ -0,0 +1,343 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package analysisflags defines helpers for processing flags of +// analysis driver tools. +package analysisflags + +import ( + "crypto/sha256" + "encoding/json" + "flag" + "fmt" + "go/token" + "io" + "io/ioutil" + "log" + "os" + "strconv" + "strings" + + "golang.org/x/tools/go/analysis" +) + +// flags common to all {single,multi,unit}checkers. +var ( + JSON = false // -json + Context = -1 // -c=N: if N>0, display offending line plus N lines of context +) + +// Parse creates a flag for each of the analyzer's flags, +// including (in multi mode) a flag named after the analyzer, +// parses the flags, then filters and returns the list of +// analyzers enabled by flags. +func Parse(analyzers []*analysis.Analyzer, multi bool) []*analysis.Analyzer { + // Connect each analysis flag to the command line as -analysis.flag. + enabled := make(map[*analysis.Analyzer]*triState) + for _, a := range analyzers { + var prefix string + + // Add -NAME flag to enable it. + if multi { + prefix = a.Name + "." + + enable := new(triState) + enableUsage := "enable " + a.Name + " analysis" + flag.Var(enable, a.Name, enableUsage) + enabled[a] = enable + } + + a.Flags.VisitAll(func(f *flag.Flag) { + if !multi && flag.Lookup(f.Name) != nil { + log.Printf("%s flag -%s would conflict with driver; skipping", a.Name, f.Name) + return + } + + name := prefix + f.Name + flag.Var(f.Value, name, f.Usage) + }) + } + + // standard flags: -flags, -V. + printflags := flag.Bool("flags", false, "print analyzer flags in JSON") + addVersionFlag() + + // flags common to all checkers + flag.BoolVar(&JSON, "json", JSON, "emit JSON output") + flag.IntVar(&Context, "c", Context, `display offending line with this many lines of context`) + + // Add shims for legacy vet flags to enable existing + // scripts that run vet to continue to work. + _ = flag.Bool("source", false, "no effect (deprecated)") + _ = flag.Bool("v", false, "no effect (deprecated)") + _ = flag.Bool("all", false, "no effect (deprecated)") + _ = flag.String("tags", "", "no effect (deprecated)") + for old, new := range vetLegacyFlags { + newFlag := flag.Lookup(new) + if newFlag != nil && flag.Lookup(old) == nil { + flag.Var(newFlag.Value, old, "deprecated alias for -"+new) + } + } + + flag.Parse() // (ExitOnError) + + // -flags: print flags so that go vet knows which ones are legitimate. + if *printflags { + printFlags() + os.Exit(0) + } + + // If any -NAME flag is true, run only those analyzers. Otherwise, + // if any -NAME flag is false, run all but those analyzers. + if multi { + var hasTrue, hasFalse bool + for _, ts := range enabled { + switch *ts { + case setTrue: + hasTrue = true + case setFalse: + hasFalse = true + } + } + + var keep []*analysis.Analyzer + if hasTrue { + for _, a := range analyzers { + if *enabled[a] == setTrue { + keep = append(keep, a) + } + } + analyzers = keep + } else if hasFalse { + for _, a := range analyzers { + if *enabled[a] != setFalse { + keep = append(keep, a) + } + } + analyzers = keep + } + } + + return analyzers +} + +func printFlags() { + type jsonFlag struct { + Name string + Bool bool + Usage string + } + var flags []jsonFlag = nil + flag.VisitAll(func(f *flag.Flag) { + // Don't report {single,multi}checker debugging + // flags as these have no effect on unitchecker + // (as invoked by 'go vet'). + switch f.Name { + case "debug", "cpuprofile", "memprofile", "trace": + return + } + + b, ok := f.Value.(interface{ IsBoolFlag() bool }) + isBool := ok && b.IsBoolFlag() + flags = append(flags, jsonFlag{f.Name, isBool, f.Usage}) + }) + data, err := json.MarshalIndent(flags, "", "\t") + if err != nil { + log.Fatal(err) + } + os.Stdout.Write(data) +} + +// addVersionFlag registers a -V flag that, if set, +// prints the executable version and exits 0. +// +// It is a variable not a function to permit easy +// overriding in the copy vendored in $GOROOT/src/cmd/vet: +// +// func init() { addVersionFlag = objabi.AddVersionFlag } +var addVersionFlag = func() { + flag.Var(versionFlag{}, "V", "print version and exit") +} + +// versionFlag minimally complies with the -V protocol required by "go vet". +type versionFlag struct{} + +func (versionFlag) IsBoolFlag() bool { return true } +func (versionFlag) Get() interface{} { return nil } +func (versionFlag) String() string { return "" } +func (versionFlag) Set(s string) error { + if s != "full" { + log.Fatalf("unsupported flag value: -V=%s", s) + } + + // This replicates the miminal subset of + // cmd/internal/objabi.AddVersionFlag, which is private to the + // go tool yet forms part of our command-line interface. + // TODO(adonovan): clarify the contract. + + // Print the tool version so the build system can track changes. + // Formats: + // $progname version devel ... buildID=... + // $progname version go1.9.1 + progname := os.Args[0] + f, err := os.Open(progname) + if err != nil { + log.Fatal(err) + } + h := sha256.New() + if _, err := io.Copy(h, f); err != nil { + log.Fatal(err) + } + f.Close() + fmt.Printf("%s version devel comments-go-here buildID=%02x\n", + progname, string(h.Sum(nil))) + os.Exit(0) + return nil +} + +// A triState is a boolean that knows whether +// it has been set to either true or false. +// It is used to identify whether a flag appears; +// the standard boolean flag cannot +// distinguish missing from unset. +// It also satisfies flag.Value. +type triState int + +const ( + unset triState = iota + setTrue + setFalse +) + +func triStateFlag(name string, value triState, usage string) *triState { + flag.Var(&value, name, usage) + return &value +} + +// triState implements flag.Value, flag.Getter, and flag.boolFlag. +// They work like boolean flags: we can say vet -printf as well as vet -printf=true +func (ts *triState) Get() interface{} { + return *ts == setTrue +} + +func (ts triState) isTrue() bool { + return ts == setTrue +} + +func (ts *triState) Set(value string) error { + b, err := strconv.ParseBool(value) + if err != nil { + // This error message looks poor but package "flag" adds + // "invalid boolean value %q for -NAME: %s" + return fmt.Errorf("want true or false") + } + if b { + *ts = setTrue + } else { + *ts = setFalse + } + return nil +} + +func (ts *triState) String() string { + switch *ts { + case unset: + return "true" + case setTrue: + return "true" + case setFalse: + return "false" + } + panic("not reached") +} + +func (ts triState) IsBoolFlag() bool { + return true +} + +// Legacy flag support + +// vetLegacyFlags maps flags used by legacy vet to their corresponding +// new names. The old names will continue to work. +var vetLegacyFlags = map[string]string{ + // Analyzer name changes + "bool": "bools", + "buildtags": "buildtag", + "methods": "stdmethods", + "rangeloops": "loopclosure", + + // Analyzer flags + "compositewhitelist": "composites.whitelist", + "printfuncs": "printf.funcs", + "shadowstrict": "shadow.strict", + "unusedfuncs": "unusedresult.funcs", + "unusedstringmethods": "unusedresult.stringmethods", +} + +// ---- output helpers common to all drivers ---- + +// PrintPlain prints a diagnostic in plain text form, +// with context specified by the -c flag. +func PrintPlain(fset *token.FileSet, diag analysis.Diagnostic) { + posn := fset.Position(diag.Pos) + fmt.Fprintf(os.Stderr, "%s: %s\n", posn, diag.Message) + + // -c=N: show offending line plus N lines of context. + if Context >= 0 { + data, _ := ioutil.ReadFile(posn.Filename) + lines := strings.Split(string(data), "\n") + for i := posn.Line - Context; i <= posn.Line+Context; i++ { + if 1 <= i && i <= len(lines) { + fmt.Fprintf(os.Stderr, "%d\t%s\n", i, lines[i-1]) + } + } + } +} + +// A JSONTree is a mapping from package ID to analysis name to result. +// Each result is either a jsonError or a list of jsonDiagnostic. +type JSONTree map[string]map[string]interface{} + +// Add adds the result of analysis 'name' on package 'id'. +// The result is either a list of diagnostics or an error. +func (tree JSONTree) Add(fset *token.FileSet, id, name string, diags []analysis.Diagnostic, err error) { + var v interface{} + if err != nil { + type jsonError struct { + Err string `json:"error"` + } + v = jsonError{err.Error()} + } else if len(diags) > 0 { + type jsonDiagnostic struct { + Category string `json:"category,omitempty"` + Posn string `json:"posn"` + Message string `json:"message"` + } + var diagnostics []jsonDiagnostic + for _, f := range diags { + diagnostics = append(diagnostics, jsonDiagnostic{ + Category: f.Category, + Posn: fset.Position(f.Pos).String(), + Message: f.Message, + }) + } + v = diagnostics + } + if v != nil { + m, ok := tree[id] + if !ok { + m = make(map[string]interface{}) + tree[id] = m + } + m[name] = v + } +} + +func (tree JSONTree) Print() { + data, err := json.MarshalIndent(tree, "", "\t") + if err != nil { + log.Panicf("internal error: JSON marshalling failed: %v", err) + } + fmt.Printf("%s\n", data) +} diff --git a/libgo/go/golang.org/x/tools/go/analysis/internal/analysisflags/help.go b/libgo/go/golang.org/x/tools/go/analysis/internal/analysisflags/help.go new file mode 100644 index 00000000000..043b97896dd --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/internal/analysisflags/help.go @@ -0,0 +1,89 @@ +package analysisflags + +import ( + "flag" + "fmt" + "log" + "sort" + "strings" + + "golang.org/x/tools/go/analysis" +) + +const help = `PROGNAME is a tool for static analysis of Go programs. + +PROGNAME examines Go source code and reports suspicious constructs, +such as Printf calls whose arguments do not align with the format +string. It uses heuristics that do not guarantee all reports are +genuine problems, but it can find errors not caught by the compilers. +` + +// Help implements the help subcommand for a multichecker or unitchecker +// style command. The optional args specify the analyzers to describe. +// Help calls log.Fatal if no such analyzer exists. +func Help(progname string, analyzers []*analysis.Analyzer, args []string) { + // No args: show summary of all analyzers. + if len(args) == 0 { + fmt.Println(strings.Replace(help, "PROGNAME", progname, -1)) + fmt.Println("Registered analyzers:") + fmt.Println() + sort.Slice(analyzers, func(i, j int) bool { + return analyzers[i].Name < analyzers[j].Name + }) + for _, a := range analyzers { + title := strings.Split(a.Doc, "\n\n")[0] + fmt.Printf(" %-12s %s\n", a.Name, title) + } + fmt.Println("\nBy default all analyzers are run.") + fmt.Println("To select specific analyzers, use the -NAME flag for each one,") + fmt.Println(" or -NAME=false to run all analyzers not explicitly disabled.") + + // Show only the core command-line flags. + fmt.Println("\nCore flags:") + fmt.Println() + fs := flag.NewFlagSet("", flag.ExitOnError) + flag.VisitAll(func(f *flag.Flag) { + if !strings.Contains(f.Name, ".") { + fs.Var(f.Value, f.Name, f.Usage) + } + }) + fs.PrintDefaults() + + fmt.Printf("\nTo see details and flags of a specific analyzer, run '%s help name'.\n", progname) + + return + } + + // Show help on specific analyzer(s). +outer: + for _, arg := range args { + for _, a := range analyzers { + if a.Name == arg { + paras := strings.Split(a.Doc, "\n\n") + title := paras[0] + fmt.Printf("%s: %s\n", a.Name, title) + + // Show only the flags relating to this analysis, + // properly prefixed. + first := true + fs := flag.NewFlagSet(a.Name, flag.ExitOnError) + a.Flags.VisitAll(func(f *flag.Flag) { + if first { + first = false + fmt.Println("\nAnalyzer flags:") + fmt.Println() + } + fs.Var(f.Value, a.Name+"."+f.Name, f.Usage) + }) + fs.PrintDefaults() + + if len(paras) > 1 { + fmt.Printf("\n%s\n", strings.Join(paras[1:], "\n\n")) + } + + continue outer + } + } + log.Fatalf("Analyzer %q not registered", arg) + } +} diff --git a/libgo/go/golang.org/x/tools/go/analysis/internal/analysisflags/patch.go b/libgo/go/golang.org/x/tools/go/analysis/internal/analysisflags/patch.go new file mode 100644 index 00000000000..8f9741055cb --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/internal/analysisflags/patch.go @@ -0,0 +1,7 @@ +package analysisflags + +import "cmd/internal/objabi" + +// This additional file changes the behavior of the vendored code. + +func init() { addVersionFlag = objabi.AddVersionFlag } diff --git a/libgo/go/golang.org/x/tools/go/analysis/internal/facts/facts.go b/libgo/go/golang.org/x/tools/go/analysis/internal/facts/facts.go new file mode 100644 index 00000000000..468f148900f --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/internal/facts/facts.go @@ -0,0 +1,299 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package facts defines a serializable set of analysis.Fact. +// +// It provides a partial implementation of the Fact-related parts of the +// analysis.Pass interface for use in analysis drivers such as "go vet" +// and other build systems. +// +// The serial format is unspecified and may change, so the same version +// of this package must be used for reading and writing serialized facts. +// +// The handling of facts in the analysis system parallels the handling +// of type information in the compiler: during compilation of package P, +// the compiler emits an export data file that describes the type of +// every object (named thing) defined in package P, plus every object +// indirectly reachable from one of those objects. Thus the downstream +// compiler of package Q need only load one export data file per direct +// import of Q, and it will learn everything about the API of package P +// and everything it needs to know about the API of P's dependencies. +// +// Similarly, analysis of package P emits a fact set containing facts +// about all objects exported from P, plus additional facts about only +// those objects of P's dependencies that are reachable from the API of +// package P; the downstream analysis of Q need only load one fact set +// per direct import of Q. +// +// The notion of "exportedness" that matters here is that of the +// compiler. According to the language spec, a method pkg.T.f is +// unexported simply because its name starts with lowercase. But the +// compiler must nonethless export f so that downstream compilations can +// accurately ascertain whether pkg.T implements an interface pkg.I +// defined as interface{f()}. Exported thus means "described in export +// data". +// +package facts + +import ( + "bytes" + "encoding/gob" + "fmt" + "go/types" + "io/ioutil" + "log" + "reflect" + "sort" + "sync" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/types/objectpath" +) + +const debug = false + +// A Set is a set of analysis.Facts. +// +// Decode creates a Set of facts by reading from the imports of a given +// package, and Encode writes out the set. Between these operation, +// the Import and Export methods will query and update the set. +// +// All of Set's methods except String are safe to call concurrently. +type Set struct { + pkg *types.Package + mu sync.Mutex + m map[key]analysis.Fact +} + +type key struct { + pkg *types.Package + obj types.Object // (object facts only) + t reflect.Type +} + +// ImportObjectFact implements analysis.Pass.ImportObjectFact. +func (s *Set) ImportObjectFact(obj types.Object, ptr analysis.Fact) bool { + if obj == nil { + panic("nil object") + } + key := key{pkg: obj.Pkg(), obj: obj, t: reflect.TypeOf(ptr)} + s.mu.Lock() + defer s.mu.Unlock() + if v, ok := s.m[key]; ok { + reflect.ValueOf(ptr).Elem().Set(reflect.ValueOf(v).Elem()) + return true + } + return false +} + +// ExportObjectFact implements analysis.Pass.ExportObjectFact. +func (s *Set) ExportObjectFact(obj types.Object, fact analysis.Fact) { + if obj.Pkg() != s.pkg { + log.Panicf("in package %s: ExportObjectFact(%s, %T): can't set fact on object belonging another package", + s.pkg, obj, fact) + } + key := key{pkg: obj.Pkg(), obj: obj, t: reflect.TypeOf(fact)} + s.mu.Lock() + s.m[key] = fact // clobber any existing entry + s.mu.Unlock() +} + +// ImportPackageFact implements analysis.Pass.ImportPackageFact. +func (s *Set) ImportPackageFact(pkg *types.Package, ptr analysis.Fact) bool { + if pkg == nil { + panic("nil package") + } + key := key{pkg: pkg, t: reflect.TypeOf(ptr)} + s.mu.Lock() + defer s.mu.Unlock() + if v, ok := s.m[key]; ok { + reflect.ValueOf(ptr).Elem().Set(reflect.ValueOf(v).Elem()) + return true + } + return false +} + +// ExportPackageFact implements analysis.Pass.ExportPackageFact. +func (s *Set) ExportPackageFact(fact analysis.Fact) { + key := key{pkg: s.pkg, t: reflect.TypeOf(fact)} + s.mu.Lock() + s.m[key] = fact // clobber any existing entry + s.mu.Unlock() +} + +// gobFact is the Gob declaration of a serialized fact. +type gobFact struct { + PkgPath string // path of package + Object objectpath.Path // optional path of object relative to package itself + Fact analysis.Fact // type and value of user-defined Fact +} + +// Decode decodes all the facts relevant to the analysis of package pkg. +// The read function reads serialized fact data from an external source +// for one of of pkg's direct imports. The empty file is a valid +// encoding of an empty fact set. +// +// It is the caller's responsibility to call gob.Register on all +// necessary fact types. +func Decode(pkg *types.Package, read func(packagePath string) ([]byte, error)) (*Set, error) { + // Compute the import map for this package. + // See the package doc comment. + packages := importMap(pkg.Imports()) + + // Read facts from imported packages. + // Facts may describe indirectly imported packages, or their objects. + m := make(map[key]analysis.Fact) // one big bucket + for _, imp := range pkg.Imports() { + logf := func(format string, args ...interface{}) { + if debug { + prefix := fmt.Sprintf("in %s, importing %s: ", + pkg.Path(), imp.Path()) + log.Print(prefix, fmt.Sprintf(format, args...)) + } + } + + // Read the gob-encoded facts. + data, err := read(imp.Path()) + if err != nil { + return nil, fmt.Errorf("in %s, can't import facts for package %q: %v", + pkg.Path(), imp.Path(), err) + } + if len(data) == 0 { + continue // no facts + } + var gobFacts []gobFact + if err := gob.NewDecoder(bytes.NewReader(data)).Decode(&gobFacts); err != nil { + return nil, fmt.Errorf("decoding facts for %q: %v", imp.Path(), err) + } + if debug { + logf("decoded %d facts: %v", len(gobFacts), gobFacts) + } + + // Parse each one into a key and a Fact. + for _, f := range gobFacts { + factPkg := packages[f.PkgPath] + if factPkg == nil { + // Fact relates to a dependency that was + // unused in this translation unit. Skip. + logf("no package %q; discarding %v", f.PkgPath, f.Fact) + continue + } + key := key{pkg: factPkg, t: reflect.TypeOf(f.Fact)} + if f.Object != "" { + // object fact + obj, err := objectpath.Object(factPkg, f.Object) + if err != nil { + // (most likely due to unexported object) + // TODO(adonovan): audit for other possibilities. + logf("no object for path: %v; discarding %s", err, f.Fact) + continue + } + key.obj = obj + logf("read %T fact %s for %v", f.Fact, f.Fact, key.obj) + } else { + // package fact + logf("read %T fact %s for %v", f.Fact, f.Fact, factPkg) + } + m[key] = f.Fact + } + } + + return &Set{pkg: pkg, m: m}, nil +} + +// Encode encodes a set of facts to a memory buffer. +// +// It may fail if one of the Facts could not be gob-encoded, but this is +// a sign of a bug in an Analyzer. +func (s *Set) Encode() []byte { + + // TODO(adonovan): opt: use a more efficient encoding + // that avoids repeating PkgPath for each fact. + + // Gather all facts, including those from imported packages. + var gobFacts []gobFact + + s.mu.Lock() + for k, fact := range s.m { + if debug { + log.Printf("%v => %s\n", k, fact) + } + var object objectpath.Path + if k.obj != nil { + path, err := objectpath.For(k.obj) + if err != nil { + if debug { + log.Printf("discarding fact %s about %s\n", fact, k.obj) + } + continue // object not accessible from package API; discard fact + } + object = path + } + gobFacts = append(gobFacts, gobFact{ + PkgPath: k.pkg.Path(), + Object: object, + Fact: fact, + }) + } + s.mu.Unlock() + + // Sort facts by (package, object, type) for determinism. + sort.Slice(gobFacts, func(i, j int) bool { + x, y := gobFacts[i], gobFacts[j] + if x.PkgPath != y.PkgPath { + return x.PkgPath < y.PkgPath + } + if x.Object != y.Object { + return x.Object < y.Object + } + tx := reflect.TypeOf(x.Fact) + ty := reflect.TypeOf(y.Fact) + if tx != ty { + return tx.String() < ty.String() + } + return false // equal + }) + + var buf bytes.Buffer + if len(gobFacts) > 0 { + if err := gob.NewEncoder(&buf).Encode(gobFacts); err != nil { + // Fact encoding should never fail. Identify the culprit. + for _, gf := range gobFacts { + if err := gob.NewEncoder(ioutil.Discard).Encode(gf); err != nil { + fact := gf.Fact + pkgpath := reflect.TypeOf(fact).Elem().PkgPath() + log.Panicf("internal error: gob encoding of analysis fact %s failed: %v; please report a bug against fact %T in package %q", + fact, err, fact, pkgpath) + } + } + } + } + + if debug { + log.Printf("package %q: encode %d facts, %d bytes\n", + s.pkg.Path(), len(gobFacts), buf.Len()) + } + + return buf.Bytes() +} + +// String is provided only for debugging, and must not be called +// concurrent with any Import/Export method. +func (s *Set) String() string { + var buf bytes.Buffer + buf.WriteString("{") + for k, f := range s.m { + if buf.Len() > 1 { + buf.WriteString(", ") + } + if k.obj != nil { + buf.WriteString(k.obj.String()) + } else { + buf.WriteString(k.pkg.Path()) + } + fmt.Fprintf(&buf, ": %v", f) + } + buf.WriteString("}") + return buf.String() +} diff --git a/libgo/go/golang.org/x/tools/go/analysis/internal/facts/imports.go b/libgo/go/golang.org/x/tools/go/analysis/internal/facts/imports.go new file mode 100644 index 00000000000..34740f48e04 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/internal/facts/imports.go @@ -0,0 +1,88 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package facts + +import "go/types" + +// importMap computes the import map for a package by traversing the +// entire exported API each of its imports. +// +// This is a workaround for the fact that we cannot access the map used +// internally by the types.Importer returned by go/importer. The entries +// in this map are the packages and objects that may be relevant to the +// current analysis unit. +// +// Packages in the map that are only indirectly imported may be +// incomplete (!pkg.Complete()). +// +func importMap(imports []*types.Package) map[string]*types.Package { + objects := make(map[types.Object]bool) + packages := make(map[string]*types.Package) + + var addObj func(obj types.Object) bool + var addType func(T types.Type) + + addObj = func(obj types.Object) bool { + if !objects[obj] { + objects[obj] = true + addType(obj.Type()) + if pkg := obj.Pkg(); pkg != nil { + packages[pkg.Path()] = pkg + } + return true + } + return false + } + + addType = func(T types.Type) { + switch T := T.(type) { + case *types.Basic: + // nop + case *types.Named: + if addObj(T.Obj()) { + for i := 0; i < T.NumMethods(); i++ { + addObj(T.Method(i)) + } + } + case *types.Pointer: + addType(T.Elem()) + case *types.Slice: + addType(T.Elem()) + case *types.Array: + addType(T.Elem()) + case *types.Chan: + addType(T.Elem()) + case *types.Map: + addType(T.Key()) + addType(T.Elem()) + case *types.Signature: + addType(T.Params()) + addType(T.Results()) + case *types.Struct: + for i := 0; i < T.NumFields(); i++ { + addObj(T.Field(i)) + } + case *types.Tuple: + for i := 0; i < T.Len(); i++ { + addObj(T.At(i)) + } + case *types.Interface: + for i := 0; i < T.NumMethods(); i++ { + addObj(T.Method(i)) + } + } + } + + for _, imp := range imports { + packages[imp.Path()] = imp + + scope := imp.Scope() + for _, name := range scope.Names() { + addObj(scope.Lookup(name)) + } + } + + return packages +} diff --git a/libgo/go/cmd/vet/asmdecl.go b/libgo/go/golang.org/x/tools/go/analysis/passes/asmdecl/asmdecl.go similarity index 87% rename from libgo/go/cmd/vet/asmdecl.go rename to libgo/go/golang.org/x/tools/go/analysis/passes/asmdecl/asmdecl.go index ccf6269f1db..dce1ef7bd5e 100644 --- a/libgo/go/cmd/vet/asmdecl.go +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/asmdecl/asmdecl.go @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Identify mismatches between assembly files and Go func declarations. - -package main +// Package asmdecl defines an Analyzer that reports mismatches between +// assembly files and Go declarations. +package asmdecl import ( "bytes" @@ -13,11 +13,21 @@ import ( "go/build" "go/token" "go/types" + "log" "regexp" "strconv" "strings" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/internal/analysisutil" ) +var Analyzer = &analysis.Analyzer{ + Name: "asmdecl", + Doc: "report mismatches between assembly files and Go declarations", + Run: run, +} + // 'kind' is a kind of assembly variable. // The kinds 1, 2, 4, 8 stand for values of that size. type asmKind int @@ -100,14 +110,18 @@ func init() { for _, arch := range arches { arch.sizes = types.SizesFor("gc", arch.name) if arch.sizes == nil { - panic("missing SizesFor for gc/" + arch.name) + // TODO(adonovan): fix: now that asmdecl is not in the standard + // library we cannot assume types.SizesFor is consistent with arches. + // For now, assume 64-bit norms and print a warning. + // But this warning should really be deferred until we attempt to use + // arch, which is very unlikely. + arch.sizes = types.SizesFor("gc", "amd64") + log.Printf("unknown architecture %s", arch.name) } arch.intSize = int(arch.sizes.Sizeof(types.Typ[types.Int])) arch.ptrSize = int(arch.sizes.Sizeof(types.Typ[types.UnsafePointer])) arch.maxAlign = int(arch.sizes.Alignof(types.Typ[types.Int64])) } - - registerPkgCheck("asmdecl", asmCheck) } var ( @@ -122,48 +136,48 @@ var ( ppc64Suff = re(`([BHWD])(ZU|Z|U|BR)?$`) ) -func asmCheck(pkg *Package) { - if vcfg.VetxOnly { - return - } - +func run(pass *analysis.Pass) (interface{}, error) { // No work if no assembly files. - if !pkg.hasFileWithSuffix(".s") { - return + var sfiles []string + for _, fname := range pass.OtherFiles { + if strings.HasSuffix(fname, ".s") { + sfiles = append(sfiles, fname) + } + } + if sfiles == nil { + return nil, nil } // Gather declarations. knownFunc[name][arch] is func description. knownFunc := make(map[string]map[string]*asmFunc) - for _, f := range pkg.files { - if f.file != nil { - for _, decl := range f.file.Decls { - if decl, ok := decl.(*ast.FuncDecl); ok && decl.Body == nil { - knownFunc[decl.Name.Name] = f.asmParseDecl(decl) - } + for _, f := range pass.Files { + for _, decl := range f.Decls { + if decl, ok := decl.(*ast.FuncDecl); ok && decl.Body == nil { + knownFunc[decl.Name.Name] = asmParseDecl(pass, decl) } } } Files: - for _, f := range pkg.files { - if !strings.HasSuffix(f.name, ".s") { - continue + for _, fname := range sfiles { + content, tf, err := analysisutil.ReadFile(pass.Fset, fname) + if err != nil { + return nil, err } - Println("Checking file", f.name) // Determine architecture from file name if possible. var arch string var archDef *asmArch for _, a := range arches { - if strings.HasSuffix(f.name, "_"+a.name+".s") { + if strings.HasSuffix(fname, "_"+a.name+".s") { arch = a.name archDef = a break } } - lines := strings.SplitAfter(string(f.content), "\n") + lines := strings.SplitAfter(string(content), "\n") var ( fn *asmFunc fnName string @@ -177,7 +191,7 @@ Files: if fn != nil && fn.vars["ret"] != nil && !haveRetArg && len(retLine) > 0 { v := fn.vars["ret"] for _, line := range retLine { - f.Badf(token.NoPos, "%s:%d: [%s] %s: RET without writing to %d-byte ret+%d(FP)", f.name, line, arch, fnName, v.size, v.off) + pass.Reportf(analysisutil.LineStart(tf, line), "[%s] %s: RET without writing to %d-byte ret+%d(FP)", arch, fnName, v.size, v.off) } } retLine = nil @@ -186,7 +200,7 @@ Files: lineno++ badf := func(format string, args ...interface{}) { - f.Badf(token.NoPos, "%s:%d: [%s] %s: %s", f.name, lineno, arch, fnName, fmt.Sprintf(format, args...)) + pass.Reportf(analysisutil.LineStart(tf, lineno), "[%s] %s: %s", arch, fnName, fmt.Sprintf(format, args...)) } if arch == "" { @@ -229,16 +243,17 @@ Files: } } if arch == "" { - f.Warnf(token.NoPos, "%s: cannot determine architecture for assembly file", f.name) + log.Printf("%s: cannot determine architecture for assembly file", fname) continue Files } } fnName = m[2] - if pkgName := strings.TrimSpace(m[1]); pkgName != "" { - pathParts := strings.Split(pkgName, "∕") - pkgName = pathParts[len(pathParts)-1] - if pkgName != f.pkg.path { - f.Warnf(token.NoPos, "%s:%d: [%s] cannot check cross-package assembly function: %s is in package %s", f.name, lineno, arch, fnName, pkgName) + if pkgPath := strings.TrimSpace(m[1]); pkgPath != "" { + // The assembler uses Unicode division slash within + // identifiers to represent the directory separator. + pkgPath = strings.Replace(pkgPath, "∕", "/", -1) + if pkgPath != pass.Pkg.Path() { + log.Printf("%s:%d: [%s] cannot check cross-package assembly function: %s is in package %s", fname, lineno, arch, fnName, pkgPath) fn = nil fnName = "" continue @@ -360,6 +375,7 @@ Files: } flushRet() } + return nil, nil } func asmKindForType(t types.Type, size int) asmKind { @@ -474,7 +490,7 @@ func appendComponentsRecursive(arch *asmArch, t types.Type, cc []component, suff offsets := arch.sizes.Offsetsof(fields) elemoff := int(offsets[1]) for i := 0; i < int(tu.Len()); i++ { - cc = appendComponentsRecursive(arch, elem, cc, suffix+"_"+strconv.Itoa(i), i*elemoff) + cc = appendComponentsRecursive(arch, elem, cc, suffix+"_"+strconv.Itoa(i), off+i*elemoff) } } @@ -482,7 +498,7 @@ func appendComponentsRecursive(arch *asmArch, t types.Type, cc []component, suff } // asmParseDecl parses a function decl for expected assembly variables. -func (f *File) asmParseDecl(decl *ast.FuncDecl) map[string]*asmFunc { +func asmParseDecl(pass *analysis.Pass, decl *ast.FuncDecl) map[string]*asmFunc { var ( arch *asmArch fn *asmFunc @@ -491,10 +507,20 @@ func (f *File) asmParseDecl(decl *ast.FuncDecl) map[string]*asmFunc { // addParams adds asmVars for each of the parameters in list. // isret indicates whether the list are the arguments or the return values. + // TODO(adonovan): simplify by passing (*types.Signature).{Params,Results} + // instead of list. addParams := func(list []*ast.Field, isret bool) { argnum := 0 for _, fld := range list { - t := f.pkg.types[fld.Type].Type + t := pass.TypesInfo.Types[fld.Type].Type + + // Work around https://golang.org/issue/28277. + if t == nil { + if ell, ok := fld.Type.(*ast.Ellipsis); ok { + t = types.NewSlice(pass.TypesInfo.Types[ell.Elt].Type) + } + } + align := int(arch.sizes.Alignof(t)) size := int(arch.sizes.Sizeof(t)) offset += -offset & (align - 1) diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/assign/assign.go b/libgo/go/golang.org/x/tools/go/analysis/passes/assign/assign.go new file mode 100644 index 00000000000..4dff2908c32 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/assign/assign.go @@ -0,0 +1,68 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package assign defines an Analyzer that detects useless assignments. +package assign + +// TODO(adonovan): check also for assignments to struct fields inside +// methods that are on T instead of *T. + +import ( + "go/ast" + "go/token" + "reflect" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/inspect" + "golang.org/x/tools/go/analysis/passes/internal/analysisutil" + "golang.org/x/tools/go/ast/inspector" +) + +const Doc = `check for useless assignments + +This checker reports assignments of the form x = x or a[i] = a[i]. +These are almost always useless, and even when they aren't they are +usually a mistake.` + +var Analyzer = &analysis.Analyzer{ + Name: "assign", + Doc: Doc, + Requires: []*analysis.Analyzer{inspect.Analyzer}, + Run: run, +} + +func run(pass *analysis.Pass) (interface{}, error) { + inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) + + nodeFilter := []ast.Node{ + (*ast.AssignStmt)(nil), + } + inspect.Preorder(nodeFilter, func(n ast.Node) { + stmt := n.(*ast.AssignStmt) + if stmt.Tok != token.ASSIGN { + return // ignore := + } + if len(stmt.Lhs) != len(stmt.Rhs) { + // If LHS and RHS have different cardinality, they can't be the same. + return + } + for i, lhs := range stmt.Lhs { + rhs := stmt.Rhs[i] + if analysisutil.HasSideEffects(pass.TypesInfo, lhs) || + analysisutil.HasSideEffects(pass.TypesInfo, rhs) { + continue // expressions may not be equal + } + if reflect.TypeOf(lhs) != reflect.TypeOf(rhs) { + continue // short-circuit the heavy-weight gofmt check + } + le := analysisutil.Format(pass.Fset, lhs) + re := analysisutil.Format(pass.Fset, rhs) + if le == re { + pass.Reportf(stmt.Pos(), "self-assignment of %s to %s", re, le) + } + } + }) + + return nil, nil +} diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/atomic/atomic.go b/libgo/go/golang.org/x/tools/go/analysis/passes/atomic/atomic.go new file mode 100644 index 00000000000..45243d6f8c0 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/atomic/atomic.go @@ -0,0 +1,96 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package atomic defines an Analyzer that checks for common mistakes +// using the sync/atomic package. +package atomic + +import ( + "go/ast" + "go/token" + "go/types" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/inspect" + "golang.org/x/tools/go/analysis/passes/internal/analysisutil" + "golang.org/x/tools/go/ast/inspector" +) + +const Doc = `check for common mistakes using the sync/atomic package + +The atomic checker looks for assignment statements of the form: + + x = atomic.AddUint64(&x, 1) + +which are not atomic.` + +var Analyzer = &analysis.Analyzer{ + Name: "atomic", + Doc: Doc, + Requires: []*analysis.Analyzer{inspect.Analyzer}, + RunDespiteErrors: true, + Run: run, +} + +func run(pass *analysis.Pass) (interface{}, error) { + inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) + + nodeFilter := []ast.Node{ + (*ast.AssignStmt)(nil), + } + inspect.Preorder(nodeFilter, func(node ast.Node) { + n := node.(*ast.AssignStmt) + if len(n.Lhs) != len(n.Rhs) { + return + } + if len(n.Lhs) == 1 && n.Tok == token.DEFINE { + return + } + + for i, right := range n.Rhs { + call, ok := right.(*ast.CallExpr) + if !ok { + continue + } + sel, ok := call.Fun.(*ast.SelectorExpr) + if !ok { + continue + } + pkgIdent, _ := sel.X.(*ast.Ident) + pkgName, ok := pass.TypesInfo.Uses[pkgIdent].(*types.PkgName) + if !ok || pkgName.Imported().Path() != "sync/atomic" { + continue + } + + switch sel.Sel.Name { + case "AddInt32", "AddInt64", "AddUint32", "AddUint64", "AddUintptr": + checkAtomicAddAssignment(pass, n.Lhs[i], call) + } + } + }) + return nil, nil +} + +// checkAtomicAddAssignment walks the atomic.Add* method calls checking +// for assigning the return value to the same variable being used in the +// operation +func checkAtomicAddAssignment(pass *analysis.Pass, left ast.Expr, call *ast.CallExpr) { + if len(call.Args) != 2 { + return + } + arg := call.Args[0] + broken := false + + gofmt := func(e ast.Expr) string { return analysisutil.Format(pass.Fset, e) } + + if uarg, ok := arg.(*ast.UnaryExpr); ok && uarg.Op == token.AND { + broken = gofmt(left) == gofmt(uarg.X) + } else if star, ok := left.(*ast.StarExpr); ok { + broken = gofmt(star.X) == gofmt(arg) + } + + if broken { + pass.Reportf(left.Pos(), "direct assignment to atomic value") + } +} diff --git a/libgo/go/cmd/vet/bool.go b/libgo/go/golang.org/x/tools/go/analysis/passes/bools/bools.go similarity index 65% rename from libgo/go/cmd/vet/bool.go rename to libgo/go/golang.org/x/tools/go/analysis/passes/bools/bools.go index 1cd477f988c..833c9d7aae1 100644 --- a/libgo/go/cmd/vet/bool.go +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/bools/bools.go @@ -2,40 +2,57 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// This file contains boolean condition tests. - -package main +// Package bools defines an Analyzer that detects common mistakes +// involving boolean operators. +package bools import ( "go/ast" "go/token" + "go/types" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/inspect" + "golang.org/x/tools/go/analysis/passes/internal/analysisutil" + "golang.org/x/tools/go/ast/inspector" ) -func init() { - register("bool", - "check for mistakes involving boolean operators", - checkBool, - binaryExpr) +var Analyzer = &analysis.Analyzer{ + Name: "bools", + Doc: "check for common mistakes involving boolean operators", + Requires: []*analysis.Analyzer{inspect.Analyzer}, + Run: run, } -func checkBool(f *File, n ast.Node) { - e := n.(*ast.BinaryExpr) - - var op boolOp - switch e.Op { - case token.LOR: - op = or - case token.LAND: - op = and - default: - return - } +func run(pass *analysis.Pass) (interface{}, error) { + inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) - comm := op.commutativeSets(f, e) - for _, exprs := range comm { - op.checkRedundant(f, exprs) - op.checkSuspect(f, exprs) + nodeFilter := []ast.Node{ + (*ast.BinaryExpr)(nil), } + inspect.Preorder(nodeFilter, func(n ast.Node) { + e := n.(*ast.BinaryExpr) + + var op boolOp + switch e.Op { + case token.LOR: + op = or + case token.LAND: + op = and + default: + return + } + + // TODO(adonovan): this reports n(n-1)/2 errors for an + // expression e||...||e of depth n. Fix. + // See https://golang.org/issue/28086. + comm := op.commutativeSets(pass.TypesInfo, e) + for _, exprs := range comm { + op.checkRedundant(pass, exprs) + op.checkSuspect(pass, exprs) + } + }) + return nil, nil } type boolOp struct { @@ -53,14 +70,14 @@ var ( // expressions in e that are connected by op. // For example, given 'a || b || f() || c || d' with the or op, // commutativeSets returns {{b, a}, {d, c}}. -func (op boolOp) commutativeSets(f *File, e *ast.BinaryExpr) [][]ast.Expr { +func (op boolOp) commutativeSets(info *types.Info, e *ast.BinaryExpr) [][]ast.Expr { exprs := op.split(e) // Partition the slice of expressions into commutative sets. i := 0 var sets [][]ast.Expr for j := 0; j <= len(exprs); j++ { - if j == len(exprs) || hasSideEffects(f, exprs[j]) { + if j == len(exprs) || hasSideEffects(info, exprs[j]) { if i < j { sets = append(sets, exprs[i:j]) } @@ -75,12 +92,12 @@ func (op boolOp) commutativeSets(f *File, e *ast.BinaryExpr) [][]ast.Expr { // e && e // e || e // Exprs must contain only side effect free expressions. -func (op boolOp) checkRedundant(f *File, exprs []ast.Expr) { +func (op boolOp) checkRedundant(pass *analysis.Pass, exprs []ast.Expr) { seen := make(map[string]bool) for _, e := range exprs { - efmt := f.gofmt(e) + efmt := analysisutil.Format(pass.Fset, e) if seen[efmt] { - f.Badf(e.Pos(), "redundant %s: %s %s %s", op.name, efmt, op.tok, efmt) + pass.Reportf(e.Pos(), "redundant %s: %s %s %s", op.name, efmt, op.tok, efmt) } else { seen[efmt] = true } @@ -94,7 +111,7 @@ func (op boolOp) checkRedundant(f *File, exprs []ast.Expr) { // If c1 and c2 are the same then it's redundant; // if c1 and c2 are different then it's always true or always false. // Exprs must contain only side effect free expressions. -func (op boolOp) checkSuspect(f *File, exprs []ast.Expr) { +func (op boolOp) checkSuspect(pass *analysis.Pass, exprs []ast.Expr) { // seen maps from expressions 'x' to equality expressions 'x != c'. seen := make(map[string]string) @@ -113,21 +130,21 @@ func (op boolOp) checkSuspect(f *File, exprs []ast.Expr) { // code is written. var x ast.Expr switch { - case f.pkg.types[bin.Y].Value != nil: + case pass.TypesInfo.Types[bin.Y].Value != nil: x = bin.X - case f.pkg.types[bin.X].Value != nil: + case pass.TypesInfo.Types[bin.X].Value != nil: x = bin.Y default: continue } // e is of the form 'x != c' or 'x == c'. - xfmt := f.gofmt(x) - efmt := f.gofmt(e) + xfmt := analysisutil.Format(pass.Fset, x) + efmt := analysisutil.Format(pass.Fset, e) if prev, found := seen[xfmt]; found { // checkRedundant handles the case in which efmt == prev. if efmt != prev { - f.Badf(e.Pos(), "suspect %s: %s %s %s", op.name, efmt, op.tok, prev) + pass.Reportf(e.Pos(), "suspect %s: %s %s %s", op.name, efmt, op.tok, prev) } } else { seen[xfmt] = efmt @@ -136,12 +153,12 @@ func (op boolOp) checkSuspect(f *File, exprs []ast.Expr) { } // hasSideEffects reports whether evaluation of e has side effects. -func hasSideEffects(f *File, e ast.Expr) bool { +func hasSideEffects(info *types.Info, e ast.Expr) bool { safe := true ast.Inspect(e, func(node ast.Node) bool { switch n := node.(type) { case *ast.CallExpr: - typVal := f.pkg.types[n.Fun] + typVal := info.Types[n.Fun] switch { case typVal.IsType(): // Type conversion, which is safe. diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/buildtag/buildtag.go b/libgo/go/golang.org/x/tools/go/analysis/passes/buildtag/buildtag.go new file mode 100644 index 00000000000..5a441e609b6 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/buildtag/buildtag.go @@ -0,0 +1,159 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package buildtag defines an Analyzer that checks build tags. +package buildtag + +import ( + "bytes" + "fmt" + "go/ast" + "strings" + "unicode" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/internal/analysisutil" +) + +var Analyzer = &analysis.Analyzer{ + Name: "buildtag", + Doc: "check that +build tags are well-formed and correctly located", + Run: runBuildTag, +} + +func runBuildTag(pass *analysis.Pass) (interface{}, error) { + for _, f := range pass.Files { + checkGoFile(pass, f) + } + for _, name := range pass.OtherFiles { + if err := checkOtherFile(pass, name); err != nil { + return nil, err + } + } + return nil, nil +} + +func checkGoFile(pass *analysis.Pass, f *ast.File) { + pastCutoff := false + for _, group := range f.Comments { + // A +build comment is ignored after or adjoining the package declaration. + if group.End()+1 >= f.Package { + pastCutoff = true + } + + // "+build" is ignored within or after a /*...*/ comment. + if !strings.HasPrefix(group.List[0].Text, "//") { + pastCutoff = true + continue + } + + // Check each line of a //-comment. + for _, c := range group.List { + if !strings.Contains(c.Text, "+build") { + continue + } + if err := checkLine(c.Text, pastCutoff); err != nil { + pass.Reportf(c.Pos(), "%s", err) + } + } + } +} + +func checkOtherFile(pass *analysis.Pass, filename string) error { + content, tf, err := analysisutil.ReadFile(pass.Fset, filename) + if err != nil { + return err + } + + // We must look at the raw lines, as build tags may appear in non-Go + // files such as assembly files. + lines := bytes.SplitAfter(content, nl) + + // Determine cutpoint where +build comments are no longer valid. + // They are valid in leading // comments in the file followed by + // a blank line. + // + // This must be done as a separate pass because of the + // requirement that the comment be followed by a blank line. + var cutoff int + for i, line := range lines { + line = bytes.TrimSpace(line) + if !bytes.HasPrefix(line, slashSlash) { + if len(line) > 0 { + break + } + cutoff = i + } + } + + for i, line := range lines { + line = bytes.TrimSpace(line) + if !bytes.HasPrefix(line, slashSlash) { + continue + } + if !bytes.Contains(line, []byte("+build")) { + continue + } + if err := checkLine(string(line), i >= cutoff); err != nil { + pass.Reportf(analysisutil.LineStart(tf, i+1), "%s", err) + continue + } + } + return nil +} + +// checkLine checks a line that starts with "//" and contains "+build". +func checkLine(line string, pastCutoff bool) error { + line = strings.TrimPrefix(line, "//") + line = strings.TrimSpace(line) + + if strings.HasPrefix(line, "+build") { + fields := strings.Fields(line) + if fields[0] != "+build" { + // Comment is something like +buildasdf not +build. + return fmt.Errorf("possible malformed +build comment") + } + if pastCutoff { + return fmt.Errorf("+build comment must appear before package clause and be followed by a blank line") + } + if err := checkArguments(fields); err != nil { + return err + } + } else { + // Comment with +build but not at beginning. + if !pastCutoff { + return fmt.Errorf("possible malformed +build comment") + } + } + return nil +} + +func checkArguments(fields []string) error { + // The original version of this checker in vet could examine + // files with malformed build tags that would cause the file to + // be always ignored by "go build". However, drivers for the new + // analysis API will analyze only the files selected to form a + // package, so these checks will never fire. + // TODO(adonovan): rethink this. + + for _, arg := range fields[1:] { + for _, elem := range strings.Split(arg, ",") { + if strings.HasPrefix(elem, "!!") { + return fmt.Errorf("invalid double negative in build constraint: %s", arg) + } + elem = strings.TrimPrefix(elem, "!") + for _, c := range elem { + if !unicode.IsLetter(c) && !unicode.IsDigit(c) && c != '_' && c != '.' { + return fmt.Errorf("invalid non-alphanumeric build constraint: %s", arg) + } + } + } + } + return nil +} + +var ( + nl = []byte("\n") + slashSlash = []byte("//") +) diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/cgocall/cgocall.go b/libgo/go/golang.org/x/tools/go/analysis/passes/cgocall/cgocall.go new file mode 100644 index 00000000000..f2e8949f607 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/cgocall/cgocall.go @@ -0,0 +1,391 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package cgocall defines an Analyzer that detects some violations of +// the cgo pointer passing rules. +package cgocall + +import ( + "fmt" + "go/ast" + "go/build" + "go/format" + "go/parser" + "go/token" + "go/types" + "log" + "os" + "runtime" + "strconv" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/internal/analysisutil" +) + +const debug = false + +const doc = `detect some violations of the cgo pointer passing rules + +Check for invalid cgo pointer passing. +This looks for code that uses cgo to call C code passing values +whose types are almost always invalid according to the cgo pointer +sharing rules. +Specifically, it warns about attempts to pass a Go chan, map, func, +or slice to C, either directly, or via a pointer, array, or struct.` + +var Analyzer = &analysis.Analyzer{ + Name: "cgocall", + Doc: doc, + RunDespiteErrors: true, + Run: run, +} + +func run(pass *analysis.Pass) (interface{}, error) { + if runtime.Compiler != "gccgo" && imports(pass.Pkg, "runtime/cgo") == nil { + return nil, nil // doesn't use cgo + } + + cgofiles, info, err := typeCheckCgoSourceFiles(pass.Fset, pass.Pkg, pass.Files, pass.TypesInfo) + if err != nil { + return nil, err + } + for _, f := range cgofiles { + checkCgo(pass.Fset, f, info, pass.Reportf) + } + return nil, nil +} + +func checkCgo(fset *token.FileSet, f *ast.File, info *types.Info, reportf func(token.Pos, string, ...interface{})) { + ast.Inspect(f, func(n ast.Node) bool { + call, ok := n.(*ast.CallExpr) + if !ok { + return true + } + + // Is this a C.f() call? + var name string + if sel, ok := analysisutil.Unparen(call.Fun).(*ast.SelectorExpr); ok { + if id, ok := sel.X.(*ast.Ident); ok && id.Name == "C" { + name = sel.Sel.Name + } + } + if name == "" { + return true // not a call we need to check + } + + // A call to C.CBytes passes a pointer but is always safe. + if name == "CBytes" { + return true + } + + if debug { + log.Printf("%s: call to C.%s", fset.Position(call.Lparen), name) + } + + for _, arg := range call.Args { + if !typeOKForCgoCall(cgoBaseType(info, arg), make(map[types.Type]bool)) { + reportf(arg.Pos(), "possibly passing Go type with embedded pointer to C") + break + } + + // Check for passing the address of a bad type. + if conv, ok := arg.(*ast.CallExpr); ok && len(conv.Args) == 1 && + isUnsafePointer(info, conv.Fun) { + arg = conv.Args[0] + } + if u, ok := arg.(*ast.UnaryExpr); ok && u.Op == token.AND { + if !typeOKForCgoCall(cgoBaseType(info, u.X), make(map[types.Type]bool)) { + reportf(arg.Pos(), "possibly passing Go type with embedded pointer to C") + break + } + } + } + return true + }) +} + +// typeCheckCgoSourceFiles returns type-checked syntax trees for the raw +// cgo files of a package (those that import "C"). Such files are not +// Go, so there may be gaps in type information around C.f references. +// +// This checker was initially written in vet to inpect raw cgo source +// files using partial type information. However, Analyzers in the new +// analysis API are presented with the type-checked, "cooked" Go ASTs +// resulting from cgo-processing files, so we must choose between +// working with the cooked file generated by cgo (which was tried but +// proved fragile) or locating the raw cgo file (e.g. from //line +// directives) and working with that, as we now do. +// +// Specifically, we must type-check the raw cgo source files (or at +// least the subtrees needed for this analyzer) in an environment that +// simulates the rest of the already type-checked package. +// +// For example, for each raw cgo source file in the original package, +// such as this one: +// +// package p +// import "C" +// import "fmt" +// type T int +// const k = 3 +// var x, y = fmt.Println() +// func f() { ... } +// func g() { ... C.malloc(k) ... } +// func (T) f(int) string { ... } +// +// we synthesize a new ast.File, shown below, that dot-imports the +// orginal "cooked" package using a special name ("·this·"), so that all +// references to package members resolve correctly. (References to +// unexported names cause an "unexported" error, which we ignore.) +// +// To avoid shadowing names imported from the cooked package, +// package-level declarations in the new source file are modified so +// that they do not declare any names. +// (The cgocall analysis is concerned with uses, not declarations.) +// Specifically, type declarations are discarded; +// all names in each var and const declaration are blanked out; +// each method is turned into a regular function by turning +// the receiver into the first parameter; +// and all functions are renamed to "_". +// +// package p +// import . "·this·" // declares T, k, x, y, f, g, T.f +// import "C" +// import "fmt" +// const _ = 3 +// var _, _ = fmt.Println() +// func _() { ... } +// func _() { ... C.malloc(k) ... } +// func _(T, int) string { ... } +// +// In this way, the raw function bodies and const/var initializer +// expressions are preserved but refer to the "cooked" objects imported +// from "·this·", and none of the transformed package-level declarations +// actually declares anything. In the example above, the reference to k +// in the argument of the call to C.malloc resolves to "·this·".k, which +// has an accurate type. +// +// This approach could in principle be generalized to more complex +// analyses on raw cgo files. One could synthesize a "C" package so that +// C.f would resolve to "·this·"._C_func_f, for example. But we have +// limited ourselves here to preserving function bodies and initializer +// expressions since that is all that the cgocall analyzer needs. +// +func typeCheckCgoSourceFiles(fset *token.FileSet, pkg *types.Package, files []*ast.File, info *types.Info) ([]*ast.File, *types.Info, error) { + const thispkg = "·this·" + + // Which files are cgo files? + var cgoFiles []*ast.File + importMap := map[string]*types.Package{thispkg: pkg} + for _, raw := range files { + // If f is a cgo-generated file, Position reports + // the original file, honoring //line directives. + filename := fset.Position(raw.Pos()).Filename + f, err := parser.ParseFile(fset, filename, nil, parser.Mode(0)) + if err != nil { + return nil, nil, fmt.Errorf("can't parse raw cgo file: %v", err) + } + found := false + for _, spec := range f.Imports { + if spec.Path.Value == `"C"` { + found = true + break + } + } + if !found { + continue // not a cgo file + } + + // Record the original import map. + for _, spec := range raw.Imports { + path, _ := strconv.Unquote(spec.Path.Value) + importMap[path] = imported(info, spec) + } + + // Add special dot-import declaration: + // import . "·this·" + var decls []ast.Decl + decls = append(decls, &ast.GenDecl{ + Tok: token.IMPORT, + Specs: []ast.Spec{ + &ast.ImportSpec{ + Name: &ast.Ident{Name: "."}, + Path: &ast.BasicLit{ + Kind: token.STRING, + Value: strconv.Quote(thispkg), + }, + }, + }, + }) + + // Transform declarations from the raw cgo file. + for _, decl := range f.Decls { + switch decl := decl.(type) { + case *ast.GenDecl: + switch decl.Tok { + case token.TYPE: + // Discard type declarations. + continue + case token.IMPORT: + // Keep imports. + case token.VAR, token.CONST: + // Blank the declared var/const names. + for _, spec := range decl.Specs { + spec := spec.(*ast.ValueSpec) + for i := range spec.Names { + spec.Names[i].Name = "_" + } + } + } + case *ast.FuncDecl: + // Blank the declared func name. + decl.Name.Name = "_" + + // Turn a method receiver: func (T) f(P) R {...} + // into regular parameter: func _(T, P) R {...} + if decl.Recv != nil { + var params []*ast.Field + params = append(params, decl.Recv.List...) + params = append(params, decl.Type.Params.List...) + decl.Type.Params.List = params + decl.Recv = nil + } + } + decls = append(decls, decl) + } + f.Decls = decls + if debug { + format.Node(os.Stderr, fset, f) // debugging + } + cgoFiles = append(cgoFiles, f) + } + if cgoFiles == nil { + return nil, nil, nil // nothing to do (can't happen?) + } + + // Type-check the synthetic files. + tc := &types.Config{ + FakeImportC: true, + Importer: importerFunc(func(path string) (*types.Package, error) { + return importMap[path], nil + }), + // TODO(adonovan): Sizes should probably be provided by analysis.Pass. + Sizes: types.SizesFor("gc", build.Default.GOARCH), + Error: func(error) {}, // ignore errors (e.g. unused import) + } + + // It's tempting to record the new types in the + // existing pass.TypesInfo, but we don't own it. + altInfo := &types.Info{ + Types: make(map[ast.Expr]types.TypeAndValue), + } + tc.Check(pkg.Path(), fset, cgoFiles, altInfo) + + return cgoFiles, altInfo, nil +} + +// cgoBaseType tries to look through type conversions involving +// unsafe.Pointer to find the real type. It converts: +// unsafe.Pointer(x) => x +// *(*unsafe.Pointer)(unsafe.Pointer(&x)) => x +func cgoBaseType(info *types.Info, arg ast.Expr) types.Type { + switch arg := arg.(type) { + case *ast.CallExpr: + if len(arg.Args) == 1 && isUnsafePointer(info, arg.Fun) { + return cgoBaseType(info, arg.Args[0]) + } + case *ast.StarExpr: + call, ok := arg.X.(*ast.CallExpr) + if !ok || len(call.Args) != 1 { + break + } + // Here arg is *f(v). + t := info.Types[call.Fun].Type + if t == nil { + break + } + ptr, ok := t.Underlying().(*types.Pointer) + if !ok { + break + } + // Here arg is *(*p)(v) + elem, ok := ptr.Elem().Underlying().(*types.Basic) + if !ok || elem.Kind() != types.UnsafePointer { + break + } + // Here arg is *(*unsafe.Pointer)(v) + call, ok = call.Args[0].(*ast.CallExpr) + if !ok || len(call.Args) != 1 { + break + } + // Here arg is *(*unsafe.Pointer)(f(v)) + if !isUnsafePointer(info, call.Fun) { + break + } + // Here arg is *(*unsafe.Pointer)(unsafe.Pointer(v)) + u, ok := call.Args[0].(*ast.UnaryExpr) + if !ok || u.Op != token.AND { + break + } + // Here arg is *(*unsafe.Pointer)(unsafe.Pointer(&v)) + return cgoBaseType(info, u.X) + } + + return info.Types[arg].Type +} + +// typeOKForCgoCall reports whether the type of arg is OK to pass to a +// C function using cgo. This is not true for Go types with embedded +// pointers. m is used to avoid infinite recursion on recursive types. +func typeOKForCgoCall(t types.Type, m map[types.Type]bool) bool { + if t == nil || m[t] { + return true + } + m[t] = true + switch t := t.Underlying().(type) { + case *types.Chan, *types.Map, *types.Signature, *types.Slice: + return false + case *types.Pointer: + return typeOKForCgoCall(t.Elem(), m) + case *types.Array: + return typeOKForCgoCall(t.Elem(), m) + case *types.Struct: + for i := 0; i < t.NumFields(); i++ { + if !typeOKForCgoCall(t.Field(i).Type(), m) { + return false + } + } + } + return true +} + +func isUnsafePointer(info *types.Info, e ast.Expr) bool { + t := info.Types[e].Type + return t != nil && t.Underlying() == types.Typ[types.UnsafePointer] +} + +type importerFunc func(path string) (*types.Package, error) + +func (f importerFunc) Import(path string) (*types.Package, error) { return f(path) } + +// TODO(adonovan): make this a library function or method of Info. +func imported(info *types.Info, spec *ast.ImportSpec) *types.Package { + obj, ok := info.Implicits[spec] + if !ok { + obj = info.Defs[spec.Name] // renaming import + } + return obj.(*types.PkgName).Imported() +} + +// imports reports whether pkg has path among its direct imports. +// It returns the imported package if so, or nil if not. +// TODO(adonovan): move to analysisutil. +func imports(pkg *types.Package, path string) *types.Package { + for _, imp := range pkg.Imports() { + if imp.Path() == path { + return imp + } + } + return nil +} diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/composite/composite.go b/libgo/go/golang.org/x/tools/go/analysis/passes/composite/composite.go new file mode 100644 index 00000000000..9cca7781d00 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/composite/composite.go @@ -0,0 +1,108 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package composite defines an Analyzer that checks for unkeyed +// composite literals. +package composite + +import ( + "go/ast" + "go/types" + "strings" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/inspect" + "golang.org/x/tools/go/ast/inspector" +) + +const Doc = `check for unkeyed composite literals + +This analyzer reports a diagnostic for composite literals of struct +types imported from another package that do not use the field-keyed +syntax. Such literals are fragile because the addition of a new field +(even if unexported) to the struct will cause compilation to fail.` + +var Analyzer = &analysis.Analyzer{ + Name: "composites", + Doc: Doc, + Requires: []*analysis.Analyzer{inspect.Analyzer}, + RunDespiteErrors: true, + Run: run, +} + +var whitelist = true + +func init() { + Analyzer.Flags.BoolVar(&whitelist, "whitelist", whitelist, "use composite white list; for testing only") +} + +// runUnkeyedLiteral checks if a composite literal is a struct literal with +// unkeyed fields. +func run(pass *analysis.Pass) (interface{}, error) { + inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) + + nodeFilter := []ast.Node{ + (*ast.CompositeLit)(nil), + } + inspect.Preorder(nodeFilter, func(n ast.Node) { + cl := n.(*ast.CompositeLit) + + typ := pass.TypesInfo.Types[cl].Type + if typ == nil { + // cannot determine composite literals' type, skip it + return + } + typeName := typ.String() + if whitelist && unkeyedLiteral[typeName] { + // skip whitelisted types + return + } + under := typ.Underlying() + for { + ptr, ok := under.(*types.Pointer) + if !ok { + break + } + under = ptr.Elem().Underlying() + } + if _, ok := under.(*types.Struct); !ok { + // skip non-struct composite literals + return + } + if isLocalType(pass, typ) { + // allow unkeyed locally defined composite literal + return + } + + // check if the CompositeLit contains an unkeyed field + allKeyValue := true + for _, e := range cl.Elts { + if _, ok := e.(*ast.KeyValueExpr); !ok { + allKeyValue = false + break + } + } + if allKeyValue { + // all the composite literal fields are keyed + return + } + + pass.Reportf(cl.Pos(), "%s composite literal uses unkeyed fields", typeName) + }) + return nil, nil +} + +func isLocalType(pass *analysis.Pass, typ types.Type) bool { + switch x := typ.(type) { + case *types.Struct: + // struct literals are local types + return true + case *types.Pointer: + return isLocalType(pass, x.Elem()) + case *types.Named: + // names in package foo are local to foo_test too + return strings.TrimSuffix(x.Obj().Pkg().Path(), "_test") == strings.TrimSuffix(pass.Pkg.Path(), "_test") + } + return false +} diff --git a/libgo/go/cmd/vet/internal/whitelist/whitelist.go b/libgo/go/golang.org/x/tools/go/analysis/passes/composite/whitelist.go similarity index 70% rename from libgo/go/cmd/vet/internal/whitelist/whitelist.go rename to libgo/go/golang.org/x/tools/go/analysis/passes/composite/whitelist.go index fdd65d37323..ab609f279bc 100644 --- a/libgo/go/cmd/vet/internal/whitelist/whitelist.go +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/composite/whitelist.go @@ -2,12 +2,11 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Package whitelist defines exceptions for the vet tool. -package whitelist +package composite -// UnkeyedLiteral is a white list of types in the standard packages +// unkeyedLiteral is a white list of types in the standard packages // that are used with unkeyed literals we deem to be acceptable. -var UnkeyedLiteral = map[string]bool{ +var unkeyedLiteral = map[string]bool{ // These image and image/color struct types are frozen. We will never add fields to them. "image/color.Alpha16": true, "image/color.Alpha": true, @@ -25,4 +24,10 @@ var UnkeyedLiteral = map[string]bool{ "image.Uniform": true, "unicode.Range16": true, + + // These three structs are used in generated test main files, + // but the generator can be trusted. + "testing.InternalBenchmark": true, + "testing.InternalExample": true, + "testing.InternalTest": true, } diff --git a/libgo/go/cmd/vet/copylock.go b/libgo/go/golang.org/x/tools/go/analysis/passes/copylock/copylock.go similarity index 50% rename from libgo/go/cmd/vet/copylock.go rename to libgo/go/golang.org/x/tools/go/analysis/passes/copylock/copylock.go index ed88ca89603..067aed57df3 100644 --- a/libgo/go/cmd/vet/copylock.go +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/copylock/copylock.go @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// This file contains the code to check that locks are not passed by value. - -package main +// Package copylock defines an Analyzer that checks for locks +// erroneously passed by value. +package copylock import ( "bytes" @@ -12,87 +12,112 @@ import ( "go/ast" "go/token" "go/types" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/inspect" + "golang.org/x/tools/go/analysis/passes/internal/analysisutil" + "golang.org/x/tools/go/ast/inspector" ) -func init() { - register("copylocks", - "check that locks are not passed by value", - checkCopyLocks, - funcDecl, rangeStmt, funcLit, callExpr, assignStmt, genDecl, compositeLit, returnStmt) +const Doc = `check for locks erroneously passed by value + +Inadvertently copying a value containing a lock, such as sync.Mutex or +sync.WaitGroup, may cause both copies to malfunction. Generally such +values should be referred to through a pointer.` + +var Analyzer = &analysis.Analyzer{ + Name: "copylocks", + Doc: Doc, + Requires: []*analysis.Analyzer{inspect.Analyzer}, + RunDespiteErrors: true, + Run: run, } -// checkCopyLocks checks whether node might -// inadvertently copy a lock. -func checkCopyLocks(f *File, node ast.Node) { - switch node := node.(type) { - case *ast.RangeStmt: - checkCopyLocksRange(f, node) - case *ast.FuncDecl: - checkCopyLocksFunc(f, node.Name.Name, node.Recv, node.Type) - case *ast.FuncLit: - checkCopyLocksFunc(f, "func", nil, node.Type) - case *ast.CallExpr: - checkCopyLocksCallExpr(f, node) - case *ast.AssignStmt: - checkCopyLocksAssign(f, node) - case *ast.GenDecl: - checkCopyLocksGenDecl(f, node) - case *ast.CompositeLit: - checkCopyLocksCompositeLit(f, node) - case *ast.ReturnStmt: - checkCopyLocksReturnStmt(f, node) +func run(pass *analysis.Pass) (interface{}, error) { + inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) + + nodeFilter := []ast.Node{ + (*ast.AssignStmt)(nil), + (*ast.CallExpr)(nil), + (*ast.CompositeLit)(nil), + (*ast.FuncDecl)(nil), + (*ast.FuncLit)(nil), + (*ast.GenDecl)(nil), + (*ast.RangeStmt)(nil), + (*ast.ReturnStmt)(nil), } + inspect.Preorder(nodeFilter, func(node ast.Node) { + switch node := node.(type) { + case *ast.RangeStmt: + checkCopyLocksRange(pass, node) + case *ast.FuncDecl: + checkCopyLocksFunc(pass, node.Name.Name, node.Recv, node.Type) + case *ast.FuncLit: + checkCopyLocksFunc(pass, "func", nil, node.Type) + case *ast.CallExpr: + checkCopyLocksCallExpr(pass, node) + case *ast.AssignStmt: + checkCopyLocksAssign(pass, node) + case *ast.GenDecl: + checkCopyLocksGenDecl(pass, node) + case *ast.CompositeLit: + checkCopyLocksCompositeLit(pass, node) + case *ast.ReturnStmt: + checkCopyLocksReturnStmt(pass, node) + } + }) + return nil, nil } // checkCopyLocksAssign checks whether an assignment // copies a lock. -func checkCopyLocksAssign(f *File, as *ast.AssignStmt) { +func checkCopyLocksAssign(pass *analysis.Pass, as *ast.AssignStmt) { for i, x := range as.Rhs { - if path := lockPathRhs(f, x); path != nil { - f.Badf(x.Pos(), "assignment copies lock value to %v: %v", f.gofmt(as.Lhs[i]), path) + if path := lockPathRhs(pass, x); path != nil { + pass.Reportf(x.Pos(), "assignment copies lock value to %v: %v", analysisutil.Format(pass.Fset, as.Lhs[i]), path) } } } // checkCopyLocksGenDecl checks whether lock is copied // in variable declaration. -func checkCopyLocksGenDecl(f *File, gd *ast.GenDecl) { +func checkCopyLocksGenDecl(pass *analysis.Pass, gd *ast.GenDecl) { if gd.Tok != token.VAR { return } for _, spec := range gd.Specs { valueSpec := spec.(*ast.ValueSpec) for i, x := range valueSpec.Values { - if path := lockPathRhs(f, x); path != nil { - f.Badf(x.Pos(), "variable declaration copies lock value to %v: %v", valueSpec.Names[i].Name, path) + if path := lockPathRhs(pass, x); path != nil { + pass.Reportf(x.Pos(), "variable declaration copies lock value to %v: %v", valueSpec.Names[i].Name, path) } } } } // checkCopyLocksCompositeLit detects lock copy inside a composite literal -func checkCopyLocksCompositeLit(f *File, cl *ast.CompositeLit) { +func checkCopyLocksCompositeLit(pass *analysis.Pass, cl *ast.CompositeLit) { for _, x := range cl.Elts { if node, ok := x.(*ast.KeyValueExpr); ok { x = node.Value } - if path := lockPathRhs(f, x); path != nil { - f.Badf(x.Pos(), "literal copies lock value from %v: %v", f.gofmt(x), path) + if path := lockPathRhs(pass, x); path != nil { + pass.Reportf(x.Pos(), "literal copies lock value from %v: %v", analysisutil.Format(pass.Fset, x), path) } } } // checkCopyLocksReturnStmt detects lock copy in return statement -func checkCopyLocksReturnStmt(f *File, rs *ast.ReturnStmt) { +func checkCopyLocksReturnStmt(pass *analysis.Pass, rs *ast.ReturnStmt) { for _, x := range rs.Results { - if path := lockPathRhs(f, x); path != nil { - f.Badf(x.Pos(), "return copies lock value: %v", path) + if path := lockPathRhs(pass, x); path != nil { + pass.Reportf(x.Pos(), "return copies lock value: %v", path) } } } // checkCopyLocksCallExpr detects lock copy in the arguments to a function call -func checkCopyLocksCallExpr(f *File, ce *ast.CallExpr) { +func checkCopyLocksCallExpr(pass *analysis.Pass, ce *ast.CallExpr) { var id *ast.Ident switch fun := ce.Fun.(type) { case *ast.Ident: @@ -100,15 +125,15 @@ func checkCopyLocksCallExpr(f *File, ce *ast.CallExpr) { case *ast.SelectorExpr: id = fun.Sel } - if fun, ok := f.pkg.uses[id].(*types.Builtin); ok { + if fun, ok := pass.TypesInfo.Uses[id].(*types.Builtin); ok { switch fun.Name() { case "new", "len", "cap", "Sizeof": return } } for _, x := range ce.Args { - if path := lockPathRhs(f, x); path != nil { - f.Badf(x.Pos(), "call of %s copies lock value: %v", f.gofmt(ce.Fun), path) + if path := lockPathRhs(pass, x); path != nil { + pass.Reportf(x.Pos(), "call of %s copies lock value: %v", analysisutil.Format(pass.Fset, ce.Fun), path) } } } @@ -117,19 +142,19 @@ func checkCopyLocksCallExpr(f *File, ce *ast.CallExpr) { // inadvertently copy a lock, by checking whether // its receiver, parameters, or return values // are locks. -func checkCopyLocksFunc(f *File, name string, recv *ast.FieldList, typ *ast.FuncType) { +func checkCopyLocksFunc(pass *analysis.Pass, name string, recv *ast.FieldList, typ *ast.FuncType) { if recv != nil && len(recv.List) > 0 { expr := recv.List[0].Type - if path := lockPath(f.pkg.typesPkg, f.pkg.types[expr].Type); path != nil { - f.Badf(expr.Pos(), "%s passes lock by value: %v", name, path) + if path := lockPath(pass.Pkg, pass.TypesInfo.Types[expr].Type); path != nil { + pass.Reportf(expr.Pos(), "%s passes lock by value: %v", name, path) } } if typ.Params != nil { for _, field := range typ.Params.List { expr := field.Type - if path := lockPath(f.pkg.typesPkg, f.pkg.types[expr].Type); path != nil { - f.Badf(expr.Pos(), "%s passes lock by value: %v", name, path) + if path := lockPath(pass.Pkg, pass.TypesInfo.Types[expr].Type); path != nil { + pass.Reportf(expr.Pos(), "%s passes lock by value: %v", name, path) } } } @@ -143,12 +168,12 @@ func checkCopyLocksFunc(f *File, name string, recv *ast.FieldList, typ *ast.Func // checkCopyLocksRange checks whether a range statement // might inadvertently copy a lock by checking whether // any of the range variables are locks. -func checkCopyLocksRange(f *File, r *ast.RangeStmt) { - checkCopyLocksRangeVar(f, r.Tok, r.Key) - checkCopyLocksRangeVar(f, r.Tok, r.Value) +func checkCopyLocksRange(pass *analysis.Pass, r *ast.RangeStmt) { + checkCopyLocksRangeVar(pass, r.Tok, r.Key) + checkCopyLocksRangeVar(pass, r.Tok, r.Value) } -func checkCopyLocksRangeVar(f *File, rtok token.Token, e ast.Expr) { +func checkCopyLocksRangeVar(pass *analysis.Pass, rtok token.Token, e ast.Expr) { if e == nil { return } @@ -162,20 +187,20 @@ func checkCopyLocksRangeVar(f *File, rtok token.Token, e ast.Expr) { if !isId { return } - obj := f.pkg.defs[id] + obj := pass.TypesInfo.Defs[id] if obj == nil { return } typ = obj.Type() } else { - typ = f.pkg.types[e].Type + typ = pass.TypesInfo.Types[e].Type } if typ == nil { return } - if path := lockPath(f.pkg.typesPkg, typ); path != nil { - f.Badf(e.Pos(), "range var %s copies lock: %v", f.gofmt(e), path) + if path := lockPath(pass.Pkg, typ); path != nil { + pass.Reportf(e.Pos(), "range var %s copies lock: %v", analysisutil.Format(pass.Fset, e), path) } } @@ -195,7 +220,7 @@ func (path typePath) String() string { return buf.String() } -func lockPathRhs(f *File, x ast.Expr) typePath { +func lockPathRhs(pass *analysis.Pass, x ast.Expr) typePath { if _, ok := x.(*ast.CompositeLit); ok { return nil } @@ -209,7 +234,7 @@ func lockPathRhs(f *File, x ast.Expr) typePath { return nil } } - return lockPath(f.pkg.typesPkg, f.pkg.types[x].Type) + return lockPath(pass.Pkg, pass.TypesInfo.Types[x].Type) } // lockPath returns a typePath describing the location of a lock value @@ -241,6 +266,15 @@ func lockPath(tpkg *types.Package, typ types.Type) typePath { return []types.Type{typ} } + // In go1.10, sync.noCopy did not implement Locker. + // (The Unlock method was added only in CL 121876.) + // TODO(adonovan): remove workaround when we drop go1.10. + if named, ok := typ.(*types.Named); ok && + named.Obj().Name() == "noCopy" && + named.Obj().Pkg().Path() == "sync" { + return []types.Type{typ} + } + nfields := styp.NumFields() for i := 0; i < nfields; i++ { ftyp := styp.Field(i).Type() diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/ctrlflow/ctrlflow.go b/libgo/go/golang.org/x/tools/go/analysis/passes/ctrlflow/ctrlflow.go new file mode 100644 index 00000000000..75655c5bad4 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/ctrlflow/ctrlflow.go @@ -0,0 +1,225 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package ctrlflow is an analysis that provides a syntactic +// control-flow graph (CFG) for the body of a function. +// It records whether a function cannot return. +// By itself, it does not report any diagnostics. +package ctrlflow + +import ( + "go/ast" + "go/types" + "log" + "reflect" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/inspect" + "golang.org/x/tools/go/ast/inspector" + "golang.org/x/tools/go/cfg" + "golang.org/x/tools/go/types/typeutil" +) + +var Analyzer = &analysis.Analyzer{ + Name: "ctrlflow", + Doc: "build a control-flow graph", + Run: run, + ResultType: reflect.TypeOf(new(CFGs)), + FactTypes: []analysis.Fact{new(noReturn)}, + Requires: []*analysis.Analyzer{inspect.Analyzer}, +} + +// noReturn is a fact indicating that a function does not return. +type noReturn struct{} + +func (*noReturn) AFact() {} + +func (*noReturn) String() string { return "noReturn" } + +// A CFGs holds the control-flow graphs +// for all the functions of the current package. +type CFGs struct { + defs map[*ast.Ident]types.Object // from Pass.TypesInfo.Defs + funcDecls map[*types.Func]*declInfo + funcLits map[*ast.FuncLit]*litInfo + pass *analysis.Pass // transient; nil after construction +} + +// CFGs has two maps: funcDecls for named functions and funcLits for +// unnamed ones. Unlike funcLits, the funcDecls map is not keyed by its +// syntax node, *ast.FuncDecl, because callMayReturn needs to do a +// look-up by *types.Func, and you can get from an *ast.FuncDecl to a +// *types.Func but not the other way. + +type declInfo struct { + decl *ast.FuncDecl + cfg *cfg.CFG // iff decl.Body != nil + started bool // to break cycles + noReturn bool +} + +type litInfo struct { + cfg *cfg.CFG + noReturn bool +} + +// FuncDecl returns the control-flow graph for a named function. +// It returns nil if decl.Body==nil. +func (c *CFGs) FuncDecl(decl *ast.FuncDecl) *cfg.CFG { + if decl.Body == nil { + return nil + } + fn := c.defs[decl.Name].(*types.Func) + return c.funcDecls[fn].cfg +} + +// FuncLit returns the control-flow graph for a literal function. +func (c *CFGs) FuncLit(lit *ast.FuncLit) *cfg.CFG { + return c.funcLits[lit].cfg +} + +func run(pass *analysis.Pass) (interface{}, error) { + inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) + + // Because CFG construction consumes and produces noReturn + // facts, CFGs for exported FuncDecls must be built before 'run' + // returns; we cannot construct them lazily. + // (We could build CFGs for FuncLits lazily, + // but the benefit is marginal.) + + // Pass 1. Map types.Funcs to ast.FuncDecls in this package. + funcDecls := make(map[*types.Func]*declInfo) // functions and methods + funcLits := make(map[*ast.FuncLit]*litInfo) + + var decls []*types.Func // keys(funcDecls), in order + var lits []*ast.FuncLit // keys(funcLits), in order + + nodeFilter := []ast.Node{ + (*ast.FuncDecl)(nil), + (*ast.FuncLit)(nil), + } + inspect.Preorder(nodeFilter, func(n ast.Node) { + switch n := n.(type) { + case *ast.FuncDecl: + fn := pass.TypesInfo.Defs[n.Name].(*types.Func) + funcDecls[fn] = &declInfo{decl: n} + decls = append(decls, fn) + + case *ast.FuncLit: + funcLits[n] = new(litInfo) + lits = append(lits, n) + } + }) + + c := &CFGs{ + defs: pass.TypesInfo.Defs, + funcDecls: funcDecls, + funcLits: funcLits, + pass: pass, + } + + // Pass 2. Build CFGs. + + // Build CFGs for named functions. + // Cycles in the static call graph are broken + // arbitrarily but deterministically. + // We create noReturn facts as discovered. + for _, fn := range decls { + c.buildDecl(fn, funcDecls[fn]) + } + + // Build CFGs for literal functions. + // These aren't relevant to facts (since they aren't named) + // but are required for the CFGs.FuncLit API. + for _, lit := range lits { + li := funcLits[lit] + if li.cfg == nil { + li.cfg = cfg.New(lit.Body, c.callMayReturn) + if !hasReachableReturn(li.cfg) { + li.noReturn = true + } + } + } + + // All CFGs are now built. + c.pass = nil + + return c, nil +} + +// di.cfg may be nil on return. +func (c *CFGs) buildDecl(fn *types.Func, di *declInfo) { + // buildDecl may call itself recursively for the same function, + // because cfg.New is passed the callMayReturn method, which + // builds the CFG of the callee, leading to recursion. + // The buildDecl call tree thus resembles the static call graph. + // We mark each node when we start working on it to break cycles. + + if !di.started { // break cycle + di.started = true + + if isIntrinsicNoReturn(fn) { + di.noReturn = true + } + if di.decl.Body != nil { + di.cfg = cfg.New(di.decl.Body, c.callMayReturn) + if !hasReachableReturn(di.cfg) { + di.noReturn = true + } + } + if di.noReturn { + c.pass.ExportObjectFact(fn, new(noReturn)) + } + + // debugging + if false { + log.Printf("CFG for %s:\n%s (noreturn=%t)\n", fn, di.cfg.Format(c.pass.Fset), di.noReturn) + } + } +} + +// callMayReturn reports whether the called function may return. +// It is passed to the CFG builder. +func (c *CFGs) callMayReturn(call *ast.CallExpr) (r bool) { + if id, ok := call.Fun.(*ast.Ident); ok && c.pass.TypesInfo.Uses[id] == panicBuiltin { + return false // panic never returns + } + + // Is this a static call? + fn := typeutil.StaticCallee(c.pass.TypesInfo, call) + if fn == nil { + return true // callee not statically known; be conservative + } + + // Function or method declared in this package? + if di, ok := c.funcDecls[fn]; ok { + c.buildDecl(fn, di) + return !di.noReturn + } + + // Not declared in this package. + // Is there a fact from another package? + return !c.pass.ImportObjectFact(fn, new(noReturn)) +} + +var panicBuiltin = types.Universe.Lookup("panic").(*types.Builtin) + +func hasReachableReturn(g *cfg.CFG) bool { + for _, b := range g.Blocks { + if b.Live && b.Return() != nil { + return true + } + } + return false +} + +// isIntrinsicNoReturn reports whether a function intrinsically never +// returns because it stops execution of the calling thread. +// It is the base case in the recursion. +func isIntrinsicNoReturn(fn *types.Func) bool { + // Add functions here as the need arises, but don't allocate memory. + path, name := fn.Pkg().Path(), fn.Name() + return path == "syscall" && (name == "Exit" || name == "ExitProcess" || name == "ExitThread") || + path == "runtime" && name == "Goexit" +} diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/httpresponse/httpresponse.go b/libgo/go/golang.org/x/tools/go/analysis/passes/httpresponse/httpresponse.go new file mode 100644 index 00000000000..0cf21b8cd1e --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/httpresponse/httpresponse.go @@ -0,0 +1,177 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package httpresponse defines an Analyzer that checks for mistakes +// using HTTP responses. +package httpresponse + +import ( + "go/ast" + "go/types" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/inspect" + "golang.org/x/tools/go/ast/inspector" +) + +const Doc = `check for mistakes using HTTP responses + +A common mistake when using the net/http package is to defer a function +call to close the http.Response Body before checking the error that +determines whether the response is valid: + + resp, err := http.Head(url) + defer resp.Body.Close() + if err != nil { + log.Fatal(err) + } + // (defer statement belongs here) + +This checker helps uncover latent nil dereference bugs by reporting a +diagnostic for such mistakes.` + +var Analyzer = &analysis.Analyzer{ + Name: "httpresponse", + Doc: Doc, + Requires: []*analysis.Analyzer{inspect.Analyzer}, + Run: run, +} + +func run(pass *analysis.Pass) (interface{}, error) { + inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) + + // Fast path: if the package doesn't import net/http, + // skip the traversal. + if !imports(pass.Pkg, "net/http") { + return nil, nil + } + + nodeFilter := []ast.Node{ + (*ast.CallExpr)(nil), + } + inspect.WithStack(nodeFilter, func(n ast.Node, push bool, stack []ast.Node) bool { + if !push { + return true + } + call := n.(*ast.CallExpr) + if !isHTTPFuncOrMethodOnClient(pass.TypesInfo, call) { + return true // the function call is not related to this check. + } + + // Find the innermost containing block, and get the list + // of statements starting with the one containing call. + stmts := restOfBlock(stack) + if len(stmts) < 2 { + return true // the call to the http function is the last statement of the block. + } + + asg, ok := stmts[0].(*ast.AssignStmt) + if !ok { + return true // the first statement is not assignment. + } + resp := rootIdent(asg.Lhs[0]) + if resp == nil { + return true // could not find the http.Response in the assignment. + } + + def, ok := stmts[1].(*ast.DeferStmt) + if !ok { + return true // the following statement is not a defer. + } + root := rootIdent(def.Call.Fun) + if root == nil { + return true // could not find the receiver of the defer call. + } + + if resp.Obj == root.Obj { + pass.Reportf(root.Pos(), "using %s before checking for errors", resp.Name) + } + return true + }) + return nil, nil +} + +// isHTTPFuncOrMethodOnClient checks whether the given call expression is on +// either a function of the net/http package or a method of http.Client that +// returns (*http.Response, error). +func isHTTPFuncOrMethodOnClient(info *types.Info, expr *ast.CallExpr) bool { + fun, _ := expr.Fun.(*ast.SelectorExpr) + sig, _ := info.Types[fun].Type.(*types.Signature) + if sig == nil { + return false // the call is not of the form x.f() + } + + res := sig.Results() + if res.Len() != 2 { + return false // the function called does not return two values. + } + if ptr, ok := res.At(0).Type().(*types.Pointer); !ok || !isNamedType(ptr.Elem(), "net/http", "Response") { + return false // the first return type is not *http.Response. + } + + errorType := types.Universe.Lookup("error").Type() + if !types.Identical(res.At(1).Type(), errorType) { + return false // the second return type is not error + } + + typ := info.Types[fun.X].Type + if typ == nil { + id, ok := fun.X.(*ast.Ident) + return ok && id.Name == "http" // function in net/http package. + } + + if isNamedType(typ, "net/http", "Client") { + return true // method on http.Client. + } + ptr, ok := typ.(*types.Pointer) + return ok && isNamedType(ptr.Elem(), "net/http", "Client") // method on *http.Client. +} + +// restOfBlock, given a traversal stack, finds the innermost containing +// block and returns the suffix of its statements starting with the +// current node (the last element of stack). +func restOfBlock(stack []ast.Node) []ast.Stmt { + for i := len(stack) - 1; i >= 0; i-- { + if b, ok := stack[i].(*ast.BlockStmt); ok { + for j, v := range b.List { + if v == stack[i+1] { + return b.List[j:] + } + } + break + } + } + return nil +} + +// rootIdent finds the root identifier x in a chain of selections x.y.z, or nil if not found. +func rootIdent(n ast.Node) *ast.Ident { + switch n := n.(type) { + case *ast.SelectorExpr: + return rootIdent(n.X) + case *ast.Ident: + return n + default: + return nil + } +} + +// isNamedType reports whether t is the named type path.name. +func isNamedType(t types.Type, path, name string) bool { + n, ok := t.(*types.Named) + if !ok { + return false + } + obj := n.Obj() + return obj.Name() == name && obj.Pkg() != nil && obj.Pkg().Path() == path +} + +func imports(pkg *types.Package, path string) bool { + for _, imp := range pkg.Imports() { + if imp.Path() == path { + return true + } + } + return false +} diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/inspect/inspect.go b/libgo/go/golang.org/x/tools/go/analysis/passes/inspect/inspect.go new file mode 100644 index 00000000000..bd06549984a --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/inspect/inspect.go @@ -0,0 +1,45 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package inspect defines an Analyzer that provides an AST inspector +// (golang.org/x/tools/go/ast/inspect.Inspect) for the syntax trees of a +// package. It is only a building block for other analyzers. +// +// Example of use in another analysis: +// +// import "golang.org/x/tools/go/analysis/passes/inspect" +// +// var Analyzer = &analysis.Analyzer{ +// ... +// Requires: reflect.TypeOf(new(inspect.Analyzer)), +// } +// +// func run(pass *analysis.Pass) (interface{}, error) { +// inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) +// inspect.Preorder(nil, func(n ast.Node) { +// ... +// }) +// return nil +// } +// +package inspect + +import ( + "reflect" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/ast/inspector" +) + +var Analyzer = &analysis.Analyzer{ + Name: "inspect", + Doc: "optimize AST traversal for later passes", + Run: run, + RunDespiteErrors: true, + ResultType: reflect.TypeOf(new(inspector.Inspector)), +} + +func run(pass *analysis.Pass) (interface{}, error) { + return inspector.New(pass.Files), nil +} diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/internal/analysisutil/util.go b/libgo/go/golang.org/x/tools/go/analysis/passes/internal/analysisutil/util.go new file mode 100644 index 00000000000..13a458d9d6b --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/internal/analysisutil/util.go @@ -0,0 +1,106 @@ +// Package analysisutil defines various helper functions +// used by two or more packages beneath go/analysis. +package analysisutil + +import ( + "bytes" + "go/ast" + "go/printer" + "go/token" + "go/types" + "io/ioutil" +) + +// Format returns a string representation of the expression. +func Format(fset *token.FileSet, x ast.Expr) string { + var b bytes.Buffer + printer.Fprint(&b, fset, x) + return b.String() +} + +// HasSideEffects reports whether evaluation of e has side effects. +func HasSideEffects(info *types.Info, e ast.Expr) bool { + safe := true + ast.Inspect(e, func(node ast.Node) bool { + switch n := node.(type) { + case *ast.CallExpr: + typVal := info.Types[n.Fun] + switch { + case typVal.IsType(): + // Type conversion, which is safe. + case typVal.IsBuiltin(): + // Builtin func, conservatively assumed to not + // be safe for now. + safe = false + return false + default: + // A non-builtin func or method call. + // Conservatively assume that all of them have + // side effects for now. + safe = false + return false + } + case *ast.UnaryExpr: + if n.Op == token.ARROW { + safe = false + return false + } + } + return true + }) + return !safe +} + +// Unparen returns e with any enclosing parentheses stripped. +func Unparen(e ast.Expr) ast.Expr { + for { + p, ok := e.(*ast.ParenExpr) + if !ok { + return e + } + e = p.X + } +} + +// ReadFile reads a file and adds it to the FileSet +// so that we can report errors against it using lineStart. +func ReadFile(fset *token.FileSet, filename string) ([]byte, *token.File, error) { + content, err := ioutil.ReadFile(filename) + if err != nil { + return nil, nil, err + } + tf := fset.AddFile(filename, -1, len(content)) + tf.SetLinesForContent(content) + return content, tf, nil +} + +// LineStart returns the position of the start of the specified line +// within file f, or NoPos if there is no line of that number. +func LineStart(f *token.File, line int) token.Pos { + // Use binary search to find the start offset of this line. + // + // TODO(adonovan): eventually replace this function with the + // simpler and more efficient (*go/token.File).LineStart, added + // in go1.12. + + min := 0 // inclusive + max := f.Size() // exclusive + for { + offset := (min + max) / 2 + pos := f.Pos(offset) + posn := f.Position(pos) + if posn.Line == line { + return pos - (token.Pos(posn.Column) - 1) + } + + if min+1 >= max { + return token.NoPos + } + + if posn.Line < line { + min = offset + } else { + max = offset + } + } +} diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/loopclosure/loopclosure.go b/libgo/go/golang.org/x/tools/go/analysis/passes/loopclosure/loopclosure.go new file mode 100644 index 00000000000..da0714069f7 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/loopclosure/loopclosure.go @@ -0,0 +1,130 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package loopclosure defines an Analyzer that checks for references to +// enclosing loop variables from within nested functions. +package loopclosure + +import ( + "go/ast" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/inspect" + "golang.org/x/tools/go/ast/inspector" +) + +// TODO(adonovan): also report an error for the following structure, +// which is often used to ensure that deferred calls do not accumulate +// in a loop: +// +// for i, x := range c { +// func() { +// ...reference to i or x... +// }() +// } + +const Doc = `check references to loop variables from within nested functions + +This analyzer checks for references to loop variables from within a +function literal inside the loop body. It checks only instances where +the function literal is called in a defer or go statement that is the +last statement in the loop body, as otherwise we would need whole +program analysis. + +For example: + + for i, v := range s { + go func() { + println(i, v) // not what you might expect + }() + } + +See: https://golang.org/doc/go_faq.html#closures_and_goroutines` + +var Analyzer = &analysis.Analyzer{ + Name: "loopclosure", + Doc: Doc, + Requires: []*analysis.Analyzer{inspect.Analyzer}, + Run: run, +} + +func run(pass *analysis.Pass) (interface{}, error) { + inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) + + nodeFilter := []ast.Node{ + (*ast.RangeStmt)(nil), + (*ast.ForStmt)(nil), + } + inspect.Preorder(nodeFilter, func(n ast.Node) { + // Find the variables updated by the loop statement. + var vars []*ast.Ident + addVar := func(expr ast.Expr) { + if id, ok := expr.(*ast.Ident); ok { + vars = append(vars, id) + } + } + var body *ast.BlockStmt + switch n := n.(type) { + case *ast.RangeStmt: + body = n.Body + addVar(n.Key) + addVar(n.Value) + case *ast.ForStmt: + body = n.Body + switch post := n.Post.(type) { + case *ast.AssignStmt: + // e.g. for p = head; p != nil; p = p.next + for _, lhs := range post.Lhs { + addVar(lhs) + } + case *ast.IncDecStmt: + // e.g. for i := 0; i < n; i++ + addVar(post.X) + } + } + if vars == nil { + return + } + + // Inspect a go or defer statement + // if it's the last one in the loop body. + // (We give up if there are following statements, + // because it's hard to prove go isn't followed by wait, + // or defer by return.) + if len(body.List) == 0 { + return + } + var last *ast.CallExpr + switch s := body.List[len(body.List)-1].(type) { + case *ast.GoStmt: + last = s.Call + case *ast.DeferStmt: + last = s.Call + default: + return + } + lit, ok := last.Fun.(*ast.FuncLit) + if !ok { + return + } + ast.Inspect(lit.Body, func(n ast.Node) bool { + id, ok := n.(*ast.Ident) + if !ok || id.Obj == nil { + return true + } + if pass.TypesInfo.Types[id].Type == nil { + // Not referring to a variable (e.g. struct field name) + return true + } + for _, v := range vars { + if v.Obj == id.Obj { + pass.Reportf(id.Pos(), "loop variable %s captured by func literal", + id.Name) + } + } + return true + }) + }) + return nil, nil +} diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/lostcancel/lostcancel.go b/libgo/go/golang.org/x/tools/go/analysis/passes/lostcancel/lostcancel.go new file mode 100644 index 00000000000..b5161836a57 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/lostcancel/lostcancel.go @@ -0,0 +1,315 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package lostcancel defines an Analyzer that checks for failure to +// call a context cancelation function. +package lostcancel + +import ( + "fmt" + "go/ast" + "go/types" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/ctrlflow" + "golang.org/x/tools/go/analysis/passes/inspect" + "golang.org/x/tools/go/ast/inspector" + "golang.org/x/tools/go/cfg" +) + +const Doc = `check cancel func returned by context.WithCancel is called + +The cancelation function returned by context.WithCancel, WithTimeout, +and WithDeadline must be called or the new context will remain live +until its parent context is cancelled. +(The background context is never cancelled.)` + +var Analyzer = &analysis.Analyzer{ + Name: "lostcancel", + Doc: Doc, + Run: run, + Requires: []*analysis.Analyzer{ + inspect.Analyzer, + ctrlflow.Analyzer, + }, +} + +const debug = false + +var contextPackage = "context" + +// checkLostCancel reports a failure to the call the cancel function +// returned by context.WithCancel, either because the variable was +// assigned to the blank identifier, or because there exists a +// control-flow path from the call to a return statement and that path +// does not "use" the cancel function. Any reference to the variable +// counts as a use, even within a nested function literal. +// +// checkLostCancel analyzes a single named or literal function. +func run(pass *analysis.Pass) (interface{}, error) { + // Fast path: bypass check if file doesn't use context.WithCancel. + if !hasImport(pass.Pkg, contextPackage) { + return nil, nil + } + + // Call runFunc for each Func{Decl,Lit}. + inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) + nodeTypes := []ast.Node{ + (*ast.FuncLit)(nil), + (*ast.FuncDecl)(nil), + } + inspect.Preorder(nodeTypes, func(n ast.Node) { + runFunc(pass, n) + }) + return nil, nil +} + +func runFunc(pass *analysis.Pass, node ast.Node) { + // Maps each cancel variable to its defining ValueSpec/AssignStmt. + cancelvars := make(map[*types.Var]ast.Node) + + // TODO(adonovan): opt: refactor to make a single pass + // over the AST using inspect.WithStack and node types + // {FuncDecl,FuncLit,CallExpr,SelectorExpr}. + + // Find the set of cancel vars to analyze. + stack := make([]ast.Node, 0, 32) + ast.Inspect(node, func(n ast.Node) bool { + switch n.(type) { + case *ast.FuncLit: + if len(stack) > 0 { + return false // don't stray into nested functions + } + case nil: + stack = stack[:len(stack)-1] // pop + return true + } + stack = append(stack, n) // push + + // Look for [{AssignStmt,ValueSpec} CallExpr SelectorExpr]: + // + // ctx, cancel := context.WithCancel(...) + // ctx, cancel = context.WithCancel(...) + // var ctx, cancel = context.WithCancel(...) + // + if !isContextWithCancel(pass.TypesInfo, n) || !isCall(stack[len(stack)-2]) { + return true + } + var id *ast.Ident // id of cancel var + stmt := stack[len(stack)-3] + switch stmt := stmt.(type) { + case *ast.ValueSpec: + if len(stmt.Names) > 1 { + id = stmt.Names[1] + } + case *ast.AssignStmt: + if len(stmt.Lhs) > 1 { + id, _ = stmt.Lhs[1].(*ast.Ident) + } + } + if id != nil { + if id.Name == "_" { + pass.Reportf(id.Pos(), + "the cancel function returned by context.%s should be called, not discarded, to avoid a context leak", + n.(*ast.SelectorExpr).Sel.Name) + } else if v, ok := pass.TypesInfo.Uses[id].(*types.Var); ok { + cancelvars[v] = stmt + } else if v, ok := pass.TypesInfo.Defs[id].(*types.Var); ok { + cancelvars[v] = stmt + } + } + return true + }) + + if len(cancelvars) == 0 { + return // no need to inspect CFG + } + + // Obtain the CFG. + cfgs := pass.ResultOf[ctrlflow.Analyzer].(*ctrlflow.CFGs) + var g *cfg.CFG + var sig *types.Signature + switch node := node.(type) { + case *ast.FuncDecl: + sig, _ = pass.TypesInfo.Defs[node.Name].Type().(*types.Signature) + if node.Name.Name == "main" && sig.Recv() == nil && pass.Pkg.Name() == "main" { + // Returning from main.main terminates the process, + // so there's no need to cancel contexts. + return + } + g = cfgs.FuncDecl(node) + + case *ast.FuncLit: + sig, _ = pass.TypesInfo.Types[node.Type].Type.(*types.Signature) + g = cfgs.FuncLit(node) + } + if sig == nil { + return // missing type information + } + + // Print CFG. + if debug { + fmt.Println(g.Format(pass.Fset)) + } + + // Examine the CFG for each variable in turn. + // (It would be more efficient to analyze all cancelvars in a + // single pass over the AST, but seldom is there more than one.) + for v, stmt := range cancelvars { + if ret := lostCancelPath(pass, g, v, stmt, sig); ret != nil { + lineno := pass.Fset.Position(stmt.Pos()).Line + pass.Reportf(stmt.Pos(), "the %s function is not used on all paths (possible context leak)", v.Name()) + pass.Reportf(ret.Pos(), "this return statement may be reached without using the %s var defined on line %d", v.Name(), lineno) + } + } +} + +func isCall(n ast.Node) bool { _, ok := n.(*ast.CallExpr); return ok } + +func hasImport(pkg *types.Package, path string) bool { + for _, imp := range pkg.Imports() { + if imp.Path() == path { + return true + } + } + return false +} + +// isContextWithCancel reports whether n is one of the qualified identifiers +// context.With{Cancel,Timeout,Deadline}. +func isContextWithCancel(info *types.Info, n ast.Node) bool { + sel, ok := n.(*ast.SelectorExpr) + if !ok { + return false + } + switch sel.Sel.Name { + case "WithCancel", "WithTimeout", "WithDeadline": + default: + return false + } + if x, ok := sel.X.(*ast.Ident); ok { + if pkgname, ok := info.Uses[x].(*types.PkgName); ok { + return pkgname.Imported().Path() == contextPackage + } + // Import failed, so we can't check package path. + // Just check the local package name (heuristic). + return x.Name == "context" + } + return false +} + +// lostCancelPath finds a path through the CFG, from stmt (which defines +// the 'cancel' variable v) to a return statement, that doesn't "use" v. +// If it finds one, it returns the return statement (which may be synthetic). +// sig is the function's type, if known. +func lostCancelPath(pass *analysis.Pass, g *cfg.CFG, v *types.Var, stmt ast.Node, sig *types.Signature) *ast.ReturnStmt { + vIsNamedResult := sig != nil && tupleContains(sig.Results(), v) + + // uses reports whether stmts contain a "use" of variable v. + uses := func(pass *analysis.Pass, v *types.Var, stmts []ast.Node) bool { + found := false + for _, stmt := range stmts { + ast.Inspect(stmt, func(n ast.Node) bool { + switch n := n.(type) { + case *ast.Ident: + if pass.TypesInfo.Uses[n] == v { + found = true + } + case *ast.ReturnStmt: + // A naked return statement counts as a use + // of the named result variables. + if n.Results == nil && vIsNamedResult { + found = true + } + } + return !found + }) + } + return found + } + + // blockUses computes "uses" for each block, caching the result. + memo := make(map[*cfg.Block]bool) + blockUses := func(pass *analysis.Pass, v *types.Var, b *cfg.Block) bool { + res, ok := memo[b] + if !ok { + res = uses(pass, v, b.Nodes) + memo[b] = res + } + return res + } + + // Find the var's defining block in the CFG, + // plus the rest of the statements of that block. + var defblock *cfg.Block + var rest []ast.Node +outer: + for _, b := range g.Blocks { + for i, n := range b.Nodes { + if n == stmt { + defblock = b + rest = b.Nodes[i+1:] + break outer + } + } + } + if defblock == nil { + panic("internal error: can't find defining block for cancel var") + } + + // Is v "used" in the remainder of its defining block? + if uses(pass, v, rest) { + return nil + } + + // Does the defining block return without using v? + if ret := defblock.Return(); ret != nil { + return ret + } + + // Search the CFG depth-first for a path, from defblock to a + // return block, in which v is never "used". + seen := make(map[*cfg.Block]bool) + var search func(blocks []*cfg.Block) *ast.ReturnStmt + search = func(blocks []*cfg.Block) *ast.ReturnStmt { + for _, b := range blocks { + if seen[b] { + continue + } + seen[b] = true + + // Prune the search if the block uses v. + if blockUses(pass, v, b) { + continue + } + + // Found path to return statement? + if ret := b.Return(); ret != nil { + if debug { + fmt.Printf("found path to return in block %s\n", b) + } + return ret // found + } + + // Recur + if ret := search(b.Succs); ret != nil { + if debug { + fmt.Printf(" from block %s\n", b) + } + return ret + } + } + return nil + } + return search(defblock.Succs) +} + +func tupleContains(tuple *types.Tuple, v *types.Var) bool { + for i := 0; i < tuple.Len(); i++ { + if tuple.At(i) == v { + return true + } + } + return false +} diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/nilfunc/nilfunc.go b/libgo/go/golang.org/x/tools/go/analysis/passes/nilfunc/nilfunc.go new file mode 100644 index 00000000000..9c2d4df20a0 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/nilfunc/nilfunc.go @@ -0,0 +1,74 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package nilfunc defines an Analyzer that checks for useless +// comparisons against nil. +package nilfunc + +import ( + "go/ast" + "go/token" + "go/types" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/inspect" + "golang.org/x/tools/go/ast/inspector" +) + +const Doc = `check for useless comparisons between functions and nil + +A useless comparison is one like f == nil as opposed to f() == nil.` + +var Analyzer = &analysis.Analyzer{ + Name: "nilfunc", + Doc: Doc, + Requires: []*analysis.Analyzer{inspect.Analyzer}, + Run: run, +} + +func run(pass *analysis.Pass) (interface{}, error) { + inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) + + nodeFilter := []ast.Node{ + (*ast.BinaryExpr)(nil), + } + inspect.Preorder(nodeFilter, func(n ast.Node) { + e := n.(*ast.BinaryExpr) + + // Only want == or != comparisons. + if e.Op != token.EQL && e.Op != token.NEQ { + return + } + + // Only want comparisons with a nil identifier on one side. + var e2 ast.Expr + switch { + case pass.TypesInfo.Types[e.X].IsNil(): + e2 = e.Y + case pass.TypesInfo.Types[e.Y].IsNil(): + e2 = e.X + default: + return + } + + // Only want identifiers or selector expressions. + var obj types.Object + switch v := e2.(type) { + case *ast.Ident: + obj = pass.TypesInfo.Uses[v] + case *ast.SelectorExpr: + obj = pass.TypesInfo.Uses[v.Sel] + default: + return + } + + // Only want functions. + if _, ok := obj.(*types.Func); !ok { + return + } + + pass.Reportf(e.Pos(), "comparison of function %v %v nil is always %v", obj.Name(), e.Op, e.Op == token.NEQ) + }) + return nil, nil +} diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/pkgfact/pkgfact.go b/libgo/go/golang.org/x/tools/go/analysis/passes/pkgfact/pkgfact.go new file mode 100644 index 00000000000..e0530867329 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/pkgfact/pkgfact.go @@ -0,0 +1,127 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// The pkgfact package is a demonstration and test of the package fact +// mechanism. +// +// The output of the pkgfact analysis is a set of key/values pairs +// gathered from the analyzed package and its imported dependencies. +// Each key/value pair comes from a top-level constant declaration +// whose name starts and ends with "_". For example: +// +// package p +// +// const _greeting_ = "hello" +// const _audience_ = "world" +// +// the pkgfact analysis output for package p would be: +// +// {"greeting": "hello", "audience": "world"}. +// +// In addition, the analysis reports a diagnostic at each import +// showing which key/value pairs it contributes. +package pkgfact + +import ( + "fmt" + "go/ast" + "go/token" + "go/types" + "reflect" + "sort" + "strings" + + "golang.org/x/tools/go/analysis" +) + +var Analyzer = &analysis.Analyzer{ + Name: "pkgfact", + Doc: "gather name/value pairs from constant declarations", + Run: run, + FactTypes: []analysis.Fact{new(pairsFact)}, + ResultType: reflect.TypeOf(map[string]string{}), +} + +// A pairsFact is a package-level fact that records +// an set of key=value strings accumulated from constant +// declarations in this package and its dependencies. +// Elements are ordered by keys, which are unique. +type pairsFact []string + +func (f *pairsFact) AFact() {} +func (f *pairsFact) String() string { return "pairs(" + strings.Join(*f, ", ") + ")" } + +func run(pass *analysis.Pass) (interface{}, error) { + result := make(map[string]string) + + // At each import, print the fact from the imported + // package and accumulate its information into the result. + // (Warning: accumulation leads to quadratic growth of work.) + doImport := func(spec *ast.ImportSpec) { + pkg := imported(pass.TypesInfo, spec) + var fact pairsFact + if pass.ImportPackageFact(pkg, &fact) { + for _, pair := range fact { + eq := strings.IndexByte(pair, '=') + result[pair[:eq]] = pair[1+eq:] + } + pass.Reportf(spec.Pos(), "%s", strings.Join(fact, " ")) + } + } + + // At each "const _name_ = value", add a fact into env. + doConst := func(spec *ast.ValueSpec) { + if len(spec.Names) == len(spec.Values) { + for i := range spec.Names { + name := spec.Names[i].Name + if strings.HasPrefix(name, "_") && strings.HasSuffix(name, "_") { + + if key := strings.Trim(name, "_"); key != "" { + value := pass.TypesInfo.Types[spec.Values[i]].Value.String() + result[key] = value + } + } + } + } + } + + for _, f := range pass.Files { + for _, decl := range f.Decls { + if decl, ok := decl.(*ast.GenDecl); ok { + for _, spec := range decl.Specs { + switch decl.Tok { + case token.IMPORT: + doImport(spec.(*ast.ImportSpec)) + case token.CONST: + doConst(spec.(*ast.ValueSpec)) + } + } + } + } + } + + // Sort/deduplicate the result and save it as a package fact. + keys := make([]string, 0, len(result)) + for key := range result { + keys = append(keys, key) + } + sort.Strings(keys) + var fact pairsFact + for _, key := range keys { + fact = append(fact, fmt.Sprintf("%s=%s", key, result[key])) + } + if len(fact) > 0 { + pass.ExportPackageFact(&fact) + } + + return result, nil +} + +func imported(info *types.Info, spec *ast.ImportSpec) *types.Package { + obj, ok := info.Implicits[spec] + if !ok { + obj = info.Defs[spec.Name] // renaming import + } + return obj.(*types.PkgName).Imported() +} diff --git a/libgo/go/cmd/vet/print.go b/libgo/go/golang.org/x/tools/go/analysis/passes/printf/printf.go similarity index 57% rename from libgo/go/cmd/vet/print.go rename to libgo/go/golang.org/x/tools/go/analysis/passes/printf/printf.go index a55da1d3c81..c0265aafeee 100644 --- a/libgo/go/cmd/vet/print.go +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/printf/printf.go @@ -4,12 +4,10 @@ // This file contains the printf-checker. -package main +package printf import ( "bytes" - "encoding/gob" - "flag" "fmt" "go/ast" "go/constant" @@ -20,58 +18,78 @@ import ( "strconv" "strings" "unicode/utf8" -) -var printfuncs = flag.String("printfuncs", "", "comma-separated list of print function names to check") + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/inspect" + "golang.org/x/tools/go/analysis/passes/internal/analysisutil" + "golang.org/x/tools/go/ast/inspector" + "golang.org/x/tools/go/types/typeutil" +) func init() { - register("printf", - "check printf-like invocations", - checkFmtPrintfCall, - funcDecl, callExpr) - registerPkgCheck("printf", findPrintfLike) - registerExport("printf", exportPrintfLike) - gob.Register([]printfExport(nil)) + Analyzer.Flags.Var(isPrint, "funcs", "comma-separated list of print function names to check") } -func initPrintFlags() { - if *printfuncs == "" { - return - } - for _, name := range strings.Split(*printfuncs, ",") { - if len(name) == 0 { - flag.Usage() - } +var Analyzer = &analysis.Analyzer{ + Name: "printf", + Doc: doc, + Requires: []*analysis.Analyzer{inspect.Analyzer}, + Run: run, + FactTypes: []analysis.Fact{new(isWrapper)}, +} - // Backwards compatibility: skip optional first argument - // index after the colon. - if colon := strings.LastIndex(name, ":"); colon > 0 { - name = name[:colon] - } +const doc = `check consistency of Printf format strings and arguments - if !strings.Contains(name, ".") { - name = strings.ToLower(name) - } - isPrint[name] = true +The check applies to known functions (for example, those in package fmt) +as well as any detected wrappers of known functions. + +A function that wants to avail itself of printf checking but is not +found by this analyzer's heuristics (for example, due to use of +dynamic calls) can insert a bogus call: + + if false { + _ = fmt.Sprintf(format, args...) // enable printf checking } -} -var localPrintfLike = make(map[string]int) +The -funcs flag specifies a comma-separated list of names of additional +known formatting functions or methods. If the name contains a period, +it must denote a specific function using one of the following forms: + + dir/pkg.Function + dir/pkg.Type.Method + (*dir/pkg.Type).Method + +Otherwise the name is interpreted as a case-insensitive unqualified +identifier such as "errorf". Either way, if a listed name ends in f, the +function is assumed to be Printf-like, taking a format string before the +argument list. Otherwise it is assumed to be Print-like, taking a list +of arguments with no format string. +` -type printfExport struct { - Name string - Kind int +// isWrapper is a fact indicating that a function is a print or printf wrapper. +type isWrapper struct{ Printf bool } + +func (f *isWrapper) AFact() {} + +func (f *isWrapper) String() string { + if f.Printf { + return "printfWrapper" + } else { + return "printWrapper" + } } -// printfImported maps from package name to the printf vet data -// exported by that package. -var printfImported = make(map[string]map[string]int) +func run(pass *analysis.Pass) (interface{}, error) { + findPrintfLike(pass) + checkCall(pass) + return nil, nil +} type printfWrapper struct { - name string - fn *ast.FuncDecl - format *ast.Field - args *ast.Field + obj *types.Func + fdecl *ast.FuncDecl + format *types.Var + args *types.Var callers []printfCaller failed bool // if true, not a printf wrapper } @@ -88,78 +106,56 @@ type printfCaller struct { // A function may be a Printf or Print wrapper if its last argument is ...interface{}. // If the next-to-last argument is a string, then this may be a Printf wrapper. // Otherwise it may be a Print wrapper. -func maybePrintfWrapper(decl ast.Decl) *printfWrapper { +func maybePrintfWrapper(info *types.Info, decl ast.Decl) *printfWrapper { // Look for functions with final argument type ...interface{}. - fn, ok := decl.(*ast.FuncDecl) - if !ok || fn.Body == nil { - return nil - } - name := fn.Name.Name - if fn.Recv != nil { - // For (*T).Name or T.name, use "T.name". - rcvr := fn.Recv.List[0].Type - if ptr, ok := rcvr.(*ast.StarExpr); ok { - rcvr = ptr.X - } - id, ok := rcvr.(*ast.Ident) - if !ok { - return nil - } - name = id.Name + "." + name - } - params := fn.Type.Params.List - if len(params) == 0 { - return nil - } - args := params[len(params)-1] - if len(args.Names) != 1 { + fdecl, ok := decl.(*ast.FuncDecl) + if !ok || fdecl.Body == nil { return nil } - ddd, ok := args.Type.(*ast.Ellipsis) - if !ok { - return nil + fn := info.Defs[fdecl.Name].(*types.Func) + + sig := fn.Type().(*types.Signature) + if !sig.Variadic() { + return nil // not variadic } - iface, ok := ddd.Elt.(*ast.InterfaceType) - if !ok || len(iface.Methods.List) > 0 { - return nil + + params := sig.Params() + nparams := params.Len() // variadic => nonzero + + args := params.At(nparams - 1) + iface, ok := args.Type().(*types.Slice).Elem().(*types.Interface) + if !ok || !iface.Empty() { + return nil // final (args) param is not ...interface{} } - var format *ast.Field - if len(params) >= 2 { - p := params[len(params)-2] - if len(p.Names) == 1 { - if id, ok := p.Type.(*ast.Ident); ok && id.Name == "string" { - format = p - } + + // Is second last param 'format string'? + var format *types.Var + if nparams >= 2 { + if p := params.At(nparams - 2); p.Type() == types.Typ[types.String] { + format = p } } return &printfWrapper{ - name: name, - fn: fn, + obj: fn, + fdecl: fdecl, format: format, args: args, } } // findPrintfLike scans the entire package to find printf-like functions. -func findPrintfLike(pkg *Package) { - if vcfg.ImportPath == "" { // no type or vetx information; don't bother - return - } - - // Gather potential wrappesr and call graph between them. - byName := make(map[string]*printfWrapper) +func findPrintfLike(pass *analysis.Pass) (interface{}, error) { + // Gather potential wrappers and call graph between them. + byObj := make(map[*types.Func]*printfWrapper) var wrappers []*printfWrapper - for _, file := range pkg.files { - if file.file == nil { - continue - } - for _, decl := range file.file.Decls { - w := maybePrintfWrapper(decl) + for _, file := range pass.Files { + for _, decl := range file.Decls { + w := maybePrintfWrapper(pass.TypesInfo, decl) if w == nil { continue } - byName[w.name] = w + byObj[w.obj] = w wrappers = append(wrappers, w) } } @@ -167,7 +163,7 @@ func findPrintfLike(pkg *Package) { // Walk the graph to figure out which are really printf wrappers. for _, w := range wrappers { // Scan function for calls that could be to other printf-like functions. - ast.Inspect(w.fn.Body, func(n ast.Node) bool { + ast.Inspect(w.fdecl.Body, func(n ast.Node) bool { if w.failed { return false } @@ -175,7 +171,8 @@ func findPrintfLike(pkg *Package) { // TODO: Relax these checks; issue 26555. if assign, ok := n.(*ast.AssignStmt); ok { for _, lhs := range assign.Lhs { - if match(lhs, w.format) || match(lhs, w.args) { + if match(pass.TypesInfo, lhs, w.format) || + match(pass.TypesInfo, lhs, w.args) { // Modifies the format // string or args in // some way, so not a @@ -186,7 +183,8 @@ func findPrintfLike(pkg *Package) { } } if un, ok := n.(*ast.UnaryExpr); ok && un.Op == token.AND { - if match(un.X, w.format) || match(un.X, w.args) { + if match(pass.TypesInfo, un.X, w.format) || + match(pass.TypesInfo, un.X, w.args) { // Taking the address of the // format string or args, // so not a simple wrapper. @@ -196,32 +194,33 @@ func findPrintfLike(pkg *Package) { } call, ok := n.(*ast.CallExpr) - if !ok || len(call.Args) == 0 || !match(call.Args[len(call.Args)-1], w.args) { + if !ok || len(call.Args) == 0 || !match(pass.TypesInfo, call.Args[len(call.Args)-1], w.args) { return true } - pkgpath, name, kind := printfNameAndKind(pkg, call.Fun) + fn, kind := printfNameAndKind(pass, call) if kind != 0 { - checkPrintfFwd(pkg, w, call, kind) + checkPrintfFwd(pass, w, call, kind) return true } // If the call is to another function in this package, // maybe we will find out it is printf-like later. // Remember this call for later checking. - if pkgpath == "" && byName[name] != nil { - callee := byName[name] + if fn != nil && fn.Pkg() == pass.Pkg && byObj[fn] != nil { + callee := byObj[fn] callee.callers = append(callee.callers, printfCaller{w, call}) } return true }) } + return nil, nil } -func match(arg ast.Expr, param *ast.Field) bool { +func match(info *types.Info, arg ast.Expr, param *types.Var) bool { id, ok := arg.(*ast.Ident) - return ok && id.Obj != nil && id.Obj.Decl == param + return ok && info.ObjectOf(id) == param } const ( @@ -229,37 +228,17 @@ const ( kindPrint = 2 ) -// printfLike reports whether a call to fn should be considered a call to a printf-like function. -// It returns 0 (indicating not a printf-like function), kindPrintf, or kindPrint. -func printfLike(pkg *Package, fn ast.Expr, byName map[string]*printfWrapper) int { - if id, ok := fn.(*ast.Ident); ok && id.Obj != nil { - if w := byName[id.Name]; w != nil && id.Obj.Decl == w.fn { - // Found call to function in same package. - return localPrintfLike[id.Name] - } - } - if sel, ok := fn.(*ast.SelectorExpr); ok { - if id, ok := sel.X.(*ast.Ident); ok && id.Name == "fmt" && strings.Contains(sel.Sel.Name, "rint") { - if strings.HasSuffix(sel.Sel.Name, "f") { - return kindPrintf - } - return kindPrint - } - } - return 0 -} - // checkPrintfFwd checks that a printf-forwarding wrapper is forwarding correctly. // It diagnoses writing fmt.Printf(format, args) instead of fmt.Printf(format, args...). -func checkPrintfFwd(pkg *Package, w *printfWrapper, call *ast.CallExpr, kind int) { +func checkPrintfFwd(pass *analysis.Pass, w *printfWrapper, call *ast.CallExpr, kind int) { matched := kind == kindPrint || - kind == kindPrintf && len(call.Args) >= 2 && match(call.Args[len(call.Args)-2], w.format) + kind == kindPrintf && len(call.Args) >= 2 && match(pass.TypesInfo, call.Args[len(call.Args)-2], w.format) if !matched { return } if !call.Ellipsis.IsValid() { - typ, ok := pkg.types[call.Fun].Type.(*types.Signature) + typ, ok := pass.TypesInfo.Types[call.Fun].Type.(*types.Signature) if !ok { return } @@ -273,41 +252,41 @@ func checkPrintfFwd(pkg *Package, w *printfWrapper, call *ast.CallExpr, kind int // } return } - if !vcfg.VetxOnly { - desc := "printf" - if kind == kindPrint { - desc = "print" - } - pkg.files[0].Badf(call.Pos(), "missing ... in args forwarded to %s-like function", desc) + desc := "printf" + if kind == kindPrint { + desc = "print" } + pass.Reportf(call.Pos(), "missing ... in args forwarded to %s-like function", desc) return } - name := w.name - if localPrintfLike[name] == 0 { - localPrintfLike[name] = kind + fn := w.obj + var fact isWrapper + if !pass.ImportObjectFact(fn, &fact) { + fact.Printf = kind == kindPrintf + pass.ExportObjectFact(fn, &fact) for _, caller := range w.callers { - checkPrintfFwd(pkg, caller.w, caller.call, kind) + checkPrintfFwd(pass, caller.w, caller.call, kind) } } } -func exportPrintfLike() interface{} { - out := make([]printfExport, 0, len(localPrintfLike)) - for name, kind := range localPrintfLike { - out = append(out, printfExport{ - Name: name, - Kind: kind, - }) - } - sort.Slice(out, func(i, j int) bool { - return out[i].Name < out[j].Name - }) - return out -} - // isPrint records the print functions. // If a key ends in 'f' then it is assumed to be a formatted print. -var isPrint = map[string]bool{ +// +// Keys are either values returned by (*types.Func).FullName, +// or case-insensitive identifiers such as "errorf". +// +// The -funcs flag adds to this set. +// +// The set below includes facts for many important standard library +// functions, even though the analysis is capable of deducing that, for +// example, fmt.Printf forwards to fmt.Fprintf. We avoid relying on the +// driver applying analyzers to standard packages because "go vet" does +// not do so with gccgo, and nor do some other build systems. +// TODO(adonovan): eliminate the redundant facts once this restriction +// is lifted. +// +var isPrint = stringSet{ "fmt.Errorf": true, "fmt.Fprint": true, "fmt.Fprintf": true, @@ -319,34 +298,45 @@ var isPrint = map[string]bool{ "fmt.Sprintf": true, "fmt.Sprintln": true, - // testing.B, testing.T not auto-detected - // because the methods are picked up by embedding. - "testing.B.Error": true, - "testing.B.Errorf": true, - "testing.B.Fatal": true, - "testing.B.Fatalf": true, - "testing.B.Log": true, - "testing.B.Logf": true, - "testing.B.Skip": true, - "testing.B.Skipf": true, - "testing.T.Error": true, - "testing.T.Errorf": true, - "testing.T.Fatal": true, - "testing.T.Fatalf": true, - "testing.T.Log": true, - "testing.T.Logf": true, - "testing.T.Skip": true, - "testing.T.Skipf": true, - - // testing.TB is an interface, so can't detect wrapping. - "testing.TB.Error": true, - "testing.TB.Errorf": true, - "testing.TB.Fatal": true, - "testing.TB.Fatalf": true, - "testing.TB.Log": true, - "testing.TB.Logf": true, - "testing.TB.Skip": true, - "testing.TB.Skipf": true, + "runtime/trace.Logf": true, + + "log.Print": true, + "log.Printf": true, + "log.Println": true, + "log.Fatal": true, + "log.Fatalf": true, + "log.Fatalln": true, + "log.Panic": true, + "log.Panicf": true, + "log.Panicln": true, + "(*log.Logger).Fatal": true, + "(*log.Logger).Fatalf": true, + "(*log.Logger).Fatalln": true, + "(*log.Logger).Panic": true, + "(*log.Logger).Panicf": true, + "(*log.Logger).Panicln": true, + "(*log.Logger).Print": true, + "(*log.Logger).Printf": true, + "(*log.Logger).Println": true, + + "(*testing.common).Error": true, + "(*testing.common).Errorf": true, + "(*testing.common).Fatal": true, + "(*testing.common).Fatalf": true, + "(*testing.common).Log": true, + "(*testing.common).Logf": true, + "(*testing.common).Skip": true, + "(*testing.common).Skipf": true, + // *testing.T and B are detected by induction, but testing.TB is + // an interface and the inference can't follow dynamic calls. + "(testing.TB).Error": true, + "(testing.TB).Errorf": true, + "(testing.TB).Fatal": true, + "(testing.TB).Fatalf": true, + "(testing.TB).Log": true, + "(testing.TB).Logf": true, + "(testing.TB).Skip": true, + "(testing.TB).Skipf": true, } // formatString returns the format string argument and its index within @@ -359,8 +349,8 @@ var isPrint = map[string]bool{ // if the call's signature cannot be determined. // // If it cannot find any format string parameter, it returns ("", -1). -func formatString(f *File, call *ast.CallExpr) (format string, idx int) { - typ := f.pkg.types[call.Fun].Type +func formatString(pass *analysis.Pass, call *ast.CallExpr) (format string, idx int) { + typ := pass.TypesInfo.Types[call.Fun].Type if typ != nil { if sig, ok := typ.(*types.Signature); ok { if !sig.Variadic() { @@ -373,7 +363,7 @@ func formatString(f *File, call *ast.CallExpr) (format string, idx int) { // fixed arguments. return "", -1 } - s, ok := stringConstantArg(f, call, idx) + s, ok := stringConstantArg(pass, call, idx) if !ok { // The last argument before variadic args isn't a string. return "", -1 @@ -385,10 +375,10 @@ func formatString(f *File, call *ast.CallExpr) (format string, idx int) { // Cannot determine call's signature. Fall back to scanning for the first // string constant in the call. for idx := range call.Args { - if s, ok := stringConstantArg(f, call, idx); ok { + if s, ok := stringConstantArg(pass, call, idx); ok { return s, idx } - if f.pkg.types[call.Args[idx]].Type == types.Typ[types.String] { + if pass.TypesInfo.Types[call.Args[idx]].Type == types.Typ[types.String] { // Skip checking a call with a non-constant format // string argument, since its contents are unavailable // for validation. @@ -402,12 +392,12 @@ func formatString(f *File, call *ast.CallExpr) (format string, idx int) { // // ("", false) is returned if call's argument at the index idx isn't a string // constant. -func stringConstantArg(f *File, call *ast.CallExpr, idx int) (string, bool) { +func stringConstantArg(pass *analysis.Pass, call *ast.CallExpr, idx int) (string, bool) { if idx >= len(call.Args) { return "", false } arg := call.Args[idx] - lit := f.pkg.types[arg].Value + lit := pass.TypesInfo.Types[arg].Value if lit != nil && lit.Kind() == constant.String { return constant.StringVal(lit), true } @@ -415,134 +405,63 @@ func stringConstantArg(f *File, call *ast.CallExpr, idx int) (string, bool) { } // checkCall triggers the print-specific checks if the call invokes a print function. -func checkFmtPrintfCall(f *File, node ast.Node) { - if f.pkg.typesPkg == nil { - // This check now requires type information. - return - } - - if d, ok := node.(*ast.FuncDecl); ok && isStringer(f, d) { - // Remember we saw this. - if f.stringerPtrs == nil { - f.stringerPtrs = make(map[*ast.Object]bool) - } - if l := d.Recv.List; len(l) == 1 { - if n := l[0].Names; len(n) == 1 { - typ := f.pkg.types[l[0].Type] - _, ptrRecv := typ.Type.(*types.Pointer) - f.stringerPtrs[n[0].Obj] = ptrRecv - } +func checkCall(pass *analysis.Pass) { + inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) + nodeFilter := []ast.Node{ + (*ast.CallExpr)(nil), + } + inspect.Preorder(nodeFilter, func(n ast.Node) { + call := n.(*ast.CallExpr) + fn, kind := printfNameAndKind(pass, call) + switch kind { + case kindPrintf: + checkPrintf(pass, call, fn) + case kindPrint: + checkPrint(pass, call, fn) } - return - } - - call, ok := node.(*ast.CallExpr) - if !ok { - return - } - - // Construct name like pkg.Printf or pkg.Type.Printf for lookup. - _, name, kind := printfNameAndKind(f.pkg, call.Fun) - if kind == kindPrintf { - f.checkPrintf(call, name) - } - if kind == kindPrint { - f.checkPrint(call, name) - } -} - -func printfName(pkg *Package, called ast.Expr) (pkgpath, name string) { - switch x := called.(type) { - case *ast.Ident: - if fn, ok := pkg.uses[x].(*types.Func); ok { - if fn.Pkg() == nil || fn.Pkg() == pkg.typesPkg { - pkgpath = "" - } else { - pkgpath = fn.Pkg().Path() - } - return pkgpath, x.Name - } - - case *ast.SelectorExpr: - // Check for "fmt.Printf". - if id, ok := x.X.(*ast.Ident); ok { - if pkgName, ok := pkg.uses[id].(*types.PkgName); ok { - return pkgName.Imported().Path(), x.Sel.Name - } - } - - // Check for t.Logf where t is a *testing.T. - if sel := pkg.selectors[x]; sel != nil { - recv := sel.Recv() - if p, ok := recv.(*types.Pointer); ok { - recv = p.Elem() - } - if named, ok := recv.(*types.Named); ok { - obj := named.Obj() - if obj.Pkg() == nil || obj.Pkg() == pkg.typesPkg { - pkgpath = "" - } else { - pkgpath = obj.Pkg().Path() - } - return pkgpath, obj.Name() + "." + x.Sel.Name - } - } - } - return "", "" + }) } -func printfNameAndKind(pkg *Package, called ast.Expr) (pkgpath, name string, kind int) { - pkgpath, name = printfName(pkg, called) - if name == "" { - return pkgpath, name, 0 +func printfNameAndKind(pass *analysis.Pass, call *ast.CallExpr) (fn *types.Func, kind int) { + fn, _ = typeutil.Callee(pass.TypesInfo, call).(*types.Func) + if fn == nil { + return nil, 0 } - if pkgpath == "" { - kind = localPrintfLike[name] - } else if m, ok := printfImported[pkgpath]; ok { - kind = m[name] - } else { - var m map[string]int - if out, ok := readVetx(pkgpath, "printf").([]printfExport); ok { - m = make(map[string]int) - for _, x := range out { - m[x.Name] = x.Kind - } + var fact isWrapper + if pass.ImportObjectFact(fn, &fact) { + if fact.Printf { + return fn, kindPrintf + } else { + return fn, kindPrint } - printfImported[pkgpath] = m - kind = m[name] } - if kind == 0 { - _, ok := isPrint[pkgpath+"."+name] - if !ok { - // Next look up just "printf", for use with -printfuncs. - short := name[strings.LastIndex(name, ".")+1:] - _, ok = isPrint[strings.ToLower(short)] - } - if ok { - if strings.HasSuffix(name, "f") { - kind = kindPrintf - } else { - kind = kindPrint - } + _, ok := isPrint[fn.FullName()] + if !ok { + // Next look up just "printf", for use with -printf.funcs. + _, ok = isPrint[strings.ToLower(fn.Name())] + } + if ok { + if strings.HasSuffix(fn.Name(), "f") { + kind = kindPrintf + } else { + kind = kindPrint } } - return pkgpath, name, kind -} - -// isStringer returns true if the provided declaration is a "String() string" -// method, an implementation of fmt.Stringer. -func isStringer(f *File, d *ast.FuncDecl) bool { - return d.Recv != nil && d.Name.Name == "String" && d.Type.Results != nil && - len(d.Type.Params.List) == 0 && len(d.Type.Results.List) == 1 && - f.pkg.types[d.Type.Results.List[0].Type].Type == types.Typ[types.String] + return fn, kind } // isFormatter reports whether t satisfies fmt.Formatter. // Unlike fmt.Stringer, it's impossible to satisfy fmt.Formatter without importing fmt. -func (f *File) isFormatter(t types.Type) bool { - return formatterType != nil && types.Implements(t, formatterType) +func isFormatter(pass *analysis.Pass, t types.Type) bool { + for _, imp := range pass.Pkg.Imports() { + if imp.Path() == "fmt" { + formatter := imp.Scope().Lookup("Formatter").Type().Underlying().(*types.Interface) + return types.Implements(t, formatter) + } + } + return false } // formatState holds the parsed representation of a printf directive such as "%3.*[4]d". @@ -555,7 +474,7 @@ type formatState struct { argNums []int // the successive argument numbers that are consumed, adjusted to refer to actual arg in call firstArg int // Index of first argument after the format in the Printf call. // Used only during parse. - file *File + pass *analysis.Pass call *ast.CallExpr argNum int // Which argument we're expecting to format now. hasIndex bool // Whether the argument is indexed. @@ -564,11 +483,11 @@ type formatState struct { } // checkPrintf checks a call to a formatted print routine such as Printf. -func (f *File) checkPrintf(call *ast.CallExpr, name string) { - format, idx := formatString(f, call) +func checkPrintf(pass *analysis.Pass, call *ast.CallExpr, fn *types.Func) { + format, idx := formatString(pass, call) if idx < 0 { - if *verbose { - f.Warn(call.Pos(), "can't check non-constant format in call to", name) + if false { + pass.Reportf(call.Lparen, "can't check non-constant format in call to %s", fn.Name()) } return } @@ -576,7 +495,7 @@ func (f *File) checkPrintf(call *ast.CallExpr, name string) { firstArg := idx + 1 // Arguments are immediately after format string. if !strings.Contains(format, "%") { if len(call.Args) > firstArg { - f.Badf(call.Pos(), "%s call has arguments but no formatting directives", name) + pass.Reportf(call.Lparen, "%s call has arguments but no formatting directives", fn.Name()) } return } @@ -589,12 +508,12 @@ func (f *File) checkPrintf(call *ast.CallExpr, name string) { if format[i] != '%' { continue } - state := f.parsePrintfVerb(call, name, format[i:], firstArg, argNum) + state := parsePrintfVerb(pass, call, fn.Name(), format[i:], firstArg, argNum) if state == nil { return } w = len(state.format) - if !f.okPrintfArg(call, state) { // One error per format is enough. + if !okPrintfArg(pass, call, state) { // One error per format is enough. return } if state.hasIndex { @@ -622,7 +541,7 @@ func (f *File) checkPrintf(call *ast.CallExpr, name string) { if maxArgNum != len(call.Args) { expect := maxArgNum - firstArg numArgs := len(call.Args) - firstArg - f.Badf(call.Pos(), "%s call needs %v but has %v", name, count(expect, "arg"), count(numArgs, "arg")) + pass.Reportf(call.Pos(), "%s call needs %v but has %v", fn.Name(), count(expect, "arg"), count(numArgs, "arg")) } } @@ -663,13 +582,13 @@ func (s *formatState) parseIndex() bool { ok = false s.nbytes = strings.Index(s.format, "]") if s.nbytes < 0 { - s.file.Badf(s.call.Pos(), "%s format %s is missing closing ]", s.name, s.format) + s.pass.Reportf(s.call.Pos(), "%s format %s is missing closing ]", s.name, s.format) return false } } arg32, err := strconv.ParseInt(s.format[start:s.nbytes], 10, 32) if err != nil || !ok || arg32 <= 0 || arg32 > int64(len(s.call.Args)-s.firstArg) { - s.file.Badf(s.call.Pos(), "%s format has invalid argument index [%s]", s.name, s.format[start:s.nbytes]) + s.pass.Reportf(s.call.Pos(), "%s format has invalid argument index [%s]", s.name, s.format[start:s.nbytes]) return false } s.nbytes++ // skip ']' @@ -715,7 +634,7 @@ func (s *formatState) parsePrecision() bool { // parsePrintfVerb looks the formatting directive that begins the format string // and returns a formatState that encodes what the directive wants, without looking // at the actual arguments present in the call. The result is nil if there is an error. -func (f *File) parsePrintfVerb(call *ast.CallExpr, name, format string, firstArg, argNum int) *formatState { +func parsePrintfVerb(pass *analysis.Pass, call *ast.CallExpr, name, format string, firstArg, argNum int) *formatState { state := &formatState{ format: format, name: name, @@ -724,7 +643,7 @@ func (f *File) parsePrintfVerb(call *ast.CallExpr, name, format string, firstArg argNums: make([]int, 0, 1), nbytes: 1, // There's guaranteed to be a percent sign. firstArg: firstArg, - file: f, + pass: pass, call: call, } // There may be flags. @@ -746,7 +665,7 @@ func (f *File) parsePrintfVerb(call *ast.CallExpr, name, format string, firstArg return nil } if state.nbytes == len(state.format) { - f.Badf(call.Pos(), "%s format %s is missing verb at end of string", name, state.format) + pass.Reportf(call.Pos(), "%s format %s is missing verb at end of string", name, state.format) return nil } verb, w := utf8.DecodeRuneInString(state.format[state.nbytes:]) @@ -795,7 +714,7 @@ var printVerbs = []printVerb{ // '#' is alternate format for several verbs. // ' ' is spacer for numbers {'%', noFlag, 0}, - {'b', numFlag, argInt | argFloat | argComplex}, + {'b', numFlag, argInt | argFloat | argComplex | argPointer}, {'c', "-", argRune | argInt}, {'d', numFlag, argInt | argPointer}, {'e', sharpNumFlag, argFloat | argComplex}, @@ -804,7 +723,7 @@ var printVerbs = []printVerb{ {'F', sharpNumFlag, argFloat | argComplex}, {'g', sharpNumFlag, argFloat | argComplex}, {'G', sharpNumFlag, argFloat | argComplex}, - {'o', sharpNumFlag, argInt}, + {'o', sharpNumFlag, argInt | argPointer}, {'p', "-#", argPointer}, {'q', " -+.0#", argRune | argInt | argString}, {'s', " -+.0", argString}, @@ -819,7 +738,7 @@ var printVerbs = []printVerb{ // okPrintfArg compares the formatState to the arguments actually present, // reporting any discrepancies it can discern. If the final argument is ellipsissed, // there's little it can do for that. -func (f *File) okPrintfArg(call *ast.CallExpr, state *formatState) (ok bool) { +func okPrintfArg(pass *analysis.Pass, call *ast.CallExpr, state *formatState) (ok bool) { var v printVerb found := false // Linear scan is fast enough for a small list. @@ -833,14 +752,14 @@ func (f *File) okPrintfArg(call *ast.CallExpr, state *formatState) (ok bool) { // Does current arg implement fmt.Formatter? formatter := false if state.argNum < len(call.Args) { - if tv, ok := f.pkg.types[call.Args[state.argNum]]; ok { - formatter = f.isFormatter(tv.Type) + if tv, ok := pass.TypesInfo.Types[call.Args[state.argNum]]; ok { + formatter = isFormatter(pass, tv.Type) } } if !formatter { if !found { - f.Badf(call.Pos(), "%s format %s has unknown verb %c", state.name, state.format, state.verb) + pass.Reportf(call.Pos(), "%s format %s has unknown verb %c", state.name, state.format, state.verb) return false } for _, flag := range state.flags { @@ -850,7 +769,7 @@ func (f *File) okPrintfArg(call *ast.CallExpr, state *formatState) (ok bool) { continue } if !strings.ContainsRune(v.flags, rune(flag)) { - f.Badf(call.Pos(), "%s format %s has unrecognized flag %c", state.name, state.format, flag) + pass.Reportf(call.Pos(), "%s format %s has unrecognized flag %c", state.name, state.format, flag) return false } } @@ -864,86 +783,88 @@ func (f *File) okPrintfArg(call *ast.CallExpr, state *formatState) (ok bool) { nargs := len(state.argNums) for i := 0; i < nargs-trueArgs; i++ { argNum := state.argNums[i] - if !f.argCanBeChecked(call, i, state) { + if !argCanBeChecked(pass, call, i, state) { return } arg := call.Args[argNum] - if !f.matchArgType(argInt, nil, arg) { - f.Badf(call.Pos(), "%s format %s uses non-int %s as argument of *", state.name, state.format, f.gofmt(arg)) + if !matchArgType(pass, argInt, nil, arg) { + pass.Reportf(call.Pos(), "%s format %s uses non-int %s as argument of *", state.name, state.format, analysisutil.Format(pass.Fset, arg)) return false } } + if state.verb == '%' || formatter { return true } argNum := state.argNums[len(state.argNums)-1] - if !f.argCanBeChecked(call, len(state.argNums)-1, state) { + if !argCanBeChecked(pass, call, len(state.argNums)-1, state) { return false } arg := call.Args[argNum] - if f.isFunctionValue(arg) && state.verb != 'p' && state.verb != 'T' { - f.Badf(call.Pos(), "%s format %s arg %s is a func value, not called", state.name, state.format, f.gofmt(arg)) + if isFunctionValue(pass, arg) && state.verb != 'p' && state.verb != 'T' { + pass.Reportf(call.Pos(), "%s format %s arg %s is a func value, not called", state.name, state.format, analysisutil.Format(pass.Fset, arg)) return false } - if !f.matchArgType(v.typ, nil, arg) { + if !matchArgType(pass, v.typ, nil, arg) { typeString := "" - if typ := f.pkg.types[arg].Type; typ != nil { + if typ := pass.TypesInfo.Types[arg].Type; typ != nil { typeString = typ.String() } - f.Badf(call.Pos(), "%s format %s has arg %s of wrong type %s", state.name, state.format, f.gofmt(arg), typeString) + pass.Reportf(call.Pos(), "%s format %s has arg %s of wrong type %s", state.name, state.format, analysisutil.Format(pass.Fset, arg), typeString) return false } - if v.typ&argString != 0 && v.verb != 'T' && !bytes.Contains(state.flags, []byte{'#'}) && f.recursiveStringer(arg) { - f.Badf(call.Pos(), "%s format %s with arg %s causes recursive String method call", state.name, state.format, f.gofmt(arg)) + if v.typ&argString != 0 && v.verb != 'T' && !bytes.Contains(state.flags, []byte{'#'}) && recursiveStringer(pass, arg) { + pass.Reportf(call.Pos(), "%s format %s with arg %s causes recursive String method call", state.name, state.format, analysisutil.Format(pass.Fset, arg)) return false } return true } -// recursiveStringer reports whether the provided argument is r or &r for the -// fmt.Stringer receiver identifier r. -func (f *File) recursiveStringer(e ast.Expr) bool { - if len(f.stringerPtrs) == 0 { +// recursiveStringer reports whether the argument e is a potential +// recursive call to stringer, such as t and &t in these examples: +// +// func (t *T) String() string { printf("%s", t) } +// func (t T) String() string { printf("%s", t) } +// func (t T) String() string { printf("%s", &t) } +// +func recursiveStringer(pass *analysis.Pass, e ast.Expr) bool { + typ := pass.TypesInfo.Types[e].Type + + // It's unlikely to be a recursive stringer if it has a Format method. + if isFormatter(pass, typ) { return false } - ptr := false - var obj *ast.Object - switch e := e.(type) { - case *ast.Ident: - obj = e.Obj - case *ast.UnaryExpr: - if id, ok := e.X.(*ast.Ident); ok && e.Op == token.AND { - obj = id.Obj - ptr = true - } - } - // It's unlikely to be a recursive stringer if it has a Format method. - if typ := f.pkg.types[e].Type; typ != nil { - if f.isFormatter(typ) { - return false - } + // Does e allow e.String()? + obj, _, _ := types.LookupFieldOrMethod(typ, false, pass.Pkg, "String") + stringMethod, ok := obj.(*types.Func) + if !ok { + return false } - // We compare the underlying Object, which checks that the identifier - // is the one we declared as the receiver for the String method in - // which this printf appears. - ptrRecv, exist := f.stringerPtrs[obj] - if !exist { + // Is the expression e within the body of that String method? + if stringMethod.Pkg() != pass.Pkg || !stringMethod.Scope().Contains(e.Pos()) { return false } - // We also need to check that using &t when we declared String - // on (t *T) is ok; in such a case, the address is printed. - if ptr && ptrRecv { + + // Is it the receiver r, or &r? + recv := stringMethod.Type().(*types.Signature).Recv() + if recv == nil { return false } - return true + if u, ok := e.(*ast.UnaryExpr); ok && u.Op == token.AND { + e = u.X // strip off & from &r + } + if id, ok := e.(*ast.Ident); ok { + return pass.TypesInfo.Uses[id] == recv + } + return false } // isFunctionValue reports whether the expression is a function as opposed to a function call. // It is almost always a mistake to print a function value. -func (f *File) isFunctionValue(e ast.Expr) bool { - if typ := f.pkg.types[e].Type; typ != nil { +func isFunctionValue(pass *analysis.Pass, e ast.Expr) bool { + if typ := pass.TypesInfo.Types[e].Type; typ != nil { _, ok := typ.(*types.Signature) return ok } @@ -953,7 +874,7 @@ func (f *File) isFunctionValue(e ast.Expr) bool { // argCanBeChecked reports whether the specified argument is statically present; // it may be beyond the list of arguments or in a terminal slice... argument, which // means we can't see it. -func (f *File) argCanBeChecked(call *ast.CallExpr, formatArg int, state *formatState) bool { +func argCanBeChecked(pass *analysis.Pass, call *ast.CallExpr, formatArg int, state *formatState) bool { argNum := state.argNums[formatArg] if argNum <= 0 { // Shouldn't happen, so catch it with prejudice. @@ -971,7 +892,7 @@ func (f *File) argCanBeChecked(call *ast.CallExpr, formatArg int, state *formatS // There are bad indexes in the format or there are fewer arguments than the format needs. // This is the argument number relative to the format: Printf("%s", "hi") will give 1 for the "hi". arg := argNum - state.firstArg + 1 // People think of arguments as 1-indexed. - f.Badf(call.Pos(), "%s format %s reads arg #%d, but call has %v", state.name, state.format, arg, count(len(call.Args)-state.firstArg, "arg")) + pass.Reportf(call.Pos(), "%s format %s reads arg #%d, but call has %v", state.name, state.format, arg, count(len(call.Args)-state.firstArg, "arg")) return false } @@ -988,9 +909,9 @@ const ( ) // checkPrint checks a call to an unformatted print routine such as Println. -func (f *File) checkPrint(call *ast.CallExpr, name string) { +func checkPrint(pass *analysis.Pass, call *ast.CallExpr, fn *types.Func) { firstArg := 0 - typ := f.pkg.types[call.Fun].Type + typ := pass.TypesInfo.Types[call.Fun].Type if typ == nil { // Skip checking functions with unknown type. return @@ -1022,7 +943,7 @@ func (f *File) checkPrint(call *ast.CallExpr, name string) { if sel, ok := call.Args[0].(*ast.SelectorExpr); ok { if x, ok := sel.X.(*ast.Ident); ok { if x.Name == "os" && strings.HasPrefix(sel.Sel.Name, "Std") { - f.Badf(call.Pos(), "%s does not take io.Writer but has first arg %s", name, f.gofmt(call.Args[0])) + pass.Reportf(call.Pos(), "%s does not take io.Writer but has first arg %s", fn.Name(), analysisutil.Format(pass.Fset, call.Args[0])) } } } @@ -1036,26 +957,26 @@ func (f *File) checkPrint(call *ast.CallExpr, name string) { if strings.Contains(s, "%") { m := printFormatRE.FindStringSubmatch(s) if m != nil { - f.Badf(call.Pos(), "%s call has possible formatting directive %s", name, m[0]) + pass.Reportf(call.Pos(), "%s call has possible formatting directive %s", fn.Name(), m[0]) } } } - if strings.HasSuffix(name, "ln") { + if strings.HasSuffix(fn.Name(), "ln") { // The last item, if a string, should not have a newline. arg = args[len(args)-1] if lit, ok := arg.(*ast.BasicLit); ok && lit.Kind == token.STRING { str, _ := strconv.Unquote(lit.Value) if strings.HasSuffix(str, "\n") { - f.Badf(call.Pos(), "%s arg list ends with redundant newline", name) + pass.Reportf(call.Pos(), "%s arg list ends with redundant newline", fn.Name()) } } } for _, arg := range args { - if f.isFunctionValue(arg) { - f.Badf(call.Pos(), "%s arg %s is a func value, not called", name, f.gofmt(arg)) + if isFunctionValue(pass, arg) { + pass.Reportf(call.Pos(), "%s arg %s is a func value, not called", fn.Name(), analysisutil.Format(pass.Fset, arg)) } - if f.recursiveStringer(arg) { - f.Badf(call.Pos(), "%s arg %s causes recursive call to String method", name, f.gofmt(arg)) + if recursiveStringer(pass, arg) { + pass.Reportf(call.Pos(), "%s arg %s causes recursive call to String method", fn.Name(), analysisutil.Format(pass.Fset, arg)) } } } @@ -1068,3 +989,29 @@ func count(n int, what string) string { } return fmt.Sprintf("%d %ss", n, what) } + +// stringSet is a set-of-nonempty-strings-valued flag. +// Note: elements without a '.' get lower-cased. +type stringSet map[string]bool + +func (ss stringSet) String() string { + var list []string + for name := range ss { + list = append(list, name) + } + sort.Strings(list) + return strings.Join(list, ",") +} + +func (ss stringSet) Set(flag string) error { + for _, name := range strings.Split(flag, ",") { + if len(name) == 0 { + return fmt.Errorf("empty string") + } + if !strings.Contains(name, ".") { + name = strings.ToLower(name) + } + ss[name] = true + } + return nil +} diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/printf/types.go b/libgo/go/golang.org/x/tools/go/analysis/passes/printf/types.go new file mode 100644 index 00000000000..e8810464cd4 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/printf/types.go @@ -0,0 +1,239 @@ +package printf + +import ( + "go/ast" + "go/build" + "go/types" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/internal/analysisutil" +) + +var errorType = types.Universe.Lookup("error").Type().Underlying().(*types.Interface) + +// matchArgType reports an error if printf verb t is not appropriate +// for operand arg. +// +// typ is used only for recursive calls; external callers must supply nil. +// +// (Recursion arises from the compound types {map,chan,slice} which +// may be printed with %d etc. if that is appropriate for their element +// types.) +func matchArgType(pass *analysis.Pass, t printfArgType, typ types.Type, arg ast.Expr) bool { + return matchArgTypeInternal(pass, t, typ, arg, make(map[types.Type]bool)) +} + +// matchArgTypeInternal is the internal version of matchArgType. It carries a map +// remembering what types are in progress so we don't recur when faced with recursive +// types or mutually recursive types. +func matchArgTypeInternal(pass *analysis.Pass, t printfArgType, typ types.Type, arg ast.Expr, inProgress map[types.Type]bool) bool { + // %v, %T accept any argument type. + if t == anyType { + return true + } + if typ == nil { + // external call + typ = pass.TypesInfo.Types[arg].Type + if typ == nil { + return true // probably a type check problem + } + } + // If the type implements fmt.Formatter, we have nothing to check. + if isFormatter(pass, typ) { + return true + } + // If we can use a string, might arg (dynamically) implement the Stringer or Error interface? + if t&argString != 0 && isConvertibleToString(pass, typ) { + return true + } + + typ = typ.Underlying() + if inProgress[typ] { + // We're already looking at this type. The call that started it will take care of it. + return true + } + inProgress[typ] = true + + switch typ := typ.(type) { + case *types.Signature: + return t == argPointer + + case *types.Map: + return t == argPointer || + // Recur: map[int]int matches %d. + (matchArgTypeInternal(pass, t, typ.Key(), arg, inProgress) && matchArgTypeInternal(pass, t, typ.Elem(), arg, inProgress)) + + case *types.Chan: + return t&argPointer != 0 + + case *types.Array: + // Same as slice. + if types.Identical(typ.Elem().Underlying(), types.Typ[types.Byte]) && t&argString != 0 { + return true // %s matches []byte + } + // Recur: []int matches %d. + return matchArgTypeInternal(pass, t, typ.Elem(), arg, inProgress) + + case *types.Slice: + // Same as array. + if types.Identical(typ.Elem().Underlying(), types.Typ[types.Byte]) && t&argString != 0 { + return true // %s matches []byte + } + if t == argPointer { + return true // %p prints a slice's 0th element + } + // Recur: []int matches %d. But watch out for + // type T []T + // If the element is a pointer type (type T[]*T), it's handled fine by the Pointer case below. + return matchArgTypeInternal(pass, t, typ.Elem(), arg, inProgress) + + case *types.Pointer: + // Ugly, but dealing with an edge case: a known pointer to an invalid type, + // probably something from a failed import. + if typ.Elem().String() == "invalid type" { + if false { + pass.Reportf(arg.Pos(), "printf argument %v is pointer to invalid or unknown type", analysisutil.Format(pass.Fset, arg)) + } + return true // special case + } + // If it's actually a pointer with %p, it prints as one. + if t == argPointer { + return true + } + + under := typ.Elem().Underlying() + switch under.(type) { + case *types.Struct: // see below + case *types.Array: // see below + case *types.Slice: // see below + case *types.Map: // see below + default: + // Check whether the rest can print pointers. + return t&argPointer != 0 + } + // If it's a top-level pointer to a struct, array, slice, or + // map, that's equivalent in our analysis to whether we can + // print the type being pointed to. Pointers in nested levels + // are not supported to minimize fmt running into loops. + if len(inProgress) > 1 { + return false + } + return matchArgTypeInternal(pass, t, under, arg, inProgress) + + case *types.Struct: + return matchStructArgType(pass, t, typ, arg, inProgress) + + case *types.Interface: + // There's little we can do. + // Whether any particular verb is valid depends on the argument. + // The user may have reasonable prior knowledge of the contents of the interface. + return true + + case *types.Basic: + switch typ.Kind() { + case types.UntypedBool, + types.Bool: + return t&argBool != 0 + + case types.UntypedInt, + types.Int, + types.Int8, + types.Int16, + types.Int32, + types.Int64, + types.Uint, + types.Uint8, + types.Uint16, + types.Uint32, + types.Uint64, + types.Uintptr: + return t&argInt != 0 + + case types.UntypedFloat, + types.Float32, + types.Float64: + return t&argFloat != 0 + + case types.UntypedComplex, + types.Complex64, + types.Complex128: + return t&argComplex != 0 + + case types.UntypedString, + types.String: + return t&argString != 0 + + case types.UnsafePointer: + return t&(argPointer|argInt) != 0 + + case types.UntypedRune: + return t&(argInt|argRune) != 0 + + case types.UntypedNil: + return false + + case types.Invalid: + if false { + pass.Reportf(arg.Pos(), "printf argument %v has invalid or unknown type", analysisutil.Format(pass.Fset, arg)) + } + return true // Probably a type check problem. + } + panic("unreachable") + } + + return false +} + +func isConvertibleToString(pass *analysis.Pass, typ types.Type) bool { + if bt, ok := typ.(*types.Basic); ok && bt.Kind() == types.UntypedNil { + // We explicitly don't want untyped nil, which is + // convertible to both of the interfaces below, as it + // would just panic anyway. + return false + } + if types.ConvertibleTo(typ, errorType) { + return true // via .Error() + } + + // Does it implement fmt.Stringer? + if obj, _, _ := types.LookupFieldOrMethod(typ, false, nil, "String"); obj != nil { + if fn, ok := obj.(*types.Func); ok { + sig := fn.Type().(*types.Signature) + if sig.Params().Len() == 0 && + sig.Results().Len() == 1 && + sig.Results().At(0).Type() == types.Typ[types.String] { + return true + } + } + } + + return false +} + +// hasBasicType reports whether x's type is a types.Basic with the given kind. +func hasBasicType(pass *analysis.Pass, x ast.Expr, kind types.BasicKind) bool { + t := pass.TypesInfo.Types[x].Type + if t != nil { + t = t.Underlying() + } + b, ok := t.(*types.Basic) + return ok && b.Kind() == kind +} + +// matchStructArgType reports whether all the elements of the struct match the expected +// type. For instance, with "%d" all the elements must be printable with the "%d" format. +func matchStructArgType(pass *analysis.Pass, t printfArgType, typ *types.Struct, arg ast.Expr, inProgress map[types.Type]bool) bool { + for i := 0; i < typ.NumFields(); i++ { + typf := typ.Field(i) + if !matchArgTypeInternal(pass, t, typf.Type(), arg, inProgress) { + return false + } + if t&argString != 0 && !typf.Exported() && isConvertibleToString(pass, typf.Type()) { + // Issue #17798: unexported Stringer or error cannot be properly fomatted. + return false + } + } + return true +} + +var archSizes = types.SizesFor("gc", build.Default.GOARCH) diff --git a/libgo/go/cmd/vet/dead.go b/libgo/go/golang.org/x/tools/go/analysis/passes/shift/dead.go similarity index 65% rename from libgo/go/cmd/vet/dead.go rename to libgo/go/golang.org/x/tools/go/analysis/passes/shift/dead.go index 0facec55258..43415a98d61 100644 --- a/libgo/go/cmd/vet/dead.go +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/shift/dead.go @@ -1,37 +1,50 @@ // Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// -// Simplified dead code detector. Used for skipping certain checks -// on unreachable code (for instance, shift checks on arch-specific code). -package main +package shift + +// Simplified dead code detector. +// Used for skipping shift checks on unreachable arch-specific code. import ( "go/ast" "go/constant" + "go/types" ) -// updateDead puts unreachable "if" and "case" nodes into f.dead. -func (f *File) updateDead(node ast.Node) { - if f.dead[node] { +// updateDead puts unreachable "if" and "case" nodes into dead. +func updateDead(info *types.Info, dead map[ast.Node]bool, node ast.Node) { + if dead[node] { // The node is already marked as dead. return } + // setDead marks the node and all the children as dead. + setDead := func(n ast.Node) { + ast.Inspect(n, func(node ast.Node) bool { + if node != nil { + dead[node] = true + } + return true + }) + } + switch stmt := node.(type) { case *ast.IfStmt: // "if" branch is dead if its condition evaluates // to constant false. - v := f.pkg.types[stmt.Cond].Value + v := info.Types[stmt.Cond].Value if v == nil { return } if !constant.BoolVal(v) { - f.setDead(stmt.Body) + setDead(stmt.Body) return } - f.setDead(stmt.Else) + if stmt.Else != nil { + setDead(stmt.Else) + } case *ast.SwitchStmt: // Case clause with empty switch tag is dead if it evaluates // to constant false. @@ -44,12 +57,12 @@ func (f *File) updateDead(node ast.Node) { continue } for _, expr := range cc.List { - v := f.pkg.types[expr].Value + v := info.Types[expr].Value if v == nil || v.Kind() != constant.Bool || constant.BoolVal(v) { continue BodyLoopBool } } - f.setDead(cc) + setDead(cc) } return } @@ -57,7 +70,7 @@ func (f *File) updateDead(node ast.Node) { // Case clause is dead if its constant value doesn't match // the constant value from the switch tag. // TODO: This handles integer comparisons only. - v := f.pkg.types[stmt.Tag].Value + v := info.Types[stmt.Tag].Value if v == nil || v.Kind() != constant.Int { return } @@ -73,7 +86,7 @@ func (f *File) updateDead(node ast.Node) { continue } for _, expr := range cc.List { - v := f.pkg.types[expr].Value + v := info.Types[expr].Value if v == nil { continue BodyLoopInt } @@ -82,27 +95,7 @@ func (f *File) updateDead(node ast.Node) { continue BodyLoopInt } } - f.setDead(cc) + setDead(cc) } } } - -// setDead marks the node and all the children as dead. -func (f *File) setDead(node ast.Node) { - dv := deadVisitor{ - f: f, - } - ast.Walk(dv, node) -} - -type deadVisitor struct { - f *File -} - -func (dv deadVisitor) Visit(node ast.Node) ast.Visitor { - if node == nil { - return nil - } - dv.f.dead[node] = true - return dv -} diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/shift/shift.go b/libgo/go/golang.org/x/tools/go/analysis/passes/shift/shift.go new file mode 100644 index 00000000000..56b150b2b13 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/shift/shift.go @@ -0,0 +1,128 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package shift defines an Analyzer that checks for shifts that exceed +// the width of an integer. +package shift + +// TODO(adonovan): integrate with ctrflow (CFG-based) dead code analysis. May +// have impedance mismatch due to its (non-)treatment of constant +// expressions (such as runtime.GOARCH=="386"). + +import ( + "go/ast" + "go/build" + "go/constant" + "go/token" + "go/types" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/inspect" + "golang.org/x/tools/go/analysis/passes/internal/analysisutil" + "golang.org/x/tools/go/ast/inspector" +) + +var Analyzer = &analysis.Analyzer{ + Name: "shift", + Doc: "check for shifts that equal or exceed the width of the integer", + Requires: []*analysis.Analyzer{inspect.Analyzer}, + Run: run, +} + +func run(pass *analysis.Pass) (interface{}, error) { + inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) + + // Do a complete pass to compute dead nodes. + dead := make(map[ast.Node]bool) + nodeFilter := []ast.Node{ + (*ast.IfStmt)(nil), + (*ast.SwitchStmt)(nil), + } + inspect.Preorder(nodeFilter, func(n ast.Node) { + // TODO(adonovan): move updateDead into this file. + updateDead(pass.TypesInfo, dead, n) + }) + + nodeFilter = []ast.Node{ + (*ast.AssignStmt)(nil), + (*ast.BinaryExpr)(nil), + } + inspect.Preorder(nodeFilter, func(node ast.Node) { + if dead[node] { + // Skip shift checks on unreachable nodes. + return + } + + switch node := node.(type) { + case *ast.BinaryExpr: + if node.Op == token.SHL || node.Op == token.SHR { + checkLongShift(pass, node, node.X, node.Y) + } + case *ast.AssignStmt: + if len(node.Lhs) != 1 || len(node.Rhs) != 1 { + return + } + if node.Tok == token.SHL_ASSIGN || node.Tok == token.SHR_ASSIGN { + checkLongShift(pass, node, node.Lhs[0], node.Rhs[0]) + } + } + }) + return nil, nil +} + +// checkLongShift checks if shift or shift-assign operations shift by more than +// the length of the underlying variable. +func checkLongShift(pass *analysis.Pass, node ast.Node, x, y ast.Expr) { + if pass.TypesInfo.Types[x].Value != nil { + // Ignore shifts of constants. + // These are frequently used for bit-twiddling tricks + // like ^uint(0) >> 63 for 32/64 bit detection and compatibility. + return + } + + v := pass.TypesInfo.Types[y].Value + if v == nil { + return + } + amt, ok := constant.Int64Val(v) + if !ok { + return + } + t := pass.TypesInfo.Types[x].Type + if t == nil { + return + } + b, ok := t.Underlying().(*types.Basic) + if !ok { + return + } + var size int64 + switch b.Kind() { + case types.Uint8, types.Int8: + size = 8 + case types.Uint16, types.Int16: + size = 16 + case types.Uint32, types.Int32: + size = 32 + case types.Uint64, types.Int64: + size = 64 + case types.Int, types.Uint: + size = uintBitSize + case types.Uintptr: + size = uintptrBitSize + default: + return + } + if amt >= size { + ident := analysisutil.Format(pass.Fset, x) + pass.Reportf(node.Pos(), "%s (%d bits) too small for shift of %d", ident, size, amt) + } +} + +var ( + uintBitSize = 8 * archSizes.Sizeof(types.Typ[types.Uint]) + uintptrBitSize = 8 * archSizes.Sizeof(types.Typ[types.Uintptr]) +) + +var archSizes = types.SizesFor("gc", build.Default.GOARCH) diff --git a/libgo/go/cmd/vet/method.go b/libgo/go/golang.org/x/tools/go/analysis/passes/stdmethods/stdmethods.go similarity index 57% rename from libgo/go/cmd/vet/method.go rename to libgo/go/golang.org/x/tools/go/analysis/passes/stdmethods/stdmethods.go index 5783278d2c2..83495112243 100644 --- a/libgo/go/cmd/vet/method.go +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/stdmethods/stdmethods.go @@ -2,27 +2,47 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// This file contains the code to check canonical methods. - -package main +// Package stdmethods defines an Analyzer that checks for misspellings +// in the signatures of methods similar to well-known interfaces. +package stdmethods import ( - "fmt" "go/ast" - "go/printer" + "go/token" + "go/types" "strings" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/inspect" + "golang.org/x/tools/go/ast/inspector" ) -func init() { - register("methods", - "check that canonically named methods are canonically defined", - checkCanonicalMethod, - funcDecl, interfaceType) -} +const Doc = `check signature of methods of well-known interfaces + +Sometimes a type may be intended to satisfy an interface but may fail to +do so because of a mistake in its method signature. +For example, the result of this WriteTo method should be (int64, error), +not error, to satisfy io.WriterTo: + + type myWriterTo struct{...} + func (myWriterTo) WriteTo(w io.Writer) error { ... } + +This check ensures that each method whose name matches one of several +well-known interface methods from the standard library has the correct +signature for that interface. -type MethodSig struct { - args []string - results []string +Checked method names include: + Format GobEncode GobDecode MarshalJSON MarshalXML + Peek ReadByte ReadFrom ReadRune Scan Seek + UnmarshalJSON UnreadByte UnreadRune WriteByte + WriteTo +` + +var Analyzer = &analysis.Analyzer{ + Name: "stdmethods", + Doc: Doc, + Requires: []*analysis.Analyzer{inspect.Analyzer}, + Run: run, } // canonicalMethods lists the input and output types for Go methods @@ -41,7 +61,7 @@ type MethodSig struct { // method doesn't have a fmt.ScanState as its first argument, // we let it go. But if it does have a fmt.ScanState, then the // rest has to match. -var canonicalMethods = map[string]MethodSig{ +var canonicalMethods = map[string]struct{ args, results []string }{ // "Flush": {{}, {"error"}}, // http.Flusher and jpeg.writer conflict "Format": {[]string{"=fmt.State", "rune"}, []string{}}, // fmt.Formatter "GobDecode": {[]string{"[]byte"}, []string{"error"}}, // gob.GobDecoder @@ -61,22 +81,31 @@ var canonicalMethods = map[string]MethodSig{ "WriteTo": {[]string{"=io.Writer"}, []string{"int64", "error"}}, // io.WriterTo } -func checkCanonicalMethod(f *File, node ast.Node) { - switch n := node.(type) { - case *ast.FuncDecl: - if n.Recv != nil { - canonicalMethod(f, n.Name, n.Type) - } - case *ast.InterfaceType: - for _, field := range n.Methods.List { - for _, id := range field.Names { - canonicalMethod(f, id, field.Type.(*ast.FuncType)) +func run(pass *analysis.Pass) (interface{}, error) { + inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) + + nodeFilter := []ast.Node{ + (*ast.FuncDecl)(nil), + (*ast.InterfaceType)(nil), + } + inspect.Preorder(nodeFilter, func(n ast.Node) { + switch n := n.(type) { + case *ast.FuncDecl: + if n.Recv != nil { + canonicalMethod(pass, n.Name) + } + case *ast.InterfaceType: + for _, field := range n.Methods.List { + for _, id := range field.Names { + canonicalMethod(pass, id) + } } } - } + }) + return nil, nil } -func canonicalMethod(f *File, id *ast.Ident, t *ast.FuncType) { +func canonicalMethod(pass *analysis.Pass, id *ast.Ident) { // Expected input/output. expect, ok := canonicalMethods[id.Name] if !ok { @@ -84,19 +113,17 @@ func canonicalMethod(f *File, id *ast.Ident, t *ast.FuncType) { } // Actual input/output - args := typeFlatten(t.Params.List) - var results []ast.Expr - if t.Results != nil { - results = typeFlatten(t.Results.List) - } + sign := pass.TypesInfo.Defs[id].Type().(*types.Signature) + args := sign.Params() + results := sign.Results() // Do the =s (if any) all match? - if !f.matchParams(expect.args, args, "=") || !f.matchParams(expect.results, results, "=") { + if !matchParams(pass, expect.args, args, "=") || !matchParams(pass, expect.results, results, "=") { return } // Everything must match. - if !f.matchParams(expect.args, args, "") || !f.matchParams(expect.results, results, "") { + if !matchParams(pass, expect.args, args, "") || !matchParams(pass, expect.results, results, "") { expectFmt := id.Name + "(" + argjoin(expect.args) + ")" if len(expect.results) == 1 { expectFmt += " " + argjoin(expect.results) @@ -104,18 +131,18 @@ func canonicalMethod(f *File, id *ast.Ident, t *ast.FuncType) { expectFmt += " (" + argjoin(expect.results) + ")" } - f.b.Reset() - if err := printer.Fprint(&f.b, f.fset, t); err != nil { - fmt.Fprintf(&f.b, "<%s>", err) - } - actual := f.b.String() + actual := typeString(sign) actual = strings.TrimPrefix(actual, "func") actual = id.Name + actual - f.Badf(id.Pos(), "method %s should have signature %s", actual, expectFmt) + pass.Reportf(id.Pos(), "method %s should have signature %s", actual, expectFmt) } } +func typeString(typ types.Type) string { + return types.TypeString(typ, (*types.Package).Name) +} + func argjoin(x []string) string { y := make([]string, len(x)) for i, s := range x { @@ -127,53 +154,33 @@ func argjoin(x []string) string { return strings.Join(y, ", ") } -// Turn parameter list into slice of types -// (in the ast, types are Exprs). -// Have to handle f(int, bool) and f(x, y, z int) -// so not a simple 1-to-1 conversion. -func typeFlatten(l []*ast.Field) []ast.Expr { - var t []ast.Expr - for _, f := range l { - if len(f.Names) == 0 { - t = append(t, f.Type) - continue - } - for range f.Names { - t = append(t, f.Type) - } - } - return t -} - // Does each type in expect with the given prefix match the corresponding type in actual? -func (f *File) matchParams(expect []string, actual []ast.Expr, prefix string) bool { +func matchParams(pass *analysis.Pass, expect []string, actual *types.Tuple, prefix string) bool { for i, x := range expect { if !strings.HasPrefix(x, prefix) { continue } - if i >= len(actual) { + if i >= actual.Len() { return false } - if !f.matchParamType(x, actual[i]) { + if !matchParamType(pass.Fset, pass.Pkg, x, actual.At(i).Type()) { return false } } - if prefix == "" && len(actual) > len(expect) { + if prefix == "" && actual.Len() > len(expect) { return false } return true } // Does this one type match? -func (f *File) matchParamType(expect string, actual ast.Expr) bool { +func matchParamType(fset *token.FileSet, pkg *types.Package, expect string, actual types.Type) bool { expect = strings.TrimPrefix(expect, "=") // Strip package name if we're in that package. - if n := len(f.file.Name.Name); len(expect) > n && expect[:n] == f.file.Name.Name && expect[n] == '.' { + if n := len(pkg.Name()); len(expect) > n && expect[:n] == pkg.Name() && expect[n] == '.' { expect = expect[n+1:] } // Overkill but easy. - f.b.Reset() - printer.Fprint(&f.b, f.fset, actual) - return f.b.String() == expect + return typeString(actual) == expect } diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/structtag/structtag.go b/libgo/go/golang.org/x/tools/go/analysis/passes/structtag/structtag.go new file mode 100644 index 00000000000..2b67c376bab --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/structtag/structtag.go @@ -0,0 +1,273 @@ +// Copyright 2010 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package structtag defines an Analyzer that checks struct field tags +// are well formed. +package structtag + +import ( + "errors" + "go/ast" + "go/token" + "go/types" + "path/filepath" + "reflect" + "strconv" + "strings" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/inspect" + "golang.org/x/tools/go/ast/inspector" +) + +const Doc = `check that struct field tags conform to reflect.StructTag.Get + +Also report certain struct tags (json, xml) used with unexported fields.` + +var Analyzer = &analysis.Analyzer{ + Name: "structtag", + Doc: Doc, + Requires: []*analysis.Analyzer{inspect.Analyzer}, + RunDespiteErrors: true, + Run: run, +} + +func run(pass *analysis.Pass) (interface{}, error) { + inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) + + nodeFilter := []ast.Node{ + (*ast.StructType)(nil), + } + inspect.Preorder(nodeFilter, func(n ast.Node) { + styp := pass.TypesInfo.Types[n.(*ast.StructType)].Type.(*types.Struct) + var seen map[[2]string]token.Pos + for i := 0; i < styp.NumFields(); i++ { + field := styp.Field(i) + tag := styp.Tag(i) + checkCanonicalFieldTag(pass, field, tag, &seen) + } + }) + return nil, nil +} + +var checkTagDups = []string{"json", "xml"} +var checkTagSpaces = map[string]bool{"json": true, "xml": true, "asn1": true} + +// checkCanonicalFieldTag checks a single struct field tag. +func checkCanonicalFieldTag(pass *analysis.Pass, field *types.Var, tag string, seen *map[[2]string]token.Pos) { + for _, key := range checkTagDups { + checkTagDuplicates(pass, tag, key, field, field, seen) + } + + if err := validateStructTag(tag); err != nil { + pass.Reportf(field.Pos(), "struct field tag %#q not compatible with reflect.StructTag.Get: %s", tag, err) + } + + // Check for use of json or xml tags with unexported fields. + + // Embedded struct. Nothing to do for now, but that + // may change, depending on what happens with issue 7363. + // TODO(adonovan): investigate, now that that issue is fixed. + if field.Anonymous() { + return + } + + if field.Exported() { + return + } + + for _, enc := range [...]string{"json", "xml"} { + if reflect.StructTag(tag).Get(enc) != "" { + pass.Reportf(field.Pos(), "struct field %s has %s tag but is not exported", field.Name(), enc) + return + } + } +} + +// checkTagDuplicates checks a single struct field tag to see if any tags are +// duplicated. nearest is the field that's closest to the field being checked, +// while still being part of the top-level struct type. +func checkTagDuplicates(pass *analysis.Pass, tag, key string, nearest, field *types.Var, seen *map[[2]string]token.Pos) { + val := reflect.StructTag(tag).Get(key) + if val == "-" { + // Ignored, even if the field is anonymous. + return + } + if val == "" || val[0] == ',' { + if field.Anonymous() { + typ, ok := field.Type().Underlying().(*types.Struct) + if !ok { + return + } + for i := 0; i < typ.NumFields(); i++ { + field := typ.Field(i) + if !field.Exported() { + continue + } + tag := typ.Tag(i) + checkTagDuplicates(pass, tag, key, nearest, field, seen) + } + } + // Ignored if the field isn't anonymous. + return + } + if key == "xml" && field.Name() == "XMLName" { + // XMLName defines the XML element name of the struct being + // checked. That name cannot collide with element or attribute + // names defined on other fields of the struct. Vet does not have a + // check for untagged fields of type struct defining their own name + // by containing a field named XMLName; see issue 18256. + return + } + if i := strings.Index(val, ","); i >= 0 { + if key == "xml" { + // Use a separate namespace for XML attributes. + for _, opt := range strings.Split(val[i:], ",") { + if opt == "attr" { + key += " attribute" // Key is part of the error message. + break + } + } + } + val = val[:i] + } + if *seen == nil { + *seen = map[[2]string]token.Pos{} + } + if pos, ok := (*seen)[[2]string{key, val}]; ok { + alsoPos := pass.Fset.Position(pos) + alsoPos.Column = 0 + + // Make the "also at" position relative to the current position, + // to ensure that all warnings are unambiguous and correct. For + // example, via anonymous struct fields, it's possible for the + // two fields to be in different packages and directories. + thisPos := pass.Fset.Position(field.Pos()) + rel, err := filepath.Rel(filepath.Dir(thisPos.Filename), alsoPos.Filename) + if err != nil { + // Possibly because the paths are relative; leave the + // filename alone. + } else { + alsoPos.Filename = rel + } + + pass.Reportf(nearest.Pos(), "struct field %s repeats %s tag %q also at %s", field.Name(), key, val, alsoPos) + } else { + (*seen)[[2]string{key, val}] = field.Pos() + } +} + +var ( + errTagSyntax = errors.New("bad syntax for struct tag pair") + errTagKeySyntax = errors.New("bad syntax for struct tag key") + errTagValueSyntax = errors.New("bad syntax for struct tag value") + errTagValueSpace = errors.New("suspicious space in struct tag value") + errTagSpace = errors.New("key:\"value\" pairs not separated by spaces") +) + +// validateStructTag parses the struct tag and returns an error if it is not +// in the canonical format, which is a space-separated list of key:"value" +// settings. The value may contain spaces. +func validateStructTag(tag string) error { + // This code is based on the StructTag.Get code in package reflect. + + n := 0 + for ; tag != ""; n++ { + if n > 0 && tag != "" && tag[0] != ' ' { + // More restrictive than reflect, but catches likely mistakes + // like `x:"foo",y:"bar"`, which parses as `x:"foo" ,y:"bar"` with second key ",y". + return errTagSpace + } + // Skip leading space. + i := 0 + for i < len(tag) && tag[i] == ' ' { + i++ + } + tag = tag[i:] + if tag == "" { + break + } + + // Scan to colon. A space, a quote or a control character is a syntax error. + // Strictly speaking, control chars include the range [0x7f, 0x9f], not just + // [0x00, 0x1f], but in practice, we ignore the multi-byte control characters + // as it is simpler to inspect the tag's bytes than the tag's runes. + i = 0 + for i < len(tag) && tag[i] > ' ' && tag[i] != ':' && tag[i] != '"' && tag[i] != 0x7f { + i++ + } + if i == 0 { + return errTagKeySyntax + } + if i+1 >= len(tag) || tag[i] != ':' { + return errTagSyntax + } + if tag[i+1] != '"' { + return errTagValueSyntax + } + key := tag[:i] + tag = tag[i+1:] + + // Scan quoted string to find value. + i = 1 + for i < len(tag) && tag[i] != '"' { + if tag[i] == '\\' { + i++ + } + i++ + } + if i >= len(tag) { + return errTagValueSyntax + } + qvalue := tag[:i+1] + tag = tag[i+1:] + + value, err := strconv.Unquote(qvalue) + if err != nil { + return errTagValueSyntax + } + + if !checkTagSpaces[key] { + continue + } + + switch key { + case "xml": + // If the first or last character in the XML tag is a space, it is + // suspicious. + if strings.Trim(value, " ") != value { + return errTagValueSpace + } + + // If there are multiple spaces, they are suspicious. + if strings.Count(value, " ") > 1 { + return errTagValueSpace + } + + // If there is no comma, skip the rest of the checks. + comma := strings.IndexRune(value, ',') + if comma < 0 { + continue + } + + // If the character before a comma is a space, this is suspicious. + if comma > 0 && value[comma-1] == ' ' { + return errTagValueSpace + } + value = value[comma+1:] + case "json": + // JSON allows using spaces in the name, so skip it. + comma := strings.IndexRune(value, ',') + if comma < 0 { + continue + } + value = value[comma+1:] + } + + if strings.IndexByte(value, ' ') >= 0 { + return errTagValueSpace + } + } + return nil +} diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/tests/tests.go b/libgo/go/golang.org/x/tools/go/analysis/passes/tests/tests.go new file mode 100644 index 00000000000..35b0a3e7cc2 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/tests/tests.go @@ -0,0 +1,175 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package tests defines an Analyzer that checks for common mistaken +// usages of tests and examples. +package tests + +import ( + "go/ast" + "go/types" + "strings" + "unicode" + "unicode/utf8" + + "golang.org/x/tools/go/analysis" +) + +const Doc = `check for common mistaken usages of tests and examples + +The tests checker walks Test, Benchmark and Example functions checking +malformed names, wrong signatures and examples documenting non-existent +identifiers.` + +var Analyzer = &analysis.Analyzer{ + Name: "tests", + Doc: Doc, + Run: run, +} + +func run(pass *analysis.Pass) (interface{}, error) { + for _, f := range pass.Files { + if !strings.HasSuffix(pass.Fset.File(f.Pos()).Name(), "_test.go") { + continue + } + for _, decl := range f.Decls { + fn, ok := decl.(*ast.FuncDecl) + if !ok || fn.Recv != nil { + // Ignore non-functions or functions with receivers. + continue + } + + switch { + case strings.HasPrefix(fn.Name.Name, "Example"): + checkExample(pass, fn) + case strings.HasPrefix(fn.Name.Name, "Test"): + checkTest(pass, fn, "Test") + case strings.HasPrefix(fn.Name.Name, "Benchmark"): + checkTest(pass, fn, "Benchmark") + } + } + } + return nil, nil +} + +func isExampleSuffix(s string) bool { + r, size := utf8.DecodeRuneInString(s) + return size > 0 && unicode.IsLower(r) +} + +func isTestSuffix(name string) bool { + if len(name) == 0 { + // "Test" is ok. + return true + } + r, _ := utf8.DecodeRuneInString(name) + return !unicode.IsLower(r) +} + +func isTestParam(typ ast.Expr, wantType string) bool { + ptr, ok := typ.(*ast.StarExpr) + if !ok { + // Not a pointer. + return false + } + // No easy way of making sure it's a *testing.T or *testing.B: + // ensure the name of the type matches. + if name, ok := ptr.X.(*ast.Ident); ok { + return name.Name == wantType + } + if sel, ok := ptr.X.(*ast.SelectorExpr); ok { + return sel.Sel.Name == wantType + } + return false +} + +func lookup(pkg *types.Package, name string) types.Object { + if o := pkg.Scope().Lookup(name); o != nil { + return o + } + + // If this package is ".../foo_test" and it imports a package + // ".../foo", try looking in the latter package. + // This heuristic should work even on build systems that do not + // record any special link between the packages. + if basePath := strings.TrimSuffix(pkg.Path(), "_test"); basePath != pkg.Path() { + for _, imp := range pkg.Imports() { + if imp.Path() == basePath { + return imp.Scope().Lookup(name) + } + } + } + return nil +} + +func checkExample(pass *analysis.Pass, fn *ast.FuncDecl) { + fnName := fn.Name.Name + if params := fn.Type.Params; len(params.List) != 0 { + pass.Reportf(fn.Pos(), "%s should be niladic", fnName) + } + if results := fn.Type.Results; results != nil && len(results.List) != 0 { + pass.Reportf(fn.Pos(), "%s should return nothing", fnName) + } + + if fnName == "Example" { + // Nothing more to do. + return + } + + var ( + exName = strings.TrimPrefix(fnName, "Example") + elems = strings.SplitN(exName, "_", 3) + ident = elems[0] + obj = lookup(pass.Pkg, ident) + ) + if ident != "" && obj == nil { + // Check ExampleFoo and ExampleBadFoo. + pass.Reportf(fn.Pos(), "%s refers to unknown identifier: %s", fnName, ident) + // Abort since obj is absent and no subsequent checks can be performed. + return + } + if len(elems) < 2 { + // Nothing more to do. + return + } + + if ident == "" { + // Check Example_suffix and Example_BadSuffix. + if residual := strings.TrimPrefix(exName, "_"); !isExampleSuffix(residual) { + pass.Reportf(fn.Pos(), "%s has malformed example suffix: %s", fnName, residual) + } + return + } + + mmbr := elems[1] + if !isExampleSuffix(mmbr) { + // Check ExampleFoo_Method and ExampleFoo_BadMethod. + if obj, _, _ := types.LookupFieldOrMethod(obj.Type(), true, obj.Pkg(), mmbr); obj == nil { + pass.Reportf(fn.Pos(), "%s refers to unknown field or method: %s.%s", fnName, ident, mmbr) + } + } + if len(elems) == 3 && !isExampleSuffix(elems[2]) { + // Check ExampleFoo_Method_suffix and ExampleFoo_Method_Badsuffix. + pass.Reportf(fn.Pos(), "%s has malformed example suffix: %s", fnName, elems[2]) + } +} + +func checkTest(pass *analysis.Pass, fn *ast.FuncDecl, prefix string) { + // Want functions with 0 results and 1 parameter. + if fn.Type.Results != nil && len(fn.Type.Results.List) > 0 || + fn.Type.Params == nil || + len(fn.Type.Params.List) != 1 || + len(fn.Type.Params.List[0].Names) > 1 { + return + } + + // The param must look like a *testing.T or *testing.B. + if !isTestParam(fn.Type.Params.List[0].Type, prefix[:1]) { + return + } + + if !isTestSuffix(fn.Name.Name[len(prefix):]) { + pass.Reportf(fn.Pos(), "%s has malformed name: first letter after '%s' must not be lowercase", fn.Name.Name, prefix) + } +} diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/unmarshal/unmarshal.go b/libgo/go/golang.org/x/tools/go/analysis/passes/unmarshal/unmarshal.go new file mode 100644 index 00000000000..6cf4358ab9a --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/unmarshal/unmarshal.go @@ -0,0 +1,92 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// The unmarshal package defines an Analyzer that checks for passing +// non-pointer or non-interface types to unmarshal and decode functions. +package unmarshal + +import ( + "go/ast" + "go/types" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/inspect" + "golang.org/x/tools/go/ast/inspector" + "golang.org/x/tools/go/types/typeutil" +) + +const doc = `report passing non-pointer or non-interface values to unmarshal + +The unmarshal analysis reports calls to functions such as json.Unmarshal +in which the argument type is not a pointer or an interface.` + +var Analyzer = &analysis.Analyzer{ + Name: "unmarshal", + Doc: doc, + Requires: []*analysis.Analyzer{inspect.Analyzer}, + Run: run, +} + +func run(pass *analysis.Pass) (interface{}, error) { + inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) + + nodeFilter := []ast.Node{ + (*ast.CallExpr)(nil), + } + inspect.Preorder(nodeFilter, func(n ast.Node) { + call := n.(*ast.CallExpr) + fn := typeutil.StaticCallee(pass.TypesInfo, call) + if fn == nil { + return // not a static call + } + + // Classify the callee (without allocating memory). + argidx := -1 + recv := fn.Type().(*types.Signature).Recv() + if fn.Name() == "Unmarshal" && recv == nil { + // "encoding/json".Unmarshal + // "encoding/xml".Unmarshal + switch fn.Pkg().Path() { + case "encoding/json", "encoding/xml": + argidx = 1 // func([]byte, interface{}) + } + } else if fn.Name() == "Decode" && recv != nil { + // (*"encoding/json".Decoder).Decode + // (* "encoding/gob".Decoder).Decode + // (* "encoding/xml".Decoder).Decode + t := recv.Type() + if ptr, ok := t.(*types.Pointer); ok { + t = ptr.Elem() + } + tname := t.(*types.Named).Obj() + if tname.Name() == "Decoder" { + switch tname.Pkg().Path() { + case "encoding/json", "encoding/xml", "encoding/gob": + argidx = 0 // func(interface{}) + } + } + } + if argidx < 0 { + return // not a function we are interested in + } + + if len(call.Args) < argidx+1 { + return // not enough arguments, e.g. called with return values of another function + } + + t := pass.TypesInfo.Types[call.Args[argidx]].Type + switch t.Underlying().(type) { + case *types.Pointer, *types.Interface: + return + } + + switch argidx { + case 0: + pass.Reportf(call.Lparen, "call of %s passes non-pointer", fn.Name()) + case 1: + pass.Reportf(call.Lparen, "call of %s passes non-pointer as second argument", fn.Name()) + } + }) + return nil, nil +} diff --git a/libgo/go/cmd/vet/deadcode.go b/libgo/go/golang.org/x/tools/go/analysis/passes/unreachable/unreachable.go similarity index 79% rename from libgo/go/cmd/vet/deadcode.go rename to libgo/go/golang.org/x/tools/go/analysis/passes/unreachable/unreachable.go index b1077aef38f..19bc9c2db98 100644 --- a/libgo/go/cmd/vet/deadcode.go +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/unreachable/unreachable.go @@ -2,24 +2,68 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Check for syntactically unreachable code. +// Package unreachable defines an Analyzer that checks for unreachable code. +package unreachable -package main +// TODO(adonovan): use the new cfg package, which is more precise. import ( "go/ast" "go/token" + "log" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/inspect" + "golang.org/x/tools/go/ast/inspector" ) -func init() { - register("unreachable", - "check for unreachable code", - checkUnreachable, - funcDecl, funcLit) +const Doc = `check for unreachable code + +The unreachable analyzer finds statements that execution can never reach +because they are preceded by an return statement, a call to panic, an +infinite loop, or similar constructs.` + +var Analyzer = &analysis.Analyzer{ + Name: "unreachable", + Doc: Doc, + Requires: []*analysis.Analyzer{inspect.Analyzer}, + RunDespiteErrors: true, + Run: run, +} + +func run(pass *analysis.Pass) (interface{}, error) { + inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) + + nodeFilter := []ast.Node{ + (*ast.FuncDecl)(nil), + (*ast.FuncLit)(nil), + } + inspect.Preorder(nodeFilter, func(n ast.Node) { + var body *ast.BlockStmt + switch n := n.(type) { + case *ast.FuncDecl: + body = n.Body + case *ast.FuncLit: + body = n.Body + } + if body == nil { + return + } + d := &deadState{ + pass: pass, + hasBreak: make(map[ast.Stmt]bool), + hasGoto: make(map[string]bool), + labels: make(map[string]ast.Stmt), + } + d.findLabels(body) + d.reachable = true + d.findDead(body) + }) + return nil, nil } type deadState struct { - f *File + pass *analysis.Pass hasBreak map[ast.Stmt]bool hasGoto map[string]bool labels map[string]ast.Stmt @@ -28,40 +72,12 @@ type deadState struct { reachable bool } -// checkUnreachable checks a function body for dead code. -// -// TODO(adonovan): use the new cfg package, which is more precise. -func checkUnreachable(f *File, node ast.Node) { - var body *ast.BlockStmt - switch n := node.(type) { - case *ast.FuncDecl: - body = n.Body - case *ast.FuncLit: - body = n.Body - } - if body == nil { - return - } - - d := &deadState{ - f: f, - hasBreak: make(map[ast.Stmt]bool), - hasGoto: make(map[string]bool), - labels: make(map[string]ast.Stmt), - } - - d.findLabels(body) - - d.reachable = true - d.findDead(body) -} - // findLabels gathers information about the labels defined and used by stmt // and about which statements break, whether a label is involved or not. func (d *deadState) findLabels(stmt ast.Stmt) { switch x := stmt.(type) { default: - d.f.Warnf(x.Pos(), "internal error in findLabels: unexpected statement %T", x) + log.Fatalf("%s: internal error in findLabels: unexpected statement %T", d.pass.Fset.Position(x.Pos()), x) case *ast.AssignStmt, *ast.BadStmt, @@ -173,14 +189,14 @@ func (d *deadState) findDead(stmt ast.Stmt) { case *ast.EmptyStmt: // do not warn about unreachable empty statements default: - d.f.Bad(stmt.Pos(), "unreachable code") + d.pass.Reportf(stmt.Pos(), "unreachable code") d.reachable = true // silence error about next statement } } switch x := stmt.(type) { default: - d.f.Warnf(x.Pos(), "internal error in findDead: unexpected statement %T", x) + log.Fatalf("%s: internal error in findDead: unexpected statement %T", d.pass.Fset.Position(x.Pos()), x) case *ast.AssignStmt, *ast.BadStmt, diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/unsafeptr/unsafeptr.go b/libgo/go/golang.org/x/tools/go/analysis/passes/unsafeptr/unsafeptr.go new file mode 100644 index 00000000000..308bfc69cb4 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/unsafeptr/unsafeptr.go @@ -0,0 +1,130 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package unsafeptr defines an Analyzer that checks for invalid +// conversions of uintptr to unsafe.Pointer. +package unsafeptr + +import ( + "go/ast" + "go/token" + "go/types" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/inspect" + "golang.org/x/tools/go/ast/inspector" +) + +const Doc = `check for invalid conversions of uintptr to unsafe.Pointer + +The unsafeptr analyzer reports likely incorrect uses of unsafe.Pointer +to convert integers to pointers. A conversion from uintptr to +unsafe.Pointer is invalid if it implies that there is a uintptr-typed +word in memory that holds a pointer value, because that word will be +invisible to stack copying and to the garbage collector.` + +var Analyzer = &analysis.Analyzer{ + Name: "unsafeptr", + Doc: Doc, + Requires: []*analysis.Analyzer{inspect.Analyzer}, + Run: run, +} + +func run(pass *analysis.Pass) (interface{}, error) { + inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) + + nodeFilter := []ast.Node{ + (*ast.CallExpr)(nil), + } + inspect.Preorder(nodeFilter, func(n ast.Node) { + x := n.(*ast.CallExpr) + if len(x.Args) != 1 { + return + } + if hasBasicType(pass.TypesInfo, x.Fun, types.UnsafePointer) && + hasBasicType(pass.TypesInfo, x.Args[0], types.Uintptr) && + !isSafeUintptr(pass.TypesInfo, x.Args[0]) { + pass.Reportf(x.Pos(), "possible misuse of unsafe.Pointer") + } + }) + return nil, nil +} + +// isSafeUintptr reports whether x - already known to be a uintptr - +// is safe to convert to unsafe.Pointer. It is safe if x is itself derived +// directly from an unsafe.Pointer via conversion and pointer arithmetic +// or if x is the result of reflect.Value.Pointer or reflect.Value.UnsafeAddr +// or obtained from the Data field of a *reflect.SliceHeader or *reflect.StringHeader. +func isSafeUintptr(info *types.Info, x ast.Expr) bool { + switch x := x.(type) { + case *ast.ParenExpr: + return isSafeUintptr(info, x.X) + + case *ast.SelectorExpr: + if x.Sel.Name != "Data" { + break + } + // reflect.SliceHeader and reflect.StringHeader are okay, + // but only if they are pointing at a real slice or string. + // It's not okay to do: + // var x SliceHeader + // x.Data = uintptr(unsafe.Pointer(...)) + // ... use x ... + // p := unsafe.Pointer(x.Data) + // because in the middle the garbage collector doesn't + // see x.Data as a pointer and so x.Data may be dangling + // by the time we get to the conversion at the end. + // For now approximate by saying that *Header is okay + // but Header is not. + pt, ok := info.Types[x.X].Type.(*types.Pointer) + if ok { + t, ok := pt.Elem().(*types.Named) + if ok && t.Obj().Pkg().Path() == "reflect" { + switch t.Obj().Name() { + case "StringHeader", "SliceHeader": + return true + } + } + } + + case *ast.CallExpr: + switch len(x.Args) { + case 0: + // maybe call to reflect.Value.Pointer or reflect.Value.UnsafeAddr. + sel, ok := x.Fun.(*ast.SelectorExpr) + if !ok { + break + } + switch sel.Sel.Name { + case "Pointer", "UnsafeAddr": + t, ok := info.Types[sel.X].Type.(*types.Named) + if ok && t.Obj().Pkg().Path() == "reflect" && t.Obj().Name() == "Value" { + return true + } + } + + case 1: + // maybe conversion of uintptr to unsafe.Pointer + return hasBasicType(info, x.Fun, types.Uintptr) && + hasBasicType(info, x.Args[0], types.UnsafePointer) + } + + case *ast.BinaryExpr: + switch x.Op { + case token.ADD, token.SUB, token.AND_NOT: + return isSafeUintptr(info, x.X) && !isSafeUintptr(info, x.Y) + } + } + return false +} + +// hasBasicType reports whether x's type is a types.Basic with the given kind. +func hasBasicType(info *types.Info, x ast.Expr, kind types.BasicKind) bool { + t := info.Types[x].Type + if t != nil { + t = t.Underlying() + } + b, ok := t.(*types.Basic) + return ok && b.Kind() == kind +} diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/unusedresult/unusedresult.go b/libgo/go/golang.org/x/tools/go/analysis/passes/unusedresult/unusedresult.go new file mode 100644 index 00000000000..76d4ab23827 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/unusedresult/unusedresult.go @@ -0,0 +1,131 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package unusedresult defines an analyzer that checks for unused +// results of calls to certain pure functions. +package unusedresult + +import ( + "go/ast" + "go/token" + "go/types" + "sort" + "strings" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/inspect" + "golang.org/x/tools/go/analysis/passes/internal/analysisutil" + "golang.org/x/tools/go/ast/inspector" +) + +// TODO(adonovan): make this analysis modular: export a mustUseResult +// fact for each function that tail-calls one of the functions that we +// check, and check those functions too. + +const Doc = `check for unused results of calls to some functions + +Some functions like fmt.Errorf return a result and have no side effects, +so it is always a mistake to discard the result. This analyzer reports +calls to certain functions in which the result of the call is ignored. + +The set of functions may be controlled using flags.` + +var Analyzer = &analysis.Analyzer{ + Name: "unusedresult", + Doc: Doc, + Requires: []*analysis.Analyzer{inspect.Analyzer}, + Run: run, +} + +// flags +var funcs, stringMethods stringSetFlag + +func init() { + // TODO(adonovan): provide a comment syntax to allow users to + // add their functions to this set using facts. + funcs.Set("errors.New,fmt.Errorf,fmt.Sprintf,fmt.Sprint,sort.Reverse") + Analyzer.Flags.Var(&funcs, "funcs", + "comma-separated list of functions whose results must be used") + + stringMethods.Set("Error,String") + Analyzer.Flags.Var(&stringMethods, "stringmethods", + "comma-separated list of names of methods of type func() string whose results must be used") +} + +func run(pass *analysis.Pass) (interface{}, error) { + inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) + + nodeFilter := []ast.Node{ + (*ast.ExprStmt)(nil), + } + inspect.Preorder(nodeFilter, func(n ast.Node) { + call, ok := analysisutil.Unparen(n.(*ast.ExprStmt).X).(*ast.CallExpr) + if !ok { + return // not a call statement + } + fun := analysisutil.Unparen(call.Fun) + + if pass.TypesInfo.Types[fun].IsType() { + return // a conversion, not a call + } + + selector, ok := fun.(*ast.SelectorExpr) + if !ok { + return // neither a method call nor a qualified ident + } + + sel, ok := pass.TypesInfo.Selections[selector] + if ok && sel.Kind() == types.MethodVal { + // method (e.g. foo.String()) + obj := sel.Obj().(*types.Func) + sig := sel.Type().(*types.Signature) + if types.Identical(sig, sigNoArgsStringResult) { + if stringMethods[obj.Name()] { + pass.Reportf(call.Lparen, "result of (%s).%s call not used", + sig.Recv().Type(), obj.Name()) + } + } + } else if !ok { + // package-qualified function (e.g. fmt.Errorf) + obj := pass.TypesInfo.Uses[selector.Sel] + if obj, ok := obj.(*types.Func); ok { + qname := obj.Pkg().Path() + "." + obj.Name() + if funcs[qname] { + pass.Reportf(call.Lparen, "result of %v call not used", qname) + } + } + } + }) + return nil, nil +} + +// func() string +var sigNoArgsStringResult = types.NewSignature(nil, nil, + types.NewTuple(types.NewVar(token.NoPos, nil, "", types.Typ[types.String])), + false) + +type stringSetFlag map[string]bool + +func (ss *stringSetFlag) String() string { + var items []string + for item := range *ss { + items = append(items, item) + } + sort.Strings(items) + return strings.Join(items, ",") +} + +func (ss *stringSetFlag) Set(s string) error { + m := make(map[string]bool) // clobber previous value + if s != "" { + for _, name := range strings.Split(s, ",") { + if name == "" { + continue // TODO: report error? proceed? + } + m[name] = true + } + } + *ss = m + return nil +} diff --git a/libgo/go/golang.org/x/tools/go/analysis/unitchecker/main.go b/libgo/go/golang.org/x/tools/go/analysis/unitchecker/main.go new file mode 100644 index 00000000000..844e8f3dac2 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/unitchecker/main.go @@ -0,0 +1,64 @@ +// +build ignore + +// This file provides an example command for static checkers +// conforming to the golang.org/x/tools/go/analysis API. +// It serves as a model for the behavior of the cmd/vet tool in $GOROOT. +// Being based on the unitchecker driver, it must be run by go vet: +// +// $ go build -o unitchecker main.go +// $ go vet -vettool=unitchecker my/project/... +// +// For a checker also capable of running standalone, use multichecker. +package main + +import ( + "golang.org/x/tools/go/analysis/unitchecker" + + "golang.org/x/tools/go/analysis/passes/asmdecl" + "golang.org/x/tools/go/analysis/passes/assign" + "golang.org/x/tools/go/analysis/passes/atomic" + "golang.org/x/tools/go/analysis/passes/bools" + "golang.org/x/tools/go/analysis/passes/buildtag" + "golang.org/x/tools/go/analysis/passes/cgocall" + "golang.org/x/tools/go/analysis/passes/composite" + "golang.org/x/tools/go/analysis/passes/copylock" + "golang.org/x/tools/go/analysis/passes/httpresponse" + "golang.org/x/tools/go/analysis/passes/loopclosure" + "golang.org/x/tools/go/analysis/passes/lostcancel" + "golang.org/x/tools/go/analysis/passes/nilfunc" + "golang.org/x/tools/go/analysis/passes/printf" + "golang.org/x/tools/go/analysis/passes/shift" + "golang.org/x/tools/go/analysis/passes/stdmethods" + "golang.org/x/tools/go/analysis/passes/structtag" + "golang.org/x/tools/go/analysis/passes/tests" + "golang.org/x/tools/go/analysis/passes/unmarshal" + "golang.org/x/tools/go/analysis/passes/unreachable" + "golang.org/x/tools/go/analysis/passes/unsafeptr" + "golang.org/x/tools/go/analysis/passes/unusedresult" +) + +func main() { + unitchecker.Main( + asmdecl.Analyzer, + assign.Analyzer, + atomic.Analyzer, + bools.Analyzer, + buildtag.Analyzer, + cgocall.Analyzer, + composite.Analyzer, + copylock.Analyzer, + httpresponse.Analyzer, + loopclosure.Analyzer, + lostcancel.Analyzer, + nilfunc.Analyzer, + printf.Analyzer, + shift.Analyzer, + stdmethods.Analyzer, + structtag.Analyzer, + tests.Analyzer, + unmarshal.Analyzer, + unreachable.Analyzer, + unsafeptr.Analyzer, + unusedresult.Analyzer, + ) +} diff --git a/libgo/go/golang.org/x/tools/go/analysis/unitchecker/unitchecker.go b/libgo/go/golang.org/x/tools/go/analysis/unitchecker/unitchecker.go new file mode 100644 index 00000000000..76dabc28b90 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/unitchecker/unitchecker.go @@ -0,0 +1,387 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// The unitchecker package defines the main function for an analysis +// driver that analyzes a single compilation unit during a build. +// It is invoked by a build system such as "go vet": +// +// $ go vet -vettool=$(which vet) +// +// It supports the following command-line protocol: +// +// -V=full describe executable (to the build tool) +// -flags describe flags (to the build tool) +// foo.cfg description of compilation unit (from the build tool) +// +// This package does not depend on go/packages. +// If you need a standalone tool, use multichecker, +// which supports this mode but can also load packages +// from source using go/packages. +package unitchecker + +// TODO(adonovan): +// - with gccgo, go build does not build standard library, +// so we will not get to analyze it. Yet we must in order +// to create base facts for, say, the fmt package for the +// printf checker. + +import ( + "encoding/gob" + "encoding/json" + "flag" + "fmt" + "go/ast" + "go/build" + "go/importer" + "go/parser" + "go/token" + "go/types" + "io" + "io/ioutil" + "log" + "os" + "path/filepath" + "sort" + "strings" + "sync" + "time" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/internal/analysisflags" + "golang.org/x/tools/go/analysis/internal/facts" +) + +// A Config describes a compilation unit to be analyzed. +// It is provided to the tool in a JSON-encoded file +// whose name ends with ".cfg". +type Config struct { + ID string // e.g. "fmt [fmt.test]" + Compiler string + Dir string + ImportPath string + GoFiles []string + NonGoFiles []string + ImportMap map[string]string + PackageFile map[string]string + Standard map[string]bool + PackageVetx map[string]string + VetxOnly bool + VetxOutput string + SucceedOnTypecheckFailure bool +} + +// Main is the main function of a vet-like analysis tool that must be +// invoked by a build system to analyze a single package. +// +// The protocol required by 'go vet -vettool=...' is that the tool must support: +// +// -flags describe flags in JSON +// -V=full describe executable for build caching +// foo.cfg perform separate modular analyze on the single +// unit described by a JSON config file foo.cfg. +// +func Main(analyzers ...*analysis.Analyzer) { + progname := filepath.Base(os.Args[0]) + log.SetFlags(0) + log.SetPrefix(progname + ": ") + + if err := analysis.Validate(analyzers); err != nil { + log.Fatal(err) + } + + flag.Usage = func() { + fmt.Fprintf(os.Stderr, `%[1]s is a tool for static analysis of Go programs. + +Usage of %[1]s: + %.16[1]s unit.cfg # execute analysis specified by config file + %.16[1]s help # general help + %.16[1]s help name # help on specific analyzer and its flags +`, progname) + os.Exit(1) + } + + analyzers = analysisflags.Parse(analyzers, true) + + args := flag.Args() + if len(args) == 0 { + flag.Usage() + } + if args[0] == "help" { + analysisflags.Help(progname, analyzers, args[1:]) + os.Exit(0) + } + if len(args) != 1 || !strings.HasSuffix(args[0], ".cfg") { + log.Fatalf(`invoking "go tool vet" directly is unsupported; use "go vet"`) + } + Run(args[0], analyzers) +} + +// Run reads the *.cfg file, runs the analysis, +// and calls os.Exit with an appropriate error code. +// It assumes flags have already been set. +func Run(configFile string, analyzers []*analysis.Analyzer) { + cfg, err := readConfig(configFile) + if err != nil { + log.Fatal(err) + } + + fset := token.NewFileSet() + results, err := run(fset, cfg, analyzers) + if err != nil { + log.Fatal(err) + } + + // In VetxOnly mode, the analysis is run only for facts. + if !cfg.VetxOnly { + if analysisflags.JSON { + // JSON output + tree := make(analysisflags.JSONTree) + for _, res := range results { + tree.Add(fset, cfg.ID, res.a.Name, res.diagnostics, res.err) + } + tree.Print() + } else { + // plain text + exit := 0 + for _, res := range results { + if res.err != nil { + log.Println(res.err) + exit = 1 + } + } + for _, res := range results { + for _, diag := range res.diagnostics { + analysisflags.PrintPlain(fset, diag) + exit = 1 + } + } + os.Exit(exit) + } + } + + os.Exit(0) +} + +func readConfig(filename string) (*Config, error) { + data, err := ioutil.ReadFile(filename) + if err != nil { + return nil, err + } + cfg := new(Config) + if err := json.Unmarshal(data, cfg); err != nil { + return nil, fmt.Errorf("cannot decode JSON config file %s: %v", filename, err) + } + if len(cfg.GoFiles) == 0 { + // The go command disallows packages with no files. + // The only exception is unsafe, but the go command + // doesn't call vet on it. + return nil, fmt.Errorf("package has no files: %s", cfg.ImportPath) + } + return cfg, nil +} + +var importerForCompiler = func(_ *token.FileSet, compiler string, lookup importer.Lookup) types.Importer { + // broken legacy implementation (https://golang.org/issue/28995) + return importer.For(compiler, lookup) +} + +func run(fset *token.FileSet, cfg *Config, analyzers []*analysis.Analyzer) ([]result, error) { + // Load, parse, typecheck. + var files []*ast.File + for _, name := range cfg.GoFiles { + f, err := parser.ParseFile(fset, name, nil, parser.ParseComments) + if err != nil { + if cfg.SucceedOnTypecheckFailure { + // Silently succeed; let the compiler + // report parse errors. + err = nil + } + return nil, err + } + files = append(files, f) + } + compilerImporter := importerForCompiler(fset, cfg.Compiler, func(path string) (io.ReadCloser, error) { + // path is a resolved package path, not an import path. + file, ok := cfg.PackageFile[path] + if !ok { + if cfg.Compiler == "gccgo" && cfg.Standard[path] { + return nil, nil // fall back to default gccgo lookup + } + return nil, fmt.Errorf("no package file for %q", path) + } + return os.Open(file) + }) + importer := importerFunc(func(importPath string) (*types.Package, error) { + path, ok := cfg.ImportMap[importPath] // resolve vendoring, etc + if !ok { + return nil, fmt.Errorf("can't resolve import %q", path) + } + return compilerImporter.Import(path) + }) + tc := &types.Config{ + Importer: importer, + Sizes: types.SizesFor("gc", build.Default.GOARCH), // assume gccgo ≡ gc? + } + info := &types.Info{ + Types: make(map[ast.Expr]types.TypeAndValue), + Defs: make(map[*ast.Ident]types.Object), + Uses: make(map[*ast.Ident]types.Object), + Implicits: make(map[ast.Node]types.Object), + Scopes: make(map[ast.Node]*types.Scope), + Selections: make(map[*ast.SelectorExpr]*types.Selection), + } + pkg, err := tc.Check(cfg.ImportPath, fset, files, info) + if err != nil { + if cfg.SucceedOnTypecheckFailure { + // Silently succeed; let the compiler + // report type errors. + err = nil + } + return nil, err + } + + // Register fact types with gob. + // In VetxOnly mode, analyzers are only for their facts, + // so we can skip any analysis that neither produces facts + // nor depends on any analysis that produces facts. + // Also build a map to hold working state and result. + type action struct { + once sync.Once + result interface{} + err error + usesFacts bool // (transitively uses) + diagnostics []analysis.Diagnostic + } + actions := make(map[*analysis.Analyzer]*action) + var registerFacts func(a *analysis.Analyzer) bool + registerFacts = func(a *analysis.Analyzer) bool { + act, ok := actions[a] + if !ok { + act = new(action) + var usesFacts bool + for _, f := range a.FactTypes { + usesFacts = true + gob.Register(f) + } + for _, req := range a.Requires { + if registerFacts(req) { + usesFacts = true + } + } + act.usesFacts = usesFacts + actions[a] = act + } + return act.usesFacts + } + var filtered []*analysis.Analyzer + for _, a := range analyzers { + if registerFacts(a) || !cfg.VetxOnly { + filtered = append(filtered, a) + } + } + analyzers = filtered + + // Read facts from imported packages. + read := func(path string) ([]byte, error) { + if vetx, ok := cfg.PackageVetx[path]; ok { + return ioutil.ReadFile(vetx) + } + return nil, nil // no .vetx file, no facts + } + facts, err := facts.Decode(pkg, read) + if err != nil { + return nil, err + } + + // In parallel, execute the DAG of analyzers. + var exec func(a *analysis.Analyzer) *action + var execAll func(analyzers []*analysis.Analyzer) + exec = func(a *analysis.Analyzer) *action { + act := actions[a] + act.once.Do(func() { + execAll(a.Requires) // prefetch dependencies in parallel + + // The inputs to this analysis are the + // results of its prerequisites. + inputs := make(map[*analysis.Analyzer]interface{}) + var failed []string + for _, req := range a.Requires { + reqact := exec(req) + if reqact.err != nil { + failed = append(failed, req.String()) + continue + } + inputs[req] = reqact.result + } + + // Report an error if any dependency failed. + if failed != nil { + sort.Strings(failed) + act.err = fmt.Errorf("failed prerequisites: %s", strings.Join(failed, ", ")) + return + } + + pass := &analysis.Pass{ + Analyzer: a, + Fset: fset, + Files: files, + OtherFiles: cfg.NonGoFiles, + Pkg: pkg, + TypesInfo: info, + ResultOf: inputs, + Report: func(d analysis.Diagnostic) { act.diagnostics = append(act.diagnostics, d) }, + ImportObjectFact: facts.ImportObjectFact, + ExportObjectFact: facts.ExportObjectFact, + ImportPackageFact: facts.ImportPackageFact, + ExportPackageFact: facts.ExportPackageFact, + } + + t0 := time.Now() + act.result, act.err = a.Run(pass) + if false { + log.Printf("analysis %s = %s", pass, time.Since(t0)) + } + }) + return act + } + execAll = func(analyzers []*analysis.Analyzer) { + var wg sync.WaitGroup + for _, a := range analyzers { + wg.Add(1) + go func(a *analysis.Analyzer) { + _ = exec(a) + wg.Done() + }(a) + } + wg.Wait() + } + + execAll(analyzers) + + // Return diagnostics and errors from root analyzers. + results := make([]result, len(analyzers)) + for i, a := range analyzers { + act := actions[a] + results[i].a = a + results[i].err = act.err + results[i].diagnostics = act.diagnostics + } + + data := facts.Encode() + if err := ioutil.WriteFile(cfg.VetxOutput, data, 0666); err != nil { + return nil, fmt.Errorf("failed to write analysis facts: %v", err) + } + + return results, nil +} + +type result struct { + a *analysis.Analyzer + diagnostics []analysis.Diagnostic + err error +} + +type importerFunc func(path string) (*types.Package, error) + +func (f importerFunc) Import(path string) (*types.Package, error) { return f(path) } diff --git a/libgo/go/golang.org/x/tools/go/analysis/unitchecker/unitchecker112.go b/libgo/go/golang.org/x/tools/go/analysis/unitchecker/unitchecker112.go new file mode 100644 index 00000000000..683b7e91d25 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/unitchecker/unitchecker112.go @@ -0,0 +1,9 @@ +// +build go1.12 + +package unitchecker + +import "go/importer" + +func init() { + importerForCompiler = importer.ForCompiler +} diff --git a/libgo/go/golang.org/x/tools/go/analysis/validate.go b/libgo/go/golang.org/x/tools/go/analysis/validate.go new file mode 100644 index 00000000000..6e6cf4984fe --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/analysis/validate.go @@ -0,0 +1,104 @@ +package analysis + +import ( + "fmt" + "reflect" + "unicode" +) + +// Validate reports an error if any of the analyzers are misconfigured. +// Checks include: +// that the name is a valid identifier; +// that analyzer names are unique; +// that the Requires graph is acylic; +// that analyzer fact types are unique; +// that each fact type is a pointer. +func Validate(analyzers []*Analyzer) error { + names := make(map[string]bool) + + // Map each fact type to its sole generating analyzer. + factTypes := make(map[reflect.Type]*Analyzer) + + // Traverse the Requires graph, depth first. + const ( + white = iota + grey + black + finished + ) + color := make(map[*Analyzer]uint8) + var visit func(a *Analyzer) error + visit = func(a *Analyzer) error { + if a == nil { + return fmt.Errorf("nil *Analyzer") + } + if color[a] == white { + color[a] = grey + + // names + if !validIdent(a.Name) { + return fmt.Errorf("invalid analyzer name %q", a) + } + if names[a.Name] { + return fmt.Errorf("duplicate analyzer name %q", a) + } + names[a.Name] = true + + if a.Doc == "" { + return fmt.Errorf("analyzer %q is undocumented", a) + } + + // fact types + for _, f := range a.FactTypes { + if f == nil { + return fmt.Errorf("analyzer %s has nil FactType", a) + } + t := reflect.TypeOf(f) + if prev := factTypes[t]; prev != nil { + return fmt.Errorf("fact type %s registered by two analyzers: %v, %v", + t, a, prev) + } + if t.Kind() != reflect.Ptr { + return fmt.Errorf("%s: fact type %s is not a pointer", a, t) + } + factTypes[t] = a + } + + // recursion + for i, req := range a.Requires { + if err := visit(req); err != nil { + return fmt.Errorf("%s.Requires[%d]: %v", a.Name, i, err) + } + } + color[a] = black + } + + return nil + } + for _, a := range analyzers { + if err := visit(a); err != nil { + return err + } + } + + // Reject duplicates among analyzers. + // Precondition: color[a] == black. + // Postcondition: color[a] == finished. + for _, a := range analyzers { + if color[a] == finished { + return fmt.Errorf("duplicate analyzer: %s", a.Name) + } + color[a] = finished + } + + return nil +} + +func validIdent(name string) bool { + for i, r := range name { + if !(r == '_' || unicode.IsLetter(r) || i > 0 && unicode.IsDigit(r)) { + return false + } + } + return name != "" +} diff --git a/libgo/go/golang.org/x/tools/go/ast/astutil/enclosing.go b/libgo/go/golang.org/x/tools/go/ast/astutil/enclosing.go new file mode 100644 index 00000000000..6b7052b892c --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/ast/astutil/enclosing.go @@ -0,0 +1,627 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package astutil + +// This file defines utilities for working with source positions. + +import ( + "fmt" + "go/ast" + "go/token" + "sort" +) + +// PathEnclosingInterval returns the node that encloses the source +// interval [start, end), and all its ancestors up to the AST root. +// +// The definition of "enclosing" used by this function considers +// additional whitespace abutting a node to be enclosed by it. +// In this example: +// +// z := x + y // add them +// <-A-> +// <----B-----> +// +// the ast.BinaryExpr(+) node is considered to enclose interval B +// even though its [Pos()..End()) is actually only interval A. +// This behaviour makes user interfaces more tolerant of imperfect +// input. +// +// This function treats tokens as nodes, though they are not included +// in the result. e.g. PathEnclosingInterval("+") returns the +// enclosing ast.BinaryExpr("x + y"). +// +// If start==end, the 1-char interval following start is used instead. +// +// The 'exact' result is true if the interval contains only path[0] +// and perhaps some adjacent whitespace. It is false if the interval +// overlaps multiple children of path[0], or if it contains only +// interior whitespace of path[0]. +// In this example: +// +// z := x + y // add them +// <--C--> <---E--> +// ^ +// D +// +// intervals C, D and E are inexact. C is contained by the +// z-assignment statement, because it spans three of its children (:=, +// x, +). So too is the 1-char interval D, because it contains only +// interior whitespace of the assignment. E is considered interior +// whitespace of the BlockStmt containing the assignment. +// +// Precondition: [start, end) both lie within the same file as root. +// TODO(adonovan): return (nil, false) in this case and remove precond. +// Requires FileSet; see loader.tokenFileContainsPos. +// +// Postcondition: path is never nil; it always contains at least 'root'. +// +func PathEnclosingInterval(root *ast.File, start, end token.Pos) (path []ast.Node, exact bool) { + // fmt.Printf("EnclosingInterval %d %d\n", start, end) // debugging + + // Precondition: node.[Pos..End) and adjoining whitespace contain [start, end). + var visit func(node ast.Node) bool + visit = func(node ast.Node) bool { + path = append(path, node) + + nodePos := node.Pos() + nodeEnd := node.End() + + // fmt.Printf("visit(%T, %d, %d)\n", node, nodePos, nodeEnd) // debugging + + // Intersect [start, end) with interval of node. + if start < nodePos { + start = nodePos + } + if end > nodeEnd { + end = nodeEnd + } + + // Find sole child that contains [start, end). + children := childrenOf(node) + l := len(children) + for i, child := range children { + // [childPos, childEnd) is unaugmented interval of child. + childPos := child.Pos() + childEnd := child.End() + + // [augPos, augEnd) is whitespace-augmented interval of child. + augPos := childPos + augEnd := childEnd + if i > 0 { + augPos = children[i-1].End() // start of preceding whitespace + } + if i < l-1 { + nextChildPos := children[i+1].Pos() + // Does [start, end) lie between child and next child? + if start >= augEnd && end <= nextChildPos { + return false // inexact match + } + augEnd = nextChildPos // end of following whitespace + } + + // fmt.Printf("\tchild %d: [%d..%d)\tcontains interval [%d..%d)?\n", + // i, augPos, augEnd, start, end) // debugging + + // Does augmented child strictly contain [start, end)? + if augPos <= start && end <= augEnd { + _, isToken := child.(tokenNode) + return isToken || visit(child) + } + + // Does [start, end) overlap multiple children? + // i.e. left-augmented child contains start + // but LR-augmented child does not contain end. + if start < childEnd && end > augEnd { + break + } + } + + // No single child contained [start, end), + // so node is the result. Is it exact? + + // (It's tempting to put this condition before the + // child loop, but it gives the wrong result in the + // case where a node (e.g. ExprStmt) and its sole + // child have equal intervals.) + if start == nodePos && end == nodeEnd { + return true // exact match + } + + return false // inexact: overlaps multiple children + } + + if start > end { + start, end = end, start + } + + if start < root.End() && end > root.Pos() { + if start == end { + end = start + 1 // empty interval => interval of size 1 + } + exact = visit(root) + + // Reverse the path: + for i, l := 0, len(path); i < l/2; i++ { + path[i], path[l-1-i] = path[l-1-i], path[i] + } + } else { + // Selection lies within whitespace preceding the + // first (or following the last) declaration in the file. + // The result nonetheless always includes the ast.File. + path = append(path, root) + } + + return +} + +// tokenNode is a dummy implementation of ast.Node for a single token. +// They are used transiently by PathEnclosingInterval but never escape +// this package. +// +type tokenNode struct { + pos token.Pos + end token.Pos +} + +func (n tokenNode) Pos() token.Pos { + return n.pos +} + +func (n tokenNode) End() token.Pos { + return n.end +} + +func tok(pos token.Pos, len int) ast.Node { + return tokenNode{pos, pos + token.Pos(len)} +} + +// childrenOf returns the direct non-nil children of ast.Node n. +// It may include fake ast.Node implementations for bare tokens. +// it is not safe to call (e.g.) ast.Walk on such nodes. +// +func childrenOf(n ast.Node) []ast.Node { + var children []ast.Node + + // First add nodes for all true subtrees. + ast.Inspect(n, func(node ast.Node) bool { + if node == n { // push n + return true // recur + } + if node != nil { // push child + children = append(children, node) + } + return false // no recursion + }) + + // Then add fake Nodes for bare tokens. + switch n := n.(type) { + case *ast.ArrayType: + children = append(children, + tok(n.Lbrack, len("[")), + tok(n.Elt.End(), len("]"))) + + case *ast.AssignStmt: + children = append(children, + tok(n.TokPos, len(n.Tok.String()))) + + case *ast.BasicLit: + children = append(children, + tok(n.ValuePos, len(n.Value))) + + case *ast.BinaryExpr: + children = append(children, tok(n.OpPos, len(n.Op.String()))) + + case *ast.BlockStmt: + children = append(children, + tok(n.Lbrace, len("{")), + tok(n.Rbrace, len("}"))) + + case *ast.BranchStmt: + children = append(children, + tok(n.TokPos, len(n.Tok.String()))) + + case *ast.CallExpr: + children = append(children, + tok(n.Lparen, len("(")), + tok(n.Rparen, len(")"))) + if n.Ellipsis != 0 { + children = append(children, tok(n.Ellipsis, len("..."))) + } + + case *ast.CaseClause: + if n.List == nil { + children = append(children, + tok(n.Case, len("default"))) + } else { + children = append(children, + tok(n.Case, len("case"))) + } + children = append(children, tok(n.Colon, len(":"))) + + case *ast.ChanType: + switch n.Dir { + case ast.RECV: + children = append(children, tok(n.Begin, len("<-chan"))) + case ast.SEND: + children = append(children, tok(n.Begin, len("chan<-"))) + case ast.RECV | ast.SEND: + children = append(children, tok(n.Begin, len("chan"))) + } + + case *ast.CommClause: + if n.Comm == nil { + children = append(children, + tok(n.Case, len("default"))) + } else { + children = append(children, + tok(n.Case, len("case"))) + } + children = append(children, tok(n.Colon, len(":"))) + + case *ast.Comment: + // nop + + case *ast.CommentGroup: + // nop + + case *ast.CompositeLit: + children = append(children, + tok(n.Lbrace, len("{")), + tok(n.Rbrace, len("{"))) + + case *ast.DeclStmt: + // nop + + case *ast.DeferStmt: + children = append(children, + tok(n.Defer, len("defer"))) + + case *ast.Ellipsis: + children = append(children, + tok(n.Ellipsis, len("..."))) + + case *ast.EmptyStmt: + // nop + + case *ast.ExprStmt: + // nop + + case *ast.Field: + // TODO(adonovan): Field.{Doc,Comment,Tag}? + + case *ast.FieldList: + children = append(children, + tok(n.Opening, len("(")), + tok(n.Closing, len(")"))) + + case *ast.File: + // TODO test: Doc + children = append(children, + tok(n.Package, len("package"))) + + case *ast.ForStmt: + children = append(children, + tok(n.For, len("for"))) + + case *ast.FuncDecl: + // TODO(adonovan): FuncDecl.Comment? + + // Uniquely, FuncDecl breaks the invariant that + // preorder traversal yields tokens in lexical order: + // in fact, FuncDecl.Recv precedes FuncDecl.Type.Func. + // + // As a workaround, we inline the case for FuncType + // here and order things correctly. + // + children = nil // discard ast.Walk(FuncDecl) info subtrees + children = append(children, tok(n.Type.Func, len("func"))) + if n.Recv != nil { + children = append(children, n.Recv) + } + children = append(children, n.Name) + if n.Type.Params != nil { + children = append(children, n.Type.Params) + } + if n.Type.Results != nil { + children = append(children, n.Type.Results) + } + if n.Body != nil { + children = append(children, n.Body) + } + + case *ast.FuncLit: + // nop + + case *ast.FuncType: + if n.Func != 0 { + children = append(children, + tok(n.Func, len("func"))) + } + + case *ast.GenDecl: + children = append(children, + tok(n.TokPos, len(n.Tok.String()))) + if n.Lparen != 0 { + children = append(children, + tok(n.Lparen, len("(")), + tok(n.Rparen, len(")"))) + } + + case *ast.GoStmt: + children = append(children, + tok(n.Go, len("go"))) + + case *ast.Ident: + children = append(children, + tok(n.NamePos, len(n.Name))) + + case *ast.IfStmt: + children = append(children, + tok(n.If, len("if"))) + + case *ast.ImportSpec: + // TODO(adonovan): ImportSpec.{Doc,EndPos}? + + case *ast.IncDecStmt: + children = append(children, + tok(n.TokPos, len(n.Tok.String()))) + + case *ast.IndexExpr: + children = append(children, + tok(n.Lbrack, len("{")), + tok(n.Rbrack, len("}"))) + + case *ast.InterfaceType: + children = append(children, + tok(n.Interface, len("interface"))) + + case *ast.KeyValueExpr: + children = append(children, + tok(n.Colon, len(":"))) + + case *ast.LabeledStmt: + children = append(children, + tok(n.Colon, len(":"))) + + case *ast.MapType: + children = append(children, + tok(n.Map, len("map"))) + + case *ast.ParenExpr: + children = append(children, + tok(n.Lparen, len("(")), + tok(n.Rparen, len(")"))) + + case *ast.RangeStmt: + children = append(children, + tok(n.For, len("for")), + tok(n.TokPos, len(n.Tok.String()))) + + case *ast.ReturnStmt: + children = append(children, + tok(n.Return, len("return"))) + + case *ast.SelectStmt: + children = append(children, + tok(n.Select, len("select"))) + + case *ast.SelectorExpr: + // nop + + case *ast.SendStmt: + children = append(children, + tok(n.Arrow, len("<-"))) + + case *ast.SliceExpr: + children = append(children, + tok(n.Lbrack, len("[")), + tok(n.Rbrack, len("]"))) + + case *ast.StarExpr: + children = append(children, tok(n.Star, len("*"))) + + case *ast.StructType: + children = append(children, tok(n.Struct, len("struct"))) + + case *ast.SwitchStmt: + children = append(children, tok(n.Switch, len("switch"))) + + case *ast.TypeAssertExpr: + children = append(children, + tok(n.Lparen-1, len(".")), + tok(n.Lparen, len("(")), + tok(n.Rparen, len(")"))) + + case *ast.TypeSpec: + // TODO(adonovan): TypeSpec.{Doc,Comment}? + + case *ast.TypeSwitchStmt: + children = append(children, tok(n.Switch, len("switch"))) + + case *ast.UnaryExpr: + children = append(children, tok(n.OpPos, len(n.Op.String()))) + + case *ast.ValueSpec: + // TODO(adonovan): ValueSpec.{Doc,Comment}? + + case *ast.BadDecl, *ast.BadExpr, *ast.BadStmt: + // nop + } + + // TODO(adonovan): opt: merge the logic of ast.Inspect() into + // the switch above so we can make interleaved callbacks for + // both Nodes and Tokens in the right order and avoid the need + // to sort. + sort.Sort(byPos(children)) + + return children +} + +type byPos []ast.Node + +func (sl byPos) Len() int { + return len(sl) +} +func (sl byPos) Less(i, j int) bool { + return sl[i].Pos() < sl[j].Pos() +} +func (sl byPos) Swap(i, j int) { + sl[i], sl[j] = sl[j], sl[i] +} + +// NodeDescription returns a description of the concrete type of n suitable +// for a user interface. +// +// TODO(adonovan): in some cases (e.g. Field, FieldList, Ident, +// StarExpr) we could be much more specific given the path to the AST +// root. Perhaps we should do that. +// +func NodeDescription(n ast.Node) string { + switch n := n.(type) { + case *ast.ArrayType: + return "array type" + case *ast.AssignStmt: + return "assignment" + case *ast.BadDecl: + return "bad declaration" + case *ast.BadExpr: + return "bad expression" + case *ast.BadStmt: + return "bad statement" + case *ast.BasicLit: + return "basic literal" + case *ast.BinaryExpr: + return fmt.Sprintf("binary %s operation", n.Op) + case *ast.BlockStmt: + return "block" + case *ast.BranchStmt: + switch n.Tok { + case token.BREAK: + return "break statement" + case token.CONTINUE: + return "continue statement" + case token.GOTO: + return "goto statement" + case token.FALLTHROUGH: + return "fall-through statement" + } + case *ast.CallExpr: + if len(n.Args) == 1 && !n.Ellipsis.IsValid() { + return "function call (or conversion)" + } + return "function call" + case *ast.CaseClause: + return "case clause" + case *ast.ChanType: + return "channel type" + case *ast.CommClause: + return "communication clause" + case *ast.Comment: + return "comment" + case *ast.CommentGroup: + return "comment group" + case *ast.CompositeLit: + return "composite literal" + case *ast.DeclStmt: + return NodeDescription(n.Decl) + " statement" + case *ast.DeferStmt: + return "defer statement" + case *ast.Ellipsis: + return "ellipsis" + case *ast.EmptyStmt: + return "empty statement" + case *ast.ExprStmt: + return "expression statement" + case *ast.Field: + // Can be any of these: + // struct {x, y int} -- struct field(s) + // struct {T} -- anon struct field + // interface {I} -- interface embedding + // interface {f()} -- interface method + // func (A) func(B) C -- receiver, param(s), result(s) + return "field/method/parameter" + case *ast.FieldList: + return "field/method/parameter list" + case *ast.File: + return "source file" + case *ast.ForStmt: + return "for loop" + case *ast.FuncDecl: + return "function declaration" + case *ast.FuncLit: + return "function literal" + case *ast.FuncType: + return "function type" + case *ast.GenDecl: + switch n.Tok { + case token.IMPORT: + return "import declaration" + case token.CONST: + return "constant declaration" + case token.TYPE: + return "type declaration" + case token.VAR: + return "variable declaration" + } + case *ast.GoStmt: + return "go statement" + case *ast.Ident: + return "identifier" + case *ast.IfStmt: + return "if statement" + case *ast.ImportSpec: + return "import specification" + case *ast.IncDecStmt: + if n.Tok == token.INC { + return "increment statement" + } + return "decrement statement" + case *ast.IndexExpr: + return "index expression" + case *ast.InterfaceType: + return "interface type" + case *ast.KeyValueExpr: + return "key/value association" + case *ast.LabeledStmt: + return "statement label" + case *ast.MapType: + return "map type" + case *ast.Package: + return "package" + case *ast.ParenExpr: + return "parenthesized " + NodeDescription(n.X) + case *ast.RangeStmt: + return "range loop" + case *ast.ReturnStmt: + return "return statement" + case *ast.SelectStmt: + return "select statement" + case *ast.SelectorExpr: + return "selector" + case *ast.SendStmt: + return "channel send" + case *ast.SliceExpr: + return "slice expression" + case *ast.StarExpr: + return "*-operation" // load/store expr or pointer type + case *ast.StructType: + return "struct type" + case *ast.SwitchStmt: + return "switch statement" + case *ast.TypeAssertExpr: + return "type assertion" + case *ast.TypeSpec: + return "type specification" + case *ast.TypeSwitchStmt: + return "type switch" + case *ast.UnaryExpr: + return fmt.Sprintf("unary %s operation", n.Op) + case *ast.ValueSpec: + return "value specification" + + } + panic(fmt.Sprintf("unexpected node type: %T", n)) +} diff --git a/libgo/go/golang.org/x/tools/go/ast/astutil/imports.go b/libgo/go/golang.org/x/tools/go/ast/astutil/imports.go new file mode 100644 index 00000000000..3e4b195368b --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/ast/astutil/imports.go @@ -0,0 +1,481 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package astutil contains common utilities for working with the Go AST. +package astutil // import "golang.org/x/tools/go/ast/astutil" + +import ( + "fmt" + "go/ast" + "go/token" + "strconv" + "strings" +) + +// AddImport adds the import path to the file f, if absent. +func AddImport(fset *token.FileSet, f *ast.File, path string) (added bool) { + return AddNamedImport(fset, f, "", path) +} + +// AddNamedImport adds the import with the given name and path to the file f, if absent. +// If name is not empty, it is used to rename the import. +// +// For example, calling +// AddNamedImport(fset, f, "pathpkg", "path") +// adds +// import pathpkg "path" +func AddNamedImport(fset *token.FileSet, f *ast.File, name, path string) (added bool) { + if imports(f, name, path) { + return false + } + + newImport := &ast.ImportSpec{ + Path: &ast.BasicLit{ + Kind: token.STRING, + Value: strconv.Quote(path), + }, + } + if name != "" { + newImport.Name = &ast.Ident{Name: name} + } + + // Find an import decl to add to. + // The goal is to find an existing import + // whose import path has the longest shared + // prefix with path. + var ( + bestMatch = -1 // length of longest shared prefix + lastImport = -1 // index in f.Decls of the file's final import decl + impDecl *ast.GenDecl // import decl containing the best match + impIndex = -1 // spec index in impDecl containing the best match + + isThirdPartyPath = isThirdParty(path) + ) + for i, decl := range f.Decls { + gen, ok := decl.(*ast.GenDecl) + if ok && gen.Tok == token.IMPORT { + lastImport = i + // Do not add to import "C", to avoid disrupting the + // association with its doc comment, breaking cgo. + if declImports(gen, "C") { + continue + } + + // Match an empty import decl if that's all that is available. + if len(gen.Specs) == 0 && bestMatch == -1 { + impDecl = gen + } + + // Compute longest shared prefix with imports in this group and find best + // matched import spec. + // 1. Always prefer import spec with longest shared prefix. + // 2. While match length is 0, + // - for stdlib package: prefer first import spec. + // - for third party package: prefer first third party import spec. + // We cannot use last import spec as best match for third party package + // because grouped imports are usually placed last by goimports -local + // flag. + // See issue #19190. + seenAnyThirdParty := false + for j, spec := range gen.Specs { + impspec := spec.(*ast.ImportSpec) + p := importPath(impspec) + n := matchLen(p, path) + if n > bestMatch || (bestMatch == 0 && !seenAnyThirdParty && isThirdPartyPath) { + bestMatch = n + impDecl = gen + impIndex = j + } + seenAnyThirdParty = seenAnyThirdParty || isThirdParty(p) + } + } + } + + // If no import decl found, add one after the last import. + if impDecl == nil { + impDecl = &ast.GenDecl{ + Tok: token.IMPORT, + } + if lastImport >= 0 { + impDecl.TokPos = f.Decls[lastImport].End() + } else { + // There are no existing imports. + // Our new import, preceded by a blank line, goes after the package declaration + // and after the comment, if any, that starts on the same line as the + // package declaration. + impDecl.TokPos = f.Package + + file := fset.File(f.Package) + pkgLine := file.Line(f.Package) + for _, c := range f.Comments { + if file.Line(c.Pos()) > pkgLine { + break + } + // +2 for a blank line + impDecl.TokPos = c.End() + 2 + } + } + f.Decls = append(f.Decls, nil) + copy(f.Decls[lastImport+2:], f.Decls[lastImport+1:]) + f.Decls[lastImport+1] = impDecl + } + + // Insert new import at insertAt. + insertAt := 0 + if impIndex >= 0 { + // insert after the found import + insertAt = impIndex + 1 + } + impDecl.Specs = append(impDecl.Specs, nil) + copy(impDecl.Specs[insertAt+1:], impDecl.Specs[insertAt:]) + impDecl.Specs[insertAt] = newImport + pos := impDecl.Pos() + if insertAt > 0 { + // If there is a comment after an existing import, preserve the comment + // position by adding the new import after the comment. + if spec, ok := impDecl.Specs[insertAt-1].(*ast.ImportSpec); ok && spec.Comment != nil { + pos = spec.Comment.End() + } else { + // Assign same position as the previous import, + // so that the sorter sees it as being in the same block. + pos = impDecl.Specs[insertAt-1].Pos() + } + } + if newImport.Name != nil { + newImport.Name.NamePos = pos + } + newImport.Path.ValuePos = pos + newImport.EndPos = pos + + // Clean up parens. impDecl contains at least one spec. + if len(impDecl.Specs) == 1 { + // Remove unneeded parens. + impDecl.Lparen = token.NoPos + } else if !impDecl.Lparen.IsValid() { + // impDecl needs parens added. + impDecl.Lparen = impDecl.Specs[0].Pos() + } + + f.Imports = append(f.Imports, newImport) + + if len(f.Decls) <= 1 { + return true + } + + // Merge all the import declarations into the first one. + var first *ast.GenDecl + for i := 0; i < len(f.Decls); i++ { + decl := f.Decls[i] + gen, ok := decl.(*ast.GenDecl) + if !ok || gen.Tok != token.IMPORT || declImports(gen, "C") { + continue + } + if first == nil { + first = gen + continue // Don't touch the first one. + } + // We now know there is more than one package in this import + // declaration. Ensure that it ends up parenthesized. + first.Lparen = first.Pos() + // Move the imports of the other import declaration to the first one. + for _, spec := range gen.Specs { + spec.(*ast.ImportSpec).Path.ValuePos = first.Pos() + first.Specs = append(first.Specs, spec) + } + f.Decls = append(f.Decls[:i], f.Decls[i+1:]...) + i-- + } + + return true +} + +func isThirdParty(importPath string) bool { + // Third party package import path usually contains "." (".com", ".org", ...) + // This logic is taken from golang.org/x/tools/imports package. + return strings.Contains(importPath, ".") +} + +// DeleteImport deletes the import path from the file f, if present. +// If there are duplicate import declarations, all matching ones are deleted. +func DeleteImport(fset *token.FileSet, f *ast.File, path string) (deleted bool) { + return DeleteNamedImport(fset, f, "", path) +} + +// DeleteNamedImport deletes the import with the given name and path from the file f, if present. +// If there are duplicate import declarations, all matching ones are deleted. +func DeleteNamedImport(fset *token.FileSet, f *ast.File, name, path string) (deleted bool) { + var delspecs []*ast.ImportSpec + var delcomments []*ast.CommentGroup + + // Find the import nodes that import path, if any. + for i := 0; i < len(f.Decls); i++ { + decl := f.Decls[i] + gen, ok := decl.(*ast.GenDecl) + if !ok || gen.Tok != token.IMPORT { + continue + } + for j := 0; j < len(gen.Specs); j++ { + spec := gen.Specs[j] + impspec := spec.(*ast.ImportSpec) + if importName(impspec) != name || importPath(impspec) != path { + continue + } + + // We found an import spec that imports path. + // Delete it. + delspecs = append(delspecs, impspec) + deleted = true + copy(gen.Specs[j:], gen.Specs[j+1:]) + gen.Specs = gen.Specs[:len(gen.Specs)-1] + + // If this was the last import spec in this decl, + // delete the decl, too. + if len(gen.Specs) == 0 { + copy(f.Decls[i:], f.Decls[i+1:]) + f.Decls = f.Decls[:len(f.Decls)-1] + i-- + break + } else if len(gen.Specs) == 1 { + if impspec.Doc != nil { + delcomments = append(delcomments, impspec.Doc) + } + if impspec.Comment != nil { + delcomments = append(delcomments, impspec.Comment) + } + for _, cg := range f.Comments { + // Found comment on the same line as the import spec. + if cg.End() < impspec.Pos() && fset.Position(cg.End()).Line == fset.Position(impspec.Pos()).Line { + delcomments = append(delcomments, cg) + break + } + } + + spec := gen.Specs[0].(*ast.ImportSpec) + + // Move the documentation right after the import decl. + if spec.Doc != nil { + for fset.Position(gen.TokPos).Line+1 < fset.Position(spec.Doc.Pos()).Line { + fset.File(gen.TokPos).MergeLine(fset.Position(gen.TokPos).Line) + } + } + for _, cg := range f.Comments { + if cg.End() < spec.Pos() && fset.Position(cg.End()).Line == fset.Position(spec.Pos()).Line { + for fset.Position(gen.TokPos).Line+1 < fset.Position(spec.Pos()).Line { + fset.File(gen.TokPos).MergeLine(fset.Position(gen.TokPos).Line) + } + break + } + } + } + if j > 0 { + lastImpspec := gen.Specs[j-1].(*ast.ImportSpec) + lastLine := fset.Position(lastImpspec.Path.ValuePos).Line + line := fset.Position(impspec.Path.ValuePos).Line + + // We deleted an entry but now there may be + // a blank line-sized hole where the import was. + if line-lastLine > 1 { + // There was a blank line immediately preceding the deleted import, + // so there's no need to close the hole. + // Do nothing. + } else if line != fset.File(gen.Rparen).LineCount() { + // There was no blank line. Close the hole. + fset.File(gen.Rparen).MergeLine(line) + } + } + j-- + } + } + + // Delete imports from f.Imports. + for i := 0; i < len(f.Imports); i++ { + imp := f.Imports[i] + for j, del := range delspecs { + if imp == del { + copy(f.Imports[i:], f.Imports[i+1:]) + f.Imports = f.Imports[:len(f.Imports)-1] + copy(delspecs[j:], delspecs[j+1:]) + delspecs = delspecs[:len(delspecs)-1] + i-- + break + } + } + } + + // Delete comments from f.Comments. + for i := 0; i < len(f.Comments); i++ { + cg := f.Comments[i] + for j, del := range delcomments { + if cg == del { + copy(f.Comments[i:], f.Comments[i+1:]) + f.Comments = f.Comments[:len(f.Comments)-1] + copy(delcomments[j:], delcomments[j+1:]) + delcomments = delcomments[:len(delcomments)-1] + i-- + break + } + } + } + + if len(delspecs) > 0 { + panic(fmt.Sprintf("deleted specs from Decls but not Imports: %v", delspecs)) + } + + return +} + +// RewriteImport rewrites any import of path oldPath to path newPath. +func RewriteImport(fset *token.FileSet, f *ast.File, oldPath, newPath string) (rewrote bool) { + for _, imp := range f.Imports { + if importPath(imp) == oldPath { + rewrote = true + // record old End, because the default is to compute + // it using the length of imp.Path.Value. + imp.EndPos = imp.End() + imp.Path.Value = strconv.Quote(newPath) + } + } + return +} + +// UsesImport reports whether a given import is used. +func UsesImport(f *ast.File, path string) (used bool) { + spec := importSpec(f, path) + if spec == nil { + return + } + + name := spec.Name.String() + switch name { + case "": + // If the package name is not explicitly specified, + // make an educated guess. This is not guaranteed to be correct. + lastSlash := strings.LastIndex(path, "/") + if lastSlash == -1 { + name = path + } else { + name = path[lastSlash+1:] + } + case "_", ".": + // Not sure if this import is used - err on the side of caution. + return true + } + + ast.Walk(visitFn(func(n ast.Node) { + sel, ok := n.(*ast.SelectorExpr) + if ok && isTopName(sel.X, name) { + used = true + } + }), f) + + return +} + +type visitFn func(node ast.Node) + +func (fn visitFn) Visit(node ast.Node) ast.Visitor { + fn(node) + return fn +} + +// imports reports whether f has an import with the specified name and path. +func imports(f *ast.File, name, path string) bool { + for _, s := range f.Imports { + if importName(s) == name && importPath(s) == path { + return true + } + } + return false +} + +// importSpec returns the import spec if f imports path, +// or nil otherwise. +func importSpec(f *ast.File, path string) *ast.ImportSpec { + for _, s := range f.Imports { + if importPath(s) == path { + return s + } + } + return nil +} + +// importName returns the name of s, +// or "" if the import is not named. +func importName(s *ast.ImportSpec) string { + if s.Name == nil { + return "" + } + return s.Name.Name +} + +// importPath returns the unquoted import path of s, +// or "" if the path is not properly quoted. +func importPath(s *ast.ImportSpec) string { + t, err := strconv.Unquote(s.Path.Value) + if err != nil { + return "" + } + return t +} + +// declImports reports whether gen contains an import of path. +func declImports(gen *ast.GenDecl, path string) bool { + if gen.Tok != token.IMPORT { + return false + } + for _, spec := range gen.Specs { + impspec := spec.(*ast.ImportSpec) + if importPath(impspec) == path { + return true + } + } + return false +} + +// matchLen returns the length of the longest path segment prefix shared by x and y. +func matchLen(x, y string) int { + n := 0 + for i := 0; i < len(x) && i < len(y) && x[i] == y[i]; i++ { + if x[i] == '/' { + n++ + } + } + return n +} + +// isTopName returns true if n is a top-level unresolved identifier with the given name. +func isTopName(n ast.Expr, name string) bool { + id, ok := n.(*ast.Ident) + return ok && id.Name == name && id.Obj == nil +} + +// Imports returns the file imports grouped by paragraph. +func Imports(fset *token.FileSet, f *ast.File) [][]*ast.ImportSpec { + var groups [][]*ast.ImportSpec + + for _, decl := range f.Decls { + genDecl, ok := decl.(*ast.GenDecl) + if !ok || genDecl.Tok != token.IMPORT { + break + } + + group := []*ast.ImportSpec{} + + var lastLine int + for _, spec := range genDecl.Specs { + importSpec := spec.(*ast.ImportSpec) + pos := importSpec.Path.ValuePos + line := fset.Position(pos).Line + if lastLine > 0 && pos > 0 && line-lastLine > 1 { + groups = append(groups, group) + group = []*ast.ImportSpec{} + } + group = append(group, importSpec) + lastLine = line + } + groups = append(groups, group) + } + + return groups +} diff --git a/libgo/go/golang.org/x/tools/go/ast/astutil/rewrite.go b/libgo/go/golang.org/x/tools/go/ast/astutil/rewrite.go new file mode 100644 index 00000000000..cf72ea990bd --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/ast/astutil/rewrite.go @@ -0,0 +1,477 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package astutil + +import ( + "fmt" + "go/ast" + "reflect" + "sort" +) + +// An ApplyFunc is invoked by Apply for each node n, even if n is nil, +// before and/or after the node's children, using a Cursor describing +// the current node and providing operations on it. +// +// The return value of ApplyFunc controls the syntax tree traversal. +// See Apply for details. +type ApplyFunc func(*Cursor) bool + +// Apply traverses a syntax tree recursively, starting with root, +// and calling pre and post for each node as described below. +// Apply returns the syntax tree, possibly modified. +// +// If pre is not nil, it is called for each node before the node's +// children are traversed (pre-order). If pre returns false, no +// children are traversed, and post is not called for that node. +// +// If post is not nil, and a prior call of pre didn't return false, +// post is called for each node after its children are traversed +// (post-order). If post returns false, traversal is terminated and +// Apply returns immediately. +// +// Only fields that refer to AST nodes are considered children; +// i.e., token.Pos, Scopes, Objects, and fields of basic types +// (strings, etc.) are ignored. +// +// Children are traversed in the order in which they appear in the +// respective node's struct definition. A package's files are +// traversed in the filenames' alphabetical order. +// +func Apply(root ast.Node, pre, post ApplyFunc) (result ast.Node) { + parent := &struct{ ast.Node }{root} + defer func() { + if r := recover(); r != nil && r != abort { + panic(r) + } + result = parent.Node + }() + a := &application{pre: pre, post: post} + a.apply(parent, "Node", nil, root) + return +} + +var abort = new(int) // singleton, to signal termination of Apply + +// A Cursor describes a node encountered during Apply. +// Information about the node and its parent is available +// from the Node, Parent, Name, and Index methods. +// +// If p is a variable of type and value of the current parent node +// c.Parent(), and f is the field identifier with name c.Name(), +// the following invariants hold: +// +// p.f == c.Node() if c.Index() < 0 +// p.f[c.Index()] == c.Node() if c.Index() >= 0 +// +// The methods Replace, Delete, InsertBefore, and InsertAfter +// can be used to change the AST without disrupting Apply. +type Cursor struct { + parent ast.Node + name string + iter *iterator // valid if non-nil + node ast.Node +} + +// Node returns the current Node. +func (c *Cursor) Node() ast.Node { return c.node } + +// Parent returns the parent of the current Node. +func (c *Cursor) Parent() ast.Node { return c.parent } + +// Name returns the name of the parent Node field that contains the current Node. +// If the parent is a *ast.Package and the current Node is a *ast.File, Name returns +// the filename for the current Node. +func (c *Cursor) Name() string { return c.name } + +// Index reports the index >= 0 of the current Node in the slice of Nodes that +// contains it, or a value < 0 if the current Node is not part of a slice. +// The index of the current node changes if InsertBefore is called while +// processing the current node. +func (c *Cursor) Index() int { + if c.iter != nil { + return c.iter.index + } + return -1 +} + +// field returns the current node's parent field value. +func (c *Cursor) field() reflect.Value { + return reflect.Indirect(reflect.ValueOf(c.parent)).FieldByName(c.name) +} + +// Replace replaces the current Node with n. +// The replacement node is not walked by Apply. +func (c *Cursor) Replace(n ast.Node) { + if _, ok := c.node.(*ast.File); ok { + file, ok := n.(*ast.File) + if !ok { + panic("attempt to replace *ast.File with non-*ast.File") + } + c.parent.(*ast.Package).Files[c.name] = file + return + } + + v := c.field() + if i := c.Index(); i >= 0 { + v = v.Index(i) + } + v.Set(reflect.ValueOf(n)) +} + +// Delete deletes the current Node from its containing slice. +// If the current Node is not part of a slice, Delete panics. +// As a special case, if the current node is a package file, +// Delete removes it from the package's Files map. +func (c *Cursor) Delete() { + if _, ok := c.node.(*ast.File); ok { + delete(c.parent.(*ast.Package).Files, c.name) + return + } + + i := c.Index() + if i < 0 { + panic("Delete node not contained in slice") + } + v := c.field() + l := v.Len() + reflect.Copy(v.Slice(i, l), v.Slice(i+1, l)) + v.Index(l - 1).Set(reflect.Zero(v.Type().Elem())) + v.SetLen(l - 1) + c.iter.step-- +} + +// InsertAfter inserts n after the current Node in its containing slice. +// If the current Node is not part of a slice, InsertAfter panics. +// Apply does not walk n. +func (c *Cursor) InsertAfter(n ast.Node) { + i := c.Index() + if i < 0 { + panic("InsertAfter node not contained in slice") + } + v := c.field() + v.Set(reflect.Append(v, reflect.Zero(v.Type().Elem()))) + l := v.Len() + reflect.Copy(v.Slice(i+2, l), v.Slice(i+1, l)) + v.Index(i + 1).Set(reflect.ValueOf(n)) + c.iter.step++ +} + +// InsertBefore inserts n before the current Node in its containing slice. +// If the current Node is not part of a slice, InsertBefore panics. +// Apply will not walk n. +func (c *Cursor) InsertBefore(n ast.Node) { + i := c.Index() + if i < 0 { + panic("InsertBefore node not contained in slice") + } + v := c.field() + v.Set(reflect.Append(v, reflect.Zero(v.Type().Elem()))) + l := v.Len() + reflect.Copy(v.Slice(i+1, l), v.Slice(i, l)) + v.Index(i).Set(reflect.ValueOf(n)) + c.iter.index++ +} + +// application carries all the shared data so we can pass it around cheaply. +type application struct { + pre, post ApplyFunc + cursor Cursor + iter iterator +} + +func (a *application) apply(parent ast.Node, name string, iter *iterator, n ast.Node) { + // convert typed nil into untyped nil + if v := reflect.ValueOf(n); v.Kind() == reflect.Ptr && v.IsNil() { + n = nil + } + + // avoid heap-allocating a new cursor for each apply call; reuse a.cursor instead + saved := a.cursor + a.cursor.parent = parent + a.cursor.name = name + a.cursor.iter = iter + a.cursor.node = n + + if a.pre != nil && !a.pre(&a.cursor) { + a.cursor = saved + return + } + + // walk children + // (the order of the cases matches the order of the corresponding node types in go/ast) + switch n := n.(type) { + case nil: + // nothing to do + + // Comments and fields + case *ast.Comment: + // nothing to do + + case *ast.CommentGroup: + if n != nil { + a.applyList(n, "List") + } + + case *ast.Field: + a.apply(n, "Doc", nil, n.Doc) + a.applyList(n, "Names") + a.apply(n, "Type", nil, n.Type) + a.apply(n, "Tag", nil, n.Tag) + a.apply(n, "Comment", nil, n.Comment) + + case *ast.FieldList: + a.applyList(n, "List") + + // Expressions + case *ast.BadExpr, *ast.Ident, *ast.BasicLit: + // nothing to do + + case *ast.Ellipsis: + a.apply(n, "Elt", nil, n.Elt) + + case *ast.FuncLit: + a.apply(n, "Type", nil, n.Type) + a.apply(n, "Body", nil, n.Body) + + case *ast.CompositeLit: + a.apply(n, "Type", nil, n.Type) + a.applyList(n, "Elts") + + case *ast.ParenExpr: + a.apply(n, "X", nil, n.X) + + case *ast.SelectorExpr: + a.apply(n, "X", nil, n.X) + a.apply(n, "Sel", nil, n.Sel) + + case *ast.IndexExpr: + a.apply(n, "X", nil, n.X) + a.apply(n, "Index", nil, n.Index) + + case *ast.SliceExpr: + a.apply(n, "X", nil, n.X) + a.apply(n, "Low", nil, n.Low) + a.apply(n, "High", nil, n.High) + a.apply(n, "Max", nil, n.Max) + + case *ast.TypeAssertExpr: + a.apply(n, "X", nil, n.X) + a.apply(n, "Type", nil, n.Type) + + case *ast.CallExpr: + a.apply(n, "Fun", nil, n.Fun) + a.applyList(n, "Args") + + case *ast.StarExpr: + a.apply(n, "X", nil, n.X) + + case *ast.UnaryExpr: + a.apply(n, "X", nil, n.X) + + case *ast.BinaryExpr: + a.apply(n, "X", nil, n.X) + a.apply(n, "Y", nil, n.Y) + + case *ast.KeyValueExpr: + a.apply(n, "Key", nil, n.Key) + a.apply(n, "Value", nil, n.Value) + + // Types + case *ast.ArrayType: + a.apply(n, "Len", nil, n.Len) + a.apply(n, "Elt", nil, n.Elt) + + case *ast.StructType: + a.apply(n, "Fields", nil, n.Fields) + + case *ast.FuncType: + a.apply(n, "Params", nil, n.Params) + a.apply(n, "Results", nil, n.Results) + + case *ast.InterfaceType: + a.apply(n, "Methods", nil, n.Methods) + + case *ast.MapType: + a.apply(n, "Key", nil, n.Key) + a.apply(n, "Value", nil, n.Value) + + case *ast.ChanType: + a.apply(n, "Value", nil, n.Value) + + // Statements + case *ast.BadStmt: + // nothing to do + + case *ast.DeclStmt: + a.apply(n, "Decl", nil, n.Decl) + + case *ast.EmptyStmt: + // nothing to do + + case *ast.LabeledStmt: + a.apply(n, "Label", nil, n.Label) + a.apply(n, "Stmt", nil, n.Stmt) + + case *ast.ExprStmt: + a.apply(n, "X", nil, n.X) + + case *ast.SendStmt: + a.apply(n, "Chan", nil, n.Chan) + a.apply(n, "Value", nil, n.Value) + + case *ast.IncDecStmt: + a.apply(n, "X", nil, n.X) + + case *ast.AssignStmt: + a.applyList(n, "Lhs") + a.applyList(n, "Rhs") + + case *ast.GoStmt: + a.apply(n, "Call", nil, n.Call) + + case *ast.DeferStmt: + a.apply(n, "Call", nil, n.Call) + + case *ast.ReturnStmt: + a.applyList(n, "Results") + + case *ast.BranchStmt: + a.apply(n, "Label", nil, n.Label) + + case *ast.BlockStmt: + a.applyList(n, "List") + + case *ast.IfStmt: + a.apply(n, "Init", nil, n.Init) + a.apply(n, "Cond", nil, n.Cond) + a.apply(n, "Body", nil, n.Body) + a.apply(n, "Else", nil, n.Else) + + case *ast.CaseClause: + a.applyList(n, "List") + a.applyList(n, "Body") + + case *ast.SwitchStmt: + a.apply(n, "Init", nil, n.Init) + a.apply(n, "Tag", nil, n.Tag) + a.apply(n, "Body", nil, n.Body) + + case *ast.TypeSwitchStmt: + a.apply(n, "Init", nil, n.Init) + a.apply(n, "Assign", nil, n.Assign) + a.apply(n, "Body", nil, n.Body) + + case *ast.CommClause: + a.apply(n, "Comm", nil, n.Comm) + a.applyList(n, "Body") + + case *ast.SelectStmt: + a.apply(n, "Body", nil, n.Body) + + case *ast.ForStmt: + a.apply(n, "Init", nil, n.Init) + a.apply(n, "Cond", nil, n.Cond) + a.apply(n, "Post", nil, n.Post) + a.apply(n, "Body", nil, n.Body) + + case *ast.RangeStmt: + a.apply(n, "Key", nil, n.Key) + a.apply(n, "Value", nil, n.Value) + a.apply(n, "X", nil, n.X) + a.apply(n, "Body", nil, n.Body) + + // Declarations + case *ast.ImportSpec: + a.apply(n, "Doc", nil, n.Doc) + a.apply(n, "Name", nil, n.Name) + a.apply(n, "Path", nil, n.Path) + a.apply(n, "Comment", nil, n.Comment) + + case *ast.ValueSpec: + a.apply(n, "Doc", nil, n.Doc) + a.applyList(n, "Names") + a.apply(n, "Type", nil, n.Type) + a.applyList(n, "Values") + a.apply(n, "Comment", nil, n.Comment) + + case *ast.TypeSpec: + a.apply(n, "Doc", nil, n.Doc) + a.apply(n, "Name", nil, n.Name) + a.apply(n, "Type", nil, n.Type) + a.apply(n, "Comment", nil, n.Comment) + + case *ast.BadDecl: + // nothing to do + + case *ast.GenDecl: + a.apply(n, "Doc", nil, n.Doc) + a.applyList(n, "Specs") + + case *ast.FuncDecl: + a.apply(n, "Doc", nil, n.Doc) + a.apply(n, "Recv", nil, n.Recv) + a.apply(n, "Name", nil, n.Name) + a.apply(n, "Type", nil, n.Type) + a.apply(n, "Body", nil, n.Body) + + // Files and packages + case *ast.File: + a.apply(n, "Doc", nil, n.Doc) + a.apply(n, "Name", nil, n.Name) + a.applyList(n, "Decls") + // Don't walk n.Comments; they have either been walked already if + // they are Doc comments, or they can be easily walked explicitly. + + case *ast.Package: + // collect and sort names for reproducible behavior + var names []string + for name := range n.Files { + names = append(names, name) + } + sort.Strings(names) + for _, name := range names { + a.apply(n, name, nil, n.Files[name]) + } + + default: + panic(fmt.Sprintf("Apply: unexpected node type %T", n)) + } + + if a.post != nil && !a.post(&a.cursor) { + panic(abort) + } + + a.cursor = saved +} + +// An iterator controls iteration over a slice of nodes. +type iterator struct { + index, step int +} + +func (a *application) applyList(parent ast.Node, name string) { + // avoid heap-allocating a new iterator for each applyList call; reuse a.iter instead + saved := a.iter + a.iter.index = 0 + for { + // must reload parent.name each time, since cursor modifications might change it + v := reflect.Indirect(reflect.ValueOf(parent)).FieldByName(name) + if a.iter.index >= v.Len() { + break + } + + // element x may be nil in a bad AST - be cautious + var x ast.Node + if e := v.Index(a.iter.index); e.IsValid() { + x = e.Interface().(ast.Node) + } + + a.iter.step = 1 + a.apply(parent, name, &a.iter, x) + a.iter.index += a.iter.step + } + a.iter = saved +} diff --git a/libgo/go/golang.org/x/tools/go/ast/astutil/util.go b/libgo/go/golang.org/x/tools/go/ast/astutil/util.go new file mode 100644 index 00000000000..7630629824a --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/ast/astutil/util.go @@ -0,0 +1,14 @@ +package astutil + +import "go/ast" + +// Unparen returns e with any enclosing parentheses stripped. +func Unparen(e ast.Expr) ast.Expr { + for { + p, ok := e.(*ast.ParenExpr) + if !ok { + return e + } + e = p.X + } +} diff --git a/libgo/go/golang.org/x/tools/go/ast/inspector/inspector.go b/libgo/go/golang.org/x/tools/go/ast/inspector/inspector.go new file mode 100644 index 00000000000..db88a951090 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/ast/inspector/inspector.go @@ -0,0 +1,182 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package inspector provides helper functions for traversal over the +// syntax trees of a package, including node filtering by type, and +// materialization of the traversal stack. +// +// During construction, the inspector does a complete traversal and +// builds a list of push/pop events and their node type. Subsequent +// method calls that request a traversal scan this list, rather than walk +// the AST, and perform type filtering using efficient bit sets. +// +// Experiments suggest the inspector's traversals are about 2.5x faster +// than ast.Inspect, but it may take around 5 traversals for this +// benefit to amortize the inspector's construction cost. +// If efficiency is the primary concern, do not use use Inspector for +// one-off traversals. +package inspector + +// There are four orthogonal features in a traversal: +// 1 type filtering +// 2 pruning +// 3 postorder calls to f +// 4 stack +// Rather than offer all of them in the API, +// only a few combinations are exposed: +// - Preorder is the fastest and has fewest features, +// but is the most commonly needed traversal. +// - Nodes and WithStack both provide pruning and postorder calls, +// even though few clients need it, because supporting two versions +// is not justified. +// More combinations could be supported by expressing them as +// wrappers around a more generic traversal, but this was measured +// and found to degrade performance significantly (30%). + +import ( + "go/ast" +) + +// An Inspector provides methods for inspecting +// (traversing) the syntax trees of a package. +type Inspector struct { + events []event +} + +// New returns an Inspector for the specified syntax trees. +func New(files []*ast.File) *Inspector { + return &Inspector{traverse(files)} +} + +// An event represents a push or a pop +// of an ast.Node during a traversal. +type event struct { + node ast.Node + typ uint64 // typeOf(node) + index int // 1 + index of corresponding pop event, or 0 if this is a pop +} + +// Preorder visits all the nodes of the files supplied to New in +// depth-first order. It calls f(n) for each node n before it visits +// n's children. +// +// The types argument, if non-empty, enables type-based filtering of +// events. The function f if is called only for nodes whose type +// matches an element of the types slice. +func (in *Inspector) Preorder(types []ast.Node, f func(ast.Node)) { + // Because it avoids postorder calls to f, and the pruning + // check, Preorder is almost twice as fast as Nodes. The two + // features seem to contribute similar slowdowns (~1.4x each). + + mask := maskOf(types) + for i := 0; i < len(in.events); { + ev := in.events[i] + if ev.typ&mask != 0 { + if ev.index > 0 { + f(ev.node) + } + } + i++ + } +} + +// Nodes visits the nodes of the files supplied to New in depth-first +// order. It calls f(n, true) for each node n before it visits n's +// children. If f returns true, Nodes invokes f recursively for each +// of the non-nil children of the node, followed by a call of +// f(n, false). +// +// The types argument, if non-empty, enables type-based filtering of +// events. The function f if is called only for nodes whose type +// matches an element of the types slice. +func (in *Inspector) Nodes(types []ast.Node, f func(n ast.Node, push bool) (prune bool)) { + mask := maskOf(types) + for i := 0; i < len(in.events); { + ev := in.events[i] + if ev.typ&mask != 0 { + if ev.index > 0 { + // push + if !f(ev.node, true) { + i = ev.index // jump to corresponding pop + 1 + continue + } + } else { + // pop + f(ev.node, false) + } + } + i++ + } +} + +// WithStack visits nodes in a similar manner to Nodes, but it +// supplies each call to f an additional argument, the current +// traversal stack. The stack's first element is the outermost node, +// an *ast.File; its last is the innermost, n. +func (in *Inspector) WithStack(types []ast.Node, f func(n ast.Node, push bool, stack []ast.Node) (prune bool)) { + mask := maskOf(types) + var stack []ast.Node + for i := 0; i < len(in.events); { + ev := in.events[i] + if ev.index > 0 { + // push + stack = append(stack, ev.node) + if ev.typ&mask != 0 { + if !f(ev.node, true, stack) { + i = ev.index + stack = stack[:len(stack)-1] + continue + } + } + } else { + // pop + if ev.typ&mask != 0 { + f(ev.node, false, stack) + } + stack = stack[:len(stack)-1] + } + i++ + } +} + +// traverse builds the table of events representing a traversal. +func traverse(files []*ast.File) []event { + // Preallocate approximate number of events + // based on source file extent. + // This makes traverse faster by 4x (!). + var extent int + for _, f := range files { + extent += int(f.End() - f.Pos()) + } + // This estimate is based on the net/http package. + events := make([]event, 0, extent*33/100) + + var stack []event + for _, f := range files { + ast.Inspect(f, func(n ast.Node) bool { + if n != nil { + // push + ev := event{ + node: n, + typ: typeOf(n), + index: len(events), // push event temporarily holds own index + } + stack = append(stack, ev) + events = append(events, ev) + } else { + // pop + ev := stack[len(stack)-1] + stack = stack[:len(stack)-1] + + events[ev.index].index = len(events) + 1 // make push refer to pop + + ev.index = 0 // turn ev into a pop event + events = append(events, ev) + } + return true + }) + } + + return events +} diff --git a/libgo/go/golang.org/x/tools/go/ast/inspector/typeof.go b/libgo/go/golang.org/x/tools/go/ast/inspector/typeof.go new file mode 100644 index 00000000000..d61301b133d --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/ast/inspector/typeof.go @@ -0,0 +1,216 @@ +package inspector + +// This file defines func typeOf(ast.Node) uint64. +// +// The initial map-based implementation was too slow; +// see https://go-review.googlesource.com/c/tools/+/135655/1/go/ast/inspector/inspector.go#196 + +import "go/ast" + +const ( + nArrayType = iota + nAssignStmt + nBadDecl + nBadExpr + nBadStmt + nBasicLit + nBinaryExpr + nBlockStmt + nBranchStmt + nCallExpr + nCaseClause + nChanType + nCommClause + nComment + nCommentGroup + nCompositeLit + nDeclStmt + nDeferStmt + nEllipsis + nEmptyStmt + nExprStmt + nField + nFieldList + nFile + nForStmt + nFuncDecl + nFuncLit + nFuncType + nGenDecl + nGoStmt + nIdent + nIfStmt + nImportSpec + nIncDecStmt + nIndexExpr + nInterfaceType + nKeyValueExpr + nLabeledStmt + nMapType + nPackage + nParenExpr + nRangeStmt + nReturnStmt + nSelectStmt + nSelectorExpr + nSendStmt + nSliceExpr + nStarExpr + nStructType + nSwitchStmt + nTypeAssertExpr + nTypeSpec + nTypeSwitchStmt + nUnaryExpr + nValueSpec +) + +// typeOf returns a distinct single-bit value that represents the type of n. +// +// Various implementations were benchmarked with BenchmarkNewInspector: +// GOGC=off +// - type switch 4.9-5.5ms 2.1ms +// - binary search over a sorted list of types 5.5-5.9ms 2.5ms +// - linear scan, frequency-ordered list 5.9-6.1ms 2.7ms +// - linear scan, unordered list 6.4ms 2.7ms +// - hash table 6.5ms 3.1ms +// A perfect hash seemed like overkill. +// +// The compiler's switch statement is the clear winner +// as it produces a binary tree in code, +// with constant conditions and good branch prediction. +// (Sadly it is the most verbose in source code.) +// Binary search suffered from poor branch prediction. +// +func typeOf(n ast.Node) uint64 { + // Fast path: nearly half of all nodes are identifiers. + if _, ok := n.(*ast.Ident); ok { + return 1 << nIdent + } + + // These cases include all nodes encountered by ast.Inspect. + switch n.(type) { + case *ast.ArrayType: + return 1 << nArrayType + case *ast.AssignStmt: + return 1 << nAssignStmt + case *ast.BadDecl: + return 1 << nBadDecl + case *ast.BadExpr: + return 1 << nBadExpr + case *ast.BadStmt: + return 1 << nBadStmt + case *ast.BasicLit: + return 1 << nBasicLit + case *ast.BinaryExpr: + return 1 << nBinaryExpr + case *ast.BlockStmt: + return 1 << nBlockStmt + case *ast.BranchStmt: + return 1 << nBranchStmt + case *ast.CallExpr: + return 1 << nCallExpr + case *ast.CaseClause: + return 1 << nCaseClause + case *ast.ChanType: + return 1 << nChanType + case *ast.CommClause: + return 1 << nCommClause + case *ast.Comment: + return 1 << nComment + case *ast.CommentGroup: + return 1 << nCommentGroup + case *ast.CompositeLit: + return 1 << nCompositeLit + case *ast.DeclStmt: + return 1 << nDeclStmt + case *ast.DeferStmt: + return 1 << nDeferStmt + case *ast.Ellipsis: + return 1 << nEllipsis + case *ast.EmptyStmt: + return 1 << nEmptyStmt + case *ast.ExprStmt: + return 1 << nExprStmt + case *ast.Field: + return 1 << nField + case *ast.FieldList: + return 1 << nFieldList + case *ast.File: + return 1 << nFile + case *ast.ForStmt: + return 1 << nForStmt + case *ast.FuncDecl: + return 1 << nFuncDecl + case *ast.FuncLit: + return 1 << nFuncLit + case *ast.FuncType: + return 1 << nFuncType + case *ast.GenDecl: + return 1 << nGenDecl + case *ast.GoStmt: + return 1 << nGoStmt + case *ast.Ident: + return 1 << nIdent + case *ast.IfStmt: + return 1 << nIfStmt + case *ast.ImportSpec: + return 1 << nImportSpec + case *ast.IncDecStmt: + return 1 << nIncDecStmt + case *ast.IndexExpr: + return 1 << nIndexExpr + case *ast.InterfaceType: + return 1 << nInterfaceType + case *ast.KeyValueExpr: + return 1 << nKeyValueExpr + case *ast.LabeledStmt: + return 1 << nLabeledStmt + case *ast.MapType: + return 1 << nMapType + case *ast.Package: + return 1 << nPackage + case *ast.ParenExpr: + return 1 << nParenExpr + case *ast.RangeStmt: + return 1 << nRangeStmt + case *ast.ReturnStmt: + return 1 << nReturnStmt + case *ast.SelectStmt: + return 1 << nSelectStmt + case *ast.SelectorExpr: + return 1 << nSelectorExpr + case *ast.SendStmt: + return 1 << nSendStmt + case *ast.SliceExpr: + return 1 << nSliceExpr + case *ast.StarExpr: + return 1 << nStarExpr + case *ast.StructType: + return 1 << nStructType + case *ast.SwitchStmt: + return 1 << nSwitchStmt + case *ast.TypeAssertExpr: + return 1 << nTypeAssertExpr + case *ast.TypeSpec: + return 1 << nTypeSpec + case *ast.TypeSwitchStmt: + return 1 << nTypeSwitchStmt + case *ast.UnaryExpr: + return 1 << nUnaryExpr + case *ast.ValueSpec: + return 1 << nValueSpec + } + return 0 +} + +func maskOf(nodes []ast.Node) uint64 { + if nodes == nil { + return 1<<64 - 1 // match all node types + } + var mask uint64 + for _, n := range nodes { + mask |= typeOf(n) + } + return mask +} diff --git a/libgo/go/cmd/vet/internal/cfg/builder.go b/libgo/go/golang.org/x/tools/go/cfg/builder.go similarity index 90% rename from libgo/go/cmd/vet/internal/cfg/builder.go rename to libgo/go/golang.org/x/tools/go/cfg/builder.go index da1cc7e6384..24e1aba0339 100644 --- a/libgo/go/cmd/vet/internal/cfg/builder.go +++ b/libgo/go/golang.org/x/tools/go/cfg/builder.go @@ -42,7 +42,7 @@ start: b.add(s) if call, ok := s.X.(*ast.CallExpr); ok && !b.mayReturn(call) { // Calls to panic, os.Exit, etc, never return. - b.current = b.newUnreachableBlock("unreachable.call") + b.current = b.newBlock("unreachable.call") } case *ast.DeclStmt: @@ -65,48 +65,10 @@ start: case *ast.ReturnStmt: b.add(s) - b.current = b.newUnreachableBlock("unreachable.return") + b.current = b.newBlock("unreachable.return") case *ast.BranchStmt: - var block *Block - switch s.Tok { - case token.BREAK: - if s.Label != nil { - if lb := b.labeledBlock(s.Label); lb != nil { - block = lb._break - } - } else { - for t := b.targets; t != nil && block == nil; t = t.tail { - block = t._break - } - } - - case token.CONTINUE: - if s.Label != nil { - if lb := b.labeledBlock(s.Label); lb != nil { - block = lb._continue - } - } else { - for t := b.targets; t != nil && block == nil; t = t.tail { - block = t._continue - } - } - - case token.FALLTHROUGH: - for t := b.targets; t != nil; t = t.tail { - block = t._fallthrough - } - - case token.GOTO: - if s.Label != nil { - block = b.labeledBlock(s.Label)._goto - } - } - if block == nil { - block = b.newBlock("undefined.branch") - } - b.jump(block) - b.current = b.newUnreachableBlock("unreachable.branch") + b.branchStmt(s) case *ast.BlockStmt: b.stmtList(s.List) @@ -161,6 +123,48 @@ func (b *builder) stmtList(list []ast.Stmt) { } } +func (b *builder) branchStmt(s *ast.BranchStmt) { + var block *Block + switch s.Tok { + case token.BREAK: + if s.Label != nil { + if lb := b.labeledBlock(s.Label); lb != nil { + block = lb._break + } + } else { + for t := b.targets; t != nil && block == nil; t = t.tail { + block = t._break + } + } + + case token.CONTINUE: + if s.Label != nil { + if lb := b.labeledBlock(s.Label); lb != nil { + block = lb._continue + } + } else { + for t := b.targets; t != nil && block == nil; t = t.tail { + block = t._continue + } + } + + case token.FALLTHROUGH: + for t := b.targets; t != nil; t = t.tail { + block = t._fallthrough + } + + case token.GOTO: + if s.Label != nil { + block = b.labeledBlock(s.Label)._goto + } + } + if block == nil { + block = b.newBlock("undefined.branch") + } + b.jump(block) + b.current = b.newBlock("unreachable.branch") +} + func (b *builder) switchStmt(s *ast.SwitchStmt, label *lblock) { if s.Init != nil { b.stmt(s.Init) @@ -479,7 +483,7 @@ func (b *builder) labeledBlock(label *ast.Ident) *lblock { func (b *builder) newBlock(comment string) *Block { g := b.cfg block := &Block{ - index: int32(len(g.Blocks)), + Index: int32(len(g.Blocks)), comment: comment, } block.Succs = block.succs2[:0] @@ -487,12 +491,6 @@ func (b *builder) newBlock(comment string) *Block { return block } -func (b *builder) newUnreachableBlock(comment string) *Block { - block := b.newBlock(comment) - block.unreachable = true - return block -} - func (b *builder) add(n ast.Node) { b.current.Nodes = append(b.current.Nodes, n) } diff --git a/libgo/go/cmd/vet/internal/cfg/cfg.go b/libgo/go/golang.org/x/tools/go/cfg/cfg.go similarity index 83% rename from libgo/go/cmd/vet/internal/cfg/cfg.go rename to libgo/go/golang.org/x/tools/go/cfg/cfg.go index e4d5bfe5d2d..b075034bb45 100644 --- a/libgo/go/cmd/vet/internal/cfg/cfg.go +++ b/libgo/go/golang.org/x/tools/go/cfg/cfg.go @@ -39,11 +39,6 @@ // package cfg -// Although the vet tool has type information, it is often extremely -// fragmentary, so for simplicity this package does not depend on -// go/types. Consequently control-flow conditions are ignored even -// when constant, and "mayReturn" information must be provided by the -// client. import ( "bytes" "fmt" @@ -68,11 +63,11 @@ type CFG struct { type Block struct { Nodes []ast.Node // statements, expressions, and ValueSpecs Succs []*Block // successor nodes in the graph + Index int32 // index within CFG.Blocks + Live bool // block is reachable from entry - comment string // for debugging - index int32 // index within CFG.Blocks - unreachable bool // is block of stmts following return/panic/for{} - succs2 [2]*Block // underlying array for Succs + comment string // for debugging + succs2 [2]*Block // underlying array for Succs } // New returns a new control-flow graph for the specified function body, @@ -91,9 +86,22 @@ func New(body *ast.BlockStmt, mayReturn func(*ast.CallExpr) bool) *CFG { b.current = b.newBlock("entry") b.stmt(body) + // Compute liveness (reachability from entry point), breadth-first. + q := make([]*Block, 0, len(b.cfg.Blocks)) + q = append(q, b.cfg.Blocks[0]) // entry point + for len(q) > 0 { + b := q[len(q)-1] + q = q[:len(q)-1] + + if !b.Live { + b.Live = true + q = append(q, b.Succs...) + } + } + // Does control fall off the end of the function's body? // Make implicit return explicit. - if b.current != nil && !b.current.unreachable { + if b.current != nil && b.current.Live { b.add(&ast.ReturnStmt{ Return: body.End() - 1, }) @@ -103,7 +111,7 @@ func New(body *ast.BlockStmt, mayReturn func(*ast.CallExpr) bool) *CFG { } func (b *Block) String() string { - return fmt.Sprintf("block %d (%s)", b.index, b.comment) + return fmt.Sprintf("block %d (%s)", b.Index, b.comment) } // Return returns the return statement at the end of this block if present, nil otherwise. @@ -118,14 +126,14 @@ func (b *Block) Return() (ret *ast.ReturnStmt) { func (g *CFG) Format(fset *token.FileSet) string { var buf bytes.Buffer for _, b := range g.Blocks { - fmt.Fprintf(&buf, ".%d: # %s\n", b.index, b.comment) + fmt.Fprintf(&buf, ".%d: # %s\n", b.Index, b.comment) for _, n := range b.Nodes { fmt.Fprintf(&buf, "\t%s\n", formatNode(fset, n)) } if len(b.Succs) > 0 { fmt.Fprintf(&buf, "\tsuccs:") for _, succ := range b.Succs { - fmt.Fprintf(&buf, " %d", succ.index) + fmt.Fprintf(&buf, " %d", succ.Index) } buf.WriteByte('\n') } diff --git a/libgo/go/golang.org/x/tools/go/types/objectpath/objectpath.go b/libgo/go/golang.org/x/tools/go/types/objectpath/objectpath.go new file mode 100644 index 00000000000..0d85488efb6 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/types/objectpath/objectpath.go @@ -0,0 +1,523 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package objectpath defines a naming scheme for types.Objects +// (that is, named entities in Go programs) relative to their enclosing +// package. +// +// Type-checker objects are canonical, so they are usually identified by +// their address in memory (a pointer), but a pointer has meaning only +// within one address space. By contrast, objectpath names allow the +// identity of an object to be sent from one program to another, +// establishing a correspondence between types.Object variables that are +// distinct but logically equivalent. +// +// A single object may have multiple paths. In this example, +// type A struct{ X int } +// type B A +// the field X has two paths due to its membership of both A and B. +// The For(obj) function always returns one of these paths, arbitrarily +// but consistently. +package objectpath + +import ( + "fmt" + "strconv" + "strings" + + "go/types" +) + +// A Path is an opaque name that identifies a types.Object +// relative to its package. Conceptually, the name consists of a +// sequence of destructuring operations applied to the package scope +// to obtain the original object. +// The name does not include the package itself. +type Path string + +// Encoding +// +// An object path is a textual and (with training) human-readable encoding +// of a sequence of destructuring operators, starting from a types.Package. +// The sequences represent a path through the package/object/type graph. +// We classify these operators by their type: +// +// PO package->object Package.Scope.Lookup +// OT object->type Object.Type +// TT type->type Type.{Elem,Key,Params,Results,Underlying} [EKPRU] +// TO type->object Type.{At,Field,Method,Obj} [AFMO] +// +// All valid paths start with a package and end at an object +// and thus may be defined by the regular language: +// +// objectpath = PO (OT TT* TO)* +// +// The concrete encoding follows directly: +// - The only PO operator is Package.Scope.Lookup, which requires an identifier. +// - The only OT operator is Object.Type, +// which we encode as '.' because dot cannot appear in an identifier. +// - The TT operators are encoded as [EKPRU]. +// - The OT operators are encoded as [AFMO]; +// three of these (At,Field,Method) require an integer operand, +// which is encoded as a string of decimal digits. +// These indices are stable across different representations +// of the same package, even source and export data. +// +// In the example below, +// +// package p +// +// type T interface { +// f() (a string, b struct{ X int }) +// } +// +// field X has the path "T.UM0.RA1.F0", +// representing the following sequence of operations: +// +// p.Lookup("T") T +// .Type().Underlying().Method(0). f +// .Type().Results().At(1) b +// .Type().Field(0) X +// +// The encoding is not maximally compact---every R or P is +// followed by an A, for example---but this simplifies the +// encoder and decoder. +// +const ( + // object->type operators + opType = '.' // .Type() (Object) + + // type->type operators + opElem = 'E' // .Elem() (Pointer, Slice, Array, Chan, Map) + opKey = 'K' // .Key() (Map) + opParams = 'P' // .Params() (Signature) + opResults = 'R' // .Results() (Signature) + opUnderlying = 'U' // .Underlying() (Named) + + // type->object operators + opAt = 'A' // .At(i) (Tuple) + opField = 'F' // .Field(i) (Struct) + opMethod = 'M' // .Method(i) (Named or Interface; not Struct: "promoted" names are ignored) + opObj = 'O' // .Obj() (Named) +) + +// The For function returns the path to an object relative to its package, +// or an error if the object is not accessible from the package's Scope. +// +// The For function guarantees to return a path only for the following objects: +// - package-level types +// - exported package-level non-types +// - methods +// - parameter and result variables +// - struct fields +// These objects are sufficient to define the API of their package. +// The objects described by a package's export data are drawn from this set. +// +// For does not return a path for predeclared names, imported package +// names, local names, and unexported package-level names (except +// types). +// +// Example: given this definition, +// +// package p +// +// type T interface { +// f() (a string, b struct{ X int }) +// } +// +// For(X) would return a path that denotes the following sequence of operations: +// +// p.Scope().Lookup("T") (TypeName T) +// .Type().Underlying().Method(0). (method Func f) +// .Type().Results().At(1) (field Var b) +// .Type().Field(0) (field Var X) +// +// where p is the package (*types.Package) to which X belongs. +func For(obj types.Object) (Path, error) { + pkg := obj.Pkg() + + // This table lists the cases of interest. + // + // Object Action + // ------ ------ + // nil reject + // builtin reject + // pkgname reject + // label reject + // var + // package-level accept + // func param/result accept + // local reject + // struct field accept + // const + // package-level accept + // local reject + // func + // package-level accept + // init functions reject + // concrete method accept + // interface method accept + // type + // package-level accept + // local reject + // + // The only accessible package-level objects are members of pkg itself. + // + // The cases are handled in four steps: + // + // 1. reject nil and builtin + // 2. accept package-level objects + // 3. reject obviously invalid objects + // 4. search the API for the path to the param/result/field/method. + + // 1. reference to nil or builtin? + if pkg == nil { + return "", fmt.Errorf("predeclared %s has no path", obj) + } + scope := pkg.Scope() + + // 2. package-level object? + if scope.Lookup(obj.Name()) == obj { + // Only exported objects (and non-exported types) have a path. + // Non-exported types may be referenced by other objects. + if _, ok := obj.(*types.TypeName); !ok && !obj.Exported() { + return "", fmt.Errorf("no path for non-exported %v", obj) + } + return Path(obj.Name()), nil + } + + // 3. Not a package-level object. + // Reject obviously non-viable cases. + switch obj := obj.(type) { + case *types.Const, // Only package-level constants have a path. + *types.TypeName, // Only package-level types have a path. + *types.Label, // Labels are function-local. + *types.PkgName: // PkgNames are file-local. + return "", fmt.Errorf("no path for %v", obj) + + case *types.Var: + // Could be: + // - a field (obj.IsField()) + // - a func parameter or result + // - a local var. + // Sadly there is no way to distinguish + // a param/result from a local + // so we must proceed to the find. + + case *types.Func: + // A func, if not package-level, must be a method. + if recv := obj.Type().(*types.Signature).Recv(); recv == nil { + return "", fmt.Errorf("func is not a method: %v", obj) + } + // TODO(adonovan): opt: if the method is concrete, + // do a specialized version of the rest of this function so + // that it's O(1) not O(|scope|). Basically 'find' is needed + // only for struct fields and interface methods. + + default: + panic(obj) + } + + // 4. Search the API for the path to the var (field/param/result) or method. + + // First inspect package-level named types. + // In the presence of path aliases, these give + // the best paths because non-types may + // refer to types, but not the reverse. + empty := make([]byte, 0, 48) // initial space + for _, name := range scope.Names() { + o := scope.Lookup(name) + tname, ok := o.(*types.TypeName) + if !ok { + continue // handle non-types in second pass + } + + path := append(empty, name...) + path = append(path, opType) + + T := o.Type() + + if tname.IsAlias() { + // type alias + if r := find(obj, T, path); r != nil { + return Path(r), nil + } + } else { + // defined (named) type + if r := find(obj, T.Underlying(), append(path, opUnderlying)); r != nil { + return Path(r), nil + } + } + } + + // Then inspect everything else: + // non-types, and declared methods of defined types. + for _, name := range scope.Names() { + o := scope.Lookup(name) + path := append(empty, name...) + if _, ok := o.(*types.TypeName); !ok { + if o.Exported() { + // exported non-type (const, var, func) + if r := find(obj, o.Type(), append(path, opType)); r != nil { + return Path(r), nil + } + } + continue + } + + // Inspect declared methods of defined types. + if T, ok := o.Type().(*types.Named); ok { + path = append(path, opType) + for i := 0; i < T.NumMethods(); i++ { + m := T.Method(i) + path2 := appendOpArg(path, opMethod, i) + if m == obj { + return Path(path2), nil // found declared method + } + if r := find(obj, m.Type(), append(path2, opType)); r != nil { + return Path(r), nil + } + } + } + } + + return "", fmt.Errorf("can't find path for %v in %s", obj, pkg.Path()) +} + +func appendOpArg(path []byte, op byte, arg int) []byte { + path = append(path, op) + path = strconv.AppendInt(path, int64(arg), 10) + return path +} + +// find finds obj within type T, returning the path to it, or nil if not found. +func find(obj types.Object, T types.Type, path []byte) []byte { + switch T := T.(type) { + case *types.Basic, *types.Named: + // Named types belonging to pkg were handled already, + // so T must belong to another package. No path. + return nil + case *types.Pointer: + return find(obj, T.Elem(), append(path, opElem)) + case *types.Slice: + return find(obj, T.Elem(), append(path, opElem)) + case *types.Array: + return find(obj, T.Elem(), append(path, opElem)) + case *types.Chan: + return find(obj, T.Elem(), append(path, opElem)) + case *types.Map: + if r := find(obj, T.Key(), append(path, opKey)); r != nil { + return r + } + return find(obj, T.Elem(), append(path, opElem)) + case *types.Signature: + if r := find(obj, T.Params(), append(path, opParams)); r != nil { + return r + } + return find(obj, T.Results(), append(path, opResults)) + case *types.Struct: + for i := 0; i < T.NumFields(); i++ { + f := T.Field(i) + path2 := appendOpArg(path, opField, i) + if f == obj { + return path2 // found field var + } + if r := find(obj, f.Type(), append(path2, opType)); r != nil { + return r + } + } + return nil + case *types.Tuple: + for i := 0; i < T.Len(); i++ { + v := T.At(i) + path2 := appendOpArg(path, opAt, i) + if v == obj { + return path2 // found param/result var + } + if r := find(obj, v.Type(), append(path2, opType)); r != nil { + return r + } + } + return nil + case *types.Interface: + for i := 0; i < T.NumMethods(); i++ { + m := T.Method(i) + path2 := appendOpArg(path, opMethod, i) + if m == obj { + return path2 // found interface method + } + if r := find(obj, m.Type(), append(path2, opType)); r != nil { + return r + } + } + return nil + } + panic(T) +} + +// Object returns the object denoted by path p within the package pkg. +func Object(pkg *types.Package, p Path) (types.Object, error) { + if p == "" { + return nil, fmt.Errorf("empty path") + } + + pathstr := string(p) + var pkgobj, suffix string + if dot := strings.IndexByte(pathstr, opType); dot < 0 { + pkgobj = pathstr + } else { + pkgobj = pathstr[:dot] + suffix = pathstr[dot:] // suffix starts with "." + } + + obj := pkg.Scope().Lookup(pkgobj) + if obj == nil { + return nil, fmt.Errorf("package %s does not contain %q", pkg.Path(), pkgobj) + } + + // abtraction of *types.{Pointer,Slice,Array,Chan,Map} + type hasElem interface { + Elem() types.Type + } + // abstraction of *types.{Interface,Named} + type hasMethods interface { + Method(int) *types.Func + NumMethods() int + } + + // The loop state is the pair (t, obj), + // exactly one of which is non-nil, initially obj. + // All suffixes start with '.' (the only object->type operation), + // followed by optional type->type operations, + // then a type->object operation. + // The cycle then repeats. + var t types.Type + for suffix != "" { + code := suffix[0] + suffix = suffix[1:] + + // Codes [AFM] have an integer operand. + var index int + switch code { + case opAt, opField, opMethod: + rest := strings.TrimLeft(suffix, "0123456789") + numerals := suffix[:len(suffix)-len(rest)] + suffix = rest + i, err := strconv.Atoi(numerals) + if err != nil { + return nil, fmt.Errorf("invalid path: bad numeric operand %q for code %q", numerals, code) + } + index = int(i) + case opObj: + // no operand + default: + // The suffix must end with a type->object operation. + if suffix == "" { + return nil, fmt.Errorf("invalid path: ends with %q, want [AFMO]", code) + } + } + + if code == opType { + if t != nil { + return nil, fmt.Errorf("invalid path: unexpected %q in type context", opType) + } + t = obj.Type() + obj = nil + continue + } + + if t == nil { + return nil, fmt.Errorf("invalid path: code %q in object context", code) + } + + // Inv: t != nil, obj == nil + + switch code { + case opElem: + hasElem, ok := t.(hasElem) // Pointer, Slice, Array, Chan, Map + if !ok { + return nil, fmt.Errorf("cannot apply %q to %s (got %T, want pointer, slice, array, chan or map)", code, t, t) + } + t = hasElem.Elem() + + case opKey: + mapType, ok := t.(*types.Map) + if !ok { + return nil, fmt.Errorf("cannot apply %q to %s (got %T, want map)", code, t, t) + } + t = mapType.Key() + + case opParams: + sig, ok := t.(*types.Signature) + if !ok { + return nil, fmt.Errorf("cannot apply %q to %s (got %T, want signature)", code, t, t) + } + t = sig.Params() + + case opResults: + sig, ok := t.(*types.Signature) + if !ok { + return nil, fmt.Errorf("cannot apply %q to %s (got %T, want signature)", code, t, t) + } + t = sig.Results() + + case opUnderlying: + named, ok := t.(*types.Named) + if !ok { + return nil, fmt.Errorf("cannot apply %q to %s (got %s, want named)", code, t, t) + } + t = named.Underlying() + + case opAt: + tuple, ok := t.(*types.Tuple) + if !ok { + return nil, fmt.Errorf("cannot apply %q to %s (got %s, want tuple)", code, t, t) + } + if n := tuple.Len(); index >= n { + return nil, fmt.Errorf("tuple index %d out of range [0-%d)", index, n) + } + obj = tuple.At(index) + t = nil + + case opField: + structType, ok := t.(*types.Struct) + if !ok { + return nil, fmt.Errorf("cannot apply %q to %s (got %T, want struct)", code, t, t) + } + if n := structType.NumFields(); index >= n { + return nil, fmt.Errorf("field index %d out of range [0-%d)", index, n) + } + obj = structType.Field(index) + t = nil + + case opMethod: + hasMethods, ok := t.(hasMethods) // Interface or Named + if !ok { + return nil, fmt.Errorf("cannot apply %q to %s (got %s, want interface or named)", code, t, t) + } + if n := hasMethods.NumMethods(); index >= n { + return nil, fmt.Errorf("method index %d out of range [0-%d)", index, n) + } + obj = hasMethods.Method(index) + t = nil + + case opObj: + named, ok := t.(*types.Named) + if !ok { + return nil, fmt.Errorf("cannot apply %q to %s (got %s, want named)", code, t, t) + } + obj = named.Obj() + t = nil + + default: + return nil, fmt.Errorf("invalid path: unknown code %q", code) + } + } + + if obj.Pkg() != pkg { + return nil, fmt.Errorf("path denotes %s, which belongs to a different package", obj) + } + + return obj, nil // success +} diff --git a/libgo/go/golang.org/x/tools/go/types/typeutil/callee.go b/libgo/go/golang.org/x/tools/go/types/typeutil/callee.go new file mode 100644 index 00000000000..38f596daf9e --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/types/typeutil/callee.go @@ -0,0 +1,46 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package typeutil + +import ( + "go/ast" + "go/types" + + "golang.org/x/tools/go/ast/astutil" +) + +// Callee returns the named target of a function call, if any: +// a function, method, builtin, or variable. +func Callee(info *types.Info, call *ast.CallExpr) types.Object { + var obj types.Object + switch fun := astutil.Unparen(call.Fun).(type) { + case *ast.Ident: + obj = info.Uses[fun] // type, var, builtin, or declared func + case *ast.SelectorExpr: + if sel, ok := info.Selections[fun]; ok { + obj = sel.Obj() // method or field + } else { + obj = info.Uses[fun.Sel] // qualified identifier? + } + } + if _, ok := obj.(*types.TypeName); ok { + return nil // T(x) is a conversion, not a call + } + return obj +} + +// StaticCallee returns the target (function or method) of a static +// function call, if any. It returns nil for calls to builtins. +func StaticCallee(info *types.Info, call *ast.CallExpr) *types.Func { + if f, ok := Callee(info, call).(*types.Func); ok && !interfaceMethod(f) { + return f + } + return nil +} + +func interfaceMethod(f *types.Func) bool { + recv := f.Type().(*types.Signature).Recv() + return recv != nil && types.IsInterface(recv.Type()) +} diff --git a/libgo/go/golang.org/x/tools/go/types/typeutil/imports.go b/libgo/go/golang.org/x/tools/go/types/typeutil/imports.go new file mode 100644 index 00000000000..9c441dba9c0 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/types/typeutil/imports.go @@ -0,0 +1,31 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package typeutil + +import "go/types" + +// Dependencies returns all dependencies of the specified packages. +// +// Dependent packages appear in topological order: if package P imports +// package Q, Q appears earlier than P in the result. +// The algorithm follows import statements in the order they +// appear in the source code, so the result is a total order. +// +func Dependencies(pkgs ...*types.Package) []*types.Package { + var result []*types.Package + seen := make(map[*types.Package]bool) + var visit func(pkgs []*types.Package) + visit = func(pkgs []*types.Package) { + for _, p := range pkgs { + if !seen[p] { + seen[p] = true + visit(p.Imports()) + result = append(result, p) + } + } + } + visit(pkgs) + return result +} diff --git a/libgo/go/golang.org/x/tools/go/types/typeutil/map.go b/libgo/go/golang.org/x/tools/go/types/typeutil/map.go new file mode 100644 index 00000000000..c7f75450064 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/types/typeutil/map.go @@ -0,0 +1,313 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package typeutil defines various utilities for types, such as Map, +// a mapping from types.Type to interface{} values. +package typeutil // import "golang.org/x/tools/go/types/typeutil" + +import ( + "bytes" + "fmt" + "go/types" + "reflect" +) + +// Map is a hash-table-based mapping from types (types.Type) to +// arbitrary interface{} values. The concrete types that implement +// the Type interface are pointers. Since they are not canonicalized, +// == cannot be used to check for equivalence, and thus we cannot +// simply use a Go map. +// +// Just as with map[K]V, a nil *Map is a valid empty map. +// +// Not thread-safe. +// +type Map struct { + hasher Hasher // shared by many Maps + table map[uint32][]entry // maps hash to bucket; entry.key==nil means unused + length int // number of map entries +} + +// entry is an entry (key/value association) in a hash bucket. +type entry struct { + key types.Type + value interface{} +} + +// SetHasher sets the hasher used by Map. +// +// All Hashers are functionally equivalent but contain internal state +// used to cache the results of hashing previously seen types. +// +// A single Hasher created by MakeHasher() may be shared among many +// Maps. This is recommended if the instances have many keys in +// common, as it will amortize the cost of hash computation. +// +// A Hasher may grow without bound as new types are seen. Even when a +// type is deleted from the map, the Hasher never shrinks, since other +// types in the map may reference the deleted type indirectly. +// +// Hashers are not thread-safe, and read-only operations such as +// Map.Lookup require updates to the hasher, so a full Mutex lock (not a +// read-lock) is require around all Map operations if a shared +// hasher is accessed from multiple threads. +// +// If SetHasher is not called, the Map will create a private hasher at +// the first call to Insert. +// +func (m *Map) SetHasher(hasher Hasher) { + m.hasher = hasher +} + +// Delete removes the entry with the given key, if any. +// It returns true if the entry was found. +// +func (m *Map) Delete(key types.Type) bool { + if m != nil && m.table != nil { + hash := m.hasher.Hash(key) + bucket := m.table[hash] + for i, e := range bucket { + if e.key != nil && types.Identical(key, e.key) { + // We can't compact the bucket as it + // would disturb iterators. + bucket[i] = entry{} + m.length-- + return true + } + } + } + return false +} + +// At returns the map entry for the given key. +// The result is nil if the entry is not present. +// +func (m *Map) At(key types.Type) interface{} { + if m != nil && m.table != nil { + for _, e := range m.table[m.hasher.Hash(key)] { + if e.key != nil && types.Identical(key, e.key) { + return e.value + } + } + } + return nil +} + +// Set sets the map entry for key to val, +// and returns the previous entry, if any. +func (m *Map) Set(key types.Type, value interface{}) (prev interface{}) { + if m.table != nil { + hash := m.hasher.Hash(key) + bucket := m.table[hash] + var hole *entry + for i, e := range bucket { + if e.key == nil { + hole = &bucket[i] + } else if types.Identical(key, e.key) { + prev = e.value + bucket[i].value = value + return + } + } + + if hole != nil { + *hole = entry{key, value} // overwrite deleted entry + } else { + m.table[hash] = append(bucket, entry{key, value}) + } + } else { + if m.hasher.memo == nil { + m.hasher = MakeHasher() + } + hash := m.hasher.Hash(key) + m.table = map[uint32][]entry{hash: {entry{key, value}}} + } + + m.length++ + return +} + +// Len returns the number of map entries. +func (m *Map) Len() int { + if m != nil { + return m.length + } + return 0 +} + +// Iterate calls function f on each entry in the map in unspecified order. +// +// If f should mutate the map, Iterate provides the same guarantees as +// Go maps: if f deletes a map entry that Iterate has not yet reached, +// f will not be invoked for it, but if f inserts a map entry that +// Iterate has not yet reached, whether or not f will be invoked for +// it is unspecified. +// +func (m *Map) Iterate(f func(key types.Type, value interface{})) { + if m != nil { + for _, bucket := range m.table { + for _, e := range bucket { + if e.key != nil { + f(e.key, e.value) + } + } + } + } +} + +// Keys returns a new slice containing the set of map keys. +// The order is unspecified. +func (m *Map) Keys() []types.Type { + keys := make([]types.Type, 0, m.Len()) + m.Iterate(func(key types.Type, _ interface{}) { + keys = append(keys, key) + }) + return keys +} + +func (m *Map) toString(values bool) string { + if m == nil { + return "{}" + } + var buf bytes.Buffer + fmt.Fprint(&buf, "{") + sep := "" + m.Iterate(func(key types.Type, value interface{}) { + fmt.Fprint(&buf, sep) + sep = ", " + fmt.Fprint(&buf, key) + if values { + fmt.Fprintf(&buf, ": %q", value) + } + }) + fmt.Fprint(&buf, "}") + return buf.String() +} + +// String returns a string representation of the map's entries. +// Values are printed using fmt.Sprintf("%v", v). +// Order is unspecified. +// +func (m *Map) String() string { + return m.toString(true) +} + +// KeysString returns a string representation of the map's key set. +// Order is unspecified. +// +func (m *Map) KeysString() string { + return m.toString(false) +} + +//////////////////////////////////////////////////////////////////////// +// Hasher + +// A Hasher maps each type to its hash value. +// For efficiency, a hasher uses memoization; thus its memory +// footprint grows monotonically over time. +// Hashers are not thread-safe. +// Hashers have reference semantics. +// Call MakeHasher to create a Hasher. +type Hasher struct { + memo map[types.Type]uint32 +} + +// MakeHasher returns a new Hasher instance. +func MakeHasher() Hasher { + return Hasher{make(map[types.Type]uint32)} +} + +// Hash computes a hash value for the given type t such that +// Identical(t, t') => Hash(t) == Hash(t'). +func (h Hasher) Hash(t types.Type) uint32 { + hash, ok := h.memo[t] + if !ok { + hash = h.hashFor(t) + h.memo[t] = hash + } + return hash +} + +// hashString computes the Fowler–Noll–Vo hash of s. +func hashString(s string) uint32 { + var h uint32 + for i := 0; i < len(s); i++ { + h ^= uint32(s[i]) + h *= 16777619 + } + return h +} + +// hashFor computes the hash of t. +func (h Hasher) hashFor(t types.Type) uint32 { + // See Identical for rationale. + switch t := t.(type) { + case *types.Basic: + return uint32(t.Kind()) + + case *types.Array: + return 9043 + 2*uint32(t.Len()) + 3*h.Hash(t.Elem()) + + case *types.Slice: + return 9049 + 2*h.Hash(t.Elem()) + + case *types.Struct: + var hash uint32 = 9059 + for i, n := 0, t.NumFields(); i < n; i++ { + f := t.Field(i) + if f.Anonymous() { + hash += 8861 + } + hash += hashString(t.Tag(i)) + hash += hashString(f.Name()) // (ignore f.Pkg) + hash += h.Hash(f.Type()) + } + return hash + + case *types.Pointer: + return 9067 + 2*h.Hash(t.Elem()) + + case *types.Signature: + var hash uint32 = 9091 + if t.Variadic() { + hash *= 8863 + } + return hash + 3*h.hashTuple(t.Params()) + 5*h.hashTuple(t.Results()) + + case *types.Interface: + var hash uint32 = 9103 + for i, n := 0, t.NumMethods(); i < n; i++ { + // See go/types.identicalMethods for rationale. + // Method order is not significant. + // Ignore m.Pkg(). + m := t.Method(i) + hash += 3*hashString(m.Name()) + 5*h.Hash(m.Type()) + } + return hash + + case *types.Map: + return 9109 + 2*h.Hash(t.Key()) + 3*h.Hash(t.Elem()) + + case *types.Chan: + return 9127 + 2*uint32(t.Dir()) + 3*h.Hash(t.Elem()) + + case *types.Named: + // Not safe with a copying GC; objects may move. + return uint32(reflect.ValueOf(t.Obj()).Pointer()) + + case *types.Tuple: + return h.hashTuple(t) + } + panic(t) +} + +func (h Hasher) hashTuple(tuple *types.Tuple) uint32 { + // See go/types.identicalTypes for rationale. + n := tuple.Len() + var hash uint32 = 9137 + 2*uint32(n) + for i := 0; i < n; i++ { + hash += 3 * h.Hash(tuple.At(i).Type()) + } + return hash +} diff --git a/libgo/go/golang.org/x/tools/go/types/typeutil/methodsetcache.go b/libgo/go/golang.org/x/tools/go/types/typeutil/methodsetcache.go new file mode 100644 index 00000000000..32084610f49 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/types/typeutil/methodsetcache.go @@ -0,0 +1,72 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file implements a cache of method sets. + +package typeutil + +import ( + "go/types" + "sync" +) + +// A MethodSetCache records the method set of each type T for which +// MethodSet(T) is called so that repeat queries are fast. +// The zero value is a ready-to-use cache instance. +type MethodSetCache struct { + mu sync.Mutex + named map[*types.Named]struct{ value, pointer *types.MethodSet } // method sets for named N and *N + others map[types.Type]*types.MethodSet // all other types +} + +// MethodSet returns the method set of type T. It is thread-safe. +// +// If cache is nil, this function is equivalent to types.NewMethodSet(T). +// Utility functions can thus expose an optional *MethodSetCache +// parameter to clients that care about performance. +// +func (cache *MethodSetCache) MethodSet(T types.Type) *types.MethodSet { + if cache == nil { + return types.NewMethodSet(T) + } + cache.mu.Lock() + defer cache.mu.Unlock() + + switch T := T.(type) { + case *types.Named: + return cache.lookupNamed(T).value + + case *types.Pointer: + if N, ok := T.Elem().(*types.Named); ok { + return cache.lookupNamed(N).pointer + } + } + + // all other types + // (The map uses pointer equivalence, not type identity.) + mset := cache.others[T] + if mset == nil { + mset = types.NewMethodSet(T) + if cache.others == nil { + cache.others = make(map[types.Type]*types.MethodSet) + } + cache.others[T] = mset + } + return mset +} + +func (cache *MethodSetCache) lookupNamed(named *types.Named) struct{ value, pointer *types.MethodSet } { + if cache.named == nil { + cache.named = make(map[*types.Named]struct{ value, pointer *types.MethodSet }) + } + // Avoid recomputing mset(*T) for each distinct Pointer + // instance whose underlying type is a named type. + msets, ok := cache.named[named] + if !ok { + msets.value = types.NewMethodSet(named) + msets.pointer = types.NewMethodSet(types.NewPointer(named)) + cache.named[named] = msets + } + return msets +} diff --git a/libgo/go/golang.org/x/tools/go/types/typeutil/ui.go b/libgo/go/golang.org/x/tools/go/types/typeutil/ui.go new file mode 100644 index 00000000000..9849c24cef3 --- /dev/null +++ b/libgo/go/golang.org/x/tools/go/types/typeutil/ui.go @@ -0,0 +1,52 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package typeutil + +// This file defines utilities for user interfaces that display types. + +import "go/types" + +// IntuitiveMethodSet returns the intuitive method set of a type T, +// which is the set of methods you can call on an addressable value of +// that type. +// +// The result always contains MethodSet(T), and is exactly MethodSet(T) +// for interface types and for pointer-to-concrete types. +// For all other concrete types T, the result additionally +// contains each method belonging to *T if there is no identically +// named method on T itself. +// +// This corresponds to user intuition about method sets; +// this function is intended only for user interfaces. +// +// The order of the result is as for types.MethodSet(T). +// +func IntuitiveMethodSet(T types.Type, msets *MethodSetCache) []*types.Selection { + isPointerToConcrete := func(T types.Type) bool { + ptr, ok := T.(*types.Pointer) + return ok && !types.IsInterface(ptr.Elem()) + } + + var result []*types.Selection + mset := msets.MethodSet(T) + if types.IsInterface(T) || isPointerToConcrete(T) { + for i, n := 0, mset.Len(); i < n; i++ { + result = append(result, mset.At(i)) + } + } else { + // T is some other concrete type. + // Report methods of T and *T, preferring those of T. + pmset := msets.MethodSet(types.NewPointer(T)) + for i, n := 0, pmset.Len(); i < n; i++ { + meth := pmset.At(i) + if m := mset.Lookup(meth.Obj().Pkg(), meth.Obj().Name()); m != nil { + meth = m + } + result = append(result, meth) + } + + } + return result +} diff --git a/libgo/go/golang_org/x/crypto/chacha20poly1305/internal/chacha20/chacha_generic.go b/libgo/go/golang_org/x/crypto/chacha20poly1305/internal/chacha20/chacha_generic.go deleted file mode 100644 index f9e8a3a2fe8..00000000000 --- a/libgo/go/golang_org/x/crypto/chacha20poly1305/internal/chacha20/chacha_generic.go +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package ChaCha20 implements the core ChaCha20 function as specified in https://tools.ietf.org/html/rfc7539#section-2.3. -package chacha20 - -import "encoding/binary" - -const rounds = 20 - -// core applies the ChaCha20 core function to 16-byte input in, 32-byte key k, -// and 16-byte constant c, and puts the result into 64-byte array out. -func core(out *[64]byte, in *[16]byte, k *[32]byte) { - j0 := uint32(0x61707865) - j1 := uint32(0x3320646e) - j2 := uint32(0x79622d32) - j3 := uint32(0x6b206574) - j4 := binary.LittleEndian.Uint32(k[0:4]) - j5 := binary.LittleEndian.Uint32(k[4:8]) - j6 := binary.LittleEndian.Uint32(k[8:12]) - j7 := binary.LittleEndian.Uint32(k[12:16]) - j8 := binary.LittleEndian.Uint32(k[16:20]) - j9 := binary.LittleEndian.Uint32(k[20:24]) - j10 := binary.LittleEndian.Uint32(k[24:28]) - j11 := binary.LittleEndian.Uint32(k[28:32]) - j12 := binary.LittleEndian.Uint32(in[0:4]) - j13 := binary.LittleEndian.Uint32(in[4:8]) - j14 := binary.LittleEndian.Uint32(in[8:12]) - j15 := binary.LittleEndian.Uint32(in[12:16]) - - x0, x1, x2, x3, x4, x5, x6, x7 := j0, j1, j2, j3, j4, j5, j6, j7 - x8, x9, x10, x11, x12, x13, x14, x15 := j8, j9, j10, j11, j12, j13, j14, j15 - - for i := 0; i < rounds; i += 2 { - x0 += x4 - x12 ^= x0 - x12 = (x12 << 16) | (x12 >> (16)) - x8 += x12 - x4 ^= x8 - x4 = (x4 << 12) | (x4 >> (20)) - x0 += x4 - x12 ^= x0 - x12 = (x12 << 8) | (x12 >> (24)) - x8 += x12 - x4 ^= x8 - x4 = (x4 << 7) | (x4 >> (25)) - x1 += x5 - x13 ^= x1 - x13 = (x13 << 16) | (x13 >> 16) - x9 += x13 - x5 ^= x9 - x5 = (x5 << 12) | (x5 >> 20) - x1 += x5 - x13 ^= x1 - x13 = (x13 << 8) | (x13 >> 24) - x9 += x13 - x5 ^= x9 - x5 = (x5 << 7) | (x5 >> 25) - x2 += x6 - x14 ^= x2 - x14 = (x14 << 16) | (x14 >> 16) - x10 += x14 - x6 ^= x10 - x6 = (x6 << 12) | (x6 >> 20) - x2 += x6 - x14 ^= x2 - x14 = (x14 << 8) | (x14 >> 24) - x10 += x14 - x6 ^= x10 - x6 = (x6 << 7) | (x6 >> 25) - x3 += x7 - x15 ^= x3 - x15 = (x15 << 16) | (x15 >> 16) - x11 += x15 - x7 ^= x11 - x7 = (x7 << 12) | (x7 >> 20) - x3 += x7 - x15 ^= x3 - x15 = (x15 << 8) | (x15 >> 24) - x11 += x15 - x7 ^= x11 - x7 = (x7 << 7) | (x7 >> 25) - x0 += x5 - x15 ^= x0 - x15 = (x15 << 16) | (x15 >> 16) - x10 += x15 - x5 ^= x10 - x5 = (x5 << 12) | (x5 >> 20) - x0 += x5 - x15 ^= x0 - x15 = (x15 << 8) | (x15 >> 24) - x10 += x15 - x5 ^= x10 - x5 = (x5 << 7) | (x5 >> 25) - x1 += x6 - x12 ^= x1 - x12 = (x12 << 16) | (x12 >> 16) - x11 += x12 - x6 ^= x11 - x6 = (x6 << 12) | (x6 >> 20) - x1 += x6 - x12 ^= x1 - x12 = (x12 << 8) | (x12 >> 24) - x11 += x12 - x6 ^= x11 - x6 = (x6 << 7) | (x6 >> 25) - x2 += x7 - x13 ^= x2 - x13 = (x13 << 16) | (x13 >> 16) - x8 += x13 - x7 ^= x8 - x7 = (x7 << 12) | (x7 >> 20) - x2 += x7 - x13 ^= x2 - x13 = (x13 << 8) | (x13 >> 24) - x8 += x13 - x7 ^= x8 - x7 = (x7 << 7) | (x7 >> 25) - x3 += x4 - x14 ^= x3 - x14 = (x14 << 16) | (x14 >> 16) - x9 += x14 - x4 ^= x9 - x4 = (x4 << 12) | (x4 >> 20) - x3 += x4 - x14 ^= x3 - x14 = (x14 << 8) | (x14 >> 24) - x9 += x14 - x4 ^= x9 - x4 = (x4 << 7) | (x4 >> 25) - } - - x0 += j0 - x1 += j1 - x2 += j2 - x3 += j3 - x4 += j4 - x5 += j5 - x6 += j6 - x7 += j7 - x8 += j8 - x9 += j9 - x10 += j10 - x11 += j11 - x12 += j12 - x13 += j13 - x14 += j14 - x15 += j15 - - binary.LittleEndian.PutUint32(out[0:4], x0) - binary.LittleEndian.PutUint32(out[4:8], x1) - binary.LittleEndian.PutUint32(out[8:12], x2) - binary.LittleEndian.PutUint32(out[12:16], x3) - binary.LittleEndian.PutUint32(out[16:20], x4) - binary.LittleEndian.PutUint32(out[20:24], x5) - binary.LittleEndian.PutUint32(out[24:28], x6) - binary.LittleEndian.PutUint32(out[28:32], x7) - binary.LittleEndian.PutUint32(out[32:36], x8) - binary.LittleEndian.PutUint32(out[36:40], x9) - binary.LittleEndian.PutUint32(out[40:44], x10) - binary.LittleEndian.PutUint32(out[44:48], x11) - binary.LittleEndian.PutUint32(out[48:52], x12) - binary.LittleEndian.PutUint32(out[52:56], x13) - binary.LittleEndian.PutUint32(out[56:60], x14) - binary.LittleEndian.PutUint32(out[60:64], x15) -} - -// XORKeyStream crypts bytes from in to out using the given key and counters. -// In and out may be the same slice but otherwise should not overlap. Counter -// contains the raw ChaCha20 counter bytes (i.e. block counter followed by -// nonce). -func XORKeyStream(out, in []byte, counter *[16]byte, key *[32]byte) { - var block [64]byte - var counterCopy [16]byte - copy(counterCopy[:], counter[:]) - - for len(in) >= 64 { - core(&block, &counterCopy, key) - for i, x := range block { - out[i] = in[i] ^ x - } - u := uint32(1) - for i := 0; i < 4; i++ { - u += uint32(counterCopy[i]) - counterCopy[i] = byte(u) - u >>= 8 - } - in = in[64:] - out = out[64:] - } - - if len(in) > 0 { - core(&block, &counterCopy, key) - for i, v := range in { - out[i] = v ^ block[i] - } - } -} diff --git a/libgo/go/golang_org/x/crypto/chacha20poly1305/internal/chacha20/chacha_test.go b/libgo/go/golang_org/x/crypto/chacha20poly1305/internal/chacha20/chacha_test.go deleted file mode 100644 index b80d34cdd77..00000000000 --- a/libgo/go/golang_org/x/crypto/chacha20poly1305/internal/chacha20/chacha_test.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package chacha20 - -import ( - "encoding/hex" - "testing" -) - -func TestCore(t *testing.T) { - // This is just a smoke test that checks the example from - // https://tools.ietf.org/html/rfc7539#section-2.3.2. The - // chacha20poly1305 package contains much more extensive tests of this - // code. - var key [32]byte - for i := range key { - key[i] = byte(i) - } - - var input [16]byte - input[0] = 1 - input[7] = 9 - input[11] = 0x4a - - var out [64]byte - XORKeyStream(out[:], out[:], &input, &key) - const expected = "10f1e7e4d13b5915500fdd1fa32071c4c7d1f4c733c068030422aa9ac3d46c4ed2826446079faa0914c2d705d98b02a2b5129cd1de164eb9cbd083e8a2503c4e" - if result := hex.EncodeToString(out[:]); result != expected { - t.Errorf("wanted %x but got %x", expected, result) - } -} diff --git a/libgo/go/golang_org/x/net/idna/idna_test.go b/libgo/go/golang_org/x/net/idna/idna_test.go deleted file mode 100644 index b1bc6fa225c..00000000000 --- a/libgo/go/golang_org/x/net/idna/idna_test.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package idna - -import ( - "testing" -) - -var idnaTestCases = [...]struct { - ascii, unicode string -}{ - // Labels. - {"books", "books"}, - {"xn--bcher-kva", "bücher"}, - - // Domains. - {"foo--xn--bar.org", "foo--xn--bar.org"}, - {"golang.org", "golang.org"}, - {"example.xn--p1ai", "example.рф"}, - {"xn--czrw28b.tw", "商業.tw"}, - {"www.xn--mller-kva.de", "www.müller.de"}, -} - -func TestIDNA(t *testing.T) { - for _, tc := range idnaTestCases { - if a, err := ToASCII(tc.unicode); err != nil { - t.Errorf("ToASCII(%q): %v", tc.unicode, err) - } else if a != tc.ascii { - t.Errorf("ToASCII(%q): got %q, want %q", tc.unicode, a, tc.ascii) - } - - if u, err := ToUnicode(tc.ascii); err != nil { - t.Errorf("ToUnicode(%q): %v", tc.ascii, err) - } else if u != tc.unicode { - t.Errorf("ToUnicode(%q): got %q, want %q", tc.ascii, u, tc.unicode) - } - } -} - -// TODO(nigeltao): test errors, once we've specified when ToASCII and ToUnicode -// return errors. diff --git a/libgo/go/golang_org/x/net/lex/httplex/httplex.go b/libgo/go/golang_org/x/net/lex/httplex/httplex.go deleted file mode 100644 index b6493f045a2..00000000000 --- a/libgo/go/golang_org/x/net/lex/httplex/httplex.go +++ /dev/null @@ -1,351 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package httplex contains rules around lexical matters of various -// HTTP-related specifications. -// -// This package is shared by the standard library (which vendors it) -// and x/net/http2. It comes with no API stability promise. -package httplex - -import ( - "net" - "strings" - "unicode/utf8" - - "golang_org/x/net/idna" -) - -var isTokenTable = [127]bool{ - '!': true, - '#': true, - '$': true, - '%': true, - '&': true, - '\'': true, - '*': true, - '+': true, - '-': true, - '.': true, - '0': true, - '1': true, - '2': true, - '3': true, - '4': true, - '5': true, - '6': true, - '7': true, - '8': true, - '9': true, - 'A': true, - 'B': true, - 'C': true, - 'D': true, - 'E': true, - 'F': true, - 'G': true, - 'H': true, - 'I': true, - 'J': true, - 'K': true, - 'L': true, - 'M': true, - 'N': true, - 'O': true, - 'P': true, - 'Q': true, - 'R': true, - 'S': true, - 'T': true, - 'U': true, - 'W': true, - 'V': true, - 'X': true, - 'Y': true, - 'Z': true, - '^': true, - '_': true, - '`': true, - 'a': true, - 'b': true, - 'c': true, - 'd': true, - 'e': true, - 'f': true, - 'g': true, - 'h': true, - 'i': true, - 'j': true, - 'k': true, - 'l': true, - 'm': true, - 'n': true, - 'o': true, - 'p': true, - 'q': true, - 'r': true, - 's': true, - 't': true, - 'u': true, - 'v': true, - 'w': true, - 'x': true, - 'y': true, - 'z': true, - '|': true, - '~': true, -} - -func IsTokenRune(r rune) bool { - i := int(r) - return i < len(isTokenTable) && isTokenTable[i] -} - -func isNotToken(r rune) bool { - return !IsTokenRune(r) -} - -// HeaderValuesContainsToken reports whether any string in values -// contains the provided token, ASCII case-insensitively. -func HeaderValuesContainsToken(values []string, token string) bool { - for _, v := range values { - if headerValueContainsToken(v, token) { - return true - } - } - return false -} - -// isOWS reports whether b is an optional whitespace byte, as defined -// by RFC 7230 section 3.2.3. -func isOWS(b byte) bool { return b == ' ' || b == '\t' } - -// trimOWS returns x with all optional whitespace removes from the -// beginning and end. -func trimOWS(x string) string { - // TODO: consider using strings.Trim(x, " \t") instead, - // if and when it's fast enough. See issue 10292. - // But this ASCII-only code will probably always beat UTF-8 - // aware code. - for len(x) > 0 && isOWS(x[0]) { - x = x[1:] - } - for len(x) > 0 && isOWS(x[len(x)-1]) { - x = x[:len(x)-1] - } - return x -} - -// headerValueContainsToken reports whether v (assumed to be a -// 0#element, in the ABNF extension described in RFC 7230 section 7) -// contains token amongst its comma-separated tokens, ASCII -// case-insensitively. -func headerValueContainsToken(v string, token string) bool { - v = trimOWS(v) - if comma := strings.IndexByte(v, ','); comma != -1 { - return tokenEqual(trimOWS(v[:comma]), token) || headerValueContainsToken(v[comma+1:], token) - } - return tokenEqual(v, token) -} - -// lowerASCII returns the ASCII lowercase version of b. -func lowerASCII(b byte) byte { - if 'A' <= b && b <= 'Z' { - return b + ('a' - 'A') - } - return b -} - -// tokenEqual reports whether t1 and t2 are equal, ASCII case-insensitively. -func tokenEqual(t1, t2 string) bool { - if len(t1) != len(t2) { - return false - } - for i, b := range t1 { - if b >= utf8.RuneSelf { - // No UTF-8 or non-ASCII allowed in tokens. - return false - } - if lowerASCII(byte(b)) != lowerASCII(t2[i]) { - return false - } - } - return true -} - -// isLWS reports whether b is linear white space, according -// to http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2 -// LWS = [CRLF] 1*( SP | HT ) -func isLWS(b byte) bool { return b == ' ' || b == '\t' } - -// isCTL reports whether b is a control byte, according -// to http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2 -// CTL = -func isCTL(b byte) bool { - const del = 0x7f // a CTL - return b < ' ' || b == del -} - -// ValidHeaderFieldName reports whether v is a valid HTTP/1.x header name. -// HTTP/2 imposes the additional restriction that uppercase ASCII -// letters are not allowed. -// -// RFC 7230 says: -// header-field = field-name ":" OWS field-value OWS -// field-name = token -// token = 1*tchar -// tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." / -// "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA -func ValidHeaderFieldName(v string) bool { - if len(v) == 0 { - return false - } - for _, r := range v { - if !IsTokenRune(r) { - return false - } - } - return true -} - -// ValidHostHeader reports whether h is a valid host header. -func ValidHostHeader(h string) bool { - // The latest spec is actually this: - // - // http://tools.ietf.org/html/rfc7230#section-5.4 - // Host = uri-host [ ":" port ] - // - // Where uri-host is: - // http://tools.ietf.org/html/rfc3986#section-3.2.2 - // - // But we're going to be much more lenient for now and just - // search for any byte that's not a valid byte in any of those - // expressions. - for i := 0; i < len(h); i++ { - if !validHostByte[h[i]] { - return false - } - } - return true -} - -// See the validHostHeader comment. -var validHostByte = [256]bool{ - '0': true, '1': true, '2': true, '3': true, '4': true, '5': true, '6': true, '7': true, - '8': true, '9': true, - - 'a': true, 'b': true, 'c': true, 'd': true, 'e': true, 'f': true, 'g': true, 'h': true, - 'i': true, 'j': true, 'k': true, 'l': true, 'm': true, 'n': true, 'o': true, 'p': true, - 'q': true, 'r': true, 's': true, 't': true, 'u': true, 'v': true, 'w': true, 'x': true, - 'y': true, 'z': true, - - 'A': true, 'B': true, 'C': true, 'D': true, 'E': true, 'F': true, 'G': true, 'H': true, - 'I': true, 'J': true, 'K': true, 'L': true, 'M': true, 'N': true, 'O': true, 'P': true, - 'Q': true, 'R': true, 'S': true, 'T': true, 'U': true, 'V': true, 'W': true, 'X': true, - 'Y': true, 'Z': true, - - '!': true, // sub-delims - '$': true, // sub-delims - '%': true, // pct-encoded (and used in IPv6 zones) - '&': true, // sub-delims - '(': true, // sub-delims - ')': true, // sub-delims - '*': true, // sub-delims - '+': true, // sub-delims - ',': true, // sub-delims - '-': true, // unreserved - '.': true, // unreserved - ':': true, // IPv6address + Host expression's optional port - ';': true, // sub-delims - '=': true, // sub-delims - '[': true, - '\'': true, // sub-delims - ']': true, - '_': true, // unreserved - '~': true, // unreserved -} - -// ValidHeaderFieldValue reports whether v is a valid "field-value" according to -// http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2 : -// -// message-header = field-name ":" [ field-value ] -// field-value = *( field-content | LWS ) -// field-content = -// -// http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2 : -// -// TEXT = -// LWS = [CRLF] 1*( SP | HT ) -// CTL = -// -// RFC 7230 says: -// field-value = *( field-content / obs-fold ) -// obj-fold = N/A to http2, and deprecated -// field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] -// field-vchar = VCHAR / obs-text -// obs-text = %x80-FF -// VCHAR = "any visible [USASCII] character" -// -// http2 further says: "Similarly, HTTP/2 allows header field values -// that are not valid. While most of the values that can be encoded -// will not alter header field parsing, carriage return (CR, ASCII -// 0xd), line feed (LF, ASCII 0xa), and the zero character (NUL, ASCII -// 0x0) might be exploited by an attacker if they are translated -// verbatim. Any request or response that contains a character not -// permitted in a header field value MUST be treated as malformed -// (Section 8.1.2.6). Valid characters are defined by the -// field-content ABNF rule in Section 3.2 of [RFC7230]." -// -// This function does not (yet?) properly handle the rejection of -// strings that begin or end with SP or HTAB. -func ValidHeaderFieldValue(v string) bool { - for i := 0; i < len(v); i++ { - b := v[i] - if isCTL(b) && !isLWS(b) { - return false - } - } - return true -} - -func isASCII(s string) bool { - for i := 0; i < len(s); i++ { - if s[i] >= utf8.RuneSelf { - return false - } - } - return true -} - -// PunycodeHostPort returns the IDNA Punycode version -// of the provided "host" or "host:port" string. -func PunycodeHostPort(v string) (string, error) { - if isASCII(v) { - return v, nil - } - - host, port, err := net.SplitHostPort(v) - if err != nil { - // The input 'v' argument was just a "host" argument, - // without a port. This error should not be returned - // to the caller. - host = v - port = "" - } - host, err = idna.ToASCII(host) - if err != nil { - // Non-UTF-8? Not representable in Punycode, in any - // case. - return "", err - } - if port == "" { - return host, nil - } - return net.JoinHostPort(host, port), nil -} diff --git a/libgo/go/golang_org/x/net/lex/httplex/httplex_test.go b/libgo/go/golang_org/x/net/lex/httplex/httplex_test.go deleted file mode 100644 index f47adc939fe..00000000000 --- a/libgo/go/golang_org/x/net/lex/httplex/httplex_test.go +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package httplex - -import ( - "testing" -) - -func isChar(c rune) bool { return c <= 127 } - -func isCtl(c rune) bool { return c <= 31 || c == 127 } - -func isSeparator(c rune) bool { - switch c { - case '(', ')', '<', '>', '@', ',', ';', ':', '\\', '"', '/', '[', ']', '?', '=', '{', '}', ' ', '\t': - return true - } - return false -} - -func TestIsToken(t *testing.T) { - for i := 0; i <= 130; i++ { - r := rune(i) - expected := isChar(r) && !isCtl(r) && !isSeparator(r) - if IsTokenRune(r) != expected { - t.Errorf("isToken(0x%x) = %v", r, !expected) - } - } -} - -func TestHeaderValuesContainsToken(t *testing.T) { - tests := []struct { - vals []string - token string - want bool - }{ - { - vals: []string{"foo"}, - token: "foo", - want: true, - }, - { - vals: []string{"bar", "foo"}, - token: "foo", - want: true, - }, - { - vals: []string{"foo"}, - token: "FOO", - want: true, - }, - { - vals: []string{"foo"}, - token: "bar", - want: false, - }, - { - vals: []string{" foo "}, - token: "FOO", - want: true, - }, - { - vals: []string{"foo,bar"}, - token: "FOO", - want: true, - }, - { - vals: []string{"bar,foo,bar"}, - token: "FOO", - want: true, - }, - { - vals: []string{"bar , foo"}, - token: "FOO", - want: true, - }, - { - vals: []string{"foo ,bar "}, - token: "FOO", - want: true, - }, - { - vals: []string{"bar, foo ,bar"}, - token: "FOO", - want: true, - }, - { - vals: []string{"bar , foo"}, - token: "FOO", - want: true, - }, - } - for _, tt := range tests { - got := HeaderValuesContainsToken(tt.vals, tt.token) - if got != tt.want { - t.Errorf("headerValuesContainsToken(%q, %q) = %v; want %v", tt.vals, tt.token, got, tt.want) - } - } -} - -func TestPunycodeHostPort(t *testing.T) { - tests := []struct { - in, want string - }{ - {"www.google.com", "www.google.com"}, - {"гофер.рф", "xn--c1ae0ajs.xn--p1ai"}, - {"bücher.de", "xn--bcher-kva.de"}, - {"bücher.de:8080", "xn--bcher-kva.de:8080"}, - {"[1::6]:8080", "[1::6]:8080"}, - } - for _, tt := range tests { - got, err := PunycodeHostPort(tt.in) - if tt.want != got || err != nil { - t.Errorf("PunycodeHostPort(%q) = %q, %v, want %q, nil", tt.in, got, err, tt.want) - } - } -} diff --git a/libgo/go/golang_org/x/net/lif/syscall.go b/libgo/go/golang_org/x/net/lif/syscall.go deleted file mode 100644 index ea7541456bd..00000000000 --- a/libgo/go/golang_org/x/net/lif/syscall.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build solaris - -package lif - -import ( - "syscall" - "unsafe" -) - -//extern __go_ioctl_ptr -func libc_ioctl(int32, int32, unsafe.Pointer) int32 - -func ioctl(s, ioc uintptr, arg unsafe.Pointer) error { - if libc_ioctl(int32(s), int32(ioc), arg) < 0 { - return syscall.GetErrno() - } - return nil -} diff --git a/libgo/go/golang_org/x/net/proxy/direct.go b/libgo/go/golang_org/x/net/proxy/direct.go deleted file mode 100644 index 4c5ad88b1e7..00000000000 --- a/libgo/go/golang_org/x/net/proxy/direct.go +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package proxy - -import ( - "net" -) - -type direct struct{} - -// Direct is a direct proxy: one that makes network connections directly. -var Direct = direct{} - -func (direct) Dial(network, addr string) (net.Conn, error) { - return net.Dial(network, addr) -} diff --git a/libgo/go/golang_org/x/net/proxy/per_host.go b/libgo/go/golang_org/x/net/proxy/per_host.go deleted file mode 100644 index f540b196f7d..00000000000 --- a/libgo/go/golang_org/x/net/proxy/per_host.go +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package proxy - -import ( - "net" - "strings" -) - -// A PerHost directs connections to a default Dialer unless the hostname -// requested matches one of a number of exceptions. -type PerHost struct { - def, bypass Dialer - - bypassNetworks []*net.IPNet - bypassIPs []net.IP - bypassZones []string - bypassHosts []string -} - -// NewPerHost returns a PerHost Dialer that directs connections to either -// defaultDialer or bypass, depending on whether the connection matches one of -// the configured rules. -func NewPerHost(defaultDialer, bypass Dialer) *PerHost { - return &PerHost{ - def: defaultDialer, - bypass: bypass, - } -} - -// Dial connects to the address addr on the given network through either -// defaultDialer or bypass. -func (p *PerHost) Dial(network, addr string) (c net.Conn, err error) { - host, _, err := net.SplitHostPort(addr) - if err != nil { - return nil, err - } - - return p.dialerForRequest(host).Dial(network, addr) -} - -func (p *PerHost) dialerForRequest(host string) Dialer { - if ip := net.ParseIP(host); ip != nil { - for _, net := range p.bypassNetworks { - if net.Contains(ip) { - return p.bypass - } - } - for _, bypassIP := range p.bypassIPs { - if bypassIP.Equal(ip) { - return p.bypass - } - } - return p.def - } - - for _, zone := range p.bypassZones { - if strings.HasSuffix(host, zone) { - return p.bypass - } - if host == zone[1:] { - // For a zone "example.com", we match "example.com" - // too. - return p.bypass - } - } - for _, bypassHost := range p.bypassHosts { - if bypassHost == host { - return p.bypass - } - } - return p.def -} - -// AddFromString parses a string that contains comma-separated values -// specifying hosts that should use the bypass proxy. Each value is either an -// IP address, a CIDR range, a zone (*.example.com) or a hostname -// (localhost). A best effort is made to parse the string and errors are -// ignored. -func (p *PerHost) AddFromString(s string) { - hosts := strings.Split(s, ",") - for _, host := range hosts { - host = strings.TrimSpace(host) - if len(host) == 0 { - continue - } - if strings.Contains(host, "/") { - // We assume that it's a CIDR address like 127.0.0.0/8 - if _, net, err := net.ParseCIDR(host); err == nil { - p.AddNetwork(net) - } - continue - } - if ip := net.ParseIP(host); ip != nil { - p.AddIP(ip) - continue - } - if strings.HasPrefix(host, "*.") { - p.AddZone(host[1:]) - continue - } - p.AddHost(host) - } -} - -// AddIP specifies an IP address that will use the bypass proxy. Note that -// this will only take effect if a literal IP address is dialed. A connection -// to a named host will never match an IP. -func (p *PerHost) AddIP(ip net.IP) { - p.bypassIPs = append(p.bypassIPs, ip) -} - -// AddNetwork specifies an IP range that will use the bypass proxy. Note that -// this will only take effect if a literal IP address is dialed. A connection -// to a named host will never match. -func (p *PerHost) AddNetwork(net *net.IPNet) { - p.bypassNetworks = append(p.bypassNetworks, net) -} - -// AddZone specifies a DNS suffix that will use the bypass proxy. A zone of -// "example.com" matches "example.com" and all of its subdomains. -func (p *PerHost) AddZone(zone string) { - if strings.HasSuffix(zone, ".") { - zone = zone[:len(zone)-1] - } - if !strings.HasPrefix(zone, ".") { - zone = "." + zone - } - p.bypassZones = append(p.bypassZones, zone) -} - -// AddHost specifies a hostname that will use the bypass proxy. -func (p *PerHost) AddHost(host string) { - if strings.HasSuffix(host, ".") { - host = host[:len(host)-1] - } - p.bypassHosts = append(p.bypassHosts, host) -} diff --git a/libgo/go/golang_org/x/net/proxy/per_host_test.go b/libgo/go/golang_org/x/net/proxy/per_host_test.go deleted file mode 100644 index a7d80957113..00000000000 --- a/libgo/go/golang_org/x/net/proxy/per_host_test.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package proxy - -import ( - "errors" - "net" - "reflect" - "testing" -) - -type recordingProxy struct { - addrs []string -} - -func (r *recordingProxy) Dial(network, addr string) (net.Conn, error) { - r.addrs = append(r.addrs, addr) - return nil, errors.New("recordingProxy") -} - -func TestPerHost(t *testing.T) { - var def, bypass recordingProxy - perHost := NewPerHost(&def, &bypass) - perHost.AddFromString("localhost,*.zone,127.0.0.1,10.0.0.1/8,1000::/16") - - expectedDef := []string{ - "example.com:123", - "1.2.3.4:123", - "[1001::]:123", - } - expectedBypass := []string{ - "localhost:123", - "zone:123", - "foo.zone:123", - "127.0.0.1:123", - "10.1.2.3:123", - "[1000::]:123", - } - - for _, addr := range expectedDef { - perHost.Dial("tcp", addr) - } - for _, addr := range expectedBypass { - perHost.Dial("tcp", addr) - } - - if !reflect.DeepEqual(expectedDef, def.addrs) { - t.Errorf("Hosts which went to the default proxy didn't match. Got %v, want %v", def.addrs, expectedDef) - } - if !reflect.DeepEqual(expectedBypass, bypass.addrs) { - t.Errorf("Hosts which went to the bypass proxy didn't match. Got %v, want %v", bypass.addrs, expectedBypass) - } -} diff --git a/libgo/go/golang_org/x/net/proxy/proxy.go b/libgo/go/golang_org/x/net/proxy/proxy.go deleted file mode 100644 index 78a8b7bee97..00000000000 --- a/libgo/go/golang_org/x/net/proxy/proxy.go +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package proxy provides support for a variety of protocols to proxy network -// data. -package proxy // import "golang.org/x/net/proxy" - -import ( - "errors" - "net" - "net/url" - "os" -) - -// A Dialer is a means to establish a connection. -type Dialer interface { - // Dial connects to the given address via the proxy. - Dial(network, addr string) (c net.Conn, err error) -} - -// Auth contains authentication parameters that specific Dialers may require. -type Auth struct { - User, Password string -} - -// FromEnvironment returns the dialer specified by the proxy related variables in -// the environment. -func FromEnvironment() Dialer { - allProxy := os.Getenv("all_proxy") - if len(allProxy) == 0 { - return Direct - } - - proxyURL, err := url.Parse(allProxy) - if err != nil { - return Direct - } - proxy, err := FromURL(proxyURL, Direct) - if err != nil { - return Direct - } - - noProxy := os.Getenv("no_proxy") - if len(noProxy) == 0 { - return proxy - } - - perHost := NewPerHost(proxy, Direct) - perHost.AddFromString(noProxy) - return perHost -} - -// proxySchemes is a map from URL schemes to a function that creates a Dialer -// from a URL with such a scheme. -var proxySchemes map[string]func(*url.URL, Dialer) (Dialer, error) - -// RegisterDialerType takes a URL scheme and a function to generate Dialers from -// a URL with that scheme and a forwarding Dialer. Registered schemes are used -// by FromURL. -func RegisterDialerType(scheme string, f func(*url.URL, Dialer) (Dialer, error)) { - if proxySchemes == nil { - proxySchemes = make(map[string]func(*url.URL, Dialer) (Dialer, error)) - } - proxySchemes[scheme] = f -} - -// FromURL returns a Dialer given a URL specification and an underlying -// Dialer for it to make network requests. -func FromURL(u *url.URL, forward Dialer) (Dialer, error) { - var auth *Auth - if u.User != nil { - auth = new(Auth) - auth.User = u.User.Username() - if p, ok := u.User.Password(); ok { - auth.Password = p - } - } - - switch u.Scheme { - case "socks5": - return SOCKS5("tcp", u.Host, auth, forward) - } - - // If the scheme doesn't match any of the built-in schemes, see if it - // was registered by another package. - if proxySchemes != nil { - if f, ok := proxySchemes[u.Scheme]; ok { - return f(u, forward) - } - } - - return nil, errors.New("proxy: unknown scheme: " + u.Scheme) -} diff --git a/libgo/go/golang_org/x/net/proxy/proxy_test.go b/libgo/go/golang_org/x/net/proxy/proxy_test.go deleted file mode 100644 index c19a5c06353..00000000000 --- a/libgo/go/golang_org/x/net/proxy/proxy_test.go +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package proxy - -import ( - "io" - "net" - "net/url" - "strconv" - "sync" - "testing" -) - -func TestFromURL(t *testing.T) { - endSystem, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - t.Fatalf("net.Listen failed: %v", err) - } - defer endSystem.Close() - gateway, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - t.Fatalf("net.Listen failed: %v", err) - } - defer gateway.Close() - - var wg sync.WaitGroup - wg.Add(1) - go socks5Gateway(t, gateway, endSystem, socks5Domain, &wg) - - url, err := url.Parse("socks5://user:password@" + gateway.Addr().String()) - if err != nil { - t.Fatalf("url.Parse failed: %v", err) - } - proxy, err := FromURL(url, Direct) - if err != nil { - t.Fatalf("FromURL failed: %v", err) - } - _, port, err := net.SplitHostPort(endSystem.Addr().String()) - if err != nil { - t.Fatalf("net.SplitHostPort failed: %v", err) - } - if c, err := proxy.Dial("tcp", "localhost:"+port); err != nil { - t.Fatalf("FromURL.Dial failed: %v", err) - } else { - c.Close() - } - - wg.Wait() -} - -func TestSOCKS5(t *testing.T) { - endSystem, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - t.Fatalf("net.Listen failed: %v", err) - } - defer endSystem.Close() - gateway, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - t.Fatalf("net.Listen failed: %v", err) - } - defer gateway.Close() - - var wg sync.WaitGroup - wg.Add(1) - go socks5Gateway(t, gateway, endSystem, socks5IP4, &wg) - - proxy, err := SOCKS5("tcp", gateway.Addr().String(), nil, Direct) - if err != nil { - t.Fatalf("SOCKS5 failed: %v", err) - } - if c, err := proxy.Dial("tcp", endSystem.Addr().String()); err != nil { - t.Fatalf("SOCKS5.Dial failed: %v", err) - } else { - c.Close() - } - - wg.Wait() -} - -func socks5Gateway(t *testing.T, gateway, endSystem net.Listener, typ byte, wg *sync.WaitGroup) { - defer wg.Done() - - c, err := gateway.Accept() - if err != nil { - t.Errorf("net.Listener.Accept failed: %v", err) - return - } - defer c.Close() - - b := make([]byte, 32) - var n int - if typ == socks5Domain { - n = 4 - } else { - n = 3 - } - if _, err := io.ReadFull(c, b[:n]); err != nil { - t.Errorf("io.ReadFull failed: %v", err) - return - } - if _, err := c.Write([]byte{socks5Version, socks5AuthNone}); err != nil { - t.Errorf("net.Conn.Write failed: %v", err) - return - } - if typ == socks5Domain { - n = 16 - } else { - n = 10 - } - if _, err := io.ReadFull(c, b[:n]); err != nil { - t.Errorf("io.ReadFull failed: %v", err) - return - } - if b[0] != socks5Version || b[1] != socks5Connect || b[2] != 0x00 || b[3] != typ { - t.Errorf("got an unexpected packet: %#02x %#02x %#02x %#02x", b[0], b[1], b[2], b[3]) - return - } - if typ == socks5Domain { - copy(b[:5], []byte{socks5Version, 0x00, 0x00, socks5Domain, 9}) - b = append(b, []byte("localhost")...) - } else { - copy(b[:4], []byte{socks5Version, 0x00, 0x00, socks5IP4}) - } - host, port, err := net.SplitHostPort(endSystem.Addr().String()) - if err != nil { - t.Errorf("net.SplitHostPort failed: %v", err) - return - } - b = append(b, []byte(net.ParseIP(host).To4())...) - p, err := strconv.Atoi(port) - if err != nil { - t.Errorf("strconv.Atoi failed: %v", err) - return - } - b = append(b, []byte{byte(p >> 8), byte(p)}...) - if _, err := c.Write(b); err != nil { - t.Errorf("net.Conn.Write failed: %v", err) - return - } -} diff --git a/libgo/go/golang_org/x/net/proxy/socks5.go b/libgo/go/golang_org/x/net/proxy/socks5.go deleted file mode 100644 index 973f57f1970..00000000000 --- a/libgo/go/golang_org/x/net/proxy/socks5.go +++ /dev/null @@ -1,213 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package proxy - -import ( - "errors" - "io" - "net" - "strconv" -) - -// SOCKS5 returns a Dialer that makes SOCKSv5 connections to the given address -// with an optional username and password. See RFC 1928. -func SOCKS5(network, addr string, auth *Auth, forward Dialer) (Dialer, error) { - s := &socks5{ - network: network, - addr: addr, - forward: forward, - } - if auth != nil { - s.user = auth.User - s.password = auth.Password - } - - return s, nil -} - -type socks5 struct { - user, password string - network, addr string - forward Dialer -} - -const socks5Version = 5 - -const ( - socks5AuthNone = 0 - socks5AuthPassword = 2 -) - -const socks5Connect = 1 - -const ( - socks5IP4 = 1 - socks5Domain = 3 - socks5IP6 = 4 -) - -var socks5Errors = []string{ - "", - "general failure", - "connection forbidden", - "network unreachable", - "host unreachable", - "connection refused", - "TTL expired", - "command not supported", - "address type not supported", -} - -// Dial connects to the address addr on the network net via the SOCKS5 proxy. -func (s *socks5) Dial(network, addr string) (net.Conn, error) { - switch network { - case "tcp", "tcp6", "tcp4": - default: - return nil, errors.New("proxy: no support for SOCKS5 proxy connections of type " + network) - } - - conn, err := s.forward.Dial(s.network, s.addr) - if err != nil { - return nil, err - } - if err := s.connect(conn, addr); err != nil { - conn.Close() - return nil, err - } - return conn, nil -} - -// connect takes an existing connection to a socks5 proxy server, -// and commands the server to extend that connection to target, -// which must be a canonical address with a host and port. -func (s *socks5) connect(conn net.Conn, target string) error { - host, portStr, err := net.SplitHostPort(target) - if err != nil { - return err - } - - port, err := strconv.Atoi(portStr) - if err != nil { - return errors.New("proxy: failed to parse port number: " + portStr) - } - if port < 1 || port > 0xffff { - return errors.New("proxy: port number out of range: " + portStr) - } - - // the size here is just an estimate - buf := make([]byte, 0, 6+len(host)) - - buf = append(buf, socks5Version) - if len(s.user) > 0 && len(s.user) < 256 && len(s.password) < 256 { - buf = append(buf, 2 /* num auth methods */, socks5AuthNone, socks5AuthPassword) - } else { - buf = append(buf, 1 /* num auth methods */, socks5AuthNone) - } - - if _, err := conn.Write(buf); err != nil { - return errors.New("proxy: failed to write greeting to SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - if _, err := io.ReadFull(conn, buf[:2]); err != nil { - return errors.New("proxy: failed to read greeting from SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - if buf[0] != 5 { - return errors.New("proxy: SOCKS5 proxy at " + s.addr + " has unexpected version " + strconv.Itoa(int(buf[0]))) - } - if buf[1] == 0xff { - return errors.New("proxy: SOCKS5 proxy at " + s.addr + " requires authentication") - } - - if buf[1] == socks5AuthPassword { - buf = buf[:0] - buf = append(buf, 1 /* password protocol version */) - buf = append(buf, uint8(len(s.user))) - buf = append(buf, s.user...) - buf = append(buf, uint8(len(s.password))) - buf = append(buf, s.password...) - - if _, err := conn.Write(buf); err != nil { - return errors.New("proxy: failed to write authentication request to SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - if _, err := io.ReadFull(conn, buf[:2]); err != nil { - return errors.New("proxy: failed to read authentication reply from SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - if buf[1] != 0 { - return errors.New("proxy: SOCKS5 proxy at " + s.addr + " rejected username/password") - } - } - - buf = buf[:0] - buf = append(buf, socks5Version, socks5Connect, 0 /* reserved */) - - if ip := net.ParseIP(host); ip != nil { - if ip4 := ip.To4(); ip4 != nil { - buf = append(buf, socks5IP4) - ip = ip4 - } else { - buf = append(buf, socks5IP6) - } - buf = append(buf, ip...) - } else { - if len(host) > 255 { - return errors.New("proxy: destination hostname too long: " + host) - } - buf = append(buf, socks5Domain) - buf = append(buf, byte(len(host))) - buf = append(buf, host...) - } - buf = append(buf, byte(port>>8), byte(port)) - - if _, err := conn.Write(buf); err != nil { - return errors.New("proxy: failed to write connect request to SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - if _, err := io.ReadFull(conn, buf[:4]); err != nil { - return errors.New("proxy: failed to read connect reply from SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - failure := "unknown error" - if int(buf[1]) < len(socks5Errors) { - failure = socks5Errors[buf[1]] - } - - if len(failure) > 0 { - return errors.New("proxy: SOCKS5 proxy at " + s.addr + " failed to connect: " + failure) - } - - bytesToDiscard := 0 - switch buf[3] { - case socks5IP4: - bytesToDiscard = net.IPv4len - case socks5IP6: - bytesToDiscard = net.IPv6len - case socks5Domain: - _, err := io.ReadFull(conn, buf[:1]) - if err != nil { - return errors.New("proxy: failed to read domain length from SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - bytesToDiscard = int(buf[0]) - default: - return errors.New("proxy: got unknown address type " + strconv.Itoa(int(buf[3])) + " from SOCKS5 proxy at " + s.addr) - } - - if cap(buf) < bytesToDiscard { - buf = make([]byte, bytesToDiscard) - } else { - buf = buf[:bytesToDiscard] - } - if _, err := io.ReadFull(conn, buf); err != nil { - return errors.New("proxy: failed to read address from SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - // Also need to discard the port number - if _, err := io.ReadFull(conn, buf[:2]); err != nil { - return errors.New("proxy: failed to read port from SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - return nil -} diff --git a/libgo/go/golang_org/x/text/width/kind_string.go b/libgo/go/golang_org/x/text/width/kind_string.go deleted file mode 100644 index ab4fee542f3..00000000000 --- a/libgo/go/golang_org/x/text/width/kind_string.go +++ /dev/null @@ -1,16 +0,0 @@ -// Code generated by "stringer -type=Kind"; DO NOT EDIT - -package width - -import "fmt" - -const _Kind_name = "NeutralEastAsianAmbiguousEastAsianWideEastAsianNarrowEastAsianFullwidthEastAsianHalfwidth" - -var _Kind_index = [...]uint8{0, 7, 25, 38, 53, 71, 89} - -func (i Kind) String() string { - if i < 0 || i >= Kind(len(_Kind_index)-1) { - return fmt.Sprintf("Kind(%d)", i) - } - return _Kind_name[_Kind_index[i]:_Kind_index[i+1]] -} diff --git a/libgo/go/golang_org/x/text/width/tables.go b/libgo/go/golang_org/x/text/width/tables.go deleted file mode 100644 index 242da0fdb9c..00000000000 --- a/libgo/go/golang_org/x/text/width/tables.go +++ /dev/null @@ -1,1284 +0,0 @@ -// This file was generated by go generate; DO NOT EDIT - -package width - -// UnicodeVersion is the Unicode version from which the tables in this package are derived. -const UnicodeVersion = "9.0.0" - -// lookup returns the trie value for the first UTF-8 encoding in s and -// the width in bytes of this encoding. The size will be 0 if s does not -// hold enough bytes to complete the encoding. len(s) must be greater than 0. -func (t *widthTrie) lookup(s []byte) (v uint16, sz int) { - c0 := s[0] - switch { - case c0 < 0x80: // is ASCII - return widthValues[c0], 1 - case c0 < 0xC2: - return 0, 1 // Illegal UTF-8: not a starter, not ASCII. - case c0 < 0xE0: // 2-byte UTF-8 - if len(s) < 2 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c1), 2 - case c0 < 0xF0: // 3-byte UTF-8 - if len(s) < 3 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c2), 3 - case c0 < 0xF8: // 4-byte UTF-8 - if len(s) < 4 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - o = uint32(i)<<6 + uint32(c2) - i = widthIndex[o] - c3 := s[3] - if c3 < 0x80 || 0xC0 <= c3 { - return 0, 3 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c3), 4 - } - // Illegal rune - return 0, 1 -} - -// lookupUnsafe returns the trie value for the first UTF-8 encoding in s. -// s must start with a full and valid UTF-8 encoded rune. -func (t *widthTrie) lookupUnsafe(s []byte) uint16 { - c0 := s[0] - if c0 < 0x80 { // is ASCII - return widthValues[c0] - } - i := widthIndex[c0] - if c0 < 0xE0 { // 2-byte UTF-8 - return t.lookupValue(uint32(i), s[1]) - } - i = widthIndex[uint32(i)<<6+uint32(s[1])] - if c0 < 0xF0 { // 3-byte UTF-8 - return t.lookupValue(uint32(i), s[2]) - } - i = widthIndex[uint32(i)<<6+uint32(s[2])] - if c0 < 0xF8 { // 4-byte UTF-8 - return t.lookupValue(uint32(i), s[3]) - } - return 0 -} - -// lookupString returns the trie value for the first UTF-8 encoding in s and -// the width in bytes of this encoding. The size will be 0 if s does not -// hold enough bytes to complete the encoding. len(s) must be greater than 0. -func (t *widthTrie) lookupString(s string) (v uint16, sz int) { - c0 := s[0] - switch { - case c0 < 0x80: // is ASCII - return widthValues[c0], 1 - case c0 < 0xC2: - return 0, 1 // Illegal UTF-8: not a starter, not ASCII. - case c0 < 0xE0: // 2-byte UTF-8 - if len(s) < 2 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c1), 2 - case c0 < 0xF0: // 3-byte UTF-8 - if len(s) < 3 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c2), 3 - case c0 < 0xF8: // 4-byte UTF-8 - if len(s) < 4 { - return 0, 0 - } - i := widthIndex[c0] - c1 := s[1] - if c1 < 0x80 || 0xC0 <= c1 { - return 0, 1 // Illegal UTF-8: not a continuation byte. - } - o := uint32(i)<<6 + uint32(c1) - i = widthIndex[o] - c2 := s[2] - if c2 < 0x80 || 0xC0 <= c2 { - return 0, 2 // Illegal UTF-8: not a continuation byte. - } - o = uint32(i)<<6 + uint32(c2) - i = widthIndex[o] - c3 := s[3] - if c3 < 0x80 || 0xC0 <= c3 { - return 0, 3 // Illegal UTF-8: not a continuation byte. - } - return t.lookupValue(uint32(i), c3), 4 - } - // Illegal rune - return 0, 1 -} - -// lookupStringUnsafe returns the trie value for the first UTF-8 encoding in s. -// s must start with a full and valid UTF-8 encoded rune. -func (t *widthTrie) lookupStringUnsafe(s string) uint16 { - c0 := s[0] - if c0 < 0x80 { // is ASCII - return widthValues[c0] - } - i := widthIndex[c0] - if c0 < 0xE0 { // 2-byte UTF-8 - return t.lookupValue(uint32(i), s[1]) - } - i = widthIndex[uint32(i)<<6+uint32(s[1])] - if c0 < 0xF0 { // 3-byte UTF-8 - return t.lookupValue(uint32(i), s[2]) - } - i = widthIndex[uint32(i)<<6+uint32(s[2])] - if c0 < 0xF8 { // 4-byte UTF-8 - return t.lookupValue(uint32(i), s[3]) - } - return 0 -} - -// widthTrie. Total size: 14080 bytes (13.75 KiB). Checksum: 3b8aeb3dc03667a3. -type widthTrie struct{} - -func newWidthTrie(i int) *widthTrie { - return &widthTrie{} -} - -// lookupValue determines the type of block n and looks up the value for b. -func (t *widthTrie) lookupValue(n uint32, b byte) uint16 { - switch { - default: - return uint16(widthValues[n<<6+uint32(b)]) - } -} - -// widthValues: 99 blocks, 6336 entries, 12672 bytes -// The third block is the zero block. -var widthValues = [6336]uint16{ - // Block 0x0, offset 0x0 - 0x20: 0x6001, 0x21: 0x6002, 0x22: 0x6002, 0x23: 0x6002, - 0x24: 0x6002, 0x25: 0x6002, 0x26: 0x6002, 0x27: 0x6002, 0x28: 0x6002, 0x29: 0x6002, - 0x2a: 0x6002, 0x2b: 0x6002, 0x2c: 0x6002, 0x2d: 0x6002, 0x2e: 0x6002, 0x2f: 0x6002, - 0x30: 0x6002, 0x31: 0x6002, 0x32: 0x6002, 0x33: 0x6002, 0x34: 0x6002, 0x35: 0x6002, - 0x36: 0x6002, 0x37: 0x6002, 0x38: 0x6002, 0x39: 0x6002, 0x3a: 0x6002, 0x3b: 0x6002, - 0x3c: 0x6002, 0x3d: 0x6002, 0x3e: 0x6002, 0x3f: 0x6002, - // Block 0x1, offset 0x40 - 0x40: 0x6003, 0x41: 0x6003, 0x42: 0x6003, 0x43: 0x6003, 0x44: 0x6003, 0x45: 0x6003, - 0x46: 0x6003, 0x47: 0x6003, 0x48: 0x6003, 0x49: 0x6003, 0x4a: 0x6003, 0x4b: 0x6003, - 0x4c: 0x6003, 0x4d: 0x6003, 0x4e: 0x6003, 0x4f: 0x6003, 0x50: 0x6003, 0x51: 0x6003, - 0x52: 0x6003, 0x53: 0x6003, 0x54: 0x6003, 0x55: 0x6003, 0x56: 0x6003, 0x57: 0x6003, - 0x58: 0x6003, 0x59: 0x6003, 0x5a: 0x6003, 0x5b: 0x6003, 0x5c: 0x6003, 0x5d: 0x6003, - 0x5e: 0x6003, 0x5f: 0x6003, 0x60: 0x6004, 0x61: 0x6004, 0x62: 0x6004, 0x63: 0x6004, - 0x64: 0x6004, 0x65: 0x6004, 0x66: 0x6004, 0x67: 0x6004, 0x68: 0x6004, 0x69: 0x6004, - 0x6a: 0x6004, 0x6b: 0x6004, 0x6c: 0x6004, 0x6d: 0x6004, 0x6e: 0x6004, 0x6f: 0x6004, - 0x70: 0x6004, 0x71: 0x6004, 0x72: 0x6004, 0x73: 0x6004, 0x74: 0x6004, 0x75: 0x6004, - 0x76: 0x6004, 0x77: 0x6004, 0x78: 0x6004, 0x79: 0x6004, 0x7a: 0x6004, 0x7b: 0x6004, - 0x7c: 0x6004, 0x7d: 0x6004, 0x7e: 0x6004, - // Block 0x2, offset 0x80 - // Block 0x3, offset 0xc0 - 0xe1: 0x2000, 0xe2: 0x6005, 0xe3: 0x6005, - 0xe4: 0x2000, 0xe5: 0x6006, 0xe6: 0x6005, 0xe7: 0x2000, 0xe8: 0x2000, - 0xea: 0x2000, 0xec: 0x6007, 0xed: 0x2000, 0xee: 0x2000, 0xef: 0x6008, - 0xf0: 0x2000, 0xf1: 0x2000, 0xf2: 0x2000, 0xf3: 0x2000, 0xf4: 0x2000, - 0xf6: 0x2000, 0xf7: 0x2000, 0xf8: 0x2000, 0xf9: 0x2000, 0xfa: 0x2000, - 0xfc: 0x2000, 0xfd: 0x2000, 0xfe: 0x2000, 0xff: 0x2000, - // Block 0x4, offset 0x100 - 0x106: 0x2000, - 0x110: 0x2000, - 0x117: 0x2000, - 0x118: 0x2000, - 0x11e: 0x2000, 0x11f: 0x2000, 0x120: 0x2000, 0x121: 0x2000, - 0x126: 0x2000, 0x128: 0x2000, 0x129: 0x2000, - 0x12a: 0x2000, 0x12c: 0x2000, 0x12d: 0x2000, - 0x130: 0x2000, 0x132: 0x2000, 0x133: 0x2000, - 0x137: 0x2000, 0x138: 0x2000, 0x139: 0x2000, 0x13a: 0x2000, - 0x13c: 0x2000, 0x13e: 0x2000, - // Block 0x5, offset 0x140 - 0x141: 0x2000, - 0x151: 0x2000, - 0x153: 0x2000, - 0x15b: 0x2000, - 0x166: 0x2000, 0x167: 0x2000, - 0x16b: 0x2000, - 0x171: 0x2000, 0x172: 0x2000, 0x173: 0x2000, - 0x178: 0x2000, - 0x17f: 0x2000, - // Block 0x6, offset 0x180 - 0x180: 0x2000, 0x181: 0x2000, 0x182: 0x2000, 0x184: 0x2000, - 0x188: 0x2000, 0x189: 0x2000, 0x18a: 0x2000, 0x18b: 0x2000, - 0x18d: 0x2000, - 0x192: 0x2000, 0x193: 0x2000, - 0x1a6: 0x2000, 0x1a7: 0x2000, - 0x1ab: 0x2000, - // Block 0x7, offset 0x1c0 - 0x1ce: 0x2000, 0x1d0: 0x2000, - 0x1d2: 0x2000, 0x1d4: 0x2000, 0x1d6: 0x2000, - 0x1d8: 0x2000, 0x1da: 0x2000, 0x1dc: 0x2000, - // Block 0x8, offset 0x200 - 0x211: 0x2000, - 0x221: 0x2000, - // Block 0x9, offset 0x240 - 0x244: 0x2000, - 0x247: 0x2000, 0x249: 0x2000, 0x24a: 0x2000, 0x24b: 0x2000, - 0x24d: 0x2000, 0x250: 0x2000, - 0x258: 0x2000, 0x259: 0x2000, 0x25a: 0x2000, 0x25b: 0x2000, 0x25d: 0x2000, - 0x25f: 0x2000, - // Block 0xa, offset 0x280 - 0x280: 0x2000, 0x281: 0x2000, 0x282: 0x2000, 0x283: 0x2000, 0x284: 0x2000, 0x285: 0x2000, - 0x286: 0x2000, 0x287: 0x2000, 0x288: 0x2000, 0x289: 0x2000, 0x28a: 0x2000, 0x28b: 0x2000, - 0x28c: 0x2000, 0x28d: 0x2000, 0x28e: 0x2000, 0x28f: 0x2000, 0x290: 0x2000, 0x291: 0x2000, - 0x292: 0x2000, 0x293: 0x2000, 0x294: 0x2000, 0x295: 0x2000, 0x296: 0x2000, 0x297: 0x2000, - 0x298: 0x2000, 0x299: 0x2000, 0x29a: 0x2000, 0x29b: 0x2000, 0x29c: 0x2000, 0x29d: 0x2000, - 0x29e: 0x2000, 0x29f: 0x2000, 0x2a0: 0x2000, 0x2a1: 0x2000, 0x2a2: 0x2000, 0x2a3: 0x2000, - 0x2a4: 0x2000, 0x2a5: 0x2000, 0x2a6: 0x2000, 0x2a7: 0x2000, 0x2a8: 0x2000, 0x2a9: 0x2000, - 0x2aa: 0x2000, 0x2ab: 0x2000, 0x2ac: 0x2000, 0x2ad: 0x2000, 0x2ae: 0x2000, 0x2af: 0x2000, - 0x2b0: 0x2000, 0x2b1: 0x2000, 0x2b2: 0x2000, 0x2b3: 0x2000, 0x2b4: 0x2000, 0x2b5: 0x2000, - 0x2b6: 0x2000, 0x2b7: 0x2000, 0x2b8: 0x2000, 0x2b9: 0x2000, 0x2ba: 0x2000, 0x2bb: 0x2000, - 0x2bc: 0x2000, 0x2bd: 0x2000, 0x2be: 0x2000, 0x2bf: 0x2000, - // Block 0xb, offset 0x2c0 - 0x2c0: 0x2000, 0x2c1: 0x2000, 0x2c2: 0x2000, 0x2c3: 0x2000, 0x2c4: 0x2000, 0x2c5: 0x2000, - 0x2c6: 0x2000, 0x2c7: 0x2000, 0x2c8: 0x2000, 0x2c9: 0x2000, 0x2ca: 0x2000, 0x2cb: 0x2000, - 0x2cc: 0x2000, 0x2cd: 0x2000, 0x2ce: 0x2000, 0x2cf: 0x2000, 0x2d0: 0x2000, 0x2d1: 0x2000, - 0x2d2: 0x2000, 0x2d3: 0x2000, 0x2d4: 0x2000, 0x2d5: 0x2000, 0x2d6: 0x2000, 0x2d7: 0x2000, - 0x2d8: 0x2000, 0x2d9: 0x2000, 0x2da: 0x2000, 0x2db: 0x2000, 0x2dc: 0x2000, 0x2dd: 0x2000, - 0x2de: 0x2000, 0x2df: 0x2000, 0x2e0: 0x2000, 0x2e1: 0x2000, 0x2e2: 0x2000, 0x2e3: 0x2000, - 0x2e4: 0x2000, 0x2e5: 0x2000, 0x2e6: 0x2000, 0x2e7: 0x2000, 0x2e8: 0x2000, 0x2e9: 0x2000, - 0x2ea: 0x2000, 0x2eb: 0x2000, 0x2ec: 0x2000, 0x2ed: 0x2000, 0x2ee: 0x2000, 0x2ef: 0x2000, - // Block 0xc, offset 0x300 - 0x311: 0x2000, - 0x312: 0x2000, 0x313: 0x2000, 0x314: 0x2000, 0x315: 0x2000, 0x316: 0x2000, 0x317: 0x2000, - 0x318: 0x2000, 0x319: 0x2000, 0x31a: 0x2000, 0x31b: 0x2000, 0x31c: 0x2000, 0x31d: 0x2000, - 0x31e: 0x2000, 0x31f: 0x2000, 0x320: 0x2000, 0x321: 0x2000, 0x323: 0x2000, - 0x324: 0x2000, 0x325: 0x2000, 0x326: 0x2000, 0x327: 0x2000, 0x328: 0x2000, 0x329: 0x2000, - 0x331: 0x2000, 0x332: 0x2000, 0x333: 0x2000, 0x334: 0x2000, 0x335: 0x2000, - 0x336: 0x2000, 0x337: 0x2000, 0x338: 0x2000, 0x339: 0x2000, 0x33a: 0x2000, 0x33b: 0x2000, - 0x33c: 0x2000, 0x33d: 0x2000, 0x33e: 0x2000, 0x33f: 0x2000, - // Block 0xd, offset 0x340 - 0x340: 0x2000, 0x341: 0x2000, 0x343: 0x2000, 0x344: 0x2000, 0x345: 0x2000, - 0x346: 0x2000, 0x347: 0x2000, 0x348: 0x2000, 0x349: 0x2000, - // Block 0xe, offset 0x380 - 0x381: 0x2000, - 0x390: 0x2000, 0x391: 0x2000, - 0x392: 0x2000, 0x393: 0x2000, 0x394: 0x2000, 0x395: 0x2000, 0x396: 0x2000, 0x397: 0x2000, - 0x398: 0x2000, 0x399: 0x2000, 0x39a: 0x2000, 0x39b: 0x2000, 0x39c: 0x2000, 0x39d: 0x2000, - 0x39e: 0x2000, 0x39f: 0x2000, 0x3a0: 0x2000, 0x3a1: 0x2000, 0x3a2: 0x2000, 0x3a3: 0x2000, - 0x3a4: 0x2000, 0x3a5: 0x2000, 0x3a6: 0x2000, 0x3a7: 0x2000, 0x3a8: 0x2000, 0x3a9: 0x2000, - 0x3aa: 0x2000, 0x3ab: 0x2000, 0x3ac: 0x2000, 0x3ad: 0x2000, 0x3ae: 0x2000, 0x3af: 0x2000, - 0x3b0: 0x2000, 0x3b1: 0x2000, 0x3b2: 0x2000, 0x3b3: 0x2000, 0x3b4: 0x2000, 0x3b5: 0x2000, - 0x3b6: 0x2000, 0x3b7: 0x2000, 0x3b8: 0x2000, 0x3b9: 0x2000, 0x3ba: 0x2000, 0x3bb: 0x2000, - 0x3bc: 0x2000, 0x3bd: 0x2000, 0x3be: 0x2000, 0x3bf: 0x2000, - // Block 0xf, offset 0x3c0 - 0x3c0: 0x2000, 0x3c1: 0x2000, 0x3c2: 0x2000, 0x3c3: 0x2000, 0x3c4: 0x2000, 0x3c5: 0x2000, - 0x3c6: 0x2000, 0x3c7: 0x2000, 0x3c8: 0x2000, 0x3c9: 0x2000, 0x3ca: 0x2000, 0x3cb: 0x2000, - 0x3cc: 0x2000, 0x3cd: 0x2000, 0x3ce: 0x2000, 0x3cf: 0x2000, 0x3d1: 0x2000, - // Block 0x10, offset 0x400 - 0x400: 0x4000, 0x401: 0x4000, 0x402: 0x4000, 0x403: 0x4000, 0x404: 0x4000, 0x405: 0x4000, - 0x406: 0x4000, 0x407: 0x4000, 0x408: 0x4000, 0x409: 0x4000, 0x40a: 0x4000, 0x40b: 0x4000, - 0x40c: 0x4000, 0x40d: 0x4000, 0x40e: 0x4000, 0x40f: 0x4000, 0x410: 0x4000, 0x411: 0x4000, - 0x412: 0x4000, 0x413: 0x4000, 0x414: 0x4000, 0x415: 0x4000, 0x416: 0x4000, 0x417: 0x4000, - 0x418: 0x4000, 0x419: 0x4000, 0x41a: 0x4000, 0x41b: 0x4000, 0x41c: 0x4000, 0x41d: 0x4000, - 0x41e: 0x4000, 0x41f: 0x4000, 0x420: 0x4000, 0x421: 0x4000, 0x422: 0x4000, 0x423: 0x4000, - 0x424: 0x4000, 0x425: 0x4000, 0x426: 0x4000, 0x427: 0x4000, 0x428: 0x4000, 0x429: 0x4000, - 0x42a: 0x4000, 0x42b: 0x4000, 0x42c: 0x4000, 0x42d: 0x4000, 0x42e: 0x4000, 0x42f: 0x4000, - 0x430: 0x4000, 0x431: 0x4000, 0x432: 0x4000, 0x433: 0x4000, 0x434: 0x4000, 0x435: 0x4000, - 0x436: 0x4000, 0x437: 0x4000, 0x438: 0x4000, 0x439: 0x4000, 0x43a: 0x4000, 0x43b: 0x4000, - 0x43c: 0x4000, 0x43d: 0x4000, 0x43e: 0x4000, 0x43f: 0x4000, - // Block 0x11, offset 0x440 - 0x440: 0x4000, 0x441: 0x4000, 0x442: 0x4000, 0x443: 0x4000, 0x444: 0x4000, 0x445: 0x4000, - 0x446: 0x4000, 0x447: 0x4000, 0x448: 0x4000, 0x449: 0x4000, 0x44a: 0x4000, 0x44b: 0x4000, - 0x44c: 0x4000, 0x44d: 0x4000, 0x44e: 0x4000, 0x44f: 0x4000, 0x450: 0x4000, 0x451: 0x4000, - 0x452: 0x4000, 0x453: 0x4000, 0x454: 0x4000, 0x455: 0x4000, 0x456: 0x4000, 0x457: 0x4000, - 0x458: 0x4000, 0x459: 0x4000, 0x45a: 0x4000, 0x45b: 0x4000, 0x45c: 0x4000, 0x45d: 0x4000, - 0x45e: 0x4000, 0x45f: 0x4000, - // Block 0x12, offset 0x480 - 0x490: 0x2000, - 0x493: 0x2000, 0x494: 0x2000, 0x495: 0x2000, 0x496: 0x2000, - 0x498: 0x2000, 0x499: 0x2000, 0x49c: 0x2000, 0x49d: 0x2000, - 0x4a0: 0x2000, 0x4a1: 0x2000, 0x4a2: 0x2000, - 0x4a4: 0x2000, 0x4a5: 0x2000, 0x4a6: 0x2000, 0x4a7: 0x2000, - 0x4b0: 0x2000, 0x4b2: 0x2000, 0x4b3: 0x2000, 0x4b5: 0x2000, - 0x4bb: 0x2000, - 0x4be: 0x2000, - // Block 0x13, offset 0x4c0 - 0x4f4: 0x2000, - 0x4ff: 0x2000, - // Block 0x14, offset 0x500 - 0x501: 0x2000, 0x502: 0x2000, 0x503: 0x2000, 0x504: 0x2000, - 0x529: 0xa009, - 0x52c: 0x2000, - // Block 0x15, offset 0x540 - 0x543: 0x2000, 0x545: 0x2000, - 0x549: 0x2000, - 0x553: 0x2000, 0x556: 0x2000, - 0x561: 0x2000, 0x562: 0x2000, - 0x566: 0x2000, - 0x56b: 0x2000, - // Block 0x16, offset 0x580 - 0x593: 0x2000, 0x594: 0x2000, - 0x59b: 0x2000, 0x59c: 0x2000, 0x59d: 0x2000, - 0x59e: 0x2000, 0x5a0: 0x2000, 0x5a1: 0x2000, 0x5a2: 0x2000, 0x5a3: 0x2000, - 0x5a4: 0x2000, 0x5a5: 0x2000, 0x5a6: 0x2000, 0x5a7: 0x2000, 0x5a8: 0x2000, 0x5a9: 0x2000, - 0x5aa: 0x2000, 0x5ab: 0x2000, - 0x5b0: 0x2000, 0x5b1: 0x2000, 0x5b2: 0x2000, 0x5b3: 0x2000, 0x5b4: 0x2000, 0x5b5: 0x2000, - 0x5b6: 0x2000, 0x5b7: 0x2000, 0x5b8: 0x2000, 0x5b9: 0x2000, - // Block 0x17, offset 0x5c0 - 0x5c9: 0x2000, - 0x5d0: 0x200a, 0x5d1: 0x200b, - 0x5d2: 0x200a, 0x5d3: 0x200c, 0x5d4: 0x2000, 0x5d5: 0x2000, 0x5d6: 0x2000, 0x5d7: 0x2000, - 0x5d8: 0x2000, 0x5d9: 0x2000, - 0x5f8: 0x2000, 0x5f9: 0x2000, - // Block 0x18, offset 0x600 - 0x612: 0x2000, 0x614: 0x2000, - 0x627: 0x2000, - // Block 0x19, offset 0x640 - 0x640: 0x2000, 0x642: 0x2000, 0x643: 0x2000, - 0x647: 0x2000, 0x648: 0x2000, 0x64b: 0x2000, - 0x64f: 0x2000, 0x651: 0x2000, - 0x655: 0x2000, - 0x65a: 0x2000, 0x65d: 0x2000, - 0x65e: 0x2000, 0x65f: 0x2000, 0x660: 0x2000, 0x663: 0x2000, - 0x665: 0x2000, 0x667: 0x2000, 0x668: 0x2000, 0x669: 0x2000, - 0x66a: 0x2000, 0x66b: 0x2000, 0x66c: 0x2000, 0x66e: 0x2000, - 0x674: 0x2000, 0x675: 0x2000, - 0x676: 0x2000, 0x677: 0x2000, - 0x67c: 0x2000, 0x67d: 0x2000, - // Block 0x1a, offset 0x680 - 0x688: 0x2000, - 0x68c: 0x2000, - 0x692: 0x2000, - 0x6a0: 0x2000, 0x6a1: 0x2000, - 0x6a4: 0x2000, 0x6a5: 0x2000, 0x6a6: 0x2000, 0x6a7: 0x2000, - 0x6aa: 0x2000, 0x6ab: 0x2000, 0x6ae: 0x2000, 0x6af: 0x2000, - // Block 0x1b, offset 0x6c0 - 0x6c2: 0x2000, 0x6c3: 0x2000, - 0x6c6: 0x2000, 0x6c7: 0x2000, - 0x6d5: 0x2000, - 0x6d9: 0x2000, - 0x6e5: 0x2000, - 0x6ff: 0x2000, - // Block 0x1c, offset 0x700 - 0x712: 0x2000, - 0x71a: 0x4000, 0x71b: 0x4000, - 0x729: 0x4000, - 0x72a: 0x4000, - // Block 0x1d, offset 0x740 - 0x769: 0x4000, - 0x76a: 0x4000, 0x76b: 0x4000, 0x76c: 0x4000, - 0x770: 0x4000, 0x773: 0x4000, - // Block 0x1e, offset 0x780 - 0x7a0: 0x2000, 0x7a1: 0x2000, 0x7a2: 0x2000, 0x7a3: 0x2000, - 0x7a4: 0x2000, 0x7a5: 0x2000, 0x7a6: 0x2000, 0x7a7: 0x2000, 0x7a8: 0x2000, 0x7a9: 0x2000, - 0x7aa: 0x2000, 0x7ab: 0x2000, 0x7ac: 0x2000, 0x7ad: 0x2000, 0x7ae: 0x2000, 0x7af: 0x2000, - 0x7b0: 0x2000, 0x7b1: 0x2000, 0x7b2: 0x2000, 0x7b3: 0x2000, 0x7b4: 0x2000, 0x7b5: 0x2000, - 0x7b6: 0x2000, 0x7b7: 0x2000, 0x7b8: 0x2000, 0x7b9: 0x2000, 0x7ba: 0x2000, 0x7bb: 0x2000, - 0x7bc: 0x2000, 0x7bd: 0x2000, 0x7be: 0x2000, 0x7bf: 0x2000, - // Block 0x1f, offset 0x7c0 - 0x7c0: 0x2000, 0x7c1: 0x2000, 0x7c2: 0x2000, 0x7c3: 0x2000, 0x7c4: 0x2000, 0x7c5: 0x2000, - 0x7c6: 0x2000, 0x7c7: 0x2000, 0x7c8: 0x2000, 0x7c9: 0x2000, 0x7ca: 0x2000, 0x7cb: 0x2000, - 0x7cc: 0x2000, 0x7cd: 0x2000, 0x7ce: 0x2000, 0x7cf: 0x2000, 0x7d0: 0x2000, 0x7d1: 0x2000, - 0x7d2: 0x2000, 0x7d3: 0x2000, 0x7d4: 0x2000, 0x7d5: 0x2000, 0x7d6: 0x2000, 0x7d7: 0x2000, - 0x7d8: 0x2000, 0x7d9: 0x2000, 0x7da: 0x2000, 0x7db: 0x2000, 0x7dc: 0x2000, 0x7dd: 0x2000, - 0x7de: 0x2000, 0x7df: 0x2000, 0x7e0: 0x2000, 0x7e1: 0x2000, 0x7e2: 0x2000, 0x7e3: 0x2000, - 0x7e4: 0x2000, 0x7e5: 0x2000, 0x7e6: 0x2000, 0x7e7: 0x2000, 0x7e8: 0x2000, 0x7e9: 0x2000, - 0x7eb: 0x2000, 0x7ec: 0x2000, 0x7ed: 0x2000, 0x7ee: 0x2000, 0x7ef: 0x2000, - 0x7f0: 0x2000, 0x7f1: 0x2000, 0x7f2: 0x2000, 0x7f3: 0x2000, 0x7f4: 0x2000, 0x7f5: 0x2000, - 0x7f6: 0x2000, 0x7f7: 0x2000, 0x7f8: 0x2000, 0x7f9: 0x2000, 0x7fa: 0x2000, 0x7fb: 0x2000, - 0x7fc: 0x2000, 0x7fd: 0x2000, 0x7fe: 0x2000, 0x7ff: 0x2000, - // Block 0x20, offset 0x800 - 0x800: 0x2000, 0x801: 0x2000, 0x802: 0x200d, 0x803: 0x2000, 0x804: 0x2000, 0x805: 0x2000, - 0x806: 0x2000, 0x807: 0x2000, 0x808: 0x2000, 0x809: 0x2000, 0x80a: 0x2000, 0x80b: 0x2000, - 0x80c: 0x2000, 0x80d: 0x2000, 0x80e: 0x2000, 0x80f: 0x2000, 0x810: 0x2000, 0x811: 0x2000, - 0x812: 0x2000, 0x813: 0x2000, 0x814: 0x2000, 0x815: 0x2000, 0x816: 0x2000, 0x817: 0x2000, - 0x818: 0x2000, 0x819: 0x2000, 0x81a: 0x2000, 0x81b: 0x2000, 0x81c: 0x2000, 0x81d: 0x2000, - 0x81e: 0x2000, 0x81f: 0x2000, 0x820: 0x2000, 0x821: 0x2000, 0x822: 0x2000, 0x823: 0x2000, - 0x824: 0x2000, 0x825: 0x2000, 0x826: 0x2000, 0x827: 0x2000, 0x828: 0x2000, 0x829: 0x2000, - 0x82a: 0x2000, 0x82b: 0x2000, 0x82c: 0x2000, 0x82d: 0x2000, 0x82e: 0x2000, 0x82f: 0x2000, - 0x830: 0x2000, 0x831: 0x2000, 0x832: 0x2000, 0x833: 0x2000, 0x834: 0x2000, 0x835: 0x2000, - 0x836: 0x2000, 0x837: 0x2000, 0x838: 0x2000, 0x839: 0x2000, 0x83a: 0x2000, 0x83b: 0x2000, - 0x83c: 0x2000, 0x83d: 0x2000, 0x83e: 0x2000, 0x83f: 0x2000, - // Block 0x21, offset 0x840 - 0x840: 0x2000, 0x841: 0x2000, 0x842: 0x2000, 0x843: 0x2000, 0x844: 0x2000, 0x845: 0x2000, - 0x846: 0x2000, 0x847: 0x2000, 0x848: 0x2000, 0x849: 0x2000, 0x84a: 0x2000, 0x84b: 0x2000, - 0x850: 0x2000, 0x851: 0x2000, - 0x852: 0x2000, 0x853: 0x2000, 0x854: 0x2000, 0x855: 0x2000, 0x856: 0x2000, 0x857: 0x2000, - 0x858: 0x2000, 0x859: 0x2000, 0x85a: 0x2000, 0x85b: 0x2000, 0x85c: 0x2000, 0x85d: 0x2000, - 0x85e: 0x2000, 0x85f: 0x2000, 0x860: 0x2000, 0x861: 0x2000, 0x862: 0x2000, 0x863: 0x2000, - 0x864: 0x2000, 0x865: 0x2000, 0x866: 0x2000, 0x867: 0x2000, 0x868: 0x2000, 0x869: 0x2000, - 0x86a: 0x2000, 0x86b: 0x2000, 0x86c: 0x2000, 0x86d: 0x2000, 0x86e: 0x2000, 0x86f: 0x2000, - 0x870: 0x2000, 0x871: 0x2000, 0x872: 0x2000, 0x873: 0x2000, - // Block 0x22, offset 0x880 - 0x880: 0x2000, 0x881: 0x2000, 0x882: 0x2000, 0x883: 0x2000, 0x884: 0x2000, 0x885: 0x2000, - 0x886: 0x2000, 0x887: 0x2000, 0x888: 0x2000, 0x889: 0x2000, 0x88a: 0x2000, 0x88b: 0x2000, - 0x88c: 0x2000, 0x88d: 0x2000, 0x88e: 0x2000, 0x88f: 0x2000, - 0x892: 0x2000, 0x893: 0x2000, 0x894: 0x2000, 0x895: 0x2000, - 0x8a0: 0x200e, 0x8a1: 0x2000, 0x8a3: 0x2000, - 0x8a4: 0x2000, 0x8a5: 0x2000, 0x8a6: 0x2000, 0x8a7: 0x2000, 0x8a8: 0x2000, 0x8a9: 0x2000, - 0x8b2: 0x2000, 0x8b3: 0x2000, - 0x8b6: 0x2000, 0x8b7: 0x2000, - 0x8bc: 0x2000, 0x8bd: 0x2000, - // Block 0x23, offset 0x8c0 - 0x8c0: 0x2000, 0x8c1: 0x2000, - 0x8c6: 0x2000, 0x8c7: 0x2000, 0x8c8: 0x2000, 0x8cb: 0x200f, - 0x8ce: 0x2000, 0x8cf: 0x2000, 0x8d0: 0x2000, 0x8d1: 0x2000, - 0x8e2: 0x2000, 0x8e3: 0x2000, - 0x8e4: 0x2000, 0x8e5: 0x2000, - 0x8ef: 0x2000, - 0x8fd: 0x4000, 0x8fe: 0x4000, - // Block 0x24, offset 0x900 - 0x905: 0x2000, - 0x906: 0x2000, 0x909: 0x2000, - 0x90e: 0x2000, 0x90f: 0x2000, - 0x914: 0x4000, 0x915: 0x4000, - 0x91c: 0x2000, - 0x91e: 0x2000, - // Block 0x25, offset 0x940 - 0x940: 0x2000, 0x942: 0x2000, - 0x948: 0x4000, 0x949: 0x4000, 0x94a: 0x4000, 0x94b: 0x4000, - 0x94c: 0x4000, 0x94d: 0x4000, 0x94e: 0x4000, 0x94f: 0x4000, 0x950: 0x4000, 0x951: 0x4000, - 0x952: 0x4000, 0x953: 0x4000, - 0x960: 0x2000, 0x961: 0x2000, 0x963: 0x2000, - 0x964: 0x2000, 0x965: 0x2000, 0x967: 0x2000, 0x968: 0x2000, 0x969: 0x2000, - 0x96a: 0x2000, 0x96c: 0x2000, 0x96d: 0x2000, 0x96f: 0x2000, - 0x97f: 0x4000, - // Block 0x26, offset 0x980 - 0x993: 0x4000, - 0x99e: 0x2000, 0x99f: 0x2000, 0x9a1: 0x4000, - 0x9aa: 0x4000, 0x9ab: 0x4000, - 0x9bd: 0x4000, 0x9be: 0x4000, 0x9bf: 0x2000, - // Block 0x27, offset 0x9c0 - 0x9c4: 0x4000, 0x9c5: 0x4000, - 0x9c6: 0x2000, 0x9c7: 0x2000, 0x9c8: 0x2000, 0x9c9: 0x2000, 0x9ca: 0x2000, 0x9cb: 0x2000, - 0x9cc: 0x2000, 0x9cd: 0x2000, 0x9ce: 0x4000, 0x9cf: 0x2000, 0x9d0: 0x2000, 0x9d1: 0x2000, - 0x9d2: 0x2000, 0x9d3: 0x2000, 0x9d4: 0x4000, 0x9d5: 0x2000, 0x9d6: 0x2000, 0x9d7: 0x2000, - 0x9d8: 0x2000, 0x9d9: 0x2000, 0x9da: 0x2000, 0x9db: 0x2000, 0x9dc: 0x2000, 0x9dd: 0x2000, - 0x9de: 0x2000, 0x9df: 0x2000, 0x9e0: 0x2000, 0x9e1: 0x2000, 0x9e3: 0x2000, - 0x9e8: 0x2000, 0x9e9: 0x2000, - 0x9ea: 0x4000, 0x9eb: 0x2000, 0x9ec: 0x2000, 0x9ed: 0x2000, 0x9ee: 0x2000, 0x9ef: 0x2000, - 0x9f0: 0x2000, 0x9f1: 0x2000, 0x9f2: 0x4000, 0x9f3: 0x4000, 0x9f4: 0x2000, 0x9f5: 0x4000, - 0x9f6: 0x2000, 0x9f7: 0x2000, 0x9f8: 0x2000, 0x9f9: 0x2000, 0x9fa: 0x4000, 0x9fb: 0x2000, - 0x9fc: 0x2000, 0x9fd: 0x4000, 0x9fe: 0x2000, 0x9ff: 0x2000, - // Block 0x28, offset 0xa00 - 0xa05: 0x4000, - 0xa0a: 0x4000, 0xa0b: 0x4000, - 0xa28: 0x4000, - 0xa3d: 0x2000, - // Block 0x29, offset 0xa40 - 0xa4c: 0x4000, 0xa4e: 0x4000, - 0xa53: 0x4000, 0xa54: 0x4000, 0xa55: 0x4000, 0xa57: 0x4000, - 0xa76: 0x2000, 0xa77: 0x2000, 0xa78: 0x2000, 0xa79: 0x2000, 0xa7a: 0x2000, 0xa7b: 0x2000, - 0xa7c: 0x2000, 0xa7d: 0x2000, 0xa7e: 0x2000, 0xa7f: 0x2000, - // Block 0x2a, offset 0xa80 - 0xa95: 0x4000, 0xa96: 0x4000, 0xa97: 0x4000, - 0xab0: 0x4000, - 0xabf: 0x4000, - // Block 0x2b, offset 0xac0 - 0xae6: 0x6000, 0xae7: 0x6000, 0xae8: 0x6000, 0xae9: 0x6000, - 0xaea: 0x6000, 0xaeb: 0x6000, 0xaec: 0x6000, 0xaed: 0x6000, - // Block 0x2c, offset 0xb00 - 0xb05: 0x6010, - 0xb06: 0x6011, - // Block 0x2d, offset 0xb40 - 0xb5b: 0x4000, 0xb5c: 0x4000, - // Block 0x2e, offset 0xb80 - 0xb90: 0x4000, - 0xb95: 0x4000, 0xb96: 0x2000, 0xb97: 0x2000, - 0xb98: 0x2000, 0xb99: 0x2000, - // Block 0x2f, offset 0xbc0 - 0xbc0: 0x4000, 0xbc1: 0x4000, 0xbc2: 0x4000, 0xbc3: 0x4000, 0xbc4: 0x4000, 0xbc5: 0x4000, - 0xbc6: 0x4000, 0xbc7: 0x4000, 0xbc8: 0x4000, 0xbc9: 0x4000, 0xbca: 0x4000, 0xbcb: 0x4000, - 0xbcc: 0x4000, 0xbcd: 0x4000, 0xbce: 0x4000, 0xbcf: 0x4000, 0xbd0: 0x4000, 0xbd1: 0x4000, - 0xbd2: 0x4000, 0xbd3: 0x4000, 0xbd4: 0x4000, 0xbd5: 0x4000, 0xbd6: 0x4000, 0xbd7: 0x4000, - 0xbd8: 0x4000, 0xbd9: 0x4000, 0xbdb: 0x4000, 0xbdc: 0x4000, 0xbdd: 0x4000, - 0xbde: 0x4000, 0xbdf: 0x4000, 0xbe0: 0x4000, 0xbe1: 0x4000, 0xbe2: 0x4000, 0xbe3: 0x4000, - 0xbe4: 0x4000, 0xbe5: 0x4000, 0xbe6: 0x4000, 0xbe7: 0x4000, 0xbe8: 0x4000, 0xbe9: 0x4000, - 0xbea: 0x4000, 0xbeb: 0x4000, 0xbec: 0x4000, 0xbed: 0x4000, 0xbee: 0x4000, 0xbef: 0x4000, - 0xbf0: 0x4000, 0xbf1: 0x4000, 0xbf2: 0x4000, 0xbf3: 0x4000, 0xbf4: 0x4000, 0xbf5: 0x4000, - 0xbf6: 0x4000, 0xbf7: 0x4000, 0xbf8: 0x4000, 0xbf9: 0x4000, 0xbfa: 0x4000, 0xbfb: 0x4000, - 0xbfc: 0x4000, 0xbfd: 0x4000, 0xbfe: 0x4000, 0xbff: 0x4000, - // Block 0x30, offset 0xc00 - 0xc00: 0x4000, 0xc01: 0x4000, 0xc02: 0x4000, 0xc03: 0x4000, 0xc04: 0x4000, 0xc05: 0x4000, - 0xc06: 0x4000, 0xc07: 0x4000, 0xc08: 0x4000, 0xc09: 0x4000, 0xc0a: 0x4000, 0xc0b: 0x4000, - 0xc0c: 0x4000, 0xc0d: 0x4000, 0xc0e: 0x4000, 0xc0f: 0x4000, 0xc10: 0x4000, 0xc11: 0x4000, - 0xc12: 0x4000, 0xc13: 0x4000, 0xc14: 0x4000, 0xc15: 0x4000, 0xc16: 0x4000, 0xc17: 0x4000, - 0xc18: 0x4000, 0xc19: 0x4000, 0xc1a: 0x4000, 0xc1b: 0x4000, 0xc1c: 0x4000, 0xc1d: 0x4000, - 0xc1e: 0x4000, 0xc1f: 0x4000, 0xc20: 0x4000, 0xc21: 0x4000, 0xc22: 0x4000, 0xc23: 0x4000, - 0xc24: 0x4000, 0xc25: 0x4000, 0xc26: 0x4000, 0xc27: 0x4000, 0xc28: 0x4000, 0xc29: 0x4000, - 0xc2a: 0x4000, 0xc2b: 0x4000, 0xc2c: 0x4000, 0xc2d: 0x4000, 0xc2e: 0x4000, 0xc2f: 0x4000, - 0xc30: 0x4000, 0xc31: 0x4000, 0xc32: 0x4000, 0xc33: 0x4000, - // Block 0x31, offset 0xc40 - 0xc40: 0x4000, 0xc41: 0x4000, 0xc42: 0x4000, 0xc43: 0x4000, 0xc44: 0x4000, 0xc45: 0x4000, - 0xc46: 0x4000, 0xc47: 0x4000, 0xc48: 0x4000, 0xc49: 0x4000, 0xc4a: 0x4000, 0xc4b: 0x4000, - 0xc4c: 0x4000, 0xc4d: 0x4000, 0xc4e: 0x4000, 0xc4f: 0x4000, 0xc50: 0x4000, 0xc51: 0x4000, - 0xc52: 0x4000, 0xc53: 0x4000, 0xc54: 0x4000, 0xc55: 0x4000, - 0xc70: 0x4000, 0xc71: 0x4000, 0xc72: 0x4000, 0xc73: 0x4000, 0xc74: 0x4000, 0xc75: 0x4000, - 0xc76: 0x4000, 0xc77: 0x4000, 0xc78: 0x4000, 0xc79: 0x4000, 0xc7a: 0x4000, 0xc7b: 0x4000, - // Block 0x32, offset 0xc80 - 0xc80: 0x9012, 0xc81: 0x4013, 0xc82: 0x4014, 0xc83: 0x4000, 0xc84: 0x4000, 0xc85: 0x4000, - 0xc86: 0x4000, 0xc87: 0x4000, 0xc88: 0x4000, 0xc89: 0x4000, 0xc8a: 0x4000, 0xc8b: 0x4000, - 0xc8c: 0x4015, 0xc8d: 0x4015, 0xc8e: 0x4000, 0xc8f: 0x4000, 0xc90: 0x4000, 0xc91: 0x4000, - 0xc92: 0x4000, 0xc93: 0x4000, 0xc94: 0x4000, 0xc95: 0x4000, 0xc96: 0x4000, 0xc97: 0x4000, - 0xc98: 0x4000, 0xc99: 0x4000, 0xc9a: 0x4000, 0xc9b: 0x4000, 0xc9c: 0x4000, 0xc9d: 0x4000, - 0xc9e: 0x4000, 0xc9f: 0x4000, 0xca0: 0x4000, 0xca1: 0x4000, 0xca2: 0x4000, 0xca3: 0x4000, - 0xca4: 0x4000, 0xca5: 0x4000, 0xca6: 0x4000, 0xca7: 0x4000, 0xca8: 0x4000, 0xca9: 0x4000, - 0xcaa: 0x4000, 0xcab: 0x4000, 0xcac: 0x4000, 0xcad: 0x4000, 0xcae: 0x4000, 0xcaf: 0x4000, - 0xcb0: 0x4000, 0xcb1: 0x4000, 0xcb2: 0x4000, 0xcb3: 0x4000, 0xcb4: 0x4000, 0xcb5: 0x4000, - 0xcb6: 0x4000, 0xcb7: 0x4000, 0xcb8: 0x4000, 0xcb9: 0x4000, 0xcba: 0x4000, 0xcbb: 0x4000, - 0xcbc: 0x4000, 0xcbd: 0x4000, 0xcbe: 0x4000, - // Block 0x33, offset 0xcc0 - 0xcc1: 0x4000, 0xcc2: 0x4000, 0xcc3: 0x4000, 0xcc4: 0x4000, 0xcc5: 0x4000, - 0xcc6: 0x4000, 0xcc7: 0x4000, 0xcc8: 0x4000, 0xcc9: 0x4000, 0xcca: 0x4000, 0xccb: 0x4000, - 0xccc: 0x4000, 0xccd: 0x4000, 0xcce: 0x4000, 0xccf: 0x4000, 0xcd0: 0x4000, 0xcd1: 0x4000, - 0xcd2: 0x4000, 0xcd3: 0x4000, 0xcd4: 0x4000, 0xcd5: 0x4000, 0xcd6: 0x4000, 0xcd7: 0x4000, - 0xcd8: 0x4000, 0xcd9: 0x4000, 0xcda: 0x4000, 0xcdb: 0x4000, 0xcdc: 0x4000, 0xcdd: 0x4000, - 0xcde: 0x4000, 0xcdf: 0x4000, 0xce0: 0x4000, 0xce1: 0x4000, 0xce2: 0x4000, 0xce3: 0x4000, - 0xce4: 0x4000, 0xce5: 0x4000, 0xce6: 0x4000, 0xce7: 0x4000, 0xce8: 0x4000, 0xce9: 0x4000, - 0xcea: 0x4000, 0xceb: 0x4000, 0xcec: 0x4000, 0xced: 0x4000, 0xcee: 0x4000, 0xcef: 0x4000, - 0xcf0: 0x4000, 0xcf1: 0x4000, 0xcf2: 0x4000, 0xcf3: 0x4000, 0xcf4: 0x4000, 0xcf5: 0x4000, - 0xcf6: 0x4000, 0xcf7: 0x4000, 0xcf8: 0x4000, 0xcf9: 0x4000, 0xcfa: 0x4000, 0xcfb: 0x4000, - 0xcfc: 0x4000, 0xcfd: 0x4000, 0xcfe: 0x4000, 0xcff: 0x4000, - // Block 0x34, offset 0xd00 - 0xd00: 0x4000, 0xd01: 0x4000, 0xd02: 0x4000, 0xd03: 0x4000, 0xd04: 0x4000, 0xd05: 0x4000, - 0xd06: 0x4000, 0xd07: 0x4000, 0xd08: 0x4000, 0xd09: 0x4000, 0xd0a: 0x4000, 0xd0b: 0x4000, - 0xd0c: 0x4000, 0xd0d: 0x4000, 0xd0e: 0x4000, 0xd0f: 0x4000, 0xd10: 0x4000, 0xd11: 0x4000, - 0xd12: 0x4000, 0xd13: 0x4000, 0xd14: 0x4000, 0xd15: 0x4000, 0xd16: 0x4000, - 0xd19: 0x4016, 0xd1a: 0x4017, 0xd1b: 0x4000, 0xd1c: 0x4000, 0xd1d: 0x4000, - 0xd1e: 0x4000, 0xd1f: 0x4000, 0xd20: 0x4000, 0xd21: 0x4018, 0xd22: 0x4019, 0xd23: 0x401a, - 0xd24: 0x401b, 0xd25: 0x401c, 0xd26: 0x401d, 0xd27: 0x401e, 0xd28: 0x401f, 0xd29: 0x4020, - 0xd2a: 0x4021, 0xd2b: 0x4022, 0xd2c: 0x4000, 0xd2d: 0x4010, 0xd2e: 0x4000, 0xd2f: 0x4023, - 0xd30: 0x4000, 0xd31: 0x4024, 0xd32: 0x4000, 0xd33: 0x4025, 0xd34: 0x4000, 0xd35: 0x4026, - 0xd36: 0x4000, 0xd37: 0x401a, 0xd38: 0x4000, 0xd39: 0x4027, 0xd3a: 0x4000, 0xd3b: 0x4028, - 0xd3c: 0x4000, 0xd3d: 0x4020, 0xd3e: 0x4000, 0xd3f: 0x4029, - // Block 0x35, offset 0xd40 - 0xd40: 0x4000, 0xd41: 0x402a, 0xd42: 0x4000, 0xd43: 0x402b, 0xd44: 0x402c, 0xd45: 0x4000, - 0xd46: 0x4017, 0xd47: 0x4000, 0xd48: 0x402d, 0xd49: 0x4000, 0xd4a: 0x402e, 0xd4b: 0x402f, - 0xd4c: 0x4030, 0xd4d: 0x4017, 0xd4e: 0x4016, 0xd4f: 0x4017, 0xd50: 0x4000, 0xd51: 0x4000, - 0xd52: 0x4031, 0xd53: 0x4000, 0xd54: 0x4000, 0xd55: 0x4031, 0xd56: 0x4000, 0xd57: 0x4000, - 0xd58: 0x4032, 0xd59: 0x4000, 0xd5a: 0x4000, 0xd5b: 0x4032, 0xd5c: 0x4000, 0xd5d: 0x4000, - 0xd5e: 0x4033, 0xd5f: 0x402e, 0xd60: 0x4034, 0xd61: 0x4035, 0xd62: 0x4034, 0xd63: 0x4036, - 0xd64: 0x4037, 0xd65: 0x4024, 0xd66: 0x4035, 0xd67: 0x4025, 0xd68: 0x4038, 0xd69: 0x4038, - 0xd6a: 0x4039, 0xd6b: 0x4039, 0xd6c: 0x403a, 0xd6d: 0x403a, 0xd6e: 0x4000, 0xd6f: 0x4035, - 0xd70: 0x4000, 0xd71: 0x4000, 0xd72: 0x403b, 0xd73: 0x403c, 0xd74: 0x4000, 0xd75: 0x4000, - 0xd76: 0x4000, 0xd77: 0x4000, 0xd78: 0x4000, 0xd79: 0x4000, 0xd7a: 0x4000, 0xd7b: 0x403d, - 0xd7c: 0x401c, 0xd7d: 0x4000, 0xd7e: 0x4000, 0xd7f: 0x4000, - // Block 0x36, offset 0xd80 - 0xd85: 0x4000, - 0xd86: 0x4000, 0xd87: 0x4000, 0xd88: 0x4000, 0xd89: 0x4000, 0xd8a: 0x4000, 0xd8b: 0x4000, - 0xd8c: 0x4000, 0xd8d: 0x4000, 0xd8e: 0x4000, 0xd8f: 0x4000, 0xd90: 0x4000, 0xd91: 0x4000, - 0xd92: 0x4000, 0xd93: 0x4000, 0xd94: 0x4000, 0xd95: 0x4000, 0xd96: 0x4000, 0xd97: 0x4000, - 0xd98: 0x4000, 0xd99: 0x4000, 0xd9a: 0x4000, 0xd9b: 0x4000, 0xd9c: 0x4000, 0xd9d: 0x4000, - 0xd9e: 0x4000, 0xd9f: 0x4000, 0xda0: 0x4000, 0xda1: 0x4000, 0xda2: 0x4000, 0xda3: 0x4000, - 0xda4: 0x4000, 0xda5: 0x4000, 0xda6: 0x4000, 0xda7: 0x4000, 0xda8: 0x4000, 0xda9: 0x4000, - 0xdaa: 0x4000, 0xdab: 0x4000, 0xdac: 0x4000, 0xdad: 0x4000, - 0xdb1: 0x403e, 0xdb2: 0x403e, 0xdb3: 0x403e, 0xdb4: 0x403e, 0xdb5: 0x403e, - 0xdb6: 0x403e, 0xdb7: 0x403e, 0xdb8: 0x403e, 0xdb9: 0x403e, 0xdba: 0x403e, 0xdbb: 0x403e, - 0xdbc: 0x403e, 0xdbd: 0x403e, 0xdbe: 0x403e, 0xdbf: 0x403e, - // Block 0x37, offset 0xdc0 - 0xdc0: 0x4037, 0xdc1: 0x4037, 0xdc2: 0x4037, 0xdc3: 0x4037, 0xdc4: 0x4037, 0xdc5: 0x4037, - 0xdc6: 0x4037, 0xdc7: 0x4037, 0xdc8: 0x4037, 0xdc9: 0x4037, 0xdca: 0x4037, 0xdcb: 0x4037, - 0xdcc: 0x4037, 0xdcd: 0x4037, 0xdce: 0x4037, 0xdcf: 0x400e, 0xdd0: 0x403f, 0xdd1: 0x4040, - 0xdd2: 0x4041, 0xdd3: 0x4040, 0xdd4: 0x403f, 0xdd5: 0x4042, 0xdd6: 0x4043, 0xdd7: 0x4044, - 0xdd8: 0x4040, 0xdd9: 0x4041, 0xdda: 0x4040, 0xddb: 0x4045, 0xddc: 0x4009, 0xddd: 0x4045, - 0xdde: 0x4046, 0xddf: 0x4045, 0xde0: 0x4047, 0xde1: 0x400b, 0xde2: 0x400a, 0xde3: 0x400c, - 0xde4: 0x4048, 0xde5: 0x4000, 0xde6: 0x4000, 0xde7: 0x4000, 0xde8: 0x4000, 0xde9: 0x4000, - 0xdea: 0x4000, 0xdeb: 0x4000, 0xdec: 0x4000, 0xded: 0x4000, 0xdee: 0x4000, 0xdef: 0x4000, - 0xdf0: 0x4000, 0xdf1: 0x4000, 0xdf2: 0x4000, 0xdf3: 0x4000, 0xdf4: 0x4000, 0xdf5: 0x4000, - 0xdf6: 0x4000, 0xdf7: 0x4000, 0xdf8: 0x4000, 0xdf9: 0x4000, 0xdfa: 0x4000, 0xdfb: 0x4000, - 0xdfc: 0x4000, 0xdfd: 0x4000, 0xdfe: 0x4000, 0xdff: 0x4000, - // Block 0x38, offset 0xe00 - 0xe00: 0x4000, 0xe01: 0x4000, 0xe02: 0x4000, 0xe03: 0x4000, 0xe04: 0x4000, 0xe05: 0x4000, - 0xe06: 0x4000, 0xe07: 0x4000, 0xe08: 0x4000, 0xe09: 0x4000, 0xe0a: 0x4000, 0xe0b: 0x4000, - 0xe0c: 0x4000, 0xe0d: 0x4000, 0xe0e: 0x4000, 0xe10: 0x4000, 0xe11: 0x4000, - 0xe12: 0x4000, 0xe13: 0x4000, 0xe14: 0x4000, 0xe15: 0x4000, 0xe16: 0x4000, 0xe17: 0x4000, - 0xe18: 0x4000, 0xe19: 0x4000, 0xe1a: 0x4000, 0xe1b: 0x4000, 0xe1c: 0x4000, 0xe1d: 0x4000, - 0xe1e: 0x4000, 0xe1f: 0x4000, 0xe20: 0x4000, 0xe21: 0x4000, 0xe22: 0x4000, 0xe23: 0x4000, - 0xe24: 0x4000, 0xe25: 0x4000, 0xe26: 0x4000, 0xe27: 0x4000, 0xe28: 0x4000, 0xe29: 0x4000, - 0xe2a: 0x4000, 0xe2b: 0x4000, 0xe2c: 0x4000, 0xe2d: 0x4000, 0xe2e: 0x4000, 0xe2f: 0x4000, - 0xe30: 0x4000, 0xe31: 0x4000, 0xe32: 0x4000, 0xe33: 0x4000, 0xe34: 0x4000, 0xe35: 0x4000, - 0xe36: 0x4000, 0xe37: 0x4000, 0xe38: 0x4000, 0xe39: 0x4000, 0xe3a: 0x4000, - // Block 0x39, offset 0xe40 - 0xe40: 0x4000, 0xe41: 0x4000, 0xe42: 0x4000, 0xe43: 0x4000, 0xe44: 0x4000, 0xe45: 0x4000, - 0xe46: 0x4000, 0xe47: 0x4000, 0xe48: 0x4000, 0xe49: 0x4000, 0xe4a: 0x4000, 0xe4b: 0x4000, - 0xe4c: 0x4000, 0xe4d: 0x4000, 0xe4e: 0x4000, 0xe4f: 0x4000, 0xe50: 0x4000, 0xe51: 0x4000, - 0xe52: 0x4000, 0xe53: 0x4000, 0xe54: 0x4000, 0xe55: 0x4000, 0xe56: 0x4000, 0xe57: 0x4000, - 0xe58: 0x4000, 0xe59: 0x4000, 0xe5a: 0x4000, 0xe5b: 0x4000, 0xe5c: 0x4000, 0xe5d: 0x4000, - 0xe5e: 0x4000, 0xe5f: 0x4000, 0xe60: 0x4000, 0xe61: 0x4000, 0xe62: 0x4000, 0xe63: 0x4000, - 0xe70: 0x4000, 0xe71: 0x4000, 0xe72: 0x4000, 0xe73: 0x4000, 0xe74: 0x4000, 0xe75: 0x4000, - 0xe76: 0x4000, 0xe77: 0x4000, 0xe78: 0x4000, 0xe79: 0x4000, 0xe7a: 0x4000, 0xe7b: 0x4000, - 0xe7c: 0x4000, 0xe7d: 0x4000, 0xe7e: 0x4000, 0xe7f: 0x4000, - // Block 0x3a, offset 0xe80 - 0xe80: 0x4000, 0xe81: 0x4000, 0xe82: 0x4000, 0xe83: 0x4000, 0xe84: 0x4000, 0xe85: 0x4000, - 0xe86: 0x4000, 0xe87: 0x4000, 0xe88: 0x4000, 0xe89: 0x4000, 0xe8a: 0x4000, 0xe8b: 0x4000, - 0xe8c: 0x4000, 0xe8d: 0x4000, 0xe8e: 0x4000, 0xe8f: 0x4000, 0xe90: 0x4000, 0xe91: 0x4000, - 0xe92: 0x4000, 0xe93: 0x4000, 0xe94: 0x4000, 0xe95: 0x4000, 0xe96: 0x4000, 0xe97: 0x4000, - 0xe98: 0x4000, 0xe99: 0x4000, 0xe9a: 0x4000, 0xe9b: 0x4000, 0xe9c: 0x4000, 0xe9d: 0x4000, - 0xe9e: 0x4000, 0xea0: 0x4000, 0xea1: 0x4000, 0xea2: 0x4000, 0xea3: 0x4000, - 0xea4: 0x4000, 0xea5: 0x4000, 0xea6: 0x4000, 0xea7: 0x4000, 0xea8: 0x4000, 0xea9: 0x4000, - 0xeaa: 0x4000, 0xeab: 0x4000, 0xeac: 0x4000, 0xead: 0x4000, 0xeae: 0x4000, 0xeaf: 0x4000, - 0xeb0: 0x4000, 0xeb1: 0x4000, 0xeb2: 0x4000, 0xeb3: 0x4000, 0xeb4: 0x4000, 0xeb5: 0x4000, - 0xeb6: 0x4000, 0xeb7: 0x4000, 0xeb8: 0x4000, 0xeb9: 0x4000, 0xeba: 0x4000, 0xebb: 0x4000, - 0xebc: 0x4000, 0xebd: 0x4000, 0xebe: 0x4000, 0xebf: 0x4000, - // Block 0x3b, offset 0xec0 - 0xec0: 0x4000, 0xec1: 0x4000, 0xec2: 0x4000, 0xec3: 0x4000, 0xec4: 0x4000, 0xec5: 0x4000, - 0xec6: 0x4000, 0xec7: 0x4000, 0xec8: 0x2000, 0xec9: 0x2000, 0xeca: 0x2000, 0xecb: 0x2000, - 0xecc: 0x2000, 0xecd: 0x2000, 0xece: 0x2000, 0xecf: 0x2000, 0xed0: 0x4000, 0xed1: 0x4000, - 0xed2: 0x4000, 0xed3: 0x4000, 0xed4: 0x4000, 0xed5: 0x4000, 0xed6: 0x4000, 0xed7: 0x4000, - 0xed8: 0x4000, 0xed9: 0x4000, 0xeda: 0x4000, 0xedb: 0x4000, 0xedc: 0x4000, 0xedd: 0x4000, - 0xede: 0x4000, 0xedf: 0x4000, 0xee0: 0x4000, 0xee1: 0x4000, 0xee2: 0x4000, 0xee3: 0x4000, - 0xee4: 0x4000, 0xee5: 0x4000, 0xee6: 0x4000, 0xee7: 0x4000, 0xee8: 0x4000, 0xee9: 0x4000, - 0xeea: 0x4000, 0xeeb: 0x4000, 0xeec: 0x4000, 0xeed: 0x4000, 0xeee: 0x4000, 0xeef: 0x4000, - 0xef0: 0x4000, 0xef1: 0x4000, 0xef2: 0x4000, 0xef3: 0x4000, 0xef4: 0x4000, 0xef5: 0x4000, - 0xef6: 0x4000, 0xef7: 0x4000, 0xef8: 0x4000, 0xef9: 0x4000, 0xefa: 0x4000, 0xefb: 0x4000, - 0xefc: 0x4000, 0xefd: 0x4000, 0xefe: 0x4000, 0xeff: 0x4000, - // Block 0x3c, offset 0xf00 - 0xf00: 0x4000, 0xf01: 0x4000, 0xf02: 0x4000, 0xf03: 0x4000, 0xf04: 0x4000, 0xf05: 0x4000, - 0xf06: 0x4000, 0xf07: 0x4000, 0xf08: 0x4000, 0xf09: 0x4000, 0xf0a: 0x4000, 0xf0b: 0x4000, - 0xf0c: 0x4000, 0xf0d: 0x4000, 0xf0e: 0x4000, 0xf0f: 0x4000, 0xf10: 0x4000, 0xf11: 0x4000, - 0xf12: 0x4000, 0xf13: 0x4000, 0xf14: 0x4000, 0xf15: 0x4000, 0xf16: 0x4000, 0xf17: 0x4000, - 0xf18: 0x4000, 0xf19: 0x4000, 0xf1a: 0x4000, 0xf1b: 0x4000, 0xf1c: 0x4000, 0xf1d: 0x4000, - 0xf1e: 0x4000, 0xf1f: 0x4000, 0xf20: 0x4000, 0xf21: 0x4000, 0xf22: 0x4000, 0xf23: 0x4000, - 0xf24: 0x4000, 0xf25: 0x4000, 0xf26: 0x4000, 0xf27: 0x4000, 0xf28: 0x4000, 0xf29: 0x4000, - 0xf2a: 0x4000, 0xf2b: 0x4000, 0xf2c: 0x4000, 0xf2d: 0x4000, 0xf2e: 0x4000, 0xf2f: 0x4000, - 0xf30: 0x4000, 0xf31: 0x4000, 0xf32: 0x4000, 0xf33: 0x4000, 0xf34: 0x4000, 0xf35: 0x4000, - 0xf36: 0x4000, 0xf37: 0x4000, 0xf38: 0x4000, 0xf39: 0x4000, 0xf3a: 0x4000, 0xf3b: 0x4000, - 0xf3c: 0x4000, 0xf3d: 0x4000, 0xf3e: 0x4000, - // Block 0x3d, offset 0xf40 - 0xf40: 0x4000, 0xf41: 0x4000, 0xf42: 0x4000, 0xf43: 0x4000, 0xf44: 0x4000, 0xf45: 0x4000, - 0xf46: 0x4000, 0xf47: 0x4000, 0xf48: 0x4000, 0xf49: 0x4000, 0xf4a: 0x4000, 0xf4b: 0x4000, - 0xf4c: 0x4000, 0xf50: 0x4000, 0xf51: 0x4000, - 0xf52: 0x4000, 0xf53: 0x4000, 0xf54: 0x4000, 0xf55: 0x4000, 0xf56: 0x4000, 0xf57: 0x4000, - 0xf58: 0x4000, 0xf59: 0x4000, 0xf5a: 0x4000, 0xf5b: 0x4000, 0xf5c: 0x4000, 0xf5d: 0x4000, - 0xf5e: 0x4000, 0xf5f: 0x4000, 0xf60: 0x4000, 0xf61: 0x4000, 0xf62: 0x4000, 0xf63: 0x4000, - 0xf64: 0x4000, 0xf65: 0x4000, 0xf66: 0x4000, 0xf67: 0x4000, 0xf68: 0x4000, 0xf69: 0x4000, - 0xf6a: 0x4000, 0xf6b: 0x4000, 0xf6c: 0x4000, 0xf6d: 0x4000, 0xf6e: 0x4000, 0xf6f: 0x4000, - 0xf70: 0x4000, 0xf71: 0x4000, 0xf72: 0x4000, 0xf73: 0x4000, 0xf74: 0x4000, 0xf75: 0x4000, - 0xf76: 0x4000, 0xf77: 0x4000, 0xf78: 0x4000, 0xf79: 0x4000, 0xf7a: 0x4000, 0xf7b: 0x4000, - 0xf7c: 0x4000, 0xf7d: 0x4000, 0xf7e: 0x4000, 0xf7f: 0x4000, - // Block 0x3e, offset 0xf80 - 0xf80: 0x4000, 0xf81: 0x4000, 0xf82: 0x4000, 0xf83: 0x4000, 0xf84: 0x4000, 0xf85: 0x4000, - 0xf86: 0x4000, - // Block 0x3f, offset 0xfc0 - 0xfe0: 0x4000, 0xfe1: 0x4000, 0xfe2: 0x4000, 0xfe3: 0x4000, - 0xfe4: 0x4000, 0xfe5: 0x4000, 0xfe6: 0x4000, 0xfe7: 0x4000, 0xfe8: 0x4000, 0xfe9: 0x4000, - 0xfea: 0x4000, 0xfeb: 0x4000, 0xfec: 0x4000, 0xfed: 0x4000, 0xfee: 0x4000, 0xfef: 0x4000, - 0xff0: 0x4000, 0xff1: 0x4000, 0xff2: 0x4000, 0xff3: 0x4000, 0xff4: 0x4000, 0xff5: 0x4000, - 0xff6: 0x4000, 0xff7: 0x4000, 0xff8: 0x4000, 0xff9: 0x4000, 0xffa: 0x4000, 0xffb: 0x4000, - 0xffc: 0x4000, - // Block 0x40, offset 0x1000 - 0x1000: 0x4000, 0x1001: 0x4000, 0x1002: 0x4000, 0x1003: 0x4000, 0x1004: 0x4000, 0x1005: 0x4000, - 0x1006: 0x4000, 0x1007: 0x4000, 0x1008: 0x4000, 0x1009: 0x4000, 0x100a: 0x4000, 0x100b: 0x4000, - 0x100c: 0x4000, 0x100d: 0x4000, 0x100e: 0x4000, 0x100f: 0x4000, 0x1010: 0x4000, 0x1011: 0x4000, - 0x1012: 0x4000, 0x1013: 0x4000, 0x1014: 0x4000, 0x1015: 0x4000, 0x1016: 0x4000, 0x1017: 0x4000, - 0x1018: 0x4000, 0x1019: 0x4000, 0x101a: 0x4000, 0x101b: 0x4000, 0x101c: 0x4000, 0x101d: 0x4000, - 0x101e: 0x4000, 0x101f: 0x4000, 0x1020: 0x4000, 0x1021: 0x4000, 0x1022: 0x4000, 0x1023: 0x4000, - // Block 0x41, offset 0x1040 - 0x1040: 0x2000, 0x1041: 0x2000, 0x1042: 0x2000, 0x1043: 0x2000, 0x1044: 0x2000, 0x1045: 0x2000, - 0x1046: 0x2000, 0x1047: 0x2000, 0x1048: 0x2000, 0x1049: 0x2000, 0x104a: 0x2000, 0x104b: 0x2000, - 0x104c: 0x2000, 0x104d: 0x2000, 0x104e: 0x2000, 0x104f: 0x2000, 0x1050: 0x4000, 0x1051: 0x4000, - 0x1052: 0x4000, 0x1053: 0x4000, 0x1054: 0x4000, 0x1055: 0x4000, 0x1056: 0x4000, 0x1057: 0x4000, - 0x1058: 0x4000, 0x1059: 0x4000, - 0x1070: 0x4000, 0x1071: 0x4000, 0x1072: 0x4000, 0x1073: 0x4000, 0x1074: 0x4000, 0x1075: 0x4000, - 0x1076: 0x4000, 0x1077: 0x4000, 0x1078: 0x4000, 0x1079: 0x4000, 0x107a: 0x4000, 0x107b: 0x4000, - 0x107c: 0x4000, 0x107d: 0x4000, 0x107e: 0x4000, 0x107f: 0x4000, - // Block 0x42, offset 0x1080 - 0x1080: 0x4000, 0x1081: 0x4000, 0x1082: 0x4000, 0x1083: 0x4000, 0x1084: 0x4000, 0x1085: 0x4000, - 0x1086: 0x4000, 0x1087: 0x4000, 0x1088: 0x4000, 0x1089: 0x4000, 0x108a: 0x4000, 0x108b: 0x4000, - 0x108c: 0x4000, 0x108d: 0x4000, 0x108e: 0x4000, 0x108f: 0x4000, 0x1090: 0x4000, 0x1091: 0x4000, - 0x1092: 0x4000, 0x1094: 0x4000, 0x1095: 0x4000, 0x1096: 0x4000, 0x1097: 0x4000, - 0x1098: 0x4000, 0x1099: 0x4000, 0x109a: 0x4000, 0x109b: 0x4000, 0x109c: 0x4000, 0x109d: 0x4000, - 0x109e: 0x4000, 0x109f: 0x4000, 0x10a0: 0x4000, 0x10a1: 0x4000, 0x10a2: 0x4000, 0x10a3: 0x4000, - 0x10a4: 0x4000, 0x10a5: 0x4000, 0x10a6: 0x4000, 0x10a8: 0x4000, 0x10a9: 0x4000, - 0x10aa: 0x4000, 0x10ab: 0x4000, - // Block 0x43, offset 0x10c0 - 0x10c1: 0x9012, 0x10c2: 0x9012, 0x10c3: 0x9012, 0x10c4: 0x9012, 0x10c5: 0x9012, - 0x10c6: 0x9012, 0x10c7: 0x9012, 0x10c8: 0x9012, 0x10c9: 0x9012, 0x10ca: 0x9012, 0x10cb: 0x9012, - 0x10cc: 0x9012, 0x10cd: 0x9012, 0x10ce: 0x9012, 0x10cf: 0x9012, 0x10d0: 0x9012, 0x10d1: 0x9012, - 0x10d2: 0x9012, 0x10d3: 0x9012, 0x10d4: 0x9012, 0x10d5: 0x9012, 0x10d6: 0x9012, 0x10d7: 0x9012, - 0x10d8: 0x9012, 0x10d9: 0x9012, 0x10da: 0x9012, 0x10db: 0x9012, 0x10dc: 0x9012, 0x10dd: 0x9012, - 0x10de: 0x9012, 0x10df: 0x9012, 0x10e0: 0x9049, 0x10e1: 0x9049, 0x10e2: 0x9049, 0x10e3: 0x9049, - 0x10e4: 0x9049, 0x10e5: 0x9049, 0x10e6: 0x9049, 0x10e7: 0x9049, 0x10e8: 0x9049, 0x10e9: 0x9049, - 0x10ea: 0x9049, 0x10eb: 0x9049, 0x10ec: 0x9049, 0x10ed: 0x9049, 0x10ee: 0x9049, 0x10ef: 0x9049, - 0x10f0: 0x9049, 0x10f1: 0x9049, 0x10f2: 0x9049, 0x10f3: 0x9049, 0x10f4: 0x9049, 0x10f5: 0x9049, - 0x10f6: 0x9049, 0x10f7: 0x9049, 0x10f8: 0x9049, 0x10f9: 0x9049, 0x10fa: 0x9049, 0x10fb: 0x9049, - 0x10fc: 0x9049, 0x10fd: 0x9049, 0x10fe: 0x9049, 0x10ff: 0x9049, - // Block 0x44, offset 0x1100 - 0x1100: 0x9049, 0x1101: 0x9049, 0x1102: 0x9049, 0x1103: 0x9049, 0x1104: 0x9049, 0x1105: 0x9049, - 0x1106: 0x9049, 0x1107: 0x9049, 0x1108: 0x9049, 0x1109: 0x9049, 0x110a: 0x9049, 0x110b: 0x9049, - 0x110c: 0x9049, 0x110d: 0x9049, 0x110e: 0x9049, 0x110f: 0x9049, 0x1110: 0x9049, 0x1111: 0x9049, - 0x1112: 0x9049, 0x1113: 0x9049, 0x1114: 0x9049, 0x1115: 0x9049, 0x1116: 0x9049, 0x1117: 0x9049, - 0x1118: 0x9049, 0x1119: 0x9049, 0x111a: 0x9049, 0x111b: 0x9049, 0x111c: 0x9049, 0x111d: 0x9049, - 0x111e: 0x9049, 0x111f: 0x904a, 0x1120: 0x904b, 0x1121: 0xb04c, 0x1122: 0xb04d, 0x1123: 0xb04d, - 0x1124: 0xb04e, 0x1125: 0xb04f, 0x1126: 0xb050, 0x1127: 0xb051, 0x1128: 0xb052, 0x1129: 0xb053, - 0x112a: 0xb054, 0x112b: 0xb055, 0x112c: 0xb056, 0x112d: 0xb057, 0x112e: 0xb058, 0x112f: 0xb059, - 0x1130: 0xb05a, 0x1131: 0xb05b, 0x1132: 0xb05c, 0x1133: 0xb05d, 0x1134: 0xb05e, 0x1135: 0xb05f, - 0x1136: 0xb060, 0x1137: 0xb061, 0x1138: 0xb062, 0x1139: 0xb063, 0x113a: 0xb064, 0x113b: 0xb065, - 0x113c: 0xb052, 0x113d: 0xb066, 0x113e: 0xb067, 0x113f: 0xb055, - // Block 0x45, offset 0x1140 - 0x1140: 0xb068, 0x1141: 0xb069, 0x1142: 0xb06a, 0x1143: 0xb06b, 0x1144: 0xb05a, 0x1145: 0xb056, - 0x1146: 0xb06c, 0x1147: 0xb06d, 0x1148: 0xb06b, 0x1149: 0xb06e, 0x114a: 0xb06b, 0x114b: 0xb06f, - 0x114c: 0xb06f, 0x114d: 0xb070, 0x114e: 0xb070, 0x114f: 0xb071, 0x1150: 0xb056, 0x1151: 0xb072, - 0x1152: 0xb073, 0x1153: 0xb072, 0x1154: 0xb074, 0x1155: 0xb073, 0x1156: 0xb075, 0x1157: 0xb075, - 0x1158: 0xb076, 0x1159: 0xb076, 0x115a: 0xb077, 0x115b: 0xb077, 0x115c: 0xb073, 0x115d: 0xb078, - 0x115e: 0xb079, 0x115f: 0xb067, 0x1160: 0xb07a, 0x1161: 0xb07b, 0x1162: 0xb07b, 0x1163: 0xb07b, - 0x1164: 0xb07b, 0x1165: 0xb07b, 0x1166: 0xb07b, 0x1167: 0xb07b, 0x1168: 0xb07b, 0x1169: 0xb07b, - 0x116a: 0xb07b, 0x116b: 0xb07b, 0x116c: 0xb07b, 0x116d: 0xb07b, 0x116e: 0xb07b, 0x116f: 0xb07b, - 0x1170: 0xb07c, 0x1171: 0xb07c, 0x1172: 0xb07c, 0x1173: 0xb07c, 0x1174: 0xb07c, 0x1175: 0xb07c, - 0x1176: 0xb07c, 0x1177: 0xb07c, 0x1178: 0xb07c, 0x1179: 0xb07c, 0x117a: 0xb07c, 0x117b: 0xb07c, - 0x117c: 0xb07c, 0x117d: 0xb07c, 0x117e: 0xb07c, - // Block 0x46, offset 0x1180 - 0x1182: 0xb07d, 0x1183: 0xb07e, 0x1184: 0xb07f, 0x1185: 0xb080, - 0x1186: 0xb07f, 0x1187: 0xb07e, 0x118a: 0xb081, 0x118b: 0xb082, - 0x118c: 0xb083, 0x118d: 0xb07f, 0x118e: 0xb080, 0x118f: 0xb07f, - 0x1192: 0xb084, 0x1193: 0xb085, 0x1194: 0xb084, 0x1195: 0xb086, 0x1196: 0xb084, 0x1197: 0xb087, - 0x119a: 0xb088, 0x119b: 0xb089, 0x119c: 0xb08a, - 0x11a0: 0x908b, 0x11a1: 0x908b, 0x11a2: 0x908c, 0x11a3: 0x908d, - 0x11a4: 0x908b, 0x11a5: 0x908e, 0x11a6: 0x908f, 0x11a8: 0xb090, 0x11a9: 0xb091, - 0x11aa: 0xb092, 0x11ab: 0xb091, 0x11ac: 0xb093, 0x11ad: 0xb094, 0x11ae: 0xb095, - 0x11bd: 0x2000, - // Block 0x47, offset 0x11c0 - 0x11e0: 0x4000, - // Block 0x48, offset 0x1200 - 0x1200: 0x4000, 0x1201: 0x4000, 0x1202: 0x4000, 0x1203: 0x4000, 0x1204: 0x4000, 0x1205: 0x4000, - 0x1206: 0x4000, 0x1207: 0x4000, 0x1208: 0x4000, 0x1209: 0x4000, 0x120a: 0x4000, 0x120b: 0x4000, - 0x120c: 0x4000, 0x120d: 0x4000, 0x120e: 0x4000, 0x120f: 0x4000, 0x1210: 0x4000, 0x1211: 0x4000, - 0x1212: 0x4000, 0x1213: 0x4000, 0x1214: 0x4000, 0x1215: 0x4000, 0x1216: 0x4000, 0x1217: 0x4000, - 0x1218: 0x4000, 0x1219: 0x4000, 0x121a: 0x4000, 0x121b: 0x4000, 0x121c: 0x4000, 0x121d: 0x4000, - 0x121e: 0x4000, 0x121f: 0x4000, 0x1220: 0x4000, 0x1221: 0x4000, 0x1222: 0x4000, 0x1223: 0x4000, - 0x1224: 0x4000, 0x1225: 0x4000, 0x1226: 0x4000, 0x1227: 0x4000, 0x1228: 0x4000, 0x1229: 0x4000, - 0x122a: 0x4000, 0x122b: 0x4000, 0x122c: 0x4000, - // Block 0x49, offset 0x1240 - 0x1240: 0x4000, 0x1241: 0x4000, 0x1242: 0x4000, 0x1243: 0x4000, 0x1244: 0x4000, 0x1245: 0x4000, - 0x1246: 0x4000, 0x1247: 0x4000, 0x1248: 0x4000, 0x1249: 0x4000, 0x124a: 0x4000, 0x124b: 0x4000, - 0x124c: 0x4000, 0x124d: 0x4000, 0x124e: 0x4000, 0x124f: 0x4000, 0x1250: 0x4000, 0x1251: 0x4000, - 0x1252: 0x4000, 0x1253: 0x4000, 0x1254: 0x4000, 0x1255: 0x4000, 0x1256: 0x4000, 0x1257: 0x4000, - 0x1258: 0x4000, 0x1259: 0x4000, 0x125a: 0x4000, 0x125b: 0x4000, 0x125c: 0x4000, 0x125d: 0x4000, - 0x125e: 0x4000, 0x125f: 0x4000, 0x1260: 0x4000, 0x1261: 0x4000, 0x1262: 0x4000, 0x1263: 0x4000, - 0x1264: 0x4000, 0x1265: 0x4000, 0x1266: 0x4000, 0x1267: 0x4000, 0x1268: 0x4000, 0x1269: 0x4000, - 0x126a: 0x4000, 0x126b: 0x4000, 0x126c: 0x4000, 0x126d: 0x4000, 0x126e: 0x4000, 0x126f: 0x4000, - 0x1270: 0x4000, 0x1271: 0x4000, 0x1272: 0x4000, - // Block 0x4a, offset 0x1280 - 0x1280: 0x4000, 0x1281: 0x4000, - // Block 0x4b, offset 0x12c0 - 0x12c4: 0x4000, - // Block 0x4c, offset 0x1300 - 0x130f: 0x4000, - // Block 0x4d, offset 0x1340 - 0x1340: 0x2000, 0x1341: 0x2000, 0x1342: 0x2000, 0x1343: 0x2000, 0x1344: 0x2000, 0x1345: 0x2000, - 0x1346: 0x2000, 0x1347: 0x2000, 0x1348: 0x2000, 0x1349: 0x2000, 0x134a: 0x2000, - 0x1350: 0x2000, 0x1351: 0x2000, - 0x1352: 0x2000, 0x1353: 0x2000, 0x1354: 0x2000, 0x1355: 0x2000, 0x1356: 0x2000, 0x1357: 0x2000, - 0x1358: 0x2000, 0x1359: 0x2000, 0x135a: 0x2000, 0x135b: 0x2000, 0x135c: 0x2000, 0x135d: 0x2000, - 0x135e: 0x2000, 0x135f: 0x2000, 0x1360: 0x2000, 0x1361: 0x2000, 0x1362: 0x2000, 0x1363: 0x2000, - 0x1364: 0x2000, 0x1365: 0x2000, 0x1366: 0x2000, 0x1367: 0x2000, 0x1368: 0x2000, 0x1369: 0x2000, - 0x136a: 0x2000, 0x136b: 0x2000, 0x136c: 0x2000, 0x136d: 0x2000, - 0x1370: 0x2000, 0x1371: 0x2000, 0x1372: 0x2000, 0x1373: 0x2000, 0x1374: 0x2000, 0x1375: 0x2000, - 0x1376: 0x2000, 0x1377: 0x2000, 0x1378: 0x2000, 0x1379: 0x2000, 0x137a: 0x2000, 0x137b: 0x2000, - 0x137c: 0x2000, 0x137d: 0x2000, 0x137e: 0x2000, 0x137f: 0x2000, - // Block 0x4e, offset 0x1380 - 0x1380: 0x2000, 0x1381: 0x2000, 0x1382: 0x2000, 0x1383: 0x2000, 0x1384: 0x2000, 0x1385: 0x2000, - 0x1386: 0x2000, 0x1387: 0x2000, 0x1388: 0x2000, 0x1389: 0x2000, 0x138a: 0x2000, 0x138b: 0x2000, - 0x138c: 0x2000, 0x138d: 0x2000, 0x138e: 0x2000, 0x138f: 0x2000, 0x1390: 0x2000, 0x1391: 0x2000, - 0x1392: 0x2000, 0x1393: 0x2000, 0x1394: 0x2000, 0x1395: 0x2000, 0x1396: 0x2000, 0x1397: 0x2000, - 0x1398: 0x2000, 0x1399: 0x2000, 0x139a: 0x2000, 0x139b: 0x2000, 0x139c: 0x2000, 0x139d: 0x2000, - 0x139e: 0x2000, 0x139f: 0x2000, 0x13a0: 0x2000, 0x13a1: 0x2000, 0x13a2: 0x2000, 0x13a3: 0x2000, - 0x13a4: 0x2000, 0x13a5: 0x2000, 0x13a6: 0x2000, 0x13a7: 0x2000, 0x13a8: 0x2000, 0x13a9: 0x2000, - 0x13b0: 0x2000, 0x13b1: 0x2000, 0x13b2: 0x2000, 0x13b3: 0x2000, 0x13b4: 0x2000, 0x13b5: 0x2000, - 0x13b6: 0x2000, 0x13b7: 0x2000, 0x13b8: 0x2000, 0x13b9: 0x2000, 0x13ba: 0x2000, 0x13bb: 0x2000, - 0x13bc: 0x2000, 0x13bd: 0x2000, 0x13be: 0x2000, 0x13bf: 0x2000, - // Block 0x4f, offset 0x13c0 - 0x13c0: 0x2000, 0x13c1: 0x2000, 0x13c2: 0x2000, 0x13c3: 0x2000, 0x13c4: 0x2000, 0x13c5: 0x2000, - 0x13c6: 0x2000, 0x13c7: 0x2000, 0x13c8: 0x2000, 0x13c9: 0x2000, 0x13ca: 0x2000, 0x13cb: 0x2000, - 0x13cc: 0x2000, 0x13cd: 0x2000, 0x13ce: 0x4000, 0x13cf: 0x2000, 0x13d0: 0x2000, 0x13d1: 0x4000, - 0x13d2: 0x4000, 0x13d3: 0x4000, 0x13d4: 0x4000, 0x13d5: 0x4000, 0x13d6: 0x4000, 0x13d7: 0x4000, - 0x13d8: 0x4000, 0x13d9: 0x4000, 0x13da: 0x4000, 0x13db: 0x2000, 0x13dc: 0x2000, 0x13dd: 0x2000, - 0x13de: 0x2000, 0x13df: 0x2000, 0x13e0: 0x2000, 0x13e1: 0x2000, 0x13e2: 0x2000, 0x13e3: 0x2000, - 0x13e4: 0x2000, 0x13e5: 0x2000, 0x13e6: 0x2000, 0x13e7: 0x2000, 0x13e8: 0x2000, 0x13e9: 0x2000, - 0x13ea: 0x2000, 0x13eb: 0x2000, 0x13ec: 0x2000, - // Block 0x50, offset 0x1400 - 0x1400: 0x4000, 0x1401: 0x4000, 0x1402: 0x4000, - 0x1410: 0x4000, 0x1411: 0x4000, - 0x1412: 0x4000, 0x1413: 0x4000, 0x1414: 0x4000, 0x1415: 0x4000, 0x1416: 0x4000, 0x1417: 0x4000, - 0x1418: 0x4000, 0x1419: 0x4000, 0x141a: 0x4000, 0x141b: 0x4000, 0x141c: 0x4000, 0x141d: 0x4000, - 0x141e: 0x4000, 0x141f: 0x4000, 0x1420: 0x4000, 0x1421: 0x4000, 0x1422: 0x4000, 0x1423: 0x4000, - 0x1424: 0x4000, 0x1425: 0x4000, 0x1426: 0x4000, 0x1427: 0x4000, 0x1428: 0x4000, 0x1429: 0x4000, - 0x142a: 0x4000, 0x142b: 0x4000, 0x142c: 0x4000, 0x142d: 0x4000, 0x142e: 0x4000, 0x142f: 0x4000, - 0x1430: 0x4000, 0x1431: 0x4000, 0x1432: 0x4000, 0x1433: 0x4000, 0x1434: 0x4000, 0x1435: 0x4000, - 0x1436: 0x4000, 0x1437: 0x4000, 0x1438: 0x4000, 0x1439: 0x4000, 0x143a: 0x4000, 0x143b: 0x4000, - // Block 0x51, offset 0x1440 - 0x1440: 0x4000, 0x1441: 0x4000, 0x1442: 0x4000, 0x1443: 0x4000, 0x1444: 0x4000, 0x1445: 0x4000, - 0x1446: 0x4000, 0x1447: 0x4000, 0x1448: 0x4000, - 0x1450: 0x4000, 0x1451: 0x4000, - // Block 0x52, offset 0x1480 - 0x1480: 0x4000, 0x1481: 0x4000, 0x1482: 0x4000, 0x1483: 0x4000, 0x1484: 0x4000, 0x1485: 0x4000, - 0x1486: 0x4000, 0x1487: 0x4000, 0x1488: 0x4000, 0x1489: 0x4000, 0x148a: 0x4000, 0x148b: 0x4000, - 0x148c: 0x4000, 0x148d: 0x4000, 0x148e: 0x4000, 0x148f: 0x4000, 0x1490: 0x4000, 0x1491: 0x4000, - 0x1492: 0x4000, 0x1493: 0x4000, 0x1494: 0x4000, 0x1495: 0x4000, 0x1496: 0x4000, 0x1497: 0x4000, - 0x1498: 0x4000, 0x1499: 0x4000, 0x149a: 0x4000, 0x149b: 0x4000, 0x149c: 0x4000, 0x149d: 0x4000, - 0x149e: 0x4000, 0x149f: 0x4000, 0x14a0: 0x4000, - 0x14ad: 0x4000, 0x14ae: 0x4000, 0x14af: 0x4000, - 0x14b0: 0x4000, 0x14b1: 0x4000, 0x14b2: 0x4000, 0x14b3: 0x4000, 0x14b4: 0x4000, 0x14b5: 0x4000, - 0x14b7: 0x4000, 0x14b8: 0x4000, 0x14b9: 0x4000, 0x14ba: 0x4000, 0x14bb: 0x4000, - 0x14bc: 0x4000, 0x14bd: 0x4000, 0x14be: 0x4000, 0x14bf: 0x4000, - // Block 0x53, offset 0x14c0 - 0x14c0: 0x4000, 0x14c1: 0x4000, 0x14c2: 0x4000, 0x14c3: 0x4000, 0x14c4: 0x4000, 0x14c5: 0x4000, - 0x14c6: 0x4000, 0x14c7: 0x4000, 0x14c8: 0x4000, 0x14c9: 0x4000, 0x14ca: 0x4000, 0x14cb: 0x4000, - 0x14cc: 0x4000, 0x14cd: 0x4000, 0x14ce: 0x4000, 0x14cf: 0x4000, 0x14d0: 0x4000, 0x14d1: 0x4000, - 0x14d2: 0x4000, 0x14d3: 0x4000, 0x14d4: 0x4000, 0x14d5: 0x4000, 0x14d6: 0x4000, 0x14d7: 0x4000, - 0x14d8: 0x4000, 0x14d9: 0x4000, 0x14da: 0x4000, 0x14db: 0x4000, 0x14dc: 0x4000, 0x14dd: 0x4000, - 0x14de: 0x4000, 0x14df: 0x4000, 0x14e0: 0x4000, 0x14e1: 0x4000, 0x14e2: 0x4000, 0x14e3: 0x4000, - 0x14e4: 0x4000, 0x14e5: 0x4000, 0x14e6: 0x4000, 0x14e7: 0x4000, 0x14e8: 0x4000, 0x14e9: 0x4000, - 0x14ea: 0x4000, 0x14eb: 0x4000, 0x14ec: 0x4000, 0x14ed: 0x4000, 0x14ee: 0x4000, 0x14ef: 0x4000, - 0x14f0: 0x4000, 0x14f1: 0x4000, 0x14f2: 0x4000, 0x14f3: 0x4000, 0x14f4: 0x4000, 0x14f5: 0x4000, - 0x14f6: 0x4000, 0x14f7: 0x4000, 0x14f8: 0x4000, 0x14f9: 0x4000, 0x14fa: 0x4000, 0x14fb: 0x4000, - 0x14fc: 0x4000, 0x14fe: 0x4000, 0x14ff: 0x4000, - // Block 0x54, offset 0x1500 - 0x1500: 0x4000, 0x1501: 0x4000, 0x1502: 0x4000, 0x1503: 0x4000, 0x1504: 0x4000, 0x1505: 0x4000, - 0x1506: 0x4000, 0x1507: 0x4000, 0x1508: 0x4000, 0x1509: 0x4000, 0x150a: 0x4000, 0x150b: 0x4000, - 0x150c: 0x4000, 0x150d: 0x4000, 0x150e: 0x4000, 0x150f: 0x4000, 0x1510: 0x4000, 0x1511: 0x4000, - 0x1512: 0x4000, 0x1513: 0x4000, - 0x1520: 0x4000, 0x1521: 0x4000, 0x1522: 0x4000, 0x1523: 0x4000, - 0x1524: 0x4000, 0x1525: 0x4000, 0x1526: 0x4000, 0x1527: 0x4000, 0x1528: 0x4000, 0x1529: 0x4000, - 0x152a: 0x4000, 0x152b: 0x4000, 0x152c: 0x4000, 0x152d: 0x4000, 0x152e: 0x4000, 0x152f: 0x4000, - 0x1530: 0x4000, 0x1531: 0x4000, 0x1532: 0x4000, 0x1533: 0x4000, 0x1534: 0x4000, 0x1535: 0x4000, - 0x1536: 0x4000, 0x1537: 0x4000, 0x1538: 0x4000, 0x1539: 0x4000, 0x153a: 0x4000, 0x153b: 0x4000, - 0x153c: 0x4000, 0x153d: 0x4000, 0x153e: 0x4000, 0x153f: 0x4000, - // Block 0x55, offset 0x1540 - 0x1540: 0x4000, 0x1541: 0x4000, 0x1542: 0x4000, 0x1543: 0x4000, 0x1544: 0x4000, 0x1545: 0x4000, - 0x1546: 0x4000, 0x1547: 0x4000, 0x1548: 0x4000, 0x1549: 0x4000, 0x154a: 0x4000, - 0x154f: 0x4000, 0x1550: 0x4000, 0x1551: 0x4000, - 0x1552: 0x4000, 0x1553: 0x4000, - 0x1560: 0x4000, 0x1561: 0x4000, 0x1562: 0x4000, 0x1563: 0x4000, - 0x1564: 0x4000, 0x1565: 0x4000, 0x1566: 0x4000, 0x1567: 0x4000, 0x1568: 0x4000, 0x1569: 0x4000, - 0x156a: 0x4000, 0x156b: 0x4000, 0x156c: 0x4000, 0x156d: 0x4000, 0x156e: 0x4000, 0x156f: 0x4000, - 0x1570: 0x4000, 0x1574: 0x4000, - 0x1578: 0x4000, 0x1579: 0x4000, 0x157a: 0x4000, 0x157b: 0x4000, - 0x157c: 0x4000, 0x157d: 0x4000, 0x157e: 0x4000, 0x157f: 0x4000, - // Block 0x56, offset 0x1580 - 0x1580: 0x4000, 0x1582: 0x4000, 0x1583: 0x4000, 0x1584: 0x4000, 0x1585: 0x4000, - 0x1586: 0x4000, 0x1587: 0x4000, 0x1588: 0x4000, 0x1589: 0x4000, 0x158a: 0x4000, 0x158b: 0x4000, - 0x158c: 0x4000, 0x158d: 0x4000, 0x158e: 0x4000, 0x158f: 0x4000, 0x1590: 0x4000, 0x1591: 0x4000, - 0x1592: 0x4000, 0x1593: 0x4000, 0x1594: 0x4000, 0x1595: 0x4000, 0x1596: 0x4000, 0x1597: 0x4000, - 0x1598: 0x4000, 0x1599: 0x4000, 0x159a: 0x4000, 0x159b: 0x4000, 0x159c: 0x4000, 0x159d: 0x4000, - 0x159e: 0x4000, 0x159f: 0x4000, 0x15a0: 0x4000, 0x15a1: 0x4000, 0x15a2: 0x4000, 0x15a3: 0x4000, - 0x15a4: 0x4000, 0x15a5: 0x4000, 0x15a6: 0x4000, 0x15a7: 0x4000, 0x15a8: 0x4000, 0x15a9: 0x4000, - 0x15aa: 0x4000, 0x15ab: 0x4000, 0x15ac: 0x4000, 0x15ad: 0x4000, 0x15ae: 0x4000, 0x15af: 0x4000, - 0x15b0: 0x4000, 0x15b1: 0x4000, 0x15b2: 0x4000, 0x15b3: 0x4000, 0x15b4: 0x4000, 0x15b5: 0x4000, - 0x15b6: 0x4000, 0x15b7: 0x4000, 0x15b8: 0x4000, 0x15b9: 0x4000, 0x15ba: 0x4000, 0x15bb: 0x4000, - 0x15bc: 0x4000, 0x15bd: 0x4000, 0x15be: 0x4000, 0x15bf: 0x4000, - // Block 0x57, offset 0x15c0 - 0x15c0: 0x4000, 0x15c1: 0x4000, 0x15c2: 0x4000, 0x15c3: 0x4000, 0x15c4: 0x4000, 0x15c5: 0x4000, - 0x15c6: 0x4000, 0x15c7: 0x4000, 0x15c8: 0x4000, 0x15c9: 0x4000, 0x15ca: 0x4000, 0x15cb: 0x4000, - 0x15cc: 0x4000, 0x15cd: 0x4000, 0x15ce: 0x4000, 0x15cf: 0x4000, 0x15d0: 0x4000, 0x15d1: 0x4000, - 0x15d2: 0x4000, 0x15d3: 0x4000, 0x15d4: 0x4000, 0x15d5: 0x4000, 0x15d6: 0x4000, 0x15d7: 0x4000, - 0x15d8: 0x4000, 0x15d9: 0x4000, 0x15da: 0x4000, 0x15db: 0x4000, 0x15dc: 0x4000, 0x15dd: 0x4000, - 0x15de: 0x4000, 0x15df: 0x4000, 0x15e0: 0x4000, 0x15e1: 0x4000, 0x15e2: 0x4000, 0x15e3: 0x4000, - 0x15e4: 0x4000, 0x15e5: 0x4000, 0x15e6: 0x4000, 0x15e7: 0x4000, 0x15e8: 0x4000, 0x15e9: 0x4000, - 0x15ea: 0x4000, 0x15eb: 0x4000, 0x15ec: 0x4000, 0x15ed: 0x4000, 0x15ee: 0x4000, 0x15ef: 0x4000, - 0x15f0: 0x4000, 0x15f1: 0x4000, 0x15f2: 0x4000, 0x15f3: 0x4000, 0x15f4: 0x4000, 0x15f5: 0x4000, - 0x15f6: 0x4000, 0x15f7: 0x4000, 0x15f8: 0x4000, 0x15f9: 0x4000, 0x15fa: 0x4000, 0x15fb: 0x4000, - 0x15fc: 0x4000, 0x15ff: 0x4000, - // Block 0x58, offset 0x1600 - 0x1600: 0x4000, 0x1601: 0x4000, 0x1602: 0x4000, 0x1603: 0x4000, 0x1604: 0x4000, 0x1605: 0x4000, - 0x1606: 0x4000, 0x1607: 0x4000, 0x1608: 0x4000, 0x1609: 0x4000, 0x160a: 0x4000, 0x160b: 0x4000, - 0x160c: 0x4000, 0x160d: 0x4000, 0x160e: 0x4000, 0x160f: 0x4000, 0x1610: 0x4000, 0x1611: 0x4000, - 0x1612: 0x4000, 0x1613: 0x4000, 0x1614: 0x4000, 0x1615: 0x4000, 0x1616: 0x4000, 0x1617: 0x4000, - 0x1618: 0x4000, 0x1619: 0x4000, 0x161a: 0x4000, 0x161b: 0x4000, 0x161c: 0x4000, 0x161d: 0x4000, - 0x161e: 0x4000, 0x161f: 0x4000, 0x1620: 0x4000, 0x1621: 0x4000, 0x1622: 0x4000, 0x1623: 0x4000, - 0x1624: 0x4000, 0x1625: 0x4000, 0x1626: 0x4000, 0x1627: 0x4000, 0x1628: 0x4000, 0x1629: 0x4000, - 0x162a: 0x4000, 0x162b: 0x4000, 0x162c: 0x4000, 0x162d: 0x4000, 0x162e: 0x4000, 0x162f: 0x4000, - 0x1630: 0x4000, 0x1631: 0x4000, 0x1632: 0x4000, 0x1633: 0x4000, 0x1634: 0x4000, 0x1635: 0x4000, - 0x1636: 0x4000, 0x1637: 0x4000, 0x1638: 0x4000, 0x1639: 0x4000, 0x163a: 0x4000, 0x163b: 0x4000, - 0x163c: 0x4000, 0x163d: 0x4000, - // Block 0x59, offset 0x1640 - 0x164b: 0x4000, - 0x164c: 0x4000, 0x164d: 0x4000, 0x164e: 0x4000, 0x1650: 0x4000, 0x1651: 0x4000, - 0x1652: 0x4000, 0x1653: 0x4000, 0x1654: 0x4000, 0x1655: 0x4000, 0x1656: 0x4000, 0x1657: 0x4000, - 0x1658: 0x4000, 0x1659: 0x4000, 0x165a: 0x4000, 0x165b: 0x4000, 0x165c: 0x4000, 0x165d: 0x4000, - 0x165e: 0x4000, 0x165f: 0x4000, 0x1660: 0x4000, 0x1661: 0x4000, 0x1662: 0x4000, 0x1663: 0x4000, - 0x1664: 0x4000, 0x1665: 0x4000, 0x1666: 0x4000, 0x1667: 0x4000, - 0x167a: 0x4000, - // Block 0x5a, offset 0x1680 - 0x1695: 0x4000, 0x1696: 0x4000, - 0x16a4: 0x4000, - // Block 0x5b, offset 0x16c0 - 0x16fb: 0x4000, - 0x16fc: 0x4000, 0x16fd: 0x4000, 0x16fe: 0x4000, 0x16ff: 0x4000, - // Block 0x5c, offset 0x1700 - 0x1700: 0x4000, 0x1701: 0x4000, 0x1702: 0x4000, 0x1703: 0x4000, 0x1704: 0x4000, 0x1705: 0x4000, - 0x1706: 0x4000, 0x1707: 0x4000, 0x1708: 0x4000, 0x1709: 0x4000, 0x170a: 0x4000, 0x170b: 0x4000, - 0x170c: 0x4000, 0x170d: 0x4000, 0x170e: 0x4000, 0x170f: 0x4000, - // Block 0x5d, offset 0x1740 - 0x1740: 0x4000, 0x1741: 0x4000, 0x1742: 0x4000, 0x1743: 0x4000, 0x1744: 0x4000, 0x1745: 0x4000, - 0x174c: 0x4000, 0x1750: 0x4000, 0x1751: 0x4000, - 0x1752: 0x4000, - 0x176b: 0x4000, 0x176c: 0x4000, - 0x1774: 0x4000, 0x1775: 0x4000, - 0x1776: 0x4000, - // Block 0x5e, offset 0x1780 - 0x1790: 0x4000, 0x1791: 0x4000, - 0x1792: 0x4000, 0x1793: 0x4000, 0x1794: 0x4000, 0x1795: 0x4000, 0x1796: 0x4000, 0x1797: 0x4000, - 0x1798: 0x4000, 0x1799: 0x4000, 0x179a: 0x4000, 0x179b: 0x4000, 0x179c: 0x4000, 0x179d: 0x4000, - 0x179e: 0x4000, 0x17a0: 0x4000, 0x17a1: 0x4000, 0x17a2: 0x4000, 0x17a3: 0x4000, - 0x17a4: 0x4000, 0x17a5: 0x4000, 0x17a6: 0x4000, 0x17a7: 0x4000, - 0x17b0: 0x4000, 0x17b3: 0x4000, 0x17b4: 0x4000, 0x17b5: 0x4000, - 0x17b6: 0x4000, 0x17b7: 0x4000, 0x17b8: 0x4000, 0x17b9: 0x4000, 0x17ba: 0x4000, 0x17bb: 0x4000, - 0x17bc: 0x4000, 0x17bd: 0x4000, 0x17be: 0x4000, - // Block 0x5f, offset 0x17c0 - 0x17c0: 0x4000, 0x17c1: 0x4000, 0x17c2: 0x4000, 0x17c3: 0x4000, 0x17c4: 0x4000, 0x17c5: 0x4000, - 0x17c6: 0x4000, 0x17c7: 0x4000, 0x17c8: 0x4000, 0x17c9: 0x4000, 0x17ca: 0x4000, 0x17cb: 0x4000, - 0x17d0: 0x4000, 0x17d1: 0x4000, - 0x17d2: 0x4000, 0x17d3: 0x4000, 0x17d4: 0x4000, 0x17d5: 0x4000, 0x17d6: 0x4000, 0x17d7: 0x4000, - 0x17d8: 0x4000, 0x17d9: 0x4000, 0x17da: 0x4000, 0x17db: 0x4000, 0x17dc: 0x4000, 0x17dd: 0x4000, - 0x17de: 0x4000, - // Block 0x60, offset 0x1800 - 0x1800: 0x4000, 0x1801: 0x4000, 0x1802: 0x4000, 0x1803: 0x4000, 0x1804: 0x4000, 0x1805: 0x4000, - 0x1806: 0x4000, 0x1807: 0x4000, 0x1808: 0x4000, 0x1809: 0x4000, 0x180a: 0x4000, 0x180b: 0x4000, - 0x180c: 0x4000, 0x180d: 0x4000, 0x180e: 0x4000, 0x180f: 0x4000, 0x1810: 0x4000, 0x1811: 0x4000, - // Block 0x61, offset 0x1840 - 0x1840: 0x4000, - // Block 0x62, offset 0x1880 - 0x1880: 0x2000, 0x1881: 0x2000, 0x1882: 0x2000, 0x1883: 0x2000, 0x1884: 0x2000, 0x1885: 0x2000, - 0x1886: 0x2000, 0x1887: 0x2000, 0x1888: 0x2000, 0x1889: 0x2000, 0x188a: 0x2000, 0x188b: 0x2000, - 0x188c: 0x2000, 0x188d: 0x2000, 0x188e: 0x2000, 0x188f: 0x2000, 0x1890: 0x2000, 0x1891: 0x2000, - 0x1892: 0x2000, 0x1893: 0x2000, 0x1894: 0x2000, 0x1895: 0x2000, 0x1896: 0x2000, 0x1897: 0x2000, - 0x1898: 0x2000, 0x1899: 0x2000, 0x189a: 0x2000, 0x189b: 0x2000, 0x189c: 0x2000, 0x189d: 0x2000, - 0x189e: 0x2000, 0x189f: 0x2000, 0x18a0: 0x2000, 0x18a1: 0x2000, 0x18a2: 0x2000, 0x18a3: 0x2000, - 0x18a4: 0x2000, 0x18a5: 0x2000, 0x18a6: 0x2000, 0x18a7: 0x2000, 0x18a8: 0x2000, 0x18a9: 0x2000, - 0x18aa: 0x2000, 0x18ab: 0x2000, 0x18ac: 0x2000, 0x18ad: 0x2000, 0x18ae: 0x2000, 0x18af: 0x2000, - 0x18b0: 0x2000, 0x18b1: 0x2000, 0x18b2: 0x2000, 0x18b3: 0x2000, 0x18b4: 0x2000, 0x18b5: 0x2000, - 0x18b6: 0x2000, 0x18b7: 0x2000, 0x18b8: 0x2000, 0x18b9: 0x2000, 0x18ba: 0x2000, 0x18bb: 0x2000, - 0x18bc: 0x2000, 0x18bd: 0x2000, -} - -// widthIndex: 22 blocks, 1408 entries, 1408 bytes -// Block 0 is the zero block. -var widthIndex = [1408]uint8{ - // Block 0x0, offset 0x0 - // Block 0x1, offset 0x40 - // Block 0x2, offset 0x80 - // Block 0x3, offset 0xc0 - 0xc2: 0x01, 0xc3: 0x02, 0xc4: 0x03, 0xc5: 0x04, 0xc7: 0x05, - 0xc9: 0x06, 0xcb: 0x07, 0xcc: 0x08, 0xcd: 0x09, 0xce: 0x0a, 0xcf: 0x0b, - 0xd0: 0x0c, 0xd1: 0x0d, - 0xe1: 0x02, 0xe2: 0x03, 0xe3: 0x04, 0xe4: 0x05, 0xe5: 0x06, 0xe6: 0x06, 0xe7: 0x06, - 0xe8: 0x06, 0xe9: 0x06, 0xea: 0x07, 0xeb: 0x06, 0xec: 0x06, 0xed: 0x08, 0xee: 0x09, 0xef: 0x0a, - 0xf0: 0x0f, 0xf3: 0x12, 0xf4: 0x13, - // Block 0x4, offset 0x100 - 0x104: 0x0e, 0x105: 0x0f, - // Block 0x5, offset 0x140 - 0x140: 0x10, 0x141: 0x11, 0x142: 0x12, 0x144: 0x13, 0x145: 0x14, 0x146: 0x15, 0x147: 0x16, - 0x148: 0x17, 0x149: 0x18, 0x14a: 0x19, 0x14c: 0x1a, 0x14f: 0x1b, - 0x151: 0x1c, 0x152: 0x08, 0x153: 0x1d, 0x154: 0x1e, 0x155: 0x1f, 0x156: 0x20, 0x157: 0x21, - 0x158: 0x22, 0x159: 0x23, 0x15a: 0x24, 0x15b: 0x25, 0x15c: 0x26, 0x15d: 0x27, 0x15e: 0x28, 0x15f: 0x29, - 0x166: 0x2a, - 0x16c: 0x2b, 0x16d: 0x2c, - 0x17a: 0x2d, 0x17b: 0x2e, 0x17c: 0x0e, 0x17d: 0x0e, 0x17e: 0x0e, 0x17f: 0x2f, - // Block 0x6, offset 0x180 - 0x180: 0x30, 0x181: 0x31, 0x182: 0x32, 0x183: 0x33, 0x184: 0x34, 0x185: 0x35, 0x186: 0x36, 0x187: 0x37, - 0x188: 0x38, 0x189: 0x39, 0x18a: 0x0e, 0x18b: 0x3a, 0x18c: 0x0e, 0x18d: 0x0e, 0x18e: 0x0e, 0x18f: 0x0e, - 0x190: 0x0e, 0x191: 0x0e, 0x192: 0x0e, 0x193: 0x0e, 0x194: 0x0e, 0x195: 0x0e, 0x196: 0x0e, 0x197: 0x0e, - 0x198: 0x0e, 0x199: 0x0e, 0x19a: 0x0e, 0x19b: 0x0e, 0x19c: 0x0e, 0x19d: 0x0e, 0x19e: 0x0e, 0x19f: 0x0e, - 0x1a0: 0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e, 0x1ee: 0x0e, 0x1ef: 0x0e, - 0x1f0: 0x0e, 0x1f1: 0x0e, 0x1f2: 0x0e, 0x1f3: 0x0e, 0x1f4: 0x0e, 0x1f5: 0x0e, 0x1f6: 0x0e, - 0x1f8: 0x0e, 0x1f9: 0x0e, 0x1fa: 0x0e, 0x1fb: 0x0e, 0x1fc: 0x0e, 0x1fd: 0x0e, 0x1fe: 0x0e, 0x1ff: 0x0e, - // Block 0x8, offset 0x200 - 0x200: 0x0e, 0x201: 0x0e, 0x202: 0x0e, 0x203: 0x0e, 0x204: 0x0e, 0x205: 0x0e, 0x206: 0x0e, 0x207: 0x0e, - 0x208: 0x0e, 0x209: 0x0e, 0x20a: 0x0e, 0x20b: 0x0e, 0x20c: 0x0e, 0x20d: 0x0e, 0x20e: 0x0e, 0x20f: 0x0e, - 0x210: 0x0e, 0x211: 0x0e, 0x212: 0x0e, 0x213: 0x0e, 0x214: 0x0e, 0x215: 0x0e, 0x216: 0x0e, 0x217: 0x0e, - 0x218: 0x0e, 0x219: 0x0e, 0x21a: 0x0e, 0x21b: 0x0e, 0x21c: 0x0e, 0x21d: 0x0e, 0x21e: 0x0e, 0x21f: 0x0e, - 0x220: 0x0e, 0x221: 0x0e, 0x222: 0x0e, 0x223: 0x0e, 0x224: 0x0e, 0x225: 0x0e, 0x226: 0x0e, 0x227: 0x0e, - 0x228: 0x0e, 0x229: 0x0e, 0x22a: 0x0e, 0x22b: 0x0e, 0x22c: 0x0e, 0x22d: 0x0e, 0x22e: 0x0e, 0x22f: 0x0e, - 0x230: 0x0e, 0x231: 0x0e, 0x232: 0x0e, 0x233: 0x0e, 0x234: 0x0e, 0x235: 0x0e, 0x236: 0x0e, 0x237: 0x0e, - 0x238: 0x0e, 0x239: 0x0e, 0x23a: 0x0e, 0x23b: 0x0e, 0x23c: 0x0e, 0x23d: 0x0e, 0x23e: 0x0e, 0x23f: 0x0e, - // Block 0x9, offset 0x240 - 0x240: 0x0e, 0x241: 0x0e, 0x242: 0x0e, 0x243: 0x0e, 0x244: 0x0e, 0x245: 0x0e, 0x246: 0x0e, 0x247: 0x0e, - 0x248: 0x0e, 0x249: 0x0e, 0x24a: 0x0e, 0x24b: 0x0e, 0x24c: 0x0e, 0x24d: 0x0e, 0x24e: 0x0e, 0x24f: 0x0e, - 0x250: 0x0e, 0x251: 0x0e, 0x252: 0x3b, 0x253: 0x3c, - 0x265: 0x3d, - 0x270: 0x0e, 0x271: 0x0e, 0x272: 0x0e, 0x273: 0x0e, 0x274: 0x0e, 0x275: 0x0e, 0x276: 0x0e, 0x277: 0x0e, - 0x278: 0x0e, 0x279: 0x0e, 0x27a: 0x0e, 0x27b: 0x0e, 0x27c: 0x0e, 0x27d: 0x0e, 0x27e: 0x0e, 0x27f: 0x0e, - // Block 0xa, offset 0x280 - 0x280: 0x0e, 0x281: 0x0e, 0x282: 0x0e, 0x283: 0x0e, 0x284: 0x0e, 0x285: 0x0e, 0x286: 0x0e, 0x287: 0x0e, - 0x288: 0x0e, 0x289: 0x0e, 0x28a: 0x0e, 0x28b: 0x0e, 0x28c: 0x0e, 0x28d: 0x0e, 0x28e: 0x0e, 0x28f: 0x0e, - 0x290: 0x0e, 0x291: 0x0e, 0x292: 0x0e, 0x293: 0x0e, 0x294: 0x0e, 0x295: 0x0e, 0x296: 0x0e, 0x297: 0x0e, - 0x298: 0x0e, 0x299: 0x0e, 0x29a: 0x0e, 0x29b: 0x0e, 0x29c: 0x0e, 0x29d: 0x0e, 0x29e: 0x3e, - // Block 0xb, offset 0x2c0 - 0x2c0: 0x08, 0x2c1: 0x08, 0x2c2: 0x08, 0x2c3: 0x08, 0x2c4: 0x08, 0x2c5: 0x08, 0x2c6: 0x08, 0x2c7: 0x08, - 0x2c8: 0x08, 0x2c9: 0x08, 0x2ca: 0x08, 0x2cb: 0x08, 0x2cc: 0x08, 0x2cd: 0x08, 0x2ce: 0x08, 0x2cf: 0x08, - 0x2d0: 0x08, 0x2d1: 0x08, 0x2d2: 0x08, 0x2d3: 0x08, 0x2d4: 0x08, 0x2d5: 0x08, 0x2d6: 0x08, 0x2d7: 0x08, - 0x2d8: 0x08, 0x2d9: 0x08, 0x2da: 0x08, 0x2db: 0x08, 0x2dc: 0x08, 0x2dd: 0x08, 0x2de: 0x08, 0x2df: 0x08, - 0x2e0: 0x08, 0x2e1: 0x08, 0x2e2: 0x08, 0x2e3: 0x08, 0x2e4: 0x08, 0x2e5: 0x08, 0x2e6: 0x08, 0x2e7: 0x08, - 0x2e8: 0x08, 0x2e9: 0x08, 0x2ea: 0x08, 0x2eb: 0x08, 0x2ec: 0x08, 0x2ed: 0x08, 0x2ee: 0x08, 0x2ef: 0x08, - 0x2f0: 0x08, 0x2f1: 0x08, 0x2f2: 0x08, 0x2f3: 0x08, 0x2f4: 0x08, 0x2f5: 0x08, 0x2f6: 0x08, 0x2f7: 0x08, - 0x2f8: 0x08, 0x2f9: 0x08, 0x2fa: 0x08, 0x2fb: 0x08, 0x2fc: 0x08, 0x2fd: 0x08, 0x2fe: 0x08, 0x2ff: 0x08, - // Block 0xc, offset 0x300 - 0x300: 0x08, 0x301: 0x08, 0x302: 0x08, 0x303: 0x08, 0x304: 0x08, 0x305: 0x08, 0x306: 0x08, 0x307: 0x08, - 0x308: 0x08, 0x309: 0x08, 0x30a: 0x08, 0x30b: 0x08, 0x30c: 0x08, 0x30d: 0x08, 0x30e: 0x08, 0x30f: 0x08, - 0x310: 0x08, 0x311: 0x08, 0x312: 0x08, 0x313: 0x08, 0x314: 0x08, 0x315: 0x08, 0x316: 0x08, 0x317: 0x08, - 0x318: 0x08, 0x319: 0x08, 0x31a: 0x08, 0x31b: 0x08, 0x31c: 0x08, 0x31d: 0x08, 0x31e: 0x08, 0x31f: 0x08, - 0x320: 0x08, 0x321: 0x08, 0x322: 0x08, 0x323: 0x08, 0x324: 0x0e, 0x325: 0x0e, 0x326: 0x0e, 0x327: 0x0e, - 0x328: 0x0e, 0x329: 0x0e, 0x32a: 0x0e, 0x32b: 0x0e, - 0x338: 0x3f, 0x339: 0x40, 0x33c: 0x41, 0x33d: 0x42, 0x33e: 0x43, 0x33f: 0x44, - // Block 0xd, offset 0x340 - 0x37f: 0x45, - // Block 0xe, offset 0x380 - 0x380: 0x0e, 0x381: 0x0e, 0x382: 0x0e, 0x383: 0x0e, 0x384: 0x0e, 0x385: 0x0e, 0x386: 0x0e, 0x387: 0x0e, - 0x388: 0x0e, 0x389: 0x0e, 0x38a: 0x0e, 0x38b: 0x0e, 0x38c: 0x0e, 0x38d: 0x0e, 0x38e: 0x0e, 0x38f: 0x0e, - 0x390: 0x0e, 0x391: 0x0e, 0x392: 0x0e, 0x393: 0x0e, 0x394: 0x0e, 0x395: 0x0e, 0x396: 0x0e, 0x397: 0x0e, - 0x398: 0x0e, 0x399: 0x0e, 0x39a: 0x0e, 0x39b: 0x0e, 0x39c: 0x0e, 0x39d: 0x0e, 0x39e: 0x0e, 0x39f: 0x46, - 0x3a0: 0x0e, 0x3a1: 0x0e, 0x3a2: 0x0e, 0x3a3: 0x0e, 0x3a4: 0x0e, 0x3a5: 0x0e, 0x3a6: 0x0e, 0x3a7: 0x0e, - 0x3a8: 0x0e, 0x3a9: 0x0e, 0x3aa: 0x0e, 0x3ab: 0x47, - // Block 0xf, offset 0x3c0 - 0x3c0: 0x48, - // Block 0x10, offset 0x400 - 0x400: 0x49, 0x403: 0x4a, 0x404: 0x4b, 0x405: 0x4c, 0x406: 0x4d, - 0x408: 0x4e, 0x409: 0x4f, 0x40c: 0x50, 0x40d: 0x51, 0x40e: 0x52, 0x40f: 0x53, - 0x410: 0x3a, 0x411: 0x54, 0x412: 0x0e, 0x413: 0x55, 0x414: 0x56, 0x415: 0x57, 0x416: 0x58, 0x417: 0x59, - 0x418: 0x0e, 0x419: 0x5a, 0x41a: 0x0e, 0x41b: 0x5b, - 0x424: 0x5c, 0x425: 0x5d, 0x426: 0x5e, 0x427: 0x5f, - // Block 0x11, offset 0x440 - 0x456: 0x0b, 0x457: 0x06, - 0x458: 0x0c, 0x45b: 0x0d, 0x45f: 0x0e, - 0x460: 0x06, 0x461: 0x06, 0x462: 0x06, 0x463: 0x06, 0x464: 0x06, 0x465: 0x06, 0x466: 0x06, 0x467: 0x06, - 0x468: 0x06, 0x469: 0x06, 0x46a: 0x06, 0x46b: 0x06, 0x46c: 0x06, 0x46d: 0x06, 0x46e: 0x06, 0x46f: 0x06, - 0x470: 0x06, 0x471: 0x06, 0x472: 0x06, 0x473: 0x06, 0x474: 0x06, 0x475: 0x06, 0x476: 0x06, 0x477: 0x06, - 0x478: 0x06, 0x479: 0x06, 0x47a: 0x06, 0x47b: 0x06, 0x47c: 0x06, 0x47d: 0x06, 0x47e: 0x06, 0x47f: 0x06, - // Block 0x12, offset 0x480 - 0x484: 0x08, 0x485: 0x08, 0x486: 0x08, 0x487: 0x09, - // Block 0x13, offset 0x4c0 - 0x4c0: 0x08, 0x4c1: 0x08, 0x4c2: 0x08, 0x4c3: 0x08, 0x4c4: 0x08, 0x4c5: 0x08, 0x4c6: 0x08, 0x4c7: 0x08, - 0x4c8: 0x08, 0x4c9: 0x08, 0x4ca: 0x08, 0x4cb: 0x08, 0x4cc: 0x08, 0x4cd: 0x08, 0x4ce: 0x08, 0x4cf: 0x08, - 0x4d0: 0x08, 0x4d1: 0x08, 0x4d2: 0x08, 0x4d3: 0x08, 0x4d4: 0x08, 0x4d5: 0x08, 0x4d6: 0x08, 0x4d7: 0x08, - 0x4d8: 0x08, 0x4d9: 0x08, 0x4da: 0x08, 0x4db: 0x08, 0x4dc: 0x08, 0x4dd: 0x08, 0x4de: 0x08, 0x4df: 0x08, - 0x4e0: 0x08, 0x4e1: 0x08, 0x4e2: 0x08, 0x4e3: 0x08, 0x4e4: 0x08, 0x4e5: 0x08, 0x4e6: 0x08, 0x4e7: 0x08, - 0x4e8: 0x08, 0x4e9: 0x08, 0x4ea: 0x08, 0x4eb: 0x08, 0x4ec: 0x08, 0x4ed: 0x08, 0x4ee: 0x08, 0x4ef: 0x08, - 0x4f0: 0x08, 0x4f1: 0x08, 0x4f2: 0x08, 0x4f3: 0x08, 0x4f4: 0x08, 0x4f5: 0x08, 0x4f6: 0x08, 0x4f7: 0x08, - 0x4f8: 0x08, 0x4f9: 0x08, 0x4fa: 0x08, 0x4fb: 0x08, 0x4fc: 0x08, 0x4fd: 0x08, 0x4fe: 0x08, 0x4ff: 0x60, - // Block 0x14, offset 0x500 - 0x520: 0x10, - 0x530: 0x09, 0x531: 0x09, 0x532: 0x09, 0x533: 0x09, 0x534: 0x09, 0x535: 0x09, 0x536: 0x09, 0x537: 0x09, - 0x538: 0x09, 0x539: 0x09, 0x53a: 0x09, 0x53b: 0x09, 0x53c: 0x09, 0x53d: 0x09, 0x53e: 0x09, 0x53f: 0x11, - // Block 0x15, offset 0x540 - 0x540: 0x09, 0x541: 0x09, 0x542: 0x09, 0x543: 0x09, 0x544: 0x09, 0x545: 0x09, 0x546: 0x09, 0x547: 0x09, - 0x548: 0x09, 0x549: 0x09, 0x54a: 0x09, 0x54b: 0x09, 0x54c: 0x09, 0x54d: 0x09, 0x54e: 0x09, 0x54f: 0x11, -} - -// inverseData contains 4-byte entries of the following format: -// <0 padding> -// The last byte of the UTF-8-encoded rune is xor-ed with the last byte of the -// UTF-8 encoding of the original rune. Mappings often have the following -// pattern: -// A -> A (U+FF21 -> U+0041) -// ï¼¢ -> B (U+FF22 -> U+0042) -// ... -// By xor-ing the last byte the same entry can be shared by many mappings. This -// reduces the total number of distinct entries by about two thirds. -// The resulting entry for the aforementioned mappings is -// { 0x01, 0xE0, 0x00, 0x00 } -// Using this entry to map U+FF21 (UTF-8 [EF BC A1]), we get -// E0 ^ A1 = 41. -// Similarly, for U+FF22 (UTF-8 [EF BC A2]), we get -// E0 ^ A2 = 42. -// Note that because of the xor-ing, the byte sequence stored in the entry is -// not valid UTF-8. -var inverseData = [150][4]byte{ - {0x00, 0x00, 0x00, 0x00}, - {0x03, 0xe3, 0x80, 0xa0}, - {0x03, 0xef, 0xbc, 0xa0}, - {0x03, 0xef, 0xbc, 0xe0}, - {0x03, 0xef, 0xbd, 0xe0}, - {0x03, 0xef, 0xbf, 0x02}, - {0x03, 0xef, 0xbf, 0x00}, - {0x03, 0xef, 0xbf, 0x0e}, - {0x03, 0xef, 0xbf, 0x0c}, - {0x03, 0xef, 0xbf, 0x0f}, - {0x03, 0xef, 0xbf, 0x39}, - {0x03, 0xef, 0xbf, 0x3b}, - {0x03, 0xef, 0xbf, 0x3f}, - {0x03, 0xef, 0xbf, 0x2a}, - {0x03, 0xef, 0xbf, 0x0d}, - {0x03, 0xef, 0xbf, 0x25}, - {0x03, 0xef, 0xbd, 0x1a}, - {0x03, 0xef, 0xbd, 0x26}, - {0x01, 0xa0, 0x00, 0x00}, - {0x03, 0xef, 0xbd, 0x25}, - {0x03, 0xef, 0xbd, 0x23}, - {0x03, 0xef, 0xbd, 0x2e}, - {0x03, 0xef, 0xbe, 0x07}, - {0x03, 0xef, 0xbe, 0x05}, - {0x03, 0xef, 0xbd, 0x06}, - {0x03, 0xef, 0xbd, 0x13}, - {0x03, 0xef, 0xbd, 0x0b}, - {0x03, 0xef, 0xbd, 0x16}, - {0x03, 0xef, 0xbd, 0x0c}, - {0x03, 0xef, 0xbd, 0x15}, - {0x03, 0xef, 0xbd, 0x0d}, - {0x03, 0xef, 0xbd, 0x1c}, - {0x03, 0xef, 0xbd, 0x02}, - {0x03, 0xef, 0xbd, 0x1f}, - {0x03, 0xef, 0xbd, 0x1d}, - {0x03, 0xef, 0xbd, 0x17}, - {0x03, 0xef, 0xbd, 0x08}, - {0x03, 0xef, 0xbd, 0x09}, - {0x03, 0xef, 0xbd, 0x0e}, - {0x03, 0xef, 0xbd, 0x04}, - {0x03, 0xef, 0xbd, 0x05}, - {0x03, 0xef, 0xbe, 0x3f}, - {0x03, 0xef, 0xbe, 0x00}, - {0x03, 0xef, 0xbd, 0x2c}, - {0x03, 0xef, 0xbe, 0x06}, - {0x03, 0xef, 0xbe, 0x0c}, - {0x03, 0xef, 0xbe, 0x0f}, - {0x03, 0xef, 0xbe, 0x0d}, - {0x03, 0xef, 0xbe, 0x0b}, - {0x03, 0xef, 0xbe, 0x19}, - {0x03, 0xef, 0xbe, 0x15}, - {0x03, 0xef, 0xbe, 0x11}, - {0x03, 0xef, 0xbe, 0x31}, - {0x03, 0xef, 0xbe, 0x33}, - {0x03, 0xef, 0xbd, 0x0f}, - {0x03, 0xef, 0xbe, 0x30}, - {0x03, 0xef, 0xbe, 0x3e}, - {0x03, 0xef, 0xbe, 0x32}, - {0x03, 0xef, 0xbe, 0x36}, - {0x03, 0xef, 0xbd, 0x14}, - {0x03, 0xef, 0xbe, 0x2e}, - {0x03, 0xef, 0xbd, 0x1e}, - {0x03, 0xef, 0xbe, 0x10}, - {0x03, 0xef, 0xbf, 0x13}, - {0x03, 0xef, 0xbf, 0x15}, - {0x03, 0xef, 0xbf, 0x17}, - {0x03, 0xef, 0xbf, 0x1f}, - {0x03, 0xef, 0xbf, 0x1d}, - {0x03, 0xef, 0xbf, 0x1b}, - {0x03, 0xef, 0xbf, 0x09}, - {0x03, 0xef, 0xbf, 0x0b}, - {0x03, 0xef, 0xbf, 0x37}, - {0x03, 0xef, 0xbe, 0x04}, - {0x01, 0xe0, 0x00, 0x00}, - {0x03, 0xe2, 0xa6, 0x1a}, - {0x03, 0xe2, 0xa6, 0x26}, - {0x03, 0xe3, 0x80, 0x23}, - {0x03, 0xe3, 0x80, 0x2e}, - {0x03, 0xe3, 0x80, 0x25}, - {0x03, 0xe3, 0x83, 0x1e}, - {0x03, 0xe3, 0x83, 0x14}, - {0x03, 0xe3, 0x82, 0x06}, - {0x03, 0xe3, 0x82, 0x0b}, - {0x03, 0xe3, 0x82, 0x0c}, - {0x03, 0xe3, 0x82, 0x0d}, - {0x03, 0xe3, 0x82, 0x02}, - {0x03, 0xe3, 0x83, 0x0f}, - {0x03, 0xe3, 0x83, 0x08}, - {0x03, 0xe3, 0x83, 0x09}, - {0x03, 0xe3, 0x83, 0x2c}, - {0x03, 0xe3, 0x83, 0x0c}, - {0x03, 0xe3, 0x82, 0x13}, - {0x03, 0xe3, 0x82, 0x16}, - {0x03, 0xe3, 0x82, 0x15}, - {0x03, 0xe3, 0x82, 0x1c}, - {0x03, 0xe3, 0x82, 0x1f}, - {0x03, 0xe3, 0x82, 0x1d}, - {0x03, 0xe3, 0x82, 0x1a}, - {0x03, 0xe3, 0x82, 0x17}, - {0x03, 0xe3, 0x82, 0x08}, - {0x03, 0xe3, 0x82, 0x09}, - {0x03, 0xe3, 0x82, 0x0e}, - {0x03, 0xe3, 0x82, 0x04}, - {0x03, 0xe3, 0x82, 0x05}, - {0x03, 0xe3, 0x82, 0x3f}, - {0x03, 0xe3, 0x83, 0x00}, - {0x03, 0xe3, 0x83, 0x06}, - {0x03, 0xe3, 0x83, 0x05}, - {0x03, 0xe3, 0x83, 0x0d}, - {0x03, 0xe3, 0x83, 0x0b}, - {0x03, 0xe3, 0x83, 0x07}, - {0x03, 0xe3, 0x83, 0x19}, - {0x03, 0xe3, 0x83, 0x15}, - {0x03, 0xe3, 0x83, 0x11}, - {0x03, 0xe3, 0x83, 0x31}, - {0x03, 0xe3, 0x83, 0x33}, - {0x03, 0xe3, 0x83, 0x30}, - {0x03, 0xe3, 0x83, 0x3e}, - {0x03, 0xe3, 0x83, 0x32}, - {0x03, 0xe3, 0x83, 0x36}, - {0x03, 0xe3, 0x83, 0x2e}, - {0x03, 0xe3, 0x82, 0x07}, - {0x03, 0xe3, 0x85, 0x04}, - {0x03, 0xe3, 0x84, 0x10}, - {0x03, 0xe3, 0x85, 0x30}, - {0x03, 0xe3, 0x85, 0x0d}, - {0x03, 0xe3, 0x85, 0x13}, - {0x03, 0xe3, 0x85, 0x15}, - {0x03, 0xe3, 0x85, 0x17}, - {0x03, 0xe3, 0x85, 0x1f}, - {0x03, 0xe3, 0x85, 0x1d}, - {0x03, 0xe3, 0x85, 0x1b}, - {0x03, 0xe3, 0x85, 0x09}, - {0x03, 0xe3, 0x85, 0x0f}, - {0x03, 0xe3, 0x85, 0x0b}, - {0x03, 0xe3, 0x85, 0x37}, - {0x03, 0xe3, 0x85, 0x3b}, - {0x03, 0xe3, 0x85, 0x39}, - {0x03, 0xe3, 0x85, 0x3f}, - {0x02, 0xc2, 0x02, 0x00}, - {0x02, 0xc2, 0x0e, 0x00}, - {0x02, 0xc2, 0x0c, 0x00}, - {0x02, 0xc2, 0x00, 0x00}, - {0x03, 0xe2, 0x82, 0x0f}, - {0x03, 0xe2, 0x94, 0x2a}, - {0x03, 0xe2, 0x86, 0x39}, - {0x03, 0xe2, 0x86, 0x3b}, - {0x03, 0xe2, 0x86, 0x3f}, - {0x03, 0xe2, 0x96, 0x0d}, - {0x03, 0xe2, 0x97, 0x25}, -} - -// Total table size 14680 bytes (14KiB) diff --git a/libgo/go/golang_org/x/text/width/transform.go b/libgo/go/golang_org/x/text/width/transform.go deleted file mode 100644 index 04f1a3fc590..00000000000 --- a/libgo/go/golang_org/x/text/width/transform.go +++ /dev/null @@ -1,239 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package width - -import ( - "unicode/utf8" - - "golang_org/x/text/transform" -) - -type foldTransform struct { - transform.NopResetter -} - -func (foldTransform) Span(src []byte, atEOF bool) (n int, err error) { - for n < len(src) { - if src[n] < utf8.RuneSelf { - // ASCII fast path. - for n++; n < len(src) && src[n] < utf8.RuneSelf; n++ { - } - continue - } - v, size := trie.lookup(src[n:]) - if size == 0 { // incomplete UTF-8 encoding - if !atEOF { - err = transform.ErrShortSrc - } else { - n = len(src) - } - break - } - if elem(v)&tagNeedsFold != 0 { - err = transform.ErrEndOfSpan - break - } - n += size - } - return n, err -} - -func (foldTransform) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) { - for nSrc < len(src) { - if src[nSrc] < utf8.RuneSelf { - // ASCII fast path. - start, end := nSrc, len(src) - if d := len(dst) - nDst; d < end-start { - end = nSrc + d - } - for nSrc++; nSrc < end && src[nSrc] < utf8.RuneSelf; nSrc++ { - } - n := copy(dst[nDst:], src[start:nSrc]) - if nDst += n; nDst == len(dst) { - nSrc = start + n - if nSrc == len(src) { - return nDst, nSrc, nil - } - if src[nSrc] < utf8.RuneSelf { - return nDst, nSrc, transform.ErrShortDst - } - } - continue - } - v, size := trie.lookup(src[nSrc:]) - if size == 0 { // incomplete UTF-8 encoding - if !atEOF { - return nDst, nSrc, transform.ErrShortSrc - } - size = 1 // gobble 1 byte - } - if elem(v)&tagNeedsFold == 0 { - if size != copy(dst[nDst:], src[nSrc:nSrc+size]) { - return nDst, nSrc, transform.ErrShortDst - } - nDst += size - } else { - data := inverseData[byte(v)] - if len(dst)-nDst < int(data[0]) { - return nDst, nSrc, transform.ErrShortDst - } - i := 1 - for end := int(data[0]); i < end; i++ { - dst[nDst] = data[i] - nDst++ - } - dst[nDst] = data[i] ^ src[nSrc+size-1] - nDst++ - } - nSrc += size - } - return nDst, nSrc, nil -} - -type narrowTransform struct { - transform.NopResetter -} - -func (narrowTransform) Span(src []byte, atEOF bool) (n int, err error) { - for n < len(src) { - if src[n] < utf8.RuneSelf { - // ASCII fast path. - for n++; n < len(src) && src[n] < utf8.RuneSelf; n++ { - } - continue - } - v, size := trie.lookup(src[n:]) - if size == 0 { // incomplete UTF-8 encoding - if !atEOF { - err = transform.ErrShortSrc - } else { - n = len(src) - } - break - } - if k := elem(v).kind(); byte(v) == 0 || k != EastAsianFullwidth && k != EastAsianWide && k != EastAsianAmbiguous { - } else { - err = transform.ErrEndOfSpan - break - } - n += size - } - return n, err -} - -func (narrowTransform) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) { - for nSrc < len(src) { - if src[nSrc] < utf8.RuneSelf { - // ASCII fast path. - start, end := nSrc, len(src) - if d := len(dst) - nDst; d < end-start { - end = nSrc + d - } - for nSrc++; nSrc < end && src[nSrc] < utf8.RuneSelf; nSrc++ { - } - n := copy(dst[nDst:], src[start:nSrc]) - if nDst += n; nDst == len(dst) { - nSrc = start + n - if nSrc == len(src) { - return nDst, nSrc, nil - } - if src[nSrc] < utf8.RuneSelf { - return nDst, nSrc, transform.ErrShortDst - } - } - continue - } - v, size := trie.lookup(src[nSrc:]) - if size == 0 { // incomplete UTF-8 encoding - if !atEOF { - return nDst, nSrc, transform.ErrShortSrc - } - size = 1 // gobble 1 byte - } - if k := elem(v).kind(); byte(v) == 0 || k != EastAsianFullwidth && k != EastAsianWide && k != EastAsianAmbiguous { - if size != copy(dst[nDst:], src[nSrc:nSrc+size]) { - return nDst, nSrc, transform.ErrShortDst - } - nDst += size - } else { - data := inverseData[byte(v)] - if len(dst)-nDst < int(data[0]) { - return nDst, nSrc, transform.ErrShortDst - } - i := 1 - for end := int(data[0]); i < end; i++ { - dst[nDst] = data[i] - nDst++ - } - dst[nDst] = data[i] ^ src[nSrc+size-1] - nDst++ - } - nSrc += size - } - return nDst, nSrc, nil -} - -type wideTransform struct { - transform.NopResetter -} - -func (wideTransform) Span(src []byte, atEOF bool) (n int, err error) { - for n < len(src) { - // TODO: Consider ASCII fast path. Special-casing ASCII handling can - // reduce the ns/op of BenchmarkWideASCII by about 30%. This is probably - // not enough to warrant the extra code and complexity. - v, size := trie.lookup(src[n:]) - if size == 0 { // incomplete UTF-8 encoding - if !atEOF { - err = transform.ErrShortSrc - } else { - n = len(src) - } - break - } - if k := elem(v).kind(); byte(v) == 0 || k != EastAsianHalfwidth && k != EastAsianNarrow { - } else { - err = transform.ErrEndOfSpan - break - } - n += size - } - return n, err -} - -func (wideTransform) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) { - for nSrc < len(src) { - // TODO: Consider ASCII fast path. Special-casing ASCII handling can - // reduce the ns/op of BenchmarkWideASCII by about 30%. This is probably - // not enough to warrant the extra code and complexity. - v, size := trie.lookup(src[nSrc:]) - if size == 0 { // incomplete UTF-8 encoding - if !atEOF { - return nDst, nSrc, transform.ErrShortSrc - } - size = 1 // gobble 1 byte - } - if k := elem(v).kind(); byte(v) == 0 || k != EastAsianHalfwidth && k != EastAsianNarrow { - if size != copy(dst[nDst:], src[nSrc:nSrc+size]) { - return nDst, nSrc, transform.ErrShortDst - } - nDst += size - } else { - data := inverseData[byte(v)] - if len(dst)-nDst < int(data[0]) { - return nDst, nSrc, transform.ErrShortDst - } - i := 1 - for end := int(data[0]); i < end; i++ { - dst[nDst] = data[i] - nDst++ - } - dst[nDst] = data[i] ^ src[nSrc+size-1] - nDst++ - } - nSrc += size - } - return nDst, nSrc, nil -} diff --git a/libgo/go/golang_org/x/text/width/trieval.go b/libgo/go/golang_org/x/text/width/trieval.go deleted file mode 100644 index 0ecffb4c64f..00000000000 --- a/libgo/go/golang_org/x/text/width/trieval.go +++ /dev/null @@ -1,30 +0,0 @@ -// This file was generated by go generate; DO NOT EDIT - -package width - -// elem is an entry of the width trie. The high byte is used to encode the type -// of the rune. The low byte is used to store the index to a mapping entry in -// the inverseData array. -type elem uint16 - -const ( - tagNeutral elem = iota << typeShift - tagAmbiguous - tagWide - tagNarrow - tagFullwidth - tagHalfwidth -) - -const ( - numTypeBits = 3 - typeShift = 16 - numTypeBits - - // tagNeedsFold is true for all fullwidth and halfwidth runes except for - // the Won sign U+20A9. - tagNeedsFold = 0x1000 - - // The Korean Won sign is halfwidth, but SHOULD NOT be mapped to a wide - // variant. - wonSign rune = 0x20A9 -) diff --git a/libgo/go/golang_org/x/text/width/width.go b/libgo/go/golang_org/x/text/width/width.go deleted file mode 100644 index 27f55b8db72..00000000000 --- a/libgo/go/golang_org/x/text/width/width.go +++ /dev/null @@ -1,206 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:generate stringer -type=Kind -//go:generate go run gen.go gen_common.go gen_trieval.go - -// Package width provides functionality for handling different widths in text. -// -// Wide characters behave like ideographs; they tend to allow line breaks after -// each character and remain upright in vertical text layout. Narrow characters -// are kept together in words or runs that are rotated sideways in vertical text -// layout. -// -// For more information, see http://unicode.org/reports/tr11/. -package width // import "golang_org/x/text/width" - -import ( - "unicode/utf8" - - "golang_org/x/text/transform" -) - -// TODO -// 1) Reduce table size by compressing blocks. -// 2) API proposition for computing display length -// (approximation, fixed pitch only). -// 3) Implement display length. - -// Kind indicates the type of width property as defined in http://unicode.org/reports/tr11/. -type Kind int - -const ( - // Neutral characters do not occur in legacy East Asian character sets. - Neutral Kind = iota - - // EastAsianAmbiguous characters that can be sometimes wide and sometimes - // narrow and require additional information not contained in the character - // code to further resolve their width. - EastAsianAmbiguous - - // EastAsianWide characters are wide in its usual form. They occur only in - // the context of East Asian typography. These runes may have explicit - // halfwidth counterparts. - EastAsianWide - - // EastAsianNarrow characters are narrow in its usual form. They often have - // fullwidth counterparts. - EastAsianNarrow - - // Note: there exist Narrow runes that do not have fullwidth or wide - // counterparts, despite what the definition says (e.g. U+27E6). - - // EastAsianFullwidth characters have a compatibility decompositions of type - // wide that map to a narrow counterpart. - EastAsianFullwidth - - // EastAsianHalfwidth characters have a compatibility decomposition of type - // narrow that map to a wide or ambiguous counterpart, plus U+20A9 ₩ WON - // SIGN. - EastAsianHalfwidth - - // Note: there exist runes that have a halfwidth counterparts but that are - // classified as Ambiguous, rather than wide (e.g. U+2190). -) - -// TODO: the generated tries need to return size 1 for invalid runes for the -// width to be computed correctly (each byte should render width 1) - -var trie = newWidthTrie(0) - -// Lookup reports the Properties of the first rune in b and the number of bytes -// of its UTF-8 encoding. -func Lookup(b []byte) (p Properties, size int) { - v, sz := trie.lookup(b) - return Properties{elem(v), b[sz-1]}, sz -} - -// LookupString reports the Properties of the first rune in s and the number of -// bytes of its UTF-8 encoding. -func LookupString(s string) (p Properties, size int) { - v, sz := trie.lookupString(s) - return Properties{elem(v), s[sz-1]}, sz -} - -// LookupRune reports the Properties of rune r. -func LookupRune(r rune) Properties { - var buf [4]byte - n := utf8.EncodeRune(buf[:], r) - v, _ := trie.lookup(buf[:n]) - last := byte(r) - if r >= utf8.RuneSelf { - last = 0x80 + byte(r&0x3f) - } - return Properties{elem(v), last} -} - -// Properties provides access to width properties of a rune. -type Properties struct { - elem elem - last byte -} - -func (e elem) kind() Kind { - return Kind(e >> typeShift) -} - -// Kind returns the Kind of a rune as defined in Unicode TR #11. -// See http://unicode.org/reports/tr11/ for more details. -func (p Properties) Kind() Kind { - return p.elem.kind() -} - -// Folded returns the folded variant of a rune or 0 if the rune is canonical. -func (p Properties) Folded() rune { - if p.elem&tagNeedsFold != 0 { - buf := inverseData[byte(p.elem)] - buf[buf[0]] ^= p.last - r, _ := utf8.DecodeRune(buf[1 : 1+buf[0]]) - return r - } - return 0 -} - -// Narrow returns the narrow variant of a rune or 0 if the rune is already -// narrow or doesn't have a narrow variant. -func (p Properties) Narrow() rune { - if k := p.elem.kind(); byte(p.elem) != 0 && (k == EastAsianFullwidth || k == EastAsianWide || k == EastAsianAmbiguous) { - buf := inverseData[byte(p.elem)] - buf[buf[0]] ^= p.last - r, _ := utf8.DecodeRune(buf[1 : 1+buf[0]]) - return r - } - return 0 -} - -// Wide returns the wide variant of a rune or 0 if the rune is already -// wide or doesn't have a wide variant. -func (p Properties) Wide() rune { - if k := p.elem.kind(); byte(p.elem) != 0 && (k == EastAsianHalfwidth || k == EastAsianNarrow) { - buf := inverseData[byte(p.elem)] - buf[buf[0]] ^= p.last - r, _ := utf8.DecodeRune(buf[1 : 1+buf[0]]) - return r - } - return 0 -} - -// TODO for Properties: -// - Add Fullwidth/Halfwidth or Inverted methods for computing variants -// mapping. -// - Add width information (including information on non-spacing runes). - -// Transformer implements the transform.Transformer interface. -type Transformer struct { - t transform.SpanningTransformer -} - -// Reset implements the transform.Transformer interface. -func (t Transformer) Reset() { t.t.Reset() } - -// Transform implements the transform.Transformer interface. -func (t Transformer) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) { - return t.t.Transform(dst, src, atEOF) -} - -// Span implements the transform.SpanningTransformer interface. -func (t Transformer) Span(src []byte, atEOF bool) (n int, err error) { - return t.t.Span(src, atEOF) -} - -// Bytes returns a new byte slice with the result of applying t to b. -func (t Transformer) Bytes(b []byte) []byte { - b, _, _ = transform.Bytes(t, b) - return b -} - -// String returns a string with the result of applying t to s. -func (t Transformer) String(s string) string { - s, _, _ = transform.String(t, s) - return s -} - -var ( - // Fold is a transform that maps all runes to their canonical width. - // - // Note that the NFKC and NFKD transforms in golang.org/x/text/unicode/norm - // provide a more generic folding mechanism. - Fold Transformer = Transformer{foldTransform{}} - - // Widen is a transform that maps runes to their wide variant, if - // available. - Widen Transformer = Transformer{wideTransform{}} - - // Narrow is a transform that maps runes to their narrow variant, if - // available. - Narrow Transformer = Transformer{narrowTransform{}} -) - -// TODO: Consider the following options: -// - Treat Ambiguous runes that have a halfwidth counterpart as wide, or some -// generalized variant of this. -// - Consider a wide Won character to be the default width (or some generalized -// variant of this). -// - Filter the set of characters that gets converted (the preferred approach is -// to allow applying filters to transforms). diff --git a/libgo/go/hash/crc32/crc32_arm64.go b/libgo/go/hash/crc32/crc32_arm64.go index 0d813b4f384..232cc3bd6c9 100644 --- a/libgo/go/hash/crc32/crc32_arm64.go +++ b/libgo/go/hash/crc32/crc32_arm64.go @@ -15,20 +15,18 @@ import "internal/cpu" func castagnoliUpdate(crc uint32, p []byte) uint32 func ieeeUpdate(crc uint32, p []byte) uint32 -var hasCRC32 = cpu.ARM64.HasCRC32 - func archAvailableCastagnoli() bool { - return hasCRC32 + return cpu.ARM64.HasCRC32 } func archInitCastagnoli() { - if !hasCRC32 { + if !cpu.ARM64.HasCRC32 { panic("arch-specific crc32 instruction for Catagnoli not available") } } func archUpdateCastagnoli(crc uint32, p []byte) uint32 { - if !hasCRC32 { + if !cpu.ARM64.HasCRC32 { panic("arch-specific crc32 instruction for Castagnoli not available") } @@ -36,17 +34,17 @@ func archUpdateCastagnoli(crc uint32, p []byte) uint32 { } func archAvailableIEEE() bool { - return hasCRC32 + return cpu.ARM64.HasCRC32 } func archInitIEEE() { - if !hasCRC32 { + if !cpu.ARM64.HasCRC32 { panic("arch-specific crc32 instruction for IEEE not available") } } func archUpdateIEEE(crc uint32, p []byte) uint32 { - if !hasCRC32 { + if !cpu.ARM64.HasCRC32 { panic("arch-specific crc32 instruction for IEEE not available") } diff --git a/libgo/go/hash/crc64/crc64.go b/libgo/go/hash/crc64/crc64.go index a799a017c93..063c63c6a3b 100644 --- a/libgo/go/hash/crc64/crc64.go +++ b/libgo/go/hash/crc64/crc64.go @@ -10,6 +10,7 @@ package crc64 import ( "errors" "hash" + "sync" ) // The size of a CRC-64 checksum in bytes. @@ -28,13 +29,24 @@ const ( type Table [256]uint64 var ( - slicing8TableISO = makeSlicingBy8Table(makeTable(ISO)) - slicing8TableECMA = makeSlicingBy8Table(makeTable(ECMA)) + slicing8TablesBuildOnce sync.Once + slicing8TableISO *[8]Table + slicing8TableECMA *[8]Table ) +func buildSlicing8TablesOnce() { + slicing8TablesBuildOnce.Do(buildSlicing8Tables) +} + +func buildSlicing8Tables() { + slicing8TableISO = makeSlicingBy8Table(makeTable(ISO)) + slicing8TableECMA = makeSlicingBy8Table(makeTable(ECMA)) +} + // MakeTable returns a Table constructed from the specified polynomial. // The contents of this Table must not be modified. func MakeTable(poly uint64) *Table { + buildSlicing8TablesOnce() switch poly { case ISO: return &slicing8TableISO[0] @@ -141,6 +153,7 @@ func readUint64(b []byte) uint64 { } func update(crc uint64, tab *Table, p []byte) uint64 { + buildSlicing8TablesOnce() crc = ^crc // Table comparison is somewhat expensive, so avoid it for small sizes for len(p) >= 64 { diff --git a/libgo/go/hash/crc64/crc64_test.go b/libgo/go/hash/crc64/crc64_test.go index 9db05b02fe9..9cf602c82f3 100644 --- a/libgo/go/hash/crc64/crc64_test.go +++ b/libgo/go/hash/crc64/crc64_test.go @@ -62,15 +62,13 @@ func TestGolden(t *testing.T) { io.WriteString(c, g.in) s := c.Sum64() if s != g.outISO { - t.Errorf("ISO crc64(%s) = 0x%x want 0x%x", g.in, s, g.outISO) - t.FailNow() + t.Fatalf("ISO crc64(%s) = 0x%x want 0x%x", g.in, s, g.outISO) } c = New(tabECMA) io.WriteString(c, g.in) s = c.Sum64() if s != g.outECMA { - t.Errorf("ECMA crc64(%s) = 0x%x want 0x%x", g.in, s, g.outECMA) - t.FailNow() + t.Fatalf("ECMA crc64(%s) = 0x%x want 0x%x", g.in, s, g.outECMA) } } } diff --git a/libgo/go/hash/fnv/fnv.go b/libgo/go/hash/fnv/fnv.go index 7662315d43c..0fce177cb33 100644 --- a/libgo/go/hash/fnv/fnv.go +++ b/libgo/go/hash/fnv/fnv.go @@ -15,6 +15,7 @@ package fnv import ( "errors" "hash" + "math/bits" ) type ( @@ -137,18 +138,12 @@ func (s *sum64a) Write(data []byte) (int, error) { func (s *sum128) Write(data []byte) (int, error) { for _, c := range data { - // Compute the multiplication in 4 parts to simplify carrying - s1l := (s[1] & 0xffffffff) * prime128Lower - s1h := (s[1] >> 32) * prime128Lower - s0l := (s[0]&0xffffffff)*prime128Lower + (s[1]&0xffffffff)<>32)*prime128Lower + (s[1]>>32)<> 32 - s0l += s1h >> 32 - s0h += s0l >> 32 + // Compute the multiplication + s0, s1 := bits.Mul64(prime128Lower, s[1]) + s0 += s[1]<> 32) * prime128Lower - s0l := (s[0]&0xffffffff)*prime128Lower + (s[1]&0xffffffff)<>32)*prime128Lower + (s[1]>>32)<> 32 - s0l += s1h >> 32 - s0h += s0l >> 32 + // Compute the multiplication + s0, s1 := bits.Mul64(prime128Lower, s[1]) + s0 += s[1]<>").Parse(text)) + + err := t.Execute(os.Stdout, data) + if err != nil { + log.Fatal(err) + } + + // Output: + // Hello {{.Name}} +} + // The following example is duplicated in text/template; keep them in sync. func ExampleTemplate_block() { diff --git a/libgo/go/html/template/js.go b/libgo/go/html/template/js.go index 33a18b41864..872f6786b35 100644 --- a/libgo/go/html/template/js.go +++ b/libgo/go/html/template/js.go @@ -172,7 +172,7 @@ func jsValEscaper(args ...interface{}) string { // turning into // x//* error marshaling y: // second line of error message */null - return fmt.Sprintf(" /* %s */null ", strings.Replace(err.Error(), "*/", "* /", -1)) + return fmt.Sprintf(" /* %s */null ", strings.ReplaceAll(err.Error(), "*/", "* /")) } // TODO: maybe post-process output to prevent it from containing @@ -371,7 +371,7 @@ func isJSIdentPart(r rune) bool { return false } -// isJSType returns true if the given MIME type should be considered JavaScript. +// isJSType reports whether the given MIME type should be considered JavaScript. // // It is used to determine whether a script tag with a type attribute is a javascript container. func isJSType(mimeType string) bool { @@ -391,6 +391,7 @@ func isJSType(mimeType string) bool { "application/ecmascript", "application/javascript", "application/json", + "application/ld+json", "application/x-ecmascript", "application/x-javascript", "text/ecmascript", diff --git a/libgo/go/html/template/js_test.go b/libgo/go/html/template/js_test.go index 12a850d6e3b..05fa105be02 100644 --- a/libgo/go/html/template/js_test.go +++ b/libgo/go/html/template/js_test.go @@ -343,6 +343,7 @@ func TestIsJsMimeType(t *testing.T) { {"application/javascript/version=1.8", false}, {"text/javascript", true}, {"application/json", true}, + {"application/ld+json", true}, } for _, test := range tests { diff --git a/libgo/go/html/template/url.go b/libgo/go/html/template/url.go index f0516300deb..6f8185a4e90 100644 --- a/libgo/go/html/template/url.go +++ b/libgo/go/html/template/url.go @@ -86,7 +86,7 @@ func urlProcessor(norm bool, args ...interface{}) string { } // processURLOnto appends a normalized URL corresponding to its input to b -// and returns true if the appended content differs from s. +// and reports whether the appended content differs from s. func processURLOnto(s string, norm bool, b *bytes.Buffer) bool { b.Grow(len(s) + 16) written := 0 @@ -156,7 +156,7 @@ func srcsetFilterAndEscaper(args ...interface{}) string { s = b.String() } // Additionally, commas separate one source from another. - return strings.Replace(s, ",", "%2c", -1) + return strings.ReplaceAll(s, ",", "%2c") } var b bytes.Buffer diff --git a/libgo/go/image/draw/draw.go b/libgo/go/image/draw/draw.go index 977d7c52215..3ff1828dc0c 100644 --- a/libgo/go/image/draw/draw.go +++ b/libgo/go/image/draw/draw.go @@ -309,23 +309,20 @@ func drawCopyOver(dst *image.RGBA, r image.Rectangle, src *image.RGBA, sp image. dpix := dst.Pix[d0:] spix := src.Pix[s0:] for i := i0; i != i1; i += idelta { - sr := uint32(spix[i+0]) * 0x101 - sg := uint32(spix[i+1]) * 0x101 - sb := uint32(spix[i+2]) * 0x101 - sa := uint32(spix[i+3]) * 0x101 - - dr := &dpix[i+0] - dg := &dpix[i+1] - db := &dpix[i+2] - da := &dpix[i+3] + s := spix[i : i+4 : i+4] // Small cap improves performance, see https://golang.org/issue/27857 + sr := uint32(s[0]) * 0x101 + sg := uint32(s[1]) * 0x101 + sb := uint32(s[2]) * 0x101 + sa := uint32(s[3]) * 0x101 // The 0x101 is here for the same reason as in drawRGBA. a := (m - sa) * 0x101 - *dr = uint8((uint32(*dr)*a/m + sr) >> 8) - *dg = uint8((uint32(*dg)*a/m + sg) >> 8) - *db = uint8((uint32(*db)*a/m + sb) >> 8) - *da = uint8((uint32(*da)*a/m + sa) >> 8) + d := dpix[i : i+4 : i+4] // Small cap improves performance, see https://golang.org/issue/27857 + d[0] = uint8((uint32(d[0])*a/m + sr) >> 8) + d[1] = uint8((uint32(d[1])*a/m + sg) >> 8) + d[2] = uint8((uint32(d[2])*a/m + sb) >> 8) + d[3] = uint8((uint32(d[3])*a/m + sa) >> 8) } d0 += ddelta s0 += sdelta @@ -372,23 +369,25 @@ func drawNRGBAOver(dst *image.RGBA, r image.Rectangle, src *image.NRGBA, sp imag for i, si := i0, si0; i < i1; i, si = i+4, si+4 { // Convert from non-premultiplied color to pre-multiplied color. - sa := uint32(spix[si+3]) * 0x101 - sr := uint32(spix[si+0]) * sa / 0xff - sg := uint32(spix[si+1]) * sa / 0xff - sb := uint32(spix[si+2]) * sa / 0xff - - dr := uint32(dpix[i+0]) - dg := uint32(dpix[i+1]) - db := uint32(dpix[i+2]) - da := uint32(dpix[i+3]) + s := spix[si : si+4 : si+4] // Small cap improves performance, see https://golang.org/issue/27857 + sa := uint32(s[3]) * 0x101 + sr := uint32(s[0]) * sa / 0xff + sg := uint32(s[1]) * sa / 0xff + sb := uint32(s[2]) * sa / 0xff + + d := dpix[i : i+4 : i+4] // Small cap improves performance, see https://golang.org/issue/27857 + dr := uint32(d[0]) + dg := uint32(d[1]) + db := uint32(d[2]) + da := uint32(d[3]) // The 0x101 is here for the same reason as in drawRGBA. a := (m - sa) * 0x101 - dpix[i+0] = uint8((dr*a/m + sr) >> 8) - dpix[i+1] = uint8((dg*a/m + sg) >> 8) - dpix[i+2] = uint8((db*a/m + sb) >> 8) - dpix[i+3] = uint8((da*a/m + sa) >> 8) + d[0] = uint8((dr*a/m + sr) >> 8) + d[1] = uint8((dg*a/m + sg) >> 8) + d[2] = uint8((db*a/m + sb) >> 8) + d[3] = uint8((da*a/m + sa) >> 8) } } } @@ -407,15 +406,17 @@ func drawNRGBASrc(dst *image.RGBA, r image.Rectangle, src *image.NRGBA, sp image for i, si := i0, si0; i < i1; i, si = i+4, si+4 { // Convert from non-premultiplied color to pre-multiplied color. - sa := uint32(spix[si+3]) * 0x101 - sr := uint32(spix[si+0]) * sa / 0xff - sg := uint32(spix[si+1]) * sa / 0xff - sb := uint32(spix[si+2]) * sa / 0xff - - dpix[i+0] = uint8(sr >> 8) - dpix[i+1] = uint8(sg >> 8) - dpix[i+2] = uint8(sb >> 8) - dpix[i+3] = uint8(sa >> 8) + s := spix[si : si+4 : si+4] // Small cap improves performance, see https://golang.org/issue/27857 + sa := uint32(s[3]) * 0x101 + sr := uint32(s[0]) * sa / 0xff + sg := uint32(s[1]) * sa / 0xff + sb := uint32(s[2]) * sa / 0xff + + d := dpix[i : i+4 : i+4] // Small cap improves performance, see https://golang.org/issue/27857 + d[0] = uint8(sr >> 8) + d[1] = uint8(sg >> 8) + d[2] = uint8(sb >> 8) + d[3] = uint8(sa >> 8) } } } @@ -434,10 +435,11 @@ func drawGray(dst *image.RGBA, r image.Rectangle, src *image.Gray, sp image.Poin for i, si := i0, si0; i < i1; i, si = i+4, si+1 { p := spix[si] - dpix[i+0] = p - dpix[i+1] = p - dpix[i+2] = p - dpix[i+3] = 255 + d := dpix[i : i+4 : i+4] // Small cap improves performance, see https://golang.org/issue/27857 + d[0] = p + d[1] = p + d[2] = p + d[3] = 255 } } } @@ -455,9 +457,10 @@ func drawCMYK(dst *image.RGBA, r image.Rectangle, src *image.CMYK, sp image.Poin spix := src.Pix[sy*src.Stride:] for i, si := i0, si0; i < i1; i, si = i+4, si+4 { - dpix[i+0], dpix[i+1], dpix[i+2] = - color.CMYKToRGB(spix[si+0], spix[si+1], spix[si+2], spix[si+3]) - dpix[i+3] = 255 + s := spix[si : si+4 : si+4] // Small cap improves performance, see https://golang.org/issue/27857 + d := dpix[i : i+4 : i+4] + d[0], d[1], d[2] = color.CMYKToRGB(s[0], s[1], s[2], s[3]) + d[3] = 255 } } } @@ -475,18 +478,14 @@ func drawGlyphOver(dst *image.RGBA, r image.Rectangle, src *image.Uniform, mask } ma |= ma << 8 - dr := &dst.Pix[i+0] - dg := &dst.Pix[i+1] - db := &dst.Pix[i+2] - da := &dst.Pix[i+3] - // The 0x101 is here for the same reason as in drawRGBA. a := (m - (sa * ma / m)) * 0x101 - *dr = uint8((uint32(*dr)*a + sr*ma) / m >> 8) - *dg = uint8((uint32(*dg)*a + sg*ma) / m >> 8) - *db = uint8((uint32(*db)*a + sb*ma) / m >> 8) - *da = uint8((uint32(*da)*a + sa*ma) / m >> 8) + d := dst.Pix[i : i+4 : i+4] // Small cap improves performance, see https://golang.org/issue/27857 + d[0] = uint8((uint32(d[0])*a + sr*ma) / m >> 8) + d[1] = uint8((uint32(d[1])*a + sg*ma) / m >> 8) + d[2] = uint8((uint32(d[2])*a + sb*ma) / m >> 8) + d[3] = uint8((uint32(d[3])*a + sa*ma) / m >> 8) } i0 += dst.Stride i1 += dst.Stride @@ -518,11 +517,12 @@ func drawRGBA(dst *image.RGBA, r image.Rectangle, src image.Image, sp image.Poin _, _, _, ma = mask.At(mx, my).RGBA() } sr, sg, sb, sa := src.At(sx, sy).RGBA() + d := dst.Pix[i : i+4 : i+4] // Small cap improves performance, see https://golang.org/issue/27857 if op == Over { - dr := uint32(dst.Pix[i+0]) - dg := uint32(dst.Pix[i+1]) - db := uint32(dst.Pix[i+2]) - da := uint32(dst.Pix[i+3]) + dr := uint32(d[0]) + dg := uint32(d[1]) + db := uint32(d[2]) + da := uint32(d[3]) // dr, dg, db and da are all 8-bit color at the moment, ranging in [0,255]. // We work in 16-bit color, and so would normally do: @@ -532,16 +532,16 @@ func drawRGBA(dst *image.RGBA, r image.Rectangle, src image.Image, sp image.Poin // This yields the same result, but is fewer arithmetic operations. a := (m - (sa * ma / m)) * 0x101 - dst.Pix[i+0] = uint8((dr*a + sr*ma) / m >> 8) - dst.Pix[i+1] = uint8((dg*a + sg*ma) / m >> 8) - dst.Pix[i+2] = uint8((db*a + sb*ma) / m >> 8) - dst.Pix[i+3] = uint8((da*a + sa*ma) / m >> 8) + d[0] = uint8((dr*a + sr*ma) / m >> 8) + d[1] = uint8((dg*a + sg*ma) / m >> 8) + d[2] = uint8((db*a + sb*ma) / m >> 8) + d[3] = uint8((da*a + sa*ma) / m >> 8) } else { - dst.Pix[i+0] = uint8(sr * ma / m >> 8) - dst.Pix[i+1] = uint8(sg * ma / m >> 8) - dst.Pix[i+2] = uint8(sb * ma / m >> 8) - dst.Pix[i+3] = uint8(sa * ma / m >> 8) + d[0] = uint8(sr * ma / m >> 8) + d[1] = uint8(sg * ma / m >> 8) + d[2] = uint8(sb * ma / m >> 8) + d[3] = uint8(sa * ma / m >> 8) } } i0 += dy * dst.Stride diff --git a/libgo/go/image/format.go b/libgo/go/image/format.go index 3668de4e685..a53b8f9b554 100644 --- a/libgo/go/image/format.go +++ b/libgo/go/image/format.go @@ -8,6 +8,8 @@ import ( "bufio" "errors" "io" + "sync" + "sync/atomic" ) // ErrFormat indicates that decoding encountered an unknown format. @@ -21,7 +23,10 @@ type format struct { } // Formats is the list of registered formats. -var formats []format +var ( + formatsMu sync.Mutex + atomicFormats atomic.Value +) // RegisterFormat registers an image format for use by Decode. // Name is the name of the format, like "jpeg" or "png". @@ -30,7 +35,10 @@ var formats []format // Decode is the function that decodes the encoded image. // DecodeConfig is the function that decodes just its configuration. func RegisterFormat(name, magic string, decode func(io.Reader) (Image, error), decodeConfig func(io.Reader) (Config, error)) { - formats = append(formats, format{name, magic, decode, decodeConfig}) + formatsMu.Lock() + formats, _ := atomicFormats.Load().([]format) + atomicFormats.Store(append(formats, format{name, magic, decode, decodeConfig})) + formatsMu.Unlock() } // A reader is an io.Reader that can also peek ahead. @@ -62,6 +70,7 @@ func match(magic string, b []byte) bool { // Sniff determines the format of r's data. func sniff(r reader) format { + formats, _ := atomicFormats.Load().([]format) for _, f := range formats { b, err := r.Peek(len(f.magic)) if err == nil && match(f.magic, b) { diff --git a/libgo/go/image/image.go b/libgo/go/image/image.go index bebb9f70fa6..ffd6de73837 100644 --- a/libgo/go/image/image.go +++ b/libgo/go/image/image.go @@ -80,7 +80,8 @@ func (p *RGBA) RGBAAt(x, y int) color.RGBA { return color.RGBA{} } i := p.PixOffset(x, y) - return color.RGBA{p.Pix[i+0], p.Pix[i+1], p.Pix[i+2], p.Pix[i+3]} + s := p.Pix[i : i+4 : i+4] // Small cap improves performance, see https://golang.org/issue/27857 + return color.RGBA{s[0], s[1], s[2], s[3]} } // PixOffset returns the index of the first element of Pix that corresponds to @@ -95,10 +96,11 @@ func (p *RGBA) Set(x, y int, c color.Color) { } i := p.PixOffset(x, y) c1 := color.RGBAModel.Convert(c).(color.RGBA) - p.Pix[i+0] = c1.R - p.Pix[i+1] = c1.G - p.Pix[i+2] = c1.B - p.Pix[i+3] = c1.A + s := p.Pix[i : i+4 : i+4] // Small cap improves performance, see https://golang.org/issue/27857 + s[0] = c1.R + s[1] = c1.G + s[2] = c1.B + s[3] = c1.A } func (p *RGBA) SetRGBA(x, y int, c color.RGBA) { @@ -106,10 +108,11 @@ func (p *RGBA) SetRGBA(x, y int, c color.RGBA) { return } i := p.PixOffset(x, y) - p.Pix[i+0] = c.R - p.Pix[i+1] = c.G - p.Pix[i+2] = c.B - p.Pix[i+3] = c.A + s := p.Pix[i : i+4 : i+4] // Small cap improves performance, see https://golang.org/issue/27857 + s[0] = c.R + s[1] = c.G + s[2] = c.B + s[3] = c.A } // SubImage returns an image representing the portion of the image p visible @@ -179,11 +182,12 @@ func (p *RGBA64) RGBA64At(x, y int) color.RGBA64 { return color.RGBA64{} } i := p.PixOffset(x, y) + s := p.Pix[i : i+8 : i+8] // Small cap improves performance, see https://golang.org/issue/27857 return color.RGBA64{ - uint16(p.Pix[i+0])<<8 | uint16(p.Pix[i+1]), - uint16(p.Pix[i+2])<<8 | uint16(p.Pix[i+3]), - uint16(p.Pix[i+4])<<8 | uint16(p.Pix[i+5]), - uint16(p.Pix[i+6])<<8 | uint16(p.Pix[i+7]), + uint16(s[0])<<8 | uint16(s[1]), + uint16(s[2])<<8 | uint16(s[3]), + uint16(s[4])<<8 | uint16(s[5]), + uint16(s[6])<<8 | uint16(s[7]), } } @@ -199,14 +203,15 @@ func (p *RGBA64) Set(x, y int, c color.Color) { } i := p.PixOffset(x, y) c1 := color.RGBA64Model.Convert(c).(color.RGBA64) - p.Pix[i+0] = uint8(c1.R >> 8) - p.Pix[i+1] = uint8(c1.R) - p.Pix[i+2] = uint8(c1.G >> 8) - p.Pix[i+3] = uint8(c1.G) - p.Pix[i+4] = uint8(c1.B >> 8) - p.Pix[i+5] = uint8(c1.B) - p.Pix[i+6] = uint8(c1.A >> 8) - p.Pix[i+7] = uint8(c1.A) + s := p.Pix[i : i+8 : i+8] // Small cap improves performance, see https://golang.org/issue/27857 + s[0] = uint8(c1.R >> 8) + s[1] = uint8(c1.R) + s[2] = uint8(c1.G >> 8) + s[3] = uint8(c1.G) + s[4] = uint8(c1.B >> 8) + s[5] = uint8(c1.B) + s[6] = uint8(c1.A >> 8) + s[7] = uint8(c1.A) } func (p *RGBA64) SetRGBA64(x, y int, c color.RGBA64) { @@ -214,14 +219,15 @@ func (p *RGBA64) SetRGBA64(x, y int, c color.RGBA64) { return } i := p.PixOffset(x, y) - p.Pix[i+0] = uint8(c.R >> 8) - p.Pix[i+1] = uint8(c.R) - p.Pix[i+2] = uint8(c.G >> 8) - p.Pix[i+3] = uint8(c.G) - p.Pix[i+4] = uint8(c.B >> 8) - p.Pix[i+5] = uint8(c.B) - p.Pix[i+6] = uint8(c.A >> 8) - p.Pix[i+7] = uint8(c.A) + s := p.Pix[i : i+8 : i+8] // Small cap improves performance, see https://golang.org/issue/27857 + s[0] = uint8(c.R >> 8) + s[1] = uint8(c.R) + s[2] = uint8(c.G >> 8) + s[3] = uint8(c.G) + s[4] = uint8(c.B >> 8) + s[5] = uint8(c.B) + s[6] = uint8(c.A >> 8) + s[7] = uint8(c.A) } // SubImage returns an image representing the portion of the image p visible @@ -291,7 +297,8 @@ func (p *NRGBA) NRGBAAt(x, y int) color.NRGBA { return color.NRGBA{} } i := p.PixOffset(x, y) - return color.NRGBA{p.Pix[i+0], p.Pix[i+1], p.Pix[i+2], p.Pix[i+3]} + s := p.Pix[i : i+4 : i+4] // Small cap improves performance, see https://golang.org/issue/27857 + return color.NRGBA{s[0], s[1], s[2], s[3]} } // PixOffset returns the index of the first element of Pix that corresponds to @@ -306,10 +313,11 @@ func (p *NRGBA) Set(x, y int, c color.Color) { } i := p.PixOffset(x, y) c1 := color.NRGBAModel.Convert(c).(color.NRGBA) - p.Pix[i+0] = c1.R - p.Pix[i+1] = c1.G - p.Pix[i+2] = c1.B - p.Pix[i+3] = c1.A + s := p.Pix[i : i+4 : i+4] // Small cap improves performance, see https://golang.org/issue/27857 + s[0] = c1.R + s[1] = c1.G + s[2] = c1.B + s[3] = c1.A } func (p *NRGBA) SetNRGBA(x, y int, c color.NRGBA) { @@ -317,10 +325,11 @@ func (p *NRGBA) SetNRGBA(x, y int, c color.NRGBA) { return } i := p.PixOffset(x, y) - p.Pix[i+0] = c.R - p.Pix[i+1] = c.G - p.Pix[i+2] = c.B - p.Pix[i+3] = c.A + s := p.Pix[i : i+4 : i+4] // Small cap improves performance, see https://golang.org/issue/27857 + s[0] = c.R + s[1] = c.G + s[2] = c.B + s[3] = c.A } // SubImage returns an image representing the portion of the image p visible @@ -390,11 +399,12 @@ func (p *NRGBA64) NRGBA64At(x, y int) color.NRGBA64 { return color.NRGBA64{} } i := p.PixOffset(x, y) + s := p.Pix[i : i+8 : i+8] // Small cap improves performance, see https://golang.org/issue/27857 return color.NRGBA64{ - uint16(p.Pix[i+0])<<8 | uint16(p.Pix[i+1]), - uint16(p.Pix[i+2])<<8 | uint16(p.Pix[i+3]), - uint16(p.Pix[i+4])<<8 | uint16(p.Pix[i+5]), - uint16(p.Pix[i+6])<<8 | uint16(p.Pix[i+7]), + uint16(s[0])<<8 | uint16(s[1]), + uint16(s[2])<<8 | uint16(s[3]), + uint16(s[4])<<8 | uint16(s[5]), + uint16(s[6])<<8 | uint16(s[7]), } } @@ -410,14 +420,15 @@ func (p *NRGBA64) Set(x, y int, c color.Color) { } i := p.PixOffset(x, y) c1 := color.NRGBA64Model.Convert(c).(color.NRGBA64) - p.Pix[i+0] = uint8(c1.R >> 8) - p.Pix[i+1] = uint8(c1.R) - p.Pix[i+2] = uint8(c1.G >> 8) - p.Pix[i+3] = uint8(c1.G) - p.Pix[i+4] = uint8(c1.B >> 8) - p.Pix[i+5] = uint8(c1.B) - p.Pix[i+6] = uint8(c1.A >> 8) - p.Pix[i+7] = uint8(c1.A) + s := p.Pix[i : i+8 : i+8] // Small cap improves performance, see https://golang.org/issue/27857 + s[0] = uint8(c1.R >> 8) + s[1] = uint8(c1.R) + s[2] = uint8(c1.G >> 8) + s[3] = uint8(c1.G) + s[4] = uint8(c1.B >> 8) + s[5] = uint8(c1.B) + s[6] = uint8(c1.A >> 8) + s[7] = uint8(c1.A) } func (p *NRGBA64) SetNRGBA64(x, y int, c color.NRGBA64) { @@ -425,14 +436,15 @@ func (p *NRGBA64) SetNRGBA64(x, y int, c color.NRGBA64) { return } i := p.PixOffset(x, y) - p.Pix[i+0] = uint8(c.R >> 8) - p.Pix[i+1] = uint8(c.R) - p.Pix[i+2] = uint8(c.G >> 8) - p.Pix[i+3] = uint8(c.G) - p.Pix[i+4] = uint8(c.B >> 8) - p.Pix[i+5] = uint8(c.B) - p.Pix[i+6] = uint8(c.A >> 8) - p.Pix[i+7] = uint8(c.A) + s := p.Pix[i : i+8 : i+8] // Small cap improves performance, see https://golang.org/issue/27857 + s[0] = uint8(c.R >> 8) + s[1] = uint8(c.R) + s[2] = uint8(c.G >> 8) + s[3] = uint8(c.G) + s[4] = uint8(c.B >> 8) + s[5] = uint8(c.B) + s[6] = uint8(c.A >> 8) + s[7] = uint8(c.A) } // SubImage returns an image representing the portion of the image p visible @@ -850,7 +862,8 @@ func (p *CMYK) CMYKAt(x, y int) color.CMYK { return color.CMYK{} } i := p.PixOffset(x, y) - return color.CMYK{p.Pix[i+0], p.Pix[i+1], p.Pix[i+2], p.Pix[i+3]} + s := p.Pix[i : i+4 : i+4] // Small cap improves performance, see https://golang.org/issue/27857 + return color.CMYK{s[0], s[1], s[2], s[3]} } // PixOffset returns the index of the first element of Pix that corresponds to @@ -865,10 +878,11 @@ func (p *CMYK) Set(x, y int, c color.Color) { } i := p.PixOffset(x, y) c1 := color.CMYKModel.Convert(c).(color.CMYK) - p.Pix[i+0] = c1.C - p.Pix[i+1] = c1.M - p.Pix[i+2] = c1.Y - p.Pix[i+3] = c1.K + s := p.Pix[i : i+4 : i+4] // Small cap improves performance, see https://golang.org/issue/27857 + s[0] = c1.C + s[1] = c1.M + s[2] = c1.Y + s[3] = c1.K } func (p *CMYK) SetCMYK(x, y int, c color.CMYK) { @@ -876,10 +890,11 @@ func (p *CMYK) SetCMYK(x, y int, c color.CMYK) { return } i := p.PixOffset(x, y) - p.Pix[i+0] = c.C - p.Pix[i+1] = c.M - p.Pix[i+2] = c.Y - p.Pix[i+3] = c.K + s := p.Pix[i : i+4 : i+4] // Small cap improves performance, see https://golang.org/issue/27857 + s[0] = c.C + s[1] = c.M + s[2] = c.Y + s[3] = c.K } // SubImage returns an image representing the portion of the image p visible diff --git a/libgo/go/image/image_test.go b/libgo/go/image/image_test.go index 08ba61ea0c7..dfd8eb35a80 100644 --- a/libgo/go/image/image_test.go +++ b/libgo/go/image/image_test.go @@ -22,22 +22,29 @@ func cmp(cm color.Model, c0, c1 color.Color) bool { return r0 == r1 && g0 == g1 && b0 == b1 && a0 == a1 } -func TestImage(t *testing.T) { - testImage := []image{ - NewRGBA(Rect(0, 0, 10, 10)), - NewRGBA64(Rect(0, 0, 10, 10)), - NewNRGBA(Rect(0, 0, 10, 10)), - NewNRGBA64(Rect(0, 0, 10, 10)), - NewAlpha(Rect(0, 0, 10, 10)), - NewAlpha16(Rect(0, 0, 10, 10)), - NewGray(Rect(0, 0, 10, 10)), - NewGray16(Rect(0, 0, 10, 10)), - NewPaletted(Rect(0, 0, 10, 10), color.Palette{ +var testImages = []struct { + name string + image func() image +}{ + {"rgba", func() image { return NewRGBA(Rect(0, 0, 10, 10)) }}, + {"rgba64", func() image { return NewRGBA64(Rect(0, 0, 10, 10)) }}, + {"nrgba", func() image { return NewNRGBA(Rect(0, 0, 10, 10)) }}, + {"nrgba64", func() image { return NewNRGBA64(Rect(0, 0, 10, 10)) }}, + {"alpha", func() image { return NewAlpha(Rect(0, 0, 10, 10)) }}, + {"alpha16", func() image { return NewAlpha16(Rect(0, 0, 10, 10)) }}, + {"gray", func() image { return NewGray(Rect(0, 0, 10, 10)) }}, + {"gray16", func() image { return NewGray16(Rect(0, 0, 10, 10)) }}, + {"paletted", func() image { + return NewPaletted(Rect(0, 0, 10, 10), color.Palette{ Transparent, Opaque, - }), - } - for _, m := range testImage { + }) + }}, +} + +func TestImage(t *testing.T) { + for _, tc := range testImages { + m := tc.image() if !Rect(0, 0, 10, 10).Eq(m.Bounds()) { t.Errorf("%T: want bounds %v, got %v", m, Rect(0, 0, 10, 10), m.Bounds()) continue @@ -111,3 +118,182 @@ func Test16BitsPerColorChannel(t *testing.T) { } } } + +func BenchmarkAt(b *testing.B) { + for _, tc := range testImages { + b.Run(tc.name, func(b *testing.B) { + m := tc.image() + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + m.At(4, 5) + } + }) + } +} + +func BenchmarkSet(b *testing.B) { + c := color.Gray{0xff} + for _, tc := range testImages { + b.Run(tc.name, func(b *testing.B) { + m := tc.image() + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + m.Set(4, 5, c) + } + }) + } +} + +func BenchmarkRGBAAt(b *testing.B) { + m := NewRGBA(Rect(0, 0, 10, 10)) + b.ResetTimer() + + for i := 0; i < b.N; i++ { + m.RGBAAt(4, 5) + } +} + +func BenchmarkRGBASetRGBA(b *testing.B) { + m := NewRGBA(Rect(0, 0, 10, 10)) + c := color.RGBA{0xff, 0xff, 0xff, 0x13} + b.ResetTimer() + + for i := 0; i < b.N; i++ { + m.SetRGBA(4, 5, c) + } +} + +func BenchmarkRGBA64At(b *testing.B) { + m := NewRGBA64(Rect(0, 0, 10, 10)) + b.ResetTimer() + + for i := 0; i < b.N; i++ { + m.RGBA64At(4, 5) + } +} + +func BenchmarkRGBA64SetRGBA64(b *testing.B) { + m := NewRGBA64(Rect(0, 0, 10, 10)) + c := color.RGBA64{0xffff, 0xffff, 0xffff, 0x1357} + b.ResetTimer() + + for i := 0; i < b.N; i++ { + m.SetRGBA64(4, 5, c) + } +} + +func BenchmarkNRGBAAt(b *testing.B) { + m := NewNRGBA(Rect(0, 0, 10, 10)) + b.ResetTimer() + + for i := 0; i < b.N; i++ { + m.NRGBAAt(4, 5) + } +} + +func BenchmarkNRGBASetNRGBA(b *testing.B) { + m := NewNRGBA(Rect(0, 0, 10, 10)) + c := color.NRGBA{0xff, 0xff, 0xff, 0x13} + b.ResetTimer() + + for i := 0; i < b.N; i++ { + m.SetNRGBA(4, 5, c) + } +} + +func BenchmarkNRGBA64At(b *testing.B) { + m := NewNRGBA64(Rect(0, 0, 10, 10)) + b.ResetTimer() + + for i := 0; i < b.N; i++ { + m.NRGBA64At(4, 5) + } +} + +func BenchmarkNRGBA64SetNRGBA64(b *testing.B) { + m := NewNRGBA64(Rect(0, 0, 10, 10)) + c := color.NRGBA64{0xffff, 0xffff, 0xffff, 0x1357} + b.ResetTimer() + + for i := 0; i < b.N; i++ { + m.SetNRGBA64(4, 5, c) + } +} + +func BenchmarkAlphaAt(b *testing.B) { + m := NewAlpha(Rect(0, 0, 10, 10)) + b.ResetTimer() + + for i := 0; i < b.N; i++ { + m.AlphaAt(4, 5) + } +} + +func BenchmarkAlphaSetAlpha(b *testing.B) { + m := NewAlpha(Rect(0, 0, 10, 10)) + c := color.Alpha{0x13} + b.ResetTimer() + + for i := 0; i < b.N; i++ { + m.SetAlpha(4, 5, c) + } +} + +func BenchmarkAlpha16At(b *testing.B) { + m := NewAlpha16(Rect(0, 0, 10, 10)) + b.ResetTimer() + + for i := 0; i < b.N; i++ { + m.Alpha16At(4, 5) + } +} + +func BenchmarkAlphaSetAlpha16(b *testing.B) { + m := NewAlpha16(Rect(0, 0, 10, 10)) + c := color.Alpha16{0x13} + b.ResetTimer() + + for i := 0; i < b.N; i++ { + m.SetAlpha16(4, 5, c) + } +} + +func BenchmarkGrayAt(b *testing.B) { + m := NewGray(Rect(0, 0, 10, 10)) + b.ResetTimer() + + for i := 0; i < b.N; i++ { + m.GrayAt(4, 5) + } +} + +func BenchmarkGraySetGray(b *testing.B) { + m := NewGray(Rect(0, 0, 10, 10)) + c := color.Gray{0x13} + b.ResetTimer() + + for i := 0; i < b.N; i++ { + m.SetGray(4, 5, c) + } +} + +func BenchmarkGray16At(b *testing.B) { + m := NewGray16(Rect(0, 0, 10, 10)) + b.ResetTimer() + + for i := 0; i < b.N; i++ { + m.Gray16At(4, 5) + } +} + +func BenchmarkGraySetGray16(b *testing.B) { + m := NewGray16(Rect(0, 0, 10, 10)) + c := color.Gray16{0x13} + b.ResetTimer() + + for i := 0; i < b.N; i++ { + m.SetGray16(4, 5, c) + } +} diff --git a/libgo/go/image/jpeg/fdct.go b/libgo/go/image/jpeg/fdct.go index 3f8be4e3260..201a5abd0ba 100644 --- a/libgo/go/image/jpeg/fdct.go +++ b/libgo/go/image/jpeg/fdct.go @@ -123,14 +123,14 @@ func fdct(b *block) { tmp13 = tmp1 + tmp3 z1 = (tmp12 + tmp13) * fix_1_175875602 z1 += 1 << (constBits - pass1Bits - 1) - tmp0 = tmp0 * fix_1_501321110 - tmp1 = tmp1 * fix_3_072711026 - tmp2 = tmp2 * fix_2_053119869 - tmp3 = tmp3 * fix_0_298631336 - tmp10 = tmp10 * -fix_0_899976223 - tmp11 = tmp11 * -fix_2_562915447 - tmp12 = tmp12 * -fix_0_390180644 - tmp13 = tmp13 * -fix_1_961570560 + tmp0 *= fix_1_501321110 + tmp1 *= fix_3_072711026 + tmp2 *= fix_2_053119869 + tmp3 *= fix_0_298631336 + tmp10 *= -fix_0_899976223 + tmp11 *= -fix_2_562915447 + tmp12 *= -fix_0_390180644 + tmp13 *= -fix_1_961570560 tmp12 += z1 tmp13 += z1 @@ -171,14 +171,14 @@ func fdct(b *block) { tmp13 = tmp1 + tmp3 z1 = (tmp12 + tmp13) * fix_1_175875602 z1 += 1 << (constBits + pass1Bits - 1) - tmp0 = tmp0 * fix_1_501321110 - tmp1 = tmp1 * fix_3_072711026 - tmp2 = tmp2 * fix_2_053119869 - tmp3 = tmp3 * fix_0_298631336 - tmp10 = tmp10 * -fix_0_899976223 - tmp11 = tmp11 * -fix_2_562915447 - tmp12 = tmp12 * -fix_0_390180644 - tmp13 = tmp13 * -fix_1_961570560 + tmp0 *= fix_1_501321110 + tmp1 *= fix_3_072711026 + tmp2 *= fix_2_053119869 + tmp3 *= fix_0_298631336 + tmp10 *= -fix_0_899976223 + tmp11 *= -fix_2_562915447 + tmp12 *= -fix_0_390180644 + tmp13 *= -fix_1_961570560 tmp12 += z1 tmp13 += z1 diff --git a/libgo/go/image/png/reader_test.go b/libgo/go/image/png/reader_test.go index 66bcfcb437e..33dcd3debcc 100644 --- a/libgo/go/image/png/reader_test.go +++ b/libgo/go/image/png/reader_test.go @@ -364,10 +364,6 @@ func TestReader(t *testing.T) { } defer sf.Close() sb := bufio.NewScanner(sf) - if err != nil { - t.Error(fn, err) - continue - } // Compare the two, in SNG format, line by line. for { diff --git a/libgo/go/image/png/writer.go b/libgo/go/image/png/writer.go index 49f1ad2e7fa..c03335120eb 100644 --- a/libgo/go/image/png/writer.go +++ b/libgo/go/image/png/writer.go @@ -7,6 +7,7 @@ package png import ( "bufio" "compress/zlib" + "encoding/binary" "hash/crc32" "image" "image/color" @@ -62,14 +63,6 @@ const ( // compression level, although that is not implemented yet. ) -// Big-endian. -func writeUint32(b []uint8, u uint32) { - b[0] = uint8(u >> 24) - b[1] = uint8(u >> 16) - b[2] = uint8(u >> 8) - b[3] = uint8(u >> 0) -} - type opaquer interface { Opaque() bool } @@ -108,7 +101,7 @@ func (e *encoder) writeChunk(b []byte, name string) { e.err = UnsupportedError(name + " chunk is too large: " + strconv.Itoa(len(b))) return } - writeUint32(e.header[:4], n) + binary.BigEndian.PutUint32(e.header[:4], n) e.header[4] = name[0] e.header[5] = name[1] e.header[6] = name[2] @@ -116,7 +109,7 @@ func (e *encoder) writeChunk(b []byte, name string) { crc := crc32.NewIEEE() crc.Write(e.header[4:8]) crc.Write(b) - writeUint32(e.footer[:4], crc.Sum32()) + binary.BigEndian.PutUint32(e.footer[:4], crc.Sum32()) _, e.err = e.w.Write(e.header[:8]) if e.err != nil { @@ -131,8 +124,8 @@ func (e *encoder) writeChunk(b []byte, name string) { func (e *encoder) writeIHDR() { b := e.m.Bounds() - writeUint32(e.tmp[0:4], uint32(b.Dx())) - writeUint32(e.tmp[4:8], uint32(b.Dy())) + binary.BigEndian.PutUint32(e.tmp[0:4], uint32(b.Dx())) + binary.BigEndian.PutUint32(e.tmp[4:8], uint32(b.Dy())) // Set bit depth and color type. switch e.cb { case cbG8: @@ -144,6 +137,15 @@ func (e *encoder) writeIHDR() { case cbP8: e.tmp[8] = 8 e.tmp[9] = ctPaletted + case cbP4: + e.tmp[8] = 4 + e.tmp[9] = ctPaletted + case cbP2: + e.tmp[8] = 2 + e.tmp[9] = ctPaletted + case cbP1: + e.tmp[8] = 1 + e.tmp[9] = ctPaletted case cbTCA8: e.tmp[8] = 8 e.tmp[9] = ctTrueColorAlpha @@ -312,31 +314,38 @@ func (e *encoder) writeImage(w io.Writer, m image.Image, cb int, level int) erro } defer e.zw.Close() - bpp := 0 // Bytes per pixel. + bitsPerPixel := 0 switch cb { case cbG8: - bpp = 1 + bitsPerPixel = 8 case cbTC8: - bpp = 3 + bitsPerPixel = 24 case cbP8: - bpp = 1 + bitsPerPixel = 8 + case cbP4: + bitsPerPixel = 4 + case cbP2: + bitsPerPixel = 2 + case cbP1: + bitsPerPixel = 1 case cbTCA8: - bpp = 4 + bitsPerPixel = 32 case cbTC16: - bpp = 6 + bitsPerPixel = 48 case cbTCA16: - bpp = 8 + bitsPerPixel = 64 case cbG16: - bpp = 2 + bitsPerPixel = 16 } + // cr[*] and pr are the bytes for the current and previous row. // cr[0] is unfiltered (or equivalently, filtered with the ftNone filter). // cr[ft], for non-zero filter types ft, are buffers for transforming cr[0] under the // other PNG filter types. These buffers are allocated once and re-used for each row. // The +1 is for the per-row filter type, which is at cr[*][0]. b := m.Bounds() - sz := 1 + bpp*b.Dx() + sz := 1 + (bitsPerPixel*b.Dx()+7)/8 for i := range e.cr { if cap(e.cr[i]) < sz { e.cr[i] = make([]uint8, sz) @@ -412,6 +421,30 @@ func (e *encoder) writeImage(w io.Writer, m image.Image, cb int, level int) erro i += 1 } } + + case cbP4, cbP2, cbP1: + pi := m.(image.PalettedImage) + + var a uint8 + var c int + for x := b.Min.X; x < b.Max.X; x++ { + a = a< 0) { + return 1; } } if (a.__count < b.__count) { diff --git a/libgo/go/internal/bytealg/bytealg.go b/libgo/go/internal/bytealg/bytealg.go index b91eb0075ba..e46ee7c4fba 100644 --- a/libgo/go/internal/bytealg/bytealg.go +++ b/libgo/go/internal/bytealg/bytealg.go @@ -13,11 +13,12 @@ import ( // Offsets into internal/cpu records for use in assembly. const ( - x86_HasSSE2 = unsafe.Offsetof(cpu.X86.HasSSE2) - x86_HasSSE42 = unsafe.Offsetof(cpu.X86.HasSSE42) - x86_HasAVX2 = unsafe.Offsetof(cpu.X86.HasAVX2) - x86_HasPOPCNT = unsafe.Offsetof(cpu.X86.HasPOPCNT) - s390x_HasVX = unsafe.Offsetof(cpu.S390X.HasVX) + offsetX86HasSSE2 = unsafe.Offsetof(cpu.X86.HasSSE2) + offsetX86HasSSE42 = unsafe.Offsetof(cpu.X86.HasSSE42) + offsetX86HasAVX2 = unsafe.Offsetof(cpu.X86.HasAVX2) + offsetX86HasPOPCNT = unsafe.Offsetof(cpu.X86.HasPOPCNT) + + offsetS390xHasVX = unsafe.Offsetof(cpu.S390X.HasVX) ) // MaxLen is the maximum length of the string to be searched for (argument b) in Index. diff --git a/libgo/go/internal/bytealg/compare_generic.go b/libgo/go/internal/bytealg/compare_generic.go index bb488330e4a..c72bf12ceb0 100644 --- a/libgo/go/internal/bytealg/compare_generic.go +++ b/libgo/go/internal/bytealg/compare_generic.go @@ -36,34 +36,6 @@ samebytes: return 0 } -//go:linkname bytes_Compare bytes.Compare -func bytes_Compare(a, b []byte) int { - l := len(a) - if len(b) < l { - l = len(b) - } - if l == 0 || &a[0] == &b[0] { - goto samebytes - } - for i := 0; i < l; i++ { - c1, c2 := a[i], b[i] - if c1 < c2 { - return -1 - } - if c1 > c2 { - return +1 - } - } -samebytes: - if len(a) < len(b) { - return -1 - } - if len(a) > len(b) { - return +1 - } - return 0 -} - //go:linkname runtime_cmpstring runtime.cmpstring func runtime_cmpstring(a, b string) int { l := len(a) diff --git a/libgo/go/internal/bytealg/compare_native.go b/libgo/go/internal/bytealg/compare_native.go index 2c317e29de8..844d6698cea 100644 --- a/libgo/go/internal/bytealg/compare_native.go +++ b/libgo/go/internal/bytealg/compare_native.go @@ -6,5 +6,14 @@ package bytealg +import _ "unsafe" // For go:linkname + //go:noescape func Compare(a, b []byte) int + +// The declaration below generates ABI wrappers for functions +// implemented in assembly in this package but declared in another +// package. + +//go:linkname abigen_runtime_cmpstring runtime.cmpstring +func abigen_runtime_cmpstring(a, b string) int diff --git a/libgo/go/internal/bytealg/count_generic.go b/libgo/go/internal/bytealg/count_generic.go index 5a0643011e4..e93ac133358 100644 --- a/libgo/go/internal/bytealg/count_generic.go +++ b/libgo/go/internal/bytealg/count_generic.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// -build !amd64,!arm64 +// -build !amd64,!arm64,!ppc64le,!ppc64 package bytealg diff --git a/libgo/go/internal/bytealg/count_native.go b/libgo/go/internal/bytealg/count_native.go index 5ea5c283851..bb622aec015 100644 --- a/libgo/go/internal/bytealg/count_native.go +++ b/libgo/go/internal/bytealg/count_native.go @@ -3,7 +3,7 @@ // license that can be found in the LICENSE file. // +build ignore_for_gccgo -// +build amd64 arm64 +// +build amd64 arm64 ppc64le ppc64 package bytealg diff --git a/libgo/go/internal/bytealg/equal_native.go b/libgo/go/internal/bytealg/equal_native.go index b5c453086c9..995f0749d44 100644 --- a/libgo/go/internal/bytealg/equal_native.go +++ b/libgo/go/internal/bytealg/equal_native.go @@ -4,11 +4,23 @@ package bytealg +import "unsafe" + // Note: there's no equal_generic.go because every platform must implement at least memequal_varlen in assembly. //go:noescape func Equal(a, b []byte) bool +// The declarations below generate ABI wrappers for functions +// implemented in assembly in this package but declared in another +// package. + // The compiler generates calls to runtime.memequal and runtime.memequal_varlen. // In addition, the runtime calls runtime.memequal explicitly. // Those functions are implemented in this package. + +//go:linkname abigen_runtime_memequal runtime.memequal +func abigen_runtime_memequal(a, b unsafe.Pointer, size uintptr) bool + +//go:linkname abigen_runtime_memequal_varlen runtime.memequal_varlen +func abigen_runtime_memequal_varlen(a, b unsafe.Pointer) bool diff --git a/libgo/go/internal/bytealg/indexbyte_generic.go b/libgo/go/internal/bytealg/indexbyte_generic.go index 6e59fd1e72e..d39dfa87c34 100644 --- a/libgo/go/internal/bytealg/indexbyte_generic.go +++ b/libgo/go/internal/bytealg/indexbyte_generic.go @@ -7,8 +7,6 @@ package bytealg -import _ "unsafe" // for go:linkname - func IndexByte(b []byte, c byte) int { for i, x := range b { if x == c { @@ -26,23 +24,3 @@ func IndexByteString(s string, c byte) int { } return -1 } - -//go:linkname bytes_IndexByte bytes.IndexByte -func bytes_IndexByte(b []byte, c byte) int { - for i, x := range b { - if x == c { - return i - } - } - return -1 -} - -//go:linkname strings_IndexByte strings.IndexByte -func strings_IndexByte(s string, c byte) int { - for i := 0; i < len(s); i++ { - if s[i] == c { - return i - } - } - return -1 -} diff --git a/libgo/go/internal/cpu/cpu.go b/libgo/go/internal/cpu/cpu.go index 9567a4f78be..eb74a9fa82a 100644 --- a/libgo/go/internal/cpu/cpu.go +++ b/libgo/go/internal/cpu/cpu.go @@ -6,11 +6,19 @@ // used by the Go standard library. package cpu -// DebugOptions is set to true by the runtime if go was compiled with GOEXPERIMENT=debugcpu -// and GOOS is Linux or Darwin. +// DebugOptions is set to true by the runtime if the OS supports reading +// GODEBUG early in runtime startup. // This should not be changed after it is initialized. var DebugOptions bool +// CacheLinePad is used to pad structs to avoid false sharing. +type CacheLinePad struct{ _ [CacheLinePadSize]byte } + +// CacheLineSize is the CPU's assumed cache line size. +// There is currently no runtime detection of the real cache line size +// so we use the constant per GOARCH CacheLinePadSize as an approximation. +var CacheLineSize uintptr = CacheLinePadSize + var X86 x86 // The booleans in x86 contain the correspondingly named cpuid feature bit. @@ -18,7 +26,7 @@ var X86 x86 // in addition to the cpuid feature bit being set. // The struct is padded to avoid false sharing. type x86 struct { - _ [CacheLineSize]byte + _ CacheLinePad HasAES bool HasADX bool HasAVX bool @@ -35,32 +43,34 @@ type x86 struct { HasSSSE3 bool HasSSE41 bool HasSSE42 bool - _ [CacheLineSize]byte + _ CacheLinePad } var PPC64 ppc64 -// For ppc64x, it is safe to check only for ISA level starting on ISA v3.00, +// For ppc64(le), it is safe to check only for ISA level starting on ISA v3.00, // since there are no optional categories. There are some exceptions that also // require kernel support to work (darn, scv), so there are feature bits for -// those as well. The minimum processor requirement is POWER8 (ISA 2.07), so we -// maintain some of the old feature checks for optional categories for -// safety. +// those as well. The minimum processor requirement is POWER8 (ISA 2.07). // The struct is padded to avoid false sharing. type ppc64 struct { - _ [CacheLineSize]byte - HasVMX bool // Vector unit (Altivec) - HasDFP bool // Decimal Floating Point unit - HasVSX bool // Vector-scalar unit - HasHTM bool // Hardware Transactional Memory - HasISEL bool // Integer select - HasVCRYPTO bool // Vector cryptography - HasHTMNOSC bool // HTM: kernel-aborted transaction in syscalls - HasDARN bool // Hardware random number generator (requires kernel enablement) - HasSCV bool // Syscall vectored (requires kernel enablement) - IsPOWER8 bool // ISA v2.07 (POWER8) - IsPOWER9 bool // ISA v3.00 (POWER9) - _ [CacheLineSize]byte + _ CacheLinePad + HasDARN bool // Hardware random number generator (requires kernel enablement) + HasSCV bool // Syscall vectored (requires kernel enablement) + IsPOWER8 bool // ISA v2.07 (POWER8) + IsPOWER9 bool // ISA v3.00 (POWER9) + _ CacheLinePad +} + +var ARM arm + +// The booleans in arm contain the correspondingly named cpu feature bit. +// The struct is padded to avoid false sharing. +type arm struct { + _ CacheLinePad + HasVFPv4 bool + HasIDIVA bool + _ CacheLinePad } var ARM64 arm64 @@ -68,7 +78,7 @@ var ARM64 arm64 // The booleans in arm64 contain the correspondingly named cpu feature bit. // The struct is padded to avoid false sharing. type arm64 struct { - _ [CacheLineSize]byte + _ CacheLinePad HasFP bool HasASIMD bool HasEVTSTRM bool @@ -93,13 +103,13 @@ type arm64 struct { HasSHA512 bool HasSVE bool HasASIMDFHM bool - _ [CacheLineSize]byte + _ CacheLinePad } var S390X s390x type s390x struct { - _ [CacheLineSize]byte + _ CacheLinePad HasZArch bool // z architecture mode is active [mandatory] HasSTFLE bool // store facility list extended [mandatory] HasLDisp bool // long (20-bit) displacements [mandatory] @@ -116,19 +126,20 @@ type s390x struct { HasSHA256 bool // K{I,L}MD-SHA-256 functions HasSHA512 bool // K{I,L}MD-SHA-512 functions HasVX bool // vector facility. Note: the runtime sets this when it processes auxv records. - _ [CacheLineSize]byte + HasVE1 bool // vector-enhancement 1 + _ CacheLinePad } // Initialize examines the processor and sets the relevant variables above. // This is called by the runtime package early in program initialization, -// before normal init functions are run. env is set by runtime on Linux and Darwin -// if go was compiled with GOEXPERIMENT=debugcpu. +// before normal init functions are run. env is set by runtime if the OS supports +// cpu feature options in GODEBUG. func Initialize(env string) { doinit() processOptions(env) } -// options contains the cpu debug options that can be used in GODEBUGCPU. +// options contains the cpu debug options that can be used in GODEBUG. // Options are arch dependent and are added by the arch specific doinit functions. // Features that are mandatory for the specific GOARCH should not be added to options // (e.g. SSE2 on amd64). @@ -136,16 +147,19 @@ var options []option // Option names should be lower case. e.g. avx instead of AVX. type option struct { - Name string - Feature *bool + Name string + Feature *bool + Specified bool // whether feature value was specified in GODEBUG + Enable bool // whether feature should be enabled + Required bool // whether feature is mandatory and can not be disabled } -// processOptions disables CPU feature values based on the parsed env string. -// The env string is expected to be of the form feature1=0,feature2=0... +// processOptions enables or disables CPU feature values based on the parsed env string. +// The env string is expected to be of the form cpu.feature1=value1,cpu.feature2=value2... // where feature names is one of the architecture specifc list stored in the -// cpu packages options variable. If env contains all=0 then all capabilities -// referenced through the options variable are disabled. Other feature -// names and values other than 0 are silently ignored. +// cpu packages options variable and values are either 'on' or 'off'. +// If env contains cpu.all=off then all cpu features referenced through the options +// variable are disabled. Other feature names and values result in warning messages. func processOptions(env string) { field: for env != "" { @@ -156,28 +170,62 @@ field: } else { field, env = env[:i], env[i+1:] } + if len(field) < 4 || field[:4] != "cpu." { + continue + } i = indexByte(field, '=') if i < 0 { + print("GODEBUG: no value specified for \"", field, "\"\n") continue } - key, value := field[:i], field[i+1:] - - // Only allow turning off CPU features by specifying '0'. - if value == "0" { - if key == "all" { - for _, v := range options { - *v.Feature = false - } - return - } else { - for _, v := range options { - if v.Name == key { - *v.Feature = false - continue field - } - } + key, value := field[4:i], field[i+1:] // e.g. "SSE2", "on" + + var enable bool + switch value { + case "on": + enable = true + case "off": + enable = false + default: + print("GODEBUG: value \"", value, "\" not supported for cpu option \"", key, "\"\n") + continue field + } + + if key == "all" { + for i := range options { + options[i].Specified = true + options[i].Enable = enable || options[i].Required + } + continue field + } + + for i := range options { + if options[i].Name == key { + options[i].Specified = true + options[i].Enable = enable + continue field } } + + print("GODEBUG: unknown cpu feature \"", key, "\"\n") + } + + for _, o := range options { + if !o.Specified { + continue + } + + if o.Enable && !*o.Feature { + print("GODEBUG: can not enable \"", o.Name, "\", missing CPU support\n") + continue + } + + if !o.Enable && o.Required { + print("GODEBUG: can not disable \"", o.Name, "\", required CPU feature\n") + continue + } + + *o.Feature = o.Enable } } diff --git a/libgo/go/internal/cpu/cpu_arm64.go b/libgo/go/internal/cpu/cpu_arm64.go index c4d6b8155ab..99fa9918625 100644 --- a/libgo/go/internal/cpu/cpu_arm64.go +++ b/libgo/go/internal/cpu/cpu_arm64.go @@ -12,60 +12,60 @@ var HWCap2 uint // HWCAP/HWCAP2 bits. These are exposed by Linux. const ( - hwcap_FP = (1 << 0) - hwcap_ASIMD = (1 << 1) - hwcap_EVTSTRM = (1 << 2) - hwcap_AES = (1 << 3) - hwcap_PMULL = (1 << 4) - hwcap_SHA1 = (1 << 5) - hwcap_SHA2 = (1 << 6) - hwcap_CRC32 = (1 << 7) - hwcap_ATOMICS = (1 << 8) - hwcap_FPHP = (1 << 9) - hwcap_ASIMDHP = (1 << 10) - hwcap_CPUID = (1 << 11) - hwcap_ASIMDRDM = (1 << 12) - hwcap_JSCVT = (1 << 13) - hwcap_FCMA = (1 << 14) - hwcap_LRCPC = (1 << 15) - hwcap_DCPOP = (1 << 16) - hwcap_SHA3 = (1 << 17) - hwcap_SM3 = (1 << 18) - hwcap_SM4 = (1 << 19) - hwcap_ASIMDDP = (1 << 20) - hwcap_SHA512 = (1 << 21) - hwcap_SVE = (1 << 22) - hwcap_ASIMDFHM = (1 << 23) + hwcap_FP = 1 << 0 + hwcap_ASIMD = 1 << 1 + hwcap_EVTSTRM = 1 << 2 + hwcap_AES = 1 << 3 + hwcap_PMULL = 1 << 4 + hwcap_SHA1 = 1 << 5 + hwcap_SHA2 = 1 << 6 + hwcap_CRC32 = 1 << 7 + hwcap_ATOMICS = 1 << 8 + hwcap_FPHP = 1 << 9 + hwcap_ASIMDHP = 1 << 10 + hwcap_CPUID = 1 << 11 + hwcap_ASIMDRDM = 1 << 12 + hwcap_JSCVT = 1 << 13 + hwcap_FCMA = 1 << 14 + hwcap_LRCPC = 1 << 15 + hwcap_DCPOP = 1 << 16 + hwcap_SHA3 = 1 << 17 + hwcap_SM3 = 1 << 18 + hwcap_SM4 = 1 << 19 + hwcap_ASIMDDP = 1 << 20 + hwcap_SHA512 = 1 << 21 + hwcap_SVE = 1 << 22 + hwcap_ASIMDFHM = 1 << 23 ) func doinit() { options = []option{ - {"evtstrm", &ARM64.HasEVTSTRM}, - {"aes", &ARM64.HasAES}, - {"pmull", &ARM64.HasPMULL}, - {"sha1", &ARM64.HasSHA1}, - {"sha2", &ARM64.HasSHA2}, - {"crc32", &ARM64.HasCRC32}, - {"atomics", &ARM64.HasATOMICS}, - {"fphp", &ARM64.HasFPHP}, - {"asimdhp", &ARM64.HasASIMDHP}, - {"cpuid", &ARM64.HasCPUID}, - {"asimdrdm", &ARM64.HasASIMDRDM}, - {"jscvt", &ARM64.HasJSCVT}, - {"fcma", &ARM64.HasFCMA}, - {"lrcpc", &ARM64.HasLRCPC}, - {"dcpop", &ARM64.HasDCPOP}, - {"sha3", &ARM64.HasSHA3}, - {"sm3", &ARM64.HasSM3}, - {"sm4", &ARM64.HasSM4}, - {"asimddp", &ARM64.HasASIMDDP}, - {"sha512", &ARM64.HasSHA512}, - {"sve", &ARM64.HasSVE}, - {"asimdfhm", &ARM64.HasASIMDFHM}, + {Name: "evtstrm", Feature: &ARM64.HasEVTSTRM}, + {Name: "aes", Feature: &ARM64.HasAES}, + {Name: "pmull", Feature: &ARM64.HasPMULL}, + {Name: "sha1", Feature: &ARM64.HasSHA1}, + {Name: "sha2", Feature: &ARM64.HasSHA2}, + {Name: "crc32", Feature: &ARM64.HasCRC32}, + {Name: "atomics", Feature: &ARM64.HasATOMICS}, + {Name: "fphp", Feature: &ARM64.HasFPHP}, + {Name: "asimdhp", Feature: &ARM64.HasASIMDHP}, + {Name: "cpuid", Feature: &ARM64.HasCPUID}, + {Name: "asimdrdm", Feature: &ARM64.HasASIMDRDM}, + {Name: "jscvt", Feature: &ARM64.HasJSCVT}, + {Name: "fcma", Feature: &ARM64.HasFCMA}, + {Name: "lrcpc", Feature: &ARM64.HasLRCPC}, + {Name: "dcpop", Feature: &ARM64.HasDCPOP}, + {Name: "sha3", Feature: &ARM64.HasSHA3}, + {Name: "sm3", Feature: &ARM64.HasSM3}, + {Name: "sm4", Feature: &ARM64.HasSM4}, + {Name: "asimddp", Feature: &ARM64.HasASIMDDP}, + {Name: "sha512", Feature: &ARM64.HasSHA512}, + {Name: "sve", Feature: &ARM64.HasSVE}, + {Name: "asimdfhm", Feature: &ARM64.HasASIMDFHM}, // These capabilities should always be enabled on arm64: - // {"fp", &ARM64.HasFP}, - // {"asimd", &ARM64.HasASIMD}, + {Name: "fp", Feature: &ARM64.HasFP, Required: true}, + {Name: "asimd", Feature: &ARM64.HasASIMD, Required: true}, } // HWCAP feature bits diff --git a/libgo/go/internal/cpu/cpu_arm64_test.go b/libgo/go/internal/cpu/cpu_arm64_test.go deleted file mode 100644 index f4c419a23f3..00000000000 --- a/libgo/go/internal/cpu/cpu_arm64_test.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package cpu_test - -import ( - . "internal/cpu" - "runtime" - "testing" -) - -func TestARM64minimalFeatures(t *testing.T) { - switch runtime.GOOS { - case "linux", "android": - default: - t.Skipf("%s/arm64 is not supported", runtime.GOOS) - } - - if !ARM64.HasASIMD { - t.Fatalf("HasASIMD expected true, got false") - } - if !ARM64.HasFP { - t.Fatalf("HasFP expected true, got false") - } -} diff --git a/libgo/go/internal/cpu/cpu_no_init.go b/libgo/go/internal/cpu/cpu_no_init.go index 1be4f29dddd..777ea9de8bd 100644 --- a/libgo/go/internal/cpu/cpu_no_init.go +++ b/libgo/go/internal/cpu/cpu_no_init.go @@ -5,6 +5,7 @@ // +build !386 // +build !amd64 // +build !amd64p32 +// +build !arm // +build !arm64 // +build !ppc64 // +build !ppc64le diff --git a/libgo/go/internal/cpu/cpu_ppc64x.go b/libgo/go/internal/cpu/cpu_ppc64x.go index 5c4bed7982c..c59503fb435 100644 --- a/libgo/go/internal/cpu/cpu_ppc64x.go +++ b/libgo/go/internal/cpu/cpu_ppc64x.go @@ -9,56 +9,36 @@ package cpu // ppc64x doesn't have a 'cpuid' equivalent, so we rely on HWCAP/HWCAP2. // These are initialized by archauxv in runtime/os_linux_ppc64x.go. // These should not be changed after they are initialized. +// On aix/ppc64, these values are initialized early in the runtime in runtime/os_aix.go. var HWCap uint var HWCap2 uint // HWCAP/HWCAP2 bits. These are exposed by the kernel. const ( // ISA Level - _PPC_FEATURE2_ARCH_2_07 = 0x80000000 - _PPC_FEATURE2_ARCH_3_00 = 0x00800000 + PPC_FEATURE2_ARCH_2_07 = 0x80000000 + PPC_FEATURE2_ARCH_3_00 = 0x00800000 // CPU features - _PPC_FEATURE_HAS_ALTIVEC = 0x10000000 - _PPC_FEATURE_HAS_DFP = 0x00000400 - _PPC_FEATURE_HAS_VSX = 0x00000080 - _PPC_FEATURE2_HAS_HTM = 0x40000000 - _PPC_FEATURE2_HAS_ISEL = 0x08000000 - _PPC_FEATURE2_HAS_VEC_CRYPTO = 0x02000000 - _PPC_FEATURE2_HTM_NOSC = 0x01000000 - _PPC_FEATURE2_DARN = 0x00200000 - _PPC_FEATURE2_SCV = 0x00100000 + PPC_FEATURE2_DARN = 0x00200000 + PPC_FEATURE2_SCV = 0x00100000 ) func doinit() { options = []option{ - {"htm", &PPC64.HasHTM}, - {"htmnosc", &PPC64.HasHTMNOSC}, - {"darn", &PPC64.HasDARN}, - {"scv", &PPC64.HasSCV}, + {Name: "darn", Feature: &PPC64.HasDARN}, + {Name: "scv", Feature: &PPC64.HasSCV}, + {Name: "power9", Feature: &PPC64.IsPOWER9}, // These capabilities should always be enabled on ppc64 and ppc64le: - // {"vmx", &PPC64.HasVMX}, - // {"dfp", &PPC64.HasDFP}, - // {"vsx", &PPC64.HasVSX}, - // {"isel", &PPC64.HasISEL}, - // {"vcrypto", &PPC64.HasVCRYPTO}, + {Name: "power8", Feature: &PPC64.IsPOWER8, Required: true}, } - // HWCAP feature bits - PPC64.HasVMX = isSet(HWCap, _PPC_FEATURE_HAS_ALTIVEC) - PPC64.HasDFP = isSet(HWCap, _PPC_FEATURE_HAS_DFP) - PPC64.HasVSX = isSet(HWCap, _PPC_FEATURE_HAS_VSX) - // HWCAP2 feature bits - PPC64.IsPOWER8 = isSet(HWCap2, _PPC_FEATURE2_ARCH_2_07) - PPC64.HasHTM = isSet(HWCap2, _PPC_FEATURE2_HAS_HTM) - PPC64.HasISEL = isSet(HWCap2, _PPC_FEATURE2_HAS_ISEL) - PPC64.HasVCRYPTO = isSet(HWCap2, _PPC_FEATURE2_HAS_VEC_CRYPTO) - PPC64.HasHTMNOSC = isSet(HWCap2, _PPC_FEATURE2_HTM_NOSC) - PPC64.IsPOWER9 = isSet(HWCap2, _PPC_FEATURE2_ARCH_3_00) - PPC64.HasDARN = isSet(HWCap2, _PPC_FEATURE2_DARN) - PPC64.HasSCV = isSet(HWCap2, _PPC_FEATURE2_SCV) + PPC64.IsPOWER8 = isSet(HWCap2, PPC_FEATURE2_ARCH_2_07) + PPC64.IsPOWER9 = isSet(HWCap2, PPC_FEATURE2_ARCH_3_00) + PPC64.HasDARN = isSet(HWCap2, PPC_FEATURE2_DARN) + PPC64.HasSCV = isSet(HWCap2, PPC_FEATURE2_SCV) } func isSet(hwc uint, value uint) bool { diff --git a/libgo/go/internal/cpu/cpu_ppc64x_test.go b/libgo/go/internal/cpu/cpu_ppc64x_test.go deleted file mode 100644 index 9c43d1e8049..00000000000 --- a/libgo/go/internal/cpu/cpu_ppc64x_test.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ppc64 ppc64le - -package cpu_test - -import ( - . "internal/cpu" - "testing" -) - -func TestPPC64minimalFeatures(t *testing.T) { - if !PPC64.IsPOWER8 { - t.Fatalf("IsPOWER8 expected true, got false") - } - if !PPC64.HasVMX { - t.Fatalf("HasVMX expected true, got false") - } - if !PPC64.HasDFP { - t.Fatalf("HasDFP expected true, got false") - } - if !PPC64.HasVSX { - t.Fatalf("HasVSX expected true, got false") - } - if !PPC64.HasISEL { - t.Fatalf("HasISEL expected true, got false") - } - if !PPC64.HasVCRYPTO { - t.Fatalf("HasVCRYPTO expected true, got false") - } -} diff --git a/libgo/go/internal/cpu/cpu_s390x.go b/libgo/go/internal/cpu/cpu_s390x.go index 43fa4ad632c..81d1afab24f 100644 --- a/libgo/go/internal/cpu/cpu_s390x.go +++ b/libgo/go/internal/cpu/cpu_s390x.go @@ -16,16 +16,16 @@ type function uint8 const ( // KM{,A,C,CTR} function codes aes128 function = 18 // AES-128 - aes192 = 19 // AES-192 - aes256 = 20 // AES-256 + aes192 function = 19 // AES-192 + aes256 function = 20 // AES-256 // K{I,L}MD function codes - sha1 = 1 // SHA-1 - sha256 = 2 // SHA-256 - sha512 = 3 // SHA-512 + sha1 function = 1 // SHA-1 + sha256 function = 2 // SHA-256 + sha512 function = 3 // SHA-512 // KLMD function codes - ghash = 65 // GHASH + ghash function = 65 // GHASH ) // queryResult contains the result of a Query function @@ -54,20 +54,23 @@ type facility uint8 const ( // mandatory facilities zarch facility = 1 // z architecture mode is active - stflef = 7 // store-facility-list-extended - ldisp = 18 // long-displacement - eimm = 21 // extended-immediate + stflef facility = 7 // store-facility-list-extended + ldisp facility = 18 // long-displacement + eimm facility = 21 // extended-immediate // miscellaneous facilities - dfp = 42 // decimal-floating-point - etf3eh = 30 // extended-translation 3 enhancement + dfp facility = 42 // decimal-floating-point + etf3eh facility = 30 // extended-translation 3 enhancement // cryptography facilities - msa = 17 // message-security-assist - msa3 = 76 // message-security-assist extension 3 - msa4 = 77 // message-security-assist extension 4 - msa5 = 57 // message-security-assist extension 5 - msa8 = 146 // message-security-assist extension 8 + msa facility = 17 // message-security-assist + msa3 facility = 76 // message-security-assist extension 3 + msa4 facility = 77 // message-security-assist extension 4 + msa5 facility = 57 // message-security-assist extension 5 + msa8 facility = 146 // message-security-assist extension 8 + + // vector facilities + ve1 facility = 135 // vector-enhancements 1 // Note: vx and highgprs are excluded because they require // kernel support and so must be fetched from HWCAP. @@ -105,14 +108,15 @@ func klmdQuery() queryResult { panic("not implemented for gccgo") } func doinit() { options = []option{ - {"zarch", &S390X.HasZArch}, - {"stfle", &S390X.HasSTFLE}, - {"ldisp", &S390X.HasLDisp}, - {"msa", &S390X.HasMSA}, - {"eimm", &S390X.HasEImm}, - {"dfp", &S390X.HasDFP}, - {"etf3eh", &S390X.HasETF3Enhanced}, - {"vx", &S390X.HasVX}, + {Name: "zarch", Feature: &S390X.HasZArch}, + {Name: "stfle", Feature: &S390X.HasSTFLE}, + {Name: "ldisp", Feature: &S390X.HasLDisp}, + {Name: "msa", Feature: &S390X.HasMSA}, + {Name: "eimm", Feature: &S390X.HasEImm}, + {Name: "dfp", Feature: &S390X.HasDFP}, + {Name: "etf3eh", Feature: &S390X.HasETF3Enhanced}, + {Name: "vx", Feature: &S390X.HasVX}, + {Name: "ve1", Feature: &S390X.HasVE1}, } aes := []function{aes128, aes192, aes256} @@ -148,4 +152,7 @@ func doinit() { S390X.HasSHA512 = kimd.Has(sha512) && klmd.Has(sha512) S390X.HasGHASH = kimd.Has(ghash) // KLMD-GHASH does not exist } + if S390X.HasVX { + S390X.HasVE1 = facilities.Has(ve1) + } } diff --git a/libgo/go/internal/cpu/cpu_test.go b/libgo/go/internal/cpu/cpu_test.go index d4115a1b875..d9be38eb3e2 100644 --- a/libgo/go/internal/cpu/cpu_test.go +++ b/libgo/go/internal/cpu/cpu_test.go @@ -9,28 +9,48 @@ import ( "internal/testenv" "os" "os/exec" + "runtime" "strings" "testing" ) -func MustHaveDebugOptionsEnabled(t *testing.T) { +func TestMinimalFeatures(t *testing.T) { + if runtime.GOARCH == "arm64" { + switch runtime.GOOS { + case "linux", "android": + default: + t.Skipf("%s/%s is not supported", runtime.GOOS, runtime.GOARCH) + } + } + + for _, o := range Options { + if o.Required && !*o.Feature { + t.Errorf("%v expected true, got false", o.Name) + } + } +} + +func MustHaveDebugOptionsSupport(t *testing.T) { if !DebugOptions { - t.Skipf("skipping test: cpu feature options not enabled") + t.Skipf("skipping test: cpu feature options not supported by OS") } } func runDebugOptionsTest(t *testing.T, test string, options string) { - MustHaveDebugOptionsEnabled(t) + MustHaveDebugOptionsSupport(t) testenv.MustHaveExec(t) - env := "GODEBUGCPU=" + options + env := "GODEBUG=" + options cmd := exec.Command(os.Args[0], "-test.run="+test) - cmd.Env = append(cmd.Env, env) + cmd.Env = append(os.Environ(), env) output, err := cmd.CombinedOutput() - got := strings.TrimSpace(string(output)) + lines := strings.Fields(string(output)) + lastline := lines[len(lines)-1] + + got := strings.TrimSpace(lastline) want := "PASS" if err != nil || got != want { t.Fatalf("%s with %s: want %s, got %v", test, env, want, got) @@ -38,19 +58,20 @@ func runDebugOptionsTest(t *testing.T, test string, options string) { } func TestDisableAllCapabilities(t *testing.T) { - runDebugOptionsTest(t, "TestAllCapabilitiesDisabled", "all=0") + runDebugOptionsTest(t, "TestAllCapabilitiesDisabled", "cpu.all=off") } func TestAllCapabilitiesDisabled(t *testing.T) { - MustHaveDebugOptionsEnabled(t) + MustHaveDebugOptionsSupport(t) - if os.Getenv("GODEBUGCPU") != "all=0" { - t.Skipf("skipping test: GODEBUGCPU=all=0 not set") + if os.Getenv("GODEBUG") != "cpu.all=off" { + t.Skipf("skipping test: GODEBUG=cpu.all=off not set") } for _, o := range Options { - if got := *o.Feature; got != false { - t.Errorf("%v: expected false, got %v", o.Name, got) + want := o.Required + if got := *o.Feature; got != want { + t.Errorf("%v: expected %v, got %v", o.Name, want, got) } } } diff --git a/libgo/go/internal/cpu/cpu_x86.go b/libgo/go/internal/cpu/cpu_x86.go index 5f159651d88..fc9b9d374df 100644 --- a/libgo/go/internal/cpu/cpu_x86.go +++ b/libgo/go/internal/cpu/cpu_x86.go @@ -38,28 +38,23 @@ const ( func doinit() { options = []option{ - {"adx", &X86.HasADX}, - {"aes", &X86.HasAES}, - {"avx", &X86.HasAVX}, - {"avx2", &X86.HasAVX2}, - {"bmi1", &X86.HasBMI1}, - {"bmi2", &X86.HasBMI2}, - {"erms", &X86.HasERMS}, - {"fma", &X86.HasFMA}, - {"pclmulqdq", &X86.HasPCLMULQDQ}, - {"popcnt", &X86.HasPOPCNT}, - {"sse3", &X86.HasSSE3}, - {"sse41", &X86.HasSSE41}, - {"sse42", &X86.HasSSE42}, - {"ssse3", &X86.HasSSSE3}, - - // sse2 set as last element so it can easily be removed again. See code below. - {"sse2", &X86.HasSSE2}, - } - - // Remove sse2 from options on amd64(p32) because SSE2 is a mandatory feature for these GOARCHs. - if GOARCH == "amd64" || GOARCH == "amd64p32" { - options = options[:len(options)-1] + {Name: "adx", Feature: &X86.HasADX}, + {Name: "aes", Feature: &X86.HasAES}, + {Name: "avx", Feature: &X86.HasAVX}, + {Name: "avx2", Feature: &X86.HasAVX2}, + {Name: "bmi1", Feature: &X86.HasBMI1}, + {Name: "bmi2", Feature: &X86.HasBMI2}, + {Name: "erms", Feature: &X86.HasERMS}, + {Name: "fma", Feature: &X86.HasFMA}, + {Name: "pclmulqdq", Feature: &X86.HasPCLMULQDQ}, + {Name: "popcnt", Feature: &X86.HasPOPCNT}, + {Name: "sse3", Feature: &X86.HasSSE3}, + {Name: "sse41", Feature: &X86.HasSSE41}, + {Name: "sse42", Feature: &X86.HasSSE42}, + {Name: "ssse3", Feature: &X86.HasSSSE3}, + + // These capabilities should always be enabled on amd64(p32): + {Name: "sse2", Feature: &X86.HasSSE2, Required: GOARCH == "amd64" || GOARCH == "amd64p32"}, } maxID, _, _, _ := cpuid(0, 0) diff --git a/libgo/go/internal/cpu/cpu_x86_test.go b/libgo/go/internal/cpu/cpu_x86_test.go index d03306c907a..9e93d1af5d7 100644 --- a/libgo/go/internal/cpu/cpu_x86_test.go +++ b/libgo/go/internal/cpu/cpu_x86_test.go @@ -13,16 +13,6 @@ import ( "testing" ) -func TestAMD64minimalFeatures(t *testing.T) { - if runtime.GOARCH != "amd64" { - return - } - - if !X86.HasSSE2 { - t.Fatalf("HasSSE2 expected true, got false") - } -} - func TestX86ifAVX2hasAVX(t *testing.T) { if X86.HasAVX2 && !X86.HasAVX { t.Fatalf("HasAVX expected true when HasAVX2 is true, got false") @@ -30,14 +20,14 @@ func TestX86ifAVX2hasAVX(t *testing.T) { } func TestDisableSSE2(t *testing.T) { - runDebugOptionsTest(t, "TestSSE2DebugOption", "sse2=0") + runDebugOptionsTest(t, "TestSSE2DebugOption", "cpu.sse2=off") } func TestSSE2DebugOption(t *testing.T) { - MustHaveDebugOptionsEnabled(t) + MustHaveDebugOptionsSupport(t) - if os.Getenv("GODEBUGCPU") != "sse2=0" { - t.Skipf("skipping test: GODEBUGCPU=sse2=0 not set") + if os.Getenv("GODEBUG") != "cpu.sse2=off" { + t.Skipf("skipping test: GODEBUG=cpu.sse2=off not set") } want := runtime.GOARCH != "386" // SSE2 can only be disabled on 386. @@ -45,3 +35,20 @@ func TestSSE2DebugOption(t *testing.T) { t.Errorf("X86.HasSSE2 on %s expected %v, got %v", runtime.GOARCH, want, got) } } + +func TestDisableSSE3(t *testing.T) { + runDebugOptionsTest(t, "TestSSE3DebugOption", "cpu.sse3=off") +} + +func TestSSE3DebugOption(t *testing.T) { + MustHaveDebugOptionsSupport(t) + + if os.Getenv("GODEBUG") != "cpu.sse3=off" { + t.Skipf("skipping test: GODEBUG=cpu.sse3=off not set") + } + + want := false + if got := X86.HasSSE3; got != want { + t.Errorf("X86.HasSSE3 expected %v, got %v", want, got) + } +} diff --git a/libgo/go/internal/fmtsort/export_test.go b/libgo/go/internal/fmtsort/export_test.go new file mode 100644 index 00000000000..25cbb5d4fca --- /dev/null +++ b/libgo/go/internal/fmtsort/export_test.go @@ -0,0 +1,11 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package fmtsort + +import "reflect" + +func Compare(a, b reflect.Value) int { + return compare(a, b) +} diff --git a/libgo/go/internal/fmtsort/sort.go b/libgo/go/internal/fmtsort/sort.go new file mode 100644 index 00000000000..c959cbee1f8 --- /dev/null +++ b/libgo/go/internal/fmtsort/sort.go @@ -0,0 +1,216 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package fmtsort provides a general stable ordering mechanism +// for maps, on behalf of the fmt and text/template packages. +// It is not guaranteed to be efficient and works only for types +// that are valid map keys. +package fmtsort + +import ( + "reflect" + "sort" +) + +// Note: Throughout this package we avoid calling reflect.Value.Interface as +// it is not always legal to do so and it's easier to avoid the issue than to face it. + +// SortedMap represents a map's keys and values. The keys and values are +// aligned in index order: Value[i] is the value in the map corresponding to Key[i]. +type SortedMap struct { + Key []reflect.Value + Value []reflect.Value +} + +func (o *SortedMap) Len() int { return len(o.Key) } +func (o *SortedMap) Less(i, j int) bool { return compare(o.Key[i], o.Key[j]) < 0 } +func (o *SortedMap) Swap(i, j int) { + o.Key[i], o.Key[j] = o.Key[j], o.Key[i] + o.Value[i], o.Value[j] = o.Value[j], o.Value[i] +} + +// Sort accepts a map and returns a SortedMap that has the same keys and +// values but in a stable sorted order according to the keys, modulo issues +// raised by unorderable key values such as NaNs. +// +// The ordering rules are more general than with Go's < operator: +// +// - when applicable, nil compares low +// - ints, floats, and strings order by < +// - NaN compares less than non-NaN floats +// - bool compares false before true +// - complex compares real, then imag +// - pointers compare by machine address +// - channel values compare by machine address +// - structs compare each field in turn +// - arrays compare each element in turn. +// Otherwise identical arrays compare by length. +// - interface values compare first by reflect.Type describing the concrete type +// and then by concrete value as described in the previous rules. +// +func Sort(mapValue reflect.Value) *SortedMap { + if mapValue.Type().Kind() != reflect.Map { + return nil + } + key := make([]reflect.Value, mapValue.Len()) + value := make([]reflect.Value, len(key)) + iter := mapValue.MapRange() + for i := 0; iter.Next(); i++ { + key[i] = iter.Key() + value[i] = iter.Value() + } + sorted := &SortedMap{ + Key: key, + Value: value, + } + sort.Stable(sorted) + return sorted +} + +// compare compares two values of the same type. It returns -1, 0, 1 +// according to whether a > b (1), a == b (0), or a < b (-1). +// If the types differ, it returns -1. +// See the comment on Sort for the comparison rules. +func compare(aVal, bVal reflect.Value) int { + aType, bType := aVal.Type(), bVal.Type() + if aType != bType { + return -1 // No good answer possible, but don't return 0: they're not equal. + } + switch aVal.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + a, b := aVal.Int(), bVal.Int() + switch { + case a < b: + return -1 + case a > b: + return 1 + default: + return 0 + } + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + a, b := aVal.Uint(), bVal.Uint() + switch { + case a < b: + return -1 + case a > b: + return 1 + default: + return 0 + } + case reflect.String: + a, b := aVal.String(), bVal.String() + switch { + case a < b: + return -1 + case a > b: + return 1 + default: + return 0 + } + case reflect.Float32, reflect.Float64: + return floatCompare(aVal.Float(), bVal.Float()) + case reflect.Complex64, reflect.Complex128: + a, b := aVal.Complex(), bVal.Complex() + if c := floatCompare(real(a), real(b)); c != 0 { + return c + } + return floatCompare(imag(a), imag(b)) + case reflect.Bool: + a, b := aVal.Bool(), bVal.Bool() + switch { + case a == b: + return 0 + case a: + return 1 + default: + return -1 + } + case reflect.Ptr: + a, b := aVal.Pointer(), bVal.Pointer() + switch { + case a < b: + return -1 + case a > b: + return 1 + default: + return 0 + } + case reflect.Chan: + if c, ok := nilCompare(aVal, bVal); ok { + return c + } + ap, bp := aVal.Pointer(), bVal.Pointer() + switch { + case ap < bp: + return -1 + case ap > bp: + return 1 + default: + return 0 + } + case reflect.Struct: + for i := 0; i < aVal.NumField(); i++ { + if c := compare(aVal.Field(i), bVal.Field(i)); c != 0 { + return c + } + } + return 0 + case reflect.Array: + for i := 0; i < aVal.Len(); i++ { + if c := compare(aVal.Index(i), bVal.Index(i)); c != 0 { + return c + } + } + return 0 + case reflect.Interface: + if c, ok := nilCompare(aVal, bVal); ok { + return c + } + c := compare(reflect.ValueOf(aType), reflect.ValueOf(bType)) + if c != 0 { + return c + } + return compare(aVal.Elem(), bVal.Elem()) + default: + // Certain types cannot appear as keys (maps, funcs, slices), but be explicit. + panic("bad type in compare: " + aType.String()) + } +} + +// nilCompare checks whether either value is nil. If not, the boolean is false. +// If either value is nil, the boolean is true and the integer is the comparison +// value. The comparison is defined to be 0 if both are nil, otherwise the one +// nil value compares low. Both arguments must represent a chan, func, +// interface, map, pointer, or slice. +func nilCompare(aVal, bVal reflect.Value) (int, bool) { + if aVal.IsNil() { + if bVal.IsNil() { + return 0, true + } + return -1, true + } + if bVal.IsNil() { + return 1, true + } + return 0, false +} + +// floatCompare compares two floating-point values. NaNs compare low. +func floatCompare(a, b float64) int { + switch { + case isNaN(a): + return -1 // No good answer if b is a NaN so don't bother checking. + case isNaN(b): + return 1 + case a < b: + return -1 + case a > b: + return 1 + } + return 0 +} + +func isNaN(a float64) bool { + return a != a +} diff --git a/libgo/go/internal/fmtsort/sort_test.go b/libgo/go/internal/fmtsort/sort_test.go new file mode 100644 index 00000000000..6b10c775b0e --- /dev/null +++ b/libgo/go/internal/fmtsort/sort_test.go @@ -0,0 +1,212 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package fmtsort_test + +import ( + "fmt" + "internal/fmtsort" + "math" + "reflect" + "strings" + "testing" +) + +var compareTests = [][]reflect.Value{ + ct(reflect.TypeOf(int(0)), -1, 0, 1), + ct(reflect.TypeOf(int8(0)), -1, 0, 1), + ct(reflect.TypeOf(int16(0)), -1, 0, 1), + ct(reflect.TypeOf(int32(0)), -1, 0, 1), + ct(reflect.TypeOf(int64(0)), -1, 0, 1), + ct(reflect.TypeOf(uint(0)), 0, 1, 5), + ct(reflect.TypeOf(uint8(0)), 0, 1, 5), + ct(reflect.TypeOf(uint16(0)), 0, 1, 5), + ct(reflect.TypeOf(uint32(0)), 0, 1, 5), + ct(reflect.TypeOf(uint64(0)), 0, 1, 5), + ct(reflect.TypeOf(uintptr(0)), 0, 1, 5), + ct(reflect.TypeOf(string("")), "", "a", "ab"), + ct(reflect.TypeOf(float32(0)), math.NaN(), math.Inf(-1), -1e10, 0, 1e10, math.Inf(1)), + ct(reflect.TypeOf(float64(0)), math.NaN(), math.Inf(-1), -1e10, 0, 1e10, math.Inf(1)), + ct(reflect.TypeOf(complex64(0+1i)), -1-1i, -1+0i, -1+1i, 0-1i, 0+0i, 0+1i, 1-1i, 1+0i, 1+1i), + ct(reflect.TypeOf(complex128(0+1i)), -1-1i, -1+0i, -1+1i, 0-1i, 0+0i, 0+1i, 1-1i, 1+0i, 1+1i), + ct(reflect.TypeOf(false), false, true), + ct(reflect.TypeOf(&ints[0]), &ints[0], &ints[1], &ints[2]), + ct(reflect.TypeOf(chans[0]), chans[0], chans[1], chans[2]), + ct(reflect.TypeOf(toy{}), toy{0, 1}, toy{0, 2}, toy{1, -1}, toy{1, 1}), + ct(reflect.TypeOf([2]int{}), [2]int{1, 1}, [2]int{1, 2}, [2]int{2, 0}), + ct(reflect.TypeOf(interface{}(interface{}(0))), iFace, 1, 2, 3), +} + +var iFace interface{} + +func ct(typ reflect.Type, args ...interface{}) []reflect.Value { + value := make([]reflect.Value, len(args)) + for i, v := range args { + x := reflect.ValueOf(v) + if !x.IsValid() { // Make it a typed nil. + x = reflect.Zero(typ) + } else { + x = x.Convert(typ) + } + value[i] = x + } + return value +} + +func TestCompare(t *testing.T) { + for _, test := range compareTests { + for i, v0 := range test { + for j, v1 := range test { + c := fmtsort.Compare(v0, v1) + var expect int + switch { + case i == j: + expect = 0 + // NaNs are tricky. + if typ := v0.Type(); (typ.Kind() == reflect.Float32 || typ.Kind() == reflect.Float64) && math.IsNaN(v0.Float()) { + expect = -1 + } + case i < j: + expect = -1 + case i > j: + expect = 1 + } + if c != expect { + t.Errorf("%s: compare(%v,%v)=%d; expect %d", v0.Type(), v0, v1, c, expect) + } + } + } + } +} + +type sortTest struct { + data interface{} // Always a map. + print string // Printed result using our custom printer. +} + +var sortTests = []sortTest{ + { + map[int]string{7: "bar", -3: "foo"}, + "-3:foo 7:bar", + }, + { + map[uint8]string{7: "bar", 3: "foo"}, + "3:foo 7:bar", + }, + { + map[string]string{"7": "bar", "3": "foo"}, + "3:foo 7:bar", + }, + { + map[float64]string{7: "bar", -3: "foo", math.NaN(): "nan", math.Inf(0): "inf"}, + "NaN:nan -3:foo 7:bar +Inf:inf", + }, + { + map[complex128]string{7 + 2i: "bar2", 7 + 1i: "bar", -3: "foo", complex(math.NaN(), 0i): "nan", complex(math.Inf(0), 0i): "inf"}, + "(NaN+0i):nan (-3+0i):foo (7+1i):bar (7+2i):bar2 (+Inf+0i):inf", + }, + { + map[bool]string{true: "true", false: "false"}, + "false:false true:true", + }, + { + chanMap(), + "CHAN0:0 CHAN1:1 CHAN2:2", + }, + { + pointerMap(), + "PTR0:0 PTR1:1 PTR2:2", + }, + { + map[toy]string{toy{7, 2}: "72", toy{7, 1}: "71", toy{3, 4}: "34"}, + "{3 4}:34 {7 1}:71 {7 2}:72", + }, + { + map[[2]int]string{{7, 2}: "72", {7, 1}: "71", {3, 4}: "34"}, + "[3 4]:34 [7 1]:71 [7 2]:72", + }, + { + map[interface{}]string{7: "7", 4: "4", 3: "3", nil: "nil"}, + ":nil 3:3 4:4 7:7", + }, +} + +func sprint(data interface{}) string { + om := fmtsort.Sort(reflect.ValueOf(data)) + if om == nil { + return "nil" + } + b := new(strings.Builder) + for i, key := range om.Key { + if i > 0 { + b.WriteRune(' ') + } + b.WriteString(sprintKey(key)) + b.WriteRune(':') + b.WriteString(fmt.Sprint(om.Value[i])) + } + return b.String() +} + +// sprintKey formats a reflect.Value but gives reproducible values for some +// problematic types such as pointers. Note that it only does special handling +// for the troublesome types used in the test cases; it is not a general +// printer. +func sprintKey(key reflect.Value) string { + switch str := key.Type().String(); str { + case "*int": + ptr := key.Interface().(*int) + for i := range ints { + if ptr == &ints[i] { + return fmt.Sprintf("PTR%d", i) + } + } + return "PTR???" + case "chan int": + c := key.Interface().(chan int) + for i := range chans { + if c == chans[i] { + return fmt.Sprintf("CHAN%d", i) + } + } + return "CHAN???" + default: + return fmt.Sprint(key) + } +} + +var ( + ints [3]int + chans = [3]chan int{make(chan int), make(chan int), make(chan int)} +) + +func pointerMap() map[*int]string { + m := make(map[*int]string) + for i := 2; i >= 0; i-- { + m[&ints[i]] = fmt.Sprint(i) + } + return m +} + +func chanMap() map[chan int]string { + m := make(map[chan int]string) + for i := 2; i >= 0; i-- { + m[chans[i]] = fmt.Sprint(i) + } + return m +} + +type toy struct { + A int // Exported. + b int // Unexported. +} + +func TestOrder(t *testing.T) { + for _, test := range sortTests { + got := sprint(test.data) + if got != test.print { + t.Errorf("%s: got %q, want %q", reflect.TypeOf(test.data), got, test.print) + } + } +} diff --git a/libgo/go/internal/goroot/gc.go b/libgo/go/internal/goroot/gc.go index ce4c1e526fc..9d846d8c49a 100644 --- a/libgo/go/internal/goroot/gc.go +++ b/libgo/go/internal/goroot/gc.go @@ -10,12 +10,11 @@ import ( "os" "os/exec" "path/filepath" - "runtime" "strings" "sync" ) -// IsStandardPackage returns whether path is a standard package, +// IsStandardPackage reports whether path is a standard package, // given goroot and compiler. func IsStandardPackage(goroot, compiler, path string) bool { switch compiler { @@ -96,7 +95,7 @@ func (gd *gccgoDirs) init() { gd.dirs = append(gd.dirs, lastDirs...) } -// isStandard returns whether path is a standard library for gccgo. +// isStandard reports whether path is a standard library for gccgo. func (gd *gccgoDirs) isStandard(path string) bool { // Quick check: if the first path component has a '.', it's not // in the standard library. This skips most GOPATH directories. diff --git a/libgo/go/internal/goroot/gccgo.go b/libgo/go/internal/goroot/gccgo.go index 098e77d893f..3530e59a15f 100644 --- a/libgo/go/internal/goroot/gccgo.go +++ b/libgo/go/internal/goroot/gccgo.go @@ -11,7 +11,7 @@ import ( "path/filepath" ) -// IsStandardPackage returns whether path is a standard package, +// IsStandardPackage reports whether path is a standard package, // given goroot and compiler. func IsStandardPackage(goroot, compiler, path string) bool { switch compiler { diff --git a/libgo/go/internal/poll/fd_fsync_darwin.go b/libgo/go/internal/poll/fd_fsync_darwin.go new file mode 100644 index 00000000000..6cd3f91e8b2 --- /dev/null +++ b/libgo/go/internal/poll/fd_fsync_darwin.go @@ -0,0 +1,38 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package poll + +import ( + "syscall" + _ "unsafe" // for go:linkname +) + +// Fsync invokes SYS_FCNTL with SYS_FULLFSYNC because +// on OS X, SYS_FSYNC doesn't fully flush contents to disk. +// See Issue #26650 as well as the man page for fsync on OS X. +func (fd *FD) Fsync() error { + if err := fd.incref(); err != nil { + return err + } + defer fd.decref() + + _, e1 := fcntl(fd.Sysfd, syscall.F_FULLFSYNC, 0) + return e1 +} + +// Use a helper function to call fcntl. This is defined in C in +// libgo/runtime. +//extern __go_fcntl_uintptr +func libc_fcntl(uintptr, uintptr, uintptr) (uintptr, uintptr) + +func fcntl(fd int, cmd int, arg int) (int, error) { + syscall.Entersyscall() + r, e := libc_fcntl(uintptr(fd), uintptr(cmd), uintptr(arg)) + syscall.Exitsyscall() + if e != 0 { + return int(r), syscall.Errno(e) + } + return int(r), nil +} diff --git a/libgo/go/internal/poll/fd_fsync_posix.go b/libgo/go/internal/poll/fd_fsync_posix.go new file mode 100644 index 00000000000..a60891f67c8 --- /dev/null +++ b/libgo/go/internal/poll/fd_fsync_posix.go @@ -0,0 +1,33 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build aix dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris + +package poll + +import "syscall" + +// Use a helper function to call fcntl. This is defined in C in +// libgo/runtime. +//extern __go_fcntl_uintptr +func libc_fcntl(uintptr, uintptr, uintptr) (uintptr, uintptr) + +// Fsync wraps syscall.Fsync. +func (fd *FD) Fsync() error { + if err := fd.incref(); err != nil { + return err + } + defer fd.decref() + return syscall.Fsync(fd.Sysfd) +} + +func fcntl(fd int, cmd int, arg int) (int, error) { + syscall.Entersyscall() + r, e := libc_fcntl(uintptr(fd), uintptr(cmd), uintptr(arg)) + syscall.Exitsyscall() + if e != 0 { + return int(r), syscall.Errno(e) + } + return int(r), nil +} diff --git a/libgo/go/internal/poll/fd_fsync_windows.go b/libgo/go/internal/poll/fd_fsync_windows.go new file mode 100644 index 00000000000..fb1211985db --- /dev/null +++ b/libgo/go/internal/poll/fd_fsync_windows.go @@ -0,0 +1,16 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package poll + +import "syscall" + +// Fsync wraps syscall.Fsync. +func (fd *FD) Fsync() error { + if err := fd.incref(); err != nil { + return err + } + defer fd.decref() + return syscall.Fsync(fd.Sysfd) +} diff --git a/libgo/go/internal/poll/fd_opendir_ios.go b/libgo/go/internal/poll/fd_opendir_ios.go new file mode 100644 index 00000000000..e646bd9a965 --- /dev/null +++ b/libgo/go/internal/poll/fd_opendir_ios.go @@ -0,0 +1,35 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build darwin +// +build arm arm64 + +package poll + +import ( + "syscall" + _ "unsafe" // for go:linkname +) + +// OpenDir returns a pointer to a DIR structure suitable for +// ReadDir. In case of an error, the name of the failed +// syscall is returned along with a syscall.Errno. +func (fd *FD) OpenDir() (uintptr, string, error) { + // fdopendir(3) takes control of the file descriptor, + // so use a dup. + fd2, call, err := fd.Dup() + if err != nil { + return 0, call, err + } + dir, err := fdopendir(fd2) + if err != nil { + syscall.Close(fd2) + return 0, "fdopendir", err + } + return dir, "", nil +} + +// Implemented in syscall/syscall_darwin.go. +//go:linkname fdopendir syscall.fdopendir +func fdopendir(fd int) (dir uintptr, err error) diff --git a/libgo/go/internal/poll/fd_plan9.go b/libgo/go/internal/poll/fd_plan9.go index 107f4545233..0fce32915e7 100644 --- a/libgo/go/internal/poll/fd_plan9.go +++ b/libgo/go/internal/poll/fd_plan9.go @@ -193,10 +193,10 @@ func isInterrupted(err error) bool { return err != nil && stringsHasSuffix(err.Error(), "interrupted") } -// PollDescriptor returns the descriptor being used by the poller, -// or ^uintptr(0) if there isn't one. This is only used for testing. -func PollDescriptor() uintptr { - return ^uintptr(0) +// IsPollDescriptor reports whether fd is the descriptor being used by the poller. +// This is only used for testing. +func IsPollDescriptor(fd uintptr) bool { + return false } // RawControl invokes the user-defined function f for a non-IO diff --git a/libgo/go/internal/poll/fd_poll_nacljs.go b/libgo/go/internal/poll/fd_poll_nacljs.go index 832dddb4aa4..0871f342d42 100644 --- a/libgo/go/internal/poll/fd_poll_nacljs.go +++ b/libgo/go/internal/poll/fd_poll_nacljs.go @@ -92,8 +92,8 @@ func setDeadlineImpl(fd *FD, t time.Time, mode int) error { return nil } -// PollDescriptor returns the descriptor being used by the poller, -// or ^uintptr(0) if there isn't one. This is only used for testing. -func PollDescriptor() uintptr { - return ^uintptr(0) +// IsPollDescriptor reports whether fd is the descriptor being used by the poller. +// This is only used for testing. +func IsPollDescriptor(fd uintptr) bool { + return false } diff --git a/libgo/go/internal/poll/fd_poll_runtime.go b/libgo/go/internal/poll/fd_poll_runtime.go index b91cbe40e48..687f702556f 100644 --- a/libgo/go/internal/poll/fd_poll_runtime.go +++ b/libgo/go/internal/poll/fd_poll_runtime.go @@ -11,13 +11,14 @@ import ( "sync" "syscall" "time" + _ "unsafe" // for go:linkname ) // runtimeNano returns the current value of the runtime clock in nanoseconds. +//go:linkname runtimeNano runtime.nanotime func runtimeNano() int64 func runtime_pollServerInit() -func runtime_pollServerDescriptor() uintptr func runtime_pollOpen(fd uintptr) (uintptr, int) func runtime_pollClose(ctx uintptr) func runtime_pollWait(ctx uintptr, mode int) int @@ -25,6 +26,7 @@ func runtime_pollWaitCanceled(ctx uintptr, mode int) int func runtime_pollReset(ctx uintptr, mode int) int func runtime_pollSetDeadline(ctx uintptr, d int64, mode int) func runtime_pollUnblock(ctx uintptr) +func runtime_isPollServerDescriptor(fd uintptr) bool type pollDesc struct { runtimeCtx uintptr @@ -134,15 +136,12 @@ func (fd *FD) SetWriteDeadline(t time.Time) error { } func setDeadlineImpl(fd *FD, t time.Time, mode int) error { - diff := int64(time.Until(t)) - d := runtimeNano() + diff - if d <= 0 && diff > 0 { - // If the user has a deadline in the future, but the delay calculation - // overflows, then set the deadline to the maximum possible value. - d = 1<<63 - 1 - } - if t.IsZero() { - d = 0 + var d int64 + if !t.IsZero() { + d = int64(time.Until(t)) + if d == 0 { + d = -1 // don't confuse deadline right now with no deadline + } } if err := fd.incref(); err != nil { return err @@ -155,8 +154,8 @@ func setDeadlineImpl(fd *FD, t time.Time, mode int) error { return nil } -// PollDescriptor returns the descriptor being used by the poller, -// or ^uintptr(0) if there isn't one. This is only used for testing. -func PollDescriptor() uintptr { - return runtime_pollServerDescriptor() +// IsPollDescriptor reports whether fd is the descriptor being used by the poller. +// This is only used for testing. +func IsPollDescriptor(fd uintptr) bool { + return runtime_isPollServerDescriptor(fd) } diff --git a/libgo/go/internal/poll/fd_posix.go b/libgo/go/internal/poll/fd_posix.go index 23ad7a0a817..b43ad517996 100644 --- a/libgo/go/internal/poll/fd_posix.go +++ b/libgo/go/internal/poll/fd_posix.go @@ -46,12 +46,3 @@ func (fd *FD) Ftruncate(size int64) error { defer fd.decref() return syscall.Ftruncate(fd.Sysfd, size) } - -// Fsync wraps syscall.Fsync. -func (fd *FD) Fsync() error { - if err := fd.incref(); err != nil { - return err - } - defer fd.decref() - return syscall.Fsync(fd.Sysfd) -} diff --git a/libgo/go/internal/poll/fd_unix.go b/libgo/go/internal/poll/fd_unix.go index 28bc32f006f..8185269c53c 100644 --- a/libgo/go/internal/poll/fd_unix.go +++ b/libgo/go/internal/poll/fd_unix.go @@ -445,11 +445,6 @@ func (fd *FD) Fstat(s *syscall.Stat_t) error { return syscall.Fstat(fd.Sysfd, s) } -// Use a helper function to call fcntl. This is defined in C in -// libgo/runtime. -//extern __go_fcntl_uintptr -func fcntl(uintptr, uintptr, uintptr) (uintptr, uintptr) - // tryDupCloexec indicates whether F_DUPFD_CLOEXEC should be used. // If the kernel doesn't support it, this is set to 0. var tryDupCloexec = int32(1) @@ -457,13 +452,11 @@ var tryDupCloexec = int32(1) // DupCloseOnExec dups fd and marks it close-on-exec. func DupCloseOnExec(fd int) (int, string, error) { if atomic.LoadInt32(&tryDupCloexec) == 1 { - syscall.Entersyscall() - r0, errno := fcntl(uintptr(fd), syscall.F_DUPFD_CLOEXEC, 0) - syscall.Exitsyscall() - e1 := syscall.Errno(errno) - switch e1 { - case 0: - return int(r0), "", nil + r0, e1 := fcntl(fd, syscall.F_DUPFD_CLOEXEC, 0) + if e1 == nil { + return r0, "", nil + } + switch e1.(syscall.Errno) { case syscall.EINVAL, syscall.ENOSYS: // Old kernel, or js/wasm (which returns // ENOSYS). Fall back to the portable way from diff --git a/libgo/go/internal/poll/fd_windows.go b/libgo/go/internal/poll/fd_windows.go index d04d332696d..19d9a12dad8 100644 --- a/libgo/go/internal/poll/fd_windows.go +++ b/libgo/go/internal/poll/fd_windows.go @@ -116,11 +116,17 @@ func (o *operation) InitBufs(buf *[][]byte) { o.bufs = o.bufs[:0] } for _, b := range *buf { - var p *byte + if len(b) == 0 { + o.bufs = append(o.bufs, syscall.WSABuf{}) + continue + } + for len(b) > maxRW { + o.bufs = append(o.bufs, syscall.WSABuf{Len: maxRW, Buf: &b[0]}) + b = b[maxRW:] + } if len(b) > 0 { - p = &b[0] + o.bufs = append(o.bufs, syscall.WSABuf{Len: uint32(len(b)), Buf: &b[0]}) } - o.bufs = append(o.bufs, syscall.WSABuf{Len: uint32(len(b)), Buf: p}) } } @@ -461,6 +467,11 @@ func (fd *FD) Shutdown(how int) error { return syscall.Shutdown(fd.Sysfd, how) } +// Windows ReadFile and WSARecv use DWORD (uint32) parameter to pass buffer length. +// This prevents us reading blocks larger than 4GB. +// See golang.org/issue/26923. +const maxRW = 1 << 30 // 1GB is large enough and keeps subsequent reads aligned + // Read implements io.Reader. func (fd *FD) Read(buf []byte) (int, error) { if err := fd.readLock(); err != nil { @@ -468,6 +479,10 @@ func (fd *FD) Read(buf []byte) (int, error) { } defer fd.readUnlock() + if len(buf) > maxRW { + buf = buf[:maxRW] + } + var n int var err error if fd.isFile || fd.isDir || fd.isConsole { @@ -581,6 +596,10 @@ func (fd *FD) Pread(b []byte, off int64) (int, error) { } defer fd.decref() + if len(b) > maxRW { + b = b[:maxRW] + } + fd.l.Lock() defer fd.l.Unlock() curoffset, e := syscall.Seek(fd.Sysfd, 0, io.SeekCurrent) @@ -611,6 +630,9 @@ func (fd *FD) ReadFrom(buf []byte) (int, syscall.Sockaddr, error) { if len(buf) == 0 { return 0, nil, nil } + if len(buf) > maxRW { + buf = buf[:maxRW] + } if err := fd.readLock(); err != nil { return 0, nil, err } @@ -639,30 +661,42 @@ func (fd *FD) Write(buf []byte) (int, error) { } defer fd.writeUnlock() - var n int - var err error - if fd.isFile || fd.isDir || fd.isConsole { - fd.l.Lock() - defer fd.l.Unlock() - if fd.isConsole { - n, err = fd.writeConsole(buf) + ntotal := 0 + for len(buf) > 0 { + b := buf + if len(b) > maxRW { + b = b[:maxRW] + } + var n int + var err error + if fd.isFile || fd.isDir || fd.isConsole { + fd.l.Lock() + defer fd.l.Unlock() + if fd.isConsole { + n, err = fd.writeConsole(b) + } else { + n, err = syscall.Write(fd.Sysfd, b) + } + if err != nil { + n = 0 + } } else { - n, err = syscall.Write(fd.Sysfd, buf) + if race.Enabled { + race.ReleaseMerge(unsafe.Pointer(&ioSync)) + } + o := &fd.wop + o.InitBuf(b) + n, err = wsrv.ExecIO(o, func(o *operation) error { + return syscall.WSASend(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, &o.o, nil) + }) } + ntotal += n if err != nil { - n = 0 + return ntotal, err } - } else { - if race.Enabled { - race.ReleaseMerge(unsafe.Pointer(&ioSync)) - } - o := &fd.wop - o.InitBuf(buf) - n, err = wsrv.ExecIO(o, func(o *operation) error { - return syscall.WSASend(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, &o.o, nil) - }) + buf = buf[n:] } - return n, err + return ntotal, nil } // writeConsole writes len(b) bytes to the console File. @@ -709,7 +743,7 @@ func (fd *FD) writeConsole(b []byte) (int, error) { } // Pwrite emulates the Unix pwrite system call. -func (fd *FD) Pwrite(b []byte, off int64) (int, error) { +func (fd *FD) Pwrite(buf []byte, off int64) (int, error) { // Call incref, not writeLock, because since pwrite specifies the // offset it is independent from other writes. if err := fd.incref(); err != nil { @@ -724,16 +758,27 @@ func (fd *FD) Pwrite(b []byte, off int64) (int, error) { return 0, e } defer syscall.Seek(fd.Sysfd, curoffset, io.SeekStart) - o := syscall.Overlapped{ - OffsetHigh: uint32(off >> 32), - Offset: uint32(off), - } - var done uint32 - e = syscall.WriteFile(fd.Sysfd, b, &done, &o) - if e != nil { - return 0, e + + ntotal := 0 + for len(buf) > 0 { + b := buf + if len(b) > maxRW { + b = b[:maxRW] + } + var n uint32 + o := syscall.Overlapped{ + OffsetHigh: uint32(off >> 32), + Offset: uint32(off), + } + e = syscall.WriteFile(fd.Sysfd, b, &n, &o) + ntotal += int(n) + if e != nil { + return ntotal, e + } + buf = buf[n:] + off += int64(n) } - return int(done), nil + return ntotal, nil } // Writev emulates the Unix writev system call. @@ -761,20 +806,41 @@ func (fd *FD) Writev(buf *[][]byte) (int64, error) { // WriteTo wraps the sendto network call. func (fd *FD) WriteTo(buf []byte, sa syscall.Sockaddr) (int, error) { - if len(buf) == 0 { - return 0, nil - } if err := fd.writeLock(); err != nil { return 0, err } defer fd.writeUnlock() - o := &fd.wop - o.InitBuf(buf) - o.sa = sa - n, err := wsrv.ExecIO(o, func(o *operation) error { - return syscall.WSASendto(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, o.sa, &o.o, nil) - }) - return n, err + + if len(buf) == 0 { + // handle zero-byte payload + o := &fd.wop + o.InitBuf(buf) + o.sa = sa + n, err := wsrv.ExecIO(o, func(o *operation) error { + return syscall.WSASendto(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, o.sa, &o.o, nil) + }) + return n, err + } + + ntotal := 0 + for len(buf) > 0 { + b := buf + if len(b) > maxRW { + b = b[:maxRW] + } + o := &fd.wop + o.InitBuf(b) + o.sa = sa + n, err := wsrv.ExecIO(o, func(o *operation) error { + return syscall.WSASendto(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, o.sa, &o.o, nil) + }) + ntotal += int(n) + if err != nil { + return ntotal, err + } + buf = buf[n:] + } + return ntotal, nil } // Call ConnectEx. This doesn't need any locking, since it is only @@ -989,6 +1055,10 @@ func (fd *FD) ReadMsg(p []byte, oob []byte) (int, int, int, syscall.Sockaddr, er } defer fd.readUnlock() + if len(p) > maxRW { + p = p[:maxRW] + } + o := &fd.rop o.InitMsg(p, oob) o.rsa = new(syscall.RawSockaddrAny) @@ -1007,6 +1077,10 @@ func (fd *FD) ReadMsg(p []byte, oob []byte) (int, int, int, syscall.Sockaddr, er // WriteMsg wraps the WSASendMsg network call. func (fd *FD) WriteMsg(p []byte, oob []byte, sa syscall.Sockaddr) (int, int, error) { + if len(p) > maxRW { + return 0, 0, errors.New("packet is too large (only 1GB is allowed)") + } + if err := fd.writeLock(); err != nil { return 0, 0, err } diff --git a/libgo/go/internal/poll/fd_writev_darwin.go b/libgo/go/internal/poll/fd_writev_darwin.go new file mode 100644 index 00000000000..e2024471d4f --- /dev/null +++ b/libgo/go/internal/poll/fd_writev_darwin.go @@ -0,0 +1,16 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build darwin + +package poll + +import ( + "syscall" + _ "unsafe" // for go:linkname +) + +// Implemented in syscall/syscall_darwin.go. +//go:linkname writev syscall.writev +func writev(fd int, iovecs []syscall.Iovec) (uintptr, error) diff --git a/libgo/go/internal/poll/fd_writev_unix.go b/libgo/go/internal/poll/fd_writev_unix.go new file mode 100644 index 00000000000..86af795b5a5 --- /dev/null +++ b/libgo/go/internal/poll/fd_writev_unix.go @@ -0,0 +1,20 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build dragonfly freebsd linux netbsd openbsd + +package poll + +import ( + "syscall" + "unsafe" +) + +func writev(fd int, iovecs []syscall.Iovec) (uintptr, error) { + r, _, e := syscall.Syscall(syscall.SYS_WRITEV, uintptr(fd), uintptr(unsafe.Pointer(&iovecs[0])), uintptr(len(iovecs))) + if e != 0 { + return r, syscall.Errno(e) + } + return r, nil +} diff --git a/libgo/go/internal/poll/sendfile_bsd.go b/libgo/go/internal/poll/sendfile_bsd.go index 980a75afa7f..40ae3468b07 100644 --- a/libgo/go/internal/poll/sendfile_bsd.go +++ b/libgo/go/internal/poll/sendfile_bsd.go @@ -32,8 +32,7 @@ func SendFile(dstFD *FD, src int, pos, remain int64) (int64, error) { pos += int64(n) written += int64(n) remain -= int64(n) - } - if n == 0 && err1 == nil { + } else if n == 0 && err1 == nil { break } if err1 == syscall.EAGAIN { diff --git a/libgo/go/internal/poll/sendfile_linux.go b/libgo/go/internal/poll/sendfile_linux.go index 52955a19d0b..8e938065f17 100644 --- a/libgo/go/internal/poll/sendfile_linux.go +++ b/libgo/go/internal/poll/sendfile_linux.go @@ -29,8 +29,7 @@ func SendFile(dstFD *FD, src int, remain int64) (int64, error) { if n > 0 { written += int64(n) remain -= int64(n) - } - if n == 0 && err1 == nil { + } else if n == 0 && err1 == nil { break } if err1 == syscall.EAGAIN { diff --git a/libgo/go/internal/poll/sendfile_solaris.go b/libgo/go/internal/poll/sendfile_solaris.go index 9093d464834..762992e9eb3 100644 --- a/libgo/go/internal/poll/sendfile_solaris.go +++ b/libgo/go/internal/poll/sendfile_solaris.go @@ -39,8 +39,7 @@ func SendFile(dstFD *FD, src int, pos, remain int64) (int64, error) { pos += int64(n) written += int64(n) remain -= int64(n) - } - if n == 0 && err1 == nil { + } else if n == 0 && err1 == nil { break } if err1 == syscall.EAGAIN { diff --git a/libgo/go/internal/poll/sendfile_windows.go b/libgo/go/internal/poll/sendfile_windows.go index dc93e851d63..17a3681064b 100644 --- a/libgo/go/internal/poll/sendfile_windows.go +++ b/libgo/go/internal/poll/sendfile_windows.go @@ -38,5 +38,11 @@ func SendFile(fd *FD, src syscall.Handle, n int64) (int64, error) { done, err := wsrv.ExecIO(o, func(o *operation) error { return syscall.TransmitFile(o.fd.Sysfd, o.handle, o.qty, 0, &o.o, nil, syscall.TF_WRITE_BEHIND) }) + if err == nil { + // Some versions of Windows (Windows 10 1803) do not set + // file position after TransmitFile completes. + // So just use Seek to set file position. + _, err = syscall.Seek(o.handle, curpos+int64(done), 0) + } return int64(done), err } diff --git a/libgo/go/internal/poll/sockopt_unix.go b/libgo/go/internal/poll/sockopt_unix.go index b33644db762..bd942c29345 100644 --- a/libgo/go/internal/poll/sockopt_unix.go +++ b/libgo/go/internal/poll/sockopt_unix.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd linux netbsd openbsd solaris +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package poll diff --git a/libgo/go/internal/poll/splice_linux.go b/libgo/go/internal/poll/splice_linux.go index 4265b429d14..68a57181f4b 100644 --- a/libgo/go/internal/poll/splice_linux.go +++ b/libgo/go/internal/poll/splice_linux.go @@ -32,8 +32,6 @@ func Splice(dst, src *FD, remain int64) (written int64, handled bool, sc string, return 0, false, sc, err } defer destroyTempPipe(prfd, pwfd) - // From here on, the operation should be considered handled, - // even if Splice doesn't transfer any data. var inPipe, n int for err == nil && remain > 0 { max := maxSpliceSize @@ -41,9 +39,18 @@ func Splice(dst, src *FD, remain int64) (written int64, handled bool, sc string, max = int(remain) } inPipe, err = spliceDrain(pwfd, src, max) + // The operation is considered handled if splice returns no + // error, or an error other than EINVAL. An EINVAL means the + // kernel does not support splice for the socket type of src. + // The failed syscall does not consume any data so it is safe + // to fall back to a generic copy. + // // spliceDrain should never return EAGAIN, so if err != nil, - // Splice cannot continue. If inPipe == 0 && err == nil, - // src is at EOF, and the transfer is complete. + // Splice cannot continue. + // + // If inPipe == 0 && err == nil, src is at EOF, and the + // transfer is complete. + handled = handled || (err != syscall.EINVAL) if err != nil || (inPipe == 0 && err == nil) { break } @@ -54,7 +61,7 @@ func Splice(dst, src *FD, remain int64) (written int64, handled bool, sc string, } } if err != nil { - return written, true, "splice", err + return written, handled, "splice", err } return written, true, "", nil } @@ -167,10 +174,10 @@ func newTempPipe() (prfd, pwfd int, sc string, err error) { destroyTempPipe(fds[0], fds[1]) return -1, -1, "fcntl", syscall.EINVAL } - if _, errno := fcntl(uintptr(fds[0]), syscall.F_GETPIPE_SZ, 0); errno != 0 { + if _, err := fcntl(fds[0], syscall.F_GETPIPE_SZ, 0); err != nil { *p = true destroyTempPipe(fds[0], fds[1]) - return -1, -1, "fcntl", syscall.Errno(errno) + return -1, -1, "fcntl", err } } diff --git a/libgo/go/internal/poll/writev.go b/libgo/go/internal/poll/writev.go index 4bf8804e217..04e3522d8a1 100644 --- a/libgo/go/internal/poll/writev.go +++ b/libgo/go/internal/poll/writev.go @@ -9,7 +9,6 @@ package poll import ( "io" "syscall" - "unsafe" ) // Writev wraps the writev system call. @@ -54,24 +53,20 @@ func (fd *FD) Writev(v *[][]byte) (int64, error) { } fd.iovecs = &iovecs // cache - wrote, _, e0 := syscall.Syscall(syscall.SYS_WRITEV, - uintptr(fd.Sysfd), - uintptr(unsafe.Pointer(&iovecs[0])), - uintptr(len(iovecs))) + var wrote uintptr + wrote, err = writev(fd.Sysfd, iovecs) if wrote == ^uintptr(0) { wrote = 0 } TestHookDidWritev(int(wrote)) n += int64(wrote) consume(v, int64(wrote)) - if e0 == syscall.EAGAIN { - if err = fd.pd.waitWrite(fd.isFile); err == nil { - continue - } - } else if e0 != 0 { - err = syscall.Errno(e0) - } if err != nil { + if err.(syscall.Errno) == syscall.EAGAIN { + if err = fd.pd.waitWrite(fd.isFile); err == nil { + continue + } + } break } if n == 0 { diff --git a/libgo/go/internal/syscall/unix/at.go b/libgo/go/internal/syscall/unix/at.go new file mode 100644 index 00000000000..b57b7918a89 --- /dev/null +++ b/libgo/go/internal/syscall/unix/at.go @@ -0,0 +1,81 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// -build linux openbsd netbsd dragonfly + +package unix + +import ( + "syscall" +) + +//extern unlinkat +func unlinkat(int32, *byte, int32) int32 + +//extern openat +func openat(int32, *byte, int32, syscall.Mode_t) int32 + +//extern fstatat +func fstatat(int32, *byte, *syscall.Stat_t, int32) int32 + +func Unlinkat(dirfd int, path string, flags int) error { + var p *byte + p, err := syscall.BytePtrFromString(path) + if err != nil { + return err + } + + syscall.Entersyscall() + r := unlinkat(int32(dirfd), p, int32(flags)) + var errno syscall.Errno + if r < 0 { + errno = syscall.GetErrno() + } + syscall.Exitsyscall() + if r < 0 { + return errno + } + return nil +} + +func Openat(dirfd int, path string, flags int, perm uint32) (int, error) { + var p *byte + p, err := syscall.BytePtrFromString(path) + if err != nil { + return 0, err + } + + syscall.Entersyscall() + fd := openat(int32(dirfd), p, int32(flags), syscall.Mode_t(perm)) + var errno syscall.Errno + if fd < 0 { + errno = syscall.GetErrno() + } + syscall.Exitsyscall() + if fd < 0 { + return 0, errno + } + return int(fd), nil +} + +func Fstatat(dirfd int, path string, stat *syscall.Stat_t, flags int) error { + var p *byte + p, err := syscall.BytePtrFromString(path) + if err != nil { + return err + } + + syscall.Entersyscall() + r := fstatat(int32(dirfd), p, stat, int32(flags)) + var errno syscall.Errno + if r < 0 { + errno = syscall.GetErrno() + } + syscall.Exitsyscall() + if r < 0 { + return errno + } + + return nil +} diff --git a/libgo/go/internal/syscall/unix/at_aix.go b/libgo/go/internal/syscall/unix/at_aix.go new file mode 100644 index 00000000000..8ee49599547 --- /dev/null +++ b/libgo/go/internal/syscall/unix/at_aix.go @@ -0,0 +1,10 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package unix + +const ( + AT_REMOVEDIR = 0x1 + AT_SYMLINK_NOFOLLOW = 0x1 +) diff --git a/libgo/go/internal/syscall/unix/at_freebsd.go b/libgo/go/internal/syscall/unix/at_freebsd.go new file mode 100644 index 00000000000..5323c548efa --- /dev/null +++ b/libgo/go/internal/syscall/unix/at_freebsd.go @@ -0,0 +1,10 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package unix + +const ( + AT_REMOVEDIR = 0x800 + AT_SYMLINK_NOFOLLOW = 0x200 +) diff --git a/libgo/go/internal/syscall/unix/at_solaris.go b/libgo/go/internal/syscall/unix/at_solaris.go new file mode 100644 index 00000000000..d6b9acebc89 --- /dev/null +++ b/libgo/go/internal/syscall/unix/at_solaris.go @@ -0,0 +1,10 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package unix + +const ( + AT_REMOVEDIR = 0x1 + AT_SYMLINK_NOFOLLOW = 0x1000 +) diff --git a/libgo/go/internal/syscall/unix/at_sysnum_darwin.go b/libgo/go/internal/syscall/unix/at_sysnum_darwin.go new file mode 100644 index 00000000000..aaaaa4751c0 --- /dev/null +++ b/libgo/go/internal/syscall/unix/at_sysnum_darwin.go @@ -0,0 +1,8 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package unix + +const AT_REMOVEDIR = 0x80 +const AT_SYMLINK_NOFOLLOW = 0x0020 diff --git a/libgo/go/internal/syscall/unix/at_sysnum_dragonfly.go b/libgo/go/internal/syscall/unix/at_sysnum_dragonfly.go new file mode 100644 index 00000000000..e9cb6a5dbda --- /dev/null +++ b/libgo/go/internal/syscall/unix/at_sysnum_dragonfly.go @@ -0,0 +1,8 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package unix + +const AT_REMOVEDIR = 0x2 +const AT_SYMLINK_NOFOLLOW = 0x1 diff --git a/libgo/go/internal/syscall/unix/at_sysnum_linux.go b/libgo/go/internal/syscall/unix/at_sysnum_linux.go new file mode 100644 index 00000000000..fe88c66a84c --- /dev/null +++ b/libgo/go/internal/syscall/unix/at_sysnum_linux.go @@ -0,0 +1,8 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package unix + +const AT_REMOVEDIR = 0x200 +const AT_SYMLINK_NOFOLLOW = 0x100 diff --git a/libgo/go/internal/syscall/unix/at_sysnum_netbsd.go b/libgo/go/internal/syscall/unix/at_sysnum_netbsd.go new file mode 100644 index 00000000000..5ec60b37713 --- /dev/null +++ b/libgo/go/internal/syscall/unix/at_sysnum_netbsd.go @@ -0,0 +1,8 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package unix + +const AT_REMOVEDIR = 0x800 +const AT_SYMLINK_NOFOLLOW = 0x200 diff --git a/libgo/go/internal/syscall/unix/at_sysnum_openbsd.go b/libgo/go/internal/syscall/unix/at_sysnum_openbsd.go new file mode 100644 index 00000000000..00b862b01df --- /dev/null +++ b/libgo/go/internal/syscall/unix/at_sysnum_openbsd.go @@ -0,0 +1,8 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package unix + +const AT_REMOVEDIR = 0x08 +const AT_SYMLINK_NOFOLLOW = 0x02 diff --git a/libgo/go/internal/syscall/unix/getrandom_freebsd.go b/libgo/go/internal/syscall/unix/getrandom_freebsd.go new file mode 100644 index 00000000000..f1ba5730c96 --- /dev/null +++ b/libgo/go/internal/syscall/unix/getrandom_freebsd.go @@ -0,0 +1,48 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package unix + +import ( + "sync/atomic" + "syscall" + "unsafe" +) + +var randomUnsupported int32 // atomic + +// FreeBSD getrandom system call number. +const randomTrap uintptr = 563 + +// GetRandomFlag is a flag supported by the getrandom system call. +type GetRandomFlag uintptr + +const ( + // GRND_NONBLOCK means return EAGAIN rather than blocking. + GRND_NONBLOCK GetRandomFlag = 0x0001 + + // GRND_RANDOM is only set for portability purpose, no-op on FreeBSD. + GRND_RANDOM GetRandomFlag = 0x0002 +) + +// GetRandom calls the FreeBSD getrandom system call. +func GetRandom(p []byte, flags GetRandomFlag) (n int, err error) { + if len(p) == 0 { + return 0, nil + } + if atomic.LoadInt32(&randomUnsupported) != 0 { + return 0, syscall.ENOSYS + } + r1, _, errno := syscall.Syscall(randomTrap, + uintptr(unsafe.Pointer(&p[0])), + uintptr(len(p)), + uintptr(flags)) + if errno != 0 { + if errno == syscall.ENOSYS { + atomic.StoreInt32(&randomUnsupported, 1) + } + return 0, errno + } + return int(r1), nil +} diff --git a/libgo/go/internal/syscall/unix/getrandom_linux.go b/libgo/go/internal/syscall/unix/getrandom_linux.go index 0d0d4f115c0..00d8110f6fc 100644 --- a/libgo/go/internal/syscall/unix/getrandom_linux.go +++ b/libgo/go/internal/syscall/unix/getrandom_linux.go @@ -26,9 +26,6 @@ const ( // GetRandom calls the Linux getrandom system call. // See https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=c6e9d6f38894798696f23c8084ca7edbf16ee895 func GetRandom(p []byte, flags GetRandomFlag) (n int, err error) { - if randomTrap == 0 { - return 0, syscall.ENOSYS - } if len(p) == 0 { return 0, nil } diff --git a/libgo/go/internal/syscall/unix/getrandom_linux_generic.go b/libgo/go/internal/syscall/unix/getrandom_linux_generic.go index 2d513df28dd..f70ada31a98 100644 --- a/libgo/go/internal/syscall/unix/getrandom_linux_generic.go +++ b/libgo/go/internal/syscall/unix/getrandom_linux_generic.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build arm64 nios2 riscv64 +// +build linux,arm64 linux,nios2 linux,riscv64 package unix diff --git a/libgo/go/internal/syscall/unix/ioctl_aix.go b/libgo/go/internal/syscall/unix/ioctl_aix.go new file mode 100644 index 00000000000..19d56c36a13 --- /dev/null +++ b/libgo/go/internal/syscall/unix/ioctl_aix.go @@ -0,0 +1,25 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package unix + +import ( + "syscall" + "unsafe" +) + +//go:cgo_import_dynamic libc_ioctl ioctl "libc.a/shr_64.o" +//go:linkname libc_ioctl libc_ioctl +var libc_ioctl uintptr + +// Implemented in syscall/syscall_aix.go. +func syscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) + +func Ioctl(fd int, cmd int, args uintptr) (err error) { + _, _, e1 := syscall6(uintptr(unsafe.Pointer(&libc_ioctl)), 3, uintptr(fd), uintptr(cmd), uintptr(args), 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} diff --git a/libgo/go/internal/syscall/unix/nonblocking.go b/libgo/go/internal/syscall/unix/nonblocking.go index da7f8bd68b2..4468784aa34 100644 --- a/libgo/go/internal/syscall/unix/nonblocking.go +++ b/libgo/go/internal/syscall/unix/nonblocking.go @@ -2,22 +2,19 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd linux netbsd openbsd solaris +// +build aix dragonfly freebsd linux netbsd openbsd solaris package unix -import ( - "syscall" - _ "unsafe" // for go:linkname -) +import "syscall" -//extern __go_fcntl -func syscall_fcntl(fd int32, cmd int32, arg int32) int32 +//extern __go_fcntl_uintptr +func fcntl(uintptr, uintptr, uintptr) (uintptr, uintptr) func IsNonblock(fd int) (nonblocking bool, err error) { - flag := syscall_fcntl(int32(fd), syscall.F_GETFL, 0) - if flag < 0 { - return false, syscall.GetErrno() + flag, e1 := fcntl(uintptr(fd), syscall.F_GETFL, 0) + if e1 != 0 { + return false, syscall.Errno(e1) } return flag&syscall.O_NONBLOCK != 0, nil } diff --git a/libgo/go/internal/syscall/unix/nonblocking_darwin.go b/libgo/go/internal/syscall/unix/nonblocking_darwin.go new file mode 100644 index 00000000000..e3dd3a06b01 --- /dev/null +++ b/libgo/go/internal/syscall/unix/nonblocking_darwin.go @@ -0,0 +1,24 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build darwin + +package unix + +import ( + "syscall" + _ "unsafe" // for go:linkname +) + +func IsNonblock(fd int) (nonblocking bool, err error) { + flag, e1 := fcntl(fd, syscall.F_GETFL, 0) + if e1 != nil { + return false, e1 + } + return flag&syscall.O_NONBLOCK != 0, nil +} + +// Implemented in syscall/syscall_darwin.go. +//go:linkname fcntl syscall.fcntl +func fcntl(fd int, cmd int, arg int) (int, error) diff --git a/libgo/go/internal/syscall/windows/mksyscall.go b/libgo/go/internal/syscall/windows/mksyscall.go index 23efb6a01ab..a8edafb3c3b 100644 --- a/libgo/go/internal/syscall/windows/mksyscall.go +++ b/libgo/go/internal/syscall/windows/mksyscall.go @@ -4,4 +4,4 @@ package windows -//go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go syscall_windows.go security_windows.go psapi_windows.go +//go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go syscall_windows.go security_windows.go psapi_windows.go symlink_windows.go diff --git a/libgo/go/internal/syscall/windows/symlink_windows.go b/libgo/go/internal/syscall/windows/symlink_windows.go index cc2163e9334..b64d058d13e 100644 --- a/libgo/go/internal/syscall/windows/symlink_windows.go +++ b/libgo/go/internal/syscall/windows/symlink_windows.go @@ -11,4 +11,29 @@ const ( // symlink support for CreateSymbolicLink() starting with Windows 10 (1703, v10.0.14972) SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE = 0x2 + + // FileInformationClass values + FileBasicInfo = 0 // FILE_BASIC_INFO + FileStandardInfo = 1 // FILE_STANDARD_INFO + FileNameInfo = 2 // FILE_NAME_INFO + FileStreamInfo = 7 // FILE_STREAM_INFO + FileCompressionInfo = 8 // FILE_COMPRESSION_INFO + FileAttributeTagInfo = 9 // FILE_ATTRIBUTE_TAG_INFO + FileIdBothDirectoryInfo = 0xa // FILE_ID_BOTH_DIR_INFO + FileIdBothDirectoryRestartInfo = 0xb // FILE_ID_BOTH_DIR_INFO + FileRemoteProtocolInfo = 0xd // FILE_REMOTE_PROTOCOL_INFO + FileFullDirectoryInfo = 0xe // FILE_FULL_DIR_INFO + FileFullDirectoryRestartInfo = 0xf // FILE_FULL_DIR_INFO + FileStorageInfo = 0x10 // FILE_STORAGE_INFO + FileAlignmentInfo = 0x11 // FILE_ALIGNMENT_INFO + FileIdInfo = 0x12 // FILE_ID_INFO + FileIdExtdDirectoryInfo = 0x13 // FILE_ID_EXTD_DIR_INFO + FileIdExtdDirectoryRestartInfo = 0x14 // FILE_ID_EXTD_DIR_INFO ) + +type FILE_ATTRIBUTE_TAG_INFO struct { + FileAttributes uint32 + ReparseTag uint32 +} + +//sys GetFileInformationByHandleEx(handle syscall.Handle, class uint32, info *byte, bufsize uint32) (err error) diff --git a/libgo/go/internal/syscall/windows/syscall_windows.go b/libgo/go/internal/syscall/windows/syscall_windows.go index 66fe9324c0a..121132f6f73 100644 --- a/libgo/go/internal/syscall/windows/syscall_windows.go +++ b/libgo/go/internal/syscall/windows/syscall_windows.go @@ -12,7 +12,11 @@ import ( const ( ERROR_SHARING_VIOLATION syscall.Errno = 32 + ERROR_LOCK_VIOLATION syscall.Errno = 33 + ERROR_NOT_SUPPORTED syscall.Errno = 50 + ERROR_CALL_NOT_IMPLEMENTED syscall.Errno = 120 ERROR_INVALID_NAME syscall.Errno = 123 + ERROR_LOCK_FAILED syscall.Errno = 167 ERROR_NO_UNICODE_TRANSLATION syscall.Errno = 1113 ) @@ -255,6 +259,14 @@ func Rename(oldpath, newpath string) error { return MoveFileEx(from, to, MOVEFILE_REPLACE_EXISTING) } +//sys LockFileEx(file syscall.Handle, flags uint32, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *syscall.Overlapped) (err error) = kernel32.LockFileEx +//sys UnlockFileEx(file syscall.Handle, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *syscall.Overlapped) (err error) = kernel32.UnlockFileEx + +const ( + LOCKFILE_FAIL_IMMEDIATELY = 0x00000001 + LOCKFILE_EXCLUSIVE_LOCK = 0x00000002 +) + const MB_ERR_INVALID_CHARS = 8 //sys GetACP() (acp uint32) = kernel32.GetACP diff --git a/libgo/go/internal/syscall/windows/zsyscall_windows.go b/libgo/go/internal/syscall/windows/zsyscall_windows.go index 550a8a5bd44..9527a370a4e 100644 --- a/libgo/go/internal/syscall/windows/zsyscall_windows.go +++ b/libgo/go/internal/syscall/windows/zsyscall_windows.go @@ -44,28 +44,31 @@ var ( moduserenv = syscall.NewLazyDLL(sysdll.Add("userenv.dll")) modpsapi = syscall.NewLazyDLL(sysdll.Add("psapi.dll")) - procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses") - procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW") - procMoveFileExW = modkernel32.NewProc("MoveFileExW") - procGetModuleFileNameW = modkernel32.NewProc("GetModuleFileNameW") - procWSASocketW = modws2_32.NewProc("WSASocketW") - procGetACP = modkernel32.NewProc("GetACP") - procGetConsoleCP = modkernel32.NewProc("GetConsoleCP") - procMultiByteToWideChar = modkernel32.NewProc("MultiByteToWideChar") - procGetCurrentThread = modkernel32.NewProc("GetCurrentThread") - procNetShareAdd = modnetapi32.NewProc("NetShareAdd") - procNetShareDel = modnetapi32.NewProc("NetShareDel") - procGetFinalPathNameByHandleW = modkernel32.NewProc("GetFinalPathNameByHandleW") - procImpersonateSelf = modadvapi32.NewProc("ImpersonateSelf") - procRevertToSelf = modadvapi32.NewProc("RevertToSelf") - procOpenThreadToken = modadvapi32.NewProc("OpenThreadToken") - procLookupPrivilegeValueW = modadvapi32.NewProc("LookupPrivilegeValueW") - procAdjustTokenPrivileges = modadvapi32.NewProc("AdjustTokenPrivileges") - procDuplicateTokenEx = modadvapi32.NewProc("DuplicateTokenEx") - procSetTokenInformation = modadvapi32.NewProc("SetTokenInformation") - procGetProfilesDirectoryW = moduserenv.NewProc("GetProfilesDirectoryW") - procNetUserGetLocalGroups = modnetapi32.NewProc("NetUserGetLocalGroups") - procGetProcessMemoryInfo = modpsapi.NewProc("GetProcessMemoryInfo") + procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses") + procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW") + procMoveFileExW = modkernel32.NewProc("MoveFileExW") + procGetModuleFileNameW = modkernel32.NewProc("GetModuleFileNameW") + procWSASocketW = modws2_32.NewProc("WSASocketW") + procLockFileEx = modkernel32.NewProc("LockFileEx") + procUnlockFileEx = modkernel32.NewProc("UnlockFileEx") + procGetACP = modkernel32.NewProc("GetACP") + procGetConsoleCP = modkernel32.NewProc("GetConsoleCP") + procMultiByteToWideChar = modkernel32.NewProc("MultiByteToWideChar") + procGetCurrentThread = modkernel32.NewProc("GetCurrentThread") + procNetShareAdd = modnetapi32.NewProc("NetShareAdd") + procNetShareDel = modnetapi32.NewProc("NetShareDel") + procGetFinalPathNameByHandleW = modkernel32.NewProc("GetFinalPathNameByHandleW") + procImpersonateSelf = modadvapi32.NewProc("ImpersonateSelf") + procRevertToSelf = modadvapi32.NewProc("RevertToSelf") + procOpenThreadToken = modadvapi32.NewProc("OpenThreadToken") + procLookupPrivilegeValueW = modadvapi32.NewProc("LookupPrivilegeValueW") + procAdjustTokenPrivileges = modadvapi32.NewProc("AdjustTokenPrivileges") + procDuplicateTokenEx = modadvapi32.NewProc("DuplicateTokenEx") + procSetTokenInformation = modadvapi32.NewProc("SetTokenInformation") + procGetProfilesDirectoryW = moduserenv.NewProc("GetProfilesDirectoryW") + procNetUserGetLocalGroups = modnetapi32.NewProc("NetUserGetLocalGroups") + procGetProcessMemoryInfo = modpsapi.NewProc("GetProcessMemoryInfo") + procGetFileInformationByHandleEx = modkernel32.NewProc("GetFileInformationByHandleEx") ) func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) { @@ -126,6 +129,30 @@ func WSASocket(af int32, typ int32, protocol int32, protinfo *syscall.WSAProtoco return } +func LockFileEx(file syscall.Handle, flags uint32, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *syscall.Overlapped) (err error) { + r1, _, e1 := syscall.Syscall6(procLockFileEx.Addr(), 6, uintptr(file), uintptr(flags), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped))) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func UnlockFileEx(file syscall.Handle, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *syscall.Overlapped) (err error) { + r1, _, e1 := syscall.Syscall6(procUnlockFileEx.Addr(), 5, uintptr(file), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped)), 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + func GetACP() (acp uint32) { r0, _, _ := syscall.Syscall(procGetACP.Addr(), 0, 0, 0, 0) acp = uint32(r0) @@ -321,3 +348,15 @@ func GetProcessMemoryInfo(handle syscall.Handle, memCounters *PROCESS_MEMORY_COU } return } + +func GetFileInformationByHandleEx(handle syscall.Handle, class uint32, info *byte, bufsize uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 4, uintptr(handle), uintptr(class), uintptr(unsafe.Pointer(info)), uintptr(bufsize), 0, 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} diff --git a/libgo/go/internal/trace/gc.go b/libgo/go/internal/trace/gc.go new file mode 100644 index 00000000000..cc19fdf8912 --- /dev/null +++ b/libgo/go/internal/trace/gc.go @@ -0,0 +1,825 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package trace + +import ( + "container/heap" + "math" + "sort" + "strings" + "time" +) + +// MutatorUtil is a change in mutator utilization at a particular +// time. Mutator utilization functions are represented as a +// time-ordered []MutatorUtil. +type MutatorUtil struct { + Time int64 + // Util is the mean mutator utilization starting at Time. This + // is in the range [0, 1]. + Util float64 +} + +// UtilFlags controls the behavior of MutatorUtilization. +type UtilFlags int + +const ( + // UtilSTW means utilization should account for STW events. + UtilSTW UtilFlags = 1 << iota + // UtilBackground means utilization should account for + // background mark workers. + UtilBackground + // UtilAssist means utilization should account for mark + // assists. + UtilAssist + // UtilSweep means utilization should account for sweeping. + UtilSweep + + // UtilPerProc means each P should be given a separate + // utilization function. Otherwise, there is a single function + // and each P is given a fraction of the utilization. + UtilPerProc +) + +// MutatorUtilization returns a set of mutator utilization functions +// for the given trace. Each function will always end with 0 +// utilization. The bounds of each function are implicit in the first +// and last event; outside of these bounds each function is undefined. +// +// If the UtilPerProc flag is not given, this always returns a single +// utilization function. Otherwise, it returns one function per P. +func MutatorUtilization(events []*Event, flags UtilFlags) [][]MutatorUtil { + if len(events) == 0 { + return nil + } + + type perP struct { + // gc > 0 indicates that GC is active on this P. + gc int + // series the logical series number for this P. This + // is necessary because Ps may be removed and then + // re-added, and then the new P needs a new series. + series int + } + ps := []perP{} + stw := 0 + + out := [][]MutatorUtil{} + assists := map[uint64]bool{} + block := map[uint64]*Event{} + bgMark := map[uint64]bool{} + + for _, ev := range events { + switch ev.Type { + case EvGomaxprocs: + gomaxprocs := int(ev.Args[0]) + if len(ps) > gomaxprocs { + if flags&UtilPerProc != 0 { + // End each P's series. + for _, p := range ps[gomaxprocs:] { + out[p.series] = addUtil(out[p.series], MutatorUtil{ev.Ts, 0}) + } + } + ps = ps[:gomaxprocs] + } + for len(ps) < gomaxprocs { + // Start new P's series. + series := 0 + if flags&UtilPerProc != 0 || len(out) == 0 { + series = len(out) + out = append(out, []MutatorUtil{{ev.Ts, 1}}) + } + ps = append(ps, perP{series: series}) + } + case EvGCSTWStart: + if flags&UtilSTW != 0 { + stw++ + } + case EvGCSTWDone: + if flags&UtilSTW != 0 { + stw-- + } + case EvGCMarkAssistStart: + if flags&UtilAssist != 0 { + ps[ev.P].gc++ + assists[ev.G] = true + } + case EvGCMarkAssistDone: + if flags&UtilAssist != 0 { + ps[ev.P].gc-- + delete(assists, ev.G) + } + case EvGCSweepStart: + if flags&UtilSweep != 0 { + ps[ev.P].gc++ + } + case EvGCSweepDone: + if flags&UtilSweep != 0 { + ps[ev.P].gc-- + } + case EvGoStartLabel: + if flags&UtilBackground != 0 && strings.HasPrefix(ev.SArgs[0], "GC ") && ev.SArgs[0] != "GC (idle)" { + // Background mark worker. + // + // If we're in per-proc mode, we don't + // count dedicated workers because + // they kick all of the goroutines off + // that P, so don't directly + // contribute to goroutine latency. + if !(flags&UtilPerProc != 0 && ev.SArgs[0] == "GC (dedicated)") { + bgMark[ev.G] = true + ps[ev.P].gc++ + } + } + fallthrough + case EvGoStart: + if assists[ev.G] { + // Unblocked during assist. + ps[ev.P].gc++ + } + block[ev.G] = ev.Link + default: + if ev != block[ev.G] { + continue + } + + if assists[ev.G] { + // Blocked during assist. + ps[ev.P].gc-- + } + if bgMark[ev.G] { + // Background mark worker done. + ps[ev.P].gc-- + delete(bgMark, ev.G) + } + delete(block, ev.G) + } + + if flags&UtilPerProc == 0 { + // Compute the current average utilization. + if len(ps) == 0 { + continue + } + gcPs := 0 + if stw > 0 { + gcPs = len(ps) + } else { + for i := range ps { + if ps[i].gc > 0 { + gcPs++ + } + } + } + mu := MutatorUtil{ev.Ts, 1 - float64(gcPs)/float64(len(ps))} + + // Record the utilization change. (Since + // len(ps) == len(out), we know len(out) > 0.) + out[0] = addUtil(out[0], mu) + } else { + // Check for per-P utilization changes. + for i := range ps { + p := &ps[i] + util := 1.0 + if stw > 0 || p.gc > 0 { + util = 0.0 + } + out[p.series] = addUtil(out[p.series], MutatorUtil{ev.Ts, util}) + } + } + } + + // Add final 0 utilization event to any remaining series. This + // is important to mark the end of the trace. The exact value + // shouldn't matter since no window should extend beyond this, + // but using 0 is symmetric with the start of the trace. + mu := MutatorUtil{events[len(events)-1].Ts, 0} + for i := range ps { + out[ps[i].series] = addUtil(out[ps[i].series], mu) + } + return out +} + +func addUtil(util []MutatorUtil, mu MutatorUtil) []MutatorUtil { + if len(util) > 0 { + if mu.Util == util[len(util)-1].Util { + // No change. + return util + } + if mu.Time == util[len(util)-1].Time { + // Take the lowest utilization at a time stamp. + if mu.Util < util[len(util)-1].Util { + util[len(util)-1] = mu + } + return util + } + } + return append(util, mu) +} + +// totalUtil is total utilization, measured in nanoseconds. This is a +// separate type primarily to distinguish it from mean utilization, +// which is also a float64. +type totalUtil float64 + +func totalUtilOf(meanUtil float64, dur int64) totalUtil { + return totalUtil(meanUtil * float64(dur)) +} + +// mean returns the mean utilization over dur. +func (u totalUtil) mean(dur time.Duration) float64 { + return float64(u) / float64(dur) +} + +// An MMUCurve is the minimum mutator utilization curve across +// multiple window sizes. +type MMUCurve struct { + series []mmuSeries +} + +type mmuSeries struct { + util []MutatorUtil + // sums[j] is the cumulative sum of util[:j]. + sums []totalUtil + // bands summarizes util in non-overlapping bands of duration + // bandDur. + bands []mmuBand + // bandDur is the duration of each band. + bandDur int64 +} + +type mmuBand struct { + // minUtil is the minimum instantaneous mutator utilization in + // this band. + minUtil float64 + // cumUtil is the cumulative total mutator utilization between + // time 0 and the left edge of this band. + cumUtil totalUtil + + // integrator is the integrator for the left edge of this + // band. + integrator integrator +} + +// NewMMUCurve returns an MMU curve for the given mutator utilization +// function. +func NewMMUCurve(utils [][]MutatorUtil) *MMUCurve { + series := make([]mmuSeries, len(utils)) + for i, util := range utils { + series[i] = newMMUSeries(util) + } + return &MMUCurve{series} +} + +// bandsPerSeries is the number of bands to divide each series into. +// This is only changed by tests. +var bandsPerSeries = 1000 + +func newMMUSeries(util []MutatorUtil) mmuSeries { + // Compute cumulative sum. + sums := make([]totalUtil, len(util)) + var prev MutatorUtil + var sum totalUtil + for j, u := range util { + sum += totalUtilOf(prev.Util, u.Time-prev.Time) + sums[j] = sum + prev = u + } + + // Divide the utilization curve up into equal size + // non-overlapping "bands" and compute a summary for each of + // these bands. + // + // Compute the duration of each band. + numBands := bandsPerSeries + if numBands > len(util) { + // There's no point in having lots of bands if there + // aren't many events. + numBands = len(util) + } + dur := util[len(util)-1].Time - util[0].Time + bandDur := (dur + int64(numBands) - 1) / int64(numBands) + if bandDur < 1 { + bandDur = 1 + } + // Compute the bands. There are numBands+1 bands in order to + // record the final cumulative sum. + bands := make([]mmuBand, numBands+1) + s := mmuSeries{util, sums, bands, bandDur} + leftSum := integrator{&s, 0} + for i := range bands { + startTime, endTime := s.bandTime(i) + cumUtil := leftSum.advance(startTime) + predIdx := leftSum.pos + minUtil := 1.0 + for i := predIdx; i < len(util) && util[i].Time < endTime; i++ { + minUtil = math.Min(minUtil, util[i].Util) + } + bands[i] = mmuBand{minUtil, cumUtil, leftSum} + } + + return s +} + +func (s *mmuSeries) bandTime(i int) (start, end int64) { + start = int64(i)*s.bandDur + s.util[0].Time + end = start + s.bandDur + return +} + +type bandUtil struct { + // Utilization series index + series int + // Band index + i int + // Lower bound of mutator utilization for all windows + // with a left edge in this band. + utilBound float64 +} + +type bandUtilHeap []bandUtil + +func (h bandUtilHeap) Len() int { + return len(h) +} + +func (h bandUtilHeap) Less(i, j int) bool { + return h[i].utilBound < h[j].utilBound +} + +func (h bandUtilHeap) Swap(i, j int) { + h[i], h[j] = h[j], h[i] +} + +func (h *bandUtilHeap) Push(x interface{}) { + *h = append(*h, x.(bandUtil)) +} + +func (h *bandUtilHeap) Pop() interface{} { + x := (*h)[len(*h)-1] + *h = (*h)[:len(*h)-1] + return x +} + +// UtilWindow is a specific window at Time. +type UtilWindow struct { + Time int64 + // MutatorUtil is the mean mutator utilization in this window. + MutatorUtil float64 +} + +type utilHeap []UtilWindow + +func (h utilHeap) Len() int { + return len(h) +} + +func (h utilHeap) Less(i, j int) bool { + if h[i].MutatorUtil != h[j].MutatorUtil { + return h[i].MutatorUtil > h[j].MutatorUtil + } + return h[i].Time > h[j].Time +} + +func (h utilHeap) Swap(i, j int) { + h[i], h[j] = h[j], h[i] +} + +func (h *utilHeap) Push(x interface{}) { + *h = append(*h, x.(UtilWindow)) +} + +func (h *utilHeap) Pop() interface{} { + x := (*h)[len(*h)-1] + *h = (*h)[:len(*h)-1] + return x +} + +// An accumulator takes a windowed mutator utilization function and +// tracks various statistics for that function. +type accumulator struct { + mmu float64 + + // bound is the mutator utilization bound where adding any + // mutator utilization above this bound cannot affect the + // accumulated statistics. + bound float64 + + // Worst N window tracking + nWorst int + wHeap utilHeap + + // Mutator utilization distribution tracking + mud *mud + // preciseMass is the distribution mass that must be precise + // before accumulation is stopped. + preciseMass float64 + // lastTime and lastMU are the previous point added to the + // windowed mutator utilization function. + lastTime int64 + lastMU float64 +} + +// resetTime declares a discontinuity in the windowed mutator +// utilization function by resetting the current time. +func (acc *accumulator) resetTime() { + // This only matters for distribution collection, since that's + // the only thing that depends on the progression of the + // windowed mutator utilization function. + acc.lastTime = math.MaxInt64 +} + +// addMU adds a point to the windowed mutator utilization function at +// (time, mu). This must be called for monotonically increasing values +// of time. +// +// It returns true if further calls to addMU would be pointless. +func (acc *accumulator) addMU(time int64, mu float64, window time.Duration) bool { + if mu < acc.mmu { + acc.mmu = mu + } + acc.bound = acc.mmu + + if acc.nWorst == 0 { + // If the minimum has reached zero, it can't go any + // lower, so we can stop early. + return mu == 0 + } + + // Consider adding this window to the n worst. + if len(acc.wHeap) < acc.nWorst || mu < acc.wHeap[0].MutatorUtil { + // This window is lower than the K'th worst window. + // + // Check if there's any overlapping window + // already in the heap and keep whichever is + // worse. + for i, ui := range acc.wHeap { + if time+int64(window) > ui.Time && ui.Time+int64(window) > time { + if ui.MutatorUtil <= mu { + // Keep the first window. + goto keep + } else { + // Replace it with this window. + heap.Remove(&acc.wHeap, i) + break + } + } + } + + heap.Push(&acc.wHeap, UtilWindow{time, mu}) + if len(acc.wHeap) > acc.nWorst { + heap.Pop(&acc.wHeap) + } + keep: + } + + if len(acc.wHeap) < acc.nWorst { + // We don't have N windows yet, so keep accumulating. + acc.bound = 1.0 + } else { + // Anything above the least worst window has no effect. + acc.bound = math.Max(acc.bound, acc.wHeap[0].MutatorUtil) + } + + if acc.mud != nil { + if acc.lastTime != math.MaxInt64 { + // Update distribution. + acc.mud.add(acc.lastMU, mu, float64(time-acc.lastTime)) + } + acc.lastTime, acc.lastMU = time, mu + if _, mudBound, ok := acc.mud.approxInvCumulativeSum(); ok { + acc.bound = math.Max(acc.bound, mudBound) + } else { + // We haven't accumulated enough total precise + // mass yet to even reach our goal, so keep + // accumulating. + acc.bound = 1 + } + // It's not worth checking percentiles every time, so + // just keep accumulating this band. + return false + } + + // If we've found enough 0 utilizations, we can stop immediately. + return len(acc.wHeap) == acc.nWorst && acc.wHeap[0].MutatorUtil == 0 +} + +// MMU returns the minimum mutator utilization for the given time +// window. This is the minimum utilization for all windows of this +// duration across the execution. The returned value is in the range +// [0, 1]. +func (c *MMUCurve) MMU(window time.Duration) (mmu float64) { + acc := accumulator{mmu: 1.0, bound: 1.0} + c.mmu(window, &acc) + return acc.mmu +} + +// Examples returns n specific examples of the lowest mutator +// utilization for the given window size. The returned windows will be +// disjoint (otherwise there would be a huge number of +// mostly-overlapping windows at the single lowest point). There are +// no guarantees on which set of disjoint windows this returns. +func (c *MMUCurve) Examples(window time.Duration, n int) (worst []UtilWindow) { + acc := accumulator{mmu: 1.0, bound: 1.0, nWorst: n} + c.mmu(window, &acc) + sort.Sort(sort.Reverse(acc.wHeap)) + return ([]UtilWindow)(acc.wHeap) +} + +// MUD returns mutator utilization distribution quantiles for the +// given window size. +// +// The mutator utilization distribution is the distribution of mean +// mutator utilization across all windows of the given window size in +// the trace. +// +// The minimum mutator utilization is the minimum (0th percentile) of +// this distribution. (However, if only the minimum is desired, it's +// more efficient to use the MMU method.) +func (c *MMUCurve) MUD(window time.Duration, quantiles []float64) []float64 { + if len(quantiles) == 0 { + return []float64{} + } + + // Each unrefined band contributes a known total mass to the + // distribution (bandDur except at the end), but in an unknown + // way. However, we know that all the mass it contributes must + // be at or above its worst-case mean mutator utilization. + // + // Hence, we refine bands until the highest desired + // distribution quantile is less than the next worst-case mean + // mutator utilization. At this point, all further + // contributions to the distribution must be beyond the + // desired quantile and hence cannot affect it. + // + // First, find the highest desired distribution quantile. + maxQ := quantiles[0] + for _, q := range quantiles { + if q > maxQ { + maxQ = q + } + } + // The distribution's mass is in units of time (it's not + // normalized because this would make it more annoying to + // account for future contributions of unrefined bands). The + // total final mass will be the duration of the trace itself + // minus the window size. Using this, we can compute the mass + // corresponding to quantile maxQ. + var duration int64 + for _, s := range c.series { + duration1 := s.util[len(s.util)-1].Time - s.util[0].Time + if duration1 >= int64(window) { + duration += duration1 - int64(window) + } + } + qMass := float64(duration) * maxQ + + // Accumulate the MUD until we have precise information for + // everything to the left of qMass. + acc := accumulator{mmu: 1.0, bound: 1.0, preciseMass: qMass, mud: new(mud)} + acc.mud.setTrackMass(qMass) + c.mmu(window, &acc) + + // Evaluate the quantiles on the accumulated MUD. + out := make([]float64, len(quantiles)) + for i := range out { + mu, _ := acc.mud.invCumulativeSum(float64(duration) * quantiles[i]) + if math.IsNaN(mu) { + // There are a few legitimate ways this can + // happen: + // + // 1. If the window is the full trace + // duration, then the windowed MU function is + // only defined at a single point, so the MU + // distribution is not well-defined. + // + // 2. If there are no events, then the MU + // distribution has no mass. + // + // Either way, all of the quantiles will have + // converged toward the MMU at this point. + mu = acc.mmu + } + out[i] = mu + } + return out +} + +func (c *MMUCurve) mmu(window time.Duration, acc *accumulator) { + if window <= 0 { + acc.mmu = 0 + return + } + + var bandU bandUtilHeap + windows := make([]time.Duration, len(c.series)) + for i, s := range c.series { + windows[i] = window + if max := time.Duration(s.util[len(s.util)-1].Time - s.util[0].Time); window > max { + windows[i] = max + } + + bandU1 := bandUtilHeap(s.mkBandUtil(i, windows[i])) + if bandU == nil { + bandU = bandU1 + } else { + bandU = append(bandU, bandU1...) + } + } + + // Process bands from lowest utilization bound to highest. + heap.Init(&bandU) + + // Refine each band into a precise window and MMU until + // refining the next lowest band can no longer affect the MMU + // or windows. + for len(bandU) > 0 && bandU[0].utilBound < acc.bound { + i := bandU[0].series + c.series[i].bandMMU(bandU[0].i, windows[i], acc) + heap.Pop(&bandU) + } +} + +func (c *mmuSeries) mkBandUtil(series int, window time.Duration) []bandUtil { + // For each band, compute the worst-possible total mutator + // utilization for all windows that start in that band. + + // minBands is the minimum number of bands a window can span + // and maxBands is the maximum number of bands a window can + // span in any alignment. + minBands := int((int64(window) + c.bandDur - 1) / c.bandDur) + maxBands := int((int64(window) + 2*(c.bandDur-1)) / c.bandDur) + if window > 1 && maxBands < 2 { + panic("maxBands < 2") + } + tailDur := int64(window) % c.bandDur + nUtil := len(c.bands) - maxBands + 1 + if nUtil < 0 { + nUtil = 0 + } + bandU := make([]bandUtil, nUtil) + for i := range bandU { + // To compute the worst-case MU, we assume the minimum + // for any bands that are only partially overlapped by + // some window and the mean for any bands that are + // completely covered by all windows. + var util totalUtil + + // Find the lowest and second lowest of the partial + // bands. + l := c.bands[i].minUtil + r1 := c.bands[i+minBands-1].minUtil + r2 := c.bands[i+maxBands-1].minUtil + minBand := math.Min(l, math.Min(r1, r2)) + // Assume the worst window maximally overlaps the + // worst minimum and then the rest overlaps the second + // worst minimum. + if minBands == 1 { + util += totalUtilOf(minBand, int64(window)) + } else { + util += totalUtilOf(minBand, c.bandDur) + midBand := 0.0 + switch { + case minBand == l: + midBand = math.Min(r1, r2) + case minBand == r1: + midBand = math.Min(l, r2) + case minBand == r2: + midBand = math.Min(l, r1) + } + util += totalUtilOf(midBand, tailDur) + } + + // Add the total mean MU of bands that are completely + // overlapped by all windows. + if minBands > 2 { + util += c.bands[i+minBands-1].cumUtil - c.bands[i+1].cumUtil + } + + bandU[i] = bandUtil{series, i, util.mean(window)} + } + + return bandU +} + +// bandMMU computes the precise minimum mutator utilization for +// windows with a left edge in band bandIdx. +func (c *mmuSeries) bandMMU(bandIdx int, window time.Duration, acc *accumulator) { + util := c.util + + // We think of the mutator utilization over time as the + // box-filtered utilization function, which we call the + // "windowed mutator utilization function". The resulting + // function is continuous and piecewise linear (unless + // window==0, which we handle elsewhere), where the boundaries + // between segments occur when either edge of the window + // encounters a change in the instantaneous mutator + // utilization function. Hence, the minimum of this function + // will always occur when one of the edges of the window + // aligns with a utilization change, so these are the only + // points we need to consider. + // + // We compute the mutator utilization function incrementally + // by tracking the integral from t=0 to the left edge of the + // window and to the right edge of the window. + left := c.bands[bandIdx].integrator + right := left + time, endTime := c.bandTime(bandIdx) + if utilEnd := util[len(util)-1].Time - int64(window); utilEnd < endTime { + endTime = utilEnd + } + acc.resetTime() + for { + // Advance edges to time and time+window. + mu := (right.advance(time+int64(window)) - left.advance(time)).mean(window) + if acc.addMU(time, mu, window) { + break + } + if time == endTime { + break + } + + // The maximum slope of the windowed mutator + // utilization function is 1/window, so we can always + // advance the time by at least (mu - mmu) * window + // without dropping below mmu. + minTime := time + int64((mu-acc.bound)*float64(window)) + + // Advance the window to the next time where either + // the left or right edge of the window encounters a + // change in the utilization curve. + if t1, t2 := left.next(time), right.next(time+int64(window))-int64(window); t1 < t2 { + time = t1 + } else { + time = t2 + } + if time < minTime { + time = minTime + } + if time >= endTime { + // For MMUs we could stop here, but for MUDs + // it's important that we span the entire + // band. + time = endTime + } + } +} + +// An integrator tracks a position in a utilization function and +// integrates it. +type integrator struct { + u *mmuSeries + // pos is the index in u.util of the current time's non-strict + // predecessor. + pos int +} + +// advance returns the integral of the utilization function from 0 to +// time. advance must be called on monotonically increasing values of +// times. +func (in *integrator) advance(time int64) totalUtil { + util, pos := in.u.util, in.pos + // Advance pos until pos+1 is time's strict successor (making + // pos time's non-strict predecessor). + // + // Very often, this will be nearby, so we optimize that case, + // but it may be arbitrarily far away, so we handled that + // efficiently, too. + const maxSeq = 8 + if pos+maxSeq < len(util) && util[pos+maxSeq].Time > time { + // Nearby. Use a linear scan. + for pos+1 < len(util) && util[pos+1].Time <= time { + pos++ + } + } else { + // Far. Binary search for time's strict successor. + l, r := pos, len(util) + for l < r { + h := int(uint(l+r) >> 1) + if util[h].Time <= time { + l = h + 1 + } else { + r = h + } + } + pos = l - 1 // Non-strict predecessor. + } + in.pos = pos + var partial totalUtil + if time != util[pos].Time { + partial = totalUtilOf(util[pos].Util, time-util[pos].Time) + } + return in.u.sums[pos] + partial +} + +// next returns the smallest time t' > time of a change in the +// utilization function. +func (in *integrator) next(time int64) int64 { + for _, u := range in.u.util[in.pos:] { + if u.Time > time { + return u.Time + } + } + return 1<<63 - 1 +} diff --git a/libgo/go/internal/trace/gc_test.go b/libgo/go/internal/trace/gc_test.go new file mode 100644 index 00000000000..da1cb90f5cd --- /dev/null +++ b/libgo/go/internal/trace/gc_test.go @@ -0,0 +1,198 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package trace + +import ( + "bytes" + "io/ioutil" + "math" + "testing" + "time" +) + +// aeq returns true if x and y are equal up to 8 digits (1 part in 100 +// million). +func aeq(x, y float64) bool { + if x < 0 && y < 0 { + x, y = -x, -y + } + const digits = 8 + factor := 1 - math.Pow(10, -digits+1) + return x*factor <= y && y*factor <= x +} + +func TestMMU(t *testing.T) { + t.Parallel() + + // MU + // 1.0 ***** ***** ***** + // 0.5 * * * * + // 0.0 ***** ***** + // 0 1 2 3 4 5 + util := [][]MutatorUtil{{ + {0e9, 1}, + {1e9, 0}, + {2e9, 1}, + {3e9, 0}, + {4e9, 1}, + {5e9, 0}, + }} + mmuCurve := NewMMUCurve(util) + + for _, test := range []struct { + window time.Duration + want float64 + worst []float64 + }{ + {0, 0, []float64{}}, + {time.Millisecond, 0, []float64{0, 0}}, + {time.Second, 0, []float64{0, 0}}, + {2 * time.Second, 0.5, []float64{0.5, 0.5}}, + {3 * time.Second, 1 / 3.0, []float64{1 / 3.0}}, + {4 * time.Second, 0.5, []float64{0.5}}, + {5 * time.Second, 3 / 5.0, []float64{3 / 5.0}}, + {6 * time.Second, 3 / 5.0, []float64{3 / 5.0}}, + } { + if got := mmuCurve.MMU(test.window); !aeq(test.want, got) { + t.Errorf("for %s window, want mu = %f, got %f", test.window, test.want, got) + } + worst := mmuCurve.Examples(test.window, 2) + // Which exact windows are returned is unspecified + // (and depends on the exact banding), so we just + // check that we got the right number with the right + // utilizations. + if len(worst) != len(test.worst) { + t.Errorf("for %s window, want worst %v, got %v", test.window, test.worst, worst) + } else { + for i := range worst { + if worst[i].MutatorUtil != test.worst[i] { + t.Errorf("for %s window, want worst %v, got %v", test.window, test.worst, worst) + break + } + } + } + } +} + +func TestMMUTrace(t *testing.T) { + // Can't be t.Parallel() because it modifies the + // testingOneBand package variable. + + data, err := ioutil.ReadFile("testdata/stress_1_10_good") + if err != nil { + t.Fatalf("failed to read input file: %v", err) + } + _, events, err := parse(bytes.NewReader(data), "") + if err != nil { + t.Fatalf("failed to parse trace: %s", err) + } + mu := MutatorUtilization(events.Events, UtilSTW|UtilBackground|UtilAssist) + mmuCurve := NewMMUCurve(mu) + + // Test the optimized implementation against the "obviously + // correct" implementation. + for window := time.Nanosecond; window < 10*time.Second; window *= 10 { + want := mmuSlow(mu[0], window) + got := mmuCurve.MMU(window) + if !aeq(want, got) { + t.Errorf("want %f, got %f mutator utilization in window %s", want, got, window) + } + } + + // Test MUD with band optimization against MUD without band + // optimization. We don't have a simple testing implementation + // of MUDs (the simplest implementation is still quite + // complex), but this is still a pretty good test. + defer func(old int) { bandsPerSeries = old }(bandsPerSeries) + bandsPerSeries = 1 + mmuCurve2 := NewMMUCurve(mu) + quantiles := []float64{0, 1 - .999, 1 - .99} + for window := time.Microsecond; window < time.Second; window *= 10 { + mud1 := mmuCurve.MUD(window, quantiles) + mud2 := mmuCurve2.MUD(window, quantiles) + for i := range mud1 { + if !aeq(mud1[i], mud2[i]) { + t.Errorf("for quantiles %v at window %v, want %v, got %v", quantiles, window, mud2, mud1) + break + } + } + } +} + +func BenchmarkMMU(b *testing.B) { + data, err := ioutil.ReadFile("testdata/stress_1_10_good") + if err != nil { + b.Fatalf("failed to read input file: %v", err) + } + _, events, err := parse(bytes.NewReader(data), "") + if err != nil { + b.Fatalf("failed to parse trace: %s", err) + } + mu := MutatorUtilization(events.Events, UtilSTW|UtilBackground|UtilAssist|UtilSweep) + b.ResetTimer() + + for i := 0; i < b.N; i++ { + mmuCurve := NewMMUCurve(mu) + xMin, xMax := time.Microsecond, time.Second + logMin, logMax := math.Log(float64(xMin)), math.Log(float64(xMax)) + const samples = 100 + for i := 0; i < samples; i++ { + window := time.Duration(math.Exp(float64(i)/(samples-1)*(logMax-logMin) + logMin)) + mmuCurve.MMU(window) + } + } +} + +func mmuSlow(util []MutatorUtil, window time.Duration) (mmu float64) { + if max := time.Duration(util[len(util)-1].Time - util[0].Time); window > max { + window = max + } + + mmu = 1.0 + + // muInWindow returns the mean mutator utilization between + // util[0].Time and end. + muInWindow := func(util []MutatorUtil, end int64) float64 { + total := 0.0 + var prevU MutatorUtil + for _, u := range util { + if u.Time > end { + total += prevU.Util * float64(end-prevU.Time) + break + } + total += prevU.Util * float64(u.Time-prevU.Time) + prevU = u + } + return total / float64(end-util[0].Time) + } + update := func() { + for i, u := range util { + if u.Time+int64(window) > util[len(util)-1].Time { + break + } + mmu = math.Min(mmu, muInWindow(util[i:], u.Time+int64(window))) + } + } + + // Consider all left-aligned windows. + update() + // Reverse the trace. Slightly subtle because each MutatorUtil + // is a *change*. + rutil := make([]MutatorUtil, len(util)) + if util[len(util)-1].Util != 0 { + panic("irreversible trace") + } + for i, u := range util { + util1 := 0.0 + if i != 0 { + util1 = util[i-1].Util + } + rutil[len(rutil)-i-1] = MutatorUtil{Time: -u.Time, Util: util1} + } + util = rutil + // Consider all right-aligned windows. + update() + return +} diff --git a/libgo/go/internal/trace/goroutines.go b/libgo/go/internal/trace/goroutines.go index 2d7d3aa3ae2..a5fda489bea 100644 --- a/libgo/go/internal/trace/goroutines.go +++ b/libgo/go/internal/trace/goroutines.go @@ -37,7 +37,7 @@ type UserRegionDesc struct { // Region end event. Normally EvUserRegion end event or nil, // but can be EvGoStop or EvGoEnd event if the goroutine - // terminated without explicitely ending the region. + // terminated without explicitly ending the region. End *Event GExecutionStat diff --git a/libgo/go/internal/trace/mud.go b/libgo/go/internal/trace/mud.go new file mode 100644 index 00000000000..88263060a0b --- /dev/null +++ b/libgo/go/internal/trace/mud.go @@ -0,0 +1,223 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package trace + +import ( + "math" + "sort" +) + +// mud is an updatable mutator utilization distribution. +// +// This is a continuous distribution of duration over mutator +// utilization. For example, the integral from mutator utilization a +// to b is the total duration during which the mutator utilization was +// in the range [a, b]. +// +// This distribution is *not* normalized (it is not a probability +// distribution). This makes it easier to work with as it's being +// updated. +// +// It is represented as the sum of scaled uniform distribution +// functions and Dirac delta functions (which are treated as +// degenerate uniform distributions). +type mud struct { + sorted, unsorted []edge + + // trackMass is the inverse cumulative sum to track as the + // distribution is updated. + trackMass float64 + // trackBucket is the bucket in which trackMass falls. If the + // total mass of the distribution is < trackMass, this is + // len(hist). + trackBucket int + // trackSum is the cumulative sum of hist[:trackBucket]. Once + // trackSum >= trackMass, trackBucket must be recomputed. + trackSum float64 + + // hist is a hierarchical histogram of distribution mass. + hist [mudDegree]float64 +} + +const ( + // mudDegree is the number of buckets in the MUD summary + // histogram. + mudDegree = 1024 +) + +type edge struct { + // At x, the function increases by y. + x, delta float64 + // Additionally at x is a Dirac delta function with area dirac. + dirac float64 +} + +// add adds a uniform function over [l, r] scaled so the total weight +// of the uniform is area. If l==r, this adds a Dirac delta function. +func (d *mud) add(l, r, area float64) { + if area == 0 { + return + } + + if r < l { + l, r = r, l + } + + // Add the edges. + if l == r { + d.unsorted = append(d.unsorted, edge{l, 0, area}) + } else { + delta := area / (r - l) + d.unsorted = append(d.unsorted, edge{l, delta, 0}, edge{r, -delta, 0}) + } + + // Update the histogram. + h := &d.hist + lbFloat, lf := math.Modf(l * mudDegree) + lb := int(lbFloat) + if lb >= mudDegree { + lb, lf = mudDegree-1, 1 + } + if l == r { + h[lb] += area + } else { + rbFloat, rf := math.Modf(r * mudDegree) + rb := int(rbFloat) + if rb >= mudDegree { + rb, rf = mudDegree-1, 1 + } + if lb == rb { + h[lb] += area + } else { + perBucket := area / (r - l) / mudDegree + h[lb] += perBucket * (1 - lf) + h[rb] += perBucket * rf + for i := lb + 1; i < rb; i++ { + h[i] += perBucket + } + } + } + + // Update mass tracking. + if thresh := float64(d.trackBucket) / mudDegree; l < thresh { + if r < thresh { + d.trackSum += area + } else { + d.trackSum += area * (thresh - l) / (r - l) + } + if d.trackSum >= d.trackMass { + // The tracked mass now falls in a different + // bucket. Recompute the inverse cumulative sum. + d.setTrackMass(d.trackMass) + } + } +} + +// setTrackMass sets the mass to track the inverse cumulative sum for. +// +// Specifically, mass is a cumulative duration, and the mutator +// utilization bounds for this duration can be queried using +// approxInvCumulativeSum. +func (d *mud) setTrackMass(mass float64) { + d.trackMass = mass + + // Find the bucket currently containing trackMass by computing + // the cumulative sum. + sum := 0.0 + for i, val := range d.hist[:] { + newSum := sum + val + if newSum > mass { + // mass falls in bucket i. + d.trackBucket = i + d.trackSum = sum + return + } + sum = newSum + } + d.trackBucket = len(d.hist) + d.trackSum = sum +} + +// approxInvCumulativeSum is like invCumulativeSum, but specifically +// operates on the tracked mass and returns an upper and lower bound +// approximation of the inverse cumulative sum. +// +// The true inverse cumulative sum will be in the range [lower, upper). +func (d *mud) approxInvCumulativeSum() (float64, float64, bool) { + if d.trackBucket == len(d.hist) { + return math.NaN(), math.NaN(), false + } + return float64(d.trackBucket) / mudDegree, float64(d.trackBucket+1) / mudDegree, true +} + +// invCumulativeSum returns x such that the integral of d from -∞ to x +// is y. If the total weight of d is less than y, it returns the +// maximum of the distribution and false. +// +// Specifically, y is a cumulative duration, and invCumulativeSum +// returns the mutator utilization x such that at least y time has +// been spent with mutator utilization <= x. +func (d *mud) invCumulativeSum(y float64) (float64, bool) { + if len(d.sorted) == 0 && len(d.unsorted) == 0 { + return math.NaN(), false + } + + // Sort edges. + edges := d.unsorted + sort.Slice(edges, func(i, j int) bool { + return edges[i].x < edges[j].x + }) + // Merge with sorted edges. + d.unsorted = nil + if d.sorted == nil { + d.sorted = edges + } else { + oldSorted := d.sorted + newSorted := make([]edge, len(oldSorted)+len(edges)) + i, j := 0, 0 + for o := range newSorted { + if i >= len(oldSorted) { + copy(newSorted[o:], edges[j:]) + break + } else if j >= len(edges) { + copy(newSorted[o:], oldSorted[i:]) + break + } else if oldSorted[i].x < edges[j].x { + newSorted[o] = oldSorted[i] + i++ + } else { + newSorted[o] = edges[j] + j++ + } + } + d.sorted = newSorted + } + + // Traverse edges in order computing a cumulative sum. + csum, rate, prevX := 0.0, 0.0, 0.0 + for _, e := range d.sorted { + newCsum := csum + (e.x-prevX)*rate + if newCsum >= y { + // y was exceeded between the previous edge + // and this one. + if rate == 0 { + // Anywhere between prevX and + // e.x will do. We return e.x + // because that takes care of + // the y==0 case naturally. + return e.x, true + } + return (y-csum)/rate + prevX, true + } + newCsum += e.dirac + if newCsum >= y { + // y was exceeded by the Dirac delta at e.x. + return e.x, true + } + csum, prevX = newCsum, e.x + rate += e.delta + } + return prevX, false +} diff --git a/libgo/go/internal/trace/mud_test.go b/libgo/go/internal/trace/mud_test.go new file mode 100644 index 00000000000..b3d74dcf342 --- /dev/null +++ b/libgo/go/internal/trace/mud_test.go @@ -0,0 +1,87 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package trace + +import ( + "math/rand" + "testing" +) + +func TestMUD(t *testing.T) { + // Insert random uniforms and check histogram mass and + // cumulative sum approximations. + rnd := rand.New(rand.NewSource(42)) + mass := 0.0 + var mud mud + for i := 0; i < 100; i++ { + area, l, r := rnd.Float64(), rnd.Float64(), rnd.Float64() + if rnd.Intn(10) == 0 { + r = l + } + t.Log(l, r, area) + mud.add(l, r, area) + mass += area + + // Check total histogram weight. + hmass := 0.0 + for _, val := range mud.hist { + hmass += val + } + if !aeq(mass, hmass) { + t.Fatalf("want mass %g, got %g", mass, hmass) + } + + // Check inverse cumulative sum approximations. + for j := 0.0; j < mass; j += mass * 0.099 { + mud.setTrackMass(j) + l, u, ok := mud.approxInvCumulativeSum() + inv, ok2 := mud.invCumulativeSum(j) + if !ok || !ok2 { + t.Fatalf("inverse cumulative sum failed: approx %v, exact %v", ok, ok2) + } + if !(l <= inv && inv < u) { + t.Fatalf("inverse(%g) = %g, not ∈ [%g, %g)", j, inv, l, u) + } + } + } +} + +func TestMUDTracking(t *testing.T) { + // Test that the tracked mass is tracked correctly across + // updates. + rnd := rand.New(rand.NewSource(42)) + const uniforms = 100 + for trackMass := 0.0; trackMass < uniforms; trackMass += uniforms / 50 { + var mud mud + mass := 0.0 + mud.setTrackMass(trackMass) + for i := 0; i < uniforms; i++ { + area, l, r := rnd.Float64(), rnd.Float64(), rnd.Float64() + mud.add(l, r, area) + mass += area + l, u, ok := mud.approxInvCumulativeSum() + inv, ok2 := mud.invCumulativeSum(trackMass) + + if mass < trackMass { + if ok { + t.Errorf("approx(%g) = [%g, %g), but mass = %g", trackMass, l, u, mass) + } + if ok2 { + t.Errorf("exact(%g) = %g, but mass = %g", trackMass, inv, mass) + } + } else { + if !ok { + t.Errorf("approx(%g) failed, but mass = %g", trackMass, mass) + } + if !ok2 { + t.Errorf("exact(%g) failed, but mass = %g", trackMass, mass) + } + if ok && ok2 && !(l <= inv && inv < u) { + t.Errorf("inverse(%g) = %g, not ∈ [%g, %g)", trackMass, inv, l, u) + } + } + } + } +} diff --git a/libgo/go/internal/trace/testdata/http_1_10_good b/libgo/go/internal/trace/testdata/http_1_10_good new file mode 100644 index 0000000000000000000000000000000000000000..a4f2ed83d84d2a5d8bf65f7b5a65bd7e178c41fd GIT binary patch literal 2201 zcma)7Z)h837|;9OT`rgAfB*m6(m(H-wCi01vK6;4MY}O{;M(ej6v8dJBqzyTmRz=} zUs72&rL#~wI}p0repsbL(1|c>oS8vTA#_ZKT97FYp(}Hp%G?Jh-h0UfYYo|#C%Jo` z=lA@6&-=X3g=M#o_4T=x1RoF#2E%~i<`1X7`i#tz1^_{x`Vv3__$intpCw4(Cx|?G zh@^lYl7qA%!~g_rd!KN7f(c zYhVq{K;uFqu-RV@)q>H8ee@3DIB?nO900GaVhMu=VshR^0seUmQIpQ@;;)d{I#jUH zr(gThfRnFw&jX#JNB%gE^105O!35M3t;3Kvn7xF7r25!LMHMG2XD%K_^N zTuhBCWU1H;gCALJkh!@Oqxm__YW}dCYXjuncQcTr-Y{Jp&p;z}mcISh4T3h+udF>J z81o8^s+@_Gq=+$r4Mcb;Aq0;4kfo~}p<*nDW3fzYgDz9`U_nVXl#&AKWaV5oc>D4g ztg@USR_mHLfFwpzWI+R=az4n%}#Tu2~$#e(sK98e49%mi5fb^_Y$KLg~j>u86= z$zy^LN6wx~#AD%r7K*VL5@aV|g$^f+Ty_7i16A8~hcc9sB$aDT>11`uIiJNi^?L@o zREf(EK8DrQ8g+Id18b-?`r1j{_O~{*z1Et1F&W^aQTA9uR0LGFvmEnc9QRW3k3T9( zspEb=7Toa|K7#rZ(m@TWfvbe11EnPKI7Vn}6eUGSs8^PY%PJ#J_ns%cYyqvQuN>Nj z94-{}>u}8uIf*eu_1YKJwUj+yImw08z*2JSzmp3TwzQX{P)x=ewpv0lh20ZRsI;OI za(9-?QNuVb3Qxd3J9F#L^RTvV-1Oa*^RT|*Lohje0X8v<9HMP=0CknNLK3%TBqAJ?6VV{@xQb*8G)M54 z3VA)1iWIu6*626V*~Qba%l;mH^ZjY)@xB7*G@11kWTNgWJWbCOhADTzVSdz}>r-<7 z-X+-W9)njW@U&dmG%YhLjoVv>gJqgIQ#iD^m$JbGuphi F`~$y}2HXGu literal 0 HcmV?d00001 diff --git a/libgo/go/internal/trace/testdata/http_1_11_good b/libgo/go/internal/trace/testdata/http_1_11_good new file mode 100644 index 0000000000000000000000000000000000000000..0efcc6fba19a32c47c9b67a4d3847a6462f8cdc3 GIT binary patch literal 2779 zcmbVNeQXnD7~lK0ckQ)Z+qLUp1IGAxq20zE9iLHI=*A$L5c#O`4@o`RYu9+atJj-= zk#IwZz!dhOF$&p0AjAX=pwY~l*yKb3Q~!X7gak+w|3Z%i^7Z|)9&yqN|N+ilPUA{5M@OpX8;1uRh>=#m=H@wc~yu75Ofho93!hqS>nY2GBL!HjEO>E z=R3e*$y0B6Xe+~iOKaLPKC0!G@#iRF?V8q(zhh(9a_zjA7@L+`&bJd|)wB>l42Wg4 zT!_yBVzIY_A8pjMPTr~II`dTjG>fD9*~^qOJ`60!8-dF;2I8$?V=r)TJV4c~y$(Df z@Y8$6cDpQQy1i@6LGL?MPXqo4M(^NTv|I;&6cSs5aX0PnB?F#ecf<2_O|h^S>;Pe$QH zIm(M%LY5Pvz;(+hZ20GsDeMt>DS;ncMu~DI4CBcrWJJ3RV0B%OBnb+#xDAhy3R%l8 zfAi`9i(f=cog}DSx2mQix{;hO9W`N|T59FBs!;7G`N zu$t~2%R)1C!n*(dCy=K0(E7C|W1Dp9#$A)$aod8b9k>rQ znG%YC&c`aKuN29p6*-F8(isR&<@#W?Glg6=25hvOmokDB3nKSKut_+XM2*kjy)=p9 zg!QFP%guwm(BeujGc z-BDQQ+y3FlSvZNxTfgihTk-X{t(aVEjIWSh&oDLT#Yw$c=fSg8C z8Xm~MSxKtG8byvLMInQxPJZA=KCTK%iKS_-%vLGN`kSAYqC$XOA*04674SxaIT?qN zX-xNwPouB#*!Er@f|I>Rt=Gl|VZC<*etu*WHu#3XjSE>gh1$!U#}_n}`onti#6dW% zvGuD@vv4}~yY-g=Le=$gR5g`3A*-qg(HDbgM!7@GP52)@VuQNJ1+RY43!B`7rVID7 za0WhAG}C3Uji2$P^a7goLKU7%m=*7#W(~a)!X-bqthfX{kh<M`gKXz=8f+}W`k2HRM)z)o0MQzS)S zTVt!VwJ&y@feX0Z@Q1?XUwgPkow0&DSUYNc+jW}*^c&Z_u-tiu=zq9d*dQxn3@tK* zk}do%6x35+YOx%A<2AU@nYa9QZxAl>_QA7~{>nX>UAdGF-85*1#Id59Lr1o!c2-;!* literal 0 HcmV?d00001 diff --git a/libgo/go/internal/trace/testdata/http_1_9_good b/libgo/go/internal/trace/testdata/http_1_9_good new file mode 100644 index 0000000000000000000000000000000000000000..ca892788383bbfe4c2585ff480a20780557c325f GIT binary patch literal 2187 zcmb7EU2Icj7~c1tzqZ@jp6;jnryKiNyRmatV{|6oEV>adNZe20!X@?4o_00eIi)=X z^s0lgU?4Cy+y&7M$Y6S5AOwHLhA<8nuvod+jK&zVpi#^&)R-tlFZ{l@G|bR@ zCW=pYASOsqv!MT+?lWhE!kP)zoX z9sx9$VeUZ2VwJ|(^esWEO5f^`W}GBC(rJH&dE{kFO82}E?cp?J=gNV@p@yAcP<9SZ zP<-#K-PHyDUME_+i>Q-l%NZbj0B|B9@=GTHiN)#kGlQ?$27a{^vtyupwSi*i%evsz z!>5fjhJ6uEeDy~;qDzx+CWBHeCLByeH5oC_i$m(LEJ~@Q7FEQEDum<%VlojFvpDgs z?3X|+s-zADq~XwW&k7M0u{ox_1`{V1Vls(RO7sw6uvAACO-^9P#JGwTd0Ts4_6Zwo z){cB^n{vc(C}7groNAJAM6v7H>WW+Pv8YKgjDfl2k|&clB$PH4NG3JdOTxpN&=XH! zSuq7Un)Bsgm}sC#meZ-p#P0~!yW1!9r4+=s=F7}NMKcBGyDAk~6NfY{9w4W}01msQ zsDjGc^Rbu-;xNW-WMQImEBPsqfGTQp7~@_vqH!Nl^;ewMYv*Sm%^bBHdpHeQ?jx{r z^CGlZzXUgK%t2f6x8U7hF2R!0DKNcs1=<~tz`g4W(8*76%lB3(SDE|zcYjgk70aB? zQh+QVs^k+XMT-v0LZ2*!2FPL}w>Mt_S*&O*Ffp;Jdh=1gCM7f>oKk{*R4qIeO^!_G zi{WPZ~!R8#gJ{HV6f?1Ry|eR5b$$hz0c+`K&xYpQE5-(P^W{O{aP zS4r`wwiIu*fOEzJHK?w{tl#jzKJT!aI^qd6h%48v5S+Vv9M;vpff_1JIT%F7AenVw zo5Q@&`cjG_Cy*yMbS6~ym$F~Kvj`jb74FWZ1-Om>nVG%206qNY+}Jguf8yWzQDb>l zjbJolm)aj3l0&E|*UNrQjc@dFyDJOL+DvXxv&+^VP@`827#}?bceDt|TVYb+nF-1fY+NjktGCf$?f!A- zt^Wq-jessNLCBY*Ns@^l7?Ss@iC74=nsy7uCKx@?J2`Ic!U^cBpX0`6CSj}lF#K(a z463`pGrHf#KCPF38UyV?ZB=G(aiLEPqu|$VC17oG5w_t;LpyVpVpuq;>__dsf|g>O z6eEV(Sg`isDBRh89v~q%b-^J?Nyxziek2xLBZ4JNE(cuxWCRN0D0TKsR$Ip=#-yx- o{K#KnmX%$ljTO^7?cBtBBd|l;M1& literal 0 HcmV?d00001 diff --git a/libgo/go/internal/trace/testdata/stress_1_10_good b/libgo/go/internal/trace/testdata/stress_1_10_good new file mode 100644 index 0000000000000000000000000000000000000000..19778b080864f5147e48caf4d32f3dd3bc8034b1 GIT binary patch literal 370999 zcmZ^s2YejG_4sdZ@Ahu@PL^%S(n&fs%d*@ny^}By#UbI$h0s9;4zMAV04We+u)!1| zn@;GVDb&zgLa(7iLI~YJLJbZH5FjMv|9x+ES1a@Te?Io=_RX6&Z{EB%vpci<9@I5= z*4#N=haE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2sKz7#Aqr;H7y zRrRs+X2HUSm^q(TeRAKx{WDg|1rg8r@BUl0JSOUt^!77*<+1jD-)=l07itTn57*JM zKk)x~*`uN@=btCaY4@)vCvR{k`D3-7b%M@J8NmZS4#i43!XYy*;qrw%fmON?Y{iy-7Q|2ko&-4cMkWa3fF8^uZ!{?c}+9!E4lWaHH zKR2$YH+Z=G25*rce7$)SqpT(a)R^?h8{AEJ^ z?a`Z(>Sdk@ZemvclF+cRmaXau0tB$prb)3k79yD=aqzC&&pO2cRDrq_vp@G=)9kGxl!btuZ336yT)g_2Q>_e4HMB*WcKSJgA`Sd^GJ6B#@X!>8Q*XDVoteXF8Wz{^% z$3GX8l;(NHP z7fZ1Rr30*G`4o#H$-hEmE~j+(3@_zVk~gur)uehBFCk9m!(VeU&XLkWmSp@>^4^v0 z_-_XEGE;3|U*8!{yHxi9Y4u)GylwBlMa=4xC@ztFWQY)1m1JW}Z{6(jl8KDt zwZ|nB^BeMa%JQbUm7V`uDld^Tzq7BNw^Uv#Wj-N)0g~}?seS5kMl9#+4Y!Z9hy~vt GO8*0#!Y%^< literal 0 HcmV?d00001 diff --git a/libgo/go/internal/trace/testdata/stress_start_stop_1_10_good b/libgo/go/internal/trace/testdata/stress_start_stop_1_10_good new file mode 100644 index 0000000000000000000000000000000000000000..b908e10f2567d64df0feb9dea43c216ee694c76c GIT binary patch literal 6338 zcmbVQ3vd+Yec%1Q-MzitJDu)UI_d7D({uIage34In2crkOo%XHrAyp4)bu#r3W21< z(g|>y#45!iF6vo9hS=B!;Utz{Gsd{~$RTbiXAe$-92x^nGEMDCCXGFf<9gc6WD?W# z|NmBZJQ}J_W|(95|NZ{&*S8u-S9ioZmRDy+6Umey2;IUzo%rFuo{<(LK_uc9O&LV#VrH?ny$dBrn=x&h0}T!VD$@=36%XgpP> zq}ji$SLS@0@V<1HM#cC-ji3bBUlBcPM5C6gM2WI5dXx}5>k*V&*vq1xRiibQUZS)y zK4Qy{L0MnRpj zg8dy=)Q%?=>?A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-Ri3&$P0Gq|I(6v+3CS-LGhC=ZE_PkI5Axk_MwT>;!_lycf?wFHaqM5SGT$ME z`bh80HP^`B_{|InNB+z8+L0Mj5jjj=xcCC8EN=egF-*v0At7eeb0t=TBRMw_C%%1v zMD^{tP>`N|6his>=6y!2p;g&K$|Ped1}*TU8v+xg~M>cUbl@v%26$ zZz|Ex-N^Y%$xoh}A=QydI(Z2>D$JTfS%8K1;K;pZ?b0;>xWo{)8+`Gfxby(2sXZ>5 zb$`SNT#?hf;_2^RAa(L1BnN-MJh6b2WY%le7xFle+ys-Pdu(iQEMuBC?2vpl!88~K zJZ7??(D?&Nhrb)^Jl7nNC!X6+>dgc4J5TH<4d$=u(Qjc6ekNU?1Ggcb{TKs!tJxUN z=dh_|IGKR5YL1Ph_GIoHO{L7HLbOLxyVF~@r;-`7x!^(~dGGk(XsU0#KRsZ!5by} zHrtnU0kOPnT;jyX2T81bR?KPDV!nBEnj%im;tV?}o68Hy8^gVscggH1xX-7UQ`pT# z^7+G4WVwFAb?lKD(h=E9zRG7~+5eh@of@~IZwQu4F65`b|L`E`Z14UBZ`lW~v}{*2 zpKd-G)~&%6=u{C`oNErtkN(FD>580p{o_%rqVM0Rip&*%L~E?fX}Wm+dl$$Gc@|nj z6VLwuN8AKF2jH&~GZ4KWin&lZy}=~R1)_yj_}dADpBK%QP5CzAPW{0J#iz=xIn5(Z Vzj=YIl>ZHKR3ctFhnCEd{{gvjRRRD2 literal 0 HcmV?d00001 diff --git a/libgo/go/internal/trace/testdata/stress_start_stop_1_11_good b/libgo/go/internal/trace/testdata/stress_start_stop_1_11_good new file mode 100644 index 0000000000000000000000000000000000000000..457f01a6cdec08a1ab02e3fb486ee0534140d467 GIT binary patch literal 4882 zcmbtXeRLGn72o$}_GNcAv)|wO*km_DzFJFsol!%>IL&Ki^K#@$eC z4^==2LLkNtUZVHpUIs& z_v_vJyT7-ICrfI>wY4SfDJ2@y>2&qFdk=omyZ?)O5X}?FE=1RJd{?!II=C>Oa%g1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!MQSGCfkl|p6V|JM0AlO~D z>cixxcc);o_9*!57l(G*qixl(Q?2X$ZoX5ilxBZugBoFM#17k@RFObv6^uEZZF0i z`;BM3(r>}OfKgL&&3R!!HHTdrG(WKgo^DR@9~(G+PVHKg;lCN7mh}HVZFNNHn`ai_ zcE0WNuV-OX^9gYE>;g>jt=@9w+yZRjQ>Znx3Mv#NRkK(K<}OUY)?mTn0bDm^s4eat zcGdLieRi+2Xh+pdeWqTlm1lMBHgG z?M|#%ZB~2J8nMFDcx=C}nfQ>o>c}V$r+=7*?ae#yx>7oE!~~XqRtJh{ 0 { + f.expander.Reset() + f.expander.Write(f.prev) + f.expander.Write(f.info) + f.expander.Write([]byte{f.counter}) + f.prev = f.expander.Sum(f.prev[:0]) + f.counter++ + + // Copy the new batch into p + f.buf = f.prev + n = copy(p, f.buf) + p = p[n:] + } + // Save leftovers for next run + f.buf = f.buf[n:] + + return need, nil +} + +// Expand returns a Reader, from which keys can be read, using the given +// pseudorandom key and optional context info, skipping the extraction step. +// +// The pseudorandomKey should have been generated by Extract, or be a uniformly +// random or pseudorandom cryptographically strong key. See RFC 5869, Section +// 3.3. Most common scenarios will want to use New instead. +func Expand(hash func() hash.Hash, pseudorandomKey, info []byte) io.Reader { + expander := hmac.New(hash, pseudorandomKey) + return &hkdf{expander, expander.Size(), info, 1, nil, nil} +} + +// New returns a Reader, from which keys can be read, using the given hash, +// secret, salt and context info. Salt and info can be nil. +func New(hash func() hash.Hash, secret, salt, info []byte) io.Reader { + prk := Extract(hash, secret, salt) + return Expand(hash, prk, info) +} diff --git a/libgo/go/internal/x/crypto/hkdf/hkdf_test.go b/libgo/go/internal/x/crypto/hkdf/hkdf_test.go new file mode 100644 index 00000000000..ea575772ef2 --- /dev/null +++ b/libgo/go/internal/x/crypto/hkdf/hkdf_test.go @@ -0,0 +1,449 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. +package hkdf + +import ( + "bytes" + "crypto/md5" + "crypto/sha1" + "crypto/sha256" + "crypto/sha512" + "hash" + "io" + "testing" +) + +type hkdfTest struct { + hash func() hash.Hash + master []byte + salt []byte + prk []byte + info []byte + out []byte +} + +var hkdfTests = []hkdfTest{ + // Tests from RFC 5869 + { + sha256.New, + []byte{ + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + }, + []byte{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, + }, + []byte{ + 0x07, 0x77, 0x09, 0x36, 0x2c, 0x2e, 0x32, 0xdf, + 0x0d, 0xdc, 0x3f, 0x0d, 0xc4, 0x7b, 0xba, 0x63, + 0x90, 0xb6, 0xc7, 0x3b, 0xb5, 0x0f, 0x9c, 0x31, + 0x22, 0xec, 0x84, 0x4a, 0xd7, 0xc2, 0xb3, 0xe5, + }, + []byte{ + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, + }, + []byte{ + 0x3c, 0xb2, 0x5f, 0x25, 0xfa, 0xac, 0xd5, 0x7a, + 0x90, 0x43, 0x4f, 0x64, 0xd0, 0x36, 0x2f, 0x2a, + 0x2d, 0x2d, 0x0a, 0x90, 0xcf, 0x1a, 0x5a, 0x4c, + 0x5d, 0xb0, 0x2d, 0x56, 0xec, 0xc4, 0xc5, 0xbf, + 0x34, 0x00, 0x72, 0x08, 0xd5, 0xb8, 0x87, 0x18, + 0x58, 0x65, + }, + }, + { + sha256.New, + []byte{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + }, + []byte{ + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, + 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + }, + []byte{ + 0x06, 0xa6, 0xb8, 0x8c, 0x58, 0x53, 0x36, 0x1a, + 0x06, 0x10, 0x4c, 0x9c, 0xeb, 0x35, 0xb4, 0x5c, + 0xef, 0x76, 0x00, 0x14, 0x90, 0x46, 0x71, 0x01, + 0x4a, 0x19, 0x3f, 0x40, 0xc1, 0x5f, 0xc2, 0x44, + }, + []byte{ + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, + 0xb8,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0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + }, + []byte{}, + []byte{ + 0x19, 0xef, 0x24, 0xa3, 0x2c, 0x71, 0x7b, 0x16, + 0x7f, 0x33, 0xa9, 0x1d, 0x6f, 0x64, 0x8b, 0xdf, + 0x96, 0x59, 0x67, 0x76, 0xaf, 0xdb, 0x63, 0x77, + 0xac, 0x43, 0x4c, 0x1c, 0x29, 0x3c, 0xcb, 0x04, + }, + []byte{}, + []byte{ + 0x8d, 0xa4, 0xe7, 0x75, 0xa5, 0x63, 0xc1, 0x8f, + 0x71, 0x5f, 0x80, 0x2a, 0x06, 0x3c, 0x5a, 0x31, + 0xb8, 0xa1, 0x1f, 0x5c, 0x5e, 0xe1, 0x87, 0x9e, + 0xc3, 0x45, 0x4e, 0x5f, 0x3c, 0x73, 0x8d, 0x2d, + 0x9d, 0x20, 0x13, 0x95, 0xfa, 0xa4, 0xb6, 0x1a, + 0x96, 0xc8, + }, + }, + { + sha256.New, + []byte{ + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + }, + nil, + []byte{ + 0x19, 0xef, 0x24, 0xa3, 0x2c, 0x71, 0x7b, 0x16, + 0x7f, 0x33, 0xa9, 0x1d, 0x6f, 0x64, 0x8b, 0xdf, + 0x96, 0x59, 0x67, 0x76, 0xaf, 0xdb, 0x63, 0x77, + 0xac, 0x43, 0x4c, 0x1c, 0x29, 0x3c, 0xcb, 0x04, + }, + nil, + []byte{ + 0x8d, 0xa4, 0xe7, 0x75, 0xa5, 0x63, 0xc1, 0x8f, + 0x71, 0x5f, 0x80, 0x2a, 0x06, 0x3c, 0x5a, 0x31, + 0xb8, 0xa1, 0x1f, 0x5c, 0x5e, 0xe1, 0x87, 0x9e, + 0xc3, 0x45, 0x4e, 0x5f, 0x3c, 0x73, 0x8d, 0x2d, + 0x9d, 0x20, 0x13, 0x95, 0xfa, 0xa4, 0xb6, 0x1a, + 0x96, 0xc8, + }, + }, + { + sha1.New, + []byte{ + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, + }, + []byte{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, + }, + []byte{ + 0x9b, 0x6c, 0x18, 0xc4, 0x32, 0xa7, 0xbf, 0x8f, + 0x0e, 0x71, 0xc8, 0xeb, 0x88, 0xf4, 0xb3, 0x0b, + 0xaa, 0x2b, 0xa2, 0x43, + }, + []byte{ + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, + }, + []byte{ + 0x08, 0x5a, 0x01, 0xea, 0x1b, 0x10, 0xf3, 0x69, + 0x33, 0x06, 0x8b, 0x56, 0xef, 0xa5, 0xad, 0x81, + 0xa4, 0xf1, 0x4b, 0x82, 0x2f, 0x5b, 0x09, 0x15, + 0x68, 0xa9, 0xcd, 0xd4, 0xf1, 0x55, 0xfd, 0xa2, + 0xc2, 0x2e, 0x42, 0x24, 0x78, 0xd3, 0x05, 0xf3, + 0xf8, 0x96, + }, + }, + { + sha1.New, + []byte{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + }, + []byte{ + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, + 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + }, + []byte{ + 0x8a, 0xda, 0xe0, 0x9a, 0x2a, 0x30, 0x70, 0x59, + 0x47, 0x8d, 0x30, 0x9b, 0x26, 0xc4, 0x11, 0x5a, + 0x22, 0x4c, 0xfa, 0xf6, + }, + []byte{ + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, + 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, + }, + []byte{ + 0x0b, 0xd7, 0x70, 0xa7, 0x4d, 0x11, 0x60, 0xf7, + 0xc9, 0xf1, 0x2c, 0xd5, 0x91, 0x2a, 0x06, 0xeb, + 0xff, 0x6a, 0xdc, 0xae, 0x89, 0x9d, 0x92, 0x19, + 0x1f, 0xe4, 0x30, 0x56, 0x73, 0xba, 0x2f, 0xfe, + 0x8f, 0xa3, 0xf1, 0xa4, 0xe5, 0xad, 0x79, 0xf3, + 0xf3, 0x34, 0xb3, 0xb2, 0x02, 0xb2, 0x17, 0x3c, + 0x48, 0x6e, 0xa3, 0x7c, 0xe3, 0xd3, 0x97, 0xed, + 0x03, 0x4c, 0x7f, 0x9d, 0xfe, 0xb1, 0x5c, 0x5e, + 0x92, 0x73, 0x36, 0xd0, 0x44, 0x1f, 0x4c, 0x43, + 0x00, 0xe2, 0xcf, 0xf0, 0xd0, 0x90, 0x0b, 0x52, + 0xd3, 0xb4, + }, + }, + { + sha1.New, + []byte{ + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + }, + []byte{}, + []byte{ + 0xda, 0x8c, 0x8a, 0x73, 0xc7, 0xfa, 0x77, 0x28, + 0x8e, 0xc6, 0xf5, 0xe7, 0xc2, 0x97, 0x78, 0x6a, + 0xa0, 0xd3, 0x2d, 0x01, + }, + []byte{}, + []byte{ + 0x0a, 0xc1, 0xaf, 0x70, 0x02, 0xb3, 0xd7, 0x61, + 0xd1, 0xe5, 0x52, 0x98, 0xda, 0x9d, 0x05, 0x06, + 0xb9, 0xae, 0x52, 0x05, 0x72, 0x20, 0xa3, 0x06, + 0xe0, 0x7b, 0x6b, 0x87, 0xe8, 0xdf, 0x21, 0xd0, + 0xea, 0x00, 0x03, 0x3d, 0xe0, 0x39, 0x84, 0xd3, + 0x49, 0x18, + }, + }, + { + sha1.New, + []byte{ + 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, + }, + nil, + []byte{ + 0x2a, 0xdc, 0xca, 0xda, 0x18, 0x77, 0x9e, 0x7c, + 0x20, 0x77, 0xad, 0x2e, 0xb1, 0x9d, 0x3f, 0x3e, + 0x73, 0x13, 0x85, 0xdd, + }, + nil, + []byte{ + 0x2c, 0x91, 0x11, 0x72, 0x04, 0xd7, 0x45, 0xf3, + 0x50, 0x0d, 0x63, 0x6a, 0x62, 0xf6, 0x4f, 0x0a, + 0xb3, 0xba, 0xe5, 0x48, 0xaa, 0x53, 0xd4, 0x23, + 0xb0, 0xd1, 0xf2, 0x7e, 0xbb, 0xa6, 0xf5, 0xe5, + 0x67, 0x3a, 0x08, 0x1d, 0x70, 0xcc, 0xe7, 0xac, + 0xfc, 0x48, + }, + }, +} + +func TestHKDF(t *testing.T) { + for i, tt := range hkdfTests { + prk := Extract(tt.hash, tt.master, tt.salt) + if !bytes.Equal(prk, tt.prk) { + t.Errorf("test %d: incorrect PRK: have %v, need %v.", i, prk, tt.prk) + } + + hkdf := New(tt.hash, tt.master, tt.salt, tt.info) + out := make([]byte, len(tt.out)) + + n, err := io.ReadFull(hkdf, out) + if n != len(tt.out) || err != nil { + t.Errorf("test %d: not enough output bytes: %d.", i, n) + } + + if !bytes.Equal(out, tt.out) { + t.Errorf("test %d: incorrect output: have %v, need %v.", i, out, tt.out) + } + + hkdf = Expand(tt.hash, prk, tt.info) + + n, err = io.ReadFull(hkdf, out) + if n != len(tt.out) || err != nil { + t.Errorf("test %d: not enough output bytes from Expand: %d.", i, n) + } + + if !bytes.Equal(out, tt.out) { + t.Errorf("test %d: incorrect output from Expand: have %v, need %v.", i, out, tt.out) + } + } +} + +func TestHKDFMultiRead(t *testing.T) { + for i, tt := range hkdfTests { + hkdf := New(tt.hash, tt.master, tt.salt, tt.info) + out := make([]byte, len(tt.out)) + + for b := 0; b < len(tt.out); b++ { + n, err := io.ReadFull(hkdf, out[b:b+1]) + if n != 1 || err != nil { + t.Errorf("test %d.%d: not enough output bytes: have %d, need %d .", i, b, n, len(tt.out)) + } + } + + if !bytes.Equal(out, tt.out) { + t.Errorf("test %d: incorrect output: have %v, need %v.", i, out, tt.out) + } + } +} + +func TestHKDFLimit(t *testing.T) { + hash := sha1.New + master := []byte{0x00, 0x01, 0x02, 0x03} + info := []byte{} + + hkdf := New(hash, master, nil, info) + limit := hash().Size() * 255 + out := make([]byte, limit) + + // The maximum output bytes should be extractable + n, err := io.ReadFull(hkdf, out) + if n != limit || err != nil { + t.Errorf("not enough output bytes: %d, %v.", n, err) + } + + // Reading one more should fail + n, err = io.ReadFull(hkdf, make([]byte, 1)) + if n > 0 || err == nil { + t.Errorf("key expansion overflowed: n = %d, err = %v", n, err) + } +} + +func Benchmark16ByteMD5Single(b *testing.B) { + benchmarkHKDFSingle(md5.New, 16, b) +} + +func Benchmark20ByteSHA1Single(b *testing.B) { + benchmarkHKDFSingle(sha1.New, 20, b) +} + +func Benchmark32ByteSHA256Single(b *testing.B) { + benchmarkHKDFSingle(sha256.New, 32, b) +} + +func Benchmark64ByteSHA512Single(b *testing.B) { + benchmarkHKDFSingle(sha512.New, 64, b) +} + +func Benchmark8ByteMD5Stream(b *testing.B) { + benchmarkHKDFStream(md5.New, 8, b) +} + +func Benchmark16ByteMD5Stream(b *testing.B) { + benchmarkHKDFStream(md5.New, 16, b) +} + +func Benchmark8ByteSHA1Stream(b *testing.B) { + benchmarkHKDFStream(sha1.New, 8, b) +} + +func Benchmark20ByteSHA1Stream(b *testing.B) { + benchmarkHKDFStream(sha1.New, 20, b) +} + +func Benchmark8ByteSHA256Stream(b *testing.B) { + benchmarkHKDFStream(sha256.New, 8, b) +} + +func Benchmark32ByteSHA256Stream(b *testing.B) { + benchmarkHKDFStream(sha256.New, 32, b) +} + +func Benchmark8ByteSHA512Stream(b *testing.B) { + benchmarkHKDFStream(sha512.New, 8, b) +} + +func Benchmark64ByteSHA512Stream(b *testing.B) { + benchmarkHKDFStream(sha512.New, 64, b) +} + +func benchmarkHKDFSingle(hasher func() hash.Hash, block int, b *testing.B) { + master := []byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07} + salt := []byte{0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17} + info := []byte{0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27} + out := make([]byte, block) + + b.SetBytes(int64(block)) + b.ResetTimer() + + for i := 0; i < b.N; i++ { + hkdf := New(hasher, master, salt, info) + io.ReadFull(hkdf, out) + } +} + +func benchmarkHKDFStream(hasher func() hash.Hash, block int, b *testing.B) { + master := []byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07} + salt := []byte{0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17} + info := []byte{0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27} + out := make([]byte, block) + + b.SetBytes(int64(block)) + b.ResetTimer() + + hkdf := New(hasher, master, salt, info) + for i := 0; i < b.N; i++ { + _, err := io.ReadFull(hkdf, out) + if err != nil { + hkdf = New(hasher, master, salt, info) + i-- + } + } +} diff --git a/libgo/go/golang_org/x/crypto/internal/chacha20/chacha_generic.go b/libgo/go/internal/x/crypto/internal/chacha20/chacha_generic.go similarity index 100% rename from libgo/go/golang_org/x/crypto/internal/chacha20/chacha_generic.go rename to libgo/go/internal/x/crypto/internal/chacha20/chacha_generic.go diff --git a/libgo/go/golang_org/x/crypto/internal/chacha20/chacha_noasm.go b/libgo/go/internal/x/crypto/internal/chacha20/chacha_noasm.go similarity index 100% rename from libgo/go/golang_org/x/crypto/internal/chacha20/chacha_noasm.go rename to libgo/go/internal/x/crypto/internal/chacha20/chacha_noasm.go diff --git a/libgo/go/golang_org/x/crypto/internal/chacha20/chacha_s390x.go b/libgo/go/internal/x/crypto/internal/chacha20/chacha_s390x.go similarity index 100% rename from libgo/go/golang_org/x/crypto/internal/chacha20/chacha_s390x.go rename to libgo/go/internal/x/crypto/internal/chacha20/chacha_s390x.go diff --git a/libgo/go/golang_org/x/crypto/internal/chacha20/chacha_test.go b/libgo/go/internal/x/crypto/internal/chacha20/chacha_test.go similarity index 100% rename from libgo/go/golang_org/x/crypto/internal/chacha20/chacha_test.go rename to libgo/go/internal/x/crypto/internal/chacha20/chacha_test.go diff --git a/libgo/go/golang_org/x/crypto/internal/chacha20/vectors_test.go b/libgo/go/internal/x/crypto/internal/chacha20/vectors_test.go similarity index 100% rename from libgo/go/golang_org/x/crypto/internal/chacha20/vectors_test.go rename to libgo/go/internal/x/crypto/internal/chacha20/vectors_test.go diff --git a/libgo/go/golang_org/x/crypto/internal/chacha20/xor.go b/libgo/go/internal/x/crypto/internal/chacha20/xor.go similarity index 100% rename from libgo/go/golang_org/x/crypto/internal/chacha20/xor.go rename to libgo/go/internal/x/crypto/internal/chacha20/xor.go diff --git a/libgo/go/golang_org/x/crypto/poly1305/poly1305.go b/libgo/go/internal/x/crypto/poly1305/poly1305.go similarity index 95% rename from libgo/go/golang_org/x/crypto/poly1305/poly1305.go rename to libgo/go/internal/x/crypto/poly1305/poly1305.go index f562fa5712b..6d6be9a6406 100644 --- a/libgo/go/golang_org/x/crypto/poly1305/poly1305.go +++ b/libgo/go/internal/x/crypto/poly1305/poly1305.go @@ -17,7 +17,7 @@ used with a fixed key in order to generate one-time keys from an nonce. However, in this package AES isn't used and the one-time key is specified directly. */ -package poly1305 // import "golang.org/x/crypto/poly1305" +package poly1305 import "crypto/subtle" diff --git a/libgo/go/golang_org/x/crypto/poly1305/poly1305_test.go b/libgo/go/internal/x/crypto/poly1305/poly1305_test.go similarity index 100% rename from libgo/go/golang_org/x/crypto/poly1305/poly1305_test.go rename to libgo/go/internal/x/crypto/poly1305/poly1305_test.go diff --git a/libgo/go/golang_org/x/crypto/poly1305/sum_amd64.go b/libgo/go/internal/x/crypto/poly1305/sum_amd64.go similarity index 100% rename from libgo/go/golang_org/x/crypto/poly1305/sum_amd64.go rename to libgo/go/internal/x/crypto/poly1305/sum_amd64.go diff --git a/libgo/go/golang_org/x/crypto/poly1305/sum_arm.go b/libgo/go/internal/x/crypto/poly1305/sum_arm.go similarity index 100% rename from libgo/go/golang_org/x/crypto/poly1305/sum_arm.go rename to libgo/go/internal/x/crypto/poly1305/sum_arm.go diff --git a/libgo/go/golang_org/x/crypto/poly1305/sum_noasm.go b/libgo/go/internal/x/crypto/poly1305/sum_noasm.go similarity index 100% rename from libgo/go/golang_org/x/crypto/poly1305/sum_noasm.go rename to libgo/go/internal/x/crypto/poly1305/sum_noasm.go diff --git a/libgo/go/golang_org/x/crypto/poly1305/sum_ref.go b/libgo/go/internal/x/crypto/poly1305/sum_ref.go similarity index 100% rename from libgo/go/golang_org/x/crypto/poly1305/sum_ref.go rename to libgo/go/internal/x/crypto/poly1305/sum_ref.go diff --git a/libgo/go/golang_org/x/crypto/poly1305/sum_s390x.go b/libgo/go/internal/x/crypto/poly1305/sum_s390x.go similarity index 100% rename from libgo/go/golang_org/x/crypto/poly1305/sum_s390x.go rename to libgo/go/internal/x/crypto/poly1305/sum_s390x.go diff --git a/libgo/go/golang_org/x/crypto/poly1305/vectors_test.go b/libgo/go/internal/x/crypto/poly1305/vectors_test.go similarity index 100% rename from libgo/go/golang_org/x/crypto/poly1305/vectors_test.go rename to libgo/go/internal/x/crypto/poly1305/vectors_test.go diff --git a/libgo/go/golang_org/x/net/dns/dnsmessage/example_test.go b/libgo/go/internal/x/net/dns/dnsmessage/example_test.go similarity index 97% rename from libgo/go/golang_org/x/net/dns/dnsmessage/example_test.go rename to libgo/go/internal/x/net/dns/dnsmessage/example_test.go index d14fb3aaf1c..4cfe2efc184 100644 --- a/libgo/go/golang_org/x/net/dns/dnsmessage/example_test.go +++ b/libgo/go/internal/x/net/dns/dnsmessage/example_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build gccgo_examples +// +build ignore package dnsmessage_test @@ -11,7 +11,7 @@ import ( "net" "strings" - "golang_org/x/net/dns/dnsmessage" + "internal/x/net/dns/dnsmessage" ) func mustNewName(name string) dnsmessage.Name { diff --git a/libgo/go/golang_org/x/net/dns/dnsmessage/message.go b/libgo/go/internal/x/net/dns/dnsmessage/message.go similarity index 100% rename from libgo/go/golang_org/x/net/dns/dnsmessage/message.go rename to libgo/go/internal/x/net/dns/dnsmessage/message.go diff --git a/libgo/go/golang_org/x/net/dns/dnsmessage/message_test.go b/libgo/go/internal/x/net/dns/dnsmessage/message_test.go similarity index 100% rename from libgo/go/golang_org/x/net/dns/dnsmessage/message_test.go rename to libgo/go/internal/x/net/dns/dnsmessage/message_test.go diff --git a/libgo/go/golang_org/x/net/http/httpguts/guts.go b/libgo/go/internal/x/net/http/httpguts/guts.go similarity index 100% rename from libgo/go/golang_org/x/net/http/httpguts/guts.go rename to libgo/go/internal/x/net/http/httpguts/guts.go diff --git a/libgo/go/golang_org/x/net/http/httpguts/httplex.go b/libgo/go/internal/x/net/http/httpguts/httplex.go similarity index 99% rename from libgo/go/golang_org/x/net/http/httpguts/httplex.go rename to libgo/go/internal/x/net/http/httpguts/httplex.go index 9337435174e..7f3cdd8bd25 100644 --- a/libgo/go/golang_org/x/net/http/httpguts/httplex.go +++ b/libgo/go/internal/x/net/http/httpguts/httplex.go @@ -9,7 +9,7 @@ import ( "strings" "unicode/utf8" - "golang_org/x/net/idna" + "internal/x/net/idna" ) var isTokenTable = [127]bool{ diff --git a/libgo/go/golang_org/x/net/http/httpguts/httplex_test.go b/libgo/go/internal/x/net/http/httpguts/httplex_test.go similarity index 100% rename from libgo/go/golang_org/x/net/http/httpguts/httplex_test.go rename to libgo/go/internal/x/net/http/httpguts/httplex_test.go diff --git a/libgo/go/golang_org/x/net/http/httpproxy/export_test.go b/libgo/go/internal/x/net/http/httpproxy/export_test.go similarity index 100% rename from libgo/go/golang_org/x/net/http/httpproxy/export_test.go rename to libgo/go/internal/x/net/http/httpproxy/export_test.go diff --git a/libgo/go/golang_org/x/net/http/httpproxy/proxy.go b/libgo/go/internal/x/net/http/httpproxy/proxy.go similarity index 99% rename from libgo/go/golang_org/x/net/http/httpproxy/proxy.go rename to libgo/go/internal/x/net/http/httpproxy/proxy.go index 0409f4340c3..d3947841392 100644 --- a/libgo/go/golang_org/x/net/http/httpproxy/proxy.go +++ b/libgo/go/internal/x/net/http/httpproxy/proxy.go @@ -19,7 +19,7 @@ import ( "strings" "unicode/utf8" - "golang_org/x/net/idna" + "internal/x/net/idna" ) // Config holds configuration for HTTP proxy settings. See diff --git a/libgo/go/golang_org/x/net/http/httpproxy/proxy_test.go b/libgo/go/internal/x/net/http/httpproxy/proxy_test.go similarity index 99% rename from libgo/go/golang_org/x/net/http/httpproxy/proxy_test.go rename to libgo/go/internal/x/net/http/httpproxy/proxy_test.go index 8791f64bcdc..cf0589dba97 100644 --- a/libgo/go/golang_org/x/net/http/httpproxy/proxy_test.go +++ b/libgo/go/internal/x/net/http/httpproxy/proxy_test.go @@ -13,7 +13,7 @@ import ( "strings" "testing" - "golang_org/x/net/http/httpproxy" + "internal/x/net/http/httpproxy" ) // setHelper calls t.Helper() for Go 1.9+ (see go19_test.go) and does nothing otherwise. diff --git a/libgo/go/golang_org/x/net/http2/hpack/encode.go b/libgo/go/internal/x/net/http2/hpack/encode.go similarity index 100% rename from libgo/go/golang_org/x/net/http2/hpack/encode.go rename to libgo/go/internal/x/net/http2/hpack/encode.go diff --git a/libgo/go/golang_org/x/net/http2/hpack/encode_test.go b/libgo/go/internal/x/net/http2/hpack/encode_test.go similarity index 100% rename from libgo/go/golang_org/x/net/http2/hpack/encode_test.go rename to libgo/go/internal/x/net/http2/hpack/encode_test.go diff --git a/libgo/go/golang_org/x/net/http2/hpack/hpack.go b/libgo/go/internal/x/net/http2/hpack/hpack.go similarity index 97% rename from libgo/go/golang_org/x/net/http2/hpack/hpack.go rename to libgo/go/internal/x/net/http2/hpack/hpack.go index 166788ceec5..85f18a2b0a8 100644 --- a/libgo/go/golang_org/x/net/http2/hpack/hpack.go +++ b/libgo/go/internal/x/net/http2/hpack/hpack.go @@ -92,6 +92,8 @@ type Decoder struct { // saveBuf is previous data passed to Write which we weren't able // to fully parse before. Unlike buf, we own this data. saveBuf bytes.Buffer + + firstField bool // processing the first field of the header block } // NewDecoder returns a new decoder with the provided maximum dynamic @@ -101,6 +103,7 @@ func NewDecoder(maxDynamicTableSize uint32, emitFunc func(f HeaderField)) *Decod d := &Decoder{ emit: emitFunc, emitEnabled: true, + firstField: true, } d.dynTab.table.init() d.dynTab.allowedMaxSize = maxDynamicTableSize @@ -226,11 +229,15 @@ func (d *Decoder) DecodeFull(p []byte) ([]HeaderField, error) { return hf, nil } +// Close declares that the decoding is complete and resets the Decoder +// to be reused again for a new header block. If there is any remaining +// data in the decoder's buffer, Close returns an error. func (d *Decoder) Close() error { if d.saveBuf.Len() > 0 { d.saveBuf.Reset() return DecodingError{errors.New("truncated headers")} } + d.firstField = true return nil } @@ -266,6 +273,7 @@ func (d *Decoder) Write(p []byte) (n int, err error) { d.saveBuf.Write(d.buf) return len(p), nil } + d.firstField = false if err != nil { break } @@ -391,7 +399,7 @@ func (d *Decoder) callEmit(hf HeaderField) error { func (d *Decoder) parseDynamicTableSizeUpdate() error { // RFC 7541, sec 4.2: This dynamic table size update MUST occur at the // beginning of the first header block following the change to the dynamic table size. - if d.dynTab.size > 0 { + if !d.firstField && d.dynTab.size > 0 { return DecodingError{errors.New("dynamic table size update MUST occur at the beginning of a header block")} } diff --git a/libgo/go/golang_org/x/net/http2/hpack/hpack_test.go b/libgo/go/internal/x/net/http2/hpack/hpack_test.go similarity index 98% rename from libgo/go/golang_org/x/net/http2/hpack/hpack_test.go rename to libgo/go/internal/x/net/http2/hpack/hpack_test.go index 3f2227442a9..a361a2a7c2e 100644 --- a/libgo/go/golang_org/x/net/http2/hpack/hpack_test.go +++ b/libgo/go/internal/x/net/http2/hpack/hpack_test.go @@ -748,14 +748,22 @@ func TestDynamicSizeUpdate(t *testing.T) { enc.SetMaxDynamicTableSize(255) enc.WriteField(HeaderField{Name: "foo", Value: "bar"}) - d := NewDecoder(4096, nil) - _, err := d.DecodeFull(buf.Bytes()) + d := NewDecoder(4096, func(_ HeaderField) {}) + _, err := d.Write(buf.Bytes()) + if err != nil { + t.Fatalf("unexpected error: got = %v", err) + } + + d.Close() + + // Start a new header + _, err = d.Write(buf.Bytes()) if err != nil { t.Fatalf("unexpected error: got = %v", err) } // must fail since the dynamic table update must be at the beginning - _, err = d.DecodeFull(buf.Bytes()) + _, err = d.Write(buf.Bytes()) if err == nil { t.Fatalf("dynamic table size update not at the beginning of a header block") } diff --git a/libgo/go/golang_org/x/net/http2/hpack/huffman.go b/libgo/go/internal/x/net/http2/hpack/huffman.go similarity index 100% rename from libgo/go/golang_org/x/net/http2/hpack/huffman.go rename to libgo/go/internal/x/net/http2/hpack/huffman.go diff --git a/libgo/go/golang_org/x/net/http2/hpack/tables.go b/libgo/go/internal/x/net/http2/hpack/tables.go similarity index 100% rename from libgo/go/golang_org/x/net/http2/hpack/tables.go rename to libgo/go/internal/x/net/http2/hpack/tables.go diff --git a/libgo/go/golang_org/x/net/http2/hpack/tables_test.go b/libgo/go/internal/x/net/http2/hpack/tables_test.go similarity index 100% rename from libgo/go/golang_org/x/net/http2/hpack/tables_test.go rename to libgo/go/internal/x/net/http2/hpack/tables_test.go diff --git a/libgo/go/golang_org/x/net/idna/idna.go b/libgo/go/internal/x/net/idna/idna.go similarity index 99% rename from libgo/go/golang_org/x/net/idna/idna.go rename to libgo/go/internal/x/net/idna/idna.go index 9fd0334cd9d..7f2471e70e7 100644 --- a/libgo/go/golang_org/x/net/idna/idna.go +++ b/libgo/go/internal/x/net/idna/idna.go @@ -13,16 +13,16 @@ // UTS #46 is defined in http://www.unicode.org/reports/tr46. // See http://unicode.org/cldr/utility/idna.jsp for a visualization of the // differences between these two standards. -package idna // import "golang_org/x/text/internal/export/idna" +package idna import ( "fmt" "strings" "unicode/utf8" - "golang_org/x/text/secure/bidirule" - "golang_org/x/text/unicode/bidi" - "golang_org/x/text/unicode/norm" + "internal/x/text/secure/bidirule" + "internal/x/text/unicode/bidi" + "internal/x/text/unicode/norm" ) // NOTE: Unlike common practice in Go APIs, the functions will return a diff --git a/libgo/go/golang_org/x/net/idna/punycode.go b/libgo/go/internal/x/net/idna/punycode.go similarity index 100% rename from libgo/go/golang_org/x/net/idna/punycode.go rename to libgo/go/internal/x/net/idna/punycode.go diff --git a/libgo/go/golang_org/x/net/idna/punycode_test.go b/libgo/go/internal/x/net/idna/punycode_test.go similarity index 100% rename from libgo/go/golang_org/x/net/idna/punycode_test.go rename to libgo/go/internal/x/net/idna/punycode_test.go diff --git a/libgo/go/golang_org/x/net/idna/tables.go b/libgo/go/internal/x/net/idna/tables.go similarity index 99% rename from libgo/go/golang_org/x/net/idna/tables.go rename to libgo/go/internal/x/net/idna/tables.go index a470c5a3e25..41cf9c13d2a 100644 --- a/libgo/go/golang_org/x/net/idna/tables.go +++ b/libgo/go/internal/x/net/idna/tables.go @@ -1,6 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. -// Code generated by running "go generate" in golang_org/x/text. DO NOT EDIT. +// Code generated by running "go generate" in internal/x/text. DO NOT EDIT. package idna diff --git a/libgo/go/golang_org/x/net/idna/trie.go b/libgo/go/internal/x/net/idna/trie.go similarity index 100% rename from libgo/go/golang_org/x/net/idna/trie.go rename to libgo/go/internal/x/net/idna/trie.go diff --git a/libgo/go/golang_org/x/net/idna/trieval.go b/libgo/go/internal/x/net/idna/trieval.go similarity index 97% rename from libgo/go/golang_org/x/net/idna/trieval.go rename to libgo/go/internal/x/net/idna/trieval.go index 5f4e5f2e745..bf572600349 100644 --- a/libgo/go/golang_org/x/net/idna/trieval.go +++ b/libgo/go/internal/x/net/idna/trieval.go @@ -1,6 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. -// Code generated by running "go generate" in golang_org/x/text. DO NOT EDIT. +// Code generated by running "go generate" in internal/x/text. DO NOT EDIT. package idna diff --git a/libgo/go/golang_org/x/net/internal/nettest/helper_bsd.go b/libgo/go/internal/x/net/internal/nettest/helper_bsd.go similarity index 100% rename from libgo/go/golang_org/x/net/internal/nettest/helper_bsd.go rename to libgo/go/internal/x/net/internal/nettest/helper_bsd.go diff --git a/libgo/go/golang_org/x/net/internal/nettest/helper_nobsd.go b/libgo/go/internal/x/net/internal/nettest/helper_nobsd.go similarity index 100% rename from libgo/go/golang_org/x/net/internal/nettest/helper_nobsd.go rename to libgo/go/internal/x/net/internal/nettest/helper_nobsd.go diff --git a/libgo/go/golang_org/x/net/internal/nettest/helper_posix.go b/libgo/go/internal/x/net/internal/nettest/helper_posix.go similarity index 100% rename from libgo/go/golang_org/x/net/internal/nettest/helper_posix.go rename to libgo/go/internal/x/net/internal/nettest/helper_posix.go diff --git a/libgo/go/golang_org/x/net/internal/nettest/helper_stub.go b/libgo/go/internal/x/net/internal/nettest/helper_stub.go similarity index 95% rename from libgo/go/golang_org/x/net/internal/nettest/helper_stub.go rename to libgo/go/internal/x/net/internal/nettest/helper_stub.go index d729156de67..d89cf299629 100644 --- a/libgo/go/golang_org/x/net/internal/nettest/helper_stub.go +++ b/libgo/go/internal/x/net/internal/nettest/helper_stub.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build js,wasm nacl plan9 +// +build js nacl plan9 package nettest diff --git a/libgo/go/golang_org/x/net/internal/nettest/helper_unix.go b/libgo/go/internal/x/net/internal/nettest/helper_unix.go similarity index 100% rename from libgo/go/golang_org/x/net/internal/nettest/helper_unix.go rename to libgo/go/internal/x/net/internal/nettest/helper_unix.go diff --git a/libgo/go/golang_org/x/net/internal/nettest/helper_windows.go b/libgo/go/internal/x/net/internal/nettest/helper_windows.go similarity index 100% rename from libgo/go/golang_org/x/net/internal/nettest/helper_windows.go rename to libgo/go/internal/x/net/internal/nettest/helper_windows.go diff --git a/libgo/go/golang_org/x/net/internal/nettest/interface.go b/libgo/go/internal/x/net/internal/nettest/interface.go similarity index 100% rename from libgo/go/golang_org/x/net/internal/nettest/interface.go rename to libgo/go/internal/x/net/internal/nettest/interface.go diff --git a/libgo/go/golang_org/x/net/internal/nettest/rlimit.go b/libgo/go/internal/x/net/internal/nettest/rlimit.go similarity index 100% rename from libgo/go/golang_org/x/net/internal/nettest/rlimit.go rename to libgo/go/internal/x/net/internal/nettest/rlimit.go diff --git a/libgo/go/golang_org/x/net/internal/nettest/stack.go b/libgo/go/internal/x/net/internal/nettest/stack.go similarity index 96% rename from libgo/go/golang_org/x/net/internal/nettest/stack.go rename to libgo/go/internal/x/net/internal/nettest/stack.go index 46d2fccab58..1a545e21ab0 100644 --- a/libgo/go/golang_org/x/net/internal/nettest/stack.go +++ b/libgo/go/internal/x/net/internal/nettest/stack.go @@ -3,7 +3,7 @@ // license that can be found in the LICENSE file. // Package nettest provides utilities for network testing. -package nettest // import "golang.org/x/net/internal/nettest" +package nettest import ( "fmt" @@ -72,7 +72,7 @@ func TestableNetwork(network string) bool { } case "unixpacket": switch runtime.GOOS { - case "android", "darwin", "freebsd", "js", "nacl", "plan9", "windows": + case "aix", "android", "darwin", "freebsd", "js", "nacl", "plan9", "windows": return false case "netbsd": // It passes on amd64 at least. 386 fails (Issue 22927). arm is unknown. diff --git a/libgo/go/golang_org/x/net/lif/address.go b/libgo/go/internal/x/net/lif/address.go similarity index 100% rename from libgo/go/golang_org/x/net/lif/address.go rename to libgo/go/internal/x/net/lif/address.go diff --git a/libgo/go/golang_org/x/net/lif/address_test.go b/libgo/go/internal/x/net/lif/address_test.go similarity index 100% rename from libgo/go/golang_org/x/net/lif/address_test.go rename to libgo/go/internal/x/net/lif/address_test.go diff --git a/libgo/go/golang_org/x/net/lif/binary.go b/libgo/go/internal/x/net/lif/binary.go similarity index 100% rename from libgo/go/golang_org/x/net/lif/binary.go rename to libgo/go/internal/x/net/lif/binary.go diff --git a/libgo/go/golang_org/x/net/lif/defs_solaris.go b/libgo/go/internal/x/net/lif/defs_solaris.go similarity index 100% rename from libgo/go/golang_org/x/net/lif/defs_solaris.go rename to libgo/go/internal/x/net/lif/defs_solaris.go diff --git a/libgo/go/golang_org/x/net/lif/lif.go b/libgo/go/internal/x/net/lif/lif.go similarity index 100% rename from libgo/go/golang_org/x/net/lif/lif.go rename to libgo/go/internal/x/net/lif/lif.go diff --git a/libgo/go/golang_org/x/net/lif/link.go b/libgo/go/internal/x/net/lif/link.go similarity index 91% rename from libgo/go/golang_org/x/net/lif/link.go rename to libgo/go/internal/x/net/lif/link.go index 912472fdac1..913a53e1185 100644 --- a/libgo/go/golang_org/x/net/lif/link.go +++ b/libgo/go/internal/x/net/lif/link.go @@ -70,7 +70,7 @@ func Links(af int, name string) ([]Link, error) { func links(eps []endpoint, name string) ([]Link, error) { var lls []Link - lifn := sysLifnum{Flags: sysLIFC_NOXMIT | sysLIFC_TEMPORARY | sysLIFC_ALLZONES | sysLIFC_UNDER_IPMP} + lifn := lifnum{Flags: sysLIFC_NOXMIT | sysLIFC_TEMPORARY | sysLIFC_ALLZONES | sysLIFC_UNDER_IPMP} lifc := lifconf{Flags: sysLIFC_NOXMIT | sysLIFC_TEMPORARY | sysLIFC_ALLZONES | sysLIFC_UNDER_IPMP} for _, ep := range eps { lifn.Family = uint16(ep.af) @@ -84,7 +84,11 @@ func links(eps []endpoint, name string) ([]Link, error) { b := make([]byte, lifn.Count*sizeofLifreq) lifc.Family = uint16(ep.af) lifc.Len = lifn.Count * sizeofLifreq - lifc.Lifcu = unsafe.Pointer(&b[0]) + if len(lifc.Lifcu) == 8 { + nativeEndian.PutUint64(lifc.Lifcu[:], uint64(uintptr(unsafe.Pointer(&b[0])))) + } else { + nativeEndian.PutUint32(lifc.Lifcu[:], uint32(uintptr(unsafe.Pointer(&b[0])))) + } ioc = int64(sysSIOCGLIFCONF) if err := ioctl(ep.s, uintptr(ioc), unsafe.Pointer(&lifc)); err != nil { continue diff --git a/libgo/go/golang_org/x/net/lif/link_test.go b/libgo/go/internal/x/net/lif/link_test.go similarity index 100% rename from libgo/go/golang_org/x/net/lif/link_test.go rename to libgo/go/internal/x/net/lif/link_test.go diff --git a/libgo/go/golang_org/x/net/lif/sys.go b/libgo/go/internal/x/net/lif/sys.go similarity index 100% rename from libgo/go/golang_org/x/net/lif/sys.go rename to libgo/go/internal/x/net/lif/sys.go diff --git a/libgo/go/internal/x/net/lif/syscall.go b/libgo/go/internal/x/net/lif/syscall.go new file mode 100644 index 00000000000..aadab2e14ba --- /dev/null +++ b/libgo/go/internal/x/net/lif/syscall.go @@ -0,0 +1,28 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build solaris + +package lif + +import ( + "syscall" + "unsafe" +) + +//go:cgo_import_dynamic libc_ioctl ioctl "libc.so" + +//go:linkname procIoctl libc_ioctl + +var procIoctl uintptr + +func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (uintptr, uintptr, syscall.Errno) + +func ioctl(s, ioc uintptr, arg unsafe.Pointer) error { + _, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procIoctl)), 3, s, ioc, uintptr(arg), 0, 0, 0) + if errno != 0 { + return error(errno) + } + return nil +} diff --git a/libgo/go/golang_org/x/net/lif/zsys_solaris.go b/libgo/go/internal/x/net/lif/zsys_solaris_amd64.go similarity index 89% rename from libgo/go/golang_org/x/net/lif/zsys_solaris.go rename to libgo/go/internal/x/net/lif/zsys_solaris_amd64.go index 6452dd8ebb0..b5e999bec3a 100644 --- a/libgo/go/golang_org/x/net/lif/zsys_solaris.go +++ b/libgo/go/internal/x/net/lif/zsys_solaris_amd64.go @@ -3,8 +3,6 @@ package lif -import "unsafe" - const ( sysAF_UNSPEC = 0x0 sysAF_INET = 0x2 @@ -61,11 +59,15 @@ const ( ) const ( + sizeofLifnum = 0xc sizeofLifreq = 0x178 + sizeofLifconf = 0x18 + sizeofLifIfinfoReq = 0x10 ) -type sysLifnum struct { +type lifnum struct { Family uint16 + Pad_cgo_0 [2]byte Flags int32 Count int32 } @@ -79,13 +81,16 @@ type lifreq struct { type lifconf struct { Family uint16 + Pad_cgo_0 [2]byte Flags int32 Len int32 - Lifcu unsafe.Pointer + Pad_cgo_1 [4]byte + Lifcu [8]byte } type lifIfinfoReq struct { Maxhops uint8 + Pad_cgo_0 [3]byte Reachtime uint32 Reachretrans uint32 Maxmtu uint32 diff --git a/libgo/go/golang_org/x/net/nettest/conntest.go b/libgo/go/internal/x/net/nettest/conntest.go similarity index 100% rename from libgo/go/golang_org/x/net/nettest/conntest.go rename to libgo/go/internal/x/net/nettest/conntest.go diff --git a/libgo/go/golang_org/x/net/nettest/conntest_go16.go b/libgo/go/internal/x/net/nettest/conntest_go16.go similarity index 100% rename from libgo/go/golang_org/x/net/nettest/conntest_go16.go rename to libgo/go/internal/x/net/nettest/conntest_go16.go diff --git a/libgo/go/golang_org/x/net/nettest/conntest_go17.go b/libgo/go/internal/x/net/nettest/conntest_go17.go similarity index 100% rename from libgo/go/golang_org/x/net/nettest/conntest_go17.go rename to libgo/go/internal/x/net/nettest/conntest_go17.go diff --git a/libgo/go/golang_org/x/net/nettest/conntest_test.go b/libgo/go/internal/x/net/nettest/conntest_test.go similarity index 97% rename from libgo/go/golang_org/x/net/nettest/conntest_test.go rename to libgo/go/internal/x/net/nettest/conntest_test.go index ae8426a05c2..e14df0e6fbb 100644 --- a/libgo/go/golang_org/x/net/nettest/conntest_test.go +++ b/libgo/go/internal/x/net/nettest/conntest_test.go @@ -12,7 +12,7 @@ import ( "runtime" "testing" - "golang_org/x/net/internal/nettest" + "internal/x/net/internal/nettest" ) func TestTestConn(t *testing.T) { diff --git a/libgo/go/golang_org/x/net/route/address.go b/libgo/go/internal/x/net/route/address.go similarity index 100% rename from libgo/go/golang_org/x/net/route/address.go rename to libgo/go/internal/x/net/route/address.go diff --git a/libgo/go/golang_org/x/net/route/address_darwin_test.go b/libgo/go/internal/x/net/route/address_darwin_test.go similarity index 100% rename from libgo/go/golang_org/x/net/route/address_darwin_test.go rename to libgo/go/internal/x/net/route/address_darwin_test.go diff --git a/libgo/go/golang_org/x/net/route/address_test.go b/libgo/go/internal/x/net/route/address_test.go similarity index 100% rename from libgo/go/golang_org/x/net/route/address_test.go rename to libgo/go/internal/x/net/route/address_test.go diff --git a/libgo/go/golang_org/x/net/route/binary.go b/libgo/go/internal/x/net/route/binary.go similarity index 100% rename from libgo/go/golang_org/x/net/route/binary.go rename to libgo/go/internal/x/net/route/binary.go diff --git a/libgo/go/golang_org/x/net/route/defs_darwin.go b/libgo/go/internal/x/net/route/defs_darwin.go similarity index 100% rename from libgo/go/golang_org/x/net/route/defs_darwin.go rename to libgo/go/internal/x/net/route/defs_darwin.go diff --git a/libgo/go/golang_org/x/net/route/defs_dragonfly.go b/libgo/go/internal/x/net/route/defs_dragonfly.go similarity index 100% rename from libgo/go/golang_org/x/net/route/defs_dragonfly.go rename to libgo/go/internal/x/net/route/defs_dragonfly.go diff --git a/libgo/go/golang_org/x/net/route/defs_freebsd.go b/libgo/go/internal/x/net/route/defs_freebsd.go similarity index 100% rename from libgo/go/golang_org/x/net/route/defs_freebsd.go rename to libgo/go/internal/x/net/route/defs_freebsd.go diff --git a/libgo/go/golang_org/x/net/route/defs_netbsd.go b/libgo/go/internal/x/net/route/defs_netbsd.go similarity index 100% rename from libgo/go/golang_org/x/net/route/defs_netbsd.go rename to libgo/go/internal/x/net/route/defs_netbsd.go diff --git a/libgo/go/golang_org/x/net/route/defs_openbsd.go b/libgo/go/internal/x/net/route/defs_openbsd.go similarity index 100% rename from libgo/go/golang_org/x/net/route/defs_openbsd.go rename to libgo/go/internal/x/net/route/defs_openbsd.go diff --git a/libgo/go/golang_org/x/net/route/interface.go b/libgo/go/internal/x/net/route/interface.go similarity index 98% rename from libgo/go/golang_org/x/net/route/interface.go rename to libgo/go/internal/x/net/route/interface.go index 854906d9c42..05ef2a9ce3c 100644 --- a/libgo/go/golang_org/x/net/route/interface.go +++ b/libgo/go/internal/x/net/route/interface.go @@ -37,7 +37,7 @@ func (m *InterfaceAddrMessage) Sys() []Sys { return nil } // address message. type InterfaceMulticastAddrMessage struct { Version int // message version - Type int // messsage type + Type int // message type Flags int // interface flags Index int // interface index Addrs []Addr // addresses diff --git a/libgo/go/golang_org/x/net/route/interface_announce.go b/libgo/go/internal/x/net/route/interface_announce.go similarity index 100% rename from libgo/go/golang_org/x/net/route/interface_announce.go rename to libgo/go/internal/x/net/route/interface_announce.go diff --git a/libgo/go/golang_org/x/net/route/interface_classic.go b/libgo/go/internal/x/net/route/interface_classic.go similarity index 100% rename from libgo/go/golang_org/x/net/route/interface_classic.go rename to libgo/go/internal/x/net/route/interface_classic.go diff --git a/libgo/go/golang_org/x/net/route/interface_freebsd.go b/libgo/go/internal/x/net/route/interface_freebsd.go similarity index 100% rename from libgo/go/golang_org/x/net/route/interface_freebsd.go rename to libgo/go/internal/x/net/route/interface_freebsd.go diff --git a/libgo/go/golang_org/x/net/route/interface_multicast.go b/libgo/go/internal/x/net/route/interface_multicast.go similarity index 100% rename from libgo/go/golang_org/x/net/route/interface_multicast.go rename to libgo/go/internal/x/net/route/interface_multicast.go diff --git a/libgo/go/golang_org/x/net/route/interface_openbsd.go b/libgo/go/internal/x/net/route/interface_openbsd.go similarity index 100% rename from libgo/go/golang_org/x/net/route/interface_openbsd.go rename to libgo/go/internal/x/net/route/interface_openbsd.go diff --git a/libgo/go/golang_org/x/net/route/message.go b/libgo/go/internal/x/net/route/message.go similarity index 100% rename from libgo/go/golang_org/x/net/route/message.go rename to libgo/go/internal/x/net/route/message.go diff --git a/libgo/go/golang_org/x/net/route/message_darwin_test.go b/libgo/go/internal/x/net/route/message_darwin_test.go similarity index 100% rename from libgo/go/golang_org/x/net/route/message_darwin_test.go rename to libgo/go/internal/x/net/route/message_darwin_test.go diff --git a/libgo/go/golang_org/x/net/route/message_freebsd_test.go b/libgo/go/internal/x/net/route/message_freebsd_test.go similarity index 95% rename from libgo/go/golang_org/x/net/route/message_freebsd_test.go rename to libgo/go/internal/x/net/route/message_freebsd_test.go index db4b56752cf..c6d8a5f54ca 100644 --- a/libgo/go/golang_org/x/net/route/message_freebsd_test.go +++ b/libgo/go/internal/x/net/route/message_freebsd_test.go @@ -4,10 +4,7 @@ package route -import ( - "testing" - "unsafe" -) +import "testing" func TestFetchAndParseRIBOnFreeBSD(t *testing.T) { for _, typ := range []RIBType{sysNET_RT_IFMALIST} { @@ -40,8 +37,7 @@ func TestFetchAndParseRIBOnFreeBSD10AndAbove(t *testing.T) { if _, err := FetchRIB(sysAF_UNSPEC, sysNET_RT_IFLISTL, 0); err != nil { t.Skip("NET_RT_IFLISTL not supported") } - var p uintptr - if kernelAlign != int(unsafe.Sizeof(p)) { + if compatFreeBSD32 { t.Skip("NET_RT_IFLIST vs. NET_RT_IFLISTL doesn't work for 386 emulation on amd64") } diff --git a/libgo/go/golang_org/x/net/route/message_test.go b/libgo/go/internal/x/net/route/message_test.go similarity index 100% rename from libgo/go/golang_org/x/net/route/message_test.go rename to libgo/go/internal/x/net/route/message_test.go diff --git a/libgo/go/golang_org/x/net/route/route.go b/libgo/go/internal/x/net/route/route.go similarity index 100% rename from libgo/go/golang_org/x/net/route/route.go rename to libgo/go/internal/x/net/route/route.go diff --git a/libgo/go/golang_org/x/net/route/route_classic.go b/libgo/go/internal/x/net/route/route_classic.go similarity index 100% rename from libgo/go/golang_org/x/net/route/route_classic.go rename to libgo/go/internal/x/net/route/route_classic.go diff --git a/libgo/go/golang_org/x/net/route/route_openbsd.go b/libgo/go/internal/x/net/route/route_openbsd.go similarity index 100% rename from libgo/go/golang_org/x/net/route/route_openbsd.go rename to libgo/go/internal/x/net/route/route_openbsd.go diff --git a/libgo/go/golang_org/x/net/route/route_test.go b/libgo/go/internal/x/net/route/route_test.go similarity index 100% rename from libgo/go/golang_org/x/net/route/route_test.go rename to libgo/go/internal/x/net/route/route_test.go diff --git a/libgo/go/golang_org/x/net/route/sys.go b/libgo/go/internal/x/net/route/sys.go similarity index 100% rename from libgo/go/golang_org/x/net/route/sys.go rename to libgo/go/internal/x/net/route/sys.go diff --git a/libgo/go/golang_org/x/net/route/sys_darwin.go b/libgo/go/internal/x/net/route/sys_darwin.go similarity index 100% rename from libgo/go/golang_org/x/net/route/sys_darwin.go rename to libgo/go/internal/x/net/route/sys_darwin.go diff --git a/libgo/go/golang_org/x/net/route/sys_dragonfly.go b/libgo/go/internal/x/net/route/sys_dragonfly.go similarity index 100% rename from libgo/go/golang_org/x/net/route/sys_dragonfly.go rename to libgo/go/internal/x/net/route/sys_dragonfly.go diff --git a/libgo/go/golang_org/x/net/route/sys_freebsd.go b/libgo/go/internal/x/net/route/sys_freebsd.go similarity index 90% rename from libgo/go/golang_org/x/net/route/sys_freebsd.go rename to libgo/go/internal/x/net/route/sys_freebsd.go index 89ba1c4e262..fe91be1249c 100644 --- a/libgo/go/golang_org/x/net/route/sys_freebsd.go +++ b/libgo/go/internal/x/net/route/sys_freebsd.go @@ -54,10 +54,12 @@ func (m *InterfaceMessage) Sys() []Sys { } } +var compatFreeBSD32 bool // 386 emulation on amd64 + func probeRoutingStack() (int, map[int]*wireFormat) { var p uintptr wordSize := int(unsafe.Sizeof(p)) - align := int(unsafe.Sizeof(p)) + align := wordSize // In the case of kern.supported_archs="amd64 i386", we need // to know the underlying kernel's architecture because the // alignment for routing facilities are set at the build time @@ -83,8 +85,11 @@ func probeRoutingStack() (int, map[int]*wireFormat) { break } } + if align != wordSize { + compatFreeBSD32 = true // 386 emulation on amd64 + } var rtm, ifm, ifam, ifmam, ifanm *wireFormat - if align != wordSize { // 386 emulation on amd64 + if compatFreeBSD32 { rtm = &wireFormat{extOff: sizeofRtMsghdrFreeBSD10Emu - sizeofRtMetricsFreeBSD10Emu, bodyOff: sizeofRtMsghdrFreeBSD10Emu} ifm = &wireFormat{extOff: 16} ifam = &wireFormat{extOff: sizeofIfaMsghdrFreeBSD10Emu, bodyOff: sizeofIfaMsghdrFreeBSD10Emu} @@ -100,35 +105,38 @@ func probeRoutingStack() (int, map[int]*wireFormat) { rel, _ := syscall.SysctlUint32("kern.osreldate") switch { case rel < 800000: - if align != wordSize { // 386 emulation on amd64 + if compatFreeBSD32 { ifm.bodyOff = sizeofIfMsghdrFreeBSD7Emu } else { ifm.bodyOff = sizeofIfMsghdrFreeBSD7 } case 800000 <= rel && rel < 900000: - if align != wordSize { // 386 emulation on amd64 + if compatFreeBSD32 { ifm.bodyOff = sizeofIfMsghdrFreeBSD8Emu } else { ifm.bodyOff = sizeofIfMsghdrFreeBSD8 } case 900000 <= rel && rel < 1000000: - if align != wordSize { // 386 emulation on amd64 + if compatFreeBSD32 { ifm.bodyOff = sizeofIfMsghdrFreeBSD9Emu } else { ifm.bodyOff = sizeofIfMsghdrFreeBSD9 } case 1000000 <= rel && rel < 1100000: - if align != wordSize { // 386 emulation on amd64 + if compatFreeBSD32 { ifm.bodyOff = sizeofIfMsghdrFreeBSD10Emu } else { ifm.bodyOff = sizeofIfMsghdrFreeBSD10 } default: - if align != wordSize { // 386 emulation on amd64 + if compatFreeBSD32 { ifm.bodyOff = sizeofIfMsghdrFreeBSD11Emu } else { ifm.bodyOff = sizeofIfMsghdrFreeBSD11 } + if rel >= 1102000 { // see https://github.com/freebsd/freebsd/commit/027c7f4d66ff8d8c4a46c3665a5ee7d6d8462034#diff-ad4e5b7f1449ea3fc87bc97280de145b + align = wordSize + } } rtm.parse = rtm.parseRouteMessage ifm.parse = ifm.parseInterfaceMessage diff --git a/libgo/go/golang_org/x/net/route/sys_netbsd.go b/libgo/go/internal/x/net/route/sys_netbsd.go similarity index 100% rename from libgo/go/golang_org/x/net/route/sys_netbsd.go rename to libgo/go/internal/x/net/route/sys_netbsd.go diff --git a/libgo/go/golang_org/x/net/route/sys_openbsd.go b/libgo/go/internal/x/net/route/sys_openbsd.go similarity index 100% rename from libgo/go/golang_org/x/net/route/sys_openbsd.go rename to libgo/go/internal/x/net/route/sys_openbsd.go diff --git a/libgo/go/golang_org/x/net/route/syscall.go b/libgo/go/internal/x/net/route/syscall.go similarity index 83% rename from libgo/go/golang_org/x/net/route/syscall.go rename to libgo/go/internal/x/net/route/syscall.go index c211188b10b..72431b03410 100644 --- a/libgo/go/golang_org/x/net/route/syscall.go +++ b/libgo/go/internal/x/net/route/syscall.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd netbsd openbsd +// +build dragonfly freebsd netbsd openbsd package route @@ -20,7 +20,7 @@ func sysctl(mib []int32, old *byte, oldlen *uintptr, new *byte, newlen uintptr) } else { p = unsafe.Pointer(&zero) } - _, _, errno := syscall.Syscall6(syscall.SYS___SYSCTL, uintptr(p), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + _, _, errno := syscall.Syscall6(syscall.SYS___SYSCTL, uintptr(p), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), newlen) if errno != 0 { return error(errno) } diff --git a/libgo/go/internal/x/net/route/syscall_go1_11_darwin.go b/libgo/go/internal/x/net/route/syscall_go1_11_darwin.go new file mode 100644 index 00000000000..7228e443cd2 --- /dev/null +++ b/libgo/go/internal/x/net/route/syscall_go1_11_darwin.go @@ -0,0 +1,28 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !go1.12 + +package route + +import ( + "syscall" + "unsafe" +) + +var zero uintptr + +func sysctl(mib []int32, old *byte, oldlen *uintptr, new *byte, newlen uintptr) error { + var p unsafe.Pointer + if len(mib) > 0 { + p = unsafe.Pointer(&mib[0]) + } else { + p = unsafe.Pointer(&zero) + } + _, _, errno := syscall.Syscall6(syscall.SYS___SYSCTL, uintptr(p), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), newlen) + if errno != 0 { + return error(errno) + } + return nil +} diff --git a/libgo/go/internal/x/net/route/syscall_go1_12_darwin.go b/libgo/go/internal/x/net/route/syscall_go1_12_darwin.go new file mode 100644 index 00000000000..7922a6836fc --- /dev/null +++ b/libgo/go/internal/x/net/route/syscall_go1_12_darwin.go @@ -0,0 +1,12 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build go1.12 + +package route + +import _ "unsafe" // for linkname + +//go:linkname sysctl syscall.sysctl +func sysctl(mib []int32, old *byte, oldlen *uintptr, new *byte, newlen uintptr) error diff --git a/libgo/go/golang_org/x/net/route/zsys_darwin.go b/libgo/go/internal/x/net/route/zsys_darwin.go similarity index 100% rename from libgo/go/golang_org/x/net/route/zsys_darwin.go rename to libgo/go/internal/x/net/route/zsys_darwin.go diff --git a/libgo/go/golang_org/x/net/route/zsys_dragonfly.go b/libgo/go/internal/x/net/route/zsys_dragonfly.go similarity index 100% rename from libgo/go/golang_org/x/net/route/zsys_dragonfly.go rename to libgo/go/internal/x/net/route/zsys_dragonfly.go diff --git a/libgo/go/golang_org/x/net/route/zsys_freebsd_386.go b/libgo/go/internal/x/net/route/zsys_freebsd_386.go similarity index 100% rename from libgo/go/golang_org/x/net/route/zsys_freebsd_386.go rename to libgo/go/internal/x/net/route/zsys_freebsd_386.go diff --git a/libgo/go/golang_org/x/net/route/zsys_freebsd_amd64.go b/libgo/go/internal/x/net/route/zsys_freebsd_amd64.go similarity index 100% rename from libgo/go/golang_org/x/net/route/zsys_freebsd_amd64.go rename to libgo/go/internal/x/net/route/zsys_freebsd_amd64.go diff --git a/libgo/go/golang_org/x/net/route/zsys_freebsd_arm.go b/libgo/go/internal/x/net/route/zsys_freebsd_arm.go similarity index 100% rename from libgo/go/golang_org/x/net/route/zsys_freebsd_arm.go rename to libgo/go/internal/x/net/route/zsys_freebsd_arm.go diff --git a/libgo/go/golang_org/x/net/route/zsys_netbsd.go b/libgo/go/internal/x/net/route/zsys_netbsd.go similarity index 100% rename from libgo/go/golang_org/x/net/route/zsys_netbsd.go rename to libgo/go/internal/x/net/route/zsys_netbsd.go diff --git a/libgo/go/golang_org/x/net/route/zsys_openbsd.go b/libgo/go/internal/x/net/route/zsys_openbsd.go similarity index 100% rename from libgo/go/golang_org/x/net/route/zsys_openbsd.go rename to libgo/go/internal/x/net/route/zsys_openbsd.go diff --git a/libgo/go/golang_org/x/text/secure/bidirule/bidirule.go b/libgo/go/internal/x/text/secure/bidirule/bidirule.go similarity index 99% rename from libgo/go/golang_org/x/text/secure/bidirule/bidirule.go rename to libgo/go/internal/x/text/secure/bidirule/bidirule.go index c3ca2bc6fed..87e656a37d0 100644 --- a/libgo/go/golang_org/x/text/secure/bidirule/bidirule.go +++ b/libgo/go/internal/x/text/secure/bidirule/bidirule.go @@ -14,8 +14,8 @@ import ( "errors" "unicode/utf8" - "golang_org/x/text/transform" - "golang_org/x/text/unicode/bidi" + "internal/x/text/transform" + "internal/x/text/unicode/bidi" ) // This file contains an implementation of RFC 5893: Right-to-Left Scripts for diff --git a/libgo/go/golang_org/x/text/secure/doc.go b/libgo/go/internal/x/text/secure/doc.go similarity index 85% rename from libgo/go/golang_org/x/text/secure/doc.go rename to libgo/go/internal/x/text/secure/doc.go index 5eb60b94bf2..6151b79d6e3 100644 --- a/libgo/go/golang_org/x/text/secure/doc.go +++ b/libgo/go/internal/x/text/secure/doc.go @@ -5,4 +5,4 @@ // license that can be found in the LICENSE file. // secure is a repository of text security related packages. -package secure // import "golang_org/x/text/secure" +package secure diff --git a/libgo/go/golang_org/x/text/transform/examples_test.go b/libgo/go/internal/x/text/transform/examples_test.go similarity index 92% rename from libgo/go/golang_org/x/text/transform/examples_test.go rename to libgo/go/internal/x/text/transform/examples_test.go index 1323d9bec03..8d2fbb21711 100644 --- a/libgo/go/golang_org/x/text/transform/examples_test.go +++ b/libgo/go/internal/x/text/transform/examples_test.go @@ -10,8 +10,8 @@ import ( "fmt" "unicode" - "golang_org/x/text/transform" - "golang_org/x/text/unicode/norm" + "internal/x/text/transform" + "internal/x/text/unicode/norm" ) func ExampleRemoveFunc() { diff --git a/libgo/go/golang_org/x/text/transform/transform.go b/libgo/go/internal/x/text/transform/transform.go similarity index 99% rename from libgo/go/golang_org/x/text/transform/transform.go rename to libgo/go/internal/x/text/transform/transform.go index 9ddfa80cf3e..7b6b55e0194 100644 --- a/libgo/go/golang_org/x/text/transform/transform.go +++ b/libgo/go/internal/x/text/transform/transform.go @@ -8,7 +8,7 @@ // bytes passing through as well as various transformations. Example // transformations provided by other packages include normalization and // conversion between character sets. -package transform // import "golang_org/x/text/transform" +package transform import ( "bytes" diff --git a/libgo/go/golang_org/x/text/unicode/bidi/bidi.go b/libgo/go/internal/x/text/unicode/bidi/bidi.go similarity index 99% rename from libgo/go/golang_org/x/text/unicode/bidi/bidi.go rename to libgo/go/internal/x/text/unicode/bidi/bidi.go index e691ae86942..4542171736e 100644 --- a/libgo/go/golang_org/x/text/unicode/bidi/bidi.go +++ b/libgo/go/internal/x/text/unicode/bidi/bidi.go @@ -10,7 +10,7 @@ // // NOTE: UNDER CONSTRUCTION. This API may change in backwards incompatible ways // and without notice. -package bidi // import "golang_org/x/text/unicode/bidi" +package bidi // TODO: // The following functionality would not be hard to implement, but hinges on diff --git a/libgo/go/golang_org/x/text/unicode/bidi/bracket.go b/libgo/go/internal/x/text/unicode/bidi/bracket.go similarity index 100% rename from libgo/go/golang_org/x/text/unicode/bidi/bracket.go rename to libgo/go/internal/x/text/unicode/bidi/bracket.go diff --git a/libgo/go/golang_org/x/text/unicode/bidi/core.go b/libgo/go/internal/x/text/unicode/bidi/core.go similarity index 100% rename from libgo/go/golang_org/x/text/unicode/bidi/core.go rename to libgo/go/internal/x/text/unicode/bidi/core.go diff --git a/libgo/go/golang_org/x/text/unicode/bidi/example_test.go b/libgo/go/internal/x/text/unicode/bidi/example_test.go similarity index 99% rename from libgo/go/golang_org/x/text/unicode/bidi/example_test.go rename to libgo/go/internal/x/text/unicode/bidi/example_test.go index e1739598d43..56c5c4a1219 100644 --- a/libgo/go/golang_org/x/text/unicode/bidi/example_test.go +++ b/libgo/go/internal/x/text/unicode/bidi/example_test.go @@ -8,7 +8,7 @@ import ( "fmt" "log" - "golang_org/x/text/bidi" + "internal/x/text/bidi" ) func foo() { diff --git a/libgo/go/golang_org/x/text/unicode/bidi/prop.go b/libgo/go/internal/x/text/unicode/bidi/prop.go similarity index 100% rename from libgo/go/golang_org/x/text/unicode/bidi/prop.go rename to libgo/go/internal/x/text/unicode/bidi/prop.go diff --git a/libgo/go/golang_org/x/text/unicode/bidi/tables.go b/libgo/go/internal/x/text/unicode/bidi/tables.go similarity index 99% rename from libgo/go/golang_org/x/text/unicode/bidi/tables.go rename to libgo/go/internal/x/text/unicode/bidi/tables.go index fb2229efa87..c9c45c625f5 100644 --- a/libgo/go/golang_org/x/text/unicode/bidi/tables.go +++ b/libgo/go/internal/x/text/unicode/bidi/tables.go @@ -1,6 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. -// Code generated by running "go generate" in golang_org/x/text. DO NOT EDIT. +// Code generated by running "go generate" in internal/x/text. DO NOT EDIT. package bidi diff --git a/libgo/go/golang_org/x/text/unicode/bidi/trieval.go b/libgo/go/internal/x/text/unicode/bidi/trieval.go similarity index 95% rename from libgo/go/golang_org/x/text/unicode/bidi/trieval.go rename to libgo/go/internal/x/text/unicode/bidi/trieval.go index c3f0e21f3e8..e59d249c750 100644 --- a/libgo/go/golang_org/x/text/unicode/bidi/trieval.go +++ b/libgo/go/internal/x/text/unicode/bidi/trieval.go @@ -1,6 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. -// Code generated by running "go generate" in golang_org/x/text. DO NOT EDIT. +// Code generated by running "go generate" in internal/x/text. DO NOT EDIT. package bidi diff --git a/libgo/go/golang_org/x/text/unicode/doc.go b/libgo/go/internal/x/text/unicode/doc.go similarity index 84% rename from libgo/go/golang_org/x/text/unicode/doc.go rename to libgo/go/internal/x/text/unicode/doc.go index 55a6775d59a..4f7e9f5a433 100644 --- a/libgo/go/golang_org/x/text/unicode/doc.go +++ b/libgo/go/internal/x/text/unicode/doc.go @@ -5,6 +5,6 @@ // license that can be found in the LICENSE file. // unicode holds packages with implementations of Unicode standards that are -// mostly used as building blocks for other packages in golang_org/x/text, +// mostly used as building blocks for other packages in internal/x/text, // layout engines, or are otherwise more low-level in nature. package unicode diff --git a/libgo/go/golang_org/x/text/unicode/norm/composition.go b/libgo/go/internal/x/text/unicode/norm/composition.go similarity index 100% rename from libgo/go/golang_org/x/text/unicode/norm/composition.go rename to libgo/go/internal/x/text/unicode/norm/composition.go diff --git a/libgo/go/golang_org/x/text/unicode/norm/example_iter_test.go b/libgo/go/internal/x/text/unicode/norm/example_iter_test.go similarity index 98% rename from libgo/go/golang_org/x/text/unicode/norm/example_iter_test.go rename to libgo/go/internal/x/text/unicode/norm/example_iter_test.go index aed6c16fbb2..fb0e52410b8 100644 --- a/libgo/go/golang_org/x/text/unicode/norm/example_iter_test.go +++ b/libgo/go/internal/x/text/unicode/norm/example_iter_test.go @@ -11,7 +11,7 @@ import ( "fmt" "unicode/utf8" - "golang_org/x/text/unicode/norm" + "internal/x/text/unicode/norm" ) // EqualSimple uses a norm.Iter to compare two non-normalized diff --git a/libgo/go/golang_org/x/text/unicode/norm/example_test.go b/libgo/go/internal/x/text/unicode/norm/example_test.go similarity index 94% rename from libgo/go/golang_org/x/text/unicode/norm/example_test.go rename to libgo/go/internal/x/text/unicode/norm/example_test.go index 72e72c9d34a..a9904400df4 100644 --- a/libgo/go/golang_org/x/text/unicode/norm/example_test.go +++ b/libgo/go/internal/x/text/unicode/norm/example_test.go @@ -9,7 +9,7 @@ package norm_test import ( "fmt" - "golang_org/x/text/unicode/norm" + "internal/x/text/unicode/norm" ) func ExampleForm_NextBoundary() { diff --git a/libgo/go/golang_org/x/text/unicode/norm/forminfo.go b/libgo/go/internal/x/text/unicode/norm/forminfo.go similarity index 100% rename from libgo/go/golang_org/x/text/unicode/norm/forminfo.go rename to libgo/go/internal/x/text/unicode/norm/forminfo.go diff --git a/libgo/go/golang_org/x/text/unicode/norm/input.go b/libgo/go/internal/x/text/unicode/norm/input.go similarity index 100% rename from libgo/go/golang_org/x/text/unicode/norm/input.go rename to libgo/go/internal/x/text/unicode/norm/input.go diff --git a/libgo/go/golang_org/x/text/unicode/norm/iter.go b/libgo/go/internal/x/text/unicode/norm/iter.go similarity index 100% rename from libgo/go/golang_org/x/text/unicode/norm/iter.go rename to libgo/go/internal/x/text/unicode/norm/iter.go diff --git a/libgo/go/golang_org/x/text/unicode/norm/normalize.go b/libgo/go/internal/x/text/unicode/norm/normalize.go similarity index 99% rename from libgo/go/golang_org/x/text/unicode/norm/normalize.go rename to libgo/go/internal/x/text/unicode/norm/normalize.go index 4de4ed6ed0f..791c39b1c48 100644 --- a/libgo/go/golang_org/x/text/unicode/norm/normalize.go +++ b/libgo/go/internal/x/text/unicode/norm/normalize.go @@ -7,12 +7,12 @@ // Note: the file data_test.go that is generated should not be checked in. // Package norm contains types and functions for normalizing Unicode strings. -package norm // import "golang_org/x/text/unicode/norm" +package norm import ( "unicode/utf8" - "golang_org/x/text/transform" + "internal/x/text/transform" ) // A Form denotes a canonical representation of Unicode code points. diff --git a/libgo/go/golang_org/x/text/unicode/norm/readwriter.go b/libgo/go/internal/x/text/unicode/norm/readwriter.go similarity index 100% rename from libgo/go/golang_org/x/text/unicode/norm/readwriter.go rename to libgo/go/internal/x/text/unicode/norm/readwriter.go diff --git a/libgo/go/golang_org/x/text/unicode/norm/tables.go b/libgo/go/internal/x/text/unicode/norm/tables.go similarity index 99% rename from libgo/go/golang_org/x/text/unicode/norm/tables.go rename to libgo/go/internal/x/text/unicode/norm/tables.go index d6466836cef..2dd61adf63c 100644 --- a/libgo/go/golang_org/x/text/unicode/norm/tables.go +++ b/libgo/go/internal/x/text/unicode/norm/tables.go @@ -1,6 +1,6 @@ // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. -// Code generated by running "go generate" in golang_org/x/text. DO NOT EDIT. +// Code generated by running "go generate" in internal/x/text. DO NOT EDIT. package norm diff --git a/libgo/go/golang_org/x/text/unicode/norm/transform.go b/libgo/go/internal/x/text/unicode/norm/transform.go similarity index 98% rename from libgo/go/golang_org/x/text/unicode/norm/transform.go rename to libgo/go/internal/x/text/unicode/norm/transform.go index 73869a5a1cd..7837cb96a41 100644 --- a/libgo/go/golang_org/x/text/unicode/norm/transform.go +++ b/libgo/go/internal/x/text/unicode/norm/transform.go @@ -9,7 +9,7 @@ package norm import ( "unicode/utf8" - "golang_org/x/text/transform" + "internal/x/text/transform" ) // Reset implements the Reset method of the transform.Transformer interface. diff --git a/libgo/go/golang_org/x/text/unicode/norm/trie.go b/libgo/go/internal/x/text/unicode/norm/trie.go similarity index 100% rename from libgo/go/golang_org/x/text/unicode/norm/trie.go rename to libgo/go/internal/x/text/unicode/norm/trie.go diff --git a/libgo/go/golang_org/x/text/unicode/norm/triegen.go b/libgo/go/internal/x/text/unicode/norm/triegen.go similarity index 100% rename from libgo/go/golang_org/x/text/unicode/norm/triegen.go rename to libgo/go/internal/x/text/unicode/norm/triegen.go diff --git a/libgo/go/internal/xcoff/ar.go b/libgo/go/internal/xcoff/ar.go new file mode 100644 index 00000000000..0fb410f7dd7 --- /dev/null +++ b/libgo/go/internal/xcoff/ar.go @@ -0,0 +1,228 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package xcoff + +import ( + "encoding/binary" + "fmt" + "io" + "os" + "strconv" + "strings" +) + +const ( + SAIAMAG = 0x8 + AIAFMAG = "`\n" + AIAMAG = "\n" + AIAMAGBIG = "\n" + + // Sizeof + FL_HSZ_BIG = 0x80 + AR_HSZ_BIG = 0x70 +) + +type bigarFileHeader struct { + Flmagic [SAIAMAG]byte // Archive magic string + Flmemoff [20]byte // Member table offset + Flgstoff [20]byte // 32-bits global symtab offset + Flgst64off [20]byte // 64-bits global symtab offset + Flfstmoff [20]byte // First member offset + Fllstmoff [20]byte // Last member offset + Flfreeoff [20]byte // First member on free list offset +} + +type bigarMemberHeader struct { + Arsize [20]byte // File member size + Arnxtmem [20]byte // Next member pointer + Arprvmem [20]byte // Previous member pointer + Ardate [12]byte // File member date + Aruid [12]byte // File member uid + Argid [12]byte // File member gid + Armode [12]byte // File member mode (octal) + Arnamlen [4]byte // File member name length + // _ar_nam is removed because it's easier to get name without it. +} + +// Archive represents an open AIX big archive. +type Archive struct { + ArchiveHeader + Members []*Member + + closer io.Closer +} + +// MemberHeader holds information about a big archive file header +type ArchiveHeader struct { + magic string +} + +// Member represents a member of an AIX big archive. +type Member struct { + MemberHeader + sr *io.SectionReader +} + +// MemberHeader holds information about a big archive member +type MemberHeader struct { + Name string + Size uint64 +} + +// OpenArchive opens the named archive using os.Open and prepares it for use +// as an AIX big archive. +func OpenArchive(name string) (*Archive, error) { + f, err := os.Open(name) + if err != nil { + return nil, err + } + arch, err := NewArchive(f) + if err != nil { + f.Close() + return nil, err + } + arch.closer = f + return arch, nil +} + +// Close closes the Archive. +// If the Archive was created using NewArchive directly instead of OpenArchive, +// Close has no effect. +func (a *Archive) Close() error { + var err error + if a.closer != nil { + err = a.closer.Close() + a.closer = nil + } + return err +} + +// NewArchive creates a new Archive for accessing an AIX big archive in an underlying reader. +func NewArchive(r io.ReaderAt) (*Archive, error) { + parseDecimalBytes := func(b []byte) (int64, error) { + return strconv.ParseInt(strings.TrimSpace(string(b)), 10, 64) + } + sr := io.NewSectionReader(r, 0, 1<<63-1) + + // Read File Header + var magic [SAIAMAG]byte + if _, err := sr.ReadAt(magic[:], 0); err != nil { + return nil, err + } + + arch := new(Archive) + switch string(magic[:]) { + case AIAMAGBIG: + arch.magic = string(magic[:]) + case AIAMAG: + return nil, fmt.Errorf("small AIX archive not supported") + default: + return nil, fmt.Errorf("unrecognised archive magic: 0x%x", magic) + } + + var fhdr bigarFileHeader + if _, err := sr.Seek(0, os.SEEK_SET); err != nil { + return nil, err + } + if err := binary.Read(sr, binary.BigEndian, &fhdr); err != nil { + return nil, err + } + + off, err := parseDecimalBytes(fhdr.Flfstmoff[:]) + if err != nil { + return nil, fmt.Errorf("error parsing offset of first member in archive header(%q); %v", fhdr, err) + } + + if off == 0 { + // Occurs if the archive is empty. + return arch, nil + } + + lastoff, err := parseDecimalBytes(fhdr.Fllstmoff[:]) + if err != nil { + return nil, fmt.Errorf("error parsing offset of first member in archive header(%q); %v", fhdr, err) + } + + // Read members + for { + // Read Member Header + // The member header is normally 2 bytes larger. But it's easier + // to read the name if the header is read without _ar_nam. + // However, AIAFMAG must be read afterward. + if _, err := sr.Seek(off, os.SEEK_SET); err != nil { + return nil, err + } + + var mhdr bigarMemberHeader + if err := binary.Read(sr, binary.BigEndian, &mhdr); err != nil { + return nil, err + } + + member := new(Member) + arch.Members = append(arch.Members, member) + + size, err := parseDecimalBytes(mhdr.Arsize[:]) + if err != nil { + return nil, fmt.Errorf("error parsing size in member header(%q); %v", mhdr, err) + } + member.Size = uint64(size) + + // Read name + namlen, err := parseDecimalBytes(mhdr.Arnamlen[:]) + if err != nil { + return nil, fmt.Errorf("error parsing name length in member header(%q); %v", mhdr, err) + } + name := make([]byte, namlen) + if err := binary.Read(sr, binary.BigEndian, name); err != nil { + return nil, err + } + member.Name = string(name) + + fileoff := off + AR_HSZ_BIG + namlen + if fileoff&1 != 0 { + fileoff++ + if _, err := sr.Seek(1, os.SEEK_CUR); err != nil { + return nil, err + } + } + + // Read AIAFMAG string + var fmag [2]byte + if err := binary.Read(sr, binary.BigEndian, &fmag); err != nil { + return nil, err + } + if string(fmag[:]) != AIAFMAG { + return nil, fmt.Errorf("AIAFMAG not found after member header") + } + + fileoff += 2 // Add the two bytes of AIAFMAG + member.sr = io.NewSectionReader(sr, fileoff, size) + + if off == lastoff { + break + } + off, err = parseDecimalBytes(mhdr.Arnxtmem[:]) + if err != nil { + return nil, fmt.Errorf("error parsing offset of first member in archive header(%q); %v", fhdr, err) + } + + } + + return arch, nil + +} + +// GetFile returns the XCOFF file defined by member name. +// FIXME: This doesn't work if an archive has two members with the same +// name which can occur if a archive has both 32-bits and 64-bits files. +func (arch *Archive) GetFile(name string) (*File, error) { + for _, mem := range arch.Members { + if mem.Name == name { + return NewFile(mem.sr) + } + } + return nil, fmt.Errorf("unknown member %s in archive", name) + +} diff --git a/libgo/go/internal/xcoff/ar_test.go b/libgo/go/internal/xcoff/ar_test.go new file mode 100644 index 00000000000..03c2fd1c5a2 --- /dev/null +++ b/libgo/go/internal/xcoff/ar_test.go @@ -0,0 +1,79 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package xcoff + +import ( + "reflect" + "testing" +) + +type archiveTest struct { + file string + hdr ArchiveHeader + members []*MemberHeader + membersFileHeader []FileHeader +} + +var archTest = []archiveTest{ + { + "testdata/bigar-ppc64", + ArchiveHeader{AIAMAGBIG}, + []*MemberHeader{ + {"printbye.o", 836}, + {"printhello.o", 860}, + }, + []FileHeader{ + FileHeader{U64_TOCMAGIC}, + FileHeader{U64_TOCMAGIC}, + }, + }, + { + "testdata/bigar-empty", + ArchiveHeader{AIAMAGBIG}, + []*MemberHeader{}, + []FileHeader{}, + }, +} + +func TestOpenArchive(t *testing.T) { + for i := range archTest { + tt := &archTest[i] + arch, err := OpenArchive(tt.file) + if err != nil { + t.Error(err) + continue + } + if !reflect.DeepEqual(arch.ArchiveHeader, tt.hdr) { + t.Errorf("open archive %s:\n\thave %#v\n\twant %#v\n", tt.file, arch.ArchiveHeader, tt.hdr) + continue + } + + for i, mem := range arch.Members { + if i >= len(tt.members) { + break + } + have := &mem.MemberHeader + want := tt.members[i] + if !reflect.DeepEqual(have, want) { + t.Errorf("open %s, member %d:\n\thave %#v\n\twant %#v\n", tt.file, i, have, want) + } + + f, err := arch.GetFile(mem.Name) + if err != nil { + t.Error(err) + continue + } + if !reflect.DeepEqual(f.FileHeader, tt.membersFileHeader[i]) { + t.Errorf("open %s, member file header %d:\n\thave %#v\n\twant %#v\n", tt.file, i, f.FileHeader, tt.membersFileHeader[i]) + } + } + tn := len(tt.members) + an := len(arch.Members) + if tn != an { + t.Errorf("open %s: len(Members) = %d, want %d", tt.file, an, tn) + } + + } +} diff --git a/libgo/go/internal/xcoff/file.go b/libgo/go/internal/xcoff/file.go new file mode 100644 index 00000000000..0923b9fcf3a --- /dev/null +++ b/libgo/go/internal/xcoff/file.go @@ -0,0 +1,687 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package xcoff implements access to XCOFF (Extended Common Object File Format) files. +package xcoff + +import ( + "debug/dwarf" + "encoding/binary" + "fmt" + "io" + "os" + "strings" +) + +// SectionHeader holds information about an XCOFF section header. +type SectionHeader struct { + Name string + VirtualAddress uint64 + Size uint64 + Type uint32 + Relptr uint64 + Nreloc uint32 +} + +type Section struct { + SectionHeader + Relocs []Reloc + io.ReaderAt + sr *io.SectionReader +} + +// AuxiliaryCSect holds information about an XCOFF symbol in an AUX_CSECT entry. +type AuxiliaryCSect struct { + Length int64 + StorageMappingClass int + SymbolType int +} + +// AuxiliaryFcn holds information about an XCOFF symbol in an AUX_FCN entry. +type AuxiliaryFcn struct { + Size int64 +} + +type Symbol struct { + Name string + Value uint64 + SectionNumber int + StorageClass int + AuxFcn AuxiliaryFcn + AuxCSect AuxiliaryCSect +} + +type Reloc struct { + VirtualAddress uint64 + Symbol *Symbol + Signed bool + InstructionFixed bool + Length uint8 + Type uint8 +} + +// ImportedSymbol holds information about an imported XCOFF symbol. +type ImportedSymbol struct { + Name string + Library string +} + +// FileHeader holds information about an XCOFF file header. +type FileHeader struct { + TargetMachine uint16 +} + +// A File represents an open XCOFF file. +type File struct { + FileHeader + Sections []*Section + Symbols []*Symbol + StringTable []byte + LibraryPaths []string + + closer io.Closer +} + +// Open opens the named file using os.Open and prepares it for use as an XCOFF binary. +func Open(name string) (*File, error) { + f, err := os.Open(name) + if err != nil { + return nil, err + } + ff, err := NewFile(f) + if err != nil { + f.Close() + return nil, err + } + ff.closer = f + return ff, nil +} + +// Close closes the File. +// If the File was created using NewFile directly instead of Open, +// Close has no effect. +func (f *File) Close() error { + var err error + if f.closer != nil { + err = f.closer.Close() + f.closer = nil + } + return err +} + +// Section returns the first section with the given name, or nil if no such +// section exists. +// Xcoff have section's name limited to 8 bytes. Some sections like .gosymtab +// can be trunked but this method will still find them. +func (f *File) Section(name string) *Section { + for _, s := range f.Sections { + if s.Name == name || (len(name) > 8 && s.Name == name[:8]) { + return s + } + } + return nil +} + +// SectionByType returns the first section in f with the +// given type, or nil if there is no such section. +func (f *File) SectionByType(typ uint32) *Section { + for _, s := range f.Sections { + if s.Type == typ { + return s + } + } + return nil +} + +// cstring converts ASCII byte sequence b to string. +// It stops once it finds 0 or reaches end of b. +func cstring(b []byte) string { + var i int + for i = 0; i < len(b) && b[i] != 0; i++ { + } + return string(b[:i]) +} + +// getString extracts a string from an XCOFF string table. +func getString(st []byte, offset uint32) (string, bool) { + if offset < 4 || int(offset) >= len(st) { + return "", false + } + return cstring(st[offset:]), true +} + +// NewFile creates a new File for accessing an XCOFF binary in an underlying reader. +func NewFile(r io.ReaderAt) (*File, error) { + sr := io.NewSectionReader(r, 0, 1<<63-1) + // Read XCOFF target machine + var magic uint16 + if err := binary.Read(sr, binary.BigEndian, &magic); err != nil { + return nil, err + } + if magic != U802TOCMAGIC && magic != U64_TOCMAGIC { + return nil, fmt.Errorf("unrecognised XCOFF magic: 0x%x", magic) + } + + f := new(File) + f.TargetMachine = magic + + // Read XCOFF file header + if _, err := sr.Seek(0, os.SEEK_SET); err != nil { + return nil, err + } + var nscns uint16 + var symptr uint64 + var nsyms int32 + var opthdr uint16 + var hdrsz int + switch f.TargetMachine { + case U802TOCMAGIC: + fhdr := new(FileHeader32) + if err := binary.Read(sr, binary.BigEndian, fhdr); err != nil { + return nil, err + } + nscns = fhdr.Fnscns + symptr = uint64(fhdr.Fsymptr) + nsyms = fhdr.Fnsyms + opthdr = fhdr.Fopthdr + hdrsz = FILHSZ_32 + case U64_TOCMAGIC: + fhdr := new(FileHeader64) + if err := binary.Read(sr, binary.BigEndian, fhdr); err != nil { + return nil, err + } + nscns = fhdr.Fnscns + symptr = fhdr.Fsymptr + nsyms = fhdr.Fnsyms + opthdr = fhdr.Fopthdr + hdrsz = FILHSZ_64 + } + + if symptr == 0 || nsyms <= 0 { + return nil, fmt.Errorf("no symbol table") + } + + // Read string table (located right after symbol table). + offset := symptr + uint64(nsyms)*SYMESZ + if _, err := sr.Seek(int64(offset), os.SEEK_SET); err != nil { + return nil, err + } + // The first 4 bytes contain the length (in bytes). + var l uint32 + if err := binary.Read(sr, binary.BigEndian, &l); err != nil { + return nil, err + } + if l > 4 { + if _, err := sr.Seek(int64(offset), os.SEEK_SET); err != nil { + return nil, err + } + f.StringTable = make([]byte, l) + if _, err := io.ReadFull(sr, f.StringTable); err != nil { + return nil, err + } + } + + // Read section headers + if _, err := sr.Seek(int64(hdrsz)+int64(opthdr), os.SEEK_SET); err != nil { + return nil, err + } + f.Sections = make([]*Section, nscns) + for i := 0; i < int(nscns); i++ { + var scnptr uint64 + s := new(Section) + switch f.TargetMachine { + case U802TOCMAGIC: + shdr := new(SectionHeader32) + if err := binary.Read(sr, binary.BigEndian, shdr); err != nil { + return nil, err + } + s.Name = cstring(shdr.Sname[:]) + s.VirtualAddress = uint64(shdr.Svaddr) + s.Size = uint64(shdr.Ssize) + scnptr = uint64(shdr.Sscnptr) + s.Type = shdr.Sflags + s.Relptr = uint64(shdr.Srelptr) + s.Nreloc = uint32(shdr.Snreloc) + case U64_TOCMAGIC: + shdr := new(SectionHeader64) + if err := binary.Read(sr, binary.BigEndian, shdr); err != nil { + return nil, err + } + s.Name = cstring(shdr.Sname[:]) + s.VirtualAddress = shdr.Svaddr + s.Size = shdr.Ssize + scnptr = shdr.Sscnptr + s.Type = shdr.Sflags + s.Relptr = shdr.Srelptr + s.Nreloc = shdr.Snreloc + } + r2 := r + if scnptr == 0 { // .bss must have all 0s + r2 = zeroReaderAt{} + } + s.sr = io.NewSectionReader(r2, int64(scnptr), int64(s.Size)) + s.ReaderAt = s.sr + f.Sections[i] = s + } + + // Symbol map needed by relocation + var idxToSym = make(map[int]*Symbol) + + // Read symbol table + if _, err := sr.Seek(int64(symptr), os.SEEK_SET); err != nil { + return nil, err + } + f.Symbols = make([]*Symbol, 0) + for i := 0; i < int(nsyms); i++ { + var numaux int + var ok, needAuxFcn bool + sym := new(Symbol) + switch f.TargetMachine { + case U802TOCMAGIC: + se := new(SymEnt32) + if err := binary.Read(sr, binary.BigEndian, se); err != nil { + return nil, err + } + numaux = int(se.Nnumaux) + sym.SectionNumber = int(se.Nscnum) + sym.StorageClass = int(se.Nsclass) + sym.Value = uint64(se.Nvalue) + needAuxFcn = se.Ntype&SYM_TYPE_FUNC != 0 && numaux > 1 + zeroes := binary.BigEndian.Uint32(se.Nname[:4]) + if zeroes != 0 { + sym.Name = cstring(se.Nname[:]) + } else { + offset := binary.BigEndian.Uint32(se.Nname[4:]) + sym.Name, ok = getString(f.StringTable, offset) + if !ok { + goto skip + } + } + case U64_TOCMAGIC: + se := new(SymEnt64) + if err := binary.Read(sr, binary.BigEndian, se); err != nil { + return nil, err + } + numaux = int(se.Nnumaux) + sym.SectionNumber = int(se.Nscnum) + sym.StorageClass = int(se.Nsclass) + sym.Value = se.Nvalue + needAuxFcn = se.Ntype&SYM_TYPE_FUNC != 0 && numaux > 1 + sym.Name, ok = getString(f.StringTable, se.Noffset) + if !ok { + goto skip + } + } + if sym.StorageClass != C_EXT && sym.StorageClass != C_WEAKEXT && sym.StorageClass != C_HIDEXT { + goto skip + } + // Must have at least one csect auxiliary entry. + if numaux < 1 || i+numaux >= int(nsyms) { + goto skip + } + + if sym.SectionNumber > int(nscns) { + goto skip + } + if sym.SectionNumber == 0 { + sym.Value = 0 + } else { + sym.Value -= f.Sections[sym.SectionNumber-1].VirtualAddress + } + + idxToSym[i] = sym + + // If this symbol is a function, it must retrieve its size from + // its AUX_FCN entry. + // It can happend that a function symbol doesn't have any AUX_FCN. + // In this case, needAuxFcn is false and their size will be set to 0 + if needAuxFcn { + switch f.TargetMachine { + case U802TOCMAGIC: + aux := new(AuxFcn32) + if err := binary.Read(sr, binary.BigEndian, aux); err != nil { + return nil, err + } + sym.AuxFcn.Size = int64(aux.Xfsize) + case U64_TOCMAGIC: + aux := new(AuxFcn64) + if err := binary.Read(sr, binary.BigEndian, aux); err != nil { + return nil, err + } + sym.AuxFcn.Size = int64(aux.Xfsize) + } + } + + // Read csect auxiliary entry (by convention, it is the last). + if !needAuxFcn { + if _, err := sr.Seek(int64(numaux-1)*SYMESZ, os.SEEK_CUR); err != nil { + return nil, err + } + } + i += numaux + numaux = 0 + switch f.TargetMachine { + case U802TOCMAGIC: + aux := new(AuxCSect32) + if err := binary.Read(sr, binary.BigEndian, aux); err != nil { + return nil, err + } + sym.AuxCSect.SymbolType = int(aux.Xsmtyp & 0x7) + sym.AuxCSect.StorageMappingClass = int(aux.Xsmclas) + sym.AuxCSect.Length = int64(aux.Xscnlen) + case U64_TOCMAGIC: + aux := new(AuxCSect64) + if err := binary.Read(sr, binary.BigEndian, aux); err != nil { + return nil, err + } + sym.AuxCSect.SymbolType = int(aux.Xsmtyp & 0x7) + sym.AuxCSect.StorageMappingClass = int(aux.Xsmclas) + sym.AuxCSect.Length = int64(aux.Xscnlenhi)<<32 | int64(aux.Xscnlenlo) + } + f.Symbols = append(f.Symbols, sym) + skip: + i += numaux // Skip auxiliary entries + if _, err := sr.Seek(int64(numaux)*SYMESZ, os.SEEK_CUR); err != nil { + return nil, err + } + } + + // Read relocations + // Only for .data or .text section + for _, sect := range f.Sections { + if sect.Type != STYP_TEXT && sect.Type != STYP_DATA { + continue + } + sect.Relocs = make([]Reloc, sect.Nreloc) + if sect.Relptr == 0 { + continue + } + if _, err := sr.Seek(int64(sect.Relptr), os.SEEK_SET); err != nil { + return nil, err + } + for i := uint32(0); i < sect.Nreloc; i++ { + switch f.TargetMachine { + case U802TOCMAGIC: + rel := new(Reloc32) + if err := binary.Read(sr, binary.BigEndian, rel); err != nil { + return nil, err + } + sect.Relocs[i].VirtualAddress = uint64(rel.Rvaddr) + sect.Relocs[i].Symbol = idxToSym[int(rel.Rsymndx)] + sect.Relocs[i].Type = rel.Rtype + sect.Relocs[i].Length = rel.Rsize&0x3F + 1 + + if rel.Rsize&0x80 == 1 { + sect.Relocs[i].Signed = true + } + if rel.Rsize&0x40 == 1 { + sect.Relocs[i].InstructionFixed = true + } + + case U64_TOCMAGIC: + rel := new(Reloc64) + if err := binary.Read(sr, binary.BigEndian, rel); err != nil { + return nil, err + } + sect.Relocs[i].VirtualAddress = rel.Rvaddr + sect.Relocs[i].Symbol = idxToSym[int(rel.Rsymndx)] + sect.Relocs[i].Type = rel.Rtype + sect.Relocs[i].Length = rel.Rsize&0x3F + 1 + if rel.Rsize&0x80 == 1 { + sect.Relocs[i].Signed = true + } + if rel.Rsize&0x40 == 1 { + sect.Relocs[i].InstructionFixed = true + } + } + } + } + + return f, nil +} + +// zeroReaderAt is ReaderAt that reads 0s. +type zeroReaderAt struct{} + +// ReadAt writes len(p) 0s into p. +func (w zeroReaderAt) ReadAt(p []byte, off int64) (n int, err error) { + for i := range p { + p[i] = 0 + } + return len(p), nil +} + +// Data reads and returns the contents of the XCOFF section s. +func (s *Section) Data() ([]byte, error) { + dat := make([]byte, s.sr.Size()) + n, err := s.sr.ReadAt(dat, 0) + if n == len(dat) { + err = nil + } + return dat[:n], err +} + +// CSect reads and returns the contents of a csect. +func (f *File) CSect(name string) []byte { + for _, sym := range f.Symbols { + if sym.Name == name && sym.AuxCSect.SymbolType == XTY_SD { + if i := sym.SectionNumber - 1; 0 <= i && i < len(f.Sections) { + s := f.Sections[i] + if sym.Value+uint64(sym.AuxCSect.Length) <= s.Size { + dat := make([]byte, sym.AuxCSect.Length) + _, err := s.sr.ReadAt(dat, int64(sym.Value)) + if err != nil { + return nil + } + return dat + } + } + break + } + } + return nil +} + +func (f *File) DWARF() (*dwarf.Data, error) { + // There are many other DWARF sections, but these + // are the ones the debug/dwarf package uses. + // Don't bother loading others. + var subtypes = [...]uint32{SSUBTYP_DWABREV, SSUBTYP_DWINFO, SSUBTYP_DWLINE, SSUBTYP_DWRNGES, SSUBTYP_DWSTR} + var dat [len(subtypes)][]byte + for i, subtype := range subtypes { + s := f.SectionByType(STYP_DWARF | subtype) + if s != nil { + b, err := s.Data() + if err != nil && uint64(len(b)) < s.Size { + return nil, err + } + dat[i] = b + } + } + + abbrev, info, line, ranges, str := dat[0], dat[1], dat[2], dat[3], dat[4] + return dwarf.New(abbrev, nil, nil, info, line, nil, ranges, str) +} + +// readImportID returns the import file IDs stored inside the .loader section. +// Library name pattern is either path/base/member or base/member +func (f *File) readImportIDs(s *Section) ([]string, error) { + // Read loader header + if _, err := s.sr.Seek(0, os.SEEK_SET); err != nil { + return nil, err + } + var istlen uint32 + var nimpid int32 + var impoff uint64 + switch f.TargetMachine { + case U802TOCMAGIC: + lhdr := new(LoaderHeader32) + if err := binary.Read(s.sr, binary.BigEndian, lhdr); err != nil { + return nil, err + } + istlen = lhdr.Listlen + nimpid = lhdr.Lnimpid + impoff = uint64(lhdr.Limpoff) + case U64_TOCMAGIC: + lhdr := new(LoaderHeader64) + if err := binary.Read(s.sr, binary.BigEndian, lhdr); err != nil { + return nil, err + } + istlen = lhdr.Listlen + nimpid = lhdr.Lnimpid + impoff = lhdr.Limpoff + } + + // Read loader import file ID table + if _, err := s.sr.Seek(int64(impoff), os.SEEK_SET); err != nil { + return nil, err + } + table := make([]byte, istlen) + if _, err := io.ReadFull(s.sr, table); err != nil { + return nil, err + } + + offset := 0 + // First import file ID is the default LIBPATH value + libpath := cstring(table[offset:]) + f.LibraryPaths = strings.Split(libpath, ":") + offset += len(libpath) + 3 // 3 null bytes + all := make([]string, 0) + for i := 1; i < int(nimpid); i++ { + impidpath := cstring(table[offset:]) + offset += len(impidpath) + 1 + impidbase := cstring(table[offset:]) + offset += len(impidbase) + 1 + impidmem := cstring(table[offset:]) + offset += len(impidmem) + 1 + var path string + if len(impidpath) > 0 { + path = impidpath + "/" + impidbase + "/" + impidmem + } else { + path = impidbase + "/" + impidmem + } + all = append(all, path) + } + + return all, nil +} + +// ImportedSymbols returns the names of all symbols +// referred to by the binary f that are expected to be +// satisfied by other libraries at dynamic load time. +// It does not return weak symbols. +func (f *File) ImportedSymbols() ([]ImportedSymbol, error) { + s := f.SectionByType(STYP_LOADER) + if s == nil { + return nil, nil + } + // Read loader header + if _, err := s.sr.Seek(0, os.SEEK_SET); err != nil { + return nil, err + } + var stlen uint32 + var stoff uint64 + var nsyms int32 + var symoff uint64 + switch f.TargetMachine { + case U802TOCMAGIC: + lhdr := new(LoaderHeader32) + if err := binary.Read(s.sr, binary.BigEndian, lhdr); err != nil { + return nil, err + } + stlen = lhdr.Lstlen + stoff = uint64(lhdr.Lstoff) + nsyms = lhdr.Lnsyms + symoff = LDHDRSZ_32 + case U64_TOCMAGIC: + lhdr := new(LoaderHeader64) + if err := binary.Read(s.sr, binary.BigEndian, lhdr); err != nil { + return nil, err + } + stlen = lhdr.Lstlen + stoff = lhdr.Lstoff + nsyms = lhdr.Lnsyms + symoff = lhdr.Lsymoff + } + + // Read loader section string table + if _, err := s.sr.Seek(int64(stoff), os.SEEK_SET); err != nil { + return nil, err + } + st := make([]byte, stlen) + if _, err := io.ReadFull(s.sr, st); err != nil { + return nil, err + } + + // Read imported libraries + libs, err := f.readImportIDs(s) + if err != nil { + return nil, err + } + + // Read loader symbol table + if _, err := s.sr.Seek(int64(symoff), os.SEEK_SET); err != nil { + return nil, err + } + all := make([]ImportedSymbol, 0) + for i := 0; i < int(nsyms); i++ { + var name string + var ifile int32 + var ok bool + switch f.TargetMachine { + case U802TOCMAGIC: + ldsym := new(LoaderSymbol32) + if err := binary.Read(s.sr, binary.BigEndian, ldsym); err != nil { + return nil, err + } + if ldsym.Lsmtype&0x40 == 0 { + continue // Imported symbols only + } + zeroes := binary.BigEndian.Uint32(ldsym.Lname[:4]) + if zeroes != 0 { + name = cstring(ldsym.Lname[:]) + } else { + offset := binary.BigEndian.Uint32(ldsym.Lname[4:]) + name, ok = getString(st, offset) + if !ok { + continue + } + } + ifile = ldsym.Lifile + case U64_TOCMAGIC: + ldsym := new(LoaderSymbol64) + if err := binary.Read(s.sr, binary.BigEndian, ldsym); err != nil { + return nil, err + } + if ldsym.Lsmtype&0x40 == 0 { + continue // Imported symbols only + } + name, ok = getString(st, ldsym.Loffset) + if !ok { + continue + } + ifile = ldsym.Lifile + } + var sym ImportedSymbol + sym.Name = name + if ifile >= 1 && int(ifile) <= len(libs) { + sym.Library = libs[ifile-1] + } + all = append(all, sym) + } + + return all, nil +} + +// ImportedLibraries returns the names of all libraries +// referred to by the binary f that are expected to be +// linked with the binary at dynamic link time. +func (f *File) ImportedLibraries() ([]string, error) { + s := f.SectionByType(STYP_LOADER) + if s == nil { + return nil, nil + } + all, err := f.readImportIDs(s) + return all, err +} diff --git a/libgo/go/internal/xcoff/file_test.go b/libgo/go/internal/xcoff/file_test.go new file mode 100644 index 00000000000..a6722e9453f --- /dev/null +++ b/libgo/go/internal/xcoff/file_test.go @@ -0,0 +1,102 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package xcoff + +import ( + "reflect" + "testing" +) + +type fileTest struct { + file string + hdr FileHeader + sections []*SectionHeader + needed []string +} + +var fileTests = []fileTest{ + { + "testdata/gcc-ppc32-aix-dwarf2-exec", + FileHeader{U802TOCMAGIC}, + []*SectionHeader{ + {".text", 0x10000290, 0x00000bbd, STYP_TEXT, 0x7ae6, 0x36}, + {".data", 0x20000e4d, 0x00000437, STYP_DATA, 0x7d02, 0x2b}, + {".bss", 0x20001284, 0x0000021c, STYP_BSS, 0, 0}, + {".loader", 0x00000000, 0x000004b3, STYP_LOADER, 0, 0}, + {".dwline", 0x00000000, 0x000000df, STYP_DWARF | SSUBTYP_DWLINE, 0x7eb0, 0x7}, + {".dwinfo", 0x00000000, 0x00000314, STYP_DWARF | SSUBTYP_DWINFO, 0x7ef6, 0xa}, + {".dwabrev", 0x00000000, 0x000000d6, STYP_DWARF | SSUBTYP_DWABREV, 0, 0}, + {".dwarnge", 0x00000000, 0x00000020, STYP_DWARF | SSUBTYP_DWARNGE, 0x7f5a, 0x2}, + {".dwloc", 0x00000000, 0x00000074, STYP_DWARF | SSUBTYP_DWLOC, 0, 0}, + {".debug", 0x00000000, 0x00005e4f, STYP_DEBUG, 0, 0}, + }, + []string{"libc.a/shr.o"}, + }, + { + "testdata/gcc-ppc64-aix-dwarf2-exec", + FileHeader{U64_TOCMAGIC}, + []*SectionHeader{ + {".text", 0x10000480, 0x00000afd, STYP_TEXT, 0x8322, 0x34}, + {".data", 0x20000f7d, 0x000002f3, STYP_DATA, 0x85fa, 0x25}, + {".bss", 0x20001270, 0x00000428, STYP_BSS, 0, 0}, + {".loader", 0x00000000, 0x00000535, STYP_LOADER, 0, 0}, + {".dwline", 0x00000000, 0x000000b4, STYP_DWARF | SSUBTYP_DWLINE, 0x8800, 0x4}, + {".dwinfo", 0x00000000, 0x0000036a, STYP_DWARF | SSUBTYP_DWINFO, 0x8838, 0x7}, + {".dwabrev", 0x00000000, 0x000000b5, STYP_DWARF | SSUBTYP_DWABREV, 0, 0}, + {".dwarnge", 0x00000000, 0x00000040, STYP_DWARF | SSUBTYP_DWARNGE, 0x889a, 0x2}, + {".dwloc", 0x00000000, 0x00000062, STYP_DWARF | SSUBTYP_DWLOC, 0, 0}, + {".debug", 0x00000000, 0x00006605, STYP_DEBUG, 0, 0}, + }, + []string{"libc.a/shr_64.o"}, + }, +} + +func TestOpen(t *testing.T) { + for i := range fileTests { + tt := &fileTests[i] + + f, err := Open(tt.file) + if err != nil { + t.Error(err) + continue + } + if !reflect.DeepEqual(f.FileHeader, tt.hdr) { + t.Errorf("open %s:\n\thave %#v\n\twant %#v\n", tt.file, f.FileHeader, tt.hdr) + continue + } + + for i, sh := range f.Sections { + if i >= len(tt.sections) { + break + } + have := &sh.SectionHeader + want := tt.sections[i] + if !reflect.DeepEqual(have, want) { + t.Errorf("open %s, section %d:\n\thave %#v\n\twant %#v\n", tt.file, i, have, want) + } + } + tn := len(tt.sections) + fn := len(f.Sections) + if tn != fn { + t.Errorf("open %s: len(Sections) = %d, want %d", tt.file, fn, tn) + } + tl := tt.needed + fl, err := f.ImportedLibraries() + if err != nil { + t.Error(err) + } + if !reflect.DeepEqual(tl, fl) { + t.Errorf("open %s: loader import = %v, want %v", tt.file, tl, fl) + } + } +} + +func TestOpenFailure(t *testing.T) { + filename := "file.go" // not an XCOFF object file + _, err := Open(filename) // don't crash + if err == nil { + t.Errorf("open %s: succeeded unexpectedly", filename) + } +} diff --git a/libgo/go/internal/xcoff/testdata/bigar-empty b/libgo/go/internal/xcoff/testdata/bigar-empty new file mode 100644 index 00000000000..851ccc51236 --- /dev/null +++ b/libgo/go/internal/xcoff/testdata/bigar-empty @@ -0,0 +1,2 @@ + +0 0 0 0 0 0 \ No newline at end of file diff --git a/libgo/go/internal/xcoff/testdata/bigar-ppc64 b/libgo/go/internal/xcoff/testdata/bigar-ppc64 new file mode 100644 index 0000000000000000000000000000000000000000..a8d4979d121f71266b57bc33c0e55e2b8a679cbb GIT binary patch literal 2468 zcmcIm&ubG=5T4ye3F)CxN@=}x=FfVZC|q z;8DSI>A&Tz;z96YpkkbPZ{FJ<*`^xsL3U=|``*mFdHc=gPP22+*uR%4<|`#DHu5o> z%wn-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<9xWOEn?uzXJELM1DqxQh)ctq4@q*_C$AnkC+7eSbDmnB^Ai2>bFt+8$m_xR?727x zX_)g&GiUUo-Slj%dIJxH#-sA_kh$4vk>9LNNq({)9(G)+;}uYN&~2$`(_{JtJ&2Cq zwhkii@xiztqv59>JGd~On=AH?-nw)5{)69H6T> z^k98|PPpWz(%ej8k7T(o_M@UTNBpavi}RiTv6S>TG^c~NhO{{v6+R3!ia literal 0 HcmV?d00001 diff --git a/libgo/go/internal/xcoff/testdata/gcc-ppc64-aix-dwarf2-exec b/libgo/go/internal/xcoff/testdata/gcc-ppc64-aix-dwarf2-exec new file mode 100644 index 0000000000000000000000000000000000000000..707d01ebd43487081a620250a213dcdba7a80379 GIT binary patch literal 57152 zcmeHwYhYZ}b?%vwY|EBxjbvdAc3{AH7$ZybIP=g5#gc7|4K_F+s7Yv!Ml&O6K$;n5 zMzTyG2tpc~r%BT^4?<`{38YC&a%oCanvyiPH))eLy|*`|DQyTh$+b(;()QlegaqAh zt^GKUElZ~9kNd+1&a?qgGc`girr( zU$Zpdl+h|*b+;_Vw{<~~yzOFfzxNBc+xWX4e^LBdeZ_n;PY<}*EI-*}@T!{F0hqi1!8oVZ>p{xtUm!uzJH`C_Sl8j@8h5h3_5O%!3cuXuF2 zTq!M0Vp)%ih;ttn_j|o`tsDrWIdOqcxiV4p#(SPyZWe*fZxr`?v!2K`{2bDJ^5gZ= zoG0G<_(u42O?&DPt*{oapwctBrqtzN zdqQg!pVIj3qzCssPOK8aS8esdzChF$IvZG80w=y=StoZ}`-h^dL%pxHtba^|qS@zu z{=$j7ts^HsVU6AQ6|3#V=dA3h5o`O2jg~cXx7Bg-Zfok)H!SP+wJi^yxXx<3Z--@_ z`WI{STlf6h{M8Gs7o7m@!noBofGkfuXVvcb{#)kXy6SE7_d#>_TcOX50bh8|8tz3H z{MtafcfS?pbhqEt*2X36hz|4JvOZv~ahygoUsrZX;(R-S{?r?_tV4HO(fzPNS1-Uk z@I~oc#G_^PSQ{LtIa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.c b/libgo/go/internal/xcoff/testdata/hello.c new file mode 100644 index 00000000000..34d9ee79234 --- /dev/null +++ b/libgo/go/internal/xcoff/testdata/hello.c @@ -0,0 +1,7 @@ +#include + +void +main(int argc, char *argv[]) +{ + printf("hello, world\n"); +} diff --git a/libgo/go/internal/xcoff/testdata/printbye.c b/libgo/go/internal/xcoff/testdata/printbye.c new file mode 100644 index 00000000000..904507998ab --- /dev/null +++ b/libgo/go/internal/xcoff/testdata/printbye.c @@ -0,0 +1,5 @@ +#include + +void printbye(){ + printf("Goodbye\n"); +} diff --git a/libgo/go/internal/xcoff/testdata/printhello.c b/libgo/go/internal/xcoff/testdata/printhello.c new file mode 100644 index 00000000000..182aa09728a --- /dev/null +++ b/libgo/go/internal/xcoff/testdata/printhello.c @@ -0,0 +1,5 @@ +#include + +void printhello(){ + printf("Helloworld\n"); +} diff --git a/libgo/go/internal/xcoff/xcoff.go b/libgo/go/internal/xcoff/xcoff.go new file mode 100644 index 00000000000..f8465d72897 --- /dev/null +++ b/libgo/go/internal/xcoff/xcoff.go @@ -0,0 +1,367 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package xcoff + +// File Header. +type FileHeader32 struct { + Fmagic uint16 // Target machine + Fnscns uint16 // Number of sections + Ftimedat int32 // Time and date of file creation + Fsymptr uint32 // Byte offset to symbol table start + Fnsyms int32 // Number of entries in symbol table + Fopthdr uint16 // Number of bytes in optional header + Fflags uint16 // Flags +} + +type FileHeader64 struct { + Fmagic uint16 // Target machine + Fnscns uint16 // Number of sections + Ftimedat int32 // Time and date of file creation + Fsymptr uint64 // Byte offset to symbol table start + Fopthdr uint16 // Number of bytes in optional header + Fflags uint16 // Flags + Fnsyms int32 // Number of entries in symbol table +} + +const ( + FILHSZ_32 = 20 + FILHSZ_64 = 24 +) +const ( + U802TOCMAGIC = 0737 // AIX 32-bit XCOFF + U64_TOCMAGIC = 0767 // AIX 64-bit XCOFF +) + +// Flags that describe the type of the object file. +const ( + F_RELFLG = 0x0001 + F_EXEC = 0x0002 + F_LNNO = 0x0004 + F_FDPR_PROF = 0x0010 + F_FDPR_OPTI = 0x0020 + F_DSA = 0x0040 + F_VARPG = 0x0100 + F_DYNLOAD = 0x1000 + F_SHROBJ = 0x2000 + F_LOADONLY = 0x4000 +) + +// Section Header. +type SectionHeader32 struct { + Sname [8]byte // Section name + Spaddr uint32 // Physical address + Svaddr uint32 // Virtual address + Ssize uint32 // Section size + Sscnptr uint32 // Offset in file to raw data for section + Srelptr uint32 // Offset in file to relocation entries for section + Slnnoptr uint32 // Offset in file to line number entries for section + Snreloc uint16 // Number of relocation entries + Snlnno uint16 // Number of line number entries + Sflags uint32 // Flags to define the section type +} + +type SectionHeader64 struct { + Sname [8]byte // Section name + Spaddr uint64 // Physical address + Svaddr uint64 // Virtual address + Ssize uint64 // Section size + Sscnptr uint64 // Offset in file to raw data for section + Srelptr uint64 // Offset in file to relocation entries for section + Slnnoptr uint64 // Offset in file to line number entries for section + Snreloc uint32 // Number of relocation entries + Snlnno uint32 // Number of line number entries + Sflags uint32 // Flags to define the section type + Spad uint32 // Needs to be 72 bytes long +} + +// Flags defining the section type. +const ( + STYP_DWARF = 0x0010 + STYP_TEXT = 0x0020 + STYP_DATA = 0x0040 + STYP_BSS = 0x0080 + STYP_EXCEPT = 0x0100 + STYP_INFO = 0x0200 + STYP_TDATA = 0x0400 + STYP_TBSS = 0x0800 + STYP_LOADER = 0x1000 + STYP_DEBUG = 0x2000 + STYP_TYPCHK = 0x4000 + STYP_OVRFLO = 0x8000 +) +const ( + SSUBTYP_DWINFO = 0x10000 // DWARF info section + SSUBTYP_DWLINE = 0x20000 // DWARF line-number section + SSUBTYP_DWPBNMS = 0x30000 // DWARF public names section + SSUBTYP_DWPBTYP = 0x40000 // DWARF public types section + SSUBTYP_DWARNGE = 0x50000 // DWARF aranges section + SSUBTYP_DWABREV = 0x60000 // DWARF abbreviation section + SSUBTYP_DWSTR = 0x70000 // DWARF strings section + SSUBTYP_DWRNGES = 0x80000 // DWARF ranges section + SSUBTYP_DWLOC = 0x90000 // DWARF location lists section + SSUBTYP_DWFRAME = 0xA0000 // DWARF frames section + SSUBTYP_DWMAC = 0xB0000 // DWARF macros section +) + +// Symbol Table Entry. +type SymEnt32 struct { + Nname [8]byte // Symbol name + Nvalue uint32 // Symbol value + Nscnum int16 // Section number of symbol + Ntype uint16 // Basic and derived type specification + Nsclass int8 // Storage class of symbol + Nnumaux int8 // Number of auxiliary entries +} + +type SymEnt64 struct { + Nvalue uint64 // Symbol value + Noffset uint32 // Offset of the name in string table or .debug section + Nscnum int16 // Section number of symbol + Ntype uint16 // Basic and derived type specification + Nsclass int8 // Storage class of symbol + Nnumaux int8 // Number of auxiliary entries +} + +const SYMESZ = 18 + +const ( + // Nscnum + N_DEBUG = -2 + N_ABS = -1 + N_UNDEF = 0 + + //Ntype + SYM_V_INTERNAL = 0x1000 + SYM_V_HIDDEN = 0x2000 + SYM_V_PROTECTED = 0x3000 + SYM_V_EXPORTED = 0x4000 + SYM_TYPE_FUNC = 0x0020 // is function +) + +// Storage Class. +const ( + C_NULL = 0 // Symbol table entry marked for deletion + C_EXT = 2 // External symbol + C_STAT = 3 // Static symbol + C_BLOCK = 100 // Beginning or end of inner block + C_FCN = 101 // Beginning or end of function + C_FILE = 103 // Source file name and compiler information + C_HIDEXT = 107 // Unnamed external symbol + C_BINCL = 108 // Beginning of include file + C_EINCL = 109 // End of include file + C_WEAKEXT = 111 // Weak external symbol + C_DWARF = 112 // DWARF symbol + C_GSYM = 128 // Global variable + C_LSYM = 129 // Automatic variable allocated on stack + C_PSYM = 130 // Argument to subroutine allocated on stack + C_RSYM = 131 // Register variable + C_RPSYM = 132 // Argument to function or procedure stored in register + C_STSYM = 133 // Statically allocated symbol + C_BCOMM = 135 // Beginning of common block + C_ECOML = 136 // Local member of common block + C_ECOMM = 137 // End of common block + C_DECL = 140 // Declaration of object + C_ENTRY = 141 // Alternate entry + C_FUN = 142 // Function or procedure + C_BSTAT = 143 // Beginning of static block + C_ESTAT = 144 // End of static block + C_GTLS = 145 // Global thread-local variable + C_STTLS = 146 // Static thread-local variable +) + +// File Auxiliary Entry +type AuxFile64 struct { + Xfname [8]byte // Name or offset inside string table + Xftype uint8 // Source file string type + Xauxtype uint8 // Type of auxiliary entry +} + +// Function Auxiliary Entry +type AuxFcn32 struct { + Xexptr uint32 // File offset to exception table entry + Xfsize uint32 // Size of function in bytes + Xlnnoptr uint32 // File pointer to line number + Xendndx uint32 // Symbol table index of next entry + Xpad uint16 // Unused +} +type AuxFcn64 struct { + Xlnnoptr uint64 // File pointer to line number + Xfsize uint32 // Size of function in bytes + Xendndx uint32 // Symbol table index of next entry + Xpad uint8 // Unused + Xauxtype uint8 // Type of auxiliary entry +} + +type AuxSect64 struct { + Xscnlen uint64 // section length + Xnreloc uint64 // Num RLDs + pad uint8 + Xauxtype uint8 // Type of auxiliary entry +} + +// csect Auxiliary Entry. +type AuxCSect32 struct { + Xscnlen int32 // Length or symbol table index + Xparmhash uint32 // Offset of parameter type-check string + Xsnhash uint16 // .typchk section number + Xsmtyp uint8 // Symbol alignment and type + Xsmclas uint8 // Storage-mapping class + Xstab uint32 // Reserved + Xsnstab uint16 // Reserved +} + +type AuxCSect64 struct { + Xscnlenlo uint32 // Lower 4 bytes of length or symbol table index + Xparmhash uint32 // Offset of parameter type-check string + Xsnhash uint16 // .typchk section number + Xsmtyp uint8 // Symbol alignment and type + Xsmclas uint8 // Storage-mapping class + Xscnlenhi int32 // Upper 4 bytes of length or symbol table index + Xpad uint8 // Unused + Xauxtype uint8 // Type of auxiliary entry +} + +// Auxiliary type +const ( + _AUX_EXCEPT = 255 + _AUX_FCN = 254 + _AUX_SYM = 253 + _AUX_FILE = 252 + _AUX_CSECT = 251 + _AUX_SECT = 250 +) + +// Symbol type field. +const ( + XTY_ER = 0 // External reference + XTY_SD = 1 // Section definition + XTY_LD = 2 // Label definition + XTY_CM = 3 // Common csect definition +) + +// Defines for File auxiliary definitions: x_ftype field of x_file +const ( + XFT_FN = 0 // Source File Name + XFT_CT = 1 // Compile Time Stamp + XFT_CV = 2 // Compiler Version Number + XFT_CD = 128 // Compiler Defined Information +) + +// Storage-mapping class. +const ( + XMC_PR = 0 // Program code + XMC_RO = 1 // Read-only constant + XMC_DB = 2 // Debug dictionary table + XMC_TC = 3 // TOC entry + XMC_UA = 4 // Unclassified + XMC_RW = 5 // Read/Write data + XMC_GL = 6 // Global linkage + XMC_XO = 7 // Extended operation + XMC_SV = 8 // 32-bit supervisor call descriptor + XMC_BS = 9 // BSS class + XMC_DS = 10 // Function descriptor + XMC_UC = 11 // Unnamed FORTRAN common + XMC_TC0 = 15 // TOC anchor + XMC_TD = 16 // Scalar data entry in the TOC + XMC_SV64 = 17 // 64-bit supervisor call descriptor + XMC_SV3264 = 18 // Supervisor call descriptor for both 32-bit and 64-bit + XMC_TL = 20 // Read/Write thread-local data + XMC_UL = 21 // Read/Write thread-local data (.tbss) + XMC_TE = 22 // TOC entry +) + +// Loader Header. +type LoaderHeader32 struct { + Lversion int32 // Loader section version number + Lnsyms int32 // Number of symbol table entries + Lnreloc int32 // Number of relocation table entries + Listlen uint32 // Length of import file ID string table + Lnimpid int32 // Number of import file IDs + Limpoff uint32 // Offset to start of import file IDs + Lstlen uint32 // Length of string table + Lstoff uint32 // Offset to start of string table +} + +type LoaderHeader64 struct { + Lversion int32 // Loader section version number + Lnsyms int32 // Number of symbol table entries + Lnreloc int32 // Number of relocation table entries + Listlen uint32 // Length of import file ID string table + Lnimpid int32 // Number of import file IDs + Lstlen uint32 // Length of string table + Limpoff uint64 // Offset to start of import file IDs + Lstoff uint64 // Offset to start of string table + Lsymoff uint64 // Offset to start of symbol table + Lrldoff uint64 // Offset to start of relocation entries +} + +const ( + LDHDRSZ_32 = 32 + LDHDRSZ_64 = 56 +) + +// Loader Symbol. +type LoaderSymbol32 struct { + Lname [8]byte // Symbol name or byte offset into string table + Lvalue uint32 // Address field + Lscnum int16 // Section number containing symbol + Lsmtype int8 // Symbol type, export, import flags + Lsmclas int8 // Symbol storage class + Lifile int32 // Import file ID; ordinal of import file IDs + Lparm uint32 // Parameter type-check field +} + +type LoaderSymbol64 struct { + Lvalue uint64 // Address field + Loffset uint32 // Byte offset into string table of symbol name + Lscnum int16 // Section number containing symbol + Lsmtype int8 // Symbol type, export, import flags + Lsmclas int8 // Symbol storage class + Lifile int32 // Import file ID; ordinal of import file IDs + Lparm uint32 // Parameter type-check field +} + +type Reloc32 struct { + Rvaddr uint32 // (virtual) address of reference + Rsymndx uint32 // Index into symbol table + Rsize uint8 // Sign and reloc bit len + Rtype uint8 // Toc relocation type +} + +type Reloc64 struct { + Rvaddr uint64 // (virtual) address of reference + Rsymndx uint32 // Index into symbol table + Rsize uint8 // Sign and reloc bit len + Rtype uint8 // Toc relocation type +} + +const ( + R_POS = 0x00 // A(sym) Positive Relocation + R_NEG = 0x01 // -A(sym) Negative Relocation + R_REL = 0x02 // A(sym-*) Relative to self + R_TOC = 0x03 // A(sym-TOC) Relative to TOC + R_TRL = 0x12 // A(sym-TOC) TOC Relative indirect load. + + R_TRLA = 0x13 // A(sym-TOC) TOC Rel load address. modifiable inst + R_GL = 0x05 // A(external TOC of sym) Global Linkage + R_TCL = 0x06 // A(local TOC of sym) Local object TOC address + R_RL = 0x0C // A(sym) Pos indirect load. modifiable instruction + R_RLA = 0x0D // A(sym) Pos Load Address. modifiable instruction + R_REF = 0x0F // AL0(sym) Non relocating ref. No garbage collect + R_BA = 0x08 // A(sym) Branch absolute. Cannot modify instruction + R_RBA = 0x18 // A(sym) Branch absolute. modifiable instruction + R_BR = 0x0A // A(sym-*) Branch rel to self. non modifiable + R_RBR = 0x1A // A(sym-*) Branch rel to self. modifiable instr + + R_TLS = 0x20 // General-dynamic reference to TLS symbol + R_TLS_IE = 0x21 // Initial-exec reference to TLS symbol + R_TLS_LD = 0x22 // Local-dynamic reference to TLS symbol + R_TLS_LE = 0x23 // Local-exec reference to TLS symbol + R_TLSM = 0x24 // Module reference to TLS symbol + R_TLSML = 0x25 // Module reference to local (own) module + + R_TOCU = 0x30 // Relative to TOC - high order bits + R_TOCL = 0x31 // Relative to TOC - low order bits +) diff --git a/libgo/go/io/io.go b/libgo/go/io/io.go index 72b75813a5e..2010770e6a4 100644 --- a/libgo/go/io/io.go +++ b/libgo/go/io/io.go @@ -278,16 +278,16 @@ type RuneScanner interface { UnreadRune() error } -// stringWriter is the interface that wraps the WriteString method. -type stringWriter interface { +// StringWriter is the interface that wraps the WriteString method. +type StringWriter interface { WriteString(s string) (n int, err error) } // WriteString writes the contents of the string s to w, which accepts a slice of bytes. -// If w implements a WriteString method, it is invoked directly. +// If w implements StringWriter, its WriteString method is invoked directly. // Otherwise, w.Write is called exactly once. func WriteString(w Writer, s string) (n int, err error) { - if sw, ok := w.(stringWriter); ok { + if sw, ok := w.(StringWriter); ok { return sw.WriteString(s) } return w.Write([]byte(s)) diff --git a/libgo/go/io/ioutil/example_test.go b/libgo/go/io/ioutil/example_test.go index 4cc7a7f0551..3066c94ee32 100644 --- a/libgo/go/io/ioutil/example_test.go +++ b/libgo/go/io/ioutil/example_test.go @@ -101,3 +101,11 @@ func ExampleReadFile() { // Output: // File contents: Hello, Gophers! } + +func ExampleWriteFile() { + message := []byte("Hello, Gophers!") + err := ioutil.WriteFile("testdata/hello", message, 0644) + if err != nil { + log.Fatal(err) + } +} diff --git a/libgo/go/io/multi.go b/libgo/go/io/multi.go index 65f99099ca7..24ee71e4ca6 100644 --- a/libgo/go/io/multi.go +++ b/libgo/go/io/multi.go @@ -69,12 +69,12 @@ func (t *multiWriter) Write(p []byte) (n int, err error) { return len(p), nil } -var _ stringWriter = (*multiWriter)(nil) +var _ StringWriter = (*multiWriter)(nil) func (t *multiWriter) WriteString(s string) (n int, err error) { var p []byte // lazily initialized if/when needed for _, w := range t.writers { - if sw, ok := w.(stringWriter); ok { + if sw, ok := w.(StringWriter); ok { n, err = sw.WriteString(s) } else { if p == nil { diff --git a/libgo/go/log/log.go b/libgo/go/log/log.go index 2b7c57fdfe5..527f853438f 100644 --- a/libgo/go/log/log.go +++ b/libgo/go/log/log.go @@ -254,6 +254,13 @@ func (l *Logger) SetPrefix(prefix string) { l.prefix = prefix } +// Writer returns the output destination for the logger. +func (l *Logger) Writer() io.Writer { + l.mu.Lock() + defer l.mu.Unlock() + return l.out +} + // SetOutput sets the output destination for the standard logger. func SetOutput(w io.Writer) { std.mu.Lock() diff --git a/libgo/go/math/all_test.go b/libgo/go/math/all_test.go index 00f2058ea68..ed429417809 100644 --- a/libgo/go/math/all_test.go +++ b/libgo/go/math/all_test.go @@ -175,6 +175,7 @@ var cosLarge = []float64{ -2.51772931436786954751e-01, -7.3924135157173099849e-01, } + var cosh = []float64{ 7.2668796942212842775517446e+01, 1.1479413465659254502011135e+03, @@ -1527,6 +1528,7 @@ var vflog1pSC = []float64{ 0, Inf(1), NaN(), + 4503599627370496.5, // Issue #29488 } var log1pSC = []float64{ NaN(), @@ -1536,6 +1538,7 @@ var log1pSC = []float64{ 0, Inf(1), NaN(), + 36.04365338911715, // Issue #29488 } var vfmodfSC = []float64{ @@ -3026,6 +3029,41 @@ func TestLargeTan(t *testing.T) { } } +// Check that trigReduce matches the standard reduction results for input values +// below reduceThreshold. +func TestTrigReduce(t *testing.T) { + inputs := make([]float64, len(vf)) + // all of the standard inputs + copy(inputs, vf) + // all of the large inputs + large := float64(100000 * Pi) + for _, v := range vf { + inputs = append(inputs, v+large) + } + // Also test some special inputs, Pi and right below the reduceThreshold + inputs = append(inputs, Pi, Nextafter(ReduceThreshold, 0)) + for _, x := range inputs { + // reduce the value to compare + j, z := TrigReduce(x) + xred := float64(j)*(Pi/4) + z + + if f, fred := Sin(x), Sin(xred); !close(f, fred) { + t.Errorf("Sin(trigReduce(%g)) != Sin(%g), got %g, want %g", x, x, fred, f) + } + if f, fred := Cos(x), Cos(xred); !close(f, fred) { + t.Errorf("Cos(trigReduce(%g)) != Cos(%g), got %g, want %g", x, x, fred, f) + } + if f, fred := Tan(x), Tan(xred); !close(f, fred) { + t.Errorf(" Tan(trigReduce(%g)) != Tan(%g), got %g, want %g", x, x, fred, f) + } + f, g := Sincos(x) + fred, gred := Sincos(xred) + if !close(f, fred) || !close(g, gred) { + t.Errorf(" Sincos(trigReduce(%g)) != Sincos(%g), got %g, %g, want %g, %g", x, x, fred, gred, f, g) + } + } +} + // Check that math constants are accepted by compiler // and have right value (assumes strconv.ParseFloat works). // https://golang.org/issue/201 @@ -3635,3 +3673,41 @@ func BenchmarkYn(b *testing.B) { } GlobalF = x } + +func BenchmarkFloat64bits(b *testing.B) { + y := uint64(0) + for i := 0; i < b.N; i++ { + y = Float64bits(roundNeg) + } + GlobalI = int(y) +} + +var roundUint64 = uint64(5) + +func BenchmarkFloat64frombits(b *testing.B) { + x := 0.0 + for i := 0; i < b.N; i++ { + x = Float64frombits(roundUint64) + } + GlobalF = x +} + +var roundFloat32 = float32(-2.5) + +func BenchmarkFloat32bits(b *testing.B) { + y := uint32(0) + for i := 0; i < b.N; i++ { + y = Float32bits(roundFloat32) + } + GlobalI = int(y) +} + +var roundUint32 = uint32(5) + +func BenchmarkFloat32frombits(b *testing.B) { + x := float32(0.0) + for i := 0; i < b.N; i++ { + x = Float32frombits(roundUint32) + } + GlobalF = float64(x) +} diff --git a/libgo/go/math/big/arith.go b/libgo/go/math/big/arith.go index ad352403a7c..f9db9118eb2 100644 --- a/libgo/go/math/big/arith.go +++ b/libgo/go/math/big/arith.go @@ -82,7 +82,7 @@ func nlz(x Word) uint { return uint(bits.LeadingZeros(uint(x))) } -// q = (u1<<_W + u0 - r)/y +// q = (u1<<_W + u0 - r)/v // Adapted from Warren, Hacker's Delight, p. 152. func divWW_g(u1, u0, v Word) (q, r Word) { if u1 >= v { diff --git a/libgo/go/math/big/float.go b/libgo/go/math/big/float.go index 55b93c89150..b3c32952014 100644 --- a/libgo/go/math/big/float.go +++ b/libgo/go/math/big/float.go @@ -43,7 +43,7 @@ const debugFloat = false // enable for debugging // precision of the argument with the largest precision value before any // rounding takes place, and the rounding mode remains unchanged. Thus, // uninitialized Floats provided as result arguments will have their -// precision set to a reasonable value determined by the operands and +// precision set to a reasonable value determined by the operands, and // their mode is the zero value for RoundingMode (ToNearestEven). // // By setting the desired precision to 24 or 53 and using matching rounding @@ -56,6 +56,12 @@ const debugFloat = false // enable for debugging // The zero (uninitialized) value for a Float is ready to use and represents // the number +0.0 exactly, with precision 0 and rounding mode ToNearestEven. // +// Operations always take pointer arguments (*Float) rather +// than Float values, and each unique Float value requires +// its own unique *Float pointer. To "copy" a Float value, +// an existing (or newly allocated) Float must be set to +// a new value using the Float.Set method; shallow copies +// of Floats are not supported and may lead to errors. type Float struct { prec uint32 mode RoundingMode @@ -293,7 +299,7 @@ func (z *Float) setExpAndRound(exp int64, sbit uint) { z.round(sbit) } -// SetMantExp sets z to mant × 2**exp and and returns z. +// SetMantExp sets z to mant × 2**exp and returns z. // The result z has the same precision and rounding mode // as mant. SetMantExp is an inverse of MantExp but does // not require 0.5 <= |mant| < 1.0. Specifically: @@ -321,7 +327,7 @@ func (z *Float) SetMantExp(mant *Float, exp int) *Float { return z } -// Signbit returns true if x is negative or negative zero. +// Signbit reports whether x is negative or negative zero. func (x *Float) Signbit() bool { return x.neg } diff --git a/libgo/go/math/big/int.go b/libgo/go/math/big/int.go index 47a288ab44d..dab9a5cc0f7 100644 --- a/libgo/go/math/big/int.go +++ b/libgo/go/math/big/int.go @@ -15,6 +15,13 @@ import ( // An Int represents a signed multi-precision integer. // The zero value for an Int represents the value 0. +// +// Operations always take pointer arguments (*Int) rather +// than Int values, and each unique Int value requires +// its own unique *Int pointer. To "copy" an Int value, +// an existing (or newly allocated) Int must be set to +// a new value using the Int.Set method; shallow copies +// of Ints are not supported and may lead to errors. type Int struct { neg bool // sign abs nat // absolute value of the integer diff --git a/libgo/go/math/big/int_test.go b/libgo/go/math/big/int_test.go index 9930ed016af..7ef2b3907f7 100644 --- a/libgo/go/math/big/int_test.go +++ b/libgo/go/math/big/int_test.go @@ -1727,3 +1727,29 @@ func BenchmarkIntSqr(b *testing.B) { }) } } + +func benchmarkDiv(b *testing.B, aSize, bSize int) { + var r = rand.New(rand.NewSource(1234)) + aa := randInt(r, uint(aSize)) + bb := randInt(r, uint(bSize)) + if aa.Cmp(bb) < 0 { + aa, bb = bb, aa + } + x := new(Int) + y := new(Int) + + b.ResetTimer() + for i := 0; i < b.N; i++ { + x.DivMod(aa, bb, y) + } +} + +func BenchmarkDiv(b *testing.B) { + min, max, step := 10, 100000, 10 + for i := min; i <= max; i *= step { + j := 2 * i + b.Run(fmt.Sprintf("%d/%d", j, i), func(b *testing.B) { + benchmarkDiv(b, j, i) + }) + } +} diff --git a/libgo/go/math/big/nat.go b/libgo/go/math/big/nat.go index a6f79edccc4..1e4a3b09cf7 100644 --- a/libgo/go/math/big/nat.go +++ b/libgo/go/math/big/nat.go @@ -58,6 +58,10 @@ func (z nat) make(n int) nat { if n <= cap(z) { return z[:n] // reuse z } + if n == 1 { + // Most nats start small and stay that way; don't over-allocate. + return make(nat, 1) + } // Choosing a good value for e has significant performance impact // because it increases the chance that a value can be reused. const e = 4 // extra capacity @@ -680,43 +684,36 @@ func putNat(x *nat) { var natPool sync.Pool -// q = (uIn-r)/v, with 0 <= r < y +// q = (uIn-r)/vIn, with 0 <= r < y // Uses z as storage for q, and u as storage for r if possible. // See Knuth, Volume 2, section 4.3.1, Algorithm D. // Preconditions: -// len(v) >= 2 -// len(uIn) >= len(v) -func (z nat) divLarge(u, uIn, v nat) (q, r nat) { - n := len(v) +// len(vIn) >= 2 +// len(uIn) >= len(vIn) +// u must not alias z +func (z nat) divLarge(u, uIn, vIn nat) (q, r nat) { + n := len(vIn) m := len(uIn) - n - // determine if z can be reused - // TODO(gri) should find a better solution - this if statement - // is very costly (see e.g. time pidigits -s -n 10000) - if alias(z, u) || alias(z, uIn) || alias(z, v) { - z = nil // z is an alias for u or uIn or v - cannot reuse + // D1. + shift := nlz(vIn[n-1]) + // do not modify vIn, it may be used by another goroutine simultaneously + vp := getNat(n) + v := *vp + shlVU(v, vIn, shift) + + // u may safely alias uIn or vIn, the value of uIn is used to set u and vIn was already used + u = u.make(len(uIn) + 1) + u[len(uIn)] = shlVU(u[0:len(uIn)], uIn, shift) + + // z may safely alias uIn or vIn, both values were used already + if alias(z, u) { + z = nil // z is an alias for u - cannot reuse } q = z.make(m + 1) qhatvp := getNat(n + 1) qhatv := *qhatvp - if alias(u, uIn) || alias(u, v) { - u = nil // u is an alias for uIn or v - cannot reuse - } - u = u.make(len(uIn) + 1) - u.clear() // TODO(gri) no need to clear if we allocated a new u - - // D1. - var v1p *nat - shift := nlz(v[n-1]) - if shift > 0 { - // do not modify v, it may be used by another goroutine simultaneously - v1p = getNat(n) - v1 := *v1p - shlVU(v1, v, shift) - v = v1 - } - u[len(uIn)] = shlVU(u[0:len(uIn)], uIn, shift) // D2. vn1 := v[n-1] @@ -756,9 +753,8 @@ func (z nat) divLarge(u, uIn, v nat) (q, r nat) { q[j] = qhat } - if v1p != nil { - putNat(v1p) - } + + putNat(vp) putNat(qhatvp) q = q.norm() diff --git a/libgo/go/math/big/prime.go b/libgo/go/math/big/prime.go index 4c2c152f65e..d9a5f1ec968 100644 --- a/libgo/go/math/big/prime.go +++ b/libgo/go/math/big/prime.go @@ -51,7 +51,7 @@ func (x *Int) ProbablyPrime(n int) bool { } if w&1 == 0 { - return false // n is even + return false // x is even } const primesA = 3 * 5 * 7 * 11 * 13 * 17 * 19 * 23 * 37 diff --git a/libgo/go/math/big/rat.go b/libgo/go/math/big/rat.go index 46d58fcf365..5d0800ca936 100644 --- a/libgo/go/math/big/rat.go +++ b/libgo/go/math/big/rat.go @@ -13,6 +13,13 @@ import ( // A Rat represents a quotient a/b of arbitrary precision. // The zero value for a Rat represents the value 0. +// +// Operations always take pointer arguments (*Rat) rather +// than Rat values, and each unique Rat value requires +// its own unique *Rat pointer. To "copy" a Rat value, +// an existing (or newly allocated) Rat must be set to +// a new value using the Rat.Set method; shallow copies +// of Rats are not supported and may lead to errors. type Rat struct { // To make zero values for Rat work w/o initialization, // a zero value of b (len(b) == 0) acts like b == 1. diff --git a/libgo/go/math/big/sqrt.go b/libgo/go/math/big/sqrt.go index b989649dcde..53403aa41d7 100644 --- a/libgo/go/math/big/sqrt.go +++ b/libgo/go/math/big/sqrt.go @@ -7,8 +7,6 @@ package big import "math" var ( - half = NewFloat(0.5) - two = NewFloat(2.0) three = NewFloat(3.0) ) @@ -57,9 +55,9 @@ func (z *Float) Sqrt(x *Float) *Float { case 0: // nothing to do case 1: - z.Mul(two, z) + z.exp++ case -1: - z.Mul(half, z) + z.exp-- } // 0.25 <= z < 2.0 @@ -96,7 +94,7 @@ func (z *Float) sqrtDirect(x *Float) { u.prec = t.prec u.Mul(t, t) // u = t² u.Add(u, x) // = t² + x - u.Mul(half, u) // = ½(t² + x) + u.exp-- // = ½(t² + x) return t.Quo(u, t) // = ½(t² + x)/t } @@ -133,11 +131,13 @@ func (z *Float) sqrtInverse(x *Float) { ng := func(t *Float) *Float { u.prec = t.prec v.prec = t.prec - u.Mul(t, t) // u = t² - u.Mul(x, u) // = xt² - v.Sub(three, u) // v = 3 - xt² - u.Mul(t, v) // u = t(3 - xt²) - return t.Mul(half, u) // = ½t(3 - xt²) + u.Mul(t, t) // u = t² + u.Mul(x, u) // = xt² + v.Sub(three, u) // v = 3 - xt² + u.Mul(t, v) // u = t(3 - xt²) + u.exp-- // = ½t(3 - xt²) + return t.Set(u) + } xf, _ := x.Float64() diff --git a/libgo/go/math/bits/bits.go b/libgo/go/math/bits/bits.go index 989baacc13f..306fa76e5e1 100644 --- a/libgo/go/math/bits/bits.go +++ b/libgo/go/math/bits/bits.go @@ -8,6 +8,8 @@ // functions for the predeclared unsigned integer types. package bits +import _ "unsafe" // for go:linkname + const uintSize = 32 << (^uint(0) >> 32 & 1) // 32 or 64 // UintSize is the size of a uint in bits. @@ -63,7 +65,7 @@ func TrailingZeros8(x uint8) int { } // TrailingZeros16 returns the number of trailing zero bits in x; the result is 16 for x == 0. -func TrailingZeros16(x uint16) (n int) { +func TrailingZeros16(x uint16) int { if x == 0 { return 16 } @@ -328,3 +330,206 @@ func Len64(x uint64) (n int) { } return n + int(len8tab[x]) } + +// --- Add with carry --- + +// Add returns the sum with carry of x, y and carry: sum = x + y + carry. +// The carry input must be 0 or 1; otherwise the behavior is undefined. +// The carryOut output is guaranteed to be 0 or 1. +func Add(x, y, carry uint) (sum, carryOut uint) { + yc := y + carry + sum = x + yc + if sum < x || yc < y { + carryOut = 1 + } + return +} + +// Add32 returns the sum with carry of x, y and carry: sum = x + y + carry. +// The carry input must be 0 or 1; otherwise the behavior is undefined. +// The carryOut output is guaranteed to be 0 or 1. +func Add32(x, y, carry uint32) (sum, carryOut uint32) { + yc := y + carry + sum = x + yc + if sum < x || yc < y { + carryOut = 1 + } + return +} + +// Add64 returns the sum with carry of x, y and carry: sum = x + y + carry. +// The carry input must be 0 or 1; otherwise the behavior is undefined. +// The carryOut output is guaranteed to be 0 or 1. +func Add64(x, y, carry uint64) (sum, carryOut uint64) { + yc := y + carry + sum = x + yc + if sum < x || yc < y { + carryOut = 1 + } + return +} + +// --- Subtract with borrow --- + +// Sub returns the difference of x, y and borrow: diff = x - y - borrow. +// The borrow input must be 0 or 1; otherwise the behavior is undefined. +// The borrowOut output is guaranteed to be 0 or 1. +func Sub(x, y, borrow uint) (diff, borrowOut uint) { + yb := y + borrow + diff = x - yb + if diff > x || yb < y { + borrowOut = 1 + } + return +} + +// Sub32 returns the difference of x, y and borrow, diff = x - y - borrow. +// The borrow input must be 0 or 1; otherwise the behavior is undefined. +// The borrowOut output is guaranteed to be 0 or 1. +func Sub32(x, y, borrow uint32) (diff, borrowOut uint32) { + yb := y + borrow + diff = x - yb + if diff > x || yb < y { + borrowOut = 1 + } + return +} + +// Sub64 returns the difference of x, y and borrow: diff = x - y - borrow. +// The borrow input must be 0 or 1; otherwise the behavior is undefined. +// The borrowOut output is guaranteed to be 0 or 1. +func Sub64(x, y, borrow uint64) (diff, borrowOut uint64) { + yb := y + borrow + diff = x - yb + if diff > x || yb < y { + borrowOut = 1 + } + return +} + +// --- Full-width multiply --- + +// Mul returns the full-width product of x and y: (hi, lo) = x * y +// with the product bits' upper half returned in hi and the lower +// half returned in lo. +func Mul(x, y uint) (hi, lo uint) { + if UintSize == 32 { + h, l := Mul32(uint32(x), uint32(y)) + return uint(h), uint(l) + } + h, l := Mul64(uint64(x), uint64(y)) + return uint(h), uint(l) +} + +// Mul32 returns the 64-bit product of x and y: (hi, lo) = x * y +// with the product bits' upper half returned in hi and the lower +// half returned in lo. +func Mul32(x, y uint32) (hi, lo uint32) { + tmp := uint64(x) * uint64(y) + hi, lo = uint32(tmp>>32), uint32(tmp) + return +} + +// Mul64 returns the 128-bit product of x and y: (hi, lo) = x * y +// with the product bits' upper half returned in hi and the lower +// half returned in lo. +func Mul64(x, y uint64) (hi, lo uint64) { + const mask32 = 1<<32 - 1 + x0 := x & mask32 + x1 := x >> 32 + y0 := y & mask32 + y1 := y >> 32 + w0 := x0 * y0 + t := x1*y0 + w0>>32 + w1 := t & mask32 + w2 := t >> 32 + w1 += x0 * y1 + hi = x1*y1 + w2 + w1>>32 + lo = x * y + return +} + +// --- Full-width divide --- + +// Div returns the quotient and remainder of (hi, lo) divided by y: +// quo = (hi, lo)/y, rem = (hi, lo)%y with the dividend bits' upper +// half in parameter hi and the lower half in parameter lo. +// Div panics for y == 0 (division by zero) or y <= hi (quotient overflow). +func Div(hi, lo, y uint) (quo, rem uint) { + if UintSize == 32 { + q, r := Div32(uint32(hi), uint32(lo), uint32(y)) + return uint(q), uint(r) + } + q, r := Div64(uint64(hi), uint64(lo), uint64(y)) + return uint(q), uint(r) +} + +// Div32 returns the quotient and remainder of (hi, lo) divided by y: +// quo = (hi, lo)/y, rem = (hi, lo)%y with the dividend bits' upper +// half in parameter hi and the lower half in parameter lo. +// Div32 panics for y == 0 (division by zero) or y <= hi (quotient overflow). +func Div32(hi, lo, y uint32) (quo, rem uint32) { + if y != 0 && y <= hi { + panic(getOverflowError()) + } + z := uint64(hi)<<32 | uint64(lo) + quo, rem = uint32(z/uint64(y)), uint32(z%uint64(y)) + return +} + +// Div64 returns the quotient and remainder of (hi, lo) divided by y: +// quo = (hi, lo)/y, rem = (hi, lo)%y with the dividend bits' upper +// half in parameter hi and the lower half in parameter lo. +// Div64 panics for y == 0 (division by zero) or y <= hi (quotient overflow). +func Div64(hi, lo, y uint64) (quo, rem uint64) { + const ( + two32 = 1 << 32 + mask32 = two32 - 1 + ) + if y == 0 { + panic(getDivideError()) + } + if y <= hi { + panic(getOverflowError()) + } + + s := uint(LeadingZeros64(y)) + y <<= s + + yn1 := y >> 32 + yn0 := y & mask32 + un32 := hi<>(64-s) + un10 := lo << s + un1 := un10 >> 32 + un0 := un10 & mask32 + q1 := un32 / yn1 + rhat := un32 - q1*yn1 + + for q1 >= two32 || q1*yn0 > two32*rhat+un1 { + q1-- + rhat += yn1 + if rhat >= two32 { + break + } + } + + un21 := un32*two32 + un1 - q1*y + q0 := un21 / yn1 + rhat = un21 - q0*yn1 + + for q0 >= two32 || q0*yn0 > two32*rhat+un0 { + q0-- + rhat += yn1 + if rhat >= two32 { + break + } + } + + return q1*two32 + q0, (un21*two32 + un0 - q0*y) >> s +} + +//go:linkname getOverflowError runtime.getOverflowError +func getOverflowError() error + +//go:linkname getDivideError runtime.getDivideError +func getDivideError() error diff --git a/libgo/go/math/bits/bits_test.go b/libgo/go/math/bits/bits_test.go index 5c34f6dbf7f..1ec5107ae12 100644 --- a/libgo/go/math/bits/bits_test.go +++ b/libgo/go/math/bits/bits_test.go @@ -6,6 +6,7 @@ package bits_test import ( . "math/bits" + "runtime" "testing" "unsafe" ) @@ -705,6 +706,385 @@ func TestLen(t *testing.T) { } } +const ( + _M = 1<> 52) - 1023) + // correction term if k > 0 { c = 1.0 - (u - x) } else { - c = x - (u - 1.0) // correction term - c /= u + c = x - (u - 1.0) } + c /= u } else { u = x iu = Float64bits(u) diff --git a/libgo/go/math/mod.go b/libgo/go/math/mod.go index 0b208f4eda3..436788ff453 100644 --- a/libgo/go/math/mod.go +++ b/libgo/go/math/mod.go @@ -30,16 +30,12 @@ func mod(x, y float64) float64 { if y == 0 || IsInf(x, 0) || IsNaN(x) || IsNaN(y) { return NaN() } - if y < 0 { - y = -y - } + y = Abs(y) yfr, yexp := Frexp(y) - sign := false r := x if x < 0 { r = -x - sign = true } for r >= y { @@ -49,7 +45,7 @@ func mod(x, y float64) float64 { } r = r - Ldexp(y, rexp-yexp) } - if sign { + if x < 0 { r = -r } return r diff --git a/libgo/go/math/pow.go b/libgo/go/math/pow.go index 314ff90d3c4..b8121793bf5 100644 --- a/libgo/go/math/pow.go +++ b/libgo/go/math/pow.go @@ -88,13 +88,7 @@ func pow(x, y float64) float64 { return 1 / Sqrt(x) } - absy := y - flip := false - if absy < 0 { - absy = -absy - flip = true - } - yi, yf := Modf(absy) + yi, yf := Modf(Abs(y)) if yf != 0 && x < 0 { return NaN() } @@ -152,9 +146,9 @@ func pow(x, y float64) float64 { } // ans = a1*2**ae - // if flip { ans = 1 / ans } + // if y < 0 { ans = 1 / ans } // but in the opposite order - if flip { + if y < 0 { a1 = 1 / a1 ae = -ae } diff --git a/libgo/go/math/signbit.go b/libgo/go/math/signbit.go index 670cc1a6679..f6e61d660e2 100644 --- a/libgo/go/math/signbit.go +++ b/libgo/go/math/signbit.go @@ -4,7 +4,7 @@ package math -// Signbit returns true if x is negative or negative zero. +// Signbit reports whether x is negative or negative zero. func Signbit(x float64) bool { return Float64bits(x)&(1<<63) != 0 } diff --git a/libgo/go/math/sin.go b/libgo/go/math/sin.go index e3166e24afa..871e8c6185f 100644 --- a/libgo/go/math/sin.go +++ b/libgo/go/math/sin.go @@ -124,10 +124,9 @@ func Cos(x float64) float64 { func cos(x float64) float64 { const ( - PI4A = 7.85398125648498535156E-1 // 0x3fe921fb40000000, Pi/4 split into three parts - PI4B = 3.77489470793079817668E-8 // 0x3e64442d00000000, - PI4C = 2.69515142907905952645E-15 // 0x3ce8469898cc5170, - M4PI = 1.273239544735162542821171882678754627704620361328125 // 4/pi + PI4A = 7.85398125648498535156E-1 // 0x3fe921fb40000000, Pi/4 split into three parts + PI4B = 3.77489470793079817668E-8 // 0x3e64442d00000000, + PI4C = 2.69515142907905952645E-15 // 0x3ce8469898cc5170, ) // special cases switch { @@ -139,15 +138,23 @@ func cos(x float64) float64 { sign := false x = Abs(x) - j := int64(x * M4PI) // integer part of x/(Pi/4), as integer for tests on the phase angle - y := float64(j) // integer part of x/(Pi/4), as float - - // map zeros to origin - if j&1 == 1 { - j++ - y++ + var j uint64 + var y, z float64 + if x >= reduceThreshold { + j, z = trigReduce(x) + } else { + j = uint64(x * (4 / Pi)) // integer part of x/(Pi/4), as integer for tests on the phase angle + y = float64(j) // integer part of x/(Pi/4), as float + + // map zeros to origin + if j&1 == 1 { + j++ + y++ + } + j &= 7 // octant modulo 2Pi radians (360 degrees) + z = ((x - y*PI4A) - y*PI4B) - y*PI4C // Extended precision modular arithmetic } - j &= 7 // octant modulo 2Pi radians (360 degrees) + if j > 3 { j -= 4 sign = !sign @@ -156,7 +163,6 @@ func cos(x float64) float64 { sign = !sign } - z := ((x - y*PI4A) - y*PI4B) - y*PI4C // Extended precision modular arithmetic zz := z * z if j == 1 || j == 2 { y = z + z*zz*((((((_sin[0]*zz)+_sin[1])*zz+_sin[2])*zz+_sin[3])*zz+_sin[4])*zz+_sin[5]) @@ -185,10 +191,9 @@ func Sin(x float64) float64 { func sin(x float64) float64 { const ( - PI4A = 7.85398125648498535156E-1 // 0x3fe921fb40000000, Pi/4 split into three parts - PI4B = 3.77489470793079817668E-8 // 0x3e64442d00000000, - PI4C = 2.69515142907905952645E-15 // 0x3ce8469898cc5170, - M4PI = 1.273239544735162542821171882678754627704620361328125 // 4/pi + PI4A = 7.85398125648498535156E-1 // 0x3fe921fb40000000, Pi/4 split into three parts + PI4B = 3.77489470793079817668E-8 // 0x3e64442d00000000, + PI4C = 2.69515142907905952645E-15 // 0x3ce8469898cc5170, ) // special cases switch { @@ -205,22 +210,27 @@ func sin(x float64) float64 { sign = true } - j := int64(x * M4PI) // integer part of x/(Pi/4), as integer for tests on the phase angle - y := float64(j) // integer part of x/(Pi/4), as float - - // map zeros to origin - if j&1 == 1 { - j++ - y++ + var j uint64 + var y, z float64 + if x >= reduceThreshold { + j, z = trigReduce(x) + } else { + j = uint64(x * (4 / Pi)) // integer part of x/(Pi/4), as integer for tests on the phase angle + y = float64(j) // integer part of x/(Pi/4), as float + + // map zeros to origin + if j&1 == 1 { + j++ + y++ + } + j &= 7 // octant modulo 2Pi radians (360 degrees) + z = ((x - y*PI4A) - y*PI4B) - y*PI4C // Extended precision modular arithmetic } - j &= 7 // octant modulo 2Pi radians (360 degrees) // reflect in x axis if j > 3 { sign = !sign j -= 4 } - - z := ((x - y*PI4A) - y*PI4B) - y*PI4C // Extended precision modular arithmetic zz := z * z if j == 1 || j == 2 { y = 1.0 - 0.5*zz + zz*zz*((((((_cos[0]*zz)+_cos[1])*zz+_cos[2])*zz+_cos[3])*zz+_cos[4])*zz+_cos[5]) diff --git a/libgo/go/math/sincos.go b/libgo/go/math/sincos.go index 65f3790918e..c002db6b3cd 100644 --- a/libgo/go/math/sincos.go +++ b/libgo/go/math/sincos.go @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// -build !386 - package math // Coefficients _sin[] and _cos[] are found in pkg/math/sin.go. @@ -16,10 +14,9 @@ package math // Sincos(NaN) = NaN, NaN func Sincos(x float64) (sin, cos float64) { const ( - PI4A = 7.85398125648498535156E-1 // 0x3fe921fb40000000, Pi/4 split into three parts - PI4B = 3.77489470793079817668E-8 // 0x3e64442d00000000, - PI4C = 2.69515142907905952645E-15 // 0x3ce8469898cc5170, - M4PI = 1.273239544735162542821171882678754627704620361328125 // 4/pi + PI4A = 7.85398125648498535156E-1 // 0x3fe921fb40000000, Pi/4 split into three parts + PI4B = 3.77489470793079817668E-8 // 0x3e64442d00000000, + PI4C = 2.69515142907905952645E-15 // 0x3ce8469898cc5170, ) // special cases switch { @@ -36,14 +33,21 @@ func Sincos(x float64) (sin, cos float64) { sinSign = true } - j := int64(x * M4PI) // integer part of x/(Pi/4), as integer for tests on the phase angle - y := float64(j) // integer part of x/(Pi/4), as float + var j uint64 + var y, z float64 + if x >= reduceThreshold { + j, z = trigReduce(x) + } else { + j = uint64(x * (4 / Pi)) // integer part of x/(Pi/4), as integer for tests on the phase angle + y = float64(j) // integer part of x/(Pi/4), as float - if j&1 == 1 { // map zeros to origin - j++ - y++ + if j&1 == 1 { // map zeros to origin + j++ + y++ + } + j &= 7 // octant modulo 2Pi radians (360 degrees) + z = ((x - y*PI4A) - y*PI4B) - y*PI4C // Extended precision modular arithmetic } - j &= 7 // octant modulo 2Pi radians (360 degrees) if j > 3 { // reflect in x axis j -= 4 sinSign, cosSign = !sinSign, !cosSign @@ -52,7 +56,6 @@ func Sincos(x float64) (sin, cos float64) { cosSign = !cosSign } - z := ((x - y*PI4A) - y*PI4B) - y*PI4C // Extended precision modular arithmetic zz := z * z cos = 1.0 - 0.5*zz + zz*zz*((((((_cos[0]*zz)+_cos[1])*zz+_cos[2])*zz+_cos[3])*zz+_cos[4])*zz+_cos[5]) sin = z + z*zz*((((((_sin[0]*zz)+_sin[1])*zz+_sin[2])*zz+_sin[3])*zz+_sin[4])*zz+_sin[5]) diff --git a/libgo/go/math/sincos_386.go b/libgo/go/math/sincos_386.go deleted file mode 100644 index d5c24573f76..00000000000 --- a/libgo/go/math/sincos_386.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -package math - -// Sincos returns Sin(x), Cos(x). -// -// Special cases are: -// Sincos(±0) = ±0, 1 -// Sincos(±Inf) = NaN, NaN -// Sincos(NaN) = NaN, NaN -func Sincos(x float64) (sin, cos float64) diff --git a/libgo/go/math/sinh.go b/libgo/go/math/sinh.go index 9dff71eacd5..993424d5aba 100644 --- a/libgo/go/math/sinh.go +++ b/libgo/go/math/sinh.go @@ -41,7 +41,7 @@ func Sinh(x float64) float64 { } var temp float64 - switch true { + switch { case x > 21: temp = Exp(x) * 0.5 diff --git a/libgo/go/math/tan.go b/libgo/go/math/tan.go index f5230d3f1f9..929a0a9fa44 100644 --- a/libgo/go/math/tan.go +++ b/libgo/go/math/tan.go @@ -89,10 +89,9 @@ func Tan(x float64) float64 { func tan(x float64) float64 { const ( - PI4A = 7.85398125648498535156E-1 // 0x3fe921fb40000000, Pi/4 split into three parts - PI4B = 3.77489470793079817668E-8 // 0x3e64442d00000000, - PI4C = 2.69515142907905952645E-15 // 0x3ce8469898cc5170, - M4PI = 1.273239544735162542821171882678754627704620361328125 // 4/pi + PI4A = 7.85398125648498535156E-1 // 0x3fe921fb40000000, Pi/4 split into three parts + PI4B = 3.77489470793079817668E-8 // 0x3e64442d00000000, + PI4C = 2.69515142907905952645E-15 // 0x3ce8469898cc5170, ) // special cases switch { @@ -108,17 +107,22 @@ func tan(x float64) float64 { x = -x sign = true } + var j uint64 + var y, z float64 + if x >= reduceThreshold { + j, z = trigReduce(x) + } else { + j = uint64(x * (4 / Pi)) // integer part of x/(Pi/4), as integer for tests on the phase angle + y = float64(j) // integer part of x/(Pi/4), as float - j := int64(x * M4PI) // integer part of x/(Pi/4), as integer for tests on the phase angle - y := float64(j) // integer part of x/(Pi/4), as float + /* map zeros and singularities to origin */ + if j&1 == 1 { + j++ + y++ + } - /* map zeros and singularities to origin */ - if j&1 == 1 { - j++ - y++ + z = ((x - y*PI4A) - y*PI4B) - y*PI4C } - - z := ((x - y*PI4A) - y*PI4B) - y*PI4C zz := z * z if zz > 1e-14 { diff --git a/libgo/go/math/trig_reduce.go b/libgo/go/math/trig_reduce.go new file mode 100644 index 00000000000..6f8eaba9b91 --- /dev/null +++ b/libgo/go/math/trig_reduce.go @@ -0,0 +1,94 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package math + +import ( + "math/bits" +) + +// reduceThreshold is the maximum value where the reduction using Pi/4 +// in 3 float64 parts still gives accurate results. Above this +// threshold Payne-Hanek range reduction must be used. +const reduceThreshold = (1 << 52) / (4 / Pi) + +// trigReduce implements Payne-Hanek range reduction by Pi/4 +// for x > 0. It returns the integer part mod 8 (j) and +// the fractional part (z) of x / (Pi/4). +// The implementation is based on: +// "ARGUMENT REDUCTION FOR HUGE ARGUMENTS: Good to the Last Bit" +// K. C. Ng et al, March 24, 1992 +// The simulated multi-precision calculation of x*B uses 64-bit integer arithmetic. +func trigReduce(x float64) (j uint64, z float64) { + const PI4 = Pi / 4 + if x < PI4 { + return 0, x + } + // Extract out the integer and exponent such that, + // x = ix * 2 ** exp. + ix := Float64bits(x) + exp := int(ix>>shift&mask) - bias - shift + ix &^= mask << shift + ix |= 1 << shift + // Use the exponent to extract the 3 appropriate uint64 digits from mPi4, + // B ~ (z0, z1, z2), such that the product leading digit has the exponent -61. + // Note, exp >= -53 since x >= PI4 and exp < 971 for maximum float64. + digit, bitshift := uint(exp+61)/64, uint(exp+61)%64 + z0 := (mPi4[digit] << bitshift) | (mPi4[digit+1] >> (64 - bitshift)) + z1 := (mPi4[digit+1] << bitshift) | (mPi4[digit+2] >> (64 - bitshift)) + z2 := (mPi4[digit+2] << bitshift) | (mPi4[digit+3] >> (64 - bitshift)) + // Multiply mantissa by the digits and extract the upper two digits (hi, lo). + z2hi, _ := bits.Mul64(z2, ix) + z1hi, z1lo := bits.Mul64(z1, ix) + z0lo := z0 * ix + lo, c := bits.Add64(z1lo, z2hi, 0) + hi, _ := bits.Add64(z0lo, z1hi, c) + // The top 3 bits are j. + j = hi >> 61 + // Extract the fraction and find its magnitude. + hi = hi<<3 | lo>>61 + lz := uint(bits.LeadingZeros64(hi)) + e := uint64(bias - (lz + 1)) + // Clear implicit mantissa bit and shift into place. + hi = (hi << (lz + 1)) | (lo >> (64 - (lz + 1))) + hi >>= 64 - shift + // Include the exponent and convert to a float. + hi |= e << shift + z = Float64frombits(hi) + // Map zeros to origin. + if j&1 == 1 { + j++ + j &= 7 + z-- + } + // Multiply the fractional part by pi/4. + return j, z * PI4 +} + +// mPi4 is the binary digits of 4/pi as a uint64 array, +// that is, 4/pi = Sum mPi4[i]*2^(-64*i) +// 19 64-bit digits and the leading one bit give 1217 bits +// of precision to handle the largest possible float64 exponent. +var mPi4 = [...]uint64{ + 0x0000000000000001, + 0x45f306dc9c882a53, + 0xf84eafa3ea69bb81, + 0xb6c52b3278872083, + 0xfca2c757bd778ac3, + 0x6e48dc74849ba5c0, + 0x0c925dd413a32439, + 0xfc3bd63962534e7d, + 0xd1046bea5d768909, + 0xd338e04d68befc82, + 0x7323ac7306a673e9, + 0x3908bf177bf25076, + 0x3ff12fffbc0b301f, + 0xde5e2316b414da3e, + 0xda6cfd9e4f96136e, + 0x9e8c7ecd3cbfd45a, + 0xea4f758fd7cbe2f6, + 0x7a0e73ef14a525d4, + 0xd7f6bf623f1aba10, + 0xac06608df8f6d757, +} diff --git a/libgo/go/math/unsafe.go b/libgo/go/math/unsafe.go index 5ae67420f4d..e59f50ca62e 100644 --- a/libgo/go/math/unsafe.go +++ b/libgo/go/math/unsafe.go @@ -6,16 +6,24 @@ package math import "unsafe" -// Float32bits returns the IEEE 754 binary representation of f. +// Float32bits returns the IEEE 754 binary representation of f, +// with the sign bit of f and the result in the same bit position. +// Float32bits(Float32frombits(x)) == x. func Float32bits(f float32) uint32 { return *(*uint32)(unsafe.Pointer(&f)) } -// Float32frombits returns the floating point number corresponding -// to the IEEE 754 binary representation b. +// Float32frombits returns the floating-point number corresponding +// to the IEEE 754 binary representation b, with the sign bit of b +// and the result in the same bit position. +// Float32frombits(Float32bits(x)) == x. func Float32frombits(b uint32) float32 { return *(*float32)(unsafe.Pointer(&b)) } -// Float64bits returns the IEEE 754 binary representation of f. +// Float64bits returns the IEEE 754 binary representation of f, +// with the sign bit of f and the result in the same bit position, +// and Float64bits(Float64frombits(x)) == x. func Float64bits(f float64) uint64 { return *(*uint64)(unsafe.Pointer(&f)) } -// Float64frombits returns the floating point number corresponding -// the IEEE 754 binary representation b. +// Float64frombits returns the floating-point number corresponding +// to the IEEE 754 binary representation b, with the sign bit of b +// and the result in the same bit position. +// Float64frombits(Float64bits(x)) == x. func Float64frombits(b uint64) float64 { return *(*float64)(unsafe.Pointer(&b)) } diff --git a/libgo/go/mime/mediatype.go b/libgo/go/mime/mediatype.go index ea2bbac1891..05390773a8a 100644 --- a/libgo/go/mime/mediatype.go +++ b/libgo/go/mime/mediatype.go @@ -56,7 +56,8 @@ func FormatMediaType(t string, param map[string]string) string { b.WriteByte('"') offset := 0 - for index, character := range value { + for index := 0; index < len(value); index++ { + character := value[index] if character == '"' || character == '\\' { b.WriteString(value[offset:index]) offset = index @@ -280,7 +281,7 @@ func consumeValue(v string) (value, rest string) { // and intended as a literal backslash. This makes Go servers deal better // with MSIE without affecting the way they handle conforming MIME // generators. - if r == '\\' && i+1 < len(v) && !isTokenChar(rune(v[i+1])) { + if r == '\\' && i+1 < len(v) && isTSpecial(rune(v[i+1])) { buffer.WriteByte(v[i+1]) i++ continue diff --git a/libgo/go/mime/mediatype_test.go b/libgo/go/mime/mediatype_test.go index 88d742f0aab..945a8189e17 100644 --- a/libgo/go/mime/mediatype_test.go +++ b/libgo/go/mime/mediatype_test.go @@ -40,6 +40,8 @@ func TestConsumeValue(t *testing.T) { {`"\\" rest`, "\\", " rest"}, {`"My \" value"end`, "My \" value", "end"}, {`"\" rest`, "", `"\" rest`}, + {`"C:\dev\go\robots.txt"`, `C:\dev\go\robots.txt`, ""}, + {`"C:\新建文件件\中文第二次测试.mp4"`, `C:\新建文件件\中文第二次测试.mp4`, ""}, } for _, test := range tests { value, rest := consumeValue(test[0]) @@ -393,6 +395,7 @@ func TestParseMediaType(t *testing.T) { // Microsoft browers in intranet mode do not think they need to escape \ in file name. {`form-data; name="file"; filename="C:\dev\go\robots.txt"`, "form-data", m("name", "file", "filename", `C:\dev\go\robots.txt`)}, + {`form-data; name="file"; filename="C:\新建文件件\中文第二次测试.mp4"`, "form-data", m("name", "file", "filename", `C:\新建文件件\中文第二次测试.mp4`)}, } for _, test := range tests { mt, params, err := ParseMediaType(test.in) @@ -478,6 +481,8 @@ var formatTests = []formatTest{ {"noslash", map[string]string{"X": "Y"}, "noslash; x=Y"}, // e.g. Content-Disposition values (RFC 2183); issue 11289 {"foo bar/baz", nil, ""}, {"foo/bar baz", nil, ""}, + {"attachment", map[string]string{"filename": "ĄĄŽŽČČŠŠ"}, ""}, + {"attachment", map[string]string{"filename": "ÁÁÊÊÇÇÎÎ"}, ""}, {"foo/BAR", nil, "foo/bar"}, {"foo/BAR", map[string]string{"X": "Y"}, "foo/bar; x=Y"}, {"foo/BAR", map[string]string{"space": "With space"}, `foo/bar; space="With space"`}, diff --git a/libgo/go/mime/multipart/formdata_test.go b/libgo/go/mime/multipart/formdata_test.go index 2d6a830cb66..105a82c4170 100644 --- a/libgo/go/mime/multipart/formdata_test.go +++ b/libgo/go/mime/multipart/formdata_test.go @@ -13,7 +13,7 @@ import ( ) func TestReadForm(t *testing.T) { - b := strings.NewReader(strings.Replace(message, "\n", "\r\n", -1)) + b := strings.NewReader(strings.ReplaceAll(message, "\n", "\r\n")) r := NewReader(b, boundary) f, err := r.ReadForm(25) if err != nil { @@ -39,7 +39,7 @@ func TestReadForm(t *testing.T) { } func TestReadFormWithNamelessFile(t *testing.T) { - b := strings.NewReader(strings.Replace(messageWithFileWithoutName, "\n", "\r\n", -1)) + b := strings.NewReader(strings.ReplaceAll(messageWithFileWithoutName, "\n", "\r\n")) r := NewReader(b, boundary) f, err := r.ReadForm(25) if err != nil { @@ -54,7 +54,7 @@ func TestReadFormWithNamelessFile(t *testing.T) { func TestReadFormWithTextContentType(t *testing.T) { // From https://github.com/golang/go/issues/24041 - b := strings.NewReader(strings.Replace(messageWithTextContentType, "\n", "\r\n", -1)) + b := strings.NewReader(strings.ReplaceAll(messageWithTextContentType, "\n", "\r\n")) r := NewReader(b, boundary) f, err := r.ReadForm(25) if err != nil { @@ -184,7 +184,7 @@ Content-Disposition: form-data; name="largetext" --MyBoundary-- ` - testBody := strings.Replace(message, "\n", "\r\n", -1) + testBody := strings.ReplaceAll(message, "\n", "\r\n") testCases := []struct { name string maxMemory int64 diff --git a/libgo/go/mime/multipart/multipart.go b/libgo/go/mime/multipart/multipart.go index 0993fb7e91d..a222409d3ce 100644 --- a/libgo/go/mime/multipart/multipart.go +++ b/libgo/go/mime/multipart/multipart.go @@ -21,6 +21,7 @@ import ( "mime" "mime/quotedprintable" "net/textproto" + "strings" ) var emptyParams = make(map[string]string) @@ -135,7 +136,7 @@ func newPart(mr *Reader) (*Part, error) { } bp.r = partReader{bp} const cte = "Content-Transfer-Encoding" - if bp.Header.Get(cte) == "quoted-printable" { + if strings.EqualFold(bp.Header.Get(cte), "quoted-printable") { bp.Header.Del(cte) bp.r = quotedprintable.NewReader(bp.r) } diff --git a/libgo/go/mime/multipart/multipart_test.go b/libgo/go/mime/multipart/multipart_test.go index abe1cc8e77c..5a8102b8223 100644 --- a/libgo/go/mime/multipart/multipart_test.go +++ b/libgo/go/mime/multipart/multipart_test.go @@ -105,7 +105,7 @@ never read data useless trailer ` - testBody = strings.Replace(testBody, "\n", sep, -1) + testBody = strings.ReplaceAll(testBody, "\n", sep) return strings.Replace(testBody, "[longline]", longLine, 1) } @@ -151,7 +151,7 @@ func testMultipart(t *testing.T, r io.Reader, onlyNewlines bool) { adjustNewlines := func(s string) string { if onlyNewlines { - return strings.Replace(s, "\r\n", "\n", -1) + return strings.ReplaceAll(s, "\r\n", "\n") } return s } @@ -299,7 +299,7 @@ foo-bar: baz Oh no, premature EOF! ` - body := strings.Replace(testBody, "\n", "\r\n", -1) + body := strings.ReplaceAll(testBody, "\n", "\r\n") bodyReader := strings.NewReader(body) r := NewReader(bodyReader, "MyBoundary") @@ -419,8 +419,16 @@ func TestLineContinuation(t *testing.T) { } func TestQuotedPrintableEncoding(t *testing.T) { + for _, cte := range []string{"quoted-printable", "Quoted-PRINTABLE"} { + t.Run(cte, func(t *testing.T) { + testQuotedPrintableEncoding(t, cte) + }) + } +} + +func testQuotedPrintableEncoding(t *testing.T, cte string) { // From https://golang.org/issue/4411 - body := "--0016e68ee29c5d515f04cedf6733\r\nContent-Type: text/plain; charset=ISO-8859-1\r\nContent-Disposition: form-data; name=text\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\nwords words words words words words words words words words words words wor=\r\nds words words words words words words words words words words words words =\r\nwords words words words words words words words words words words words wor=\r\nds words words words words words words words words words words words words =\r\nwords words words words words words words words words\r\n--0016e68ee29c5d515f04cedf6733\r\nContent-Type: text/plain; charset=ISO-8859-1\r\nContent-Disposition: form-data; name=submit\r\n\r\nSubmit\r\n--0016e68ee29c5d515f04cedf6733--" + body := "--0016e68ee29c5d515f04cedf6733\r\nContent-Type: text/plain; charset=ISO-8859-1\r\nContent-Disposition: form-data; name=text\r\nContent-Transfer-Encoding: " + cte + "\r\n\r\nwords words words words words words words words words words words words wor=\r\nds words words words words words words words words words words words words =\r\nwords words words words words words words words words words words words wor=\r\nds words words words words words words words words words words words words =\r\nwords words words words words words words words words\r\n--0016e68ee29c5d515f04cedf6733\r\nContent-Type: text/plain; charset=ISO-8859-1\r\nContent-Disposition: form-data; name=submit\r\n\r\nSubmit\r\n--0016e68ee29c5d515f04cedf6733--" r := NewReader(strings.NewReader(body), "0016e68ee29c5d515f04cedf6733") part, err := r.NextPart() if err != nil { diff --git a/libgo/go/mime/multipart/writer.go b/libgo/go/mime/multipart/writer.go index 3dd0c8fb136..d1ff151a7d1 100644 --- a/libgo/go/mime/multipart/writer.go +++ b/libgo/go/mime/multipart/writer.go @@ -72,7 +72,13 @@ func (w *Writer) SetBoundary(boundary string) error { // FormDataContentType returns the Content-Type for an HTTP // multipart/form-data with this Writer's Boundary. func (w *Writer) FormDataContentType() string { - return "multipart/form-data; boundary=" + w.boundary + b := w.boundary + // We must quote the boundary if it contains any of the + // tspecials characters defined by RFC 2045, or space. + if strings.ContainsAny(b, `()<>@,;:\"/[]?= `) { + b = `"` + b + `"` + } + return "multipart/form-data; boundary=" + b } func randomBoundary() string { diff --git a/libgo/go/mime/multipart/writer_test.go b/libgo/go/mime/multipart/writer_test.go index 8b1bcd68d87..b89b093fff6 100644 --- a/libgo/go/mime/multipart/writer_test.go +++ b/libgo/go/mime/multipart/writer_test.go @@ -7,6 +7,7 @@ package multipart import ( "bytes" "io/ioutil" + "mime" "net/textproto" "strings" "testing" @@ -94,6 +95,7 @@ func TestWriterSetBoundary(t *testing.T) { {"my-separator", true}, {"with space", true}, {"badspace ", false}, + {"(boundary)", true}, } for i, tt := range tests { var b bytes.Buffer @@ -107,6 +109,17 @@ func TestWriterSetBoundary(t *testing.T) { if got != tt.b { t.Errorf("boundary = %q; want %q", got, tt.b) } + + ct := w.FormDataContentType() + mt, params, err := mime.ParseMediaType(ct) + if err != nil { + t.Errorf("could not parse Content-Type %q: %v", ct, err) + } else if mt != "multipart/form-data" { + t.Errorf("unexpected media type %q; want %q", mt, "multipart/form-data") + } else if b := params["boundary"]; b != tt.b { + t.Errorf("unexpected boundary parameter %q; want %q", b, tt.b) + } + w.Close() wantSub := "\r\n--" + tt.b + "--\r\n" if got := b.String(); !strings.Contains(got, wantSub) { diff --git a/libgo/go/net/cgo_stub.go b/libgo/go/net/cgo_stub.go index 51259722aec..041f8af1296 100644 --- a/libgo/go/net/cgo_stub.go +++ b/libgo/go/net/cgo_stub.go @@ -24,7 +24,7 @@ func cgoLookupPort(ctx context.Context, network, service string) (port int, err return 0, nil, false } -func cgoLookupIP(ctx context.Context, name string) (addrs []IPAddr, err error, completed bool) { +func cgoLookupIP(ctx context.Context, network, name string) (addrs []IPAddr, err error, completed bool) { return nil, nil, false } diff --git a/libgo/go/net/cgo_unix.go b/libgo/go/net/cgo_unix.go index a4be3ba8293..7b0f02b6830 100644 --- a/libgo/go/net/cgo_unix.go +++ b/libgo/go/net/cgo_unix.go @@ -68,7 +68,7 @@ type reverseLookupResult struct { } func cgoLookupHost(ctx context.Context, name string) (hosts []string, err error, completed bool) { - addrs, err, completed := cgoLookupIP(ctx, name) + addrs, err, completed := cgoLookupIP(ctx, "ip", name) for _, addr := range addrs { hosts = append(hosts, addr.String()) } @@ -88,13 +88,11 @@ func cgoLookupPort(ctx context.Context, network, service string) (port int, err default: return 0, &DNSError{Err: "unknown network", Name: network + "/" + service}, true } - if len(network) >= 4 { - switch network[3] { - case '4': - hints.Ai_family = syscall.AF_INET - case '6': - hints.Ai_family = syscall.AF_INET6 - } + switch ipVersion(network) { + case '4': + hints.Ai_family = syscall.AF_INET + case '6': + hints.Ai_family = syscall.AF_INET6 } if ctx.Done() == nil { port, err := cgoLookupServicePort(&hints, network, service) @@ -161,13 +159,20 @@ func cgoPortLookup(result chan<- portLookupResult, hints *syscall.Addrinfo, netw result <- portLookupResult{port, err} } -func cgoLookupIPCNAME(name string) (addrs []IPAddr, cname string, err error) { +func cgoLookupIPCNAME(network, name string) (addrs []IPAddr, cname string, err error) { acquireThread() defer releaseThread() var hints syscall.Addrinfo hints.Ai_flags = int32(cgoAddrInfoFlags) hints.Ai_socktype = syscall.SOCK_STREAM + hints.Ai_family = syscall.AF_UNSPEC + switch ipVersion(network) { + case '4': + hints.Ai_family = syscall.AF_INET + case '6': + hints.Ai_family = syscall.AF_INET6 + } h := syscall.StringBytePtr(name) var res *syscall.Addrinfo @@ -226,18 +231,18 @@ func cgoLookupIPCNAME(name string) (addrs []IPAddr, cname string, err error) { return addrs, cname, nil } -func cgoIPLookup(result chan<- ipLookupResult, name string) { - addrs, cname, err := cgoLookupIPCNAME(name) +func cgoIPLookup(result chan<- ipLookupResult, network, name string) { + addrs, cname, err := cgoLookupIPCNAME(network, name) result <- ipLookupResult{addrs, cname, err} } -func cgoLookupIP(ctx context.Context, name string) (addrs []IPAddr, err error, completed bool) { +func cgoLookupIP(ctx context.Context, network, name string) (addrs []IPAddr, err error, completed bool) { if ctx.Done() == nil { - addrs, _, err = cgoLookupIPCNAME(name) + addrs, _, err = cgoLookupIPCNAME(network, name) return addrs, err, true } result := make(chan ipLookupResult, 1) - go cgoIPLookup(result, name) + go cgoIPLookup(result, network, name) select { case r := <-result: return r.addrs, r.err, true @@ -248,11 +253,11 @@ func cgoLookupIP(ctx context.Context, name string) (addrs []IPAddr, err error, c func cgoLookupCNAME(ctx context.Context, name string) (cname string, err error, completed bool) { if ctx.Done() == nil { - _, cname, err = cgoLookupIPCNAME(name) + _, cname, err = cgoLookupIPCNAME("ip", name) return cname, err, true } result := make(chan ipLookupResult, 1) - go cgoIPLookup(result, name) + go cgoIPLookup(result, "ip", name) select { case r := <-result: return r.cname, r.err, true diff --git a/libgo/go/net/cgo_unix_test.go b/libgo/go/net/cgo_unix_test.go index 49da9936d3f..99d79a60c46 100644 --- a/libgo/go/net/cgo_unix_test.go +++ b/libgo/go/net/cgo_unix_test.go @@ -15,7 +15,7 @@ import ( func TestCgoLookupIP(t *testing.T) { defer dnsWaitGroup.Wait() ctx := context.Background() - _, err, ok := cgoLookupIP(ctx, "localhost") + _, err, ok := cgoLookupIP(ctx, "ip", "localhost") if !ok { t.Errorf("cgoLookupIP must not be a placeholder") } @@ -28,7 +28,7 @@ func TestCgoLookupIPWithCancel(t *testing.T) { defer dnsWaitGroup.Wait() ctx, cancel := context.WithCancel(context.Background()) defer cancel() - _, err, ok := cgoLookupIP(ctx, "localhost") + _, err, ok := cgoLookupIP(ctx, "ip", "localhost") if !ok { t.Errorf("cgoLookupIP must not be a placeholder") } diff --git a/libgo/go/net/conf.go b/libgo/go/net/conf.go index 6cc4a99bd35..971b1a399a1 100644 --- a/libgo/go/net/conf.go +++ b/libgo/go/net/conf.go @@ -7,6 +7,7 @@ package net import ( + "internal/bytealg" "os" "runtime" "sync" @@ -132,7 +133,7 @@ func (c *conf) hostLookupOrder(r *Resolver, hostname string) (ret hostLookupOrde if c.forceCgoLookupHost || c.resolv.unknownOpt || c.goos == "android" { return fallbackOrder } - if byteIndex(hostname, '\\') != -1 || byteIndex(hostname, '%') != -1 { + if bytealg.IndexByteString(hostname, '\\') != -1 || bytealg.IndexByteString(hostname, '%') != -1 { // Don't deal with special form hostnames with backslashes // or '%'. return fallbackOrder @@ -301,7 +302,7 @@ func goDebugNetDNS() (dnsMode string, debugLevel int) { dnsMode = s } } - if i := byteIndex(goDebug, '+'); i != -1 { + if i := bytealg.IndexByteString(goDebug, '+'); i != -1 { parsePart(goDebug[:i]) parsePart(goDebug[i+1:]) return diff --git a/libgo/go/net/dial.go b/libgo/go/net/dial.go index b1a5ca7cd53..1dd8690739e 100644 --- a/libgo/go/net/dial.go +++ b/libgo/go/net/dial.go @@ -44,22 +44,31 @@ type Dialer struct { // If nil, a local address is automatically chosen. LocalAddr Addr - // DualStack enables RFC 6555-compliant "Happy Eyeballs" - // dialing when the network is "tcp" and the host in the - // address parameter resolves to both IPv4 and IPv6 addresses. - // This allows a client to tolerate networks where one address - // family is silently broken. + // DualStack previously enabled RFC 6555 Fast Fallback + // support, also known as "Happy Eyeballs", in which IPv4 is + // tried soon if IPv6 appears to be misconfigured and + // hanging. + // + // Deprecated: Fast Fallback is enabled by default. To + // disable, set FallbackDelay to a negative value. DualStack bool // FallbackDelay specifies the length of time to wait before - // spawning a fallback connection, when DualStack is enabled. + // spawning a RFC 6555 Fast Fallback connection. That is, this + // is the amount of time to wait for IPv6 to succeed before + // assuming that IPv6 is misconfigured and falling back to + // IPv4. + // // If zero, a default delay of 300ms is used. + // A negative value disables Fast Fallback support. FallbackDelay time.Duration // KeepAlive specifies the keep-alive period for an active // network connection. - // If zero, keep-alives are not enabled. Network protocols + // If zero, keep-alives are enabled if supported by the protocol + // and operating system. Network protocols or operating systems // that do not support keep-alives ignore this field. + // If negative, keep-alives are disabled. KeepAlive time.Duration // Resolver optionally specifies an alternate resolver to use. @@ -81,6 +90,8 @@ type Dialer struct { Control func(network, address string, c syscall.RawConn) error } +func (d *Dialer) dualStack() bool { return d.FallbackDelay >= 0 } + func minNonzeroTime(a, b time.Time) time.Time { if a.IsZero() { return b @@ -393,7 +404,7 @@ func (d *Dialer) DialContext(ctx context.Context, network, address string) (Conn } var primaries, fallbacks addrList - if d.DualStack && network == "tcp" { + if d.dualStack() && network == "tcp" { primaries, fallbacks = addrs.partition(isIPv4) } else { primaries = addrs @@ -409,10 +420,14 @@ func (d *Dialer) DialContext(ctx context.Context, network, address string) (Conn return nil, err } - if tc, ok := c.(*TCPConn); ok && d.KeepAlive > 0 { + if tc, ok := c.(*TCPConn); ok && d.KeepAlive >= 0 { setKeepAlive(tc.fd, true) - setKeepAlivePeriod(tc.fd, d.KeepAlive) - testHookSetKeepAlive() + ka := d.KeepAlive + if d.KeepAlive == 0 { + ka = 15 * time.Second + } + setKeepAlivePeriod(tc.fd, ka) + testHookSetKeepAlive(ka) } return c, nil } diff --git a/libgo/go/net/dial_test.go b/libgo/go/net/dial_test.go index 00a84d17d60..3a2c59a2d1d 100644 --- a/libgo/go/net/dial_test.go +++ b/libgo/go/net/dial_test.go @@ -318,9 +318,9 @@ func TestDialParallel(t *testing.T) { expectElapsedMin := tt.expectElapsed - 95*time.Millisecond expectElapsedMax := tt.expectElapsed + 95*time.Millisecond - if !(elapsed >= expectElapsedMin) { + if elapsed < expectElapsedMin { t.Errorf("#%d: got %v; want >= %v", i, elapsed, expectElapsedMin) - } else if !(elapsed <= expectElapsedMax) { + } else if elapsed > expectElapsedMax { t.Errorf("#%d: got %v; want <= %v", i, elapsed, expectElapsedMax) } @@ -346,7 +346,7 @@ func TestDialParallel(t *testing.T) { } } -func lookupSlowFast(ctx context.Context, fn func(context.Context, string) ([]IPAddr, error), host string) ([]IPAddr, error) { +func lookupSlowFast(ctx context.Context, fn func(context.Context, string, string) ([]IPAddr, error), network, host string) ([]IPAddr, error) { switch host { case "slow6loopback4": // Returns a slow IPv6 address, and a local IPv4 address. @@ -355,7 +355,7 @@ func lookupSlowFast(ctx context.Context, fn func(context.Context, string) ([]IPA {IP: ParseIP("127.0.0.1")}, }, nil default: - return fn(ctx, host) + return fn(ctx, network, host) } } @@ -418,10 +418,10 @@ func TestDialerFallbackDelay(t *testing.T) { } expectMin := tt.expectElapsed - 1*time.Millisecond expectMax := tt.expectElapsed + 95*time.Millisecond - if !(elapsed >= expectMin) { + if elapsed < expectMin { t.Errorf("#%d: got %v; want >= %v", i, elapsed, expectMin) } - if !(elapsed <= expectMax) { + if elapsed > expectMax { t.Errorf("#%d: got %v; want <= %v", i, elapsed, expectMax) } } @@ -729,22 +729,29 @@ func TestDialerKeepAlive(t *testing.T) { if err := ls.buildup(handler); err != nil { t.Fatal(err) } - defer func() { testHookSetKeepAlive = func() {} }() + defer func() { testHookSetKeepAlive = func(time.Duration) {} }() - for _, keepAlive := range []bool{false, true} { - got := false - testHookSetKeepAlive = func() { got = true } - var d Dialer - if keepAlive { - d.KeepAlive = 30 * time.Second - } + tests := []struct { + ka time.Duration + expected time.Duration + }{ + {-1, -1}, + {0, 15 * time.Second}, + {5 * time.Second, 5 * time.Second}, + {30 * time.Second, 30 * time.Second}, + } + + for _, test := range tests { + var got time.Duration = -1 + testHookSetKeepAlive = func(d time.Duration) { got = d } + d := Dialer{KeepAlive: test.ka} c, err := d.Dial("tcp", ls.Listener.Addr().String()) if err != nil { t.Fatal(err) } c.Close() - if got != keepAlive { - t.Errorf("Dialer.KeepAlive = %v: SetKeepAlive called = %v, want %v", d.KeepAlive, got, !got) + if got != test.expected { + t.Errorf("Dialer.KeepAlive = %v: SetKeepAlive set to %v, want %v", d.KeepAlive, got, test.expected) } } } diff --git a/libgo/go/net/dnsclient.go b/libgo/go/net/dnsclient.go index 2e4bffaab8b..4fdf60ff4e3 100644 --- a/libgo/go/net/dnsclient.go +++ b/libgo/go/net/dnsclient.go @@ -8,7 +8,7 @@ import ( "math/rand" "sort" - "golang_org/x/net/dns/dnsmessage" + "internal/x/net/dns/dnsmessage" ) // reverseaddr returns the in-addr.arpa. or ip6.arpa. hostname of the IP @@ -27,10 +27,10 @@ func reverseaddr(addr string) (arpa string, err error) { // Add it, in reverse, to the buffer for i := len(ip) - 1; i >= 0; i-- { v := ip[i] - buf = append(buf, hexDigit[v&0xF]) - buf = append(buf, '.') - buf = append(buf, hexDigit[v>>4]) - buf = append(buf, '.') + buf = append(buf, hexDigit[v&0xF], + '.', + hexDigit[v>>4], + '.') } // Append "ip6.arpa." and return (buf already has the final .) buf = append(buf, "ip6.arpa."...) @@ -75,7 +75,7 @@ func isDomainName(s string) bool { } last := byte('.') - ok := false // Ok once we've seen a letter. + nonNumeric := false // true once we've seen a letter or hyphen partlen := 0 for i := 0; i < len(s); i++ { c := s[i] @@ -83,7 +83,7 @@ func isDomainName(s string) bool { default: return false case 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' || c == '_': - ok = true + nonNumeric = true partlen++ case '0' <= c && c <= '9': // fine @@ -94,6 +94,7 @@ func isDomainName(s string) bool { return false } partlen++ + nonNumeric = true case c == '.': // Byte before dot cannot be dot, dash. if last == '.' || last == '-' { @@ -110,7 +111,7 @@ func isDomainName(s string) bool { return false } - return ok + return nonNumeric } // absDomainName returns an absolute domain name which ends with a diff --git a/libgo/go/net/dnsclient_unix.go b/libgo/go/net/dnsclient_unix.go index 3b0293025d9..86ce92dc437 100644 --- a/libgo/go/net/dnsclient_unix.go +++ b/libgo/go/net/dnsclient_unix.go @@ -9,7 +9,6 @@ // TODO(rsc): // Could potentially handle many outstanding lookups faster. -// Could have a small cache. // Random UDP source port (net.Dial should do that for us). // Random request IDs. @@ -24,7 +23,7 @@ import ( "sync" "time" - "golang_org/x/net/dns/dnsmessage" + "internal/x/net/dns/dnsmessage" ) var ( diff --git a/libgo/go/net/dnsclient_unix_test.go b/libgo/go/net/dnsclient_unix_test.go index 8992480b6ac..38057d72439 100644 --- a/libgo/go/net/dnsclient_unix_test.go +++ b/libgo/go/net/dnsclient_unix_test.go @@ -20,7 +20,7 @@ import ( "testing" "time" - "golang_org/x/net/dns/dnsmessage" + "internal/x/net/dns/dnsmessage" ) var goResolver = Resolver{PreferGo: true} diff --git a/libgo/go/net/dnsconfig_unix.go b/libgo/go/net/dnsconfig_unix.go index 8ae5de6d3a0..842d408e562 100644 --- a/libgo/go/net/dnsconfig_unix.go +++ b/libgo/go/net/dnsconfig_unix.go @@ -9,6 +9,7 @@ package net import ( + "internal/bytealg" "os" "sync/atomic" "time" @@ -155,7 +156,7 @@ func dnsDefaultSearch() []string { // best effort return nil } - if i := byteIndex(hn, '.'); i >= 0 && i < len(hn)-1 { + if i := bytealg.IndexByteString(hn, '.'); i >= 0 && i < len(hn)-1 { return []string{ensureRooted(hn[i+1:])} } return nil diff --git a/libgo/go/net/dnsname_test.go b/libgo/go/net/dnsname_test.go index 806d8756cb5..2964982311c 100644 --- a/libgo/go/net/dnsname_test.go +++ b/libgo/go/net/dnsname_test.go @@ -22,6 +22,7 @@ var dnsNameTests = []dnsNameTest{ {"foo.com", true}, {"1foo.com", true}, {"26.0.0.73.com", true}, + {"10-0-0-1", true}, {"fo-o.com", true}, {"fo1o.com", true}, {"foo1.com", true}, diff --git a/libgo/go/net/error_test.go b/libgo/go/net/error_test.go index e09670e5ce0..2819986c0cd 100644 --- a/libgo/go/net/error_test.go +++ b/libgo/go/net/error_test.go @@ -144,7 +144,7 @@ func TestDialError(t *testing.T) { origTestHookLookupIP := testHookLookupIP defer func() { testHookLookupIP = origTestHookLookupIP }() - testHookLookupIP = func(ctx context.Context, fn func(context.Context, string) ([]IPAddr, error), host string) ([]IPAddr, error) { + testHookLookupIP = func(ctx context.Context, fn func(context.Context, string, string) ([]IPAddr, error), network, host string) ([]IPAddr, error) { return nil, &DNSError{Err: "dial error test", Name: "name", Server: "server", IsTimeout: true} } sw.Set(socktest.FilterConnect, func(so *socktest.Status) (socktest.AfterFilter, error) { @@ -293,7 +293,7 @@ func TestListenError(t *testing.T) { origTestHookLookupIP := testHookLookupIP defer func() { testHookLookupIP = origTestHookLookupIP }() - testHookLookupIP = func(_ context.Context, fn func(context.Context, string) ([]IPAddr, error), host string) ([]IPAddr, error) { + testHookLookupIP = func(_ context.Context, fn func(context.Context, string, string) ([]IPAddr, error), network, host string) ([]IPAddr, error) { return nil, &DNSError{Err: "listen error test", Name: "name", Server: "server", IsTimeout: true} } sw.Set(socktest.FilterListen, func(so *socktest.Status) (socktest.AfterFilter, error) { @@ -353,7 +353,7 @@ func TestListenPacketError(t *testing.T) { origTestHookLookupIP := testHookLookupIP defer func() { testHookLookupIP = origTestHookLookupIP }() - testHookLookupIP = func(_ context.Context, fn func(context.Context, string) ([]IPAddr, error), host string) ([]IPAddr, error) { + testHookLookupIP = func(_ context.Context, fn func(context.Context, string, string) ([]IPAddr, error), network, host string) ([]IPAddr, error) { return nil, &DNSError{Err: "listen error test", Name: "name", Server: "server", IsTimeout: true} } diff --git a/libgo/go/net/error_unix.go b/libgo/go/net/error_unix.go index b5a5829eaa0..e6153303882 100644 --- a/libgo/go/net/error_unix.go +++ b/libgo/go/net/error_unix.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd js linux netbsd openbsd solaris +// +build aix darwin dragonfly freebsd js linux netbsd openbsd solaris package net diff --git a/libgo/go/net/hook.go b/libgo/go/net/hook.go index d7316ea4383..ea71803e22a 100644 --- a/libgo/go/net/hook.go +++ b/libgo/go/net/hook.go @@ -4,7 +4,10 @@ package net -import "context" +import ( + "context" + "time" +) var ( // if non-nil, overrides dialTCP. @@ -13,10 +16,11 @@ var ( testHookHostsPath = "/etc/hosts" testHookLookupIP = func( ctx context.Context, - fn func(context.Context, string) ([]IPAddr, error), + fn func(context.Context, string, string) ([]IPAddr, error), + network string, host string, ) ([]IPAddr, error) { - return fn(ctx, host) + return fn(ctx, network, host) } - testHookSetKeepAlive = func() {} + testHookSetKeepAlive = func(time.Duration) {} ) diff --git a/libgo/go/net/hosts.go b/libgo/go/net/hosts.go index ebc0353a7fb..5c560f3756e 100644 --- a/libgo/go/net/hosts.go +++ b/libgo/go/net/hosts.go @@ -5,6 +5,7 @@ package net import ( + "internal/bytealg" "sync" "time" ) @@ -68,7 +69,7 @@ func readHosts() { return } for line, ok := file.readLine(); ok; line, ok = file.readLine() { - if i := byteIndex(line, '#'); i >= 0 { + if i := bytealg.IndexByteString(line, '#'); i >= 0 { // Discard comments. line = line[0:i] } diff --git a/libgo/go/net/http/cgi/child.go b/libgo/go/net/http/cgi/child.go index da12ac34980..10325c2eb5a 100644 --- a/libgo/go/net/http/cgi/child.go +++ b/libgo/go/net/http/cgi/child.go @@ -86,7 +86,7 @@ func RequestFromMap(params map[string]string) (*http.Request, error) { if !strings.HasPrefix(k, "HTTP_") || k == "HTTP_HOST" { continue } - r.Header.Add(strings.Replace(k[5:], "_", "-", -1), v) + r.Header.Add(strings.ReplaceAll(k[5:], "_", "-"), v) } // TODO: cookies. parsing them isn't exported, though. diff --git a/libgo/go/net/http/client.go b/libgo/go/net/http/client.go index 8f69a298e3f..ea6c0719119 100644 --- a/libgo/go/net/http/client.go +++ b/libgo/go/net/http/client.go @@ -238,7 +238,7 @@ func send(ireq *Request, rt RoundTripper, deadline time.Time) (resp *Response, d username := u.Username() password, _ := u.Password() forkReq() - req.Header = cloneHeader(ireq.Header) + req.Header = ireq.Header.clone() req.Header.Set("Authorization", "Basic "+basicAuth(username, password)) } @@ -833,6 +833,22 @@ func (c *Client) Head(url string) (resp *Response, err error) { return c.Do(req) } +// CloseIdleConnections closes any connections on its Transport which +// were previously connected from previous requests but are now +// sitting idle in a "keep-alive" state. It does not interrupt any +// connections currently in use. +// +// If the Client's Transport does not have a CloseIdleConnections method +// then this method does nothing. +func (c *Client) CloseIdleConnections() { + type closeIdler interface { + CloseIdleConnections() + } + if tr, ok := c.transport().(closeIdler); ok { + tr.CloseIdleConnections() + } +} + // cancelTimerBody is an io.ReadCloser that wraps rc with two features: // 1) on Read error or close, the stop func is called. // 2) On Read failure, if reqDidTimeout is true, the error is wrapped and diff --git a/libgo/go/net/http/client_test.go b/libgo/go/net/http/client_test.go index bfc793e638c..1c59ce74352 100644 --- a/libgo/go/net/http/client_test.go +++ b/libgo/go/net/http/client_test.go @@ -977,6 +977,7 @@ func TestResponseSetsTLSConnectionState(t *testing.T) { c := ts.Client() tr := c.Transport.(*Transport) tr.TLSClientConfig.CipherSuites = []uint16{tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA} + tr.TLSClientConfig.MaxVersion = tls.VersionTLS12 // to get to pick the cipher suite tr.Dial = func(netw, addr string) (net.Conn, error) { return net.Dial(netw, ts.Listener.Addr().String()) } @@ -1888,3 +1889,27 @@ func TestTransportBodyReadError(t *testing.T) { t.Errorf("close calls = %d; want 1", closeCalls) } } + +type roundTripperWithoutCloseIdle struct{} + +func (roundTripperWithoutCloseIdle) RoundTrip(*Request) (*Response, error) { panic("unused") } + +type roundTripperWithCloseIdle func() // underlying func is CloseIdleConnections func + +func (roundTripperWithCloseIdle) RoundTrip(*Request) (*Response, error) { panic("unused") } +func (f roundTripperWithCloseIdle) CloseIdleConnections() { f() } + +func TestClientCloseIdleConnections(t *testing.T) { + c := &Client{Transport: roundTripperWithoutCloseIdle{}} + c.CloseIdleConnections() // verify we don't crash at least + + closed := false + var tr RoundTripper = roundTripperWithCloseIdle(func() { + closed = true + }) + c = &Client{Transport: tr} + c.CloseIdleConnections() + if !closed { + t.Error("not closed") + } +} diff --git a/libgo/go/net/http/clientserver_test.go b/libgo/go/net/http/clientserver_test.go index 6513b2d32fc..4da218b2568 100644 --- a/libgo/go/net/http/clientserver_test.go +++ b/libgo/go/net/http/clientserver_test.go @@ -9,8 +9,11 @@ package http_test import ( "bytes" "compress/gzip" + "crypto/rand" + "crypto/sha1" "crypto/tls" "fmt" + "hash" "io" "io/ioutil" "log" @@ -249,7 +252,7 @@ type slurpResult struct { func (sr slurpResult) String() string { return fmt.Sprintf("body %q; err %v", sr.body, sr.err) } func (tt h12Compare) normalizeRes(t *testing.T, res *Response, wantProto string) { - if res.Proto == wantProto { + if res.Proto == wantProto || res.Proto == "HTTP/IGNORE" { res.Proto, res.ProtoMajor, res.ProtoMinor = "", 0, 0 } else { t.Errorf("got %q response; want %q", res.Proto, wantProto) @@ -1475,11 +1478,97 @@ func testWriteHeaderAfterWrite(t *testing.T, h2, hijack bool) { return } gotLog := strings.TrimSpace(errorLog.String()) - wantLog := "http: multiple response.WriteHeader calls" + wantLog := "http: superfluous response.WriteHeader call from http_test.testWriteHeaderAfterWrite..func1 (clientserver_test.go:" if hijack { - wantLog = "http: response.WriteHeader on hijacked connection" + wantLog = "http: response.WriteHeader on hijacked connection from http_test.testWriteHeaderAfterWrite..func1 (clientserver_test.go:" } - if gotLog != wantLog { + if !strings.HasPrefix(gotLog, wantLog) { t.Errorf("stderr output = %q; want %q", gotLog, wantLog) } } + +func TestBidiStreamReverseProxy(t *testing.T) { + setParallel(t) + defer afterTest(t) + backend := newClientServerTest(t, h2Mode, HandlerFunc(func(w ResponseWriter, r *Request) { + if _, err := io.Copy(w, r.Body); err != nil { + log.Printf("bidi backend copy: %v", err) + } + })) + defer backend.close() + + backURL, err := url.Parse(backend.ts.URL) + if err != nil { + t.Fatal(err) + } + rp := httputil.NewSingleHostReverseProxy(backURL) + rp.Transport = backend.tr + proxy := newClientServerTest(t, h2Mode, HandlerFunc(func(w ResponseWriter, r *Request) { + rp.ServeHTTP(w, r) + })) + defer proxy.close() + + bodyRes := make(chan interface{}, 1) // error or hash.Hash + pr, pw := io.Pipe() + req, _ := NewRequest("PUT", proxy.ts.URL, pr) + const size = 4 << 20 + go func() { + h := sha1.New() + _, err := io.CopyN(io.MultiWriter(h, pw), rand.Reader, size) + go pw.Close() + if err != nil { + bodyRes <- err + } else { + bodyRes <- h + } + }() + res, err := backend.c.Do(req) + if err != nil { + t.Fatal(err) + } + defer res.Body.Close() + hgot := sha1.New() + n, err := io.Copy(hgot, res.Body) + if err != nil { + t.Fatal(err) + } + if n != size { + t.Fatalf("got %d bytes; want %d", n, size) + } + select { + case v := <-bodyRes: + switch v := v.(type) { + default: + t.Fatalf("body copy: %v", err) + case hash.Hash: + if !bytes.Equal(v.Sum(nil), hgot.Sum(nil)) { + t.Errorf("written bytes didn't match received bytes") + } + } + case <-time.After(10 * time.Second): + t.Fatal("timeout") + } + +} + +// Always use HTTP/1.1 for WebSocket upgrades. +func TestH12_WebSocketUpgrade(t *testing.T) { + h12Compare{ + Handler: func(w ResponseWriter, r *Request) { + h := w.Header() + h.Set("Foo", "bar") + }, + ReqFunc: func(c *Client, url string) (*Response, error) { + req, _ := NewRequest("GET", url, nil) + req.Header.Set("Connection", "Upgrade") + req.Header.Set("Upgrade", "WebSocket") + return c.Do(req) + }, + EarlyCheckResponse: func(proto string, res *Response) { + if res.Proto != "HTTP/1.1" { + t.Errorf("%s: expected HTTP/1.1, got %q", proto, res.Proto) + } + res.Proto = "HTTP/IGNORE" // skip later checks that Proto must be 1.1 vs 2.0 + }, + }.run(t) +} diff --git a/libgo/go/net/http/cookie.go b/libgo/go/net/http/cookie.go index b1a6cef6f70..63f62214db8 100644 --- a/libgo/go/net/http/cookie.go +++ b/libgo/go/net/http/cookie.go @@ -36,10 +36,10 @@ type Cookie struct { Unparsed []string // Raw text of unparsed attribute-value pairs } -// SameSite allows a server define a cookie attribute making it impossible to -// the browser send this cookie along with cross-site requests. The main goal -// is mitigate the risk of cross-origin information leakage, and provides some -// protection against cross-site request forgery attacks. +// SameSite allows a server to define a cookie attribute making it impossible for +// the browser to send this cookie along with cross-site requests. The main +// goal is to mitigate the risk of cross-origin information leakage, and provide +// some protection against cross-site request forgery attacks. // // See https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-00 for details. type SameSite int @@ -263,7 +263,7 @@ func readCookies(h Header, filter string) []*Cookie { return cookies } -// validCookieDomain returns whether v is a valid cookie domain-value. +// validCookieDomain reports whether v is a valid cookie domain-value. func validCookieDomain(v string) bool { if isCookieDomainName(v) { return true @@ -274,13 +274,13 @@ func validCookieDomain(v string) bool { return false } -// validCookieExpires returns whether v is a valid cookie expires-value. +// validCookieExpires reports whether v is a valid cookie expires-value. func validCookieExpires(t time.Time) bool { // IETF RFC 6265 Section 5.1.1.5, the year must not be less than 1601 return t.Year() >= 1601 } -// isCookieDomainName returns whether s is a valid domain name or a valid +// isCookieDomainName reports whether s is a valid domain name or a valid // domain name with a leading dot '.'. It is almost a direct copy of // package net's isDomainName. func isCookieDomainName(s string) bool { diff --git a/libgo/go/net/http/example_filesystem_test.go b/libgo/go/net/http/example_filesystem_test.go new file mode 100644 index 00000000000..e1fd42d0494 --- /dev/null +++ b/libgo/go/net/http/example_filesystem_test.go @@ -0,0 +1,71 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package http_test + +import ( + "log" + "net/http" + "os" + "strings" +) + +// containsDotFile reports whether name contains a path element starting with a period. +// The name is assumed to be a delimited by forward slashes, as guaranteed +// by the http.FileSystem interface. +func containsDotFile(name string) bool { + parts := strings.Split(name, "/") + for _, part := range parts { + if strings.HasPrefix(part, ".") { + return true + } + } + return false +} + +// dotFileHidingFile is the http.File use in dotFileHidingFileSystem. +// It is used to wrap the Readdir method of http.File so that we can +// remove files and directories that start with a period from its output. +type dotFileHidingFile struct { + http.File +} + +// Readdir is a wrapper around the Readdir method of the embedded File +// that filters out all files that start with a period in their name. +func (f dotFileHidingFile) Readdir(n int) (fis []os.FileInfo, err error) { + files, err := f.File.Readdir(n) + for _, file := range files { // Filters out the dot files + if !strings.HasPrefix(file.Name(), ".") { + fis = append(fis, file) + } + } + return +} + +// dotFileHidingFileSystem is an http.FileSystem that hides +// hidden "dot files" from being served. +type dotFileHidingFileSystem struct { + http.FileSystem +} + +// Open is a wrapper around the Open method of the embedded FileSystem +// that serves a 403 permission error when name has a file or directory +// with whose name starts with a period in its path. +func (fs dotFileHidingFileSystem) Open(name string) (http.File, error) { + if containsDotFile(name) { // If dot file, return 403 response + return nil, os.ErrPermission + } + + file, err := fs.FileSystem.Open(name) + if err != nil { + return nil, err + } + return dotFileHidingFile{file}, err +} + +func ExampleFileServer_dotFileHiding() { + fs := dotFileHidingFileSystem{http.Dir(".")} + http.Handle("/", http.FileServer(fs)) + log.Fatal(http.ListenAndServe(":8080", nil)) +} diff --git a/libgo/go/net/http/example_handle_test.go b/libgo/go/net/http/example_handle_test.go new file mode 100644 index 00000000000..10a62f64c2f --- /dev/null +++ b/libgo/go/net/http/example_handle_test.go @@ -0,0 +1,29 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package http_test + +import ( + "fmt" + "log" + "net/http" + "sync" +) + +type countHandler struct { + mu sync.Mutex // guards n + n int +} + +func (h *countHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + h.mu.Lock() + defer h.mu.Unlock() + h.n++ + fmt.Fprintf(w, "count is %d\n", h.n) +} + +func ExampleHandle() { + http.Handle("/count", new(countHandler)) + log.Fatal(http.ListenAndServe(":8080", nil)) +} diff --git a/libgo/go/net/http/example_test.go b/libgo/go/net/http/example_test.go index 53fb0bbb4e1..2a09f5f6c69 100644 --- a/libgo/go/net/http/example_test.go +++ b/libgo/go/net/http/example_test.go @@ -159,3 +159,35 @@ func ExampleListenAndServe() { http.HandleFunc("/hello", helloHandler) log.Fatal(http.ListenAndServe(":8080", nil)) } + +func ExampleHandleFunc() { + h1 := func(w http.ResponseWriter, _ *http.Request) { + io.WriteString(w, "Hello from a HandleFunc #1!\n") + } + h2 := func(w http.ResponseWriter, _ *http.Request) { + io.WriteString(w, "Hello from a HandleFunc #2!\n") + } + + http.HandleFunc("/", h1) + http.HandleFunc("/endpoint", h2) + + log.Fatal(http.ListenAndServe(":8080", nil)) +} + +func newPeopleHandler() http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + fmt.Fprintln(w, "This is the people handler.") + }) +} + +func ExampleNotFoundHandler() { + mux := http.NewServeMux() + + // Create sample handler to returns 404 + mux.Handle("/resources", http.NotFoundHandler()) + + // Create sample handler that returns 200 + mux.Handle("/resources/people/", newPeopleHandler()) + + log.Fatal(http.ListenAndServe(":8080", mux)) +} diff --git a/libgo/go/net/http/export_test.go b/libgo/go/net/http/export_test.go index bc0db53a2c6..b6965c239e9 100644 --- a/libgo/go/net/http/export_test.go +++ b/libgo/go/net/http/export_test.go @@ -155,7 +155,7 @@ func (t *Transport) IdleConnStrsForTesting_h2() []string { func (t *Transport) IdleConnCountForTesting(scheme, addr string) int { t.idleMu.Lock() defer t.idleMu.Unlock() - key := connectMethodKey{"", scheme, addr} + key := connectMethodKey{"", scheme, addr, false} cacheKey := key.String() for k, conns := range t.idleConn { if k.String() == cacheKey { @@ -178,12 +178,12 @@ func (t *Transport) IsIdleForTesting() bool { } func (t *Transport) RequestIdleConnChForTesting() { - t.getIdleConnCh(connectMethod{nil, "http", "example.com"}) + t.getIdleConnCh(connectMethod{nil, "http", "example.com", false}) } func (t *Transport) PutIdleTestConn(scheme, addr string) bool { c, _ := net.Pipe() - key := connectMethodKey{"", scheme, addr} + key := connectMethodKey{"", scheme, addr, false} select { case <-t.incHostConnCount(key): default: @@ -242,3 +242,5 @@ func ExportSetH2GoawayTimeout(d time.Duration) (restore func()) { http2goAwayTimeout = d return func() { http2goAwayTimeout = old } } + +func (r *Request) ExportIsReplayable() bool { return r.isReplayable() } diff --git a/libgo/go/net/http/h2_bundle.go b/libgo/go/net/http/h2_bundle.go index 4268f2fbd0a..77c7eee74a5 100644 --- a/libgo/go/net/http/h2_bundle.go +++ b/libgo/go/net/http/h2_bundle.go @@ -44,9 +44,9 @@ import ( "sync" "time" - "golang_org/x/net/http/httpguts" - "golang_org/x/net/http2/hpack" - "golang_org/x/net/idna" + "internal/x/net/http/httpguts" + "internal/x/net/http2/hpack" + "internal/x/net/idna" ) // A list of the possible cipher suite ids. Taken from @@ -954,75 +954,6 @@ func (p http2noDialClientConnPool) GetClientConn(req *Request, addr string) (*ht return p.getClientConn(req, addr, http2noDialOnMiss) } -func http2configureTransport(t1 *Transport) (*http2Transport, error) { - connPool := new(http2clientConnPool) - t2 := &http2Transport{ - ConnPool: http2noDialClientConnPool{connPool}, - t1: t1, - } - connPool.t = t2 - if err := http2registerHTTPSProtocol(t1, http2noDialH2RoundTripper{t2}); err != nil { - return nil, err - } - if t1.TLSClientConfig == nil { - t1.TLSClientConfig = new(tls.Config) - } - if !http2strSliceContains(t1.TLSClientConfig.NextProtos, "h2") { - t1.TLSClientConfig.NextProtos = append([]string{"h2"}, t1.TLSClientConfig.NextProtos...) - } - if !http2strSliceContains(t1.TLSClientConfig.NextProtos, "http/1.1") { - t1.TLSClientConfig.NextProtos = append(t1.TLSClientConfig.NextProtos, "http/1.1") - } - upgradeFn := func(authority string, c *tls.Conn) RoundTripper { - addr := http2authorityAddr("https", authority) - if used, err := connPool.addConnIfNeeded(addr, t2, c); err != nil { - go c.Close() - return http2erringRoundTripper{err} - } else if !used { - // Turns out we don't need this c. - // For example, two goroutines made requests to the same host - // at the same time, both kicking off TCP dials. (since protocol - // was unknown) - go c.Close() - } - return t2 - } - if m := t1.TLSNextProto; len(m) == 0 { - t1.TLSNextProto = map[string]func(string, *tls.Conn) RoundTripper{ - "h2": upgradeFn, - } - } else { - m["h2"] = upgradeFn - } - return t2, nil -} - -// registerHTTPSProtocol calls Transport.RegisterProtocol but -// converting panics into errors. -func http2registerHTTPSProtocol(t *Transport, rt http2noDialH2RoundTripper) (err error) { - defer func() { - if e := recover(); e != nil { - err = fmt.Errorf("%v", e) - } - }() - t.RegisterProtocol("https", rt) - return nil -} - -// noDialH2RoundTripper is a RoundTripper which only tries to complete the request -// if there's already has a cached connection to the host. -// (The field is exported so it can be accessed via reflect from net/http; tested -// by TestNoDialH2RoundTripperType) -type http2noDialH2RoundTripper struct{ *http2Transport } - -func (rt http2noDialH2RoundTripper) RoundTrip(req *Request) (*Response, error) { - res, err := rt.http2Transport.RoundTrip(req) - if http2isNoCachedConnError(err) { - return nil, ErrSkipAltProtocol - } - return res, err -} - // Buffer chunks are allocated from a pool to reduce pressure on GC. // The maximum wasted space per dataBuffer is 2x the largest size class, // which happens when the dataBuffer has multiple chunks and there is @@ -2788,7 +2719,7 @@ func (fr *http2Framer) maxHeaderStringLen() int { } // readMetaFrame returns 0 or more CONTINUATION frames from fr and -// merge them into into the provided hf and returns a MetaHeadersFrame +// merge them into the provided hf and returns a MetaHeadersFrame // with the decoded hpack values. func (fr *http2Framer) readMetaFrame(hf *http2HeadersFrame) (*http2MetaHeadersFrame, error) { if fr.AllowIllegalReads { @@ -2924,181 +2855,23 @@ func http2summarizeFrame(f http2Frame) string { return buf.String() } -func http2traceHasWroteHeaderField(trace *http2clientTrace) bool { +func http2traceHasWroteHeaderField(trace *httptrace.ClientTrace) bool { return trace != nil && trace.WroteHeaderField != nil } -func http2traceWroteHeaderField(trace *http2clientTrace, k, v string) { +func http2traceWroteHeaderField(trace *httptrace.ClientTrace, k, v string) { if trace != nil && trace.WroteHeaderField != nil { trace.WroteHeaderField(k, []string{v}) } } -func http2traceGot1xxResponseFunc(trace *http2clientTrace) func(int, textproto.MIMEHeader) error { +func http2traceGot1xxResponseFunc(trace *httptrace.ClientTrace) func(int, textproto.MIMEHeader) error { if trace != nil { return trace.Got1xxResponse } return nil } -func http2transportExpectContinueTimeout(t1 *Transport) time.Duration { - return t1.ExpectContinueTimeout -} - -type http2contextContext interface { - context.Context -} - -var http2errCanceled = context.Canceled - -func http2serverConnBaseContext(c net.Conn, opts *http2ServeConnOpts) (ctx http2contextContext, cancel func()) { - ctx, cancel = context.WithCancel(context.Background()) - ctx = context.WithValue(ctx, LocalAddrContextKey, c.LocalAddr()) - if hs := opts.baseConfig(); hs != nil { - ctx = context.WithValue(ctx, ServerContextKey, hs) - } - return -} - -func http2contextWithCancel(ctx http2contextContext) (_ http2contextContext, cancel func()) { - return context.WithCancel(ctx) -} - -func http2requestWithContext(req *Request, ctx http2contextContext) *Request { - return req.WithContext(ctx) -} - -type http2clientTrace httptrace.ClientTrace - -func http2reqContext(r *Request) context.Context { return r.Context() } - -func (t *http2Transport) idleConnTimeout() time.Duration { - if t.t1 != nil { - return t.t1.IdleConnTimeout - } - return 0 -} - -func http2setResponseUncompressed(res *Response) { res.Uncompressed = true } - -func http2traceGetConn(req *Request, hostPort string) { - trace := httptrace.ContextClientTrace(req.Context()) - if trace == nil || trace.GetConn == nil { - return - } - trace.GetConn(hostPort) -} - -func http2traceGotConn(req *Request, cc *http2ClientConn) { - trace := httptrace.ContextClientTrace(req.Context()) - if trace == nil || trace.GotConn == nil { - return - } - ci := httptrace.GotConnInfo{Conn: cc.tconn} - cc.mu.Lock() - ci.Reused = cc.nextStreamID > 1 - ci.WasIdle = len(cc.streams) == 0 && ci.Reused - if ci.WasIdle && !cc.lastActive.IsZero() { - ci.IdleTime = time.Now().Sub(cc.lastActive) - } - cc.mu.Unlock() - - trace.GotConn(ci) -} - -func http2traceWroteHeaders(trace *http2clientTrace) { - if trace != nil && trace.WroteHeaders != nil { - trace.WroteHeaders() - } -} - -func http2traceGot100Continue(trace *http2clientTrace) { - if trace != nil && trace.Got100Continue != nil { - trace.Got100Continue() - } -} - -func http2traceWait100Continue(trace *http2clientTrace) { - if trace != nil && trace.Wait100Continue != nil { - trace.Wait100Continue() - } -} - -func http2traceWroteRequest(trace *http2clientTrace, err error) { - if trace != nil && trace.WroteRequest != nil { - trace.WroteRequest(httptrace.WroteRequestInfo{Err: err}) - } -} - -func http2traceFirstResponseByte(trace *http2clientTrace) { - if trace != nil && trace.GotFirstResponseByte != nil { - trace.GotFirstResponseByte() - } -} - -func http2requestTrace(req *Request) *http2clientTrace { - trace := httptrace.ContextClientTrace(req.Context()) - return (*http2clientTrace)(trace) -} - -// Ping sends a PING frame to the server and waits for the ack. -func (cc *http2ClientConn) Ping(ctx context.Context) error { - return cc.ping(ctx) -} - -// Shutdown gracefully closes the client connection, waiting for running streams to complete. -func (cc *http2ClientConn) Shutdown(ctx context.Context) error { - return cc.shutdown(ctx) -} - -func http2cloneTLSConfig(c *tls.Config) *tls.Config { - c2 := c.Clone() - c2.GetClientCertificate = c.GetClientCertificate // golang.org/issue/19264 - return c2 -} - -var _ Pusher = (*http2responseWriter)(nil) - -// Push implements http.Pusher. -func (w *http2responseWriter) Push(target string, opts *PushOptions) error { - internalOpts := http2pushOptions{} - if opts != nil { - internalOpts.Method = opts.Method - internalOpts.Header = opts.Header - } - return w.push(target, internalOpts) -} - -func http2configureServer18(h1 *Server, h2 *http2Server) error { - if h2.IdleTimeout == 0 { - if h1.IdleTimeout != 0 { - h2.IdleTimeout = h1.IdleTimeout - } else { - h2.IdleTimeout = h1.ReadTimeout - } - } - return nil -} - -func http2shouldLogPanic(panicValue interface{}) bool { - return panicValue != nil && panicValue != ErrAbortHandler -} - -func http2reqGetBody(req *Request) func() (io.ReadCloser, error) { - return req.GetBody -} - -func http2reqBodyIsNoBody(body io.ReadCloser) bool { - return body == NoBody -} - -func http2go18httpNoBody() io.ReadCloser { return NoBody } // for tests only - -func http2configureServer19(s *Server, conf *http2Server) error { - s.RegisterOnShutdown(conf.state.startGracefulShutdown) - return nil -} - var http2DebugGoroutines = os.Getenv("DEBUG_HTTP2_GOROUTINES") == "1" type http2goroutineLock uint64 @@ -3252,12 +3025,17 @@ func http2cutoff64(base int) uint64 { } var ( - http2commonLowerHeader = map[string]string{} // Go-Canonical-Case -> lower-case - http2commonCanonHeader = map[string]string{} // lower-case -> Go-Canonical-Case + http2commonBuildOnce sync.Once + http2commonLowerHeader map[string]string // Go-Canonical-Case -> lower-case + http2commonCanonHeader map[string]string // lower-case -> Go-Canonical-Case ) -func init() { - for _, v := range []string{ +func http2buildCommonHeaderMapsOnce() { + http2commonBuildOnce.Do(http2buildCommonHeaderMaps) +} + +func http2buildCommonHeaderMaps() { + common := []string{ "accept", "accept-charset", "accept-encoding", @@ -3305,7 +3083,10 @@ func init() { "vary", "via", "www-authenticate", - } { + } + http2commonLowerHeader = make(map[string]string, len(common)) + http2commonCanonHeader = make(map[string]string, len(common)) + for _, v := range common { chk := CanonicalHeaderKey(v) http2commonLowerHeader[chk] = v http2commonCanonHeader[v] = chk @@ -3313,6 +3094,7 @@ func init() { } func http2lowerHeader(v string) string { + http2buildCommonHeaderMapsOnce() if s, ok := http2commonLowerHeader[v]; ok { return s } @@ -3488,19 +3270,12 @@ func http2validWireHeaderFieldName(v string) bool { return true } -var http2httpCodeStringCommon = map[int]string{} // n -> strconv.Itoa(n) - -func init() { - for i := 100; i <= 999; i++ { - if v := StatusText(i); v != "" { - http2httpCodeStringCommon[i] = strconv.Itoa(i) - } - } -} - func http2httpCodeString(code int) string { - if s, ok := http2httpCodeStringCommon[code]; ok { - return s + switch code { + case 200: + return "200" + case 404: + return "404" } return strconv.Itoa(code) } @@ -3993,12 +3768,14 @@ func http2ConfigureServer(s *Server, conf *http2Server) error { conf = new(http2Server) } conf.state = &http2serverInternalState{activeConns: make(map[*http2serverConn]struct{})} - if err := http2configureServer18(s, conf); err != nil { - return err - } - if err := http2configureServer19(s, conf); err != nil { - return err + if h1, h2 := s, conf; h2.IdleTimeout == 0 { + if h1.IdleTimeout != 0 { + h2.IdleTimeout = h1.IdleTimeout + } else { + h2.IdleTimeout = h1.ReadTimeout + } } + s.RegisterOnShutdown(conf.state.startGracefulShutdown) if s.TLSConfig == nil { s.TLSConfig = new(tls.Config) @@ -4219,6 +3996,15 @@ func (s *http2Server) ServeConn(c net.Conn, opts *http2ServeConnOpts) { sc.serve() } +func http2serverConnBaseContext(c net.Conn, opts *http2ServeConnOpts) (ctx context.Context, cancel func()) { + ctx, cancel = context.WithCancel(context.Background()) + ctx = context.WithValue(ctx, LocalAddrContextKey, c.LocalAddr()) + if hs := opts.baseConfig(); hs != nil { + ctx = context.WithValue(ctx, ServerContextKey, hs) + } + return +} + func (sc *http2serverConn) rejectConn(err http2ErrCode, debug string) { sc.vlogf("http2: server rejecting conn: %v, %s", err, debug) // ignoring errors. hanging up anyway. @@ -4234,7 +4020,7 @@ type http2serverConn struct { conn net.Conn bw *http2bufferedWriter // writing to conn handler Handler - baseCtx http2contextContext + baseCtx context.Context framer *http2Framer doneServing chan struct{} // closed when serverConn.serve ends readFrameCh chan http2readFrameResult // written by serverConn.readFrames @@ -4314,7 +4100,7 @@ type http2stream struct { id uint32 body *http2pipe // non-nil if expecting DATA frames cw http2closeWaiter // closed wait stream transitions to closed state - ctx http2contextContext + ctx context.Context cancelCtx func() // owned by serverConn's serve loop: @@ -4450,6 +4236,7 @@ func (sc *http2serverConn) condlogf(err error, format string, args ...interface{ func (sc *http2serverConn) canonicalHeader(v string) string { sc.serveG.check() + http2buildCommonHeaderMapsOnce() cv, ok := http2commonCanonHeader[v] if ok { return cv @@ -4898,7 +4685,7 @@ func (sc *http2serverConn) startFrameWrite(wr http2FrameWriteRequest) { // errHandlerPanicked is the error given to any callers blocked in a read from // Request.Body when the main goroutine panics. Since most handlers read in the -// the main ServeHTTP goroutine, this will show up rarely. +// main ServeHTTP goroutine, this will show up rarely. var http2errHandlerPanicked = errors.New("http2: handler panicked") // wroteFrame is called on the serve goroutine with the result of @@ -5065,7 +4852,7 @@ func (sc *http2serverConn) resetStream(se http2StreamError) { // processFrameFromReader processes the serve loop's read from readFrameCh from the // frame-reading goroutine. -// processFrameFromReader returns whether the connection should be kept open. +// processFrameFromReader reports whether the connection should be kept open. func (sc *http2serverConn) processFrameFromReader(res http2readFrameResult) bool { sc.serveG.check() err := res.err @@ -5670,7 +5457,7 @@ func (sc *http2serverConn) newStream(id, pusherID uint32, state http2streamState panic("internal error: cannot create stream with id 0") } - ctx, cancelCtx := http2contextWithCancel(sc.baseCtx) + ctx, cancelCtx := context.WithCancel(sc.baseCtx) st := &http2stream{ sc: sc, id: id, @@ -5836,7 +5623,7 @@ func (sc *http2serverConn) newWriterAndRequestNoBody(st *http2stream, rp http2re Body: body, Trailer: trailer, } - req = http2requestWithContext(req, st.ctx) + req = req.WithContext(st.ctx) rws := http2responseWriterStatePool.Get().(*http2responseWriterState) bwSave := rws.bw @@ -5864,7 +5651,7 @@ func (sc *http2serverConn) runHandler(rw *http2responseWriter, req *Request, han stream: rw.rws.stream, }) // Same as net/http: - if http2shouldLogPanic(e) { + if e != nil && e != ErrAbortHandler { const size = 64 << 10 buf := make([]byte, size) buf = buf[:runtime.Stack(buf, false)] @@ -6426,14 +6213,9 @@ var ( http2ErrPushLimitReached = errors.New("http2: push would exceed peer's SETTINGS_MAX_CONCURRENT_STREAMS") ) -// pushOptions is the internal version of http.PushOptions, which we -// cannot include here because it's only defined in Go 1.8 and later. -type http2pushOptions struct { - Method string - Header Header -} +var _ Pusher = (*http2responseWriter)(nil) -func (w *http2responseWriter) push(target string, opts http2pushOptions) error { +func (w *http2responseWriter) Push(target string, opts *PushOptions) error { st := w.rws.stream sc := st.sc sc.serveG.checkNotOn() @@ -6444,6 +6226,10 @@ func (w *http2responseWriter) push(target string, opts http2pushOptions) error { return http2ErrRecursivePush } + if opts == nil { + opts = new(PushOptions) + } + // Default options. if opts.Method == "" { opts.Method = "GET" @@ -6739,6 +6525,16 @@ type http2Transport struct { // to mean no limit. MaxHeaderListSize uint32 + // StrictMaxConcurrentStreams controls whether the server's + // SETTINGS_MAX_CONCURRENT_STREAMS should be respected + // globally. If false, new TCP connections are created to the + // server as needed to keep each under the per-connection + // SETTINGS_MAX_CONCURRENT_STREAMS limit. If true, the + // server's SETTINGS_MAX_CONCURRENT_STREAMS is interpreted as + // a global limit and callers of RoundTrip block when needed, + // waiting for their turn. + StrictMaxConcurrentStreams bool + // t1, if non-nil, is the standard library Transport using // this transport. Its settings are used (but not its // RoundTrip method, etc). @@ -6762,16 +6558,56 @@ func (t *http2Transport) disableCompression() bool { return t.DisableCompression || (t.t1 != nil && t.t1.DisableCompression) } -var http2errTransportVersion = errors.New("http2: ConfigureTransport is only supported starting at Go 1.6") - // ConfigureTransport configures a net/http HTTP/1 Transport to use HTTP/2. -// It requires Go 1.6 or later and returns an error if the net/http package is too old -// or if t1 has already been HTTP/2-enabled. +// It returns an error if t1 has already been HTTP/2-enabled. func http2ConfigureTransport(t1 *Transport) error { - _, err := http2configureTransport(t1) // in configure_transport.go (go1.6) or not_go16.go + _, err := http2configureTransport(t1) return err } +func http2configureTransport(t1 *Transport) (*http2Transport, error) { + connPool := new(http2clientConnPool) + t2 := &http2Transport{ + ConnPool: http2noDialClientConnPool{connPool}, + t1: t1, + } + connPool.t = t2 + if err := http2registerHTTPSProtocol(t1, http2noDialH2RoundTripper{t2}); err != nil { + return nil, err + } + if t1.TLSClientConfig == nil { + t1.TLSClientConfig = new(tls.Config) + } + if !http2strSliceContains(t1.TLSClientConfig.NextProtos, "h2") { + t1.TLSClientConfig.NextProtos = append([]string{"h2"}, t1.TLSClientConfig.NextProtos...) + } + if !http2strSliceContains(t1.TLSClientConfig.NextProtos, "http/1.1") { + t1.TLSClientConfig.NextProtos = append(t1.TLSClientConfig.NextProtos, "http/1.1") + } + upgradeFn := func(authority string, c *tls.Conn) RoundTripper { + addr := http2authorityAddr("https", authority) + if used, err := connPool.addConnIfNeeded(addr, t2, c); err != nil { + go c.Close() + return http2erringRoundTripper{err} + } else if !used { + // Turns out we don't need this c. + // For example, two goroutines made requests to the same host + // at the same time, both kicking off TCP dials. (since protocol + // was unknown) + go c.Close() + } + return t2 + } + if m := t1.TLSNextProto; len(m) == 0 { + t1.TLSNextProto = map[string]func(string, *tls.Conn) RoundTripper{ + "h2": upgradeFn, + } + } else { + m["h2"] = upgradeFn + } + return t2, nil +} + func (t *http2Transport) connPool() http2ClientConnPool { t.connPoolOnce.Do(t.initConnPool) return t.connPoolOrDef @@ -6836,7 +6672,7 @@ type http2ClientConn struct { type http2clientStream struct { cc *http2ClientConn req *Request - trace *http2clientTrace // or nil + trace *httptrace.ClientTrace // or nil ID uint32 resc chan http2resAndError bufPipe http2pipe // buffered pipe with the flow-controlled response payload @@ -6870,7 +6706,7 @@ type http2clientStream struct { // channel to be signaled. A non-nil error is returned only if the request was // canceled. func http2awaitRequestCancel(req *Request, done <-chan struct{}) error { - ctx := http2reqContext(req) + ctx := req.Context() if req.Cancel == nil && ctx.Done() == nil { return nil } @@ -7046,8 +6882,8 @@ func (t *http2Transport) RoundTripOpt(req *Request, opt http2RoundTripOpt) (*Res select { case <-time.After(time.Second * time.Duration(backoff)): continue - case <-http2reqContext(req).Done(): - return nil, http2reqContext(req).Err() + case <-req.Context().Done(): + return nil, req.Context().Err() } } } @@ -7084,16 +6920,15 @@ func http2shouldRetryRequest(req *Request, err error, afterBodyWrite bool) (*Req } // If the Body is nil (or http.NoBody), it's safe to reuse // this request and its Body. - if req.Body == nil || http2reqBodyIsNoBody(req.Body) { + if req.Body == nil || req.Body == NoBody { return req, nil } // If the request body can be reset back to its original // state via the optional req.GetBody, do that. - getBody := http2reqGetBody(req) // Go 1.8: getBody = req.GetBody - if getBody != nil { + if req.GetBody != nil { // TODO: consider a req.Body.Close here? or audit that all caller paths do? - body, err := getBody() + body, err := req.GetBody() if err != nil { return nil, err } @@ -7139,7 +6974,7 @@ func (t *http2Transport) dialClientConn(addr string, singleUse bool) (*http2Clie func (t *http2Transport) newTLSConfig(host string) *tls.Config { cfg := new(tls.Config) if t.TLSClientConfig != nil { - *cfg = *http2cloneTLSConfig(t.TLSClientConfig) + *cfg = *t.TLSClientConfig.Clone() } if !http2strSliceContains(cfg.NextProtos, http2NextProtoTLS) { cfg.NextProtos = append([]string{http2NextProtoTLS}, cfg.NextProtos...) @@ -7190,7 +7025,7 @@ func (t *http2Transport) expectContinueTimeout() time.Duration { if t.t1 == nil { return 0 } - return http2transportExpectContinueTimeout(t.t1) + return t.t1.ExpectContinueTimeout } func (t *http2Transport) NewClientConn(c net.Conn) (*http2ClientConn, error) { @@ -7315,8 +7150,19 @@ func (cc *http2ClientConn) idleStateLocked() (st http2clientConnIdleState) { if cc.singleUse && cc.nextStreamID > 1 { return } - st.canTakeNewRequest = cc.goAway == nil && !cc.closed && !cc.closing && - int64(cc.nextStreamID)+int64(cc.pendingRequests) < math.MaxInt32 + var maxConcurrentOkay bool + if cc.t.StrictMaxConcurrentStreams { + // We'll tell the caller we can take a new request to + // prevent the caller from dialing a new TCP + // connection, but then we'll block later before + // writing it. + maxConcurrentOkay = true + } else { + maxConcurrentOkay = int64(len(cc.streams)+1) < int64(cc.maxConcurrentStreams) + } + + st.canTakeNewRequest = cc.goAway == nil && !cc.closed && !cc.closing && maxConcurrentOkay && + int64(cc.nextStreamID)+2*int64(cc.pendingRequests) < math.MaxInt32 st.freshConn = cc.nextStreamID == 1 && st.canTakeNewRequest return } @@ -7356,8 +7202,7 @@ func (cc *http2ClientConn) closeIfIdle() { var http2shutdownEnterWaitStateHook = func() {} // Shutdown gracefully close the client connection, waiting for running streams to complete. -// Public implementation is in go17.go and not_go17.go -func (cc *http2ClientConn) shutdown(ctx http2contextContext) error { +func (cc *http2ClientConn) Shutdown(ctx context.Context) error { if err := cc.sendGoAway(); err != nil { return err } @@ -7527,7 +7372,7 @@ func http2checkConnHeaders(req *Request) error { // req.ContentLength, where 0 actually means zero (not unknown) and -1 // means unknown. func http2actualContentLength(req *Request) int64 { - if req.Body == nil || http2reqBodyIsNoBody(req.Body) { + if req.Body == nil || req.Body == NoBody { return 0 } if req.ContentLength != 0 { @@ -7597,7 +7442,7 @@ func (cc *http2ClientConn) roundTrip(req *Request) (res *Response, gotErrAfterRe cs := cc.newStream() cs.req = req - cs.trace = http2requestTrace(req) + cs.trace = httptrace.ContextClientTrace(req.Context()) cs.requestedGzip = requestedGzip bodyWriter := cc.t.getBodyWriterState(cs, body) cs.on100 = bodyWriter.on100 @@ -7635,7 +7480,7 @@ func (cc *http2ClientConn) roundTrip(req *Request) (res *Response, gotErrAfterRe readLoopResCh := cs.resc bodyWritten := false - ctx := http2reqContext(req) + ctx := req.Context() handleReadLoopResponse := func(re http2resAndError) (*Response, bool, error) { res := re.res @@ -7720,6 +7565,7 @@ func (cc *http2ClientConn) roundTrip(req *Request) (res *Response, gotErrAfterRe default: } if err != nil { + cc.forgetStreamID(cs.ID) return nil, cs.getStartedWrite(), err } bodyWritten = true @@ -7841,6 +7687,7 @@ func (cs *http2clientStream) writeRequestBody(body io.Reader, bodyCloser io.Clos sawEOF = true err = nil } else if err != nil { + cc.writeStreamReset(cs.ID, http2ErrCodeCancel, err) return err } @@ -8076,7 +7923,7 @@ func (cc *http2ClientConn) encodeHeaders(req *Request, addGzipHeader bool, trail return nil, http2errRequestHeaderListSize } - trace := http2requestTrace(req) + trace := httptrace.ContextClientTrace(req.Context()) traceHeaders := http2traceHasWroteHeaderField(trace) // Header list size is ok. Write the headers. @@ -8499,7 +8346,7 @@ func (rl *http2clientConnReadLoop) handleResponse(cs *http2clientStream, f *http res.Header.Del("Content-Length") res.ContentLength = -1 res.Body = &http2gzipReader{body: res.Body} - http2setResponseUncompressed(res) + res.Uncompressed = true } return res, nil } @@ -8876,8 +8723,7 @@ func (rl *http2clientConnReadLoop) processResetStream(f *http2RSTStreamFrame) er } // Ping sends a PING frame to the server and waits for the ack. -// Public implementation is in go17.go and not_go17.go -func (cc *http2ClientConn) ping(ctx http2contextContext) error { +func (cc *http2ClientConn) Ping(ctx context.Context) error { c := make(chan struct{}) // Generate a random payload var p [8]byte @@ -9112,6 +8958,94 @@ func http2isConnectionCloseRequest(req *Request) bool { return req.Close || httpguts.HeaderValuesContainsToken(req.Header["Connection"], "close") } +// registerHTTPSProtocol calls Transport.RegisterProtocol but +// converting panics into errors. +func http2registerHTTPSProtocol(t *Transport, rt http2noDialH2RoundTripper) (err error) { + defer func() { + if e := recover(); e != nil { + err = fmt.Errorf("%v", e) + } + }() + t.RegisterProtocol("https", rt) + return nil +} + +// noDialH2RoundTripper is a RoundTripper which only tries to complete the request +// if there's already has a cached connection to the host. +// (The field is exported so it can be accessed via reflect from net/http; tested +// by TestNoDialH2RoundTripperType) +type http2noDialH2RoundTripper struct{ *http2Transport } + +func (rt http2noDialH2RoundTripper) RoundTrip(req *Request) (*Response, error) { + res, err := rt.http2Transport.RoundTrip(req) + if http2isNoCachedConnError(err) { + return nil, ErrSkipAltProtocol + } + return res, err +} + +func (t *http2Transport) idleConnTimeout() time.Duration { + if t.t1 != nil { + return t.t1.IdleConnTimeout + } + return 0 +} + +func http2traceGetConn(req *Request, hostPort string) { + trace := httptrace.ContextClientTrace(req.Context()) + if trace == nil || trace.GetConn == nil { + return + } + trace.GetConn(hostPort) +} + +func http2traceGotConn(req *Request, cc *http2ClientConn) { + trace := httptrace.ContextClientTrace(req.Context()) + if trace == nil || trace.GotConn == nil { + return + } + ci := httptrace.GotConnInfo{Conn: cc.tconn} + cc.mu.Lock() + ci.Reused = cc.nextStreamID > 1 + ci.WasIdle = len(cc.streams) == 0 && ci.Reused + if ci.WasIdle && !cc.lastActive.IsZero() { + ci.IdleTime = time.Now().Sub(cc.lastActive) + } + cc.mu.Unlock() + + trace.GotConn(ci) +} + +func http2traceWroteHeaders(trace *httptrace.ClientTrace) { + if trace != nil && trace.WroteHeaders != nil { + trace.WroteHeaders() + } +} + +func http2traceGot100Continue(trace *httptrace.ClientTrace) { + if trace != nil && trace.Got100Continue != nil { + trace.Got100Continue() + } +} + +func http2traceWait100Continue(trace *httptrace.ClientTrace) { + if trace != nil && trace.Wait100Continue != nil { + trace.Wait100Continue() + } +} + +func http2traceWroteRequest(trace *httptrace.ClientTrace, err error) { + if trace != nil && trace.WroteRequest != nil { + trace.WroteRequest(httptrace.WroteRequestInfo{Err: err}) + } +} + +func http2traceFirstResponseByte(trace *httptrace.ClientTrace) { + if trace != nil && trace.GotFirstResponseByte != nil { + trace.GotFirstResponseByte() + } +} + // writeFramer is implemented by any type that is used to write frames. type http2writeFramer interface { writeFrame(http2writeContext) error @@ -9298,7 +9232,7 @@ func (w *http2writeResHeaders) staysWithinBuffer(max int) bool { // TODO: this is a common one. It'd be nice to return true // here and get into the fast path if we could be clever and // calculate the size fast enough, or at least a conservative - // uppper bound that usually fires. (Maybe if w.h and + // upper bound that usually fires. (Maybe if w.h and // w.trailers are nil, so we don't need to enumerate it.) // Otherwise I'm afraid that just calculating the length to // answer this question would be slower than the ~2µs benefit. @@ -9428,7 +9362,7 @@ func (wu http2writeWindowUpdate) writeFrame(ctx http2writeContext) error { } // encodeHeaders encodes an http.Header. If keys is not nil, then (k, h[k]) -// is encoded only only if k is in keys. +// is encoded only if k is in keys. func http2encodeHeaders(enc *hpack.Encoder, h Header, keys []string) { if keys == nil { sorter := http2sorterPool.Get().(*http2sorter) diff --git a/libgo/go/net/http/header.go b/libgo/go/net/http/header.go index 461ae9368ac..b699e7ef8ff 100644 --- a/libgo/go/net/http/header.go +++ b/libgo/go/net/http/header.go @@ -14,30 +14,35 @@ import ( "time" ) -var raceEnabled = false // set by race.go - // A Header represents the key-value pairs in an HTTP header. +// +// The keys should be in canonical form, as returned by +// CanonicalHeaderKey. type Header map[string][]string // Add adds the key, value pair to the header. // It appends to any existing values associated with key. +// The key is case insensitive; it is canonicalized by +// CanonicalHeaderKey. func (h Header) Add(key, value string) { textproto.MIMEHeader(h).Add(key, value) } -// Set sets the header entries associated with key to -// the single element value. It replaces any existing -// values associated with key. +// Set sets the header entries associated with key to the +// single element value. It replaces any existing values +// associated with key. The key is case insensitive; it is +// canonicalized by textproto.CanonicalMIMEHeaderKey. +// To use non-canonical keys, assign to the map directly. func (h Header) Set(key, value string) { textproto.MIMEHeader(h).Set(key, value) } -// Get gets the first value associated with the given key. -// It is case insensitive; textproto.CanonicalMIMEHeaderKey is used -// to canonicalize the provided key. -// If there are no values associated with the key, Get returns "". -// To access multiple values of a key, or to use non-canonical keys, -// access the map directly. +// Get gets the first value associated with the given key. If +// there are no values associated with the key, Get returns "". +// It is case insensitive; textproto.CanonicalMIMEHeaderKey is +// used to canonicalize the provided key. To access multiple +// values of a key, or to use non-canonical keys, access the +// map directly. func (h Header) Get(key string) string { return textproto.MIMEHeader(h).Get(key) } @@ -50,7 +55,16 @@ func (h Header) get(key string) string { return "" } +// has reports whether h has the provided key defined, even if it's +// set to 0-length slice. +func (h Header) has(key string) bool { + _, ok := h[key] + return ok +} + // Del deletes the values associated with key. +// The key is case insensitive; it is canonicalized by +// CanonicalHeaderKey. func (h Header) Del(key string) { textproto.MIMEHeader(h).Del(key) } @@ -95,10 +109,6 @@ func ParseTime(text string) (t time.Time, err error) { var headerNewlineToSpace = strings.NewReplacer("\n", " ", "\r", " ") -type writeStringer interface { - WriteString(string) (int, error) -} - // stringWriter implements WriteString on a Writer. type stringWriter struct { w io.Writer @@ -154,7 +164,7 @@ func (h Header) WriteSubset(w io.Writer, exclude map[string]bool) error { } func (h Header) writeSubset(w io.Writer, exclude map[string]bool, trace *httptrace.ClientTrace) error { - ws, ok := w.(writeStringer) + ws, ok := w.(io.StringWriter) if !ok { ws = stringWriter{w} } @@ -231,13 +241,3 @@ func hasToken(v, token string) bool { func isTokenBoundary(b byte) bool { return b == ' ' || b == ',' || b == '\t' } - -func cloneHeader(h Header) Header { - h2 := make(Header, len(h)) - for k, vv := range h { - vv2 := make([]string, len(vv)) - copy(vv2, vv) - h2[k] = vv2 - } - return h2 -} diff --git a/libgo/go/net/http/header_test.go b/libgo/go/net/http/header_test.go index 5c0de15b731..7595fb7f0ea 100644 --- a/libgo/go/net/http/header_test.go +++ b/libgo/go/net/http/header_test.go @@ -6,6 +6,7 @@ package http import ( "bytes" + "internal/race" "runtime" "testing" "time" @@ -196,7 +197,7 @@ func TestHeaderWriteSubsetAllocs(t *testing.T) { if testing.Short() { t.Skip("skipping alloc test in short mode") } - if raceEnabled { + if race.Enabled { t.Skip("skipping test under race detector") } t.Skip("Skipping alloc count test on gccgo") diff --git a/libgo/go/net/http/http.go b/libgo/go/net/http/http.go index ce0eceb1de3..624b2cfe695 100644 --- a/libgo/go/net/http/http.go +++ b/libgo/go/net/http/http.go @@ -11,7 +11,7 @@ import ( "time" "unicode/utf8" - "golang_org/x/net/http/httpguts" + "internal/x/net/http/httpguts" ) // maxInt64 is the effective "infinite" value for the Server and @@ -135,6 +135,10 @@ type Pusher interface { // data that may trigger a request for URL X. This avoids a race where the // client issues requests for X before receiving the PUSH_PROMISE for X. // + // Push will run in a separate goroutine making the order of arrival + // non-deterministic. Any required synchronization needs to be implemented + // by the caller. + // // Push returns ErrNotSupported if the client has disabled push or if push // is not supported on the underlying connection. Push(target string, opts *PushOptions) error diff --git a/libgo/go/net/http/httptest/recorder.go b/libgo/go/net/http/httptest/recorder.go index 67f90b83769..f2c3c0757ba 100644 --- a/libgo/go/net/http/httptest/recorder.go +++ b/libgo/go/net/http/httptest/recorder.go @@ -12,7 +12,7 @@ import ( "strconv" "strings" - "golang_org/x/net/http/httpguts" + "internal/x/net/http/httpguts" ) // ResponseRecorder is an implementation of http.ResponseWriter that diff --git a/libgo/go/net/http/httptest/server.go b/libgo/go/net/http/httptest/server.go index f6bcf3abc39..485a4a5797e 100644 --- a/libgo/go/net/http/httptest/server.go +++ b/libgo/go/net/http/httptest/server.go @@ -53,10 +53,10 @@ type Server struct { } func newLocalListener() net.Listener { - if *serve != "" { - l, err := net.Listen("tcp", *serve) + if serveFlag != "" { + l, err := net.Listen("tcp", serveFlag) if err != nil { - panic(fmt.Sprintf("httptest: failed to listen on %v: %v", *serve, err)) + panic(fmt.Sprintf("httptest: failed to listen on %v: %v", serveFlag, err)) } return l } @@ -73,7 +73,25 @@ func newLocalListener() net.Listener { // this flag lets you run // go test -run=BrokenTest -httptest.serve=127.0.0.1:8000 // to start the broken server so you can interact with it manually. -var serve = flag.String("httptest.serve", "", "if non-empty, httptest.NewServer serves on this address and blocks") +// We only register this flag if it looks like the caller knows about it +// and is trying to use it as we don't want to pollute flags and this +// isn't really part of our API. Don't depend on this. +var serveFlag string + +func init() { + if strSliceContainsPrefix(os.Args, "-httptest.serve=") || strSliceContainsPrefix(os.Args, "--httptest.serve=") { + flag.StringVar(&serveFlag, "httptest.serve", "", "if non-empty, httptest.NewServer serves on this address and blocks.") + } +} + +func strSliceContainsPrefix(v []string, pre string) bool { + for _, s := range v { + if strings.HasPrefix(s, pre) { + return true + } + } + return false +} // NewServer starts and returns a new Server. // The caller should call Close when finished, to shut it down. @@ -107,7 +125,7 @@ func (s *Server) Start() { s.URL = "http://" + s.Listener.Addr().String() s.wrap() s.goServe() - if *serve != "" { + if serveFlag != "" { fmt.Fprintln(os.Stderr, "httptest: serving on", s.URL) select {} } diff --git a/libgo/go/net/http/httputil/dump_test.go b/libgo/go/net/http/httputil/dump_test.go index 5703a7fb866..63312dd8856 100644 --- a/libgo/go/net/http/httputil/dump_test.go +++ b/libgo/go/net/http/httputil/dump_test.go @@ -370,7 +370,7 @@ func TestDumpResponse(t *testing.T) { } got := string(gotb) got = strings.TrimSpace(got) - got = strings.Replace(got, "\r", "", -1) + got = strings.ReplaceAll(got, "\r", "") if got != tt.want { t.Errorf("%d.\nDumpResponse got:\n%s\n\nWant:\n%s\n", i, got, tt.want) diff --git a/libgo/go/net/http/httputil/reverseproxy.go b/libgo/go/net/http/httputil/reverseproxy.go index 1dddaa95a77..4e10bf39971 100644 --- a/libgo/go/net/http/httputil/reverseproxy.go +++ b/libgo/go/net/http/httputil/reverseproxy.go @@ -8,6 +8,7 @@ package httputil import ( "context" + "fmt" "io" "log" "net" @@ -16,11 +17,9 @@ import ( "strings" "sync" "time" -) -// onExitFlushLoop is a callback set by tests to detect the state of the -// flushLoop() goroutine. -var onExitFlushLoop func() + "internal/x/net/http/httpguts" +) // ReverseProxy is an HTTP Handler that takes an incoming request and // sends it to another server, proxying the response back to the @@ -42,6 +41,12 @@ type ReverseProxy struct { // to flush to the client while copying the // response body. // If zero, no periodic flushing is done. + // A negative value means to flush immediately + // after each write to the client. + // The FlushInterval is ignored when ReverseProxy + // recognizes a response as a streaming response; + // for such responses, writes are flushed to the client + // immediately. FlushInterval time.Duration // ErrorLog specifies an optional logger for errors @@ -166,6 +171,20 @@ func (p *ReverseProxy) getErrorHandler() func(http.ResponseWriter, *http.Request return p.defaultErrorHandler } +// modifyResponse conditionally runs the optional ModifyResponse hook +// and reports whether the request should proceed. +func (p *ReverseProxy) modifyResponse(rw http.ResponseWriter, res *http.Response, req *http.Request) bool { + if p.ModifyResponse == nil { + return true + } + if err := p.ModifyResponse(res); err != nil { + res.Body.Close() + p.getErrorHandler()(rw, req, err) + return false + } + return true +} + func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) { transport := p.Transport if transport == nil { @@ -197,6 +216,7 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) { p.Director(outreq) outreq.Close = false + reqUpType := upgradeType(outreq.Header) removeConnectionHeaders(outreq.Header) // Remove hop-by-hop headers to the backend. Especially @@ -219,6 +239,13 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) { outreq.Header.Del(h) } + // After stripping all the hop-by-hop connection headers above, add back any + // necessary for protocol upgrades, such as for websockets. + if reqUpType != "" { + outreq.Header.Set("Connection", "Upgrade") + outreq.Header.Set("Upgrade", reqUpType) + } + if clientIP, _, err := net.SplitHostPort(req.RemoteAddr); err == nil { // If we aren't the first proxy retain prior // X-Forwarded-For information as a comma+space @@ -235,18 +262,23 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) { return } + // Deal with 101 Switching Protocols responses: (WebSocket, h2c, etc) + if res.StatusCode == http.StatusSwitchingProtocols { + if !p.modifyResponse(rw, res, outreq) { + return + } + p.handleUpgradeResponse(rw, outreq, res) + return + } + removeConnectionHeaders(res.Header) for _, h := range hopHeaders { res.Header.Del(h) } - if p.ModifyResponse != nil { - if err := p.ModifyResponse(res); err != nil { - res.Body.Close() - p.getErrorHandler()(rw, outreq, err) - return - } + if !p.modifyResponse(rw, res, outreq) { + return } copyHeader(rw.Header(), res.Header) @@ -263,15 +295,8 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) { } rw.WriteHeader(res.StatusCode) - if len(res.Trailer) > 0 { - // Force chunking if we saw a response trailer. - // This prevents net/http from calculating the length for short - // bodies and adding a Content-Length. - if fl, ok := rw.(http.Flusher); ok { - fl.Flush() - } - } - err = p.copyResponse(rw, res.Body) + + err = p.copyResponse(rw, res.Body, p.flushInterval(req, res)) if err != nil { defer res.Body.Close() // Since we're streaming the response, if we run into an error all we can do @@ -285,6 +310,15 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) { } res.Body.Close() // close now, instead of defer, to populate res.Trailer + if len(res.Trailer) > 0 { + // Force chunking if we saw a response trailer. + // This prevents net/http from calculating the length for short + // bodies and adding a Content-Length. + if fl, ok := rw.(http.Flusher); ok { + fl.Flush() + } + } + if len(res.Trailer) == announcedTrailers { copyHeader(rw.Header(), res.Trailer) return @@ -332,15 +366,28 @@ func removeConnectionHeaders(h http.Header) { } } -func (p *ReverseProxy) copyResponse(dst io.Writer, src io.Reader) error { - if p.FlushInterval != 0 { +// flushInterval returns the p.FlushInterval value, conditionally +// overriding its value for a specific request/response. +func (p *ReverseProxy) flushInterval(req *http.Request, res *http.Response) time.Duration { + resCT := res.Header.Get("Content-Type") + + // For Server-Sent Events responses, flush immediately. + // The MIME type is defined in https://www.w3.org/TR/eventsource/#text-event-stream + if resCT == "text/event-stream" { + return -1 // negative means immediately + } + + // TODO: more specific cases? e.g. res.ContentLength == -1? + return p.FlushInterval +} + +func (p *ReverseProxy) copyResponse(dst io.Writer, src io.Reader, flushInterval time.Duration) error { + if flushInterval != 0 { if wf, ok := dst.(writeFlusher); ok { mlw := &maxLatencyWriter{ dst: wf, - latency: p.FlushInterval, - done: make(chan bool), + latency: flushInterval, } - go mlw.flushLoop() defer mlw.stop() dst = mlw } @@ -403,34 +450,115 @@ type writeFlusher interface { type maxLatencyWriter struct { dst writeFlusher - latency time.Duration + latency time.Duration // non-zero; negative means to flush immediately - mu sync.Mutex // protects Write + Flush - done chan bool + mu sync.Mutex // protects t, flushPending, and dst.Flush + t *time.Timer + flushPending bool } -func (m *maxLatencyWriter) Write(p []byte) (int, error) { +func (m *maxLatencyWriter) Write(p []byte) (n int, err error) { m.mu.Lock() defer m.mu.Unlock() - return m.dst.Write(p) + n, err = m.dst.Write(p) + if m.latency < 0 { + m.dst.Flush() + return + } + if m.flushPending { + return + } + if m.t == nil { + m.t = time.AfterFunc(m.latency, m.delayedFlush) + } else { + m.t.Reset(m.latency) + } + m.flushPending = true + return } -func (m *maxLatencyWriter) flushLoop() { - t := time.NewTicker(m.latency) - defer t.Stop() - for { - select { - case <-m.done: - if onExitFlushLoop != nil { - onExitFlushLoop() - } - return - case <-t.C: - m.mu.Lock() - m.dst.Flush() - m.mu.Unlock() - } +func (m *maxLatencyWriter) delayedFlush() { + m.mu.Lock() + defer m.mu.Unlock() + if !m.flushPending { // if stop was called but AfterFunc already started this goroutine + return } + m.dst.Flush() + m.flushPending = false } -func (m *maxLatencyWriter) stop() { m.done <- true } +func (m *maxLatencyWriter) stop() { + m.mu.Lock() + defer m.mu.Unlock() + m.flushPending = false + if m.t != nil { + m.t.Stop() + } +} + +func upgradeType(h http.Header) string { + if !httpguts.HeaderValuesContainsToken(h["Connection"], "Upgrade") { + return "" + } + return strings.ToLower(h.Get("Upgrade")) +} + +func (p *ReverseProxy) handleUpgradeResponse(rw http.ResponseWriter, req *http.Request, res *http.Response) { + reqUpType := upgradeType(req.Header) + resUpType := upgradeType(res.Header) + if reqUpType != resUpType { + p.getErrorHandler()(rw, req, fmt.Errorf("backend tried to switch protocol %q when %q was requested", resUpType, reqUpType)) + return + } + + copyHeader(res.Header, rw.Header()) + + hj, ok := rw.(http.Hijacker) + if !ok { + p.getErrorHandler()(rw, req, fmt.Errorf("can't switch protocols using non-Hijacker ResponseWriter type %T", rw)) + return + } + backConn, ok := res.Body.(io.ReadWriteCloser) + if !ok { + p.getErrorHandler()(rw, req, fmt.Errorf("internal error: 101 switching protocols response with non-writable body")) + return + } + defer backConn.Close() + conn, brw, err := hj.Hijack() + if err != nil { + p.getErrorHandler()(rw, req, fmt.Errorf("Hijack failed on protocol switch: %v", err)) + return + } + defer conn.Close() + res.Body = nil // so res.Write only writes the headers; we have res.Body in backConn above + if err := res.Write(brw); err != nil { + p.getErrorHandler()(rw, req, fmt.Errorf("response write: %v", err)) + return + } + if err := brw.Flush(); err != nil { + p.getErrorHandler()(rw, req, fmt.Errorf("response flush: %v", err)) + return + } + errc := make(chan error, 1) + spc := switchProtocolCopier{user: conn, backend: backConn} + go spc.copyToBackend(errc) + go spc.copyFromBackend(errc) + <-errc + return +} + +// switchProtocolCopier exists so goroutines proxying data back and +// forth have nice names in stacks. +type switchProtocolCopier struct { + user, backend io.ReadWriter +} + +func (c switchProtocolCopier) copyFromBackend(errc chan<- error) { + _, err := io.Copy(c.user, c.backend) + errc <- err +} + +func (c switchProtocolCopier) copyToBackend(errc chan<- error) { + _, err := io.Copy(c.backend, c.user) + errc <- err +} diff --git a/libgo/go/net/http/httputil/reverseproxy_test.go b/libgo/go/net/http/httputil/reverseproxy_test.go index 2f75b4e34ec..5edefa08e55 100644 --- a/libgo/go/net/http/httputil/reverseproxy_test.go +++ b/libgo/go/net/http/httputil/reverseproxy_test.go @@ -153,15 +153,20 @@ func TestReverseProxy(t *testing.T) { func TestReverseProxyStripHeadersPresentInConnection(t *testing.T) { const fakeConnectionToken = "X-Fake-Connection-Token" const backendResponse = "I am the backend" + + // someConnHeader is some arbitrary header to be declared as a hop-by-hop header + // in the Request's Connection header. + const someConnHeader = "X-Some-Conn-Header" + backend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if c := r.Header.Get(fakeConnectionToken); c != "" { t.Errorf("handler got header %q = %q; want empty", fakeConnectionToken, c) } - if c := r.Header.Get("Upgrade"); c != "" { - t.Errorf("handler got header %q = %q; want empty", "Upgrade", c) + if c := r.Header.Get(someConnHeader); c != "" { + t.Errorf("handler got header %q = %q; want empty", someConnHeader, c) } - w.Header().Set("Connection", "Upgrade, "+fakeConnectionToken) - w.Header().Set("Upgrade", "should be deleted") + w.Header().Set("Connection", someConnHeader+", "+fakeConnectionToken) + w.Header().Set(someConnHeader, "should be deleted") w.Header().Set(fakeConnectionToken, "should be deleted") io.WriteString(w, backendResponse) })) @@ -173,15 +178,15 @@ func TestReverseProxyStripHeadersPresentInConnection(t *testing.T) { proxyHandler := NewSingleHostReverseProxy(backendURL) frontend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { proxyHandler.ServeHTTP(w, r) - if c := r.Header.Get("Upgrade"); c != "original value" { - t.Errorf("handler modified header %q = %q; want %q", "Upgrade", c, "original value") + if c := r.Header.Get(someConnHeader); c != "original value" { + t.Errorf("handler modified header %q = %q; want %q", someConnHeader, c, "original value") } })) defer frontend.Close() getReq, _ := http.NewRequest("GET", frontend.URL, nil) - getReq.Header.Set("Connection", "Upgrade, "+fakeConnectionToken) - getReq.Header.Set("Upgrade", "original value") + getReq.Header.Set("Connection", someConnHeader+", "+fakeConnectionToken) + getReq.Header.Set(someConnHeader, "original value") getReq.Header.Set(fakeConnectionToken, "should be deleted") res, err := frontend.Client().Do(getReq) if err != nil { @@ -195,8 +200,8 @@ func TestReverseProxyStripHeadersPresentInConnection(t *testing.T) { if got, want := string(bodyBytes), backendResponse; got != want { t.Errorf("got body %q; want %q", got, want) } - if c := res.Header.Get("Upgrade"); c != "" { - t.Errorf("handler got header %q = %q; want empty", "Upgrade", c) + if c := res.Header.Get(someConnHeader); c != "" { + t.Errorf("handler got header %q = %q; want empty", someConnHeader, c) } if c := res.Header.Get(fakeConnectionToken); c != "" { t.Errorf("handler got header %q = %q; want empty", fakeConnectionToken, c) @@ -297,10 +302,6 @@ func TestReverseProxyFlushInterval(t *testing.T) { proxyHandler := NewSingleHostReverseProxy(backendURL) proxyHandler.FlushInterval = time.Microsecond - done := make(chan bool) - onExitFlushLoop = func() { done <- true } - defer func() { onExitFlushLoop = nil }() - frontend := httptest.NewServer(proxyHandler) defer frontend.Close() @@ -314,13 +315,6 @@ func TestReverseProxyFlushInterval(t *testing.T) { if bodyBytes, _ := ioutil.ReadAll(res.Body); string(bodyBytes) != expected { t.Errorf("got body %q; expected %q", bodyBytes, expected) } - - select { - case <-done: - // OK - case <-time.After(5 * time.Second): - t.Error("maxLatencyWriter flushLoop() never exited") - } } func TestReverseProxyCancelation(t *testing.T) { @@ -946,3 +940,184 @@ func TestReverseProxy_PanicBodyError(t *testing.T) { req, _ := http.NewRequest("GET", "http://foo.tld/", nil) rproxy.ServeHTTP(httptest.NewRecorder(), req) } + +func TestSelectFlushInterval(t *testing.T) { + tests := []struct { + name string + p *ReverseProxy + req *http.Request + res *http.Response + want time.Duration + }{ + { + name: "default", + res: &http.Response{}, + p: &ReverseProxy{FlushInterval: 123}, + want: 123, + }, + { + name: "server-sent events overrides non-zero", + res: &http.Response{ + Header: http.Header{ + "Content-Type": {"text/event-stream"}, + }, + }, + p: &ReverseProxy{FlushInterval: 123}, + want: -1, + }, + { + name: "server-sent events overrides zero", + res: &http.Response{ + Header: http.Header{ + "Content-Type": {"text/event-stream"}, + }, + }, + p: &ReverseProxy{FlushInterval: 0}, + want: -1, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got := tt.p.flushInterval(tt.req, tt.res) + if got != tt.want { + t.Errorf("flushLatency = %v; want %v", got, tt.want) + } + }) + } +} + +func TestReverseProxyWebSocket(t *testing.T) { + backendServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if upgradeType(r.Header) != "websocket" { + t.Error("unexpected backend request") + http.Error(w, "unexpected request", 400) + return + } + c, _, err := w.(http.Hijacker).Hijack() + if err != nil { + t.Error(err) + return + } + defer c.Close() + io.WriteString(c, "HTTP/1.1 101 Switching Protocols\r\nConnection: upgrade\r\nUpgrade: WebSocket\r\n\r\n") + bs := bufio.NewScanner(c) + if !bs.Scan() { + t.Errorf("backend failed to read line from client: %v", bs.Err()) + return + } + fmt.Fprintf(c, "backend got %q\n", bs.Text()) + })) + defer backendServer.Close() + + backURL, _ := url.Parse(backendServer.URL) + rproxy := NewSingleHostReverseProxy(backURL) + rproxy.ErrorLog = log.New(ioutil.Discard, "", 0) // quiet for tests + rproxy.ModifyResponse = func(res *http.Response) error { + res.Header.Add("X-Modified", "true") + return nil + } + + handler := http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { + rw.Header().Set("X-Header", "X-Value") + rproxy.ServeHTTP(rw, req) + }) + + frontendProxy := httptest.NewServer(handler) + defer frontendProxy.Close() + + req, _ := http.NewRequest("GET", frontendProxy.URL, nil) + req.Header.Set("Connection", "Upgrade") + req.Header.Set("Upgrade", "websocket") + + c := frontendProxy.Client() + res, err := c.Do(req) + if err != nil { + t.Fatal(err) + } + if res.StatusCode != 101 { + t.Fatalf("status = %v; want 101", res.Status) + } + + got := res.Header.Get("X-Header") + want := "X-Value" + if got != want { + t.Errorf("Header(XHeader) = %q; want %q", got, want) + } + + if upgradeType(res.Header) != "websocket" { + t.Fatalf("not websocket upgrade; got %#v", res.Header) + } + rwc, ok := res.Body.(io.ReadWriteCloser) + if !ok { + t.Fatalf("response body is of type %T; does not implement ReadWriteCloser", res.Body) + } + defer rwc.Close() + + if got, want := res.Header.Get("X-Modified"), "true"; got != want { + t.Errorf("response X-Modified header = %q; want %q", got, want) + } + + io.WriteString(rwc, "Hello\n") + bs := bufio.NewScanner(rwc) + if !bs.Scan() { + t.Fatalf("Scan: %v", bs.Err()) + } + got = bs.Text() + want = `backend got "Hello"` + if got != want { + t.Errorf("got %#q, want %#q", got, want) + } +} + +func TestUnannouncedTrailer(t *testing.T) { + backend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + w.(http.Flusher).Flush() + w.Header().Set(http.TrailerPrefix+"X-Unannounced-Trailer", "unannounced_trailer_value") + })) + defer backend.Close() + backendURL, err := url.Parse(backend.URL) + if err != nil { + t.Fatal(err) + } + proxyHandler := NewSingleHostReverseProxy(backendURL) + proxyHandler.ErrorLog = log.New(ioutil.Discard, "", 0) // quiet for tests + frontend := httptest.NewServer(proxyHandler) + defer frontend.Close() + frontendClient := frontend.Client() + + res, err := frontendClient.Get(frontend.URL) + if err != nil { + t.Fatalf("Get: %v", err) + } + + ioutil.ReadAll(res.Body) + + if g, w := res.Trailer.Get("X-Unannounced-Trailer"), "unannounced_trailer_value"; g != w { + t.Errorf("Trailer(X-Unannounced-Trailer) = %q; want %q", g, w) + } + +} + +func TestSingleJoinSlash(t *testing.T) { + tests := []struct { + slasha string + slashb string + expected string + }{ + {"https://www.google.com/", "/favicon.ico", "https://www.google.com/favicon.ico"}, + {"https://www.google.com", "/favicon.ico", "https://www.google.com/favicon.ico"}, + {"https://www.google.com", "favicon.ico", "https://www.google.com/favicon.ico"}, + {"https://www.google.com", "", "https://www.google.com/"}, + {"", "favicon.ico", "/favicon.ico"}, + } + for _, tt := range tests { + if got := singleJoiningSlash(tt.slasha, tt.slashb); got != tt.expected { + t.Errorf("singleJoiningSlash(%s,%s) want %s got %s", + tt.slasha, + tt.slashb, + tt.expected, + got) + } + } +} diff --git a/libgo/go/net/http/proxy_test.go b/libgo/go/net/http/proxy_test.go index eef0ca82f8c..feb7047a58e 100644 --- a/libgo/go/net/http/proxy_test.go +++ b/libgo/go/net/http/proxy_test.go @@ -35,7 +35,7 @@ func TestCacheKeys(t *testing.T) { } proxy = u } - cm := connectMethod{proxy, tt.scheme, tt.addr} + cm := connectMethod{proxy, tt.scheme, tt.addr, false} if got := cm.key().String(); got != tt.key { t.Fatalf("{%q, %q, %q} cache key = %q; want %q", tt.proxy, tt.scheme, tt.addr, got, tt.key) } diff --git a/libgo/go/net/http/readrequest_test.go b/libgo/go/net/http/readrequest_test.go index 18eed345a84..517a8189e15 100644 --- a/libgo/go/net/http/readrequest_test.go +++ b/libgo/go/net/http/readrequest_test.go @@ -438,7 +438,7 @@ func TestReadRequest(t *testing.T) { // reqBytes treats req as a request (with \n delimiters) and returns it with \r\n delimiters, // ending in \r\n\r\n func reqBytes(req string) []byte { - return []byte(strings.Replace(strings.TrimSpace(req), "\n", "\r\n", -1) + "\r\n\r\n") + return []byte(strings.ReplaceAll(strings.TrimSpace(req), "\n", "\r\n") + "\r\n\r\n") } var badRequestTests = []struct { diff --git a/libgo/go/net/http/request.go b/libgo/go/net/http/request.go index a40b0a3cb83..fb058f9fbf3 100644 --- a/libgo/go/net/http/request.go +++ b/libgo/go/net/http/request.go @@ -26,7 +26,7 @@ import ( "strings" "sync" - "golang_org/x/net/idna" + "internal/x/net/idna" ) const ( @@ -53,8 +53,9 @@ var ( // available. ErrNotSupported = &ProtocolError{"feature not supported"} - // ErrUnexpectedTrailer is returned by the Transport when a server - // replies with a Trailer header, but without a chunked reply. + // Deprecated: ErrUnexpectedTrailer is no longer returned by + // anything in the net/http package. Callers should not + // compare errors against this variable. ErrUnexpectedTrailer = &ProtocolError{"trailer header without chunked transfer encoding"} // ErrMissingBoundary is returned by Request.MultipartReader when the @@ -105,7 +106,7 @@ var reqWriteExcludeHeader = map[string]bool{ // documentation for Request.Write and RoundTripper. type Request struct { // Method specifies the HTTP method (GET, POST, PUT, etc.). - // For client requests an empty string means GET. + // For client requests, an empty string means GET. // // Go's HTTP client does not support sending a request with // the CONNECT method. See the documentation on Transport for @@ -115,7 +116,7 @@ type Request struct { // URL specifies either the URI being requested (for server // requests) or the URL to access (for client requests). // - // For server requests the URL is parsed from the URI + // For server requests, the URL is parsed from the URI // supplied on the Request-Line as stored in RequestURI. For // most requests, fields other than Path and RawQuery will be // empty. (See RFC 7230, Section 5.3) @@ -128,7 +129,7 @@ type Request struct { // The protocol version for incoming server requests. // - // For client requests these fields are ignored. The HTTP + // For client requests, these fields are ignored. The HTTP // client code always uses either HTTP/1.1 or HTTP/2. // See the docs on Transport for details. Proto string // "HTTP/1.0" @@ -170,11 +171,11 @@ type Request struct { // Body is the request's body. // - // For client requests a nil body means the request has no + // For client requests, a nil body means the request has no // body, such as a GET request. The HTTP Client's Transport // is responsible for calling the Close method. // - // For server requests the Request Body is always non-nil + // For server requests, the Request Body is always non-nil // but will return EOF immediately when no body is present. // The Server will close the request body. The ServeHTTP // Handler does not need to. @@ -185,13 +186,14 @@ type Request struct { // reading the body more than once. Use of GetBody still // requires setting Body. // - // For server requests it is unused. + // For server requests, it is unused. GetBody func() (io.ReadCloser, error) // ContentLength records the length of the associated content. // The value -1 indicates that the length is unknown. // Values >= 0 indicate that the given number of bytes may // be read from Body. + // // For client requests, a value of 0 with a non-nil Body is // also treated as unknown. ContentLength int64 @@ -215,7 +217,7 @@ type Request struct { // Transport.DisableKeepAlives were set. Close bool - // For server requests Host specifies the host on which the URL + // For server requests, Host specifies the host on which the URL // is sought. Per RFC 7230, section 5.4, this is either the value // of the "Host" header or the host name given in the URL itself. // It may be of the form "host:port". For international domain @@ -228,7 +230,7 @@ type Request struct { // ServeMux supports patterns registered to particular host // names and thus protects its registered Handlers. // - // For client requests Host optionally overrides the Host + // For client requests, Host optionally overrides the Host // header to send. If empty, the Request.Write method uses // the value of URL.Host. Host may contain an international // domain name. @@ -255,14 +257,14 @@ type Request struct { // Trailer specifies additional headers that are sent after the request // body. // - // For server requests the Trailer map initially contains only the + // For server requests, the Trailer map initially contains only the // trailer keys, with nil values. (The client declares which trailers it // will later send.) While the handler is reading from Body, it must // not reference Trailer. After reading from Body returns EOF, Trailer // can be read again and will contain non-nil values, if they were sent // by the client. // - // For client requests Trailer must be initialized to a map containing + // For client requests, Trailer must be initialized to a map containing // the trailer keys to later send. The values may be nil or their final // values. The ContentLength must be 0 or -1, to send a chunked request. // After the HTTP request is sent the map values can be updated while @@ -544,6 +546,9 @@ func (r *Request) write(w io.Writer, usingProxy bool, extraHeaders Header, waitF } else if r.Method == "CONNECT" && r.URL.Path == "" { // CONNECT requests normally give just the host and port, not a full URL. ruri = host + if r.URL.Opaque != "" { + ruri = r.URL.Opaque + } } // TODO(bradfitz): escape at least newlines in ruri? @@ -574,7 +579,7 @@ func (r *Request) write(w io.Writer, usingProxy bool, extraHeaders Header, waitF // Use the defaultUserAgent unless the Header contains one, which // may be blank to not send the header. userAgent := defaultUserAgent - if _, ok := r.Header["User-Agent"]; ok { + if r.Header.has("User-Agent") { userAgent = r.Header.Get("User-Agent") } if userAgent != "" { @@ -1325,6 +1330,9 @@ func (r *Request) wantsHttp10KeepAlive() bool { } func (r *Request) wantsClose() bool { + if r.Close { + return true + } return hasToken(r.Header.get("Connection"), "close") } @@ -1340,6 +1348,12 @@ func (r *Request) isReplayable() bool { case "GET", "HEAD", "OPTIONS", "TRACE": return true } + // The Idempotency-Key, while non-standard, is widely used to + // mean a POST or other request is idempotent. See + // https://golang.org/issue/19943#issuecomment-421092421 + if r.Header.has("Idempotency-Key") || r.Header.has("X-Idempotency-Key") { + return true + } } return false } @@ -1370,3 +1384,10 @@ func requestMethodUsuallyLacksBody(method string) bool { } return false } + +// requiresHTTP1 reports whether this request requires being sent on +// an HTTP/1 connection. +func (r *Request) requiresHTTP1() bool { + return hasToken(r.Header.Get("Connection"), "upgrade") && + strings.EqualFold(r.Header.Get("Upgrade"), "websocket") +} diff --git a/libgo/go/net/http/request_test.go b/libgo/go/net/http/request_test.go index 7a83ae5b1ce..e8005571df9 100644 --- a/libgo/go/net/http/request_test.go +++ b/libgo/go/net/http/request_test.go @@ -878,7 +878,7 @@ func testMissingFile(t *testing.T, req *Request) { } func newTestMultipartRequest(t *testing.T) *Request { - b := strings.NewReader(strings.Replace(message, "\n", "\r\n", -1)) + b := strings.NewReader(strings.ReplaceAll(message, "\n", "\r\n")) req, err := NewRequest("POST", "/", b) if err != nil { t.Fatal("NewRequest:", err) @@ -970,8 +970,8 @@ Content-Disposition: form-data; name="textb" ` func benchmarkReadRequest(b *testing.B, request string) { - request = request + "\n" // final \n - request = strings.Replace(request, "\n", "\r\n", -1) // expand \n to \r\n + request = request + "\n" // final \n + request = strings.ReplaceAll(request, "\n", "\r\n") // expand \n to \r\n b.SetBytes(int64(len(request))) r := bufio.NewReader(&infiniteReader{buf: []byte(request)}) b.ReportAllocs() diff --git a/libgo/go/net/http/requestwrite_test.go b/libgo/go/net/http/requestwrite_test.go index eb65b9f736f..7dbf0d4e8a1 100644 --- a/libgo/go/net/http/requestwrite_test.go +++ b/libgo/go/net/http/requestwrite_test.go @@ -512,6 +512,70 @@ var reqWriteTests = []reqWriteTest{ "User-Agent: Go-http-client/1.1\r\n" + "\r\n", }, + + // CONNECT without Opaque + 21: { + Req: Request{ + Method: "CONNECT", + URL: &url.URL{ + Scheme: "https", // of proxy.com + Host: "proxy.com", + }, + }, + // What we used to do, locking that behavior in: + WantWrite: "CONNECT proxy.com HTTP/1.1\r\n" + + "Host: proxy.com\r\n" + + "User-Agent: Go-http-client/1.1\r\n" + + "\r\n", + }, + + // CONNECT with Opaque + 22: { + Req: Request{ + Method: "CONNECT", + URL: &url.URL{ + Scheme: "https", // of proxy.com + Host: "proxy.com", + Opaque: "backend:443", + }, + }, + WantWrite: "CONNECT backend:443 HTTP/1.1\r\n" + + "Host: proxy.com\r\n" + + "User-Agent: Go-http-client/1.1\r\n" + + "\r\n", + }, + + // Verify that a nil header value doesn't get written. + 23: { + Req: Request{ + Method: "GET", + URL: mustParseURL("/foo"), + Header: Header{ + "X-Foo": []string{"X-Bar"}, + "X-Idempotency-Key": nil, + }, + }, + + WantWrite: "GET /foo HTTP/1.1\r\n" + + "Host: \r\n" + + "User-Agent: Go-http-client/1.1\r\n" + + "X-Foo: X-Bar\r\n\r\n", + }, + 24: { + Req: Request{ + Method: "GET", + URL: mustParseURL("/foo"), + Header: Header{ + "X-Foo": []string{"X-Bar"}, + "X-Idempotency-Key": []string{}, + }, + }, + + WantWrite: "GET /foo HTTP/1.1\r\n" + + "Host: \r\n" + + "User-Agent: Go-http-client/1.1\r\n" + + "X-Foo: X-Bar\r\n\r\n", + }, } func TestRequestWrite(t *testing.T) { diff --git a/libgo/go/net/http/response.go b/libgo/go/net/http/response.go index bf1e13c8ae2..f906ce829b4 100644 --- a/libgo/go/net/http/response.go +++ b/libgo/go/net/http/response.go @@ -12,6 +12,7 @@ import ( "crypto/tls" "errors" "fmt" + "internal/x/net/http/httpguts" "io" "net/textproto" "net/url" @@ -63,6 +64,10 @@ type Response struct { // // The Body is automatically dechunked if the server replied // with a "chunked" Transfer-Encoding. + // + // As of Go 1.12, the Body will be also implement io.Writer + // on a successful "101 Switching Protocols" responses, + // as used by WebSockets and HTTP/2's "h2c" mode. Body io.ReadCloser // ContentLength records the length of the associated content. The @@ -333,3 +338,23 @@ func (r *Response) closeBody() { r.Body.Close() } } + +// bodyIsWritable reports whether the Body supports writing. The +// Transport returns Writable bodies for 101 Switching Protocols +// responses. +// The Transport uses this method to determine whether a persistent +// connection is done being managed from its perspective. Once we +// return a writable response body to a user, the net/http package is +// done managing that connection. +func (r *Response) bodyIsWritable() bool { + _, ok := r.Body.(io.Writer) + return ok +} + +// isProtocolSwitch reports whether r is a response to a successful +// protocol upgrade. +func (r *Response) isProtocolSwitch() bool { + return r.StatusCode == StatusSwitchingProtocols && + r.Header.Get("Upgrade") != "" && + httpguts.HeaderValuesContainsToken(r.Header["Connection"], "Upgrade") +} diff --git a/libgo/go/net/http/response_test.go b/libgo/go/net/http/response_test.go index c28b0cba89e..c46f13f7988 100644 --- a/libgo/go/net/http/response_test.go +++ b/libgo/go/net/http/response_test.go @@ -157,6 +157,34 @@ var respTests = []respTest{ "Body here\ncontinued", }, + // Trailer header but no TransferEncoding + { + "HTTP/1.0 200 OK\r\n" + + "Trailer: Content-MD5, Content-Sources\r\n" + + "Content-Length: 10\r\n" + + "Connection: close\r\n" + + "\r\n" + + "Body here\n", + + Response{ + Status: "200 OK", + StatusCode: 200, + Proto: "HTTP/1.0", + ProtoMajor: 1, + ProtoMinor: 0, + Request: dummyReq("GET"), + Header: Header{ + "Connection": {"close"}, + "Content-Length": {"10"}, + "Trailer": []string{"Content-MD5, Content-Sources"}, + }, + Close: true, + ContentLength: 10, + }, + + "Body here\n", + }, + // Chunked response with Content-Length. { "HTTP/1.1 200 OK\r\n" + diff --git a/libgo/go/net/http/roundtrip_js.go b/libgo/go/net/http/roundtrip_js.go index 38e4f5573e6..1e38b908d38 100644 --- a/libgo/go/net/http/roundtrip_js.go +++ b/libgo/go/net/http/roundtrip_js.go @@ -93,7 +93,7 @@ func (t *Transport) RoundTrip(req *Request) (*Response, error) { respCh = make(chan *Response, 1) errCh = make(chan error, 1) ) - success := js.NewCallback(func(args []js.Value) { + success := js.FuncOf(func(this js.Value, args []js.Value) interface{} { result := args[0] header := Header{} // https://developer.mozilla.org/en-US/docs/Web/API/Headers/entries @@ -137,14 +137,17 @@ func (t *Transport) RoundTrip(req *Request) (*Response, error) { }: case <-req.Context().Done(): } + + return nil }) defer success.Release() - failure := js.NewCallback(func(args []js.Value) { + failure := js.FuncOf(func(this js.Value, args []js.Value) interface{} { err := fmt.Errorf("net/http: fetch() failed: %s", args[0].String()) select { case errCh <- err: case <-req.Context().Done(): } + return nil }) defer failure.Release() respPromise.Call("then", success, failure) @@ -187,26 +190,28 @@ func (r *streamReader) Read(p []byte) (n int, err error) { bCh = make(chan []byte, 1) errCh = make(chan error, 1) ) - success := js.NewCallback(func(args []js.Value) { + success := js.FuncOf(func(this js.Value, args []js.Value) interface{} { result := args[0] if result.Get("done").Bool() { errCh <- io.EOF - return + return nil } value := make([]byte, result.Get("value").Get("byteLength").Int()) a := js.TypedArrayOf(value) a.Call("set", result.Get("value")) a.Release() bCh <- value + return nil }) defer success.Release() - failure := js.NewCallback(func(args []js.Value) { + failure := js.FuncOf(func(this js.Value, args []js.Value) interface{} { // Assumes it's a TypeError. See // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError // for more information on this type. See // https://streams.spec.whatwg.org/#byob-reader-read for the spec on // the read method. errCh <- errors.New(args[0].Get("message").String()) + return nil }) defer failure.Release() r.stream.Call("read").Call("then", success, failure) @@ -253,7 +258,7 @@ func (r *arrayReader) Read(p []byte) (n int, err error) { bCh = make(chan []byte, 1) errCh = make(chan error, 1) ) - success := js.NewCallback(func(args []js.Value) { + success := js.FuncOf(func(this js.Value, args []js.Value) interface{} { // Wrap the input ArrayBuffer with a Uint8Array uint8arrayWrapper := js.Global().Get("Uint8Array").New(args[0]) value := make([]byte, uint8arrayWrapper.Get("byteLength").Int()) @@ -261,14 +266,16 @@ func (r *arrayReader) Read(p []byte) (n int, err error) { a.Call("set", uint8arrayWrapper) a.Release() bCh <- value + return nil }) defer success.Release() - failure := js.NewCallback(func(args []js.Value) { + failure := js.FuncOf(func(this js.Value, args []js.Value) interface{} { // Assumes it's a TypeError. See // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError // for more information on this type. // See https://fetch.spec.whatwg.org/#concept-body-consume-body for reasons this might error. errCh <- errors.New(args[0].Get("message").String()) + return nil }) defer failure.Release() r.arrayPromise.Call("then", success, failure) diff --git a/libgo/go/net/http/serve_test.go b/libgo/go/net/http/serve_test.go index a4385419d04..6eb0088a963 100644 --- a/libgo/go/net/http/serve_test.go +++ b/libgo/go/net/http/serve_test.go @@ -130,7 +130,7 @@ func (c *testConn) Close() error { // reqBytes treats req as a request (with \n delimiters) and returns it with \r\n delimiters, // ending in \r\n\r\n func reqBytes(req string) []byte { - return []byte(strings.Replace(strings.TrimSpace(req), "\n", "\r\n", -1) + "\r\n\r\n") + return []byte(strings.ReplaceAll(strings.TrimSpace(req), "\n", "\r\n") + "\r\n\r\n") } type handlerTest struct { @@ -1556,6 +1556,32 @@ func TestServeTLS(t *testing.T) { } } +// Test that the HTTPS server nicely rejects plaintext HTTP/1.x requests. +func TestTLSServerRejectHTTPRequests(t *testing.T) { + setParallel(t) + defer afterTest(t) + ts := httptest.NewTLSServer(HandlerFunc(func(w ResponseWriter, r *Request) { + t.Error("unexpected HTTPS request") + })) + var errBuf bytes.Buffer + ts.Config.ErrorLog = log.New(&errBuf, "", 0) + defer ts.Close() + conn, err := net.Dial("tcp", ts.Listener.Addr().String()) + if err != nil { + t.Fatal(err) + } + defer conn.Close() + io.WriteString(conn, "GET / HTTP/1.1\r\nHost: foo\r\n\r\n") + slurp, err := ioutil.ReadAll(conn) + if err != nil { + t.Fatal(err) + } + const wantPrefix = "HTTP/1.0 400 Bad Request\r\n" + if !strings.HasPrefix(string(slurp), wantPrefix) { + t.Errorf("response = %q; wanted prefix %q", slurp, wantPrefix) + } +} + // Issue 15908 func TestAutomaticHTTP2_Serve_NoTLSConfig(t *testing.T) { testAutomaticHTTP2_Serve(t, nil, true) @@ -2988,7 +3014,7 @@ func testRequestBodyLimit(t *testing.T, h2 bool) { // side of their TCP connection, the server doesn't send a 400 Bad Request. func TestClientWriteShutdown(t *testing.T) { if runtime.GOOS == "plan9" { - t.Skip("skipping test; see https://golang.org/issue/7237") + t.Skip("skipping test; see https://golang.org/issue/17906") } defer afterTest(t) ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) {})) @@ -4028,21 +4054,18 @@ func TestRequestBodyCloseDoesntBlock(t *testing.T) { } } -// test that ResponseWriter implements io.stringWriter. +// test that ResponseWriter implements io.StringWriter. func TestResponseWriterWriteString(t *testing.T) { okc := make(chan bool, 1) ht := newHandlerTest(HandlerFunc(func(w ResponseWriter, r *Request) { - type stringWriter interface { - WriteString(s string) (n int, err error) - } - _, ok := w.(stringWriter) + _, ok := w.(io.StringWriter) okc <- ok })) ht.rawResponse("GET / HTTP/1.0") select { case ok := <-okc: if !ok { - t.Error("ResponseWriter did not implement io.stringWriter") + t.Error("ResponseWriter did not implement io.StringWriter") } default: t.Error("handler was never called") diff --git a/libgo/go/net/http/server.go b/libgo/go/net/http/server.go index c24ad750f21..cbf5673ee6b 100644 --- a/libgo/go/net/http/server.go +++ b/libgo/go/net/http/server.go @@ -22,13 +22,14 @@ import ( "os" "path" "runtime" + "sort" "strconv" "strings" "sync" "sync/atomic" "time" - "golang_org/x/net/http/httpguts" + "internal/x/net/http/httpguts" ) // Errors used by the HTTP server. @@ -1093,13 +1094,39 @@ func checkWriteHeaderCode(code int) { } } +// relevantCaller searches the call stack for the first function outside of net/http. +// The purpose of this function is to provide more helpful error messages. +func relevantCaller() runtime.Frame { + pc := make([]uintptr, 16) + n := runtime.Callers(1, pc) + frames := runtime.CallersFrames(pc[:n]) + prefix1 := "net/http." + prefix2 := "net/http." + if runtime.Compiler == "gccgo" { + prefix2 = "http." + } + var frame runtime.Frame + for { + frame, more := frames.Next() + if !strings.HasPrefix(frame.Function, prefix1) && !strings.HasPrefix(frame.Function, prefix2) { + return frame + } + if !more { + break + } + } + return frame +} + func (w *response) WriteHeader(code int) { if w.conn.hijacked() { - w.conn.server.logf("http: response.WriteHeader on hijacked connection") + caller := relevantCaller() + w.conn.server.logf("http: response.WriteHeader on hijacked connection from %s (%s:%d)", caller.Function, path.Base(caller.File), caller.Line) return } if w.wroteHeader { - w.conn.server.logf("http: multiple response.WriteHeader calls") + caller := relevantCaller() + w.conn.server.logf("http: superfluous response.WriteHeader call from %s (%s:%d)", caller.Function, path.Base(caller.File), caller.Line) return } checkWriteHeaderCode(code) @@ -1368,7 +1395,7 @@ func (cw *chunkWriter) writeHeader(p []byte) { } } - if _, ok := header["Date"]; !ok { + if !header.has("Date") { setHeader.date = appendTime(cw.res.dateBuf[:0], time.Now()) } @@ -1529,7 +1556,8 @@ func (w *response) WriteString(data string) (n int, err error) { func (w *response) write(lenData int, dataB []byte, dataS string) (n int, err error) { if w.conn.hijacked() { if lenData > 0 { - w.conn.server.logf("http: response.Write on hijacked connection") + caller := relevantCaller() + w.conn.server.logf("http: response.Write on hijacked connection from %s (%s:%d)", caller.Function, path.Base(caller.File), caller.Line) } return 0, ErrHijacked } @@ -1760,6 +1788,14 @@ func (c *conn) serve(ctx context.Context) { c.rwc.SetWriteDeadline(time.Now().Add(d)) } if err := tlsConn.Handshake(); err != nil { + // If the handshake failed due to the client not speaking + // TLS, assume they're speaking plaintext HTTP and write a + // 400 response on the TLS conn's underlying net.Conn. + if re, ok := err.(tls.RecordHeaderError); ok && re.Conn != nil && tlsRecordHeaderLooksLikeHTTP(re.RecordHeader) { + io.WriteString(re.Conn, "HTTP/1.0 400 Bad Request\r\n\r\nClient sent an HTTP request to an HTTPS server.\n") + re.Conn.Close() + return + } c.server.logf("http: TLS handshake error from %s: %v", c.rwc.RemoteAddr(), err) return } @@ -2149,7 +2185,8 @@ func RedirectHandler(url string, code int) Handler { type ServeMux struct { mu sync.RWMutex m map[string]muxEntry - hosts bool // whether any patterns contain hostnames + es []muxEntry // slice of entries sorted from longest to shortest. + hosts bool // whether any patterns contain hostnames } type muxEntry struct { @@ -2165,19 +2202,6 @@ var DefaultServeMux = &defaultServeMux var defaultServeMux ServeMux -// Does path match pattern? -func pathMatch(pattern, path string) bool { - if len(pattern) == 0 { - // should not happen - return false - } - n := len(pattern) - if pattern[n-1] != '/' { - return pattern == path - } - return len(path) >= n && path[0:n] == pattern -} - // cleanPath returns the canonical path for p, eliminating . and .. elements. func cleanPath(p string) string { if p == "" { @@ -2222,19 +2246,14 @@ func (mux *ServeMux) match(path string) (h Handler, pattern string) { return v.h, v.pattern } - // Check for longest valid match. - var n = 0 - for k, v := range mux.m { - if !pathMatch(k, path) { - continue - } - if h == nil || len(k) > n { - n = len(k) - h = v.h - pattern = v.pattern + // Check for longest valid match. mux.es contains all patterns + // that end in / sorted from longest to shortest. + for _, e := range mux.es { + if strings.HasPrefix(path, e.pattern) { + return e.h, e.pattern } } - return + return nil, "" } // redirectToPathSlash determines if the given path needs appending "/" to it. @@ -2380,13 +2399,32 @@ func (mux *ServeMux) Handle(pattern string, handler Handler) { if mux.m == nil { mux.m = make(map[string]muxEntry) } - mux.m[pattern] = muxEntry{h: handler, pattern: pattern} + e := muxEntry{h: handler, pattern: pattern} + mux.m[pattern] = e + if pattern[len(pattern)-1] == '/' { + mux.es = appendSorted(mux.es, e) + } if pattern[0] != '/' { mux.hosts = true } } +func appendSorted(es []muxEntry, e muxEntry) []muxEntry { + n := len(es) + i := sort.Search(n, func(i int) bool { + return len(es[i].pattern) < len(e.pattern) + }) + if i == n { + return append(es, e) + } + // we now know that i points at where we want to insert + es = append(es, muxEntry{}) // try to grow the slice in place, any entry works. + copy(es[i+1:], es[i:]) // Move shorter entries down + es[i] = e + return es +} + // HandleFunc registers the handler function for the given pattern. func (mux *ServeMux) HandleFunc(pattern string, handler func(ResponseWriter, *Request)) { if handler == nil { @@ -3049,7 +3087,7 @@ func (srv *Server) ListenAndServeTLS(certFile, keyFile string) error { } // setupHTTP2_ServeTLS conditionally configures HTTP/2 on -// srv and returns whether there was an error setting it up. If it is +// srv and reports whether there was an error setting it up. If it is // not configured for policy reasons, nil is returned. func (srv *Server) setupHTTP2_ServeTLS() error { srv.nextProtoOnce.Do(srv.onceSetNextProtoDefaults) @@ -3176,7 +3214,6 @@ func (h *timeoutHandler) ServeHTTP(w ResponseWriter, r *Request) { w.WriteHeader(StatusServiceUnavailable) io.WriteString(w, h.errorBody()) tw.timedOut = true - return } } @@ -3369,3 +3406,13 @@ func strSliceContains(ss []string, s string) bool { } return false } + +// tlsRecordHeaderLooksLikeHTTP reports whether a TLS record header +// looks like it might've been a misdirected plaintext HTTP request. +func tlsRecordHeaderLooksLikeHTTP(hdr [5]byte) bool { + switch string(hdr[:]) { + case "GET /", "HEAD ", "POST ", "PUT /", "OPTIO": + return true + } + return false +} diff --git a/libgo/go/net/http/server_test.go b/libgo/go/net/http/server_test.go new file mode 100644 index 00000000000..0132f3ba5fb --- /dev/null +++ b/libgo/go/net/http/server_test.go @@ -0,0 +1,45 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Server unit tests + +package http + +import ( + "fmt" + "testing" +) + +func BenchmarkServerMatch(b *testing.B) { + fn := func(w ResponseWriter, r *Request) { + fmt.Fprintf(w, "OK") + } + mux := NewServeMux() + mux.HandleFunc("/", fn) + mux.HandleFunc("/index", fn) + mux.HandleFunc("/home", fn) + mux.HandleFunc("/about", fn) + mux.HandleFunc("/contact", fn) + mux.HandleFunc("/robots.txt", fn) + mux.HandleFunc("/products/", fn) + mux.HandleFunc("/products/1", fn) + mux.HandleFunc("/products/2", fn) + mux.HandleFunc("/products/3", fn) + mux.HandleFunc("/products/3/image.jpg", fn) + mux.HandleFunc("/admin", fn) + mux.HandleFunc("/admin/products/", fn) + mux.HandleFunc("/admin/products/create", fn) + mux.HandleFunc("/admin/products/update", fn) + mux.HandleFunc("/admin/products/delete", fn) + + paths := []string{"/", "/notfound", "/admin/", "/admin/foo", "/contact", "/products", + "/products/", "/products/3/image.jpg"} + b.StartTimer() + for i := 0; i < b.N; i++ { + if h, p := mux.match(paths[i%len(paths)]); h != nil && p == "" { + b.Error("impossible") + } + } + b.StopTimer() +} diff --git a/libgo/go/net/http/socks_bundle.go b/libgo/go/net/http/socks_bundle.go index e4314b41283..e6640dd404d 100644 --- a/libgo/go/net/http/socks_bundle.go +++ b/libgo/go/net/http/socks_bundle.go @@ -380,6 +380,7 @@ func (d *socksDialer) Dial(network, address string) (net.Conn, error) { return nil, &net.OpError{Op: d.cmd.String(), Net: network, Source: proxy, Addr: dst, Err: err} } if _, err := d.DialWithConn(context.Background(), c, network, address); err != nil { + c.Close() return nil, err } return c, nil diff --git a/libgo/go/net/http/status.go b/libgo/go/net/http/status.go index dd72d67be91..086f3d1a71e 100644 --- a/libgo/go/net/http/status.go +++ b/libgo/go/net/http/status.go @@ -55,6 +55,7 @@ const ( StatusUnprocessableEntity = 422 // RFC 4918, 11.2 StatusLocked = 423 // RFC 4918, 11.3 StatusFailedDependency = 424 // RFC 4918, 11.4 + StatusTooEarly = 425 // RFC 8470, 5.2. StatusUpgradeRequired = 426 // RFC 7231, 6.5.15 StatusPreconditionRequired = 428 // RFC 6585, 3 StatusTooManyRequests = 429 // RFC 6585, 4 @@ -122,6 +123,7 @@ var statusText = map[int]string{ StatusUnprocessableEntity: "Unprocessable Entity", StatusLocked: "Locked", StatusFailedDependency: "Failed Dependency", + StatusTooEarly: "Too Early", StatusUpgradeRequired: "Upgrade Required", StatusPreconditionRequired: "Precondition Required", StatusTooManyRequests: "Too Many Requests", diff --git a/libgo/go/net/http/transfer.go b/libgo/go/net/http/transfer.go index 2c6ba3231b0..e8a93e9137e 100644 --- a/libgo/go/net/http/transfer.go +++ b/libgo/go/net/http/transfer.go @@ -21,7 +21,7 @@ import ( "sync" "time" - "golang_org/x/net/http/httpguts" + "internal/x/net/http/httpguts" ) // ErrLineTooLong is returned when reading request or response bodies @@ -184,6 +184,9 @@ func (t *transferWriter) shouldSendChunkedRequestBody() bool { if t.ContentLength >= 0 || t.Body == nil { // redundant checks; caller did them return false } + if t.Method == "CONNECT" { + return false + } if requestMethodUsuallyLacksBody(t.Method) { // Only probe the Request.Body for GET/HEAD/DELETE/etc // requests, because it's only those types of requests @@ -357,7 +360,11 @@ func (t *transferWriter) writeBody(w io.Writer) error { err = cw.Close() } } else if t.ContentLength == -1 { - ncopy, err = io.Copy(w, body) + dst := w + if t.Method == "CONNECT" { + dst = bufioFlushWriter{dst} + } + ncopy, err = io.Copy(dst, body) } else { ncopy, err = io.Copy(w, io.LimitReader(body, t.ContentLength)) if err != nil { @@ -733,6 +740,16 @@ func fixTrailer(header Header, te []string) (Header, error) { if !ok { return nil, nil } + if !chunked(te) { + // Trailer and no chunking: + // this is an invalid use case for trailer header. + // Nevertheless, no error will be returned and we + // let users decide if this is a valid HTTP message. + // The Trailer header will be kept in Response.Header + // but not populate Response.Trailer. + // See issue #27197. + return nil, nil + } header.Del("Trailer") trailer := make(Header) @@ -756,10 +773,6 @@ func fixTrailer(header Header, te []string) (Header, error) { if len(trailer) == 0 { return nil, nil } - if !chunked(te) { - // Trailer and no chunking - return nil, ErrUnexpectedTrailer - } return trailer, nil } @@ -942,7 +955,7 @@ func (b *body) Close() error { // no trailer and closing the connection next. // no point in reading to EOF. case b.doEarlyClose: - // Read up to maxPostHandlerReadBytes bytes of the body, looking for + // Read up to maxPostHandlerReadBytes bytes of the body, looking // for EOF (and trailers), so we can re-use this connection. if lr, ok := b.src.(*io.LimitedReader); ok && lr.N > maxPostHandlerReadBytes { // There was a declared Content-Length, and we have more bytes remaining @@ -1050,3 +1063,18 @@ func isKnownInMemoryReader(r io.Reader) bool { } return false } + +// bufioFlushWriter is an io.Writer wrapper that flushes all writes +// on its wrapped writer if it's a *bufio.Writer. +type bufioFlushWriter struct{ w io.Writer } + +func (fw bufioFlushWriter) Write(p []byte) (n int, err error) { + n, err = fw.w.Write(p) + if bw, ok := fw.w.(*bufio.Writer); n > 0 && ok { + ferr := bw.Flush() + if ferr != nil && err == nil { + err = ferr + } + } + return +} diff --git a/libgo/go/net/http/transport.go b/libgo/go/net/http/transport.go index 40947baf87a..a8c5efe6aaf 100644 --- a/libgo/go/net/http/transport.go +++ b/libgo/go/net/http/transport.go @@ -30,8 +30,8 @@ import ( "sync/atomic" "time" - "golang_org/x/net/http/httpguts" - "golang_org/x/net/http/httpproxy" + "internal/x/net/http/httpguts" + "internal/x/net/http/httpproxy" ) // DefaultTransport is the default implementation of Transport and is @@ -85,21 +85,21 @@ func init() { // To explicitly enable HTTP/2 on a transport, use golang.org/x/net/http2 // and call ConfigureTransport. See the package docs for more about HTTP/2. // -// The Transport will send CONNECT requests to a proxy for its own use -// when processing HTTPS requests, but Transport should generally not -// be used to send a CONNECT request. That is, the Request passed to -// the RoundTrip method should not have a Method of "CONNECT", as Go's -// HTTP/1.x implementation does not support full-duplex request bodies -// being written while the response body is streamed. Go's HTTP/2 -// implementation does support full duplex, but many CONNECT proxies speak -// HTTP/1.x. -// // Responses with status codes in the 1xx range are either handled // automatically (100 expect-continue) or ignored. The one // exception is HTTP status code 101 (Switching Protocols), which is // considered a terminal status and returned by RoundTrip. To see the // ignored 1xx responses, use the httptrace trace package's // ClientTrace.Got1xxResponse. +// +// Transport only retries a request upon encountering a network error +// if the request is idempotent and either has no body or has its +// Request.GetBody defined. HTTP requests are considered idempotent if +// they have HTTP methods GET, HEAD, OPTIONS, or TRACE; or if their +// Header map contains an "Idempotency-Key" or "X-Idempotency-Key" +// entry. If the idempotency key value is an zero-length slice, the +// request is treated as idempotent but the header is not sent on the +// wire. type Transport struct { idleMu sync.Mutex wantIdle bool // user has requested to close all idle conns @@ -134,7 +134,7 @@ type Transport struct { // // DialContext runs concurrently with calls to RoundTrip. // A RoundTrip call that initiates a dial may end up using - // an connection dialed previously when the earlier connection + // a connection dialed previously when the earlier connection // becomes idle before the later DialContext completes. DialContext func(ctx context.Context, network, addr string) (net.Conn, error) @@ -142,7 +142,7 @@ type Transport struct { // // Dial runs concurrently with calls to RoundTrip. // A RoundTrip call that initiates a dial may end up using - // an connection dialed previously when the earlier connection + // a connection dialed previously when the earlier connection // becomes idle before the later Dial completes. // // Deprecated: Use DialContext instead, which allows the transport @@ -278,7 +278,7 @@ func (t *Transport) onceSetNextProtoDefaults() { // If they've already configured http2 with // golang.org/x/net/http2 instead of the bundled copy, try to - // get at its http2.Transport value (via the the "https" + // get at its http2.Transport value (via the "https" // altproto map) so we can call CloseIdleConnections on it if // requested. (Issue 22891) altProto, _ := t.altProto.Load().(map[string]RoundTripper) @@ -286,6 +286,7 @@ func (t *Transport) onceSetNextProtoDefaults() { if v := rv.Field(0); v.CanInterface() { if h2i, ok := v.Interface().(h2Transport); ok { t.h2transport = h2i + return } } } @@ -381,6 +382,19 @@ func (tr *transportRequest) setError(err error) { tr.mu.Unlock() } +// useRegisteredProtocol reports whether an alternate protocol (as reqistered +// with Transport.RegisterProtocol) should be respected for this request. +func (t *Transport) useRegisteredProtocol(req *Request) bool { + if req.URL.Scheme == "https" && req.requiresHTTP1() { + // If this request requires HTTP/1, don't use the + // "https" alternate protocol, which is used by the + // HTTP/2 code to take over requests if there's an + // existing cached HTTP/2 connection. + return false + } + return true +} + // roundTrip implements a RoundTripper over HTTP. func (t *Transport) roundTrip(req *Request) (*Response, error) { t.nextProtoOnce.Do(t.onceSetNextProtoDefaults) @@ -410,10 +424,12 @@ func (t *Transport) roundTrip(req *Request) (*Response, error) { } } - altProto, _ := t.altProto.Load().(map[string]RoundTripper) - if altRT := altProto[scheme]; altRT != nil { - if resp, err := altRT.RoundTrip(req); err != ErrSkipAltProtocol { - return resp, err + if t.useRegisteredProtocol(req) { + altProto, _ := t.altProto.Load().(map[string]RoundTripper) + if altRT := altProto[scheme]; altRT != nil { + if resp, err := altRT.RoundTrip(req); err != ErrSkipAltProtocol { + return resp, err + } } } if !isHTTP { @@ -477,9 +493,8 @@ func (t *Transport) roundTrip(req *Request) (*Response, error) { } testHookRoundTripRetried() - // Rewind the body if we're able to. (HTTP/2 does this itself so we only - // need to do it for HTTP/1.1 connections.) - if req.GetBody != nil && pconn.alt == nil { + // Rewind the body if we're able to. + if req.GetBody != nil { newReq := *req var err error newReq.Body, err = req.GetBody() @@ -653,6 +668,7 @@ func (t *Transport) connectMethodForRequest(treq *transportRequest) (cm connectM } } } + cm.onlyH1 = treq.requiresHTTP1() return cm, err } @@ -1155,6 +1171,9 @@ func (pconn *persistConn) addTLS(name string, trace *httptrace.ClientTrace) erro if cfg.ServerName == "" { cfg.ServerName = name } + if pconn.cacheKey.onlyH1 { + cfg.NextProtos = nil + } plainConn := pconn.conn tlsConn := tls.Client(plainConn, cfg) errc := make(chan error, 2) @@ -1361,10 +1380,11 @@ func (w persistConnWriter) Write(p []byte) (n int, err error) { // // A connect method may be of the following types: // -// Cache key form Description -// ----------------- ------------------------- +// connectMethod.key().String() Description +// ------------------------------ ------------------------- // |http|foo.com http directly to server, no proxy // |https|foo.com https directly to server, no proxy +// |https,h1|foo.com https directly to server w/o HTTP/2, no proxy // http://proxy.com|https|foo.com http to proxy, then CONNECT to foo.com // http://proxy.com|http http to proxy, http to anywhere after that // socks5://proxy.com|http|foo.com socks5 to proxy, then http to foo.com @@ -1379,6 +1399,7 @@ type connectMethod struct { // then targetAddr is not included in the connect method key, because the socket can // be reused for different targetAddr values. targetAddr string + onlyH1 bool // whether to disable HTTP/2 and force HTTP/1 } func (cm *connectMethod) key() connectMethodKey { @@ -1394,6 +1415,7 @@ func (cm *connectMethod) key() connectMethodKey { proxy: proxyStr, scheme: cm.targetScheme, addr: targetAddr, + onlyH1: cm.onlyH1, } } @@ -1428,11 +1450,16 @@ func (cm *connectMethod) tlsHost() string { // a URL. type connectMethodKey struct { proxy, scheme, addr string + onlyH1 bool } func (k connectMethodKey) String() string { // Only used by tests. - return fmt.Sprintf("%s|%s|%s", k.proxy, k.scheme, k.addr) + var h1 string + if k.onlyH1 { + h1 = ",h1" + } + return fmt.Sprintf("%s|%s%s|%s", k.proxy, k.scheme, h1, k.addr) } // persistConn wraps a connection, usually a persistent one @@ -1607,6 +1634,11 @@ func (pc *persistConn) mapRoundTripError(req *transportRequest, startBytesWritte return err } +// errCallerOwnsConn is an internal sentinel error used when we hand +// off a writable response.Body to the caller. We use this to prevent +// closing a net.Conn that is now owned by the caller. +var errCallerOwnsConn = errors.New("read loop ending; caller owns writable underlying conn") + func (pc *persistConn) readLoop() { closeErr := errReadLoopExiting // default value, if not changed below defer func() { @@ -1681,16 +1713,17 @@ func (pc *persistConn) readLoop() { pc.numExpectedResponses-- pc.mu.Unlock() + bodyWritable := resp.bodyIsWritable() hasBody := rc.req.Method != "HEAD" && resp.ContentLength != 0 - if resp.Close || rc.req.Close || resp.StatusCode <= 199 { + if resp.Close || rc.req.Close || resp.StatusCode <= 199 || bodyWritable { // Don't do keep-alive on error if either party requested a close // or we get an unexpected informational (1xx) response. // StatusCode 100 is already handled above. alive = false } - if !hasBody { + if !hasBody || bodyWritable { pc.t.setReqCanceler(rc.req, nil) // Put the idle conn back into the pool before we send the response @@ -1704,6 +1737,10 @@ func (pc *persistConn) readLoop() { pc.wroteRequest() && tryPutIdleConn(trace) + if bodyWritable { + closeErr = errCallerOwnsConn + } + select { case rc.ch <- responseAndError{res: resp}: case <-rc.callerGone: @@ -1848,6 +1885,10 @@ func (pc *persistConn) readResponse(rc requestAndChan, trace *httptrace.ClientTr } break } + if resp.isProtocolSwitch() { + resp.Body = newReadWriteCloserBody(pc.br, pc.conn) + } + resp.TLS = pc.tlsState return } @@ -1874,6 +1915,38 @@ func (pc *persistConn) waitForContinue(continueCh <-chan struct{}) func() bool { } } +func newReadWriteCloserBody(br *bufio.Reader, rwc io.ReadWriteCloser) io.ReadWriteCloser { + body := &readWriteCloserBody{ReadWriteCloser: rwc} + if br.Buffered() != 0 { + body.br = br + } + return body +} + +// readWriteCloserBody is the Response.Body type used when we want to +// give users write access to the Body through the underlying +// connection (TCP, unless using custom dialers). This is then +// the concrete type for a Response.Body on the 101 Switching +// Protocols response, as used by WebSockets, h2c, etc. +type readWriteCloserBody struct { + br *bufio.Reader // used until empty + io.ReadWriteCloser +} + +func (b *readWriteCloserBody) Read(p []byte) (n int, err error) { + if b.br != nil { + if n := b.br.Buffered(); len(p) > n { + p = p[:n] + } + n, err = b.br.Read(p) + if b.br.Buffered() == 0 { + b.br = nil + } + return n, err + } + return b.ReadWriteCloser.Read(p) +} + // nothingWrittenError wraps a write errors which ended up writing zero bytes. type nothingWrittenError struct { error @@ -2043,7 +2116,7 @@ func (pc *persistConn) roundTrip(req *transportRequest) (resp *Response, err err req.Method != "HEAD" { // Request gzip only, not deflate. Deflate is ambiguous and // not as universally supported anyway. - // See: http://www.gzip.org/zlib/zlib_faq.html#faq38 + // See: https://zlib.net/zlib_faq.html#faq39 // // Note that we don't request this for HEAD requests, // due to a bug in nginx: @@ -2062,7 +2135,7 @@ func (pc *persistConn) roundTrip(req *transportRequest) (resp *Response, err err continueCh = make(chan struct{}, 1) } - if pc.t.DisableKeepAlives { + if pc.t.DisableKeepAlives && !req.wantsClose() { req.extraHeaders().Set("Connection", "close") } @@ -2193,7 +2266,9 @@ func (pc *persistConn) closeLocked(err error) { // freelist for http2. That's done by the // alternate protocol's RoundTripper. } else { - pc.conn.Close() + if err != errCallerOwnsConn { + pc.conn.Close() + } close(pc.closech) } } @@ -2341,7 +2416,7 @@ type fakeLocker struct{} func (fakeLocker) Lock() {} func (fakeLocker) Unlock() {} -// clneTLSConfig returns a shallow clone of cfg, or a new zero tls.Config if +// cloneTLSConfig returns a shallow clone of cfg, or a new zero tls.Config if // cfg is nil. This is safe to call even if cfg is in active use by a TLS // client or server. func cloneTLSConfig(cfg *tls.Config) *tls.Config { diff --git a/libgo/go/net/http/transport_internal_test.go b/libgo/go/net/http/transport_internal_test.go index a5f29c97a90..92729e65b26 100644 --- a/libgo/go/net/http/transport_internal_test.go +++ b/libgo/go/net/http/transport_internal_test.go @@ -7,8 +7,13 @@ package http import ( + "bytes" + "crypto/tls" "errors" + "io" + "io/ioutil" "net" + "net/http/internal" "strings" "testing" ) @@ -178,3 +183,81 @@ func TestTransportShouldRetryRequest(t *testing.T) { } } } + +type roundTripFunc func(r *Request) (*Response, error) + +func (f roundTripFunc) RoundTrip(r *Request) (*Response, error) { + return f(r) +} + +// Issue 25009 +func TestTransportBodyAltRewind(t *testing.T) { + cert, err := tls.X509KeyPair(internal.LocalhostCert, internal.LocalhostKey) + if err != nil { + t.Fatal(err) + } + ln := newLocalListener(t) + defer ln.Close() + + go func() { + tln := tls.NewListener(ln, &tls.Config{ + NextProtos: []string{"foo"}, + Certificates: []tls.Certificate{cert}, + }) + for i := 0; i < 2; i++ { + sc, err := tln.Accept() + if err != nil { + t.Error(err) + return + } + if err := sc.(*tls.Conn).Handshake(); err != nil { + t.Error(err) + return + } + sc.Close() + } + }() + + addr := ln.Addr().String() + req, _ := NewRequest("POST", "https://example.org/", bytes.NewBufferString("request")) + roundTripped := false + tr := &Transport{ + DisableKeepAlives: true, + TLSNextProto: map[string]func(string, *tls.Conn) RoundTripper{ + "foo": func(authority string, c *tls.Conn) RoundTripper { + return roundTripFunc(func(r *Request) (*Response, error) { + n, _ := io.Copy(ioutil.Discard, r.Body) + if n == 0 { + t.Error("body length is zero") + } + if roundTripped { + return &Response{ + Body: NoBody, + StatusCode: 200, + }, nil + } + roundTripped = true + return nil, http2noCachedConnError{} + }) + }, + }, + DialTLS: func(_, _ string) (net.Conn, error) { + tc, err := tls.Dial("tcp", addr, &tls.Config{ + InsecureSkipVerify: true, + NextProtos: []string{"foo"}, + }) + if err != nil { + return nil, err + } + if err := tc.Handshake(); err != nil { + return nil, err + } + return tc, nil + }, + } + c := &Client{Transport: tr} + _, err = c.Do(req) + if err != nil { + t.Error(err) + } +} diff --git a/libgo/go/net/http/transport_test.go b/libgo/go/net/http/transport_test.go index aa8beb9357c..6e075847dde 100644 --- a/libgo/go/net/http/transport_test.go +++ b/libgo/go/net/http/transport_test.go @@ -21,7 +21,6 @@ import ( "errors" "fmt" "internal/nettrace" - "internal/testenv" "io" "io/ioutil" "log" @@ -42,6 +41,8 @@ import ( "sync/atomic" "testing" "time" + + "internal/x/net/http/httpguts" ) // TODO: test 5 pipelined requests with responses: 1) OK, 2) OK, Connection: Close @@ -311,6 +312,58 @@ func TestTransportConnectionCloseOnRequestDisableKeepAlive(t *testing.T) { } } +// Test that Transport only sends one "Connection: close", regardless of +// how "close" was indicated. +func TestTransportRespectRequestWantsClose(t *testing.T) { + tests := []struct { + disableKeepAlives bool + close bool + }{ + {disableKeepAlives: false, close: false}, + {disableKeepAlives: false, close: true}, + {disableKeepAlives: true, close: false}, + {disableKeepAlives: true, close: true}, + } + + for _, tc := range tests { + t.Run(fmt.Sprintf("DisableKeepAlive=%v,RequestClose=%v", tc.disableKeepAlives, tc.close), + func(t *testing.T) { + defer afterTest(t) + ts := httptest.NewServer(hostPortHandler) + defer ts.Close() + + c := ts.Client() + c.Transport.(*Transport).DisableKeepAlives = tc.disableKeepAlives + req, err := NewRequest("GET", ts.URL, nil) + if err != nil { + t.Fatal(err) + } + count := 0 + trace := &httptrace.ClientTrace{ + WroteHeaderField: func(key string, field []string) { + if key != "Connection" { + return + } + if httpguts.HeaderValuesContainsToken(field, "close") { + count += 1 + } + }, + } + req = req.WithContext(httptrace.WithClientTrace(req.Context(), trace)) + req.Close = tc.close + res, err := c.Do(req) + if err != nil { + t.Fatal(err) + } + defer res.Body.Close() + if want := tc.disableKeepAlives || tc.close; count > 1 || (count == 1) != want { + t.Errorf("expecting want:%v, got 'Connection: close':%d", want, count) + } + }) + } + +} + func TestTransportIdleCacheKeys(t *testing.T) { defer afterTest(t) ts := httptest.NewServer(hostPortHandler) @@ -2726,7 +2779,6 @@ func TestTransportTLSHandshakeTimeout(t *testing.T) { // Trying to repro golang.org/issue/3514 func TestTLSServerClosesConnection(t *testing.T) { defer afterTest(t) - testenv.SkipFlaky(t, 7634) closedc := make(chan bool, 1) ts := httptest.NewTLSServer(HandlerFunc(func(w ResponseWriter, r *Request) { @@ -3827,9 +3879,9 @@ func testTransportEventTrace(t *testing.T, h2 bool, noHooks bool) { } // Install a fake DNS server. - ctx := context.WithValue(context.Background(), nettrace.LookupIPAltResolverKey{}, func(ctx context.Context, host string) ([]net.IPAddr, error) { + ctx := context.WithValue(context.Background(), nettrace.LookupIPAltResolverKey{}, func(ctx context.Context, network, host string) ([]net.IPAddr, error) { if host != "dns-is-faked.golang" { - t.Errorf("unexpected DNS host lookup for %q", host) + t.Errorf("unexpected DNS host lookup for %q/%q", network, host) return nil, nil } return []net.IPAddr{{IP: net.ParseIP(ip)}}, nil @@ -4178,7 +4230,7 @@ func TestTransportMaxIdleConns(t *testing.T) { if err != nil { t.Fatal(err) } - ctx := context.WithValue(context.Background(), nettrace.LookupIPAltResolverKey{}, func(ctx context.Context, host string) ([]net.IPAddr, error) { + ctx := context.WithValue(context.Background(), nettrace.LookupIPAltResolverKey{}, func(ctx context.Context, _, host string) ([]net.IPAddr, error) { return []net.IPAddr{{IP: net.ParseIP(ip)}}, nil }) @@ -4281,7 +4333,7 @@ func testTransportIdleConnTimeout(t *testing.T, h2 bool) { } // Issue 16208: Go 1.7 crashed after Transport.IdleConnTimeout if an -// HTTP/2 connection was established but but its caller no longer +// HTTP/2 connection was established but its caller no longer // wanted it. (Assuming the connection cache was enabled, which it is // by default) // @@ -4418,9 +4470,9 @@ func testTransportIDNA(t *testing.T, h2 bool) { } // Install a fake DNS server. - ctx := context.WithValue(context.Background(), nettrace.LookupIPAltResolverKey{}, func(ctx context.Context, host string) ([]net.IPAddr, error) { + ctx := context.WithValue(context.Background(), nettrace.LookupIPAltResolverKey{}, func(ctx context.Context, network, host string) ([]net.IPAddr, error) { if host != punyDomain { - t.Errorf("got DNS host lookup for %q; want %q", host, punyDomain) + t.Errorf("got DNS host lookup for %q/%q; want %q", network, host, punyDomain) return nil, nil } return []net.IPAddr{{IP: net.ParseIP(ip)}}, nil @@ -4755,7 +4807,7 @@ func TestClientTimeoutKillsConn_BeforeHeaders(t *testing.T) { } case <-time.After(timeout * 10): // If we didn't get into the Handler in 50ms, that probably means - // the builder was just slow and the the Get failed in that time + // the builder was just slow and the Get failed in that time // but never made it to the server. That's fine. We'll usually // test the part above on faster machines. t.Skip("skipping test on slow builder") @@ -4766,7 +4818,7 @@ func TestClientTimeoutKillsConn_BeforeHeaders(t *testing.T) { // conn is closed so that it's not reused. // // This is the test variant that has the server send response headers -// first, and time out during the the write of the response body. +// first, and time out during the write of the response body. func TestClientTimeoutKillsConn_AfterHeaders(t *testing.T) { setParallel(t) defer afterTest(t) @@ -4838,3 +4890,172 @@ func TestClientTimeoutKillsConn_AfterHeaders(t *testing.T) { t.Fatal("timeout") } } + +func TestTransportResponseBodyWritableOnProtocolSwitch(t *testing.T) { + setParallel(t) + defer afterTest(t) + done := make(chan struct{}) + defer close(done) + cst := newClientServerTest(t, h1Mode, HandlerFunc(func(w ResponseWriter, r *Request) { + conn, _, err := w.(Hijacker).Hijack() + if err != nil { + t.Error(err) + return + } + defer conn.Close() + io.WriteString(conn, "HTTP/1.1 101 Switching Protocols Hi\r\nConnection: upgRADe\r\nUpgrade: foo\r\n\r\nSome buffered data\n") + bs := bufio.NewScanner(conn) + bs.Scan() + fmt.Fprintf(conn, "%s\n", strings.ToUpper(bs.Text())) + <-done + })) + defer cst.close() + + req, _ := NewRequest("GET", cst.ts.URL, nil) + req.Header.Set("Upgrade", "foo") + req.Header.Set("Connection", "upgrade") + res, err := cst.c.Do(req) + if err != nil { + t.Fatal(err) + } + if res.StatusCode != 101 { + t.Fatalf("expected 101 switching protocols; got %v, %v", res.Status, res.Header) + } + rwc, ok := res.Body.(io.ReadWriteCloser) + if !ok { + t.Fatalf("expected a ReadWriteCloser; got a %T", res.Body) + } + defer rwc.Close() + bs := bufio.NewScanner(rwc) + if !bs.Scan() { + t.Fatalf("expected readable input") + } + if got, want := bs.Text(), "Some buffered data"; got != want { + t.Errorf("read %q; want %q", got, want) + } + io.WriteString(rwc, "echo\n") + if !bs.Scan() { + t.Fatalf("expected another line") + } + if got, want := bs.Text(), "ECHO"; got != want { + t.Errorf("read %q; want %q", got, want) + } +} + +func TestTransportCONNECTBidi(t *testing.T) { + defer afterTest(t) + const target = "backend:443" + cst := newClientServerTest(t, h1Mode, HandlerFunc(func(w ResponseWriter, r *Request) { + if r.Method != "CONNECT" { + t.Errorf("unexpected method %q", r.Method) + w.WriteHeader(500) + return + } + if r.RequestURI != target { + t.Errorf("unexpected CONNECT target %q", r.RequestURI) + w.WriteHeader(500) + return + } + nc, brw, err := w.(Hijacker).Hijack() + if err != nil { + t.Error(err) + return + } + defer nc.Close() + nc.Write([]byte("HTTP/1.1 200 OK\r\n\r\n")) + // Switch to a little protocol that capitalize its input lines: + for { + line, err := brw.ReadString('\n') + if err != nil { + if err != io.EOF { + t.Error(err) + } + return + } + io.WriteString(brw, strings.ToUpper(line)) + brw.Flush() + } + })) + defer cst.close() + pr, pw := io.Pipe() + defer pw.Close() + req, err := NewRequest("CONNECT", cst.ts.URL, pr) + if err != nil { + t.Fatal(err) + } + req.URL.Opaque = target + res, err := cst.c.Do(req) + if err != nil { + t.Fatal(err) + } + defer res.Body.Close() + if res.StatusCode != 200 { + t.Fatalf("status code = %d; want 200", res.StatusCode) + } + br := bufio.NewReader(res.Body) + for _, str := range []string{"foo", "bar", "baz"} { + fmt.Fprintf(pw, "%s\n", str) + got, err := br.ReadString('\n') + if err != nil { + t.Fatal(err) + } + got = strings.TrimSpace(got) + want := strings.ToUpper(str) + if got != want { + t.Fatalf("got %q; want %q", got, want) + } + } +} + +func TestTransportRequestReplayable(t *testing.T) { + someBody := ioutil.NopCloser(strings.NewReader("")) + tests := []struct { + name string + req *Request + want bool + }{ + { + name: "GET", + req: &Request{Method: "GET"}, + want: true, + }, + { + name: "GET_http.NoBody", + req: &Request{Method: "GET", Body: NoBody}, + want: true, + }, + { + name: "GET_body", + req: &Request{Method: "GET", Body: someBody}, + want: false, + }, + { + name: "POST", + req: &Request{Method: "POST"}, + want: false, + }, + { + name: "POST_idempotency-key", + req: &Request{Method: "POST", Header: Header{"Idempotency-Key": {"x"}}}, + want: true, + }, + { + name: "POST_x-idempotency-key", + req: &Request{Method: "POST", Header: Header{"X-Idempotency-Key": {"x"}}}, + want: true, + }, + { + name: "POST_body", + req: &Request{Method: "POST", Header: Header{"Idempotency-Key": {"x"}}, Body: someBody}, + want: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got := tt.req.ExportIsReplayable() + if got != tt.want { + t.Errorf("replyable = %v; want %v", got, tt.want) + } + }) + } +} diff --git a/libgo/go/net/interface.go b/libgo/go/net/interface.go index 375a4568e3f..58248560a25 100644 --- a/libgo/go/net/interface.go +++ b/libgo/go/net/interface.go @@ -13,8 +13,8 @@ import ( // BUG(mikio): On JS and NaCl, methods and functions related to // Interface are not implemented. -// BUG(mikio): On DragonFly BSD, NetBSD, OpenBSD, Plan 9 and Solaris, -// the MulticastAddrs method of Interface is not implemented. +// BUG(mikio): On AIX, DragonFly BSD, NetBSD, OpenBSD, Plan 9 and +// Solaris, the MulticastAddrs method of Interface is not implemented. var ( errInvalidInterface = errors.New("invalid network interface") @@ -102,7 +102,7 @@ func Interfaces() ([]Interface, error) { return nil, &OpError{Op: "route", Net: "ip+net", Source: nil, Addr: nil, Err: err} } if len(ift) != 0 { - zoneCache.update(ift) + zoneCache.update(ift, false) } return ift, nil } @@ -159,7 +159,7 @@ func InterfaceByName(name string) (*Interface, error) { return nil, &OpError{Op: "route", Net: "ip+net", Source: nil, Addr: nil, Err: err} } if len(ift) != 0 { - zoneCache.update(ift) + zoneCache.update(ift, false) } for _, ifi := range ift { if name == ifi.Name { @@ -187,18 +187,21 @@ var zoneCache = ipv6ZoneCache{ toName: make(map[int]string), } -func (zc *ipv6ZoneCache) update(ift []Interface) { +// update refreshes the network interface information if the cache was last +// updated more than 1 minute ago, or if force is set. It reports whether the +// cache was updated. +func (zc *ipv6ZoneCache) update(ift []Interface, force bool) (updated bool) { zc.Lock() defer zc.Unlock() now := time.Now() - if zc.lastFetched.After(now.Add(-60 * time.Second)) { - return + if !force && zc.lastFetched.After(now.Add(-60*time.Second)) { + return false } zc.lastFetched = now if len(ift) == 0 { var err error if ift, err = interfaceTable(0); err != nil { - return + return false } } zc.toIndex = make(map[string]int, len(ift)) @@ -209,17 +212,24 @@ func (zc *ipv6ZoneCache) update(ift []Interface) { zc.toName[ifi.Index] = ifi.Name } } + return true } func (zc *ipv6ZoneCache) name(index int) string { if index == 0 { return "" } - zoneCache.update(nil) + updated := zoneCache.update(nil, false) zoneCache.RLock() - defer zoneCache.RUnlock() name, ok := zoneCache.toName[index] - if !ok { + zoneCache.RUnlock() + if !ok && !updated { + zoneCache.update(nil, true) + zoneCache.RLock() + name, ok = zoneCache.toName[index] + zoneCache.RUnlock() + } + if !ok { // last resort name = uitoa(uint(index)) } return name @@ -229,11 +239,17 @@ func (zc *ipv6ZoneCache) index(name string) int { if name == "" { return 0 } - zoneCache.update(nil) + updated := zoneCache.update(nil, false) zoneCache.RLock() - defer zoneCache.RUnlock() index, ok := zoneCache.toIndex[name] - if !ok { + zoneCache.RUnlock() + if !ok && !updated { + zoneCache.update(nil, true) + zoneCache.RLock() + index, ok = zoneCache.toIndex[name] + zoneCache.RUnlock() + } + if !ok { // last resort index, _, _ = dtoi(name) } return index diff --git a/libgo/go/net/interface_aix.go b/libgo/go/net/interface_aix.go new file mode 100644 index 00000000000..9a8b5bbdb1b --- /dev/null +++ b/libgo/go/net/interface_aix.go @@ -0,0 +1,183 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package net + +import ( + "internal/syscall/unix" + "syscall" + "unsafe" +) + +type rawSockaddrDatalink struct { + Len uint8 + Family uint8 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [120]byte +} + +type ifreq struct { + Name [16]uint8 + Ifru [16]byte +} + +const _KINFO_RT_IFLIST = (0x1 << 8) | 3 | (1 << 30) + +const _RTAX_NETMASK = 2 +const _RTAX_IFA = 5 +const _RTAX_MAX = 8 + +func getIfList() ([]byte, error) { + needed, err := syscall.Getkerninfo(_KINFO_RT_IFLIST, 0, 0, 0) + if err != nil { + return nil, err + } + tab := make([]byte, needed) + _, err = syscall.Getkerninfo(_KINFO_RT_IFLIST, uintptr(unsafe.Pointer(&tab[0])), uintptr(unsafe.Pointer(&needed)), 0) + if err != nil { + return nil, err + } + return tab[:needed], nil +} + +// If the ifindex is zero, interfaceTable returns mappings of all +// network interfaces. Otherwise it returns a mapping of a specific +// interface. +func interfaceTable(ifindex int) ([]Interface, error) { + tab, err := getIfList() + if err != nil { + return nil, err + } + + var ift []Interface + for len(tab) > 0 { + ifm := (*syscall.IfMsgHdr)(unsafe.Pointer(&tab[0])) + if ifm.Msglen == 0 { + break + } + if ifm.Type == syscall.RTM_IFINFO { + if ifindex == 0 || ifindex == int(ifm.Index) { + sdl := (*rawSockaddrDatalink)(unsafe.Pointer(&tab[syscall.SizeofIfMsghdr])) + + ifi := &Interface{Index: int(ifm.Index), Flags: linkFlags(ifm.Flags)} + ifi.Name = string(sdl.Data[:sdl.Nlen]) + ifi.HardwareAddr = sdl.Data[sdl.Nlen : sdl.Nlen+sdl.Alen] + + // Retrieve MTU + ifr := &ifreq{} + copy(ifr.Name[:], ifi.Name) + sock, err := syscall.Socket(syscall.AF_INET, syscall.SOCK_DGRAM, 0) + if err != nil { + return nil, err + } + err = unix.Ioctl(sock, syscall.SIOCGIFMTU, uintptr(unsafe.Pointer(ifr))) + if err != nil { + return nil, err + } + ifi.MTU = int(ifr.Ifru[0])<<24 | int(ifr.Ifru[1])<<16 | int(ifr.Ifru[2])<<8 | int(ifr.Ifru[3]) + + ift = append(ift, *ifi) + if ifindex == int(ifm.Index) { + break + } + } + } + tab = tab[ifm.Msglen:] + } + + return ift, nil +} + +func linkFlags(rawFlags int32) Flags { + var f Flags + if rawFlags&syscall.IFF_UP != 0 { + f |= FlagUp + } + if rawFlags&syscall.IFF_BROADCAST != 0 { + f |= FlagBroadcast + } + if rawFlags&syscall.IFF_LOOPBACK != 0 { + f |= FlagLoopback + } + if rawFlags&syscall.IFF_POINTOPOINT != 0 { + f |= FlagPointToPoint + } + if rawFlags&syscall.IFF_MULTICAST != 0 { + f |= FlagMulticast + } + return f +} + +// If the ifi is nil, interfaceAddrTable returns addresses for all +// network interfaces. Otherwise it returns addresses for a specific +// interface. +func interfaceAddrTable(ifi *Interface) ([]Addr, error) { + tab, err := getIfList() + if err != nil { + return nil, err + } + + var ifat []Addr + for len(tab) > 0 { + ifm := (*syscall.IfMsgHdr)(unsafe.Pointer(&tab[0])) + if ifm.Msglen == 0 { + break + } + if ifm.Type == syscall.RTM_NEWADDR { + if ifi == nil || ifi.Index == int(ifm.Index) { + mask := ifm.Addrs + off := uint(syscall.SizeofIfMsghdr) + + var iprsa, nmrsa *syscall.RawSockaddr + for i := uint(0); i < _RTAX_MAX; i++ { + if mask&(1<= 0 { + if bytealg.IndexByteString(host, ':') >= 0 { return addrErr(hostport, tooManyColons) } } - if byteIndex(hostport[j:], '[') >= 0 { + if bytealg.IndexByteString(hostport[j:], '[') >= 0 { return addrErr(hostport, "unexpected '[' in address") } - if byteIndex(hostport[k:], ']') >= 0 { + if bytealg.IndexByteString(hostport[k:], ']') >= 0 { return addrErr(hostport, "unexpected ']' in address") } @@ -226,7 +227,7 @@ func splitHostZone(s string) (host, zone string) { func JoinHostPort(host, port string) string { // We assume that host is a literal IPv6 address if host has // colons. - if byteIndex(host, ':') >= 0 { + if bytealg.IndexByteString(host, ':') >= 0 { return "[" + host + "]:" + port } return host + ":" + port @@ -276,7 +277,7 @@ func (r *Resolver) internetAddrList(ctx context.Context, net, addr string) (addr } // Try as a literal IP address, then as a DNS name. - ips, err := r.LookupIPAddr(ctx, host) + ips, err := r.lookupIPAddr(ctx, net, host) if err != nil { return nil, err } diff --git a/libgo/go/net/ipsock_plan9.go b/libgo/go/net/ipsock_plan9.go index 312e4adb47d..d226585e086 100644 --- a/libgo/go/net/ipsock_plan9.go +++ b/libgo/go/net/ipsock_plan9.go @@ -6,6 +6,7 @@ package net import ( "context" + "internal/bytealg" "os" "syscall" ) @@ -49,7 +50,7 @@ func probe(filename, query string) bool { // parsePlan9Addr parses address of the form [ip!]port (e.g. 127.0.0.1!80). func parsePlan9Addr(s string) (ip IP, iport int, err error) { addr := IPv4zero // address contains port only - i := byteIndex(s, '!') + i := bytealg.IndexByteString(s, '!') if i >= 0 { addr = ParseIP(s[:i]) if addr == nil { diff --git a/libgo/go/net/ipsock_posix.go b/libgo/go/net/ipsock_posix.go index 08804ca577b..947f4ef6148 100644 --- a/libgo/go/net/ipsock_posix.go +++ b/libgo/go/net/ipsock_posix.go @@ -134,7 +134,7 @@ func favoriteAddrFamily(network string, laddr, raddr sockaddr, mode string) (fam } func internetSocket(ctx context.Context, net string, laddr, raddr sockaddr, sotype, proto int, mode string, ctrlFn func(string, string, syscall.RawConn) error) (fd *netFD, err error) { - if (runtime.GOOS == "windows" || runtime.GOOS == "openbsd" || runtime.GOOS == "nacl") && mode == "dial" && raddr.isWildcard() { + if (runtime.GOOS == "aix" || runtime.GOOS == "windows" || runtime.GOOS == "openbsd" || runtime.GOOS == "nacl") && mode == "dial" && raddr.isWildcard() { raddr = raddr.toLocal(net) } family, ipv6only := favoriteAddrFamily(net, laddr, raddr, mode) diff --git a/libgo/go/net/listen_test.go b/libgo/go/net/listen_test.go index ffce8e22ec9..6c3f70cc7bf 100644 --- a/libgo/go/net/listen_test.go +++ b/libgo/go/net/listen_test.go @@ -674,7 +674,7 @@ func checkMulticastListener(c *UDPConn, ip IP) error { func multicastRIBContains(ip IP) (bool, error) { switch runtime.GOOS { - case "dragonfly", "netbsd", "openbsd", "plan9", "solaris", "windows": + case "aix", "dragonfly", "netbsd", "openbsd", "plan9", "solaris", "windows": return true, nil // not implemented yet case "linux": if runtime.GOARCH == "arm" || runtime.GOARCH == "alpha" { diff --git a/libgo/go/net/lookup.go b/libgo/go/net/lookup.go index e0f21fa9a8d..e10889331e4 100644 --- a/libgo/go/net/lookup.go +++ b/libgo/go/net/lookup.go @@ -97,6 +97,19 @@ func lookupPortMap(network, service string) (port int, error error) { return 0, &AddrError{Err: "unknown port", Addr: network + "/" + service} } +// ipVersion returns the provided network's IP version: '4', '6' or 0 +// if network does not end in a '4' or '6' byte. +func ipVersion(network string) byte { + if network == "" { + return 0 + } + n := network[len(network)-1] + if n != '4' && n != '6' { + n = 0 + } + return n +} + // DefaultResolver is the resolver used by the package-level Lookup // functions and by Dialers without a specified Resolver. var DefaultResolver = &Resolver{} @@ -189,6 +202,39 @@ func LookupIP(host string) ([]IP, error) { // LookupIPAddr looks up host using the local resolver. // It returns a slice of that host's IPv4 and IPv6 addresses. func (r *Resolver) LookupIPAddr(ctx context.Context, host string) ([]IPAddr, error) { + return r.lookupIPAddr(ctx, "ip", host) +} + +// onlyValuesCtx is a context that uses an underlying context +// for value lookup if the underlying context hasn't yet expired. +type onlyValuesCtx struct { + context.Context + lookupValues context.Context +} + +var _ context.Context = (*onlyValuesCtx)(nil) + +// Value performs a lookup if the original context hasn't expired. +func (ovc *onlyValuesCtx) Value(key interface{}) interface{} { + select { + case <-ovc.lookupValues.Done(): + return nil + default: + return ovc.lookupValues.Value(key) + } +} + +// withUnexpiredValuesPreserved returns a context.Context that only uses lookupCtx +// for its values, otherwise it is never canceled and has no deadline. +// If the lookup context expires, any looked up values will return nil. +// See Issue 28600. +func withUnexpiredValuesPreserved(lookupCtx context.Context) context.Context { + return &onlyValuesCtx{Context: context.Background(), lookupValues: lookupCtx} +} + +// lookupIPAddr looks up host using the local resolver and particular network. +// It returns a slice of that host's IPv4 and IPv6 addresses. +func (r *Resolver) lookupIPAddr(ctx context.Context, network, host string) ([]IPAddr, error) { // Make sure that no matter what we do later, host=="" is rejected. // parseIP, for example, does accept empty strings. if host == "" { @@ -205,20 +251,21 @@ func (r *Resolver) LookupIPAddr(ctx context.Context, host string) ([]IPAddr, err // can be overridden by tests. This is needed by net/http, so it // uses a context key instead of unexported variables. resolverFunc := r.lookupIP - if alt, _ := ctx.Value(nettrace.LookupIPAltResolverKey{}).(func(context.Context, string) ([]IPAddr, error)); alt != nil { + if alt, _ := ctx.Value(nettrace.LookupIPAltResolverKey{}).(func(context.Context, string, string) ([]IPAddr, error)); alt != nil { resolverFunc = alt } // We don't want a cancelation of ctx to affect the // lookupGroup operation. Otherwise if our context gets // canceled it might cause an error to be returned to a lookup - // using a completely different context. - lookupGroupCtx, lookupGroupCancel := context.WithCancel(context.Background()) + // using a completely different context. However we need to preserve + // only the values in context. See Issue 28600. + lookupGroupCtx, lookupGroupCancel := context.WithCancel(withUnexpiredValuesPreserved(ctx)) dnsWaitGroup.Add(1) ch, called := r.getLookupGroup().DoChan(host, func() (interface{}, error) { defer dnsWaitGroup.Done() - return testHookLookupIP(lookupGroupCtx, resolverFunc, host) + return testHookLookupIP(lookupGroupCtx, resolverFunc, network, host) }) if !called { dnsWaitGroup.Done() @@ -289,6 +336,13 @@ func LookupPort(network, service string) (port int, err error) { func (r *Resolver) LookupPort(ctx context.Context, network, service string) (port int, err error) { port, needsLookup := parsePort(service) if needsLookup { + switch network { + case "tcp", "tcp4", "tcp6", "udp", "udp4", "udp6": + case "": // a hint wildcard for Go 1.0 undocumented behavior + network = "ip" + default: + return 0, &AddrError{Err: "unknown network", Addr: network} + } port, err = r.lookupPort(ctx, network, service) if err != nil { return 0, err diff --git a/libgo/go/net/lookup_fake.go b/libgo/go/net/lookup_fake.go index d3d1dbc9003..6c8a151bcac 100644 --- a/libgo/go/net/lookup_fake.go +++ b/libgo/go/net/lookup_fake.go @@ -19,7 +19,7 @@ func (*Resolver) lookupHost(ctx context.Context, host string) (addrs []string, e return nil, syscall.ENOPROTOOPT } -func (*Resolver) lookupIP(ctx context.Context, host string) (addrs []IPAddr, err error) { +func (*Resolver) lookupIP(ctx context.Context, network, host string) (addrs []IPAddr, err error) { return nil, syscall.ENOPROTOOPT } diff --git a/libgo/go/net/lookup_plan9.go b/libgo/go/net/lookup_plan9.go index 5547f0b0eeb..70805ddf4cd 100644 --- a/libgo/go/net/lookup_plan9.go +++ b/libgo/go/net/lookup_plan9.go @@ -7,6 +7,7 @@ package net import ( "context" "errors" + "internal/bytealg" "io" "os" ) @@ -135,7 +136,7 @@ func lookupProtocol(ctx context.Context, name string) (proto int, err error) { return 0, UnknownNetworkError(name) } s := f[1] - if n, _, ok := dtoi(s[byteIndex(s, '=')+1:]); ok { + if n, _, ok := dtoi(s[bytealg.IndexByteString(s, '=')+1:]); ok { return n, nil } return 0, UnknownNetworkError(name) @@ -158,7 +159,7 @@ loop: continue } addr := f[1] - if i := byteIndex(addr, '!'); i >= 0 { + if i := bytealg.IndexByteString(addr, '!'); i >= 0 { addr = addr[:i] // remove port } if ParseIP(addr) == nil { @@ -175,7 +176,7 @@ loop: return } -func (r *Resolver) lookupIP(ctx context.Context, host string) (addrs []IPAddr, err error) { +func (r *Resolver) lookupIP(ctx context.Context, _, host string) (addrs []IPAddr, err error) { lits, err := r.lookupHost(ctx, host) if err != nil { return @@ -210,7 +211,7 @@ func (*Resolver) lookupPort(ctx context.Context, network, service string) (port return 0, unknownPortError } s := f[1] - if i := byteIndex(s, '!'); i >= 0 { + if i := bytealg.IndexByteString(s, '!'); i >= 0 { s = s[i+1:] // remove address } if n, _, ok := dtoi(s); ok { @@ -304,7 +305,7 @@ func (*Resolver) lookupTXT(ctx context.Context, name string) (txt []string, err return } for _, line := range lines { - if i := byteIndex(line, '\t'); i >= 0 { + if i := bytealg.IndexByteString(line, '\t'); i >= 0 { txt = append(txt, absDomainName([]byte(line[i+1:]))) } } diff --git a/libgo/go/net/lookup_test.go b/libgo/go/net/lookup_test.go index 5c66dfa2603..1da0e49a28c 100644 --- a/libgo/go/net/lookup_test.go +++ b/libgo/go/net/lookup_test.go @@ -20,7 +20,7 @@ import ( "time" ) -func lookupLocalhost(ctx context.Context, fn func(context.Context, string) ([]IPAddr, error), host string) ([]IPAddr, error) { +func lookupLocalhost(ctx context.Context, fn func(context.Context, string, string) ([]IPAddr, error), network, host string) ([]IPAddr, error) { switch host { case "localhost": return []IPAddr{ @@ -28,7 +28,7 @@ func lookupLocalhost(ctx context.Context, fn func(context.Context, string) ([]IP {IP: IPv6loopback}, }, nil default: - return fn(ctx, host) + return fn(ctx, network, host) } } @@ -618,6 +618,9 @@ func TestLookupDotsWithLocalSource(t *testing.T) { } func TestLookupDotsWithRemoteSource(t *testing.T) { + if runtime.GOOS == "darwin" { + testenv.SkipFlaky(t, 27992) + } mustHaveExternalNetwork(t) if !supportsIPv4() || !*testIPv4 { @@ -925,8 +928,8 @@ func TestLookupHostCancel(t *testing.T) { const ( google = "www.google.com" - invalidDomain = "nonexistentdomain.golang.org" - n = 600 // this needs to be larger than threadLimit size + invalidDomain = "invalid.invalid" // RFC 2606 reserves .invalid + n = 600 // this needs to be larger than threadLimit size ) _, err := LookupHost(google) @@ -1008,3 +1011,104 @@ func TestConcurrentPreferGoResolversDial(t *testing.T) { } } } + +var ipVersionTests = []struct { + network string + version byte +}{ + {"tcp", 0}, + {"tcp4", '4'}, + {"tcp6", '6'}, + {"udp", 0}, + {"udp4", '4'}, + {"udp6", '6'}, + {"ip", 0}, + {"ip4", '4'}, + {"ip6", '6'}, + {"ip7", 0}, + {"", 0}, +} + +func TestIPVersion(t *testing.T) { + for _, tt := range ipVersionTests { + if version := ipVersion(tt.network); version != tt.version { + t.Errorf("Family for: %s. Expected: %s, Got: %s", tt.network, + string(tt.version), string(version)) + } + } +} + +// Issue 28600: The context that is used to lookup ips should always +// preserve the values from the context that was passed into LookupIPAddr. +func TestLookupIPAddrPreservesContextValues(t *testing.T) { + origTestHookLookupIP := testHookLookupIP + defer func() { testHookLookupIP = origTestHookLookupIP }() + + keyValues := []struct { + key, value interface{} + }{ + {"key-1", 12}, + {384, "value2"}, + {new(float64), 137}, + } + ctx := context.Background() + for _, kv := range keyValues { + ctx = context.WithValue(ctx, kv.key, kv.value) + } + + wantIPs := []IPAddr{ + {IP: IPv4(127, 0, 0, 1)}, + {IP: IPv6loopback}, + } + + checkCtxValues := func(ctx_ context.Context, fn func(context.Context, string, string) ([]IPAddr, error), network, host string) ([]IPAddr, error) { + for _, kv := range keyValues { + g, w := ctx_.Value(kv.key), kv.value + if !reflect.DeepEqual(g, w) { + t.Errorf("Value lookup:\n\tGot: %v\n\tWant: %v", g, w) + } + } + return wantIPs, nil + } + testHookLookupIP = checkCtxValues + + resolvers := []*Resolver{ + nil, + new(Resolver), + } + + for i, resolver := range resolvers { + gotIPs, err := resolver.LookupIPAddr(ctx, "golang.org") + if err != nil { + t.Errorf("Resolver #%d: unexpected error: %v", i, err) + } + if !reflect.DeepEqual(gotIPs, wantIPs) { + t.Errorf("#%d: mismatched IPAddr results\n\tGot: %v\n\tWant: %v", i, gotIPs, wantIPs) + } + } +} + +func TestWithUnexpiredValuesPreserved(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + + // Insert a value into it. + key, value := "key-1", 2 + ctx = context.WithValue(ctx, key, value) + + // Now use the "values preserving context" like + // we would for LookupIPAddr. See Issue 28600. + ctx = withUnexpiredValuesPreserved(ctx) + + // Lookup before expiry. + if g, w := ctx.Value(key), value; g != w { + t.Errorf("Lookup before expiry: Got %v Want %v", g, w) + } + + // Cancel the context. + cancel() + + // Lookup after expiry should return nil + if g := ctx.Value(key); g != nil { + t.Errorf("Lookup after expiry: Got %v want nil", g) + } +} diff --git a/libgo/go/net/lookup_unix.go b/libgo/go/net/lookup_unix.go index 39e8b720076..6543f121a73 100644 --- a/libgo/go/net/lookup_unix.go +++ b/libgo/go/net/lookup_unix.go @@ -8,10 +8,11 @@ package net import ( "context" + "internal/bytealg" "sync" "syscall" - "golang_org/x/net/dns/dnsmessage" + "internal/x/net/dns/dnsmessage" ) var onceReadProtocols sync.Once @@ -27,7 +28,7 @@ func readProtocols() { for line, ok := file.readLine(); ok; line, ok = file.readLine() { // tcp 6 TCP # transmission control protocol - if i := byteIndex(line, '#'); i >= 0 { + if i := bytealg.IndexByteString(line, '#'); i >= 0 { line = line[0:i] } f := getFields(line) @@ -86,13 +87,13 @@ func (r *Resolver) lookupHost(ctx context.Context, host string) (addrs []string, return r.goLookupHostOrder(ctx, host, order) } -func (r *Resolver) lookupIP(ctx context.Context, host string) (addrs []IPAddr, err error) { +func (r *Resolver) lookupIP(ctx context.Context, network, host string) (addrs []IPAddr, err error) { if r.preferGo() { return r.goLookupIP(ctx, host) } order := systemConf().hostLookupOrder(r, host) if order == hostLookupCgo { - if addrs, err, ok := cgoLookupIP(ctx, host); ok { + if addrs, err, ok := cgoLookupIP(ctx, network, host); ok { return addrs, err } // cgo not available (or netgo); fall back to Go's DNS resolver diff --git a/libgo/go/net/lookup_windows.go b/libgo/go/net/lookup_windows.go index f76e0af400d..8a68d18a674 100644 --- a/libgo/go/net/lookup_windows.go +++ b/libgo/go/net/lookup_windows.go @@ -65,7 +65,7 @@ func lookupProtocol(ctx context.Context, name string) (int, error) { } func (r *Resolver) lookupHost(ctx context.Context, name string) ([]string, error) { - ips, err := r.lookupIP(ctx, name) + ips, err := r.lookupIP(ctx, "ip", name) if err != nil { return nil, err } @@ -76,14 +76,22 @@ func (r *Resolver) lookupHost(ctx context.Context, name string) ([]string, error return addrs, nil } -func (r *Resolver) lookupIP(ctx context.Context, name string) ([]IPAddr, error) { +func (r *Resolver) lookupIP(ctx context.Context, network, name string) ([]IPAddr, error) { // TODO(bradfitz,brainman): use ctx more. See TODO below. + var family int32 = syscall.AF_UNSPEC + switch ipVersion(network) { + case '4': + family = syscall.AF_INET + case '6': + family = syscall.AF_INET6 + } + getaddr := func() ([]IPAddr, error) { acquireThread() defer releaseThread() hints := syscall.AddrinfoW{ - Family: syscall.AF_UNSPEC, + Family: family, Socktype: syscall.SOCK_STREAM, Protocol: syscall.IPPROTO_IP, } diff --git a/libgo/go/net/mail/message.go b/libgo/go/net/mail/message.go index 5912b903347..554377aa1da 100644 --- a/libgo/go/net/mail/message.go +++ b/libgo/go/net/mail/message.go @@ -26,6 +26,7 @@ import ( "mime" "net/textproto" "strings" + "sync" "time" "unicode/utf8" ) @@ -65,9 +66,12 @@ func ReadMessage(r io.Reader) (msg *Message, err error) { // Layouts suitable for passing to time.Parse. // These are tried in order. -var dateLayouts []string +var ( + dateLayoutsBuildOnce sync.Once + dateLayouts []string +) -func init() { +func buildDateLayouts() { // Generate layouts based on RFC 5322, section 3.3. dows := [...]string{"", "Mon, "} // day-of-week @@ -93,6 +97,7 @@ func init() { // ParseDate parses an RFC 5322 date string. func ParseDate(date string) (time.Time, error) { + dateLayoutsBuildOnce.Do(buildDateLayouts) for _, layout := range dateLayouts { t, err := time.Parse(layout, date) if err == nil { diff --git a/libgo/go/net/mail/message_test.go b/libgo/go/net/mail/message_test.go index b19da52c423..14ac9192a4a 100644 --- a/libgo/go/net/mail/message_test.go +++ b/libgo/go/net/mail/message_test.go @@ -668,9 +668,9 @@ func TestAddressParser(t *testing.T) { switch charset { case "iso-8859-15": - in = bytes.Replace(in, []byte("\xf6"), []byte("ö"), -1) + in = bytes.ReplaceAll(in, []byte("\xf6"), []byte("ö")) case "windows-1252": - in = bytes.Replace(in, []byte("\xe9"), []byte("é"), -1) + in = bytes.ReplaceAll(in, []byte("\xe9"), []byte("é")) } return bytes.NewReader(in), nil diff --git a/libgo/go/net/net.go b/libgo/go/net/net.go index c9099862699..77b8f69074e 100644 --- a/libgo/go/net/net.go +++ b/libgo/go/net/net.go @@ -357,7 +357,16 @@ type PacketConn interface { SetWriteDeadline(t time.Time) error } -var listenerBacklog = maxListenerBacklog() +var listenerBacklogCache struct { + sync.Once + val int +} + +// listenerBacklog is a caching wrapper around maxListenerBacklog. +func listenerBacklog() int { + listenerBacklogCache.Do(func() { listenerBacklogCache.val = maxListenerBacklog() }) + return listenerBacklogCache.val +} // A Listener is a generic network listener for stream-oriented protocols. // diff --git a/libgo/go/net/nss.go b/libgo/go/net/nss.go index 1650f5e301d..96b9cdd1210 100644 --- a/libgo/go/net/nss.go +++ b/libgo/go/net/nss.go @@ -8,6 +8,7 @@ package net import ( "errors" + "internal/bytealg" "io" "os" ) @@ -85,7 +86,7 @@ func parseNSSConf(r io.Reader) *nssConf { if len(line) == 0 { return nil } - colon := bytesIndexByte(line, ':') + colon := bytealg.IndexByte(line, ':') if colon == -1 { return errors.New("no colon on line") } @@ -96,7 +97,7 @@ func parseNSSConf(r io.Reader) *nssConf { if len(srcs) == 0 { break } - sp := bytesIndexByte(srcs, ' ') + sp := bytealg.IndexByte(srcs, ' ') var src string if sp == -1 { src = string(srcs) @@ -108,7 +109,7 @@ func parseNSSConf(r io.Reader) *nssConf { var criteria []nssCriterion // See if there's a criteria block in brackets. if len(srcs) > 0 && srcs[0] == '[' { - bclose := bytesIndexByte(srcs, ']') + bclose := bytealg.IndexByte(srcs, ']') if bclose == -1 { return errors.New("unclosed criterion bracket") } @@ -143,7 +144,7 @@ func parseCriteria(x []byte) (c []nssCriterion, err error) { if len(f) < 3 { return errors.New("criterion too short") } - eq := bytesIndexByte(f, '=') + eq := bytealg.IndexByte(f, '=') if eq == -1 { return errors.New("criterion lacks equal sign") } diff --git a/libgo/go/net/parse.go b/libgo/go/net/parse.go index a2d9245348c..cdb35bb826e 100644 --- a/libgo/go/net/parse.go +++ b/libgo/go/net/parse.go @@ -8,10 +8,10 @@ package net import ( + "internal/bytealg" "io" "os" "time" - _ "unsafe" // For go:linkname ) type file struct { @@ -80,18 +80,11 @@ func stat(name string) (mtime time.Time, size int64, err error) { return st.ModTime(), st.Size(), nil } -// byteIndex is strings.IndexByte. It returns the index of the -// first instance of c in s, or -1 if c is not present in s. -// strings.IndexByte is implemented in runtime/asm_$GOARCH.s -//go:linkname byteIndex strings.IndexByte -//extern strings.IndexByte -func byteIndex(s string, c byte) int - // Count occurrences in s of any bytes in t. func countAnyByte(s string, t string) int { n := 0 for i := 0; i < len(s); i++ { - if byteIndex(t, s[i]) >= 0 { + if bytealg.IndexByteString(t, s[i]) >= 0 { n++ } } @@ -104,7 +97,7 @@ func splitAtBytes(s string, t string) []string { n := 0 last := 0 for i := 0; i < len(s); i++ { - if byteIndex(t, s[i]) >= 0 { + if bytealg.IndexByteString(t, s[i]) >= 0 { if last < i { a[n] = s[last:i] n++ @@ -277,7 +270,7 @@ func isSpace(b byte) bool { // removeComment returns line, removing any '#' byte and any following // bytes. func removeComment(line []byte) []byte { - if i := bytesIndexByte(line, '#'); i != -1 { + if i := bytealg.IndexByte(line, '#'); i != -1 { return line[:i] } return line @@ -288,7 +281,7 @@ func removeComment(line []byte) []byte { // It returns the first non-nil error returned by fn. func foreachLine(x []byte, fn func(line []byte) error) error { for len(x) > 0 { - nl := bytesIndexByte(x, '\n') + nl := bytealg.IndexByte(x, '\n') if nl == -1 { return fn(x) } @@ -306,7 +299,7 @@ func foreachLine(x []byte, fn func(line []byte) error) error { func foreachField(x []byte, fn func(field []byte) error) error { x = trimSpace(x) for len(x) > 0 { - sp := bytesIndexByte(x, ' ') + sp := bytealg.IndexByte(x, ' ') if sp == -1 { return fn(x) } @@ -320,13 +313,6 @@ func foreachField(x []byte, fn func(field []byte) error) error { return nil } -// bytesIndexByte is bytes.IndexByte. It returns the index of the -// first instance of c in s, or -1 if c is not present in s. -// bytes.IndexByte is implemented in runtime/asm_$GOARCH.s -//go:linkname bytesIndexByte bytes.IndexByte -//extern bytes.IndexByte -func bytesIndexByte(s []byte, c byte) int - // stringsHasSuffix is strings.HasSuffix. It reports whether s ends in // suffix. func stringsHasSuffix(s, suffix string) bool { diff --git a/libgo/go/net/pipe_test.go b/libgo/go/net/pipe_test.go index 84a71b756bc..53ddc16313d 100644 --- a/libgo/go/net/pipe_test.go +++ b/libgo/go/net/pipe_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "golang_org/x/net/nettest" + "internal/x/net/nettest" ) func TestPipe(t *testing.T) { diff --git a/libgo/go/net/platform_test.go b/libgo/go/net/platform_test.go index 8e7d9151dee..7e9ad70d19b 100644 --- a/libgo/go/net/platform_test.go +++ b/libgo/go/net/platform_test.go @@ -7,7 +7,9 @@ package net import ( "internal/testenv" "os" + "os/exec" "runtime" + "strconv" "strings" "testing" ) @@ -35,6 +37,16 @@ func testableNetwork(network string) bool { switch runtime.GOOS { case "android", "nacl", "plan9", "windows": return false + case "aix": + // Unix network isn't properly working on AIX 7.2 with Technical Level < 2 + out, err := exec.Command("oslevel", "-s").Output() + if err != nil { + return false + } + if tl, err := strconv.Atoi(string(out[5:7])); err != nil || tl < 2 { + return false + } + return true } // iOS does not support unix, unixgram. if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") { @@ -42,7 +54,7 @@ func testableNetwork(network string) bool { } case "unixpacket": switch runtime.GOOS { - case "android", "darwin", "nacl", "plan9", "windows": + case "aix", "android", "darwin", "nacl", "plan9", "windows": return false case "netbsd": // It passes on amd64 at least. 386 fails (Issue 22927). arm is unknown. diff --git a/libgo/go/net/port_unix.go b/libgo/go/net/port_unix.go index ea3bb0229e3..a6153c0c206 100644 --- a/libgo/go/net/port_unix.go +++ b/libgo/go/net/port_unix.go @@ -8,7 +8,10 @@ package net -import "sync" +import ( + "internal/bytealg" + "sync" +) var onceReadServices sync.Once @@ -21,7 +24,7 @@ func readServices() { for line, ok := file.readLine(); ok; line, ok = file.readLine() { // "http 80/tcp www www-http # World Wide Web HTTP" - if i := byteIndex(line, '#'); i >= 0 { + if i := bytealg.IndexByteString(line, '#'); i >= 0 { line = line[:i] } f := getFields(line) diff --git a/libgo/go/net/rawconn_unix_test.go b/libgo/go/net/rawconn_unix_test.go index a720a8a4a3e..a71b6f3041d 100644 --- a/libgo/go/net/rawconn_unix_test.go +++ b/libgo/go/net/rawconn_unix_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd linux netbsd openbsd solaris +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package net diff --git a/libgo/go/net/sendfile_linux.go b/libgo/go/net/sendfile_linux.go index c537ea68b2b..297e625d24b 100644 --- a/libgo/go/net/sendfile_linux.go +++ b/libgo/go/net/sendfile_linux.go @@ -32,7 +32,19 @@ func sendFile(c *netFD, r io.Reader) (written int64, err error, handled bool) { return 0, nil, false } - written, err = poll.SendFile(&c.pfd, int(f.Fd()), remain) + sc, err := f.SyscallConn() + if err != nil { + return 0, nil, false + } + + var werr error + err = sc.Read(func(fd uintptr) bool { + written, werr = poll.SendFile(&c.pfd, int(fd), remain) + return true + }) + if werr == nil { + werr = err + } if lr != nil { lr.N = remain - written diff --git a/libgo/go/net/sendfile_test.go b/libgo/go/net/sendfile_test.go index 3b982774b02..911e6139c57 100644 --- a/libgo/go/net/sendfile_test.go +++ b/libgo/go/net/sendfile_test.go @@ -12,14 +12,18 @@ import ( "encoding/hex" "fmt" "io" + "io/ioutil" "os" + "runtime" + "sync" "testing" + "time" ) const ( - twain = "testdata/Mark.Twain-Tom.Sawyer.txt" - twainLen = 387851 - twainSHA256 = "461eb7cb2d57d293fc680c836464c9125e4382be3596f7d415093ae9db8fcb0e" + newton = "../testdata/Isaac.Newton-Opticks.txt" + newtonLen = 567198 + newtonSHA256 = "d4a9ac22462b35e7821a4f2706c211093da678620a8f9997989ee7cf8d507bbd" ) func TestSendfile(t *testing.T) { @@ -43,7 +47,7 @@ func TestSendfile(t *testing.T) { defer close(errc) defer conn.Close() - f, err := os.Open(twain) + f, err := os.Open(newton) if err != nil { errc <- err return @@ -58,8 +62,8 @@ func TestSendfile(t *testing.T) { return } - if sbytes != twainLen { - errc <- fmt.Errorf("sent %d bytes; expected %d", sbytes, twainLen) + if sbytes != newtonLen { + errc <- fmt.Errorf("sent %d bytes; expected %d", sbytes, newtonLen) return } }() @@ -79,11 +83,11 @@ func TestSendfile(t *testing.T) { t.Error(err) } - if rbytes != twainLen { - t.Errorf("received %d bytes; expected %d", rbytes, twainLen) + if rbytes != newtonLen { + t.Errorf("received %d bytes; expected %d", rbytes, newtonLen) } - if res := hex.EncodeToString(h.Sum(nil)); res != twainSHA256 { + if res := hex.EncodeToString(h.Sum(nil)); res != newtonSHA256 { t.Error("retrieved data hash did not match") } @@ -113,7 +117,7 @@ func TestSendfileParts(t *testing.T) { defer close(errc) defer conn.Close() - f, err := os.Open(twain) + f, err := os.Open(newton) if err != nil { errc <- err return @@ -174,7 +178,7 @@ func TestSendfileSeeked(t *testing.T) { defer close(errc) defer conn.Close() - f, err := os.Open(twain) + f, err := os.Open(newton) if err != nil { errc <- err return @@ -210,3 +214,103 @@ func TestSendfileSeeked(t *testing.T) { t.Error(err) } } + +// Test that sendfile doesn't put a pipe into blocking mode. +func TestSendfilePipe(t *testing.T) { + switch runtime.GOOS { + case "nacl", "plan9", "windows": + // These systems don't support deadlines on pipes. + t.Skipf("skipping on %s", runtime.GOOS) + } + + t.Parallel() + + ln, err := newLocalListener("tcp") + if err != nil { + t.Fatal(err) + } + defer ln.Close() + + r, w, err := os.Pipe() + if err != nil { + t.Fatal(err) + } + defer w.Close() + defer r.Close() + + copied := make(chan bool) + + var wg sync.WaitGroup + wg.Add(1) + go func() { + // Accept a connection and copy 1 byte from the read end of + // the pipe to the connection. This will call into sendfile. + defer wg.Done() + conn, err := ln.Accept() + if err != nil { + t.Error(err) + return + } + defer conn.Close() + _, err = io.CopyN(conn, r, 1) + if err != nil { + t.Error(err) + return + } + // Signal the main goroutine that we've copied the byte. + close(copied) + }() + + wg.Add(1) + go func() { + // Write 1 byte to the write end of the pipe. + defer wg.Done() + _, err := w.Write([]byte{'a'}) + if err != nil { + t.Error(err) + } + }() + + wg.Add(1) + go func() { + // Connect to the server started two goroutines up and + // discard any data that it writes. + defer wg.Done() + conn, err := Dial("tcp", ln.Addr().String()) + if err != nil { + t.Error(err) + return + } + defer conn.Close() + io.Copy(ioutil.Discard, conn) + }() + + // Wait for the byte to be copied, meaning that sendfile has + // been called on the pipe. + <-copied + + // Set a very short deadline on the read end of the pipe. + if err := r.SetDeadline(time.Now().Add(time.Microsecond)); err != nil { + t.Fatal(err) + } + + wg.Add(1) + go func() { + // Wait for much longer than the deadline and write a byte + // to the pipe. + defer wg.Done() + time.Sleep(50 * time.Millisecond) + w.Write([]byte{'b'}) + }() + + // If this read does not time out, the pipe was incorrectly + // put into blocking mode. + _, err = r.Read(make([]byte, 1)) + if err == nil { + t.Error("Read did not time out") + } else if !os.IsTimeout(err) { + t.Errorf("got error %v, expected a time out", err) + } + + wg.Wait() +} diff --git a/libgo/go/net/sendfile_unix_alt.go b/libgo/go/net/sendfile_unix_alt.go index 9b3ba4ee624..43df3bfd15e 100644 --- a/libgo/go/net/sendfile_unix_alt.go +++ b/libgo/go/net/sendfile_unix_alt.go @@ -58,7 +58,19 @@ func sendFile(c *netFD, r io.Reader) (written int64, err error, handled bool) { return 0, err, false } - written, err = poll.SendFile(&c.pfd, int(f.Fd()), pos, remain) + sc, err := f.SyscallConn() + if err != nil { + return 0, nil, false + } + + var werr error + err = sc.Read(func(fd uintptr) bool { + written, werr = poll.SendFile(&c.pfd, int(fd), pos, remain) + return true + }) + if werr == nil { + werr = err + } if lr != nil { lr.N = remain - written diff --git a/libgo/go/net/smtp/smtp_test.go b/libgo/go/net/smtp/smtp_test.go index 000cac4fcbb..e366ef80158 100644 --- a/libgo/go/net/smtp/smtp_test.go +++ b/libgo/go/net/smtp/smtp_test.go @@ -540,7 +540,7 @@ func TestSendMail(t *testing.T) { bcmdbuf := bufio.NewWriter(&cmdbuf) l, err := net.Listen("tcp", "127.0.0.1:0") if err != nil { - t.Fatalf("Unable to to create listener: %v", err) + t.Fatalf("Unable to create listener: %v", err) } defer l.Close() @@ -639,7 +639,7 @@ QUIT func TestSendMailWithAuth(t *testing.T) { l, err := net.Listen("tcp", "127.0.0.1:0") if err != nil { - t.Fatalf("Unable to to create listener: %v", err) + t.Fatalf("Unable to create listener: %v", err) } defer l.Close() wg := sync.WaitGroup{} @@ -880,31 +880,39 @@ func sendMail(hostPort string) error { return SendMail(hostPort, nil, from, to, []byte("Subject: test\n\nhowdy!")) } -// (copied from net/http/httptest) -// localhostCert is a PEM-encoded TLS cert with SAN IPs -// "127.0.0.1" and "[::1]", expiring at the last second of 2049 (the end -// of ASN.1 time). -// generated from src/crypto/tls: -// go run generate_cert.go --rsa-bits 512 --host 127.0.0.1,::1,example.com --ca --start-date "Jan 1 00:00:00 1970" --duration=1000000h -var localhostCert = []byte(`-----BEGIN CERTIFICATE----- -MIIBjjCCATigAwIBAgIQMon9v0s3pDFXvAMnPgelpzANBgkqhkiG9w0BAQsFADAS -MRAwDgYDVQQKEwdBY21lIENvMCAXDTcwMDEwMTAwMDAwMFoYDzIwODQwMTI5MTYw -MDAwWjASMRAwDgYDVQQKEwdBY21lIENvMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJB -AM0u/mNXKkhAzNsFkwKZPSpC4lZZaePQ55IyaJv3ovMM2smvthnlqaUfVKVmz7FF -wLP9csX6vGtvkZg1uWAtvfkCAwEAAaNoMGYwDgYDVR0PAQH/BAQDAgKkMBMGA1Ud -JQQMMAoGCCsGAQUFBwMBMA8GA1UdEwEB/wQFMAMBAf8wLgYDVR0RBCcwJYILZXhh -bXBsZS5jb22HBH8AAAGHEAAAAAAAAAAAAAAAAAAAAAEwDQYJKoZIhvcNAQELBQAD -QQBOZsFVC7IwX+qibmSbt2IPHkUgXhfbq0a9MYhD6tHcj4gbDcTXh4kZCbgHCz22 -gfSj2/G2wxzopoISVDucuncj +// localhostCert is a PEM-encoded TLS cert generated from src/crypto/tls: +// go run generate_cert.go --rsa-bits 1024 --host 127.0.0.1,::1,example.com \ +// --ca --start-date "Jan 1 00:00:00 1970" --duration=1000000h +var localhostCert = []byte(` +-----BEGIN CERTIFICATE----- +MIICFDCCAX2gAwIBAgIRAK0xjnaPuNDSreeXb+z+0u4wDQYJKoZIhvcNAQELBQAw +EjEQMA4GA1UEChMHQWNtZSBDbzAgFw03MDAxMDEwMDAwMDBaGA8yMDg0MDEyOTE2 +MDAwMFowEjEQMA4GA1UEChMHQWNtZSBDbzCBnzANBgkqhkiG9w0BAQEFAAOBjQAw +gYkCgYEA0nFbQQuOWsjbGtejcpWz153OlziZM4bVjJ9jYruNw5n2Ry6uYQAffhqa +JOInCmmcVe2siJglsyH9aRh6vKiobBbIUXXUU1ABd56ebAzlt0LobLlx7pZEMy30 +LqIi9E6zmL3YvdGzpYlkFRnRrqwEtWYbGBf3znO250S56CCWH2UCAwEAAaNoMGYw +DgYDVR0PAQH/BAQDAgKkMBMGA1UdJQQMMAoGCCsGAQUFBwMBMA8GA1UdEwEB/wQF +MAMBAf8wLgYDVR0RBCcwJYILZXhhbXBsZS5jb22HBH8AAAGHEAAAAAAAAAAAAAAA +AAAAAAEwDQYJKoZIhvcNAQELBQADgYEAbZtDS2dVuBYvb+MnolWnCNqvw1w5Gtgi +NmvQQPOMgM3m+oQSCPRTNGSg25e1Qbo7bgQDv8ZTnq8FgOJ/rbkyERw2JckkHpD4 +n4qcK27WkEDBtQFlPihIM8hLIuzWoi/9wygiElTy/tVL3y7fGCvY2/k1KBthtZGF +tN8URjVmyEo= -----END CERTIFICATE-----`) // localhostKey is the private key for localhostCert. -var localhostKey = []byte(`-----BEGIN RSA PRIVATE KEY----- -MIIBOwIBAAJBAM0u/mNXKkhAzNsFkwKZPSpC4lZZaePQ55IyaJv3ovMM2smvthnl -qaUfVKVmz7FFwLP9csX6vGtvkZg1uWAtvfkCAwEAAQJART2qkxODLUbQ2siSx7m2 -rmBLyR/7X+nLe8aPDrMOxj3heDNl4YlaAYLexbcY8d7VDfCRBKYoAOP0UCP1Vhuf -UQIhAO6PEI55K3SpNIdc2k5f0xz+9rodJCYzu51EwWX7r8ufAiEA3C9EkLiU2NuK -3L3DHCN5IlUSN1Nr/lw8NIt50Yorj2cCIQCDw1VbvCV6bDLtSSXzAA51B4ZzScE7 -sHtB5EYF9Dwm9QIhAJuCquuH4mDzVjUntXjXOQPdj7sRqVGCNWdrJwOukat7AiAy -LXLEwb77DIPoI5ZuaXQC+MnyyJj1ExC9RFcGz+bexA== +var localhostKey = []byte(` +-----BEGIN RSA PRIVATE KEY----- +MIICXgIBAAKBgQDScVtBC45ayNsa16NylbPXnc6XOJkzhtWMn2Niu43DmfZHLq5h +AB9+Gpok4icKaZxV7ayImCWzIf1pGHq8qKhsFshRddRTUAF3np5sDOW3QuhsuXHu +lkQzLfQuoiL0TrOYvdi90bOliWQVGdGurAS1ZhsYF/fOc7bnRLnoIJYfZQIDAQAB +AoGBAMst7OgpKyFV6c3JwyI/jWqxDySL3caU+RuTTBaodKAUx2ZEmNJIlx9eudLA +kucHvoxsM/eRxlxkhdFxdBcwU6J+zqooTnhu/FE3jhrT1lPrbhfGhyKnUrB0KKMM +VY3IQZyiehpxaeXAwoAou6TbWoTpl9t8ImAqAMY8hlULCUqlAkEA+9+Ry5FSYK/m +542LujIcCaIGoG1/Te6Sxr3hsPagKC2rH20rDLqXwEedSFOpSS0vpzlPAzy/6Rbb +PHTJUhNdwwJBANXkA+TkMdbJI5do9/mn//U0LfrCR9NkcoYohxfKz8JuhgRQxzF2 +6jpo3q7CdTuuRixLWVfeJzcrAyNrVcBq87cCQFkTCtOMNC7fZnCTPUv+9q1tcJyB +vNjJu3yvoEZeIeuzouX9TJE21/33FaeDdsXbRhQEj23cqR38qFHsF1qAYNMCQQDP +QXLEiJoClkR2orAmqjPLVhR3t2oB3INcnEjLNSq8LHyQEfXyaFfu4U9l5+fRPL2i +jiC0k/9L5dHUsF0XZothAkEA23ddgRs+Id/HxtojqqUT27B8MT/IGNrYsp4DvS/c +qgkeluku4GjxRlDMBuXk94xOBEinUs+p/hwP1Alll80Tpg== -----END RSA PRIVATE KEY-----`) diff --git a/libgo/go/net/sock_posix.go b/libgo/go/net/sock_posix.go index fac3ac11ae2..7b1c380e297 100644 --- a/libgo/go/net/sock_posix.go +++ b/libgo/go/net/sock_posix.go @@ -54,7 +54,7 @@ func socket(ctx context.Context, net string, family, sotype, proto int, ipv6only if laddr != nil && raddr == nil { switch sotype { case syscall.SOCK_STREAM, syscall.SOCK_SEQPACKET: - if err := fd.listenStream(laddr, listenerBacklog, ctrlFn); err != nil { + if err := fd.listenStream(laddr, listenerBacklog(), ctrlFn); err != nil { fd.Close() return nil, err } diff --git a/libgo/go/net/sockaddr_posix.go b/libgo/go/net/sockaddr_posix.go index 4b8699d1f56..ae83b5ab196 100644 --- a/libgo/go/net/sockaddr_posix.go +++ b/libgo/go/net/sockaddr_posix.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris windows +// +build aix darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris windows package net diff --git a/libgo/go/net/sockopt_aix.go b/libgo/go/net/sockopt_aix.go index 7aef64b48e4..b49c4d5c7c7 100644 --- a/libgo/go/net/sockopt_aix.go +++ b/libgo/go/net/sockopt_aix.go @@ -1,4 +1,4 @@ -// Copyright 2017 The Go Authors. All rights reserved. +// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. @@ -9,8 +9,6 @@ import ( "syscall" ) -// This was copied from sockopt_linux.go - func setDefaultSockopts(s, family, sotype int, ipv6only bool) error { if family == syscall.AF_INET6 && sotype != syscall.SOCK_RAW { // Allow both IP versions even if the OS default @@ -30,5 +28,9 @@ func setDefaultListenerSockopts(s int) error { func setDefaultMulticastSockopts(s int) error { // Allow multicast UDP and raw IP datagram sockets to listen // concurrently across multiple listeners. - return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)) + if err := syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1); err != nil { + return os.NewSyscallError("setsockopt", err) + } + // Allow reuse of recently-used ports. + return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEPORT, 1)) } diff --git a/libgo/go/net/sockopt_posix.go b/libgo/go/net/sockopt_posix.go index 29edddbf374..de7255667f7 100644 --- a/libgo/go/net/sockopt_posix.go +++ b/libgo/go/net/sockopt_posix.go @@ -7,6 +7,7 @@ package net import ( + "internal/bytealg" "runtime" "syscall" ) @@ -94,7 +95,7 @@ func setIPv4MreqToInterface(mreq *syscall.IPMreq, ifi *Interface) error { } } done: - if bytesEqual(mreq.Multiaddr[:], IPv4zero.To4()) { + if bytealg.Equal(mreq.Multiaddr[:], IPv4zero.To4()) { return errNoSuchMulticastInterface } return nil diff --git a/libgo/go/net/sockoptip_bsdvar.go b/libgo/go/net/sockoptip_bsdvar.go index 95601013987..20a6dc95497 100644 --- a/libgo/go/net/sockoptip_bsdvar.go +++ b/libgo/go/net/sockoptip_bsdvar.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd netbsd openbsd solaris +// +build aix darwin dragonfly freebsd netbsd openbsd solaris package net diff --git a/libgo/go/net/splice_linux.go b/libgo/go/net/splice_linux.go index b055f933518..69c3f65770f 100644 --- a/libgo/go/net/splice_linux.go +++ b/libgo/go/net/splice_linux.go @@ -11,7 +11,7 @@ import ( // splice transfers data from r to c using the splice system call to minimize // copies from and to userspace. c must be a TCP connection. Currently, splice -// is only enabled if r is also a TCP connection. +// is only enabled if r is a TCP or a stream-oriented Unix connection. // // If splice returns handled == false, it has performed no work. func splice(c *netFD, r io.Reader) (written int64, err error, handled bool) { @@ -23,11 +23,20 @@ func splice(c *netFD, r io.Reader) (written int64, err error, handled bool) { return 0, nil, true } } - s, ok := r.(*TCPConn) - if !ok { + + var s *netFD + if tc, ok := r.(*TCPConn); ok { + s = tc.fd + } else if uc, ok := r.(*UnixConn); ok { + if uc.fd.net != "unix" { + return 0, nil, false + } + s = uc.fd + } else { return 0, nil, false } - written, handled, sc, err := poll.Splice(&c.pfd, &s.fd.pfd, remain) + + written, handled, sc, err := poll.Splice(&c.pfd, &s.pfd, remain) if lr != nil { lr.N -= written } diff --git a/libgo/go/net/splice_test.go b/libgo/go/net/splice_test.go index 3be1c7e5de1..26e3ac4bb14 100644 --- a/libgo/go/net/splice_test.go +++ b/libgo/go/net/splice_test.go @@ -7,245 +7,109 @@ package net import ( - "bytes" - "fmt" "io" "io/ioutil" + "log" "os" + "os/exec" + "strconv" "sync" - "syscall" "testing" + "time" ) func TestSplice(t *testing.T) { - t.Run("simple", testSpliceSimple) - t.Run("multipleWrite", testSpliceMultipleWrite) - t.Run("big", testSpliceBig) - t.Run("honorsLimitedReader", testSpliceHonorsLimitedReader) - t.Run("readerAtEOF", testSpliceReaderAtEOF) - t.Run("issue25985", testSpliceIssue25985) -} - -func testSpliceSimple(t *testing.T) { - srv, err := newSpliceTestServer() - if err != nil { - t.Fatal(err) - } - defer srv.Close() - copyDone := srv.Copy() - msg := []byte("splice test") - if _, err := srv.Write(msg); err != nil { - t.Fatal(err) - } - got := make([]byte, len(msg)) - if _, err := io.ReadFull(srv, got); err != nil { - t.Fatal(err) - } - if !bytes.Equal(got, msg) { - t.Errorf("got %q, wrote %q", got, msg) - } - srv.CloseWrite() - srv.CloseRead() - if err := <-copyDone; err != nil { - t.Errorf("splice: %v", err) + t.Run("tcp-to-tcp", func(t *testing.T) { testSplice(t, "tcp", "tcp") }) + if !testableNetwork("unixgram") { + t.Skip("skipping unix-to-tcp tests") } + t.Run("unix-to-tcp", func(t *testing.T) { testSplice(t, "unix", "tcp") }) + t.Run("no-unixpacket", testSpliceNoUnixpacket) + t.Run("no-unixgram", testSpliceNoUnixgram) } -func testSpliceMultipleWrite(t *testing.T) { - srv, err := newSpliceTestServer() - if err != nil { - t.Fatal(err) - } - defer srv.Close() - copyDone := srv.Copy() - msg1 := []byte("splice test part 1 ") - msg2 := []byte(" splice test part 2") - if _, err := srv.Write(msg1); err != nil { - t.Fatalf("Write: %v", err) - } - if _, err := srv.Write(msg2); err != nil { - t.Fatal(err) - } - got := make([]byte, len(msg1)+len(msg2)) - if _, err := io.ReadFull(srv, got); err != nil { - t.Fatal(err) - } - want := append(msg1, msg2...) - if !bytes.Equal(got, want) { - t.Errorf("got %q, wrote %q", got, want) - } - srv.CloseWrite() - srv.CloseRead() - if err := <-copyDone; err != nil { - t.Errorf("splice: %v", err) - } +func testSplice(t *testing.T, upNet, downNet string) { + t.Run("simple", spliceTestCase{upNet, downNet, 128, 128, 0}.test) + t.Run("multipleWrite", spliceTestCase{upNet, downNet, 4096, 1 << 20, 0}.test) + t.Run("big", spliceTestCase{upNet, downNet, 5 << 20, 1 << 30, 0}.test) + t.Run("honorsLimitedReader", spliceTestCase{upNet, downNet, 4096, 1 << 20, 1 << 10}.test) + t.Run("updatesLimitedReaderN", spliceTestCase{upNet, downNet, 1024, 4096, 4096 + 100}.test) + t.Run("limitedReaderAtLimit", spliceTestCase{upNet, downNet, 32, 128, 128}.test) + t.Run("readerAtEOF", func(t *testing.T) { testSpliceReaderAtEOF(t, upNet, downNet) }) + t.Run("issue25985", func(t *testing.T) { testSpliceIssue25985(t, upNet, downNet) }) } -func testSpliceBig(t *testing.T) { - // The maximum amount of data that internal/poll.Splice will use in a - // splice(2) call is 4 << 20. Use a bigger size here so that we test an - // amount that doesn't fit in a single call. - size := 5 << 20 - srv, err := newSpliceTestServer() - if err != nil { - t.Fatal(err) - } - defer srv.Close() - big := make([]byte, size) - copyDone := srv.Copy() - type readResult struct { - b []byte - err error - } - readDone := make(chan readResult) - go func() { - got := make([]byte, len(big)) - _, err := io.ReadFull(srv, got) - readDone <- readResult{got, err} - }() - if _, err := srv.Write(big); err != nil { - t.Fatal(err) - } - res := <-readDone - if res.err != nil { - t.Fatal(res.err) - } - got := res.b - if !bytes.Equal(got, big) { - t.Errorf("input and output differ") - } - srv.CloseWrite() - srv.CloseRead() - if err := <-copyDone; err != nil { - t.Errorf("splice: %v", err) - } -} +type spliceTestCase struct { + upNet, downNet string -func testSpliceHonorsLimitedReader(t *testing.T) { - t.Run("stopsAfterN", testSpliceStopsAfterN) - t.Run("updatesN", testSpliceUpdatesN) - t.Run("readerAtLimit", testSpliceReaderAtLimit) + chunkSize, totalSize int + limitReadSize int } -func testSpliceStopsAfterN(t *testing.T) { - clientUp, serverUp, err := spliceTestSocketPair("tcp") +func (tc spliceTestCase) test(t *testing.T) { + clientUp, serverUp, err := spliceTestSocketPair(tc.upNet) if err != nil { t.Fatal(err) } - defer clientUp.Close() defer serverUp.Close() - clientDown, serverDown, err := spliceTestSocketPair("tcp") + cleanup, err := startSpliceClient(clientUp, "w", tc.chunkSize, tc.totalSize) if err != nil { t.Fatal(err) } - defer clientDown.Close() - defer serverDown.Close() - count := 128 - copyDone := make(chan error) - lr := &io.LimitedReader{ - N: int64(count), - R: serverUp, - } - go func() { - _, err := io.Copy(serverDown, lr) - serverDown.Close() - copyDone <- err - }() - msg := make([]byte, 2*count) - if _, err := clientUp.Write(msg); err != nil { - t.Fatal(err) - } - clientUp.Close() - var buf bytes.Buffer - if _, err := io.Copy(&buf, clientDown); err != nil { - t.Fatal(err) - } - if buf.Len() != count { - t.Errorf("splice transferred %d bytes, want to stop after %d", buf.Len(), count) - } - clientDown.Close() - if err := <-copyDone; err != nil { - t.Errorf("splice: %v", err) - } -} - -func testSpliceUpdatesN(t *testing.T) { - clientUp, serverUp, err := spliceTestSocketPair("tcp") + defer cleanup() + clientDown, serverDown, err := spliceTestSocketPair(tc.downNet) if err != nil { t.Fatal(err) } - defer clientUp.Close() - defer serverUp.Close() - clientDown, serverDown, err := spliceTestSocketPair("tcp") - if err != nil { - t.Fatal(err) - } - defer clientDown.Close() defer serverDown.Close() - count := 128 - copyDone := make(chan error) - lr := &io.LimitedReader{ - N: int64(100 + count), - R: serverUp, - } - go func() { - _, err := io.Copy(serverDown, lr) - copyDone <- err - }() - msg := make([]byte, count) - if _, err := clientUp.Write(msg); err != nil { - t.Fatal(err) - } - clientUp.Close() - got := make([]byte, count) - if _, err := io.ReadFull(clientDown, got); err != nil { + cleanup, err = startSpliceClient(clientDown, "r", tc.chunkSize, tc.totalSize) + if err != nil { t.Fatal(err) } - clientDown.Close() - if err := <-copyDone; err != nil { - t.Errorf("splice: %v", err) - } - wantN := int64(100) - if lr.N != wantN { - t.Errorf("lr.N = %d, want %d", lr.N, wantN) - } -} + defer cleanup() + var ( + r io.Reader = serverUp + size = tc.totalSize + ) + if tc.limitReadSize > 0 { + if tc.limitReadSize < size { + size = tc.limitReadSize + } -func testSpliceReaderAtLimit(t *testing.T) { - clientUp, serverUp, err := spliceTestSocketPair("tcp") - if err != nil { - t.Fatal(err) + r = &io.LimitedReader{ + N: int64(tc.limitReadSize), + R: serverUp, + } + defer serverUp.Close() } - defer clientUp.Close() - defer serverUp.Close() - clientDown, serverDown, err := spliceTestSocketPair("tcp") + n, err := io.Copy(serverDown, r) + serverDown.Close() if err != nil { t.Fatal(err) } - defer clientDown.Close() - defer serverDown.Close() - - lr := &io.LimitedReader{ - N: 0, - R: serverUp, + if want := int64(size); want != n { + t.Errorf("want %d bytes spliced, got %d", want, n) } - _, err, handled := splice(serverDown.(*TCPConn).fd, lr) - if !handled { - if serr, ok := err.(*os.SyscallError); ok && serr.Syscall == "pipe2" && serr.Err == syscall.ENOSYS { - t.Skip("pipe2 not supported") + + if tc.limitReadSize > 0 { + wantN := 0 + if tc.limitReadSize > size { + wantN = tc.limitReadSize - size } - t.Errorf("exhausted LimitedReader: got err = %v, handled = %t, want handled = true", err, handled) + if n := r.(*io.LimitedReader).N; n != int64(wantN) { + t.Errorf("r.N = %d, want %d", n, wantN) + } } } -func testSpliceReaderAtEOF(t *testing.T) { - clientUp, serverUp, err := spliceTestSocketPair("tcp") +func testSpliceReaderAtEOF(t *testing.T, upNet, downNet string) { + clientUp, serverUp, err := spliceTestSocketPair(upNet) if err != nil { t.Fatal(err) } defer clientUp.Close() - clientDown, serverDown, err := spliceTestSocketPair("tcp") + clientDown, serverDown, err := spliceTestSocketPair(downNet) if err != nil { t.Fatal(err) } @@ -271,7 +135,7 @@ func testSpliceReaderAtEOF(t *testing.T) { // get a goodbye signal. Test for the goodbye signal. msg := "bye" go func() { - serverDown.(*TCPConn).ReadFrom(serverUp) + serverDown.(io.ReaderFrom).ReadFrom(serverUp) io.WriteString(serverDown, msg) serverDown.Close() }() @@ -286,13 +150,13 @@ func testSpliceReaderAtEOF(t *testing.T) { } } -func testSpliceIssue25985(t *testing.T) { - front, err := newLocalListener("tcp") +func testSpliceIssue25985(t *testing.T, upNet, downNet string) { + front, err := newLocalListener(upNet) if err != nil { t.Fatal(err) } defer front.Close() - back, err := newLocalListener("tcp") + back, err := newLocalListener(downNet) if err != nil { t.Fatal(err) } @@ -306,7 +170,7 @@ func testSpliceIssue25985(t *testing.T) { if err != nil { return } - dst, err := Dial("tcp", back.Addr().String()) + dst, err := Dial(downNet, back.Addr().String()) if err != nil { return } @@ -324,7 +188,7 @@ func testSpliceIssue25985(t *testing.T) { go proxy() - toFront, err := Dial("tcp", front.Addr().String()) + toFront, err := Dial(upNet, front.Addr().String()) if err != nil { t.Fatal(err) } @@ -346,166 +210,121 @@ func testSpliceIssue25985(t *testing.T) { wg.Wait() } -func BenchmarkTCPReadFrom(b *testing.B) { - testHookUninstaller.Do(uninstallTestHooks) - - var chunkSizes []int - for i := uint(10); i <= 20; i++ { - chunkSizes = append(chunkSizes, 1< totalSize { + buf = buf[:totalSize-count] + } + + var err error + if n, err = fn(buf); err != nil { + return + } + } +} diff --git a/libgo/go/net/tcpsock_test.go b/libgo/go/net/tcpsock_test.go index f8a775fdded..65a6ee579ea 100644 --- a/libgo/go/net/tcpsock_test.go +++ b/libgo/go/net/tcpsock_test.go @@ -801,3 +801,34 @@ func TestCopyPipeIntoTCP(t *testing.T) { t.Fatal(err) } } + +func BenchmarkSetReadDeadline(b *testing.B) { + ln, err := newLocalListener("tcp") + if err != nil { + b.Fatal(err) + } + defer ln.Close() + var serv Conn + done := make(chan error) + go func() { + var err error + serv, err = ln.Accept() + done <- err + }() + c, err := Dial("tcp", ln.Addr().String()) + if err != nil { + b.Fatal(err) + } + defer c.Close() + if err := <-done; err != nil { + b.Fatal(err) + } + defer serv.Close() + c.SetWriteDeadline(time.Now().Add(2 * time.Hour)) + deadline := time.Now().Add(time.Hour) + b.ResetTimer() + for i := 0; i < b.N; i++ { + c.SetReadDeadline(deadline) + deadline = deadline.Add(1) + } +} diff --git a/libgo/go/net/testdata/Mark.Twain-Tom.Sawyer.txt b/libgo/go/net/testdata/Mark.Twain-Tom.Sawyer.txt deleted file mode 100644 index c9106fd522c..00000000000 --- a/libgo/go/net/testdata/Mark.Twain-Tom.Sawyer.txt +++ /dev/null @@ -1,8465 +0,0 @@ -Produced by David Widger. The previous edition was updated by Jose -Menendez. - - - - - - THE ADVENTURES OF TOM SAWYER - BY - MARK TWAIN - (Samuel Langhorne Clemens) - - - - - P R E F A C E - -MOST of the adventures recorded in this book really occurred; one or -two were experiences of my own, the rest those of boys who were -schoolmates of mine. Huck Finn is drawn from life; Tom Sawyer also, but -not from an individual--he is a combination of the characteristics of -three boys whom I knew, and therefore belongs to the composite order of -architecture. - -The odd superstitions touched upon were all prevalent among children -and slaves in the West at the period of this story--that is to say, -thirty or forty years ago. - -Although my book is intended mainly for the entertainment of boys and -girls, I hope it will not be shunned by men and women on that account, -for part of my plan has been to try to pleasantly remind adults of what -they once were themselves, and of how they felt and thought and talked, -and what queer enterprises they sometimes engaged in. - - THE AUTHOR. - -HARTFORD, 1876. - - - - T O M S A W Y E R - - - -CHAPTER I - -"TOM!" - -No answer. - -"TOM!" - -No answer. - -"What's gone with that boy, I wonder? You TOM!" - -No answer. - -The old lady pulled her spectacles down and looked over them about the -room; then she put them up and looked out under them. She seldom or -never looked THROUGH them for so small a thing as a boy; they were her -state pair, the pride of her heart, and were built for "style," not -service--she could have seen through a pair of stove-lids just as well. -She looked perplexed for a moment, and then said, not fiercely, but -still loud enough for the furniture to hear: - -"Well, I lay if I get hold of you I'll--" - -She did not finish, for by this time she was bending down and punching -under the bed with the broom, and so she needed breath to punctuate the -punches with. She resurrected nothing but the cat. - -"I never did see the beat of that boy!" - -She went to the open door and stood in it and looked out among the -tomato vines and "jimpson" weeds that constituted the garden. No Tom. -So she lifted up her voice at an angle calculated for distance and -shouted: - -"Y-o-u-u TOM!" - -There was a slight noise behind her and she turned just in time to -seize a small boy by the slack of his roundabout and arrest his flight. - -"There! I might 'a' thought of that closet. What you been doing in -there?" - -"Nothing." - -"Nothing! Look at your hands. And look at your mouth. What IS that -truck?" - -"I don't know, aunt." - -"Well, I know. It's jam--that's what it is. Forty times I've said if -you didn't let that jam alone I'd skin you. Hand me that switch." - -The switch hovered in the air--the peril was desperate-- - -"My! Look behind you, aunt!" - -The old lady whirled round, and snatched her skirts out of danger. The -lad fled on the instant, scrambled up the high board-fence, and -disappeared over it. - -His aunt Polly stood surprised a moment, and then broke into a gentle -laugh. - -"Hang the boy, can't I never learn anything? Ain't he played me tricks -enough like that for me to be looking out for him by this time? But old -fools is the biggest fools there is. Can't learn an old dog new tricks, -as the saying is. But my goodness, he never plays them alike, two days, -and how is a body to know what's coming? He 'pears to know just how -long he can torment me before I get my dander up, and he knows if he -can make out to put me off for a minute or make me laugh, it's all down -again and I can't hit him a lick. I ain't doing my duty by that boy, -and that's the Lord's truth, goodness knows. Spare the rod and spile -the child, as the Good Book says. I'm a laying up sin and suffering for -us both, I know. He's full of the Old Scratch, but laws-a-me! he's my -own dead sister's boy, poor thing, and I ain't got the heart to lash -him, somehow. Every time I let him off, my conscience does hurt me so, -and every time I hit him my old heart most breaks. Well-a-well, man -that is born of woman is of few days and full of trouble, as the -Scripture says, and I reckon it's so. He'll play hookey this evening, * -and [* Southwestern for "afternoon"] I'll just be obleeged to make him -work, to-morrow, to punish him. It's mighty hard to make him work -Saturdays, when all the boys is having holiday, but he hates work more -than he hates anything else, and I've GOT to do some of my duty by him, -or I'll be the ruination of the child." - -Tom did play hookey, and he had a very good time. He got back home -barely in season to help Jim, the small colored boy, saw next-day's -wood and split the kindlings before supper--at least he was there in -time to tell his adventures to Jim while Jim did three-fourths of the -work. Tom's younger brother (or rather half-brother) Sid was already -through with his part of the work (picking up chips), for he was a -quiet boy, and had no adventurous, troublesome ways. - -While Tom was eating his supper, and stealing sugar as opportunity -offered, Aunt Polly asked him questions that were full of guile, and -very deep--for she wanted to trap him into damaging revealments. Like -many other simple-hearted souls, it was her pet vanity to believe she -was endowed with a talent for dark and mysterious diplomacy, and she -loved to contemplate her most transparent devices as marvels of low -cunning. Said she: - -"Tom, it was middling warm in school, warn't it?" - -"Yes'm." - -"Powerful warm, warn't it?" - -"Yes'm." - -"Didn't you want to go in a-swimming, Tom?" - -A bit of a scare shot through Tom--a touch of uncomfortable suspicion. -He searched Aunt Polly's face, but it told him nothing. So he said: - -"No'm--well, not very much." - -The old lady reached out her hand and felt Tom's shirt, and said: - -"But you ain't too warm now, though." And it flattered her to reflect -that she had discovered that the shirt was dry without anybody knowing -that that was what she had in her mind. But in spite of her, Tom knew -where the wind lay, now. So he forestalled what might be the next move: - -"Some of us pumped on our heads--mine's damp yet. See?" - -Aunt Polly was vexed to think she had overlooked that bit of -circumstantial evidence, and missed a trick. Then she had a new -inspiration: - -"Tom, you didn't have to undo your shirt collar where I sewed it, to -pump on your head, did you? Unbutton your jacket!" - -The trouble vanished out of Tom's face. He opened his jacket. His -shirt collar was securely sewed. - -"Bother! Well, go 'long with you. I'd made sure you'd played hookey -and been a-swimming. But I forgive ye, Tom. I reckon you're a kind of a -singed cat, as the saying is--better'n you look. THIS time." - -She was half sorry her sagacity had miscarried, and half glad that Tom -had stumbled into obedient conduct for once. - -But Sidney said: - -"Well, now, if I didn't think you sewed his collar with white thread, -but it's black." - -"Why, I did sew it with white! Tom!" - -But Tom did not wait for the rest. As he went out at the door he said: - -"Siddy, I'll lick you for that." - -In a safe place Tom examined two large needles which were thrust into -the lapels of his jacket, and had thread bound about them--one needle -carried white thread and the other black. He said: - -"She'd never noticed if it hadn't been for Sid. Confound it! sometimes -she sews it with white, and sometimes she sews it with black. I wish to -geeminy she'd stick to one or t'other--I can't keep the run of 'em. But -I bet you I'll lam Sid for that. I'll learn him!" - -He was not the Model Boy of the village. He knew the model boy very -well though--and loathed him. - -Within two minutes, or even less, he had forgotten all his troubles. -Not because his troubles were one whit less heavy and bitter to him -than a man's are to a man, but because a new and powerful interest bore -them down and drove them out of his mind for the time--just as men's -misfortunes are forgotten in the excitement of new enterprises. This -new interest was a valued novelty in whistling, which he had just -acquired from a negro, and he was suffering to practise it undisturbed. -It consisted in a peculiar bird-like turn, a sort of liquid warble, -produced by touching the tongue to the roof of the mouth at short -intervals in the midst of the music--the reader probably remembers how -to do it, if he has ever been a boy. Diligence and attention soon gave -him the knack of it, and he strode down the street with his mouth full -of harmony and his soul full of gratitude. He felt much as an -astronomer feels who has discovered a new planet--no doubt, as far as -strong, deep, unalloyed pleasure is concerned, the advantage was with -the boy, not the astronomer. - -The summer evenings were long. It was not dark, yet. Presently Tom -checked his whistle. A stranger was before him--a boy a shade larger -than himself. A new-comer of any age or either sex was an impressive -curiosity in the poor little shabby village of St. Petersburg. This boy -was well dressed, too--well dressed on a week-day. This was simply -astounding. His cap was a dainty thing, his close-buttoned blue cloth -roundabout was new and natty, and so were his pantaloons. He had shoes -on--and it was only Friday. He even wore a necktie, a bright bit of -ribbon. He had a citified air about him that ate into Tom's vitals. The -more Tom stared at the splendid marvel, the higher he turned up his -nose at his finery and the shabbier and shabbier his own outfit seemed -to him to grow. Neither boy spoke. If one moved, the other moved--but -only sidewise, in a circle; they kept face to face and eye to eye all -the time. Finally Tom said: - -"I can lick you!" - -"I'd like to see you try it." - -"Well, I can do it." - -"No you can't, either." - -"Yes I can." - -"No you can't." - -"I can." - -"You can't." - -"Can!" - -"Can't!" - -An uncomfortable pause. Then Tom said: - -"What's your name?" - -"'Tisn't any of your business, maybe." - -"Well I 'low I'll MAKE it my business." - -"Well why don't you?" - -"If you say much, I will." - -"Much--much--MUCH. There now." - -"Oh, you think you're mighty smart, DON'T you? I could lick you with -one hand tied behind me, if I wanted to." - -"Well why don't you DO it? You SAY you can do it." - -"Well I WILL, if you fool with me." - -"Oh yes--I've seen whole families in the same fix." - -"Smarty! You think you're SOME, now, DON'T you? Oh, what a hat!" - -"You can lump that hat if you don't like it. I dare you to knock it -off--and anybody that'll take a dare will suck eggs." - -"You're a liar!" - -"You're another." - -"You're a fighting liar and dasn't take it up." - -"Aw--take a walk!" - -"Say--if you give me much more of your sass I'll take and bounce a -rock off'n your head." - -"Oh, of COURSE you will." - -"Well I WILL." - -"Well why don't you DO it then? What do you keep SAYING you will for? -Why don't you DO it? It's because you're afraid." - -"I AIN'T afraid." - -"You are." - -"I ain't." - -"You are." - -Another pause, and more eying and sidling around each other. Presently -they were shoulder to shoulder. Tom said: - -"Get away from here!" - -"Go away yourself!" - -"I won't." - -"I won't either." - -So they stood, each with a foot placed at an angle as a brace, and -both shoving with might and main, and glowering at each other with -hate. But neither could get an advantage. After struggling till both -were hot and flushed, each relaxed his strain with watchful caution, -and Tom said: - -"You're a coward and a pup. I'll tell my big brother on you, and he -can thrash you with his little finger, and I'll make him do it, too." - -"What do I care for your big brother? I've got a brother that's bigger -than he is--and what's more, he can throw him over that fence, too." -[Both brothers were imaginary.] - -"That's a lie." - -"YOUR saying so don't make it so." - -Tom drew a line in the dust with his big toe, and said: - -"I dare you to step over that, and I'll lick you till you can't stand -up. Anybody that'll take a dare will steal sheep." - -The new boy stepped over promptly, and said: - -"Now you said you'd do it, now let's see you do it." - -"Don't you crowd me now; you better look out." - -"Well, you SAID you'd do it--why don't you do it?" - -"By jingo! for two cents I WILL do it." - -The new boy took two broad coppers out of his pocket and held them out -with derision. Tom struck them to the ground. In an instant both boys -were rolling and tumbling in the dirt, gripped together like cats; and -for the space of a minute they tugged and tore at each other's hair and -clothes, punched and scratched each other's nose, and covered -themselves with dust and glory. Presently the confusion took form, and -through the fog of battle Tom appeared, seated astride the new boy, and -pounding him with his fists. "Holler 'nuff!" said he. - -The boy only struggled to free himself. He was crying--mainly from rage. - -"Holler 'nuff!"--and the pounding went on. - -At last the stranger got out a smothered "'Nuff!" and Tom let him up -and said: - -"Now that'll learn you. Better look out who you're fooling with next -time." - -The new boy went off brushing the dust from his clothes, sobbing, -snuffling, and occasionally looking back and shaking his head and -threatening what he would do to Tom the "next time he caught him out." -To which Tom responded with jeers, and started off in high feather, and -as soon as his back was turned the new boy snatched up a stone, threw -it and hit him between the shoulders and then turned tail and ran like -an antelope. Tom chased the traitor home, and thus found out where he -lived. He then held a position at the gate for some time, daring the -enemy to come outside, but the enemy only made faces at him through the -window and declined. At last the enemy's mother appeared, and called -Tom a bad, vicious, vulgar child, and ordered him away. So he went -away; but he said he "'lowed" to "lay" for that boy. - -He got home pretty late that night, and when he climbed cautiously in -at the window, he uncovered an ambuscade, in the person of his aunt; -and when she saw the state his clothes were in her resolution to turn -his Saturday holiday into captivity at hard labor became adamantine in -its firmness. - - - -CHAPTER II - -SATURDAY morning was come, and all the summer world was bright and -fresh, and brimming with life. There was a song in every heart; and if -the heart was young the music issued at the lips. There was cheer in -every face and a spring in every step. The locust-trees were in bloom -and the fragrance of the blossoms filled the air. Cardiff Hill, beyond -the village and above it, was green with vegetation and it lay just far -enough away to seem a Delectable Land, dreamy, reposeful, and inviting. - -Tom appeared on the sidewalk with a bucket of whitewash and a -long-handled brush. He surveyed the fence, and all gladness left him and -a deep melancholy settled down upon his spirit. Thirty yards of board -fence nine feet high. Life to him seemed hollow, and existence but a -burden. Sighing, he dipped his brush and passed it along the topmost -plank; repeated the operation; did it again; compared the insignificant -whitewashed streak with the far-reaching continent of unwhitewashed -fence, and sat down on a tree-box discouraged. Jim came skipping out at -the gate with a tin pail, and singing Buffalo Gals. Bringing water from -the town pump had always been hateful work in Tom's eyes, before, but -now it did not strike him so. He remembered that there was company at -the pump. White, mulatto, and negro boys and girls were always there -waiting their turns, resting, trading playthings, quarrelling, -fighting, skylarking. And he remembered that although the pump was only -a hundred and fifty yards off, Jim never got back with a bucket of -water under an hour--and even then somebody generally had to go after -him. Tom said: - -"Say, Jim, I'll fetch the water if you'll whitewash some." - -Jim shook his head and said: - -"Can't, Mars Tom. Ole missis, she tole me I got to go an' git dis -water an' not stop foolin' roun' wid anybody. She say she spec' Mars -Tom gwine to ax me to whitewash, an' so she tole me go 'long an' 'tend -to my own business--she 'lowed SHE'D 'tend to de whitewashin'." - -"Oh, never you mind what she said, Jim. That's the way she always -talks. Gimme the bucket--I won't be gone only a a minute. SHE won't -ever know." - -"Oh, I dasn't, Mars Tom. Ole missis she'd take an' tar de head off'n -me. 'Deed she would." - -"SHE! She never licks anybody--whacks 'em over the head with her -thimble--and who cares for that, I'd like to know. She talks awful, but -talk don't hurt--anyways it don't if she don't cry. Jim, I'll give you -a marvel. I'll give you a white alley!" - -Jim began to waver. - -"White alley, Jim! And it's a bully taw." - -"My! Dat's a mighty gay marvel, I tell you! But Mars Tom I's powerful -'fraid ole missis--" - -"And besides, if you will I'll show you my sore toe." - -Jim was only human--this attraction was too much for him. He put down -his pail, took the white alley, and bent over the toe with absorbing -interest while the bandage was being unwound. In another moment he was -flying down the street with his pail and a tingling rear, Tom was -whitewashing with vigor, and Aunt Polly was retiring from the field -with a slipper in her hand and triumph in her eye. - -But Tom's energy did not last. He began to think of the fun he had -planned for this day, and his sorrows multiplied. Soon the free boys -would come tripping along on all sorts of delicious expeditions, and -they would make a world of fun of him for having to work--the very -thought of it burnt him like fire. He got out his worldly wealth and -examined it--bits of toys, marbles, and trash; enough to buy an -exchange of WORK, maybe, but not half enough to buy so much as half an -hour of pure freedom. So he returned his straitened means to his -pocket, and gave up the idea of trying to buy the boys. At this dark -and hopeless moment an inspiration burst upon him! Nothing less than a -great, magnificent inspiration. - -He took up his brush and went tranquilly to work. Ben Rogers hove in -sight presently--the very boy, of all boys, whose ridicule he had been -dreading. Ben's gait was the hop-skip-and-jump--proof enough that his -heart was light and his anticipations high. He was eating an apple, and -giving a long, melodious whoop, at intervals, followed by a deep-toned -ding-dong-dong, ding-dong-dong, for he was personating a steamboat. As -he drew near, he slackened speed, took the middle of the street, leaned -far over to starboard and rounded to ponderously and with laborious -pomp and circumstance--for he was personating the Big Missouri, and -considered himself to be drawing nine feet of water. He was boat and -captain and engine-bells combined, so he had to imagine himself -standing on his own hurricane-deck giving the orders and executing them: - -"Stop her, sir! Ting-a-ling-ling!" The headway ran almost out, and he -drew up slowly toward the sidewalk. - -"Ship up to back! Ting-a-ling-ling!" His arms straightened and -stiffened down his sides. - -"Set her back on the stabboard! Ting-a-ling-ling! Chow! ch-chow-wow! -Chow!" His right hand, meantime, describing stately circles--for it was -representing a forty-foot wheel. - -"Let her go back on the labboard! Ting-a-lingling! Chow-ch-chow-chow!" -The left hand began to describe circles. - -"Stop the stabboard! Ting-a-ling-ling! Stop the labboard! Come ahead -on the stabboard! Stop her! Let your outside turn over slow! -Ting-a-ling-ling! Chow-ow-ow! Get out that head-line! LIVELY now! -Come--out with your spring-line--what're you about there! Take a turn -round that stump with the bight of it! Stand by that stage, now--let her -go! Done with the engines, sir! Ting-a-ling-ling! SH'T! S'H'T! SH'T!" -(trying the gauge-cocks). - -Tom went on whitewashing--paid no attention to the steamboat. Ben -stared a moment and then said: "Hi-YI! YOU'RE up a stump, ain't you!" - -No answer. Tom surveyed his last touch with the eye of an artist, then -he gave his brush another gentle sweep and surveyed the result, as -before. Ben ranged up alongside of him. Tom's mouth watered for the -apple, but he stuck to his work. Ben said: - -"Hello, old chap, you got to work, hey?" - -Tom wheeled suddenly and said: - -"Why, it's you, Ben! I warn't noticing." - -"Say--I'm going in a-swimming, I am. Don't you wish you could? But of -course you'd druther WORK--wouldn't you? Course you would!" - -Tom contemplated the boy a bit, and said: - -"What do you call work?" - -"Why, ain't THAT work?" - -Tom resumed his whitewashing, and answered carelessly: - -"Well, maybe it is, and maybe it ain't. All I know, is, it suits Tom -Sawyer." - -"Oh come, now, you don't mean to let on that you LIKE it?" - -The brush continued to move. - -"Like it? Well, I don't see why I oughtn't to like it. Does a boy get -a chance to whitewash a fence every day?" - -That put the thing in a new light. Ben stopped nibbling his apple. Tom -swept his brush daintily back and forth--stepped back to note the -effect--added a touch here and there--criticised the effect again--Ben -watching every move and getting more and more interested, more and more -absorbed. Presently he said: - -"Say, Tom, let ME whitewash a little." - -Tom considered, was about to consent; but he altered his mind: - -"No--no--I reckon it wouldn't hardly do, Ben. You see, Aunt Polly's -awful particular about this fence--right here on the street, you know ---but if it was the back fence I wouldn't mind and SHE wouldn't. Yes, -she's awful particular about this fence; it's got to be done very -careful; I reckon there ain't one boy in a thousand, maybe two -thousand, that can do it the way it's got to be done." - -"No--is that so? Oh come, now--lemme just try. Only just a little--I'd -let YOU, if you was me, Tom." - -"Ben, I'd like to, honest injun; but Aunt Polly--well, Jim wanted to -do it, but she wouldn't let him; Sid wanted to do it, and she wouldn't -let Sid. Now don't you see how I'm fixed? If you was to tackle this -fence and anything was to happen to it--" - -"Oh, shucks, I'll be just as careful. Now lemme try. Say--I'll give -you the core of my apple." - -"Well, here--No, Ben, now don't. I'm afeard--" - -"I'll give you ALL of it!" - -Tom gave up the brush with reluctance in his face, but alacrity in his -heart. And while the late steamer Big Missouri worked and sweated in -the sun, the retired artist sat on a barrel in the shade close by, -dangled his legs, munched his apple, and planned the slaughter of more -innocents. There was no lack of material; boys happened along every -little while; they came to jeer, but remained to whitewash. By the time -Ben was fagged out, Tom had traded the next chance to Billy Fisher for -a kite, in good repair; and when he played out, Johnny Miller bought in -for a dead rat and a string to swing it with--and so on, and so on, -hour after hour. And when the middle of the afternoon came, from being -a poor poverty-stricken boy in the morning, Tom was literally rolling -in wealth. He had besides the things before mentioned, twelve marbles, -part of a jews-harp, a piece of blue bottle-glass to look through, a -spool cannon, a key that wouldn't unlock anything, a fragment of chalk, -a glass stopper of a decanter, a tin soldier, a couple of tadpoles, six -fire-crackers, a kitten with only one eye, a brass doorknob, a -dog-collar--but no dog--the handle of a knife, four pieces of -orange-peel, and a dilapidated old window sash. - -He had had a nice, good, idle time all the while--plenty of company ---and the fence had three coats of whitewash on it! If he hadn't run out -of whitewash he would have bankrupted every boy in the village. - -Tom said to himself that it was not such a hollow world, after all. He -had discovered a great law of human action, without knowing it--namely, -that in order to make a man or a boy covet a thing, it is only -necessary to make the thing difficult to attain. If he had been a great -and wise philosopher, like the writer of this book, he would now have -comprehended that Work consists of whatever a body is OBLIGED to do, -and that Play consists of whatever a body is not obliged to do. And -this would help him to understand why constructing artificial flowers -or performing on a tread-mill is work, while rolling ten-pins or -climbing Mont Blanc is only amusement. There are wealthy gentlemen in -England who drive four-horse passenger-coaches twenty or thirty miles -on a daily line, in the summer, because the privilege costs them -considerable money; but if they were offered wages for the service, -that would turn it into work and then they would resign. - -The boy mused awhile over the substantial change which had taken place -in his worldly circumstances, and then wended toward headquarters to -report. - - - -CHAPTER III - -TOM presented himself before Aunt Polly, who was sitting by an open -window in a pleasant rearward apartment, which was bedroom, -breakfast-room, dining-room, and library, combined. The balmy summer -air, the restful quiet, the odor of the flowers, and the drowsing murmur -of the bees had had their effect, and she was nodding over her knitting ---for she had no company but the cat, and it was asleep in her lap. Her -spectacles were propped up on her gray head for safety. She had thought -that of course Tom had deserted long ago, and she wondered at seeing him -place himself in her power again in this intrepid way. He said: "Mayn't -I go and play now, aunt?" - -"What, a'ready? How much have you done?" - -"It's all done, aunt." - -"Tom, don't lie to me--I can't bear it." - -"I ain't, aunt; it IS all done." - -Aunt Polly placed small trust in such evidence. She went out to see -for herself; and she would have been content to find twenty per cent. -of Tom's statement true. When she found the entire fence whitewashed, -and not only whitewashed but elaborately coated and recoated, and even -a streak added to the ground, her astonishment was almost unspeakable. -She said: - -"Well, I never! There's no getting round it, you can work when you're -a mind to, Tom." And then she diluted the compliment by adding, "But -it's powerful seldom you're a mind to, I'm bound to say. Well, go 'long -and play; but mind you get back some time in a week, or I'll tan you." - -She was so overcome by the splendor of his achievement that she took -him into the closet and selected a choice apple and delivered it to -him, along with an improving lecture upon the added value and flavor a -treat took to itself when it came without sin through virtuous effort. -And while she closed with a happy Scriptural flourish, he "hooked" a -doughnut. - -Then he skipped out, and saw Sid just starting up the outside stairway -that led to the back rooms on the second floor. Clods were handy and -the air was full of them in a twinkling. They raged around Sid like a -hail-storm; and before Aunt Polly could collect her surprised faculties -and sally to the rescue, six or seven clods had taken personal effect, -and Tom was over the fence and gone. There was a gate, but as a general -thing he was too crowded for time to make use of it. His soul was at -peace, now that he had settled with Sid for calling attention to his -black thread and getting him into trouble. - -Tom skirted the block, and came round into a muddy alley that led by -the back of his aunt's cow-stable. He presently got safely beyond the -reach of capture and punishment, and hastened toward the public square -of the village, where two "military" companies of boys had met for -conflict, according to previous appointment. Tom was General of one of -these armies, Joe Harper (a bosom friend) General of the other. These -two great commanders did not condescend to fight in person--that being -better suited to the still smaller fry--but sat together on an eminence -and conducted the field operations by orders delivered through -aides-de-camp. Tom's army won a great victory, after a long and -hard-fought battle. Then the dead were counted, prisoners exchanged, -the terms of the next disagreement agreed upon, and the day for the -necessary battle appointed; after which the armies fell into line and -marched away, and Tom turned homeward alone. - -As he was passing by the house where Jeff Thatcher lived, he saw a new -girl in the garden--a lovely little blue-eyed creature with yellow hair -plaited into two long-tails, white summer frock and embroidered -pantalettes. The fresh-crowned hero fell without firing a shot. A -certain Amy Lawrence vanished out of his heart and left not even a -memory of herself behind. He had thought he loved her to distraction; -he had regarded his passion as adoration; and behold it was only a poor -little evanescent partiality. He had been months winning her; she had -confessed hardly a week ago; he had been the happiest and the proudest -boy in the world only seven short days, and here in one instant of time -she had gone out of his heart like a casual stranger whose visit is -done. - -He worshipped this new angel with furtive eye, till he saw that she -had discovered him; then he pretended he did not know she was present, -and began to "show off" in all sorts of absurd boyish ways, in order to -win her admiration. He kept up this grotesque foolishness for some -time; but by-and-by, while he was in the midst of some dangerous -gymnastic performances, he glanced aside and saw that the little girl -was wending her way toward the house. Tom came up to the fence and -leaned on it, grieving, and hoping she would tarry yet awhile longer. -She halted a moment on the steps and then moved toward the door. Tom -heaved a great sigh as she put her foot on the threshold. But his face -lit up, right away, for she tossed a pansy over the fence a moment -before she disappeared. - -The boy ran around and stopped within a foot or two of the flower, and -then shaded his eyes with his hand and began to look down street as if -he had discovered something of interest going on in that direction. -Presently he picked up a straw and began trying to balance it on his -nose, with his head tilted far back; and as he moved from side to side, -in his efforts, he edged nearer and nearer toward the pansy; finally -his bare foot rested upon it, his pliant toes closed upon it, and he -hopped away with the treasure and disappeared round the corner. But -only for a minute--only while he could button the flower inside his -jacket, next his heart--or next his stomach, possibly, for he was not -much posted in anatomy, and not hypercritical, anyway. - -He returned, now, and hung about the fence till nightfall, "showing -off," as before; but the girl never exhibited herself again, though Tom -comforted himself a little with the hope that she had been near some -window, meantime, and been aware of his attentions. Finally he strode -home reluctantly, with his poor head full of visions. - -All through supper his spirits were so high that his aunt wondered -"what had got into the child." He took a good scolding about clodding -Sid, and did not seem to mind it in the least. He tried to steal sugar -under his aunt's very nose, and got his knuckles rapped for it. He said: - -"Aunt, you don't whack Sid when he takes it." - -"Well, Sid don't torment a body the way you do. You'd be always into -that sugar if I warn't watching you." - -Presently she stepped into the kitchen, and Sid, happy in his -immunity, reached for the sugar-bowl--a sort of glorying over Tom which -was wellnigh unbearable. But Sid's fingers slipped and the bowl dropped -and broke. Tom was in ecstasies. In such ecstasies that he even -controlled his tongue and was silent. He said to himself that he would -not speak a word, even when his aunt came in, but would sit perfectly -still till she asked who did the mischief; and then he would tell, and -there would be nothing so good in the world as to see that pet model -"catch it." He was so brimful of exultation that he could hardly hold -himself when the old lady came back and stood above the wreck -discharging lightnings of wrath from over her spectacles. He said to -himself, "Now it's coming!" And the next instant he was sprawling on -the floor! The potent palm was uplifted to strike again when Tom cried -out: - -"Hold on, now, what 'er you belting ME for?--Sid broke it!" - -Aunt Polly paused, perplexed, and Tom looked for healing pity. But -when she got her tongue again, she only said: - -"Umf! Well, you didn't get a lick amiss, I reckon. You been into some -other audacious mischief when I wasn't around, like enough." - -Then her conscience reproached her, and she yearned to say something -kind and loving; but she judged that this would be construed into a -confession that she had been in the wrong, and discipline forbade that. -So she kept silence, and went about her affairs with a troubled heart. -Tom sulked in a corner and exalted his woes. He knew that in her heart -his aunt was on her knees to him, and he was morosely gratified by the -consciousness of it. He would hang out no signals, he would take notice -of none. He knew that a yearning glance fell upon him, now and then, -through a film of tears, but he refused recognition of it. He pictured -himself lying sick unto death and his aunt bending over him beseeching -one little forgiving word, but he would turn his face to the wall, and -die with that word unsaid. Ah, how would she feel then? And he pictured -himself brought home from the river, dead, with his curls all wet, and -his sore heart at rest. How she would throw herself upon him, and how -her tears would fall like rain, and her lips pray God to give her back -her boy and she would never, never abuse him any more! But he would lie -there cold and white and make no sign--a poor little sufferer, whose -griefs were at an end. He so worked upon his feelings with the pathos -of these dreams, that he had to keep swallowing, he was so like to -choke; and his eyes swam in a blur of water, which overflowed when he -winked, and ran down and trickled from the end of his nose. And such a -luxury to him was this petting of his sorrows, that he could not bear -to have any worldly cheeriness or any grating delight intrude upon it; -it was too sacred for such contact; and so, presently, when his cousin -Mary danced in, all alive with the joy of seeing home again after an -age-long visit of one week to the country, he got up and moved in -clouds and darkness out at one door as she brought song and sunshine in -at the other. - -He wandered far from the accustomed haunts of boys, and sought -desolate places that were in harmony with his spirit. A log raft in the -river invited him, and he seated himself on its outer edge and -contemplated the dreary vastness of the stream, wishing, the while, -that he could only be drowned, all at once and unconsciously, without -undergoing the uncomfortable routine devised by nature. Then he thought -of his flower. He got it out, rumpled and wilted, and it mightily -increased his dismal felicity. He wondered if she would pity him if she -knew? Would she cry, and wish that she had a right to put her arms -around his neck and comfort him? Or would she turn coldly away like all -the hollow world? This picture brought such an agony of pleasurable -suffering that he worked it over and over again in his mind and set it -up in new and varied lights, till he wore it threadbare. At last he -rose up sighing and departed in the darkness. - -About half-past nine or ten o'clock he came along the deserted street -to where the Adored Unknown lived; he paused a moment; no sound fell -upon his listening ear; a candle was casting a dull glow upon the -curtain of a second-story window. Was the sacred presence there? He -climbed the fence, threaded his stealthy way through the plants, till -he stood under that window; he looked up at it long, and with emotion; -then he laid him down on the ground under it, disposing himself upon -his back, with his hands clasped upon his breast and holding his poor -wilted flower. And thus he would die--out in the cold world, with no -shelter over his homeless head, no friendly hand to wipe the -death-damps from his brow, no loving face to bend pityingly over him -when the great agony came. And thus SHE would see him when she looked -out upon the glad morning, and oh! would she drop one little tear upon -his poor, lifeless form, would she heave one little sigh to see a bright -young life so rudely blighted, so untimely cut down? - -The window went up, a maid-servant's discordant voice profaned the -holy calm, and a deluge of water drenched the prone martyr's remains! - -The strangling hero sprang up with a relieving snort. There was a whiz -as of a missile in the air, mingled with the murmur of a curse, a sound -as of shivering glass followed, and a small, vague form went over the -fence and shot away in the gloom. - -Not long after, as Tom, all undressed for bed, was surveying his -drenched garments by the light of a tallow dip, Sid woke up; but if he -had any dim idea of making any "references to allusions," he thought -better of it and held his peace, for there was danger in Tom's eye. - -Tom turned in without the added vexation of prayers, and Sid made -mental note of the omission. - - - -CHAPTER IV - -THE sun rose upon a tranquil world, and beamed down upon the peaceful -village like a benediction. Breakfast over, Aunt Polly had family -worship: it began with a prayer built from the ground up of solid -courses of Scriptural quotations, welded together with a thin mortar of -originality; and from the summit of this she delivered a grim chapter -of the Mosaic Law, as from Sinai. - -Then Tom girded up his loins, so to speak, and went to work to "get -his verses." Sid had learned his lesson days before. Tom bent all his -energies to the memorizing of five verses, and he chose part of the -Sermon on the Mount, because he could find no verses that were shorter. -At the end of half an hour Tom had a vague general idea of his lesson, -but no more, for his mind was traversing the whole field of human -thought, and his hands were busy with distracting recreations. Mary -took his book to hear him recite, and he tried to find his way through -the fog: - -"Blessed are the--a--a--" - -"Poor"-- - -"Yes--poor; blessed are the poor--a--a--" - -"In spirit--" - -"In spirit; blessed are the poor in spirit, for they--they--" - -"THEIRS--" - -"For THEIRS. Blessed are the poor in spirit, for theirs is the kingdom -of heaven. Blessed are they that mourn, for they--they--" - -"Sh--" - -"For they--a--" - -"S, H, A--" - -"For they S, H--Oh, I don't know what it is!" - -"SHALL!" - -"Oh, SHALL! for they shall--for they shall--a--a--shall mourn--a--a-- -blessed are they that shall--they that--a--they that shall mourn, for -they shall--a--shall WHAT? Why don't you tell me, Mary?--what do you -want to be so mean for?" - -"Oh, Tom, you poor thick-headed thing, I'm not teasing you. I wouldn't -do that. You must go and learn it again. Don't you be discouraged, Tom, -you'll manage it--and if you do, I'll give you something ever so nice. -There, now, that's a good boy." - -"All right! What is it, Mary, tell me what it is." - -"Never you mind, Tom. You know if I say it's nice, it is nice." - -"You bet you that's so, Mary. All right, I'll tackle it again." - -And he did "tackle it again"--and under the double pressure of -curiosity and prospective gain he did it with such spirit that he -accomplished a shining success. Mary gave him a brand-new "Barlow" -knife worth twelve and a half cents; and the convulsion of delight that -swept his system shook him to his foundations. True, the knife would -not cut anything, but it was a "sure-enough" Barlow, and there was -inconceivable grandeur in that--though where the Western boys ever got -the idea that such a weapon could possibly be counterfeited to its -injury is an imposing mystery and will always remain so, perhaps. Tom -contrived to scarify the cupboard with it, and was arranging to begin -on the bureau, when he was called off to dress for Sunday-school. - -Mary gave him a tin basin of water and a piece of soap, and he went -outside the door and set the basin on a little bench there; then he -dipped the soap in the water and laid it down; turned up his sleeves; -poured out the water on the ground, gently, and then entered the -kitchen and began to wipe his face diligently on the towel behind the -door. But Mary removed the towel and said: - -"Now ain't you ashamed, Tom. You mustn't be so bad. Water won't hurt -you." - -Tom was a trifle disconcerted. The basin was refilled, and this time -he stood over it a little while, gathering resolution; took in a big -breath and began. When he entered the kitchen presently, with both eyes -shut and groping for the towel with his hands, an honorable testimony -of suds and water was dripping from his face. But when he emerged from -the towel, he was not yet satisfactory, for the clean territory stopped -short at his chin and his jaws, like a mask; below and beyond this line -there was a dark expanse of unirrigated soil that spread downward in -front and backward around his neck. Mary took him in hand, and when she -was done with him he was a man and a brother, without distinction of -color, and his saturated hair was neatly brushed, and its short curls -wrought into a dainty and symmetrical general effect. [He privately -smoothed out the curls, with labor and difficulty, and plastered his -hair close down to his head; for he held curls to be effeminate, and -his own filled his life with bitterness.] Then Mary got out a suit of -his clothing that had been used only on Sundays during two years--they -were simply called his "other clothes"--and so by that we know the -size of his wardrobe. The girl "put him to rights" after he had dressed -himself; she buttoned his neat roundabout up to his chin, turned his -vast shirt collar down over his shoulders, brushed him off and crowned -him with his speckled straw hat. He now looked exceedingly improved and -uncomfortable. He was fully as uncomfortable as he looked; for there -was a restraint about whole clothes and cleanliness that galled him. He -hoped that Mary would forget his shoes, but the hope was blighted; she -coated them thoroughly with tallow, as was the custom, and brought them -out. He lost his temper and said he was always being made to do -everything he didn't want to do. But Mary said, persuasively: - -"Please, Tom--that's a good boy." - -So he got into the shoes snarling. Mary was soon ready, and the three -children set out for Sunday-school--a place that Tom hated with his -whole heart; but Sid and Mary were fond of it. - -Sabbath-school hours were from nine to half-past ten; and then church -service. Two of the children always remained for the sermon -voluntarily, and the other always remained too--for stronger reasons. -The church's high-backed, uncushioned pews would seat about three -hundred persons; the edifice was but a small, plain affair, with a sort -of pine board tree-box on top of it for a steeple. At the door Tom -dropped back a step and accosted a Sunday-dressed comrade: - -"Say, Billy, got a yaller ticket?" - -"Yes." - -"What'll you take for her?" - -"What'll you give?" - -"Piece of lickrish and a fish-hook." - -"Less see 'em." - -Tom exhibited. They were satisfactory, and the property changed hands. -Then Tom traded a couple of white alleys for three red tickets, and -some small trifle or other for a couple of blue ones. He waylaid other -boys as they came, and went on buying tickets of various colors ten or -fifteen minutes longer. He entered the church, now, with a swarm of -clean and noisy boys and girls, proceeded to his seat and started a -quarrel with the first boy that came handy. The teacher, a grave, -elderly man, interfered; then turned his back a moment and Tom pulled a -boy's hair in the next bench, and was absorbed in his book when the boy -turned around; stuck a pin in another boy, presently, in order to hear -him say "Ouch!" and got a new reprimand from his teacher. Tom's whole -class were of a pattern--restless, noisy, and troublesome. When they -came to recite their lessons, not one of them knew his verses -perfectly, but had to be prompted all along. However, they worried -through, and each got his reward--in small blue tickets, each with a -passage of Scripture on it; each blue ticket was pay for two verses of -the recitation. Ten blue tickets equalled a red one, and could be -exchanged for it; ten red tickets equalled a yellow one; for ten yellow -tickets the superintendent gave a very plainly bound Bible (worth forty -cents in those easy times) to the pupil. How many of my readers would -have the industry and application to memorize two thousand verses, even -for a Dore Bible? And yet Mary had acquired two Bibles in this way--it -was the patient work of two years--and a boy of German parentage had -won four or five. He once recited three thousand verses without -stopping; but the strain upon his mental faculties was too great, and -he was little better than an idiot from that day forth--a grievous -misfortune for the school, for on great occasions, before company, the -superintendent (as Tom expressed it) had always made this boy come out -and "spread himself." Only the older pupils managed to keep their -tickets and stick to their tedious work long enough to get a Bible, and -so the delivery of one of these prizes was a rare and noteworthy -circumstance; the successful pupil was so great and conspicuous for -that day that on the spot every scholar's heart was fired with a fresh -ambition that often lasted a couple of weeks. It is possible that Tom's -mental stomach had never really hungered for one of those prizes, but -unquestionably his entire being had for many a day longed for the glory -and the eclat that came with it. - -In due course the superintendent stood up in front of the pulpit, with -a closed hymn-book in his hand and his forefinger inserted between its -leaves, and commanded attention. When a Sunday-school superintendent -makes his customary little speech, a hymn-book in the hand is as -necessary as is the inevitable sheet of music in the hand of a singer -who stands forward on the platform and sings a solo at a concert ---though why, is a mystery: for neither the hymn-book nor the sheet of -music is ever referred to by the sufferer. This superintendent was a -slim creature of thirty-five, with a sandy goatee and short sandy hair; -he wore a stiff standing-collar whose upper edge almost reached his -ears and whose sharp points curved forward abreast the corners of his -mouth--a fence that compelled a straight lookout ahead, and a turning -of the whole body when a side view was required; his chin was propped -on a spreading cravat which was as broad and as long as a bank-note, -and had fringed ends; his boot toes were turned sharply up, in the -fashion of the day, like sleigh-runners--an effect patiently and -laboriously produced by the young men by sitting with their toes -pressed against a wall for hours together. Mr. Walters was very earnest -of mien, and very sincere and honest at heart; and he held sacred -things and places in such reverence, and so separated them from worldly -matters, that unconsciously to himself his Sunday-school voice had -acquired a peculiar intonation which was wholly absent on week-days. He -began after this fashion: - -"Now, children, I want you all to sit up just as straight and pretty -as you can and give me all your attention for a minute or two. There ---that is it. That is the way good little boys and girls should do. I see -one little girl who is looking out of the window--I am afraid she -thinks I am out there somewhere--perhaps up in one of the trees making -a speech to the little birds. [Applausive titter.] I want to tell you -how good it makes me feel to see so many bright, clean little faces -assembled in a place like this, learning to do right and be good." And -so forth and so on. It is not necessary to set down the rest of the -oration. It was of a pattern which does not vary, and so it is familiar -to us all. - -The latter third of the speech was marred by the resumption of fights -and other recreations among certain of the bad boys, and by fidgetings -and whisperings that extended far and wide, washing even to the bases -of isolated and incorruptible rocks like Sid and Mary. But now every -sound ceased suddenly, with the subsidence of Mr. Walters' voice, and -the conclusion of the speech was received with a burst of silent -gratitude. - -A good part of the whispering had been occasioned by an event which -was more or less rare--the entrance of visitors: lawyer Thatcher, -accompanied by a very feeble and aged man; a fine, portly, middle-aged -gentleman with iron-gray hair; and a dignified lady who was doubtless -the latter's wife. The lady was leading a child. Tom had been restless -and full of chafings and repinings; conscience-smitten, too--he could -not meet Amy Lawrence's eye, he could not brook her loving gaze. But -when he saw this small new-comer his soul was all ablaze with bliss in -a moment. The next moment he was "showing off" with all his might ---cuffing boys, pulling hair, making faces--in a word, using every art -that seemed likely to fascinate a girl and win her applause. His -exaltation had but one alloy--the memory of his humiliation in this -angel's garden--and that record in sand was fast washing out, under -the waves of happiness that were sweeping over it now. - -The visitors were given the highest seat of honor, and as soon as Mr. -Walters' speech was finished, he introduced them to the school. The -middle-aged man turned out to be a prodigious personage--no less a one -than the county judge--altogether the most august creation these -children had ever looked upon--and they wondered what kind of material -he was made of--and they half wanted to hear him roar, and were half -afraid he might, too. He was from Constantinople, twelve miles away--so -he had travelled, and seen the world--these very eyes had looked upon -the county court-house--which was said to have a tin roof. The awe -which these reflections inspired was attested by the impressive silence -and the ranks of staring eyes. This was the great Judge Thatcher, -brother of their own lawyer. Jeff Thatcher immediately went forward, to -be familiar with the great man and be envied by the school. It would -have been music to his soul to hear the whisperings: - -"Look at him, Jim! He's a going up there. Say--look! he's a going to -shake hands with him--he IS shaking hands with him! By jings, don't you -wish you was Jeff?" - -Mr. Walters fell to "showing off," with all sorts of official -bustlings and activities, giving orders, delivering judgments, -discharging directions here, there, everywhere that he could find a -target. The librarian "showed off"--running hither and thither with his -arms full of books and making a deal of the splutter and fuss that -insect authority delights in. The young lady teachers "showed off" ---bending sweetly over pupils that were lately being boxed, lifting -pretty warning fingers at bad little boys and patting good ones -lovingly. The young gentlemen teachers "showed off" with small -scoldings and other little displays of authority and fine attention to -discipline--and most of the teachers, of both sexes, found business up -at the library, by the pulpit; and it was business that frequently had -to be done over again two or three times (with much seeming vexation). -The little girls "showed off" in various ways, and the little boys -"showed off" with such diligence that the air was thick with paper wads -and the murmur of scufflings. And above it all the great man sat and -beamed a majestic judicial smile upon all the house, and warmed himself -in the sun of his own grandeur--for he was "showing off," too. - -There was only one thing wanting to make Mr. Walters' ecstasy -complete, and that was a chance to deliver a Bible-prize and exhibit a -prodigy. Several pupils had a few yellow tickets, but none had enough ---he had been around among the star pupils inquiring. He would have given -worlds, now, to have that German lad back again with a sound mind. - -And now at this moment, when hope was dead, Tom Sawyer came forward -with nine yellow tickets, nine red tickets, and ten blue ones, and -demanded a Bible. This was a thunderbolt out of a clear sky. Walters -was not expecting an application from this source for the next ten -years. But there was no getting around it--here were the certified -checks, and they were good for their face. Tom was therefore elevated -to a place with the Judge and the other elect, and the great news was -announced from headquarters. It was the most stunning surprise of the -decade, and so profound was the sensation that it lifted the new hero -up to the judicial one's altitude, and the school had two marvels to -gaze upon in place of one. The boys were all eaten up with envy--but -those that suffered the bitterest pangs were those who perceived too -late that they themselves had contributed to this hated splendor by -trading tickets to Tom for the wealth he had amassed in selling -whitewashing privileges. These despised themselves, as being the dupes -of a wily fraud, a guileful snake in the grass. - -The prize was delivered to Tom with as much effusion as the -superintendent could pump up under the circumstances; but it lacked -somewhat of the true gush, for the poor fellow's instinct taught him -that there was a mystery here that could not well bear the light, -perhaps; it was simply preposterous that this boy had warehoused two -thousand sheaves of Scriptural wisdom on his premises--a dozen would -strain his capacity, without a doubt. - -Amy Lawrence was proud and glad, and she tried to make Tom see it in -her face--but he wouldn't look. She wondered; then she was just a grain -troubled; next a dim suspicion came and went--came again; she watched; -a furtive glance told her worlds--and then her heart broke, and she was -jealous, and angry, and the tears came and she hated everybody. Tom -most of all (she thought). - -Tom was introduced to the Judge; but his tongue was tied, his breath -would hardly come, his heart quaked--partly because of the awful -greatness of the man, but mainly because he was her parent. He would -have liked to fall down and worship him, if it were in the dark. The -Judge put his hand on Tom's head and called him a fine little man, and -asked him what his name was. The boy stammered, gasped, and got it out: - -"Tom." - -"Oh, no, not Tom--it is--" - -"Thomas." - -"Ah, that's it. I thought there was more to it, maybe. That's very -well. But you've another one I daresay, and you'll tell it to me, won't -you?" - -"Tell the gentleman your other name, Thomas," said Walters, "and say -sir. You mustn't forget your manners." - -"Thomas Sawyer--sir." - -"That's it! That's a good boy. Fine boy. Fine, manly little fellow. -Two thousand verses is a great many--very, very great many. And you -never can be sorry for the trouble you took to learn them; for -knowledge is worth more than anything there is in the world; it's what -makes great men and good men; you'll be a great man and a good man -yourself, some day, Thomas, and then you'll look back and say, It's all -owing to the precious Sunday-school privileges of my boyhood--it's all -owing to my dear teachers that taught me to learn--it's all owing to -the good superintendent, who encouraged me, and watched over me, and -gave me a beautiful Bible--a splendid elegant Bible--to keep and have -it all for my own, always--it's all owing to right bringing up! That is -what you will say, Thomas--and you wouldn't take any money for those -two thousand verses--no indeed you wouldn't. And now you wouldn't mind -telling me and this lady some of the things you've learned--no, I know -you wouldn't--for we are proud of little boys that learn. Now, no -doubt you know the names of all the twelve disciples. Won't you tell us -the names of the first two that were appointed?" - -Tom was tugging at a button-hole and looking sheepish. He blushed, -now, and his eyes fell. Mr. Walters' heart sank within him. He said to -himself, it is not possible that the boy can answer the simplest -question--why DID the Judge ask him? Yet he felt obliged to speak up -and say: - -"Answer the gentleman, Thomas--don't be afraid." - -Tom still hung fire. - -"Now I know you'll tell me," said the lady. "The names of the first -two disciples were--" - -"DAVID AND GOLIAH!" - -Let us draw the curtain of charity over the rest of the scene. - - - -CHAPTER V - -ABOUT half-past ten the cracked bell of the small church began to -ring, and presently the people began to gather for the morning sermon. -The Sunday-school children distributed themselves about the house and -occupied pews with their parents, so as to be under supervision. Aunt -Polly came, and Tom and Sid and Mary sat with her--Tom being placed -next the aisle, in order that he might be as far away from the open -window and the seductive outside summer scenes as possible. The crowd -filed up the aisles: the aged and needy postmaster, who had seen better -days; the mayor and his wife--for they had a mayor there, among other -unnecessaries; the justice of the peace; the widow Douglass, fair, -smart, and forty, a generous, good-hearted soul and well-to-do, her -hill mansion the only palace in the town, and the most hospitable and -much the most lavish in the matter of festivities that St. Petersburg -could boast; the bent and venerable Major and Mrs. Ward; lawyer -Riverson, the new notable from a distance; next the belle of the -village, followed by a troop of lawn-clad and ribbon-decked young -heart-breakers; then all the young clerks in town in a body--for they -had stood in the vestibule sucking their cane-heads, a circling wall of -oiled and simpering admirers, till the last girl had run their gantlet; -and last of all came the Model Boy, Willie Mufferson, taking as heedful -care of his mother as if she were cut glass. He always brought his -mother to church, and was the pride of all the matrons. The boys all -hated him, he was so good. And besides, he had been "thrown up to them" -so much. His white handkerchief was hanging out of his pocket behind, as -usual on Sundays--accidentally. Tom had no handkerchief, and he looked -upon boys who had as snobs. - -The congregation being fully assembled, now, the bell rang once more, -to warn laggards and stragglers, and then a solemn hush fell upon the -church which was only broken by the tittering and whispering of the -choir in the gallery. The choir always tittered and whispered all -through service. There was once a church choir that was not ill-bred, -but I have forgotten where it was, now. It was a great many years ago, -and I can scarcely remember anything about it, but I think it was in -some foreign country. - -The minister gave out the hymn, and read it through with a relish, in -a peculiar style which was much admired in that part of the country. -His voice began on a medium key and climbed steadily up till it reached -a certain point, where it bore with strong emphasis upon the topmost -word and then plunged down as if from a spring-board: - - Shall I be car-ri-ed toe the skies, on flow'ry BEDS of ease, - - Whilst others fight to win the prize, and sail thro' BLOODY seas? - -He was regarded as a wonderful reader. At church "sociables" he was -always called upon to read poetry; and when he was through, the ladies -would lift up their hands and let them fall helplessly in their laps, -and "wall" their eyes, and shake their heads, as much as to say, "Words -cannot express it; it is too beautiful, TOO beautiful for this mortal -earth." - -After the hymn had been sung, the Rev. Mr. Sprague turned himself into -a bulletin-board, and read off "notices" of meetings and societies and -things till it seemed that the list would stretch out to the crack of -doom--a queer custom which is still kept up in America, even in cities, -away here in this age of abundant newspapers. Often, the less there is -to justify a traditional custom, the harder it is to get rid of it. - -And now the minister prayed. A good, generous prayer it was, and went -into details: it pleaded for the church, and the little children of the -church; for the other churches of the village; for the village itself; -for the county; for the State; for the State officers; for the United -States; for the churches of the United States; for Congress; for the -President; for the officers of the Government; for poor sailors, tossed -by stormy seas; for the oppressed millions groaning under the heel of -European monarchies and Oriental despotisms; for such as have the light -and the good tidings, and yet have not eyes to see nor ears to hear -withal; for the heathen in the far islands of the sea; and closed with -a supplication that the words he was about to speak might find grace -and favor, and be as seed sown in fertile ground, yielding in time a -grateful harvest of good. Amen. - -There was a rustling of dresses, and the standing congregation sat -down. The boy whose history this book relates did not enjoy the prayer, -he only endured it--if he even did that much. He was restive all -through it; he kept tally of the details of the prayer, unconsciously ---for he was not listening, but he knew the ground of old, and the -clergyman's regular route over it--and when a little trifle of new -matter was interlarded, his ear detected it and his whole nature -resented it; he considered additions unfair, and scoundrelly. In the -midst of the prayer a fly had lit on the back of the pew in front of -him and tortured his spirit by calmly rubbing its hands together, -embracing its head with its arms, and polishing it so vigorously that -it seemed to almost part company with the body, and the slender thread -of a neck was exposed to view; scraping its wings with its hind legs -and smoothing them to its body as if they had been coat-tails; going -through its whole toilet as tranquilly as if it knew it was perfectly -safe. As indeed it was; for as sorely as Tom's hands itched to grab for -it they did not dare--he believed his soul would be instantly destroyed -if he did such a thing while the prayer was going on. But with the -closing sentence his hand began to curve and steal forward; and the -instant the "Amen" was out the fly was a prisoner of war. His aunt -detected the act and made him let it go. - -The minister gave out his text and droned along monotonously through -an argument that was so prosy that many a head by and by began to nod ---and yet it was an argument that dealt in limitless fire and brimstone -and thinned the predestined elect down to a company so small as to be -hardly worth the saving. Tom counted the pages of the sermon; after -church he always knew how many pages there had been, but he seldom knew -anything else about the discourse. However, this time he was really -interested for a little while. The minister made a grand and moving -picture of the assembling together of the world's hosts at the -millennium when the lion and the lamb should lie down together and a -little child should lead them. But the pathos, the lesson, the moral of -the great spectacle were lost upon the boy; he only thought of the -conspicuousness of the principal character before the on-looking -nations; his face lit with the thought, and he said to himself that he -wished he could be that child, if it was a tame lion. - -Now he lapsed into suffering again, as the dry argument was resumed. -Presently he bethought him of a treasure he had and got it out. It was -a large black beetle with formidable jaws--a "pinchbug," he called it. -It was in a percussion-cap box. The first thing the beetle did was to -take him by the finger. A natural fillip followed, the beetle went -floundering into the aisle and lit on its back, and the hurt finger -went into the boy's mouth. The beetle lay there working its helpless -legs, unable to turn over. Tom eyed it, and longed for it; but it was -safe out of his reach. Other people uninterested in the sermon found -relief in the beetle, and they eyed it too. Presently a vagrant poodle -dog came idling along, sad at heart, lazy with the summer softness and -the quiet, weary of captivity, sighing for change. He spied the beetle; -the drooping tail lifted and wagged. He surveyed the prize; walked -around it; smelt at it from a safe distance; walked around it again; -grew bolder, and took a closer smell; then lifted his lip and made a -gingerly snatch at it, just missing it; made another, and another; -began to enjoy the diversion; subsided to his stomach with the beetle -between his paws, and continued his experiments; grew weary at last, -and then indifferent and absent-minded. His head nodded, and little by -little his chin descended and touched the enemy, who seized it. There -was a sharp yelp, a flirt of the poodle's head, and the beetle fell a -couple of yards away, and lit on its back once more. The neighboring -spectators shook with a gentle inward joy, several faces went behind -fans and handkerchiefs, and Tom was entirely happy. The dog looked -foolish, and probably felt so; but there was resentment in his heart, -too, and a craving for revenge. So he went to the beetle and began a -wary attack on it again; jumping at it from every point of a circle, -lighting with his fore-paws within an inch of the creature, making even -closer snatches at it with his teeth, and jerking his head till his -ears flapped again. But he grew tired once more, after a while; tried -to amuse himself with a fly but found no relief; followed an ant -around, with his nose close to the floor, and quickly wearied of that; -yawned, sighed, forgot the beetle entirely, and sat down on it. Then -there was a wild yelp of agony and the poodle went sailing up the -aisle; the yelps continued, and so did the dog; he crossed the house in -front of the altar; he flew down the other aisle; he crossed before the -doors; he clamored up the home-stretch; his anguish grew with his -progress, till presently he was but a woolly comet moving in its orbit -with the gleam and the speed of light. At last the frantic sufferer -sheered from its course, and sprang into its master's lap; he flung it -out of the window, and the voice of distress quickly thinned away and -died in the distance. - -By this time the whole church was red-faced and suffocating with -suppressed laughter, and the sermon had come to a dead standstill. The -discourse was resumed presently, but it went lame and halting, all -possibility of impressiveness being at an end; for even the gravest -sentiments were constantly being received with a smothered burst of -unholy mirth, under cover of some remote pew-back, as if the poor -parson had said a rarely facetious thing. It was a genuine relief to -the whole congregation when the ordeal was over and the benediction -pronounced. - -Tom Sawyer went home quite cheerful, thinking to himself that there -was some satisfaction about divine service when there was a bit of -variety in it. He had but one marring thought; he was willing that the -dog should play with his pinchbug, but he did not think it was upright -in him to carry it off. - - - -CHAPTER VI - -MONDAY morning found Tom Sawyer miserable. Monday morning always found -him so--because it began another week's slow suffering in school. He -generally began that day with wishing he had had no intervening -holiday, it made the going into captivity and fetters again so much -more odious. - -Tom lay thinking. Presently it occurred to him that he wished he was -sick; then he could stay home from school. Here was a vague -possibility. He canvassed his system. No ailment was found, and he -investigated again. This time he thought he could detect colicky -symptoms, and he began to encourage them with considerable hope. But -they soon grew feeble, and presently died wholly away. He reflected -further. Suddenly he discovered something. One of his upper front teeth -was loose. This was lucky; he was about to begin to groan, as a -"starter," as he called it, when it occurred to him that if he came -into court with that argument, his aunt would pull it out, and that -would hurt. So he thought he would hold the tooth in reserve for the -present, and seek further. Nothing offered for some little time, and -then he remembered hearing the doctor tell about a certain thing that -laid up a patient for two or three weeks and threatened to make him -lose a finger. So the boy eagerly drew his sore toe from under the -sheet and held it up for inspection. But now he did not know the -necessary symptoms. However, it seemed well worth while to chance it, -so he fell to groaning with considerable spirit. - -But Sid slept on unconscious. - -Tom groaned louder, and fancied that he began to feel pain in the toe. - -No result from Sid. - -Tom was panting with his exertions by this time. He took a rest and -then swelled himself up and fetched a succession of admirable groans. - -Sid snored on. - -Tom was aggravated. He said, "Sid, Sid!" and shook him. This course -worked well, and Tom began to groan again. Sid yawned, stretched, then -brought himself up on his elbow with a snort, and began to stare at -Tom. Tom went on groaning. Sid said: - -"Tom! Say, Tom!" [No response.] "Here, Tom! TOM! What is the matter, -Tom?" And he shook him and looked in his face anxiously. - -Tom moaned out: - -"Oh, don't, Sid. Don't joggle me." - -"Why, what's the matter, Tom? I must call auntie." - -"No--never mind. It'll be over by and by, maybe. Don't call anybody." - -"But I must! DON'T groan so, Tom, it's awful. How long you been this -way?" - -"Hours. Ouch! Oh, don't stir so, Sid, you'll kill me." - -"Tom, why didn't you wake me sooner? Oh, Tom, DON'T! It makes my -flesh crawl to hear you. Tom, what is the matter?" - -"I forgive you everything, Sid. [Groan.] Everything you've ever done -to me. When I'm gone--" - -"Oh, Tom, you ain't dying, are you? Don't, Tom--oh, don't. Maybe--" - -"I forgive everybody, Sid. [Groan.] Tell 'em so, Sid. And Sid, you -give my window-sash and my cat with one eye to that new girl that's -come to town, and tell her--" - -But Sid had snatched his clothes and gone. Tom was suffering in -reality, now, so handsomely was his imagination working, and so his -groans had gathered quite a genuine tone. - -Sid flew down-stairs and said: - -"Oh, Aunt Polly, come! Tom's dying!" - -"Dying!" - -"Yes'm. Don't wait--come quick!" - -"Rubbage! I don't believe it!" - -But she fled up-stairs, nevertheless, with Sid and Mary at her heels. -And her face grew white, too, and her lip trembled. When she reached -the bedside she gasped out: - -"You, Tom! Tom, what's the matter with you?" - -"Oh, auntie, I'm--" - -"What's the matter with you--what is the matter with you, child?" - -"Oh, auntie, my sore toe's mortified!" - -The old lady sank down into a chair and laughed a little, then cried a -little, then did both together. This restored her and she said: - -"Tom, what a turn you did give me. Now you shut up that nonsense and -climb out of this." - -The groans ceased and the pain vanished from the toe. The boy felt a -little foolish, and he said: - -"Aunt Polly, it SEEMED mortified, and it hurt so I never minded my -tooth at all." - -"Your tooth, indeed! What's the matter with your tooth?" - -"One of them's loose, and it aches perfectly awful." - -"There, there, now, don't begin that groaning again. Open your mouth. -Well--your tooth IS loose, but you're not going to die about that. -Mary, get me a silk thread, and a chunk of fire out of the kitchen." - -Tom said: - -"Oh, please, auntie, don't pull it out. It don't hurt any more. I wish -I may never stir if it does. Please don't, auntie. I don't want to stay -home from school." - -"Oh, you don't, don't you? So all this row was because you thought -you'd get to stay home from school and go a-fishing? Tom, Tom, I love -you so, and you seem to try every way you can to break my old heart -with your outrageousness." By this time the dental instruments were -ready. The old lady made one end of the silk thread fast to Tom's tooth -with a loop and tied the other to the bedpost. Then she seized the -chunk of fire and suddenly thrust it almost into the boy's face. The -tooth hung dangling by the bedpost, now. - -But all trials bring their compensations. As Tom wended to school -after breakfast, he was the envy of every boy he met because the gap in -his upper row of teeth enabled him to expectorate in a new and -admirable way. He gathered quite a following of lads interested in the -exhibition; and one that had cut his finger and had been a centre of -fascination and homage up to this time, now found himself suddenly -without an adherent, and shorn of his glory. His heart was heavy, and -he said with a disdain which he did not feel that it wasn't anything to -spit like Tom Sawyer; but another boy said, "Sour grapes!" and he -wandered away a dismantled hero. - -Shortly Tom came upon the juvenile pariah of the village, Huckleberry -Finn, son of the town drunkard. Huckleberry was cordially hated and -dreaded by all the mothers of the town, because he was idle and lawless -and vulgar and bad--and because all their children admired him so, and -delighted in his forbidden society, and wished they dared to be like -him. Tom was like the rest of the respectable boys, in that he envied -Huckleberry his gaudy outcast condition, and was under strict orders -not to play with him. So he played with him every time he got a chance. -Huckleberry was always dressed in the cast-off clothes of full-grown -men, and they were in perennial bloom and fluttering with rags. His hat -was a vast ruin with a wide crescent lopped out of its brim; his coat, -when he wore one, hung nearly to his heels and had the rearward buttons -far down the back; but one suspender supported his trousers; the seat -of the trousers bagged low and contained nothing, the fringed legs -dragged in the dirt when not rolled up. - -Huckleberry came and went, at his own free will. He slept on doorsteps -in fine weather and in empty hogsheads in wet; he did not have to go to -school or to church, or call any being master or obey anybody; he could -go fishing or swimming when and where he chose, and stay as long as it -suited him; nobody forbade him to fight; he could sit up as late as he -pleased; he was always the first boy that went barefoot in the spring -and the last to resume leather in the fall; he never had to wash, nor -put on clean clothes; he could swear wonderfully. In a word, everything -that goes to make life precious that boy had. So thought every -harassed, hampered, respectable boy in St. Petersburg. - -Tom hailed the romantic outcast: - -"Hello, Huckleberry!" - -"Hello yourself, and see how you like it." - -"What's that you got?" - -"Dead cat." - -"Lemme see him, Huck. My, he's pretty stiff. Where'd you get him?" - -"Bought him off'n a boy." - -"What did you give?" - -"I give a blue ticket and a bladder that I got at the slaughter-house." - -"Where'd you get the blue ticket?" - -"Bought it off'n Ben Rogers two weeks ago for a hoop-stick." - -"Say--what is dead cats good for, Huck?" - -"Good for? Cure warts with." - -"No! Is that so? I know something that's better." - -"I bet you don't. What is it?" - -"Why, spunk-water." - -"Spunk-water! I wouldn't give a dern for spunk-water." - -"You wouldn't, wouldn't you? D'you ever try it?" - -"No, I hain't. But Bob Tanner did." - -"Who told you so!" - -"Why, he told Jeff Thatcher, and Jeff told Johnny Baker, and Johnny -told Jim Hollis, and Jim told Ben Rogers, and Ben told a nigger, and -the nigger told me. There now!" - -"Well, what of it? They'll all lie. Leastways all but the nigger. I -don't know HIM. But I never see a nigger that WOULDN'T lie. Shucks! Now -you tell me how Bob Tanner done it, Huck." - -"Why, he took and dipped his hand in a rotten stump where the -rain-water was." - -"In the daytime?" - -"Certainly." - -"With his face to the stump?" - -"Yes. Least I reckon so." - -"Did he say anything?" - -"I don't reckon he did. I don't know." - -"Aha! Talk about trying to cure warts with spunk-water such a blame -fool way as that! Why, that ain't a-going to do any good. You got to go -all by yourself, to the middle of the woods, where you know there's a -spunk-water stump, and just as it's midnight you back up against the -stump and jam your hand in and say: - - 'Barley-corn, barley-corn, injun-meal shorts, - Spunk-water, spunk-water, swaller these warts,' - -and then walk away quick, eleven steps, with your eyes shut, and then -turn around three times and walk home without speaking to anybody. -Because if you speak the charm's busted." - -"Well, that sounds like a good way; but that ain't the way Bob Tanner -done." - -"No, sir, you can bet he didn't, becuz he's the wartiest boy in this -town; and he wouldn't have a wart on him if he'd knowed how to work -spunk-water. I've took off thousands of warts off of my hands that way, -Huck. I play with frogs so much that I've always got considerable many -warts. Sometimes I take 'em off with a bean." - -"Yes, bean's good. I've done that." - -"Have you? What's your way?" - -"You take and split the bean, and cut the wart so as to get some -blood, and then you put the blood on one piece of the bean and take and -dig a hole and bury it 'bout midnight at the crossroads in the dark of -the moon, and then you burn up the rest of the bean. You see that piece -that's got the blood on it will keep drawing and drawing, trying to -fetch the other piece to it, and so that helps the blood to draw the -wart, and pretty soon off she comes." - -"Yes, that's it, Huck--that's it; though when you're burying it if you -say 'Down bean; off wart; come no more to bother me!' it's better. -That's the way Joe Harper does, and he's been nearly to Coonville and -most everywheres. But say--how do you cure 'em with dead cats?" - -"Why, you take your cat and go and get in the graveyard 'long about -midnight when somebody that was wicked has been buried; and when it's -midnight a devil will come, or maybe two or three, but you can't see -'em, you can only hear something like the wind, or maybe hear 'em talk; -and when they're taking that feller away, you heave your cat after 'em -and say, 'Devil follow corpse, cat follow devil, warts follow cat, I'm -done with ye!' That'll fetch ANY wart." - -"Sounds right. D'you ever try it, Huck?" - -"No, but old Mother Hopkins told me." - -"Well, I reckon it's so, then. Becuz they say she's a witch." - -"Say! Why, Tom, I KNOW she is. She witched pap. Pap says so his own -self. He come along one day, and he see she was a-witching him, so he -took up a rock, and if she hadn't dodged, he'd a got her. Well, that -very night he rolled off'n a shed wher' he was a layin drunk, and broke -his arm." - -"Why, that's awful. How did he know she was a-witching him?" - -"Lord, pap can tell, easy. Pap says when they keep looking at you -right stiddy, they're a-witching you. Specially if they mumble. Becuz -when they mumble they're saying the Lord's Prayer backards." - -"Say, Hucky, when you going to try the cat?" - -"To-night. I reckon they'll come after old Hoss Williams to-night." - -"But they buried him Saturday. Didn't they get him Saturday night?" - -"Why, how you talk! How could their charms work till midnight?--and -THEN it's Sunday. Devils don't slosh around much of a Sunday, I don't -reckon." - -"I never thought of that. That's so. Lemme go with you?" - -"Of course--if you ain't afeard." - -"Afeard! 'Tain't likely. Will you meow?" - -"Yes--and you meow back, if you get a chance. Last time, you kep' me -a-meowing around till old Hays went to throwing rocks at me and says -'Dern that cat!' and so I hove a brick through his window--but don't -you tell." - -"I won't. I couldn't meow that night, becuz auntie was watching me, -but I'll meow this time. Say--what's that?" - -"Nothing but a tick." - -"Where'd you get him?" - -"Out in the woods." - -"What'll you take for him?" - -"I don't know. I don't want to sell him." - -"All right. It's a mighty small tick, anyway." - -"Oh, anybody can run a tick down that don't belong to them. I'm -satisfied with it. It's a good enough tick for me." - -"Sho, there's ticks a plenty. I could have a thousand of 'em if I -wanted to." - -"Well, why don't you? Becuz you know mighty well you can't. This is a -pretty early tick, I reckon. It's the first one I've seen this year." - -"Say, Huck--I'll give you my tooth for him." - -"Less see it." - -Tom got out a bit of paper and carefully unrolled it. Huckleberry -viewed it wistfully. The temptation was very strong. At last he said: - -"Is it genuwyne?" - -Tom lifted his lip and showed the vacancy. - -"Well, all right," said Huckleberry, "it's a trade." - -Tom enclosed the tick in the percussion-cap box that had lately been -the pinchbug's prison, and the boys separated, each feeling wealthier -than before. - -When Tom reached the little isolated frame schoolhouse, he strode in -briskly, with the manner of one who had come with all honest speed. -He hung his hat on a peg and flung himself into his seat with -business-like alacrity. The master, throned on high in his great -splint-bottom arm-chair, was dozing, lulled by the drowsy hum of study. -The interruption roused him. - -"Thomas Sawyer!" - -Tom knew that when his name was pronounced in full, it meant trouble. - -"Sir!" - -"Come up here. Now, sir, why are you late again, as usual?" - -Tom was about to take refuge in a lie, when he saw two long tails of -yellow hair hanging down a back that he recognized by the electric -sympathy of love; and by that form was THE ONLY VACANT PLACE on the -girls' side of the schoolhouse. He instantly said: - -"I STOPPED TO TALK WITH HUCKLEBERRY FINN!" - -The master's pulse stood still, and he stared helplessly. The buzz of -study ceased. The pupils wondered if this foolhardy boy had lost his -mind. The master said: - -"You--you did what?" - -"Stopped to talk with Huckleberry Finn." - -There was no mistaking the words. - -"Thomas Sawyer, this is the most astounding confession I have ever -listened to. No mere ferule will answer for this offence. Take off your -jacket." - -The master's arm performed until it was tired and the stock of -switches notably diminished. Then the order followed: - -"Now, sir, go and sit with the girls! And let this be a warning to you." - -The titter that rippled around the room appeared to abash the boy, but -in reality that result was caused rather more by his worshipful awe of -his unknown idol and the dread pleasure that lay in his high good -fortune. He sat down upon the end of the pine bench and the girl -hitched herself away from him with a toss of her head. Nudges and winks -and whispers traversed the room, but Tom sat still, with his arms upon -the long, low desk before him, and seemed to study his book. - -By and by attention ceased from him, and the accustomed school murmur -rose upon the dull air once more. Presently the boy began to steal -furtive glances at the girl. She observed it, "made a mouth" at him and -gave him the back of her head for the space of a minute. When she -cautiously faced around again, a peach lay before her. She thrust it -away. Tom gently put it back. She thrust it away again, but with less -animosity. Tom patiently returned it to its place. Then she let it -remain. Tom scrawled on his slate, "Please take it--I got more." The -girl glanced at the words, but made no sign. Now the boy began to draw -something on the slate, hiding his work with his left hand. For a time -the girl refused to notice; but her human curiosity presently began to -manifest itself by hardly perceptible signs. The boy worked on, -apparently unconscious. The girl made a sort of noncommittal attempt to -see, but the boy did not betray that he was aware of it. At last she -gave in and hesitatingly whispered: - -"Let me see it." - -Tom partly uncovered a dismal caricature of a house with two gable -ends to it and a corkscrew of smoke issuing from the chimney. Then the -girl's interest began to fasten itself upon the work and she forgot -everything else. When it was finished, she gazed a moment, then -whispered: - -"It's nice--make a man." - -The artist erected a man in the front yard, that resembled a derrick. -He could have stepped over the house; but the girl was not -hypercritical; she was satisfied with the monster, and whispered: - -"It's a beautiful man--now make me coming along." - -Tom drew an hour-glass with a full moon and straw limbs to it and -armed the spreading fingers with a portentous fan. The girl said: - -"It's ever so nice--I wish I could draw." - -"It's easy," whispered Tom, "I'll learn you." - -"Oh, will you? When?" - -"At noon. Do you go home to dinner?" - -"I'll stay if you will." - -"Good--that's a whack. What's your name?" - -"Becky Thatcher. What's yours? Oh, I know. It's Thomas Sawyer." - -"That's the name they lick me by. I'm Tom when I'm good. You call me -Tom, will you?" - -"Yes." - -Now Tom began to scrawl something on the slate, hiding the words from -the girl. But she was not backward this time. She begged to see. Tom -said: - -"Oh, it ain't anything." - -"Yes it is." - -"No it ain't. You don't want to see." - -"Yes I do, indeed I do. Please let me." - -"You'll tell." - -"No I won't--deed and deed and double deed won't." - -"You won't tell anybody at all? Ever, as long as you live?" - -"No, I won't ever tell ANYbody. Now let me." - -"Oh, YOU don't want to see!" - -"Now that you treat me so, I WILL see." And she put her small hand -upon his and a little scuffle ensued, Tom pretending to resist in -earnest but letting his hand slip by degrees till these words were -revealed: "I LOVE YOU." - -"Oh, you bad thing!" And she hit his hand a smart rap, but reddened -and looked pleased, nevertheless. - -Just at this juncture the boy felt a slow, fateful grip closing on his -ear, and a steady lifting impulse. In that wise he was borne across the -house and deposited in his own seat, under a peppering fire of giggles -from the whole school. Then the master stood over him during a few -awful moments, and finally moved away to his throne without saying a -word. But although Tom's ear tingled, his heart was jubilant. - -As the school quieted down Tom made an honest effort to study, but the -turmoil within him was too great. In turn he took his place in the -reading class and made a botch of it; then in the geography class and -turned lakes into mountains, mountains into rivers, and rivers into -continents, till chaos was come again; then in the spelling class, and -got "turned down," by a succession of mere baby words, till he brought -up at the foot and yielded up the pewter medal which he had worn with -ostentation for months. - - - -CHAPTER VII - -THE harder Tom tried to fasten his mind on his book, the more his -ideas wandered. So at last, with a sigh and a yawn, he gave it up. It -seemed to him that the noon recess would never come. The air was -utterly dead. There was not a breath stirring. It was the sleepiest of -sleepy days. The drowsing murmur of the five and twenty studying -scholars soothed the soul like the spell that is in the murmur of bees. -Away off in the flaming sunshine, Cardiff Hill lifted its soft green -sides through a shimmering veil of heat, tinted with the purple of -distance; a few birds floated on lazy wing high in the air; no other -living thing was visible but some cows, and they were asleep. Tom's -heart ached to be free, or else to have something of interest to do to -pass the dreary time. His hand wandered into his pocket and his face -lit up with a glow of gratitude that was prayer, though he did not know -it. Then furtively the percussion-cap box came out. He released the -tick and put him on the long flat desk. The creature probably glowed -with a gratitude that amounted to prayer, too, at this moment, but it -was premature: for when he started thankfully to travel off, Tom turned -him aside with a pin and made him take a new direction. - -Tom's bosom friend sat next him, suffering just as Tom had been, and -now he was deeply and gratefully interested in this entertainment in an -instant. This bosom friend was Joe Harper. The two boys were sworn -friends all the week, and embattled enemies on Saturdays. Joe took a -pin out of his lapel and began to assist in exercising the prisoner. -The sport grew in interest momently. Soon Tom said that they were -interfering with each other, and neither getting the fullest benefit of -the tick. So he put Joe's slate on the desk and drew a line down the -middle of it from top to bottom. - -"Now," said he, "as long as he is on your side you can stir him up and -I'll let him alone; but if you let him get away and get on my side, -you're to leave him alone as long as I can keep him from crossing over." - -"All right, go ahead; start him up." - -The tick escaped from Tom, presently, and crossed the equator. Joe -harassed him awhile, and then he got away and crossed back again. This -change of base occurred often. While one boy was worrying the tick with -absorbing interest, the other would look on with interest as strong, -the two heads bowed together over the slate, and the two souls dead to -all things else. At last luck seemed to settle and abide with Joe. The -tick tried this, that, and the other course, and got as excited and as -anxious as the boys themselves, but time and again just as he would -have victory in his very grasp, so to speak, and Tom's fingers would be -twitching to begin, Joe's pin would deftly head him off, and keep -possession. At last Tom could stand it no longer. The temptation was -too strong. So he reached out and lent a hand with his pin. Joe was -angry in a moment. Said he: - -"Tom, you let him alone." - -"I only just want to stir him up a little, Joe." - -"No, sir, it ain't fair; you just let him alone." - -"Blame it, I ain't going to stir him much." - -"Let him alone, I tell you." - -"I won't!" - -"You shall--he's on my side of the line." - -"Look here, Joe Harper, whose is that tick?" - -"I don't care whose tick he is--he's on my side of the line, and you -sha'n't touch him." - -"Well, I'll just bet I will, though. He's my tick and I'll do what I -blame please with him, or die!" - -A tremendous whack came down on Tom's shoulders, and its duplicate on -Joe's; and for the space of two minutes the dust continued to fly from -the two jackets and the whole school to enjoy it. The boys had been too -absorbed to notice the hush that had stolen upon the school awhile -before when the master came tiptoeing down the room and stood over -them. He had contemplated a good part of the performance before he -contributed his bit of variety to it. - -When school broke up at noon, Tom flew to Becky Thatcher, and -whispered in her ear: - -"Put on your bonnet and let on you're going home; and when you get to -the corner, give the rest of 'em the slip, and turn down through the -lane and come back. I'll go the other way and come it over 'em the same -way." - -So the one went off with one group of scholars, and the other with -another. In a little while the two met at the bottom of the lane, and -when they reached the school they had it all to themselves. Then they -sat together, with a slate before them, and Tom gave Becky the pencil -and held her hand in his, guiding it, and so created another surprising -house. When the interest in art began to wane, the two fell to talking. -Tom was swimming in bliss. He said: - -"Do you love rats?" - -"No! I hate them!" - -"Well, I do, too--LIVE ones. But I mean dead ones, to swing round your -head with a string." - -"No, I don't care for rats much, anyway. What I like is chewing-gum." - -"Oh, I should say so! I wish I had some now." - -"Do you? I've got some. I'll let you chew it awhile, but you must give -it back to me." - -That was agreeable, so they chewed it turn about, and dangled their -legs against the bench in excess of contentment. - -"Was you ever at a circus?" said Tom. - -"Yes, and my pa's going to take me again some time, if I'm good." - -"I been to the circus three or four times--lots of times. Church ain't -shucks to a circus. There's things going on at a circus all the time. -I'm going to be a clown in a circus when I grow up." - -"Oh, are you! That will be nice. They're so lovely, all spotted up." - -"Yes, that's so. And they get slathers of money--most a dollar a day, -Ben Rogers says. Say, Becky, was you ever engaged?" - -"What's that?" - -"Why, engaged to be married." - -"No." - -"Would you like to?" - -"I reckon so. I don't know. What is it like?" - -"Like? Why it ain't like anything. You only just tell a boy you won't -ever have anybody but him, ever ever ever, and then you kiss and that's -all. Anybody can do it." - -"Kiss? What do you kiss for?" - -"Why, that, you know, is to--well, they always do that." - -"Everybody?" - -"Why, yes, everybody that's in love with each other. Do you remember -what I wrote on the slate?" - -"Ye--yes." - -"What was it?" - -"I sha'n't tell you." - -"Shall I tell YOU?" - -"Ye--yes--but some other time." - -"No, now." - -"No, not now--to-morrow." - -"Oh, no, NOW. Please, Becky--I'll whisper it, I'll whisper it ever so -easy." - -Becky hesitating, Tom took silence for consent, and passed his arm -about her waist and whispered the tale ever so softly, with his mouth -close to her ear. And then he added: - -"Now you whisper it to me--just the same." - -She resisted, for a while, and then said: - -"You turn your face away so you can't see, and then I will. But you -mustn't ever tell anybody--WILL you, Tom? Now you won't, WILL you?" - -"No, indeed, indeed I won't. Now, Becky." - -He turned his face away. She bent timidly around till her breath -stirred his curls and whispered, "I--love--you!" - -Then she sprang away and ran around and around the desks and benches, -with Tom after her, and took refuge in a corner at last, with her -little white apron to her face. Tom clasped her about her neck and -pleaded: - -"Now, Becky, it's all done--all over but the kiss. Don't you be afraid -of that--it ain't anything at all. Please, Becky." And he tugged at her -apron and the hands. - -By and by she gave up, and let her hands drop; her face, all glowing -with the struggle, came up and submitted. Tom kissed the red lips and -said: - -"Now it's all done, Becky. And always after this, you know, you ain't -ever to love anybody but me, and you ain't ever to marry anybody but -me, ever never and forever. Will you?" - -"No, I'll never love anybody but you, Tom, and I'll never marry -anybody but you--and you ain't to ever marry anybody but me, either." - -"Certainly. Of course. That's PART of it. And always coming to school -or when we're going home, you're to walk with me, when there ain't -anybody looking--and you choose me and I choose you at parties, because -that's the way you do when you're engaged." - -"It's so nice. I never heard of it before." - -"Oh, it's ever so gay! Why, me and Amy Lawrence--" - -The big eyes told Tom his blunder and he stopped, confused. - -"Oh, Tom! Then I ain't the first you've ever been engaged to!" - -The child began to cry. Tom said: - -"Oh, don't cry, Becky, I don't care for her any more." - -"Yes, you do, Tom--you know you do." - -Tom tried to put his arm about her neck, but she pushed him away and -turned her face to the wall, and went on crying. Tom tried again, with -soothing words in his mouth, and was repulsed again. Then his pride was -up, and he strode away and went outside. He stood about, restless and -uneasy, for a while, glancing at the door, every now and then, hoping -she would repent and come to find him. But she did not. Then he began -to feel badly and fear that he was in the wrong. It was a hard struggle -with him to make new advances, now, but he nerved himself to it and -entered. She was still standing back there in the corner, sobbing, with -her face to the wall. Tom's heart smote him. He went to her and stood a -moment, not knowing exactly how to proceed. Then he said hesitatingly: - -"Becky, I--I don't care for anybody but you." - -No reply--but sobs. - -"Becky"--pleadingly. "Becky, won't you say something?" - -More sobs. - -Tom got out his chiefest jewel, a brass knob from the top of an -andiron, and passed it around her so that she could see it, and said: - -"Please, Becky, won't you take it?" - -She struck it to the floor. Then Tom marched out of the house and over -the hills and far away, to return to school no more that day. Presently -Becky began to suspect. She ran to the door; he was not in sight; she -flew around to the play-yard; he was not there. Then she called: - -"Tom! Come back, Tom!" - -She listened intently, but there was no answer. She had no companions -but silence and loneliness. So she sat down to cry again and upbraid -herself; and by this time the scholars began to gather again, and she -had to hide her griefs and still her broken heart and take up the cross -of a long, dreary, aching afternoon, with none among the strangers -about her to exchange sorrows with. - - - -CHAPTER VIII - -TOM dodged hither and thither through lanes until he was well out of -the track of returning scholars, and then fell into a moody jog. He -crossed a small "branch" two or three times, because of a prevailing -juvenile superstition that to cross water baffled pursuit. Half an hour -later he was disappearing behind the Douglas mansion on the summit of -Cardiff Hill, and the schoolhouse was hardly distinguishable away off -in the valley behind him. He entered a dense wood, picked his pathless -way to the centre of it, and sat down on a mossy spot under a spreading -oak. There was not even a zephyr stirring; the dead noonday heat had -even stilled the songs of the birds; nature lay in a trance that was -broken by no sound but the occasional far-off hammering of a -woodpecker, and this seemed to render the pervading silence and sense -of loneliness the more profound. The boy's soul was steeped in -melancholy; his feelings were in happy accord with his surroundings. He -sat long with his elbows on his knees and his chin in his hands, -meditating. It seemed to him that life was but a trouble, at best, and -he more than half envied Jimmy Hodges, so lately released; it must be -very peaceful, he thought, to lie and slumber and dream forever and -ever, with the wind whispering through the trees and caressing the -grass and the flowers over the grave, and nothing to bother and grieve -about, ever any more. If he only had a clean Sunday-school record he -could be willing to go, and be done with it all. Now as to this girl. -What had he done? Nothing. He had meant the best in the world, and been -treated like a dog--like a very dog. She would be sorry some day--maybe -when it was too late. Ah, if he could only die TEMPORARILY! - -But the elastic heart of youth cannot be compressed into one -constrained shape long at a time. Tom presently began to drift -insensibly back into the concerns of this life again. What if he turned -his back, now, and disappeared mysteriously? What if he went away--ever -so far away, into unknown countries beyond the seas--and never came -back any more! How would she feel then! The idea of being a clown -recurred to him now, only to fill him with disgust. For frivolity and -jokes and spotted tights were an offense, when they intruded themselves -upon a spirit that was exalted into the vague august realm of the -romantic. No, he would be a soldier, and return after long years, all -war-worn and illustrious. No--better still, he would join the Indians, -and hunt buffaloes and go on the warpath in the mountain ranges and the -trackless great plains of the Far West, and away in the future come -back a great chief, bristling with feathers, hideous with paint, and -prance into Sunday-school, some drowsy summer morning, with a -bloodcurdling war-whoop, and sear the eyeballs of all his companions -with unappeasable envy. But no, there was something gaudier even than -this. He would be a pirate! That was it! NOW his future lay plain -before him, and glowing with unimaginable splendor. How his name would -fill the world, and make people shudder! How gloriously he would go -plowing the dancing seas, in his long, low, black-hulled racer, the -Spirit of the Storm, with his grisly flag flying at the fore! And at -the zenith of his fame, how he would suddenly appear at the old village -and stalk into church, brown and weather-beaten, in his black velvet -doublet and trunks, his great jack-boots, his crimson sash, his belt -bristling with horse-pistols, his crime-rusted cutlass at his side, his -slouch hat with waving plumes, his black flag unfurled, with the skull -and crossbones on it, and hear with swelling ecstasy the whisperings, -"It's Tom Sawyer the Pirate!--the Black Avenger of the Spanish Main!" - -Yes, it was settled; his career was determined. He would run away from -home and enter upon it. He would start the very next morning. Therefore -he must now begin to get ready. He would collect his resources -together. He went to a rotten log near at hand and began to dig under -one end of it with his Barlow knife. He soon struck wood that sounded -hollow. He put his hand there and uttered this incantation impressively: - -"What hasn't come here, come! What's here, stay here!" - -Then he scraped away the dirt, and exposed a pine shingle. He took it -up and disclosed a shapely little treasure-house whose bottom and sides -were of shingles. In it lay a marble. Tom's astonishment was boundless! -He scratched his head with a perplexed air, and said: - -"Well, that beats anything!" - -Then he tossed the marble away pettishly, and stood cogitating. The -truth was, that a superstition of his had failed, here, which he and -all his comrades had always looked upon as infallible. If you buried a -marble with certain necessary incantations, and left it alone a -fortnight, and then opened the place with the incantation he had just -used, you would find that all the marbles you had ever lost had -gathered themselves together there, meantime, no matter how widely they -had been separated. But now, this thing had actually and unquestionably -failed. Tom's whole structure of faith was shaken to its foundations. -He had many a time heard of this thing succeeding but never of its -failing before. It did not occur to him that he had tried it several -times before, himself, but could never find the hiding-places -afterward. He puzzled over the matter some time, and finally decided -that some witch had interfered and broken the charm. He thought he -would satisfy himself on that point; so he searched around till he -found a small sandy spot with a little funnel-shaped depression in it. -He laid himself down and put his mouth close to this depression and -called-- - -"Doodle-bug, doodle-bug, tell me what I want to know! Doodle-bug, -doodle-bug, tell me what I want to know!" - -The sand began to work, and presently a small black bug appeared for a -second and then darted under again in a fright. - -"He dasn't tell! So it WAS a witch that done it. I just knowed it." - -He well knew the futility of trying to contend against witches, so he -gave up discouraged. But it occurred to him that he might as well have -the marble he had just thrown away, and therefore he went and made a -patient search for it. But he could not find it. Now he went back to -his treasure-house and carefully placed himself just as he had been -standing when he tossed the marble away; then he took another marble -from his pocket and tossed it in the same way, saying: - -"Brother, go find your brother!" - -He watched where it stopped, and went there and looked. But it must -have fallen short or gone too far; so he tried twice more. The last -repetition was successful. The two marbles lay within a foot of each -other. - -Just here the blast of a toy tin trumpet came faintly down the green -aisles of the forest. Tom flung off his jacket and trousers, turned a -suspender into a belt, raked away some brush behind the rotten log, -disclosing a rude bow and arrow, a lath sword and a tin trumpet, and in -a moment had seized these things and bounded away, barelegged, with -fluttering shirt. He presently halted under a great elm, blew an -answering blast, and then began to tiptoe and look warily out, this way -and that. He said cautiously--to an imaginary company: - -"Hold, my merry men! Keep hid till I blow." - -Now appeared Joe Harper, as airily clad and elaborately armed as Tom. -Tom called: - -"Hold! Who comes here into Sherwood Forest without my pass?" - -"Guy of Guisborne wants no man's pass. Who art thou that--that--" - -"Dares to hold such language," said Tom, prompting--for they talked -"by the book," from memory. - -"Who art thou that dares to hold such language?" - -"I, indeed! I am Robin Hood, as thy caitiff carcase soon shall know." - -"Then art thou indeed that famous outlaw? Right gladly will I dispute -with thee the passes of the merry wood. Have at thee!" - -They took their lath swords, dumped their other traps on the ground, -struck a fencing attitude, foot to foot, and began a grave, careful -combat, "two up and two down." Presently Tom said: - -"Now, if you've got the hang, go it lively!" - -So they "went it lively," panting and perspiring with the work. By and -by Tom shouted: - -"Fall! fall! Why don't you fall?" - -"I sha'n't! Why don't you fall yourself? You're getting the worst of -it." - -"Why, that ain't anything. I can't fall; that ain't the way it is in -the book. The book says, 'Then with one back-handed stroke he slew poor -Guy of Guisborne.' You're to turn around and let me hit you in the -back." - -There was no getting around the authorities, so Joe turned, received -the whack and fell. - -"Now," said Joe, getting up, "you got to let me kill YOU. That's fair." - -"Why, I can't do that, it ain't in the book." - -"Well, it's blamed mean--that's all." - -"Well, say, Joe, you can be Friar Tuck or Much the miller's son, and -lam me with a quarter-staff; or I'll be the Sheriff of Nottingham and -you be Robin Hood a little while and kill me." - -This was satisfactory, and so these adventures were carried out. Then -Tom became Robin Hood again, and was allowed by the treacherous nun to -bleed his strength away through his neglected wound. And at last Joe, -representing a whole tribe of weeping outlaws, dragged him sadly forth, -gave his bow into his feeble hands, and Tom said, "Where this arrow -falls, there bury poor Robin Hood under the greenwood tree." Then he -shot the arrow and fell back and would have died, but he lit on a -nettle and sprang up too gaily for a corpse. - -The boys dressed themselves, hid their accoutrements, and went off -grieving that there were no outlaws any more, and wondering what modern -civilization could claim to have done to compensate for their loss. -They said they would rather be outlaws a year in Sherwood Forest than -President of the United States forever. - - - -CHAPTER IX - -AT half-past nine, that night, Tom and Sid were sent to bed, as usual. -They said their prayers, and Sid was soon asleep. Tom lay awake and -waited, in restless impatience. When it seemed to him that it must be -nearly daylight, he heard the clock strike ten! This was despair. He -would have tossed and fidgeted, as his nerves demanded, but he was -afraid he might wake Sid. So he lay still, and stared up into the dark. -Everything was dismally still. By and by, out of the stillness, little, -scarcely perceptible noises began to emphasize themselves. The ticking -of the clock began to bring itself into notice. Old beams began to -crack mysteriously. The stairs creaked faintly. Evidently spirits were -abroad. A measured, muffled snore issued from Aunt Polly's chamber. And -now the tiresome chirping of a cricket that no human ingenuity could -locate, began. Next the ghastly ticking of a deathwatch in the wall at -the bed's head made Tom shudder--it meant that somebody's days were -numbered. Then the howl of a far-off dog rose on the night air, and was -answered by a fainter howl from a remoter distance. Tom was in an -agony. At last he was satisfied that time had ceased and eternity -begun; he began to doze, in spite of himself; the clock chimed eleven, -but he did not hear it. And then there came, mingling with his -half-formed dreams, a most melancholy caterwauling. The raising of a -neighboring window disturbed him. A cry of "Scat! you devil!" and the -crash of an empty bottle against the back of his aunt's woodshed -brought him wide awake, and a single minute later he was dressed and -out of the window and creeping along the roof of the "ell" on all -fours. He "meow'd" with caution once or twice, as he went; then jumped -to the roof of the woodshed and thence to the ground. Huckleberry Finn -was there, with his dead cat. The boys moved off and disappeared in the -gloom. At the end of half an hour they were wading through the tall -grass of the graveyard. - -It was a graveyard of the old-fashioned Western kind. It was on a -hill, about a mile and a half from the village. It had a crazy board -fence around it, which leaned inward in places, and outward the rest of -the time, but stood upright nowhere. Grass and weeds grew rank over the -whole cemetery. All the old graves were sunken in, there was not a -tombstone on the place; round-topped, worm-eaten boards staggered over -the graves, leaning for support and finding none. "Sacred to the memory -of" So-and-So had been painted on them once, but it could no longer -have been read, on the most of them, now, even if there had been light. - -A faint wind moaned through the trees, and Tom feared it might be the -spirits of the dead, complaining at being disturbed. The boys talked -little, and only under their breath, for the time and the place and the -pervading solemnity and silence oppressed their spirits. They found the -sharp new heap they were seeking, and ensconced themselves within the -protection of three great elms that grew in a bunch within a few feet -of the grave. - -Then they waited in silence for what seemed a long time. The hooting -of a distant owl was all the sound that troubled the dead stillness. -Tom's reflections grew oppressive. He must force some talk. So he said -in a whisper: - -"Hucky, do you believe the dead people like it for us to be here?" - -Huckleberry whispered: - -"I wisht I knowed. It's awful solemn like, AIN'T it?" - -"I bet it is." - -There was a considerable pause, while the boys canvassed this matter -inwardly. Then Tom whispered: - -"Say, Hucky--do you reckon Hoss Williams hears us talking?" - -"O' course he does. Least his sperrit does." - -Tom, after a pause: - -"I wish I'd said Mister Williams. But I never meant any harm. -Everybody calls him Hoss." - -"A body can't be too partic'lar how they talk 'bout these-yer dead -people, Tom." - -This was a damper, and conversation died again. - -Presently Tom seized his comrade's arm and said: - -"Sh!" - -"What is it, Tom?" And the two clung together with beating hearts. - -"Sh! There 'tis again! Didn't you hear it?" - -"I--" - -"There! Now you hear it." - -"Lord, Tom, they're coming! They're coming, sure. What'll we do?" - -"I dono. Think they'll see us?" - -"Oh, Tom, they can see in the dark, same as cats. I wisht I hadn't -come." - -"Oh, don't be afeard. I don't believe they'll bother us. We ain't -doing any harm. If we keep perfectly still, maybe they won't notice us -at all." - -"I'll try to, Tom, but, Lord, I'm all of a shiver." - -"Listen!" - -The boys bent their heads together and scarcely breathed. A muffled -sound of voices floated up from the far end of the graveyard. - -"Look! See there!" whispered Tom. "What is it?" - -"It's devil-fire. Oh, Tom, this is awful." - -Some vague figures approached through the gloom, swinging an -old-fashioned tin lantern that freckled the ground with innumerable -little spangles of light. Presently Huckleberry whispered with a -shudder: - -"It's the devils sure enough. Three of 'em! Lordy, Tom, we're goners! -Can you pray?" - -"I'll try, but don't you be afeard. They ain't going to hurt us. 'Now -I lay me down to sleep, I--'" - -"Sh!" - -"What is it, Huck?" - -"They're HUMANS! One of 'em is, anyway. One of 'em's old Muff Potter's -voice." - -"No--'tain't so, is it?" - -"I bet I know it. Don't you stir nor budge. He ain't sharp enough to -notice us. Drunk, the same as usual, likely--blamed old rip!" - -"All right, I'll keep still. Now they're stuck. Can't find it. Here -they come again. Now they're hot. Cold again. Hot again. Red hot! -They're p'inted right, this time. Say, Huck, I know another o' them -voices; it's Injun Joe." - -"That's so--that murderin' half-breed! I'd druther they was devils a -dern sight. What kin they be up to?" - -The whisper died wholly out, now, for the three men had reached the -grave and stood within a few feet of the boys' hiding-place. - -"Here it is," said the third voice; and the owner of it held the -lantern up and revealed the face of young Doctor Robinson. - -Potter and Injun Joe were carrying a handbarrow with a rope and a -couple of shovels on it. They cast down their load and began to open -the grave. The doctor put the lantern at the head of the grave and came -and sat down with his back against one of the elm trees. He was so -close the boys could have touched him. - -"Hurry, men!" he said, in a low voice; "the moon might come out at any -moment." - -They growled a response and went on digging. For some time there was -no noise but the grating sound of the spades discharging their freight -of mould and gravel. It was very monotonous. Finally a spade struck -upon the coffin with a dull woody accent, and within another minute or -two the men had hoisted it out on the ground. They pried off the lid -with their shovels, got out the body and dumped it rudely on the -ground. The moon drifted from behind the clouds and exposed the pallid -face. The barrow was got ready and the corpse placed on it, covered -with a blanket, and bound to its place with the rope. Potter took out a -large spring-knife and cut off the dangling end of the rope and then -said: - -"Now the cussed thing's ready, Sawbones, and you'll just out with -another five, or here she stays." - -"That's the talk!" said Injun Joe. - -"Look here, what does this mean?" said the doctor. "You required your -pay in advance, and I've paid you." - -"Yes, and you done more than that," said Injun Joe, approaching the -doctor, who was now standing. "Five years ago you drove me away from -your father's kitchen one night, when I come to ask for something to -eat, and you said I warn't there for any good; and when I swore I'd get -even with you if it took a hundred years, your father had me jailed for -a vagrant. Did you think I'd forget? The Injun blood ain't in me for -nothing. And now I've GOT you, and you got to SETTLE, you know!" - -He was threatening the doctor, with his fist in his face, by this -time. The doctor struck out suddenly and stretched the ruffian on the -ground. Potter dropped his knife, and exclaimed: - -"Here, now, don't you hit my pard!" and the next moment he had -grappled with the doctor and the two were struggling with might and -main, trampling the grass and tearing the ground with their heels. -Injun Joe sprang to his feet, his eyes flaming with passion, snatched -up Potter's knife, and went creeping, catlike and stooping, round and -round about the combatants, seeking an opportunity. All at once the -doctor flung himself free, seized the heavy headboard of Williams' -grave and felled Potter to the earth with it--and in the same instant -the half-breed saw his chance and drove the knife to the hilt in the -young man's breast. He reeled and fell partly upon Potter, flooding him -with his blood, and in the same moment the clouds blotted out the -dreadful spectacle and the two frightened boys went speeding away in -the dark. - -Presently, when the moon emerged again, Injun Joe was standing over -the two forms, contemplating them. The doctor murmured inarticulately, -gave a long gasp or two and was still. The half-breed muttered: - -"THAT score is settled--damn you." - -Then he robbed the body. After which he put the fatal knife in -Potter's open right hand, and sat down on the dismantled coffin. Three ---four--five minutes passed, and then Potter began to stir and moan. His -hand closed upon the knife; he raised it, glanced at it, and let it -fall, with a shudder. Then he sat up, pushing the body from him, and -gazed at it, and then around him, confusedly. His eyes met Joe's. - -"Lord, how is this, Joe?" he said. - -"It's a dirty business," said Joe, without moving. - -"What did you do it for?" - -"I! I never done it!" - -"Look here! That kind of talk won't wash." - -Potter trembled and grew white. - -"I thought I'd got sober. I'd no business to drink to-night. But it's -in my head yet--worse'n when we started here. I'm all in a muddle; -can't recollect anything of it, hardly. Tell me, Joe--HONEST, now, old -feller--did I do it? Joe, I never meant to--'pon my soul and honor, I -never meant to, Joe. Tell me how it was, Joe. Oh, it's awful--and him -so young and promising." - -"Why, you two was scuffling, and he fetched you one with the headboard -and you fell flat; and then up you come, all reeling and staggering -like, and snatched the knife and jammed it into him, just as he fetched -you another awful clip--and here you've laid, as dead as a wedge til -now." - -"Oh, I didn't know what I was a-doing. I wish I may die this minute if -I did. It was all on account of the whiskey and the excitement, I -reckon. I never used a weepon in my life before, Joe. I've fought, but -never with weepons. They'll all say that. Joe, don't tell! Say you -won't tell, Joe--that's a good feller. I always liked you, Joe, and -stood up for you, too. Don't you remember? You WON'T tell, WILL you, -Joe?" And the poor creature dropped on his knees before the stolid -murderer, and clasped his appealing hands. - -"No, you've always been fair and square with me, Muff Potter, and I -won't go back on you. There, now, that's as fair as a man can say." - -"Oh, Joe, you're an angel. I'll bless you for this the longest day I -live." And Potter began to cry. - -"Come, now, that's enough of that. This ain't any time for blubbering. -You be off yonder way and I'll go this. Move, now, and don't leave any -tracks behind you." - -Potter started on a trot that quickly increased to a run. The -half-breed stood looking after him. He muttered: - -"If he's as much stunned with the lick and fuddled with the rum as he -had the look of being, he won't think of the knife till he's gone so -far he'll be afraid to come back after it to such a place by himself ---chicken-heart!" - -Two or three minutes later the murdered man, the blanketed corpse, the -lidless coffin, and the open grave were under no inspection but the -moon's. The stillness was complete again, too. - - - -CHAPTER X - -THE two boys flew on and on, toward the village, speechless with -horror. They glanced backward over their shoulders from time to time, -apprehensively, as if they feared they might be followed. Every stump -that started up in their path seemed a man and an enemy, and made them -catch their breath; and as they sped by some outlying cottages that lay -near the village, the barking of the aroused watch-dogs seemed to give -wings to their feet. - -"If we can only get to the old tannery before we break down!" -whispered Tom, in short catches between breaths. "I can't stand it much -longer." - -Huckleberry's hard pantings were his only reply, and the boys fixed -their eyes on the goal of their hopes and bent to their work to win it. -They gained steadily on it, and at last, breast to breast, they burst -through the open door and fell grateful and exhausted in the sheltering -shadows beyond. By and by their pulses slowed down, and Tom whispered: - -"Huckleberry, what do you reckon'll come of this?" - -"If Doctor Robinson dies, I reckon hanging'll come of it." - -"Do you though?" - -"Why, I KNOW it, Tom." - -Tom thought a while, then he said: - -"Who'll tell? We?" - -"What are you talking about? S'pose something happened and Injun Joe -DIDN'T hang? Why, he'd kill us some time or other, just as dead sure as -we're a laying here." - -"That's just what I was thinking to myself, Huck." - -"If anybody tells, let Muff Potter do it, if he's fool enough. He's -generally drunk enough." - -Tom said nothing--went on thinking. Presently he whispered: - -"Huck, Muff Potter don't know it. How can he tell?" - -"What's the reason he don't know it?" - -"Because he'd just got that whack when Injun Joe done it. D'you reckon -he could see anything? D'you reckon he knowed anything?" - -"By hokey, that's so, Tom!" - -"And besides, look-a-here--maybe that whack done for HIM!" - -"No, 'taint likely, Tom. He had liquor in him; I could see that; and -besides, he always has. Well, when pap's full, you might take and belt -him over the head with a church and you couldn't phase him. He says so, -his own self. So it's the same with Muff Potter, of course. But if a -man was dead sober, I reckon maybe that whack might fetch him; I dono." - -After another reflective silence, Tom said: - -"Hucky, you sure you can keep mum?" - -"Tom, we GOT to keep mum. You know that. That Injun devil wouldn't -make any more of drownding us than a couple of cats, if we was to -squeak 'bout this and they didn't hang him. Now, look-a-here, Tom, less -take and swear to one another--that's what we got to do--swear to keep -mum." - -"I'm agreed. It's the best thing. Would you just hold hands and swear -that we--" - -"Oh no, that wouldn't do for this. That's good enough for little -rubbishy common things--specially with gals, cuz THEY go back on you -anyway, and blab if they get in a huff--but there orter be writing -'bout a big thing like this. And blood." - -Tom's whole being applauded this idea. It was deep, and dark, and -awful; the hour, the circumstances, the surroundings, were in keeping -with it. He picked up a clean pine shingle that lay in the moonlight, -took a little fragment of "red keel" out of his pocket, got the moon on -his work, and painfully scrawled these lines, emphasizing each slow -down-stroke by clamping his tongue between his teeth, and letting up -the pressure on the up-strokes. [See next page.] - - "Huck Finn and - Tom Sawyer swears - they will keep mum - about This and They - wish They may Drop - down dead in Their - Tracks if They ever - Tell and Rot." - -Huckleberry was filled with admiration of Tom's facility in writing, -and the sublimity of his language. He at once took a pin from his lapel -and was going to prick his flesh, but Tom said: - -"Hold on! Don't do that. A pin's brass. It might have verdigrease on -it." - -"What's verdigrease?" - -"It's p'ison. That's what it is. You just swaller some of it once ---you'll see." - -So Tom unwound the thread from one of his needles, and each boy -pricked the ball of his thumb and squeezed out a drop of blood. In -time, after many squeezes, Tom managed to sign his initials, using the -ball of his little finger for a pen. Then he showed Huckleberry how to -make an H and an F, and the oath was complete. They buried the shingle -close to the wall, with some dismal ceremonies and incantations, and -the fetters that bound their tongues were considered to be locked and -the key thrown away. - -A figure crept stealthily through a break in the other end of the -ruined building, now, but they did not notice it. - -"Tom," whispered Huckleberry, "does this keep us from EVER telling ---ALWAYS?" - -"Of course it does. It don't make any difference WHAT happens, we got -to keep mum. We'd drop down dead--don't YOU know that?" - -"Yes, I reckon that's so." - -They continued to whisper for some little time. Presently a dog set up -a long, lugubrious howl just outside--within ten feet of them. The boys -clasped each other suddenly, in an agony of fright. - -"Which of us does he mean?" gasped Huckleberry. - -"I dono--peep through the crack. Quick!" - -"No, YOU, Tom!" - -"I can't--I can't DO it, Huck!" - -"Please, Tom. There 'tis again!" - -"Oh, lordy, I'm thankful!" whispered Tom. "I know his voice. It's Bull -Harbison." * - -[* If Mr. Harbison owned a slave named Bull, Tom would have spoken of -him as "Harbison's Bull," but a son or a dog of that name was "Bull -Harbison."] - -"Oh, that's good--I tell you, Tom, I was most scared to death; I'd a -bet anything it was a STRAY dog." - -The dog howled again. The boys' hearts sank once more. - -"Oh, my! that ain't no Bull Harbison!" whispered Huckleberry. "DO, Tom!" - -Tom, quaking with fear, yielded, and put his eye to the crack. His -whisper was hardly audible when he said: - -"Oh, Huck, IT S A STRAY DOG!" - -"Quick, Tom, quick! Who does he mean?" - -"Huck, he must mean us both--we're right together." - -"Oh, Tom, I reckon we're goners. I reckon there ain't no mistake 'bout -where I'LL go to. I been so wicked." - -"Dad fetch it! This comes of playing hookey and doing everything a -feller's told NOT to do. I might a been good, like Sid, if I'd a tried ---but no, I wouldn't, of course. But if ever I get off this time, I lay -I'll just WALLER in Sunday-schools!" And Tom began to snuffle a little. - -"YOU bad!" and Huckleberry began to snuffle too. "Consound it, Tom -Sawyer, you're just old pie, 'longside o' what I am. Oh, LORDY, lordy, -lordy, I wisht I only had half your chance." - -Tom choked off and whispered: - -"Look, Hucky, look! He's got his BACK to us!" - -Hucky looked, with joy in his heart. - -"Well, he has, by jingoes! Did he before?" - -"Yes, he did. But I, like a fool, never thought. Oh, this is bully, -you know. NOW who can he mean?" - -The howling stopped. Tom pricked up his ears. - -"Sh! What's that?" he whispered. - -"Sounds like--like hogs grunting. No--it's somebody snoring, Tom." - -"That IS it! Where 'bouts is it, Huck?" - -"I bleeve it's down at 'tother end. Sounds so, anyway. Pap used to -sleep there, sometimes, 'long with the hogs, but laws bless you, he -just lifts things when HE snores. Besides, I reckon he ain't ever -coming back to this town any more." - -The spirit of adventure rose in the boys' souls once more. - -"Hucky, do you das't to go if I lead?" - -"I don't like to, much. Tom, s'pose it's Injun Joe!" - -Tom quailed. But presently the temptation rose up strong again and the -boys agreed to try, with the understanding that they would take to -their heels if the snoring stopped. So they went tiptoeing stealthily -down, the one behind the other. When they had got to within five steps -of the snorer, Tom stepped on a stick, and it broke with a sharp snap. -The man moaned, writhed a little, and his face came into the moonlight. -It was Muff Potter. The boys' hearts had stood still, and their hopes -too, when the man moved, but their fears passed away now. They tiptoed -out, through the broken weather-boarding, and stopped at a little -distance to exchange a parting word. That long, lugubrious howl rose on -the night air again! They turned and saw the strange dog standing -within a few feet of where Potter was lying, and FACING Potter, with -his nose pointing heavenward. - -"Oh, geeminy, it's HIM!" exclaimed both boys, in a breath. - -"Say, Tom--they say a stray dog come howling around Johnny Miller's -house, 'bout midnight, as much as two weeks ago; and a whippoorwill -come in and lit on the banisters and sung, the very same evening; and -there ain't anybody dead there yet." - -"Well, I know that. And suppose there ain't. Didn't Gracie Miller fall -in the kitchen fire and burn herself terrible the very next Saturday?" - -"Yes, but she ain't DEAD. And what's more, she's getting better, too." - -"All right, you wait and see. She's a goner, just as dead sure as Muff -Potter's a goner. That's what the niggers say, and they know all about -these kind of things, Huck." - -Then they separated, cogitating. When Tom crept in at his bedroom -window the night was almost spent. He undressed with excessive caution, -and fell asleep congratulating himself that nobody knew of his -escapade. He was not aware that the gently-snoring Sid was awake, and -had been so for an hour. - -When Tom awoke, Sid was dressed and gone. There was a late look in the -light, a late sense in the atmosphere. He was startled. Why had he not -been called--persecuted till he was up, as usual? The thought filled -him with bodings. Within five minutes he was dressed and down-stairs, -feeling sore and drowsy. The family were still at table, but they had -finished breakfast. There was no voice of rebuke; but there were -averted eyes; there was a silence and an air of solemnity that struck a -chill to the culprit's heart. He sat down and tried to seem gay, but it -was up-hill work; it roused no smile, no response, and he lapsed into -silence and let his heart sink down to the depths. - -After breakfast his aunt took him aside, and Tom almost brightened in -the hope that he was going to be flogged; but it was not so. His aunt -wept over him and asked him how he could go and break her old heart so; -and finally told him to go on, and ruin himself and bring her gray -hairs with sorrow to the grave, for it was no use for her to try any -more. This was worse than a thousand whippings, and Tom's heart was -sorer now than his body. He cried, he pleaded for forgiveness, promised -to reform over and over again, and then received his dismissal, feeling -that he had won but an imperfect forgiveness and established but a -feeble confidence. - -He left the presence too miserable to even feel revengeful toward Sid; -and so the latter's prompt retreat through the back gate was -unnecessary. He moped to school gloomy and sad, and took his flogging, -along with Joe Harper, for playing hookey the day before, with the air -of one whose heart was busy with heavier woes and wholly dead to -trifles. Then he betook himself to his seat, rested his elbows on his -desk and his jaws in his hands, and stared at the wall with the stony -stare of suffering that has reached the limit and can no further go. -His elbow was pressing against some hard substance. After a long time -he slowly and sadly changed his position, and took up this object with -a sigh. It was in a paper. He unrolled it. A long, lingering, colossal -sigh followed, and his heart broke. It was his brass andiron knob! - -This final feather broke the camel's back. - - - -CHAPTER XI - -CLOSE upon the hour of noon the whole village was suddenly electrified -with the ghastly news. No need of the as yet undreamed-of telegraph; -the tale flew from man to man, from group to group, from house to -house, with little less than telegraphic speed. Of course the -schoolmaster gave holiday for that afternoon; the town would have -thought strangely of him if he had not. - -A gory knife had been found close to the murdered man, and it had been -recognized by somebody as belonging to Muff Potter--so the story ran. -And it was said that a belated citizen had come upon Potter washing -himself in the "branch" about one or two o'clock in the morning, and -that Potter had at once sneaked off--suspicious circumstances, -especially the washing which was not a habit with Potter. It was also -said that the town had been ransacked for this "murderer" (the public -are not slow in the matter of sifting evidence and arriving at a -verdict), but that he could not be found. Horsemen had departed down -all the roads in every direction, and the Sheriff "was confident" that -he would be captured before night. - -All the town was drifting toward the graveyard. Tom's heartbreak -vanished and he joined the procession, not because he would not a -thousand times rather go anywhere else, but because an awful, -unaccountable fascination drew him on. Arrived at the dreadful place, -he wormed his small body through the crowd and saw the dismal -spectacle. It seemed to him an age since he was there before. Somebody -pinched his arm. He turned, and his eyes met Huckleberry's. Then both -looked elsewhere at once, and wondered if anybody had noticed anything -in their mutual glance. But everybody was talking, and intent upon the -grisly spectacle before them. - -"Poor fellow!" "Poor young fellow!" "This ought to be a lesson to -grave robbers!" "Muff Potter'll hang for this if they catch him!" This -was the drift of remark; and the minister said, "It was a judgment; His -hand is here." - -Now Tom shivered from head to heel; for his eye fell upon the stolid -face of Injun Joe. At this moment the crowd began to sway and struggle, -and voices shouted, "It's him! it's him! he's coming himself!" - -"Who? Who?" from twenty voices. - -"Muff Potter!" - -"Hallo, he's stopped!--Look out, he's turning! Don't let him get away!" - -People in the branches of the trees over Tom's head said he wasn't -trying to get away--he only looked doubtful and perplexed. - -"Infernal impudence!" said a bystander; "wanted to come and take a -quiet look at his work, I reckon--didn't expect any company." - -The crowd fell apart, now, and the Sheriff came through, -ostentatiously leading Potter by the arm. The poor fellow's face was -haggard, and his eyes showed the fear that was upon him. When he stood -before the murdered man, he shook as with a palsy, and he put his face -in his hands and burst into tears. - -"I didn't do it, friends," he sobbed; "'pon my word and honor I never -done it." - -"Who's accused you?" shouted a voice. - -This shot seemed to carry home. Potter lifted his face and looked -around him with a pathetic hopelessness in his eyes. He saw Injun Joe, -and exclaimed: - -"Oh, Injun Joe, you promised me you'd never--" - -"Is that your knife?" and it was thrust before him by the Sheriff. - -Potter would have fallen if they had not caught him and eased him to -the ground. Then he said: - -"Something told me 't if I didn't come back and get--" He shuddered; -then waved his nerveless hand with a vanquished gesture and said, "Tell -'em, Joe, tell 'em--it ain't any use any more." - -Then Huckleberry and Tom stood dumb and staring, and heard the -stony-hearted liar reel off his serene statement, they expecting every -moment that the clear sky would deliver God's lightnings upon his head, -and wondering to see how long the stroke was delayed. And when he had -finished and still stood alive and whole, their wavering impulse to -break their oath and save the poor betrayed prisoner's life faded and -vanished away, for plainly this miscreant had sold himself to Satan and -it would be fatal to meddle with the property of such a power as that. - -"Why didn't you leave? What did you want to come here for?" somebody -said. - -"I couldn't help it--I couldn't help it," Potter moaned. "I wanted to -run away, but I couldn't seem to come anywhere but here." And he fell -to sobbing again. - -Injun Joe repeated his statement, just as calmly, a few minutes -afterward on the inquest, under oath; and the boys, seeing that the -lightnings were still withheld, were confirmed in their belief that Joe -had sold himself to the devil. He was now become, to them, the most -balefully interesting object they had ever looked upon, and they could -not take their fascinated eyes from his face. - -They inwardly resolved to watch him nights, when opportunity should -offer, in the hope of getting a glimpse of his dread master. - -Injun Joe helped to raise the body of the murdered man and put it in a -wagon for removal; and it was whispered through the shuddering crowd -that the wound bled a little! The boys thought that this happy -circumstance would turn suspicion in the right direction; but they were -disappointed, for more than one villager remarked: - -"It was within three feet of Muff Potter when it done it." - -Tom's fearful secret and gnawing conscience disturbed his sleep for as -much as a week after this; and at breakfast one morning Sid said: - -"Tom, you pitch around and talk in your sleep so much that you keep me -awake half the time." - -Tom blanched and dropped his eyes. - -"It's a bad sign," said Aunt Polly, gravely. "What you got on your -mind, Tom?" - -"Nothing. Nothing 't I know of." But the boy's hand shook so that he -spilled his coffee. - -"And you do talk such stuff," Sid said. "Last night you said, 'It's -blood, it's blood, that's what it is!' You said that over and over. And -you said, 'Don't torment me so--I'll tell!' Tell WHAT? What is it -you'll tell?" - -Everything was swimming before Tom. There is no telling what might -have happened, now, but luckily the concern passed out of Aunt Polly's -face and she came to Tom's relief without knowing it. She said: - -"Sho! It's that dreadful murder. I dream about it most every night -myself. Sometimes I dream it's me that done it." - -Mary said she had been affected much the same way. Sid seemed -satisfied. Tom got out of the presence as quick as he plausibly could, -and after that he complained of toothache for a week, and tied up his -jaws every night. He never knew that Sid lay nightly watching, and -frequently slipped the bandage free and then leaned on his elbow -listening a good while at a time, and afterward slipped the bandage -back to its place again. Tom's distress of mind wore off gradually and -the toothache grew irksome and was discarded. If Sid really managed to -make anything out of Tom's disjointed mutterings, he kept it to himself. - -It seemed to Tom that his schoolmates never would get done holding -inquests on dead cats, and thus keeping his trouble present to his -mind. Sid noticed that Tom never was coroner at one of these inquiries, -though it had been his habit to take the lead in all new enterprises; -he noticed, too, that Tom never acted as a witness--and that was -strange; and Sid did not overlook the fact that Tom even showed a -marked aversion to these inquests, and always avoided them when he -could. Sid marvelled, but said nothing. However, even inquests went out -of vogue at last, and ceased to torture Tom's conscience. - -Every day or two, during this time of sorrow, Tom watched his -opportunity and went to the little grated jail-window and smuggled such -small comforts through to the "murderer" as he could get hold of. The -jail was a trifling little brick den that stood in a marsh at the edge -of the village, and no guards were afforded for it; indeed, it was -seldom occupied. These offerings greatly helped to ease Tom's -conscience. - -The villagers had a strong desire to tar-and-feather Injun Joe and -ride him on a rail, for body-snatching, but so formidable was his -character that nobody could be found who was willing to take the lead -in the matter, so it was dropped. He had been careful to begin both of -his inquest-statements with the fight, without confessing the -grave-robbery that preceded it; therefore it was deemed wisest not -to try the case in the courts at present. - - - -CHAPTER XII - -ONE of the reasons why Tom's mind had drifted away from its secret -troubles was, that it had found a new and weighty matter to interest -itself about. Becky Thatcher had stopped coming to school. Tom had -struggled with his pride a few days, and tried to "whistle her down the -wind," but failed. He began to find himself hanging around her father's -house, nights, and feeling very miserable. She was ill. What if she -should die! There was distraction in the thought. He no longer took an -interest in war, nor even in piracy. The charm of life was gone; there -was nothing but dreariness left. He put his hoop away, and his bat; -there was no joy in them any more. His aunt was concerned. She began to -try all manner of remedies on him. She was one of those people who are -infatuated with patent medicines and all new-fangled methods of -producing health or mending it. She was an inveterate experimenter in -these things. When something fresh in this line came out she was in a -fever, right away, to try it; not on herself, for she was never ailing, -but on anybody else that came handy. She was a subscriber for all the -"Health" periodicals and phrenological frauds; and the solemn ignorance -they were inflated with was breath to her nostrils. All the "rot" they -contained about ventilation, and how to go to bed, and how to get up, -and what to eat, and what to drink, and how much exercise to take, and -what frame of mind to keep one's self in, and what sort of clothing to -wear, was all gospel to her, and she never observed that her -health-journals of the current month customarily upset everything they -had recommended the month before. She was as simple-hearted and honest -as the day was long, and so she was an easy victim. She gathered -together her quack periodicals and her quack medicines, and thus armed -with death, went about on her pale horse, metaphorically speaking, with -"hell following after." But she never suspected that she was not an -angel of healing and the balm of Gilead in disguise, to the suffering -neighbors. - -The water treatment was new, now, and Tom's low condition was a -windfall to her. She had him out at daylight every morning, stood him -up in the woodshed and drowned him with a deluge of cold water; then -she scrubbed him down with a towel like a file, and so brought him to; -then she rolled him up in a wet sheet and put him away under blankets -till she sweated his soul clean and "the yellow stains of it came -through his pores"--as Tom said. - -Yet notwithstanding all this, the boy grew more and more melancholy -and pale and dejected. She added hot baths, sitz baths, shower baths, -and plunges. The boy remained as dismal as a hearse. She began to -assist the water with a slim oatmeal diet and blister-plasters. She -calculated his capacity as she would a jug's, and filled him up every -day with quack cure-alls. - -Tom had become indifferent to persecution by this time. This phase -filled the old lady's heart with consternation. This indifference must -be broken up at any cost. Now she heard of Pain-killer for the first -time. She ordered a lot at once. She tasted it and was filled with -gratitude. It was simply fire in a liquid form. She dropped the water -treatment and everything else, and pinned her faith to Pain-killer. She -gave Tom a teaspoonful and watched with the deepest anxiety for the -result. Her troubles were instantly at rest, her soul at peace again; -for the "indifference" was broken up. The boy could not have shown a -wilder, heartier interest, if she had built a fire under him. - -Tom felt that it was time to wake up; this sort of life might be -romantic enough, in his blighted condition, but it was getting to have -too little sentiment and too much distracting variety about it. So he -thought over various plans for relief, and finally hit pon that of -professing to be fond of Pain-killer. He asked for it so often that he -became a nuisance, and his aunt ended by telling him to help himself -and quit bothering her. If it had been Sid, she would have had no -misgivings to alloy her delight; but since it was Tom, she watched the -bottle clandestinely. She found that the medicine did really diminish, -but it did not occur to her that the boy was mending the health of a -crack in the sitting-room floor with it. - -One day Tom was in the act of dosing the crack when his aunt's yellow -cat came along, purring, eying the teaspoon avariciously, and begging -for a taste. Tom said: - -"Don't ask for it unless you want it, Peter." - -But Peter signified that he did want it. - -"You better make sure." - -Peter was sure. - -"Now you've asked for it, and I'll give it to you, because there ain't -anything mean about me; but if you find you don't like it, you mustn't -blame anybody but your own self." - -Peter was agreeable. So Tom pried his mouth open and poured down the -Pain-killer. Peter sprang a couple of yards in the air, and then -delivered a war-whoop and set off round and round the room, banging -against furniture, upsetting flower-pots, and making general havoc. -Next he rose on his hind feet and pranced around, in a frenzy of -enjoyment, with his head over his shoulder and his voice proclaiming -his unappeasable happiness. Then he went tearing around the house again -spreading chaos and destruction in his path. Aunt Polly entered in time -to see him throw a few double summersets, deliver a final mighty -hurrah, and sail through the open window, carrying the rest of the -flower-pots with him. The old lady stood petrified with astonishment, -peering over her glasses; Tom lay on the floor expiring with laughter. - -"Tom, what on earth ails that cat?" - -"I don't know, aunt," gasped the boy. - -"Why, I never see anything like it. What did make him act so?" - -"Deed I don't know, Aunt Polly; cats always act so when they're having -a good time." - -"They do, do they?" There was something in the tone that made Tom -apprehensive. - -"Yes'm. That is, I believe they do." - -"You DO?" - -"Yes'm." - -The old lady was bending down, Tom watching, with interest emphasized -by anxiety. Too late he divined her "drift." The handle of the telltale -teaspoon was visible under the bed-valance. Aunt Polly took it, held it -up. Tom winced, and dropped his eyes. Aunt Polly raised him by the -usual handle--his ear--and cracked his head soundly with her thimble. - -"Now, sir, what did you want to treat that poor dumb beast so, for?" - -"I done it out of pity for him--because he hadn't any aunt." - -"Hadn't any aunt!--you numskull. What has that got to do with it?" - -"Heaps. Because if he'd had one she'd a burnt him out herself! She'd a -roasted his bowels out of him 'thout any more feeling than if he was a -human!" - -Aunt Polly felt a sudden pang of remorse. This was putting the thing -in a new light; what was cruelty to a cat MIGHT be cruelty to a boy, -too. She began to soften; she felt sorry. Her eyes watered a little, -and she put her hand on Tom's head and said gently: - -"I was meaning for the best, Tom. And, Tom, it DID do you good." - -Tom looked up in her face with just a perceptible twinkle peeping -through his gravity. - -"I know you was meaning for the best, aunty, and so was I with Peter. -It done HIM good, too. I never see him get around so since--" - -"Oh, go 'long with you, Tom, before you aggravate me again. And you -try and see if you can't be a good boy, for once, and you needn't take -any more medicine." - -Tom reached school ahead of time. It was noticed that this strange -thing had been occurring every day latterly. And now, as usual of late, -he hung about the gate of the schoolyard instead of playing with his -comrades. He was sick, he said, and he looked it. He tried to seem to -be looking everywhere but whither he really was looking--down the road. -Presently Jeff Thatcher hove in sight, and Tom's face lighted; he gazed -a moment, and then turned sorrowfully away. When Jeff arrived, Tom -accosted him; and "led up" warily to opportunities for remark about -Becky, but the giddy lad never could see the bait. Tom watched and -watched, hoping whenever a frisking frock came in sight, and hating the -owner of it as soon as he saw she was not the right one. At last frocks -ceased to appear, and he dropped hopelessly into the dumps; he entered -the empty schoolhouse and sat down to suffer. Then one more frock -passed in at the gate, and Tom's heart gave a great bound. The next -instant he was out, and "going on" like an Indian; yelling, laughing, -chasing boys, jumping over the fence at risk of life and limb, throwing -handsprings, standing on his head--doing all the heroic things he could -conceive of, and keeping a furtive eye out, all the while, to see if -Becky Thatcher was noticing. But she seemed to be unconscious of it -all; she never looked. Could it be possible that she was not aware that -he was there? He carried his exploits to her immediate vicinity; came -war-whooping around, snatched a boy's cap, hurled it to the roof of the -schoolhouse, broke through a group of boys, tumbling them in every -direction, and fell sprawling, himself, under Becky's nose, almost -upsetting her--and she turned, with her nose in the air, and he heard -her say: "Mf! some people think they're mighty smart--always showing -off!" - -Tom's cheeks burned. He gathered himself up and sneaked off, crushed -and crestfallen. - - - -CHAPTER XIII - -TOM'S mind was made up now. He was gloomy and desperate. He was a -forsaken, friendless boy, he said; nobody loved him; when they found -out what they had driven him to, perhaps they would be sorry; he had -tried to do right and get along, but they would not let him; since -nothing would do them but to be rid of him, let it be so; and let them -blame HIM for the consequences--why shouldn't they? What right had the -friendless to complain? Yes, they had forced him to it at last: he -would lead a life of crime. There was no choice. - -By this time he was far down Meadow Lane, and the bell for school to -"take up" tinkled faintly upon his ear. He sobbed, now, to think he -should never, never hear that old familiar sound any more--it was very -hard, but it was forced on him; since he was driven out into the cold -world, he must submit--but he forgave them. Then the sobs came thick -and fast. - -Just at this point he met his soul's sworn comrade, Joe Harper ---hard-eyed, and with evidently a great and dismal purpose in his heart. -Plainly here were "two souls with but a single thought." Tom, wiping -his eyes with his sleeve, began to blubber out something about a -resolution to escape from hard usage and lack of sympathy at home by -roaming abroad into the great world never to return; and ended by -hoping that Joe would not forget him. - -But it transpired that this was a request which Joe had just been -going to make of Tom, and had come to hunt him up for that purpose. His -mother had whipped him for drinking some cream which he had never -tasted and knew nothing about; it was plain that she was tired of him -and wished him to go; if she felt that way, there was nothing for him -to do but succumb; he hoped she would be happy, and never regret having -driven her poor boy out into the unfeeling world to suffer and die. - -As the two boys walked sorrowing along, they made a new compact to -stand by each other and be brothers and never separate till death -relieved them of their troubles. Then they began to lay their plans. -Joe was for being a hermit, and living on crusts in a remote cave, and -dying, some time, of cold and want and grief; but after listening to -Tom, he conceded that there were some conspicuous advantages about a -life of crime, and so he consented to be a pirate. - -Three miles below St. Petersburg, at a point where the Mississippi -River was a trifle over a mile wide, there was a long, narrow, wooded -island, with a shallow bar at the head of it, and this offered well as -a rendezvous. It was not inhabited; it lay far over toward the further -shore, abreast a dense and almost wholly unpeopled forest. So Jackson's -Island was chosen. Who were to be the subjects of their piracies was a -matter that did not occur to them. Then they hunted up Huckleberry -Finn, and he joined them promptly, for all careers were one to him; he -was indifferent. They presently separated to meet at a lonely spot on -the river-bank two miles above the village at the favorite hour--which -was midnight. There was a small log raft there which they meant to -capture. Each would bring hooks and lines, and such provision as he -could steal in the most dark and mysterious way--as became outlaws. And -before the afternoon was done, they had all managed to enjoy the sweet -glory of spreading the fact that pretty soon the town would "hear -something." All who got this vague hint were cautioned to "be mum and -wait." - -About midnight Tom arrived with a boiled ham and a few trifles, -and stopped in a dense undergrowth on a small bluff overlooking the -meeting-place. It was starlight, and very still. The mighty river lay -like an ocean at rest. Tom listened a moment, but no sound disturbed the -quiet. Then he gave a low, distinct whistle. It was answered from under -the bluff. Tom whistled twice more; these signals were answered in the -same way. Then a guarded voice said: - -"Who goes there?" - -"Tom Sawyer, the Black Avenger of the Spanish Main. Name your names." - -"Huck Finn the Red-Handed, and Joe Harper the Terror of the Seas." Tom -had furnished these titles, from his favorite literature. - -"'Tis well. Give the countersign." - -Two hoarse whispers delivered the same awful word simultaneously to -the brooding night: - -"BLOOD!" - -Then Tom tumbled his ham over the bluff and let himself down after it, -tearing both skin and clothes to some extent in the effort. There was -an easy, comfortable path along the shore under the bluff, but it -lacked the advantages of difficulty and danger so valued by a pirate. - -The Terror of the Seas had brought a side of bacon, and had about worn -himself out with getting it there. Finn the Red-Handed had stolen a -skillet and a quantity of half-cured leaf tobacco, and had also brought -a few corn-cobs to make pipes with. But none of the pirates smoked or -"chewed" but himself. The Black Avenger of the Spanish Main said it -would never do to start without some fire. That was a wise thought; -matches were hardly known there in that day. They saw a fire -smouldering upon a great raft a hundred yards above, and they went -stealthily thither and helped themselves to a chunk. They made an -imposing adventure of it, saying, "Hist!" every now and then, and -suddenly halting with finger on lip; moving with hands on imaginary -dagger-hilts; and giving orders in dismal whispers that if "the foe" -stirred, to "let him have it to the hilt," because "dead men tell no -tales." They knew well enough that the raftsmen were all down at the -village laying in stores or having a spree, but still that was no -excuse for their conducting this thing in an unpiratical way. - -They shoved off, presently, Tom in command, Huck at the after oar and -Joe at the forward. Tom stood amidships, gloomy-browed, and with folded -arms, and gave his orders in a low, stern whisper: - -"Luff, and bring her to the wind!" - -"Aye-aye, sir!" - -"Steady, steady-y-y-y!" - -"Steady it is, sir!" - -"Let her go off a point!" - -"Point it is, sir!" - -As the boys steadily and monotonously drove the raft toward mid-stream -it was no doubt understood that these orders were given only for -"style," and were not intended to mean anything in particular. - -"What sail's she carrying?" - -"Courses, tops'ls, and flying-jib, sir." - -"Send the r'yals up! Lay out aloft, there, half a dozen of ye ---foretopmaststuns'l! Lively, now!" - -"Aye-aye, sir!" - -"Shake out that maintogalans'l! Sheets and braces! NOW my hearties!" - -"Aye-aye, sir!" - -"Hellum-a-lee--hard a port! Stand by to meet her when she comes! Port, -port! NOW, men! With a will! Stead-y-y-y!" - -"Steady it is, sir!" - -The raft drew beyond the middle of the river; the boys pointed her -head right, and then lay on their oars. The river was not high, so -there was not more than a two or three mile current. Hardly a word was -said during the next three-quarters of an hour. Now the raft was -passing before the distant town. Two or three glimmering lights showed -where it lay, peacefully sleeping, beyond the vague vast sweep of -star-gemmed water, unconscious of the tremendous event that was happening. -The Black Avenger stood still with folded arms, "looking his last" upon -the scene of his former joys and his later sufferings, and wishing -"she" could see him now, abroad on the wild sea, facing peril and death -with dauntless heart, going to his doom with a grim smile on his lips. -It was but a small strain on his imagination to remove Jackson's Island -beyond eyeshot of the village, and so he "looked his last" with a -broken and satisfied heart. The other pirates were looking their last, -too; and they all looked so long that they came near letting the -current drift them out of the range of the island. But they discovered -the danger in time, and made shift to avert it. About two o'clock in -the morning the raft grounded on the bar two hundred yards above the -head of the island, and they waded back and forth until they had landed -their freight. Part of the little raft's belongings consisted of an old -sail, and this they spread over a nook in the bushes for a tent to -shelter their provisions; but they themselves would sleep in the open -air in good weather, as became outlaws. - -They built a fire against the side of a great log twenty or thirty -steps within the sombre depths of the forest, and then cooked some -bacon in the frying-pan for supper, and used up half of the corn "pone" -stock they had brought. It seemed glorious sport to be feasting in that -wild, free way in the virgin forest of an unexplored and uninhabited -island, far from the haunts of men, and they said they never would -return to civilization. The climbing fire lit up their faces and threw -its ruddy glare upon the pillared tree-trunks of their forest temple, -and upon the varnished foliage and festooning vines. - -When the last crisp slice of bacon was gone, and the last allowance of -corn pone devoured, the boys stretched themselves out on the grass, -filled with contentment. They could have found a cooler place, but they -would not deny themselves such a romantic feature as the roasting -camp-fire. - -"AIN'T it gay?" said Joe. - -"It's NUTS!" said Tom. "What would the boys say if they could see us?" - -"Say? Well, they'd just die to be here--hey, Hucky!" - -"I reckon so," said Huckleberry; "anyways, I'm suited. I don't want -nothing better'n this. I don't ever get enough to eat, gen'ally--and -here they can't come and pick at a feller and bullyrag him so." - -"It's just the life for me," said Tom. "You don't have to get up, -mornings, and you don't have to go to school, and wash, and all that -blame foolishness. You see a pirate don't have to do ANYTHING, Joe, -when he's ashore, but a hermit HE has to be praying considerable, and -then he don't have any fun, anyway, all by himself that way." - -"Oh yes, that's so," said Joe, "but I hadn't thought much about it, -you know. I'd a good deal rather be a pirate, now that I've tried it." - -"You see," said Tom, "people don't go much on hermits, nowadays, like -they used to in old times, but a pirate's always respected. And a -hermit's got to sleep on the hardest place he can find, and put -sackcloth and ashes on his head, and stand out in the rain, and--" - -"What does he put sackcloth and ashes on his head for?" inquired Huck. - -"I dono. But they've GOT to do it. Hermits always do. You'd have to do -that if you was a hermit." - -"Dern'd if I would," said Huck. - -"Well, what would you do?" - -"I dono. But I wouldn't do that." - -"Why, Huck, you'd HAVE to. How'd you get around it?" - -"Why, I just wouldn't stand it. I'd run away." - -"Run away! Well, you WOULD be a nice old slouch of a hermit. You'd be -a disgrace." - -The Red-Handed made no response, being better employed. He had -finished gouging out a cob, and now he fitted a weed stem to it, loaded -it with tobacco, and was pressing a coal to the charge and blowing a -cloud of fragrant smoke--he was in the full bloom of luxurious -contentment. The other pirates envied him this majestic vice, and -secretly resolved to acquire it shortly. Presently Huck said: - -"What does pirates have to do?" - -Tom said: - -"Oh, they have just a bully time--take ships and burn them, and get -the money and bury it in awful places in their island where there's -ghosts and things to watch it, and kill everybody in the ships--make -'em walk a plank." - -"And they carry the women to the island," said Joe; "they don't kill -the women." - -"No," assented Tom, "they don't kill the women--they're too noble. And -the women's always beautiful, too. - -"And don't they wear the bulliest clothes! Oh no! All gold and silver -and di'monds," said Joe, with enthusiasm. - -"Who?" said Huck. - -"Why, the pirates." - -Huck scanned his own clothing forlornly. - -"I reckon I ain't dressed fitten for a pirate," said he, with a -regretful pathos in his voice; "but I ain't got none but these." - -But the other boys told him the fine clothes would come fast enough, -after they should have begun their adventures. They made him understand -that his poor rags would do to begin with, though it was customary for -wealthy pirates to start with a proper wardrobe. - -Gradually their talk died out and drowsiness began to steal upon the -eyelids of the little waifs. The pipe dropped from the fingers of the -Red-Handed, and he slept the sleep of the conscience-free and the -weary. The Terror of the Seas and the Black Avenger of the Spanish Main -had more difficulty in getting to sleep. They said their prayers -inwardly, and lying down, since there was nobody there with authority -to make them kneel and recite aloud; in truth, they had a mind not to -say them at all, but they were afraid to proceed to such lengths as -that, lest they might call down a sudden and special thunderbolt from -heaven. Then at once they reached and hovered upon the imminent verge -of sleep--but an intruder came, now, that would not "down." It was -conscience. They began to feel a vague fear that they had been doing -wrong to run away; and next they thought of the stolen meat, and then -the real torture came. They tried to argue it away by reminding -conscience that they had purloined sweetmeats and apples scores of -times; but conscience was not to be appeased by such thin -plausibilities; it seemed to them, in the end, that there was no -getting around the stubborn fact that taking sweetmeats was only -"hooking," while taking bacon and hams and such valuables was plain -simple stealing--and there was a command against that in the Bible. So -they inwardly resolved that so long as they remained in the business, -their piracies should not again be sullied with the crime of stealing. -Then conscience granted a truce, and these curiously inconsistent -pirates fell peacefully to sleep. - - - -CHAPTER XIV - -WHEN Tom awoke in the morning, he wondered where he was. He sat up and -rubbed his eyes and looked around. Then he comprehended. It was the -cool gray dawn, and there was a delicious sense of repose and peace in -the deep pervading calm and silence of the woods. Not a leaf stirred; -not a sound obtruded upon great Nature's meditation. Beaded dewdrops -stood upon the leaves and grasses. A white layer of ashes covered the -fire, and a thin blue breath of smoke rose straight into the air. Joe -and Huck still slept. - -Now, far away in the woods a bird called; another answered; presently -the hammering of a woodpecker was heard. Gradually the cool dim gray of -the morning whitened, and as gradually sounds multiplied and life -manifested itself. The marvel of Nature shaking off sleep and going to -work unfolded itself to the musing boy. A little green worm came -crawling over a dewy leaf, lifting two-thirds of his body into the air -from time to time and "sniffing around," then proceeding again--for he -was measuring, Tom said; and when the worm approached him, of its own -accord, he sat as still as a stone, with his hopes rising and falling, -by turns, as the creature still came toward him or seemed inclined to -go elsewhere; and when at last it considered a painful moment with its -curved body in the air and then came decisively down upon Tom's leg and -began a journey over him, his whole heart was glad--for that meant that -he was going to have a new suit of clothes--without the shadow of a -doubt a gaudy piratical uniform. Now a procession of ants appeared, -from nowhere in particular, and went about their labors; one struggled -manfully by with a dead spider five times as big as itself in its arms, -and lugged it straight up a tree-trunk. A brown spotted lady-bug -climbed the dizzy height of a grass blade, and Tom bent down close to -it and said, "Lady-bug, lady-bug, fly away home, your house is on fire, -your children's alone," and she took wing and went off to see about it ---which did not surprise the boy, for he knew of old that this insect was -credulous about conflagrations, and he had practised upon its -simplicity more than once. A tumblebug came next, heaving sturdily at -its ball, and Tom touched the creature, to see it shut its legs against -its body and pretend to be dead. The birds were fairly rioting by this -time. A catbird, the Northern mocker, lit in a tree over Tom's head, -and trilled out her imitations of her neighbors in a rapture of -enjoyment; then a shrill jay swept down, a flash of blue flame, and -stopped on a twig almost within the boy's reach, cocked his head to one -side and eyed the strangers with a consuming curiosity; a gray squirrel -and a big fellow of the "fox" kind came skurrying along, sitting up at -intervals to inspect and chatter at the boys, for the wild things had -probably never seen a human being before and scarcely knew whether to -be afraid or not. All Nature was wide awake and stirring, now; long -lances of sunlight pierced down through the dense foliage far and near, -and a few butterflies came fluttering upon the scene. - -Tom stirred up the other pirates and they all clattered away with a -shout, and in a minute or two were stripped and chasing after and -tumbling over each other in the shallow limpid water of the white -sandbar. They felt no longing for the little village sleeping in the -distance beyond the majestic waste of water. A vagrant current or a -slight rise in the river had carried off their raft, but this only -gratified them, since its going was something like burning the bridge -between them and civilization. - -They came back to camp wonderfully refreshed, glad-hearted, and -ravenous; and they soon had the camp-fire blazing up again. Huck found -a spring of clear cold water close by, and the boys made cups of broad -oak or hickory leaves, and felt that water, sweetened with such a -wildwood charm as that, would be a good enough substitute for coffee. -While Joe was slicing bacon for breakfast, Tom and Huck asked him to -hold on a minute; they stepped to a promising nook in the river-bank -and threw in their lines; almost immediately they had reward. Joe had -not had time to get impatient before they were back again with some -handsome bass, a couple of sun-perch and a small catfish--provisions -enough for quite a family. They fried the fish with the bacon, and were -astonished; for no fish had ever seemed so delicious before. They did -not know that the quicker a fresh-water fish is on the fire after he is -caught the better he is; and they reflected little upon what a sauce -open-air sleeping, open-air exercise, bathing, and a large ingredient -of hunger make, too. - -They lay around in the shade, after breakfast, while Huck had a smoke, -and then went off through the woods on an exploring expedition. They -tramped gayly along, over decaying logs, through tangled underbrush, -among solemn monarchs of the forest, hung from their crowns to the -ground with a drooping regalia of grape-vines. Now and then they came -upon snug nooks carpeted with grass and jeweled with flowers. - -They found plenty of things to be delighted with, but nothing to be -astonished at. They discovered that the island was about three miles -long and a quarter of a mile wide, and that the shore it lay closest to -was only separated from it by a narrow channel hardly two hundred yards -wide. They took a swim about every hour, so it was close upon the -middle of the afternoon when they got back to camp. They were too -hungry to stop to fish, but they fared sumptuously upon cold ham, and -then threw themselves down in the shade to talk. But the talk soon -began to drag, and then died. The stillness, the solemnity that brooded -in the woods, and the sense of loneliness, began to tell upon the -spirits of the boys. They fell to thinking. A sort of undefined longing -crept upon them. This took dim shape, presently--it was budding -homesickness. Even Finn the Red-Handed was dreaming of his doorsteps -and empty hogsheads. But they were all ashamed of their weakness, and -none was brave enough to speak his thought. - -For some time, now, the boys had been dully conscious of a peculiar -sound in the distance, just as one sometimes is of the ticking of a -clock which he takes no distinct note of. But now this mysterious sound -became more pronounced, and forced a recognition. The boys started, -glanced at each other, and then each assumed a listening attitude. -There was a long silence, profound and unbroken; then a deep, sullen -boom came floating down out of the distance. - -"What is it!" exclaimed Joe, under his breath. - -"I wonder," said Tom in a whisper. - -"'Tain't thunder," said Huckleberry, in an awed tone, "becuz thunder--" - -"Hark!" said Tom. "Listen--don't talk." - -They waited a time that seemed an age, and then the same muffled boom -troubled the solemn hush. - -"Let's go and see." - -They sprang to their feet and hurried to the shore toward the town. -They parted the bushes on the bank and peered out over the water. The -little steam ferryboat was about a mile below the village, drifting -with the current. Her broad deck seemed crowded with people. There were -a great many skiffs rowing about or floating with the stream in the -neighborhood of the ferryboat, but the boys could not determine what -the men in them were doing. Presently a great jet of white smoke burst -from the ferryboat's side, and as it expanded and rose in a lazy cloud, -that same dull throb of sound was borne to the listeners again. - -"I know now!" exclaimed Tom; "somebody's drownded!" - -"That's it!" said Huck; "they done that last summer, when Bill Turner -got drownded; they shoot a cannon over the water, and that makes him -come up to the top. Yes, and they take loaves of bread and put -quicksilver in 'em and set 'em afloat, and wherever there's anybody -that's drownded, they'll float right there and stop." - -"Yes, I've heard about that," said Joe. "I wonder what makes the bread -do that." - -"Oh, it ain't the bread, so much," said Tom; "I reckon it's mostly -what they SAY over it before they start it out." - -"But they don't say anything over it," said Huck. "I've seen 'em and -they don't." - -"Well, that's funny," said Tom. "But maybe they say it to themselves. -Of COURSE they do. Anybody might know that." - -The other boys agreed that there was reason in what Tom said, because -an ignorant lump of bread, uninstructed by an incantation, could not be -expected to act very intelligently when set upon an errand of such -gravity. - -"By jings, I wish I was over there, now," said Joe. - -"I do too" said Huck "I'd give heaps to know who it is." - -The boys still listened and watched. Presently a revealing thought -flashed through Tom's mind, and he exclaimed: - -"Boys, I know who's drownded--it's us!" - -They felt like heroes in an instant. Here was a gorgeous triumph; they -were missed; they were mourned; hearts were breaking on their account; -tears were being shed; accusing memories of unkindness to these poor -lost lads were rising up, and unavailing regrets and remorse were being -indulged; and best of all, the departed were the talk of the whole -town, and the envy of all the boys, as far as this dazzling notoriety -was concerned. This was fine. It was worth while to be a pirate, after -all. - -As twilight drew on, the ferryboat went back to her accustomed -business and the skiffs disappeared. The pirates returned to camp. They -were jubilant with vanity over their new grandeur and the illustrious -trouble they were making. They caught fish, cooked supper and ate it, -and then fell to guessing at what the village was thinking and saying -about them; and the pictures they drew of the public distress on their -account were gratifying to look upon--from their point of view. But -when the shadows of night closed them in, they gradually ceased to -talk, and sat gazing into the fire, with their minds evidently -wandering elsewhere. The excitement was gone, now, and Tom and Joe -could not keep back thoughts of certain persons at home who were not -enjoying this fine frolic as much as they were. Misgivings came; they -grew troubled and unhappy; a sigh or two escaped, unawares. By and by -Joe timidly ventured upon a roundabout "feeler" as to how the others -might look upon a return to civilization--not right now, but-- - -Tom withered him with derision! Huck, being uncommitted as yet, joined -in with Tom, and the waverer quickly "explained," and was glad to get -out of the scrape with as little taint of chicken-hearted homesickness -clinging to his garments as he could. Mutiny was effectually laid to -rest for the moment. - -As the night deepened, Huck began to nod, and presently to snore. Joe -followed next. Tom lay upon his elbow motionless, for some time, -watching the two intently. At last he got up cautiously, on his knees, -and went searching among the grass and the flickering reflections flung -by the camp-fire. He picked up and inspected several large -semi-cylinders of the thin white bark of a sycamore, and finally chose -two which seemed to suit him. Then he knelt by the fire and painfully -wrote something upon each of these with his "red keel"; one he rolled up -and put in his jacket pocket, and the other he put in Joe's hat and -removed it to a little distance from the owner. And he also put into the -hat certain schoolboy treasures of almost inestimable value--among them -a lump of chalk, an India-rubber ball, three fishhooks, and one of that -kind of marbles known as a "sure 'nough crystal." Then he tiptoed his -way cautiously among the trees till he felt that he was out of hearing, -and straightway broke into a keen run in the direction of the sandbar. - - - -CHAPTER XV - -A FEW minutes later Tom was in the shoal water of the bar, wading -toward the Illinois shore. Before the depth reached his middle he was -half-way over; the current would permit no more wading, now, so he -struck out confidently to swim the remaining hundred yards. He swam -quartering upstream, but still was swept downward rather faster than he -had expected. However, he reached the shore finally, and drifted along -till he found a low place and drew himself out. He put his hand on his -jacket pocket, found his piece of bark safe, and then struck through -the woods, following the shore, with streaming garments. Shortly before -ten o'clock he came out into an open place opposite the village, and -saw the ferryboat lying in the shadow of the trees and the high bank. -Everything was quiet under the blinking stars. He crept down the bank, -watching with all his eyes, slipped into the water, swam three or four -strokes and climbed into the skiff that did "yawl" duty at the boat's -stern. He laid himself down under the thwarts and waited, panting. - -Presently the cracked bell tapped and a voice gave the order to "cast -off." A minute or two later the skiff's head was standing high up, -against the boat's swell, and the voyage was begun. Tom felt happy in -his success, for he knew it was the boat's last trip for the night. At -the end of a long twelve or fifteen minutes the wheels stopped, and Tom -slipped overboard and swam ashore in the dusk, landing fifty yards -downstream, out of danger of possible stragglers. - -He flew along unfrequented alleys, and shortly found himself at his -aunt's back fence. He climbed over, approached the "ell," and looked in -at the sitting-room window, for a light was burning there. There sat -Aunt Polly, Sid, Mary, and Joe Harper's mother, grouped together, -talking. They were by the bed, and the bed was between them and the -door. Tom went to the door and began to softly lift the latch; then he -pressed gently and the door yielded a crack; he continued pushing -cautiously, and quaking every time it creaked, till he judged he might -squeeze through on his knees; so he put his head through and began, -warily. - -"What makes the candle blow so?" said Aunt Polly. Tom hurried up. -"Why, that door's open, I believe. Why, of course it is. No end of -strange things now. Go 'long and shut it, Sid." - -Tom disappeared under the bed just in time. He lay and "breathed" -himself for a time, and then crept to where he could almost touch his -aunt's foot. - -"But as I was saying," said Aunt Polly, "he warn't BAD, so to say ---only mischEEvous. Only just giddy, and harum-scarum, you know. He -warn't any more responsible than a colt. HE never meant any harm, and -he was the best-hearted boy that ever was"--and she began to cry. - -"It was just so with my Joe--always full of his devilment, and up to -every kind of mischief, but he was just as unselfish and kind as he -could be--and laws bless me, to think I went and whipped him for taking -that cream, never once recollecting that I throwed it out myself -because it was sour, and I never to see him again in this world, never, -never, never, poor abused boy!" And Mrs. Harper sobbed as if her heart -would break. - -"I hope Tom's better off where he is," said Sid, "but if he'd been -better in some ways--" - -"SID!" Tom felt the glare of the old lady's eye, though he could not -see it. "Not a word against my Tom, now that he's gone! God'll take -care of HIM--never you trouble YOURself, sir! Oh, Mrs. Harper, I don't -know how to give him up! I don't know how to give him up! He was such a -comfort to me, although he tormented my old heart out of me, 'most." - -"The Lord giveth and the Lord hath taken away--Blessed be the name of -the Lord! But it's so hard--Oh, it's so hard! Only last Saturday my -Joe busted a firecracker right under my nose and I knocked him -sprawling. Little did I know then, how soon--Oh, if it was to do over -again I'd hug him and bless him for it." - -"Yes, yes, yes, I know just how you feel, Mrs. Harper, I know just -exactly how you feel. No longer ago than yesterday noon, my Tom took -and filled the cat full of Pain-killer, and I did think the cretur -would tear the house down. And God forgive me, I cracked Tom's head -with my thimble, poor boy, poor dead boy. But he's out of all his -troubles now. And the last words I ever heard him say was to reproach--" - -But this memory was too much for the old lady, and she broke entirely -down. Tom was snuffling, now, himself--and more in pity of himself than -anybody else. He could hear Mary crying, and putting in a kindly word -for him from time to time. He began to have a nobler opinion of himself -than ever before. Still, he was sufficiently touched by his aunt's -grief to long to rush out from under the bed and overwhelm her with -joy--and the theatrical gorgeousness of the thing appealed strongly to -his nature, too, but he resisted and lay still. - -He went on listening, and gathered by odds and ends that it was -conjectured at first that the boys had got drowned while taking a swim; -then the small raft had been missed; next, certain boys said the -missing lads had promised that the village should "hear something" -soon; the wise-heads had "put this and that together" and decided that -the lads had gone off on that raft and would turn up at the next town -below, presently; but toward noon the raft had been found, lodged -against the Missouri shore some five or six miles below the village ---and then hope perished; they must be drowned, else hunger would have -driven them home by nightfall if not sooner. It was believed that the -search for the bodies had been a fruitless effort merely because the -drowning must have occurred in mid-channel, since the boys, being good -swimmers, would otherwise have escaped to shore. This was Wednesday -night. If the bodies continued missing until Sunday, all hope would be -given over, and the funerals would be preached on that morning. Tom -shuddered. - -Mrs. Harper gave a sobbing good-night and turned to go. Then with a -mutual impulse the two bereaved women flung themselves into each -other's arms and had a good, consoling cry, and then parted. Aunt Polly -was tender far beyond her wont, in her good-night to Sid and Mary. Sid -snuffled a bit and Mary went off crying with all her heart. - -Aunt Polly knelt down and prayed for Tom so touchingly, so -appealingly, and with such measureless love in her words and her old -trembling voice, that he was weltering in tears again, long before she -was through. - -He had to keep still long after she went to bed, for she kept making -broken-hearted ejaculations from time to time, tossing unrestfully, and -turning over. But at last she was still, only moaning a little in her -sleep. Now the boy stole out, rose gradually by the bedside, shaded the -candle-light with his hand, and stood regarding her. His heart was full -of pity for her. He took out his sycamore scroll and placed it by the -candle. But something occurred to him, and he lingered considering. His -face lighted with a happy solution of his thought; he put the bark -hastily in his pocket. Then he bent over and kissed the faded lips, and -straightway made his stealthy exit, latching the door behind him. - -He threaded his way back to the ferry landing, found nobody at large -there, and walked boldly on board the boat, for he knew she was -tenantless except that there was a watchman, who always turned in and -slept like a graven image. He untied the skiff at the stern, slipped -into it, and was soon rowing cautiously upstream. When he had pulled a -mile above the village, he started quartering across and bent himself -stoutly to his work. He hit the landing on the other side neatly, for -this was a familiar bit of work to him. He was moved to capture the -skiff, arguing that it might be considered a ship and therefore -legitimate prey for a pirate, but he knew a thorough search would be -made for it and that might end in revelations. So he stepped ashore and -entered the woods. - -He sat down and took a long rest, torturing himself meanwhile to keep -awake, and then started warily down the home-stretch. The night was far -spent. It was broad daylight before he found himself fairly abreast the -island bar. He rested again until the sun was well up and gilding the -great river with its splendor, and then he plunged into the stream. A -little later he paused, dripping, upon the threshold of the camp, and -heard Joe say: - -"No, Tom's true-blue, Huck, and he'll come back. He won't desert. He -knows that would be a disgrace to a pirate, and Tom's too proud for -that sort of thing. He's up to something or other. Now I wonder what?" - -"Well, the things is ours, anyway, ain't they?" - -"Pretty near, but not yet, Huck. The writing says they are if he ain't -back here to breakfast." - -"Which he is!" exclaimed Tom, with fine dramatic effect, stepping -grandly into camp. - -A sumptuous breakfast of bacon and fish was shortly provided, and as -the boys set to work upon it, Tom recounted (and adorned) his -adventures. They were a vain and boastful company of heroes when the -tale was done. Then Tom hid himself away in a shady nook to sleep till -noon, and the other pirates got ready to fish and explore. - - - -CHAPTER XVI - -AFTER dinner all the gang turned out to hunt for turtle eggs on the -bar. They went about poking sticks into the sand, and when they found a -soft place they went down on their knees and dug with their hands. -Sometimes they would take fifty or sixty eggs out of one hole. They -were perfectly round white things a trifle smaller than an English -walnut. They had a famous fried-egg feast that night, and another on -Friday morning. - -After breakfast they went whooping and prancing out on the bar, and -chased each other round and round, shedding clothes as they went, until -they were naked, and then continued the frolic far away up the shoal -water of the bar, against the stiff current, which latter tripped their -legs from under them from time to time and greatly increased the fun. -And now and then they stooped in a group and splashed water in each -other's faces with their palms, gradually approaching each other, with -averted faces to avoid the strangling sprays, and finally gripping and -struggling till the best man ducked his neighbor, and then they all -went under in a tangle of white legs and arms and came up blowing, -sputtering, laughing, and gasping for breath at one and the same time. - -When they were well exhausted, they would run out and sprawl on the -dry, hot sand, and lie there and cover themselves up with it, and by -and by break for the water again and go through the original -performance once more. Finally it occurred to them that their naked -skin represented flesh-colored "tights" very fairly; so they drew a -ring in the sand and had a circus--with three clowns in it, for none -would yield this proudest post to his neighbor. - -Next they got their marbles and played "knucks" and "ring-taw" and -"keeps" till that amusement grew stale. Then Joe and Huck had another -swim, but Tom would not venture, because he found that in kicking off -his trousers he had kicked his string of rattlesnake rattles off his -ankle, and he wondered how he had escaped cramp so long without the -protection of this mysterious charm. He did not venture again until he -had found it, and by that time the other boys were tired and ready to -rest. They gradually wandered apart, dropped into the "dumps," and fell -to gazing longingly across the wide river to where the village lay -drowsing in the sun. Tom found himself writing "BECKY" in the sand with -his big toe; he scratched it out, and was angry with himself for his -weakness. But he wrote it again, nevertheless; he could not help it. He -erased it once more and then took himself out of temptation by driving -the other boys together and joining them. - -But Joe's spirits had gone down almost beyond resurrection. He was so -homesick that he could hardly endure the misery of it. The tears lay -very near the surface. Huck was melancholy, too. Tom was downhearted, -but tried hard not to show it. He had a secret which he was not ready -to tell, yet, but if this mutinous depression was not broken up soon, -he would have to bring it out. He said, with a great show of -cheerfulness: - -"I bet there's been pirates on this island before, boys. We'll explore -it again. They've hid treasures here somewhere. How'd you feel to light -on a rotten chest full of gold and silver--hey?" - -But it roused only faint enthusiasm, which faded out, with no reply. -Tom tried one or two other seductions; but they failed, too. It was -discouraging work. Joe sat poking up the sand with a stick and looking -very gloomy. Finally he said: - -"Oh, boys, let's give it up. I want to go home. It's so lonesome." - -"Oh no, Joe, you'll feel better by and by," said Tom. "Just think of -the fishing that's here." - -"I don't care for fishing. I want to go home." - -"But, Joe, there ain't such another swimming-place anywhere." - -"Swimming's no good. I don't seem to care for it, somehow, when there -ain't anybody to say I sha'n't go in. I mean to go home." - -"Oh, shucks! Baby! You want to see your mother, I reckon." - -"Yes, I DO want to see my mother--and you would, too, if you had one. -I ain't any more baby than you are." And Joe snuffled a little. - -"Well, we'll let the cry-baby go home to his mother, won't we, Huck? -Poor thing--does it want to see its mother? And so it shall. You like -it here, don't you, Huck? We'll stay, won't we?" - -Huck said, "Y-e-s"--without any heart in it. - -"I'll never speak to you again as long as I live," said Joe, rising. -"There now!" And he moved moodily away and began to dress himself. - -"Who cares!" said Tom. "Nobody wants you to. Go 'long home and get -laughed at. Oh, you're a nice pirate. Huck and me ain't cry-babies. -We'll stay, won't we, Huck? Let him go if he wants to. I reckon we can -get along without him, per'aps." - -But Tom was uneasy, nevertheless, and was alarmed to see Joe go -sullenly on with his dressing. And then it was discomforting to see -Huck eying Joe's preparations so wistfully, and keeping up such an -ominous silence. Presently, without a parting word, Joe began to wade -off toward the Illinois shore. Tom's heart began to sink. He glanced at -Huck. Huck could not bear the look, and dropped his eyes. Then he said: - -"I want to go, too, Tom. It was getting so lonesome anyway, and now -it'll be worse. Let's us go, too, Tom." - -"I won't! You can all go, if you want to. I mean to stay." - -"Tom, I better go." - -"Well, go 'long--who's hendering you." - -Huck began to pick up his scattered clothes. He said: - -"Tom, I wisht you'd come, too. Now you think it over. We'll wait for -you when we get to shore." - -"Well, you'll wait a blame long time, that's all." - -Huck started sorrowfully away, and Tom stood looking after him, with a -strong desire tugging at his heart to yield his pride and go along too. -He hoped the boys would stop, but they still waded slowly on. It -suddenly dawned on Tom that it was become very lonely and still. He -made one final struggle with his pride, and then darted after his -comrades, yelling: - -"Wait! Wait! I want to tell you something!" - -They presently stopped and turned around. When he got to where they -were, he began unfolding his secret, and they listened moodily till at -last they saw the "point" he was driving at, and then they set up a -war-whoop of applause and said it was "splendid!" and said if he had -told them at first, they wouldn't have started away. He made a plausible -excuse; but his real reason had been the fear that not even the secret -would keep them with him any very great length of time, and so he had -meant to hold it in reserve as a last seduction. - -The lads came gayly back and went at their sports again with a will, -chattering all the time about Tom's stupendous plan and admiring the -genius of it. After a dainty egg and fish dinner, Tom said he wanted to -learn to smoke, now. Joe caught at the idea and said he would like to -try, too. So Huck made pipes and filled them. These novices had never -smoked anything before but cigars made of grape-vine, and they "bit" -the tongue, and were not considered manly anyway. - -Now they stretched themselves out on their elbows and began to puff, -charily, and with slender confidence. The smoke had an unpleasant -taste, and they gagged a little, but Tom said: - -"Why, it's just as easy! If I'd a knowed this was all, I'd a learnt -long ago." - -"So would I," said Joe. "It's just nothing." - -"Why, many a time I've looked at people smoking, and thought well I -wish I could do that; but I never thought I could," said Tom. - -"That's just the way with me, hain't it, Huck? You've heard me talk -just that way--haven't you, Huck? I'll leave it to Huck if I haven't." - -"Yes--heaps of times," said Huck. - -"Well, I have too," said Tom; "oh, hundreds of times. Once down by the -slaughter-house. Don't you remember, Huck? Bob Tanner was there, and -Johnny Miller, and Jeff Thatcher, when I said it. Don't you remember, -Huck, 'bout me saying that?" - -"Yes, that's so," said Huck. "That was the day after I lost a white -alley. No, 'twas the day before." - -"There--I told you so," said Tom. "Huck recollects it." - -"I bleeve I could smoke this pipe all day," said Joe. "I don't feel -sick." - -"Neither do I," said Tom. "I could smoke it all day. But I bet you -Jeff Thatcher couldn't." - -"Jeff Thatcher! Why, he'd keel over just with two draws. Just let him -try it once. HE'D see!" - -"I bet he would. And Johnny Miller--I wish could see Johnny Miller -tackle it once." - -"Oh, don't I!" said Joe. "Why, I bet you Johnny Miller couldn't any -more do this than nothing. Just one little snifter would fetch HIM." - -"'Deed it would, Joe. Say--I wish the boys could see us now." - -"So do I." - -"Say--boys, don't say anything about it, and some time when they're -around, I'll come up to you and say, 'Joe, got a pipe? I want a smoke.' -And you'll say, kind of careless like, as if it warn't anything, you'll -say, 'Yes, I got my OLD pipe, and another one, but my tobacker ain't -very good.' And I'll say, 'Oh, that's all right, if it's STRONG -enough.' And then you'll out with the pipes, and we'll light up just as -ca'm, and then just see 'em look!" - -"By jings, that'll be gay, Tom! I wish it was NOW!" - -"So do I! And when we tell 'em we learned when we was off pirating, -won't they wish they'd been along?" - -"Oh, I reckon not! I'll just BET they will!" - -So the talk ran on. But presently it began to flag a trifle, and grow -disjointed. The silences widened; the expectoration marvellously -increased. Every pore inside the boys' cheeks became a spouting -fountain; they could scarcely bail out the cellars under their tongues -fast enough to prevent an inundation; little overflowings down their -throats occurred in spite of all they could do, and sudden retchings -followed every time. Both boys were looking very pale and miserable, -now. Joe's pipe dropped from his nerveless fingers. Tom's followed. -Both fountains were going furiously and both pumps bailing with might -and main. Joe said feebly: - -"I've lost my knife. I reckon I better go and find it." - -Tom said, with quivering lips and halting utterance: - -"I'll help you. You go over that way and I'll hunt around by the -spring. No, you needn't come, Huck--we can find it." - -So Huck sat down again, and waited an hour. Then he found it lonesome, -and went to find his comrades. They were wide apart in the woods, both -very pale, both fast asleep. But something informed him that if they -had had any trouble they had got rid of it. - -They were not talkative at supper that night. They had a humble look, -and when Huck prepared his pipe after the meal and was going to prepare -theirs, they said no, they were not feeling very well--something they -ate at dinner had disagreed with them. - -About midnight Joe awoke, and called the boys. There was a brooding -oppressiveness in the air that seemed to bode something. The boys -huddled themselves together and sought the friendly companionship of -the fire, though the dull dead heat of the breathless atmosphere was -stifling. They sat still, intent and waiting. The solemn hush -continued. Beyond the light of the fire everything was swallowed up in -the blackness of darkness. Presently there came a quivering glow that -vaguely revealed the foliage for a moment and then vanished. By and by -another came, a little stronger. Then another. Then a faint moan came -sighing through the branches of the forest and the boys felt a fleeting -breath upon their cheeks, and shuddered with the fancy that the Spirit -of the Night had gone by. There was a pause. Now a weird flash turned -night into day and showed every little grass-blade, separate and -distinct, that grew about their feet. And it showed three white, -startled faces, too. A deep peal of thunder went rolling and tumbling -down the heavens and lost itself in sullen rumblings in the distance. A -sweep of chilly air passed by, rustling all the leaves and snowing the -flaky ashes broadcast about the fire. Another fierce glare lit up the -forest and an instant crash followed that seemed to rend the tree-tops -right over the boys' heads. They clung together in terror, in the thick -gloom that followed. A few big rain-drops fell pattering upon the -leaves. - -"Quick! boys, go for the tent!" exclaimed Tom. - -They sprang away, stumbling over roots and among vines in the dark, no -two plunging in the same direction. A furious blast roared through the -trees, making everything sing as it went. One blinding flash after -another came, and peal on peal of deafening thunder. And now a -drenching rain poured down and the rising hurricane drove it in sheets -along the ground. The boys cried out to each other, but the roaring -wind and the booming thunder-blasts drowned their voices utterly. -However, one by one they straggled in at last and took shelter under -the tent, cold, scared, and streaming with water; but to have company -in misery seemed something to be grateful for. They could not talk, the -old sail flapped so furiously, even if the other noises would have -allowed them. The tempest rose higher and higher, and presently the -sail tore loose from its fastenings and went winging away on the blast. -The boys seized each others' hands and fled, with many tumblings and -bruises, to the shelter of a great oak that stood upon the river-bank. -Now the battle was at its highest. Under the ceaseless conflagration of -lightning that flamed in the skies, everything below stood out in -clean-cut and shadowless distinctness: the bending trees, the billowy -river, white with foam, the driving spray of spume-flakes, the dim -outlines of the high bluffs on the other side, glimpsed through the -drifting cloud-rack and the slanting veil of rain. Every little while -some giant tree yielded the fight and fell crashing through the younger -growth; and the unflagging thunder-peals came now in ear-splitting -explosive bursts, keen and sharp, and unspeakably appalling. The storm -culminated in one matchless effort that seemed likely to tear the island -to pieces, burn it up, drown it to the tree-tops, blow it away, and -deafen every creature in it, all at one and the same moment. It was a -wild night for homeless young heads to be out in. - -But at last the battle was done, and the forces retired with weaker -and weaker threatenings and grumblings, and peace resumed her sway. The -boys went back to camp, a good deal awed; but they found there was -still something to be thankful for, because the great sycamore, the -shelter of their beds, was a ruin, now, blasted by the lightnings, and -they were not under it when the catastrophe happened. - -Everything in camp was drenched, the camp-fire as well; for they were -but heedless lads, like their generation, and had made no provision -against rain. Here was matter for dismay, for they were soaked through -and chilled. They were eloquent in their distress; but they presently -discovered that the fire had eaten so far up under the great log it had -been built against (where it curved upward and separated itself from -the ground), that a handbreadth or so of it had escaped wetting; so -they patiently wrought until, with shreds and bark gathered from the -under sides of sheltered logs, they coaxed the fire to burn again. Then -they piled on great dead boughs till they had a roaring furnace, and -were glad-hearted once more. They dried their boiled ham and had a -feast, and after that they sat by the fire and expanded and glorified -their midnight adventure until morning, for there was not a dry spot to -sleep on, anywhere around. - -As the sun began to steal in upon the boys, drowsiness came over them, -and they went out on the sandbar and lay down to sleep. They got -scorched out by and by, and drearily set about getting breakfast. After -the meal they felt rusty, and stiff-jointed, and a little homesick once -more. Tom saw the signs, and fell to cheering up the pirates as well as -he could. But they cared nothing for marbles, or circus, or swimming, -or anything. He reminded them of the imposing secret, and raised a ray -of cheer. While it lasted, he got them interested in a new device. This -was to knock off being pirates, for a while, and be Indians for a -change. They were attracted by this idea; so it was not long before -they were stripped, and striped from head to heel with black mud, like -so many zebras--all of them chiefs, of course--and then they went -tearing through the woods to attack an English settlement. - -By and by they separated into three hostile tribes, and darted upon -each other from ambush with dreadful war-whoops, and killed and scalped -each other by thousands. It was a gory day. Consequently it was an -extremely satisfactory one. - -They assembled in camp toward supper-time, hungry and happy; but now a -difficulty arose--hostile Indians could not break the bread of -hospitality together without first making peace, and this was a simple -impossibility without smoking a pipe of peace. There was no other -process that ever they had heard of. Two of the savages almost wished -they had remained pirates. However, there was no other way; so with -such show of cheerfulness as they could muster they called for the pipe -and took their whiff as it passed, in due form. - -And behold, they were glad they had gone into savagery, for they had -gained something; they found that they could now smoke a little without -having to go and hunt for a lost knife; they did not get sick enough to -be seriously uncomfortable. They were not likely to fool away this high -promise for lack of effort. No, they practised cautiously, after -supper, with right fair success, and so they spent a jubilant evening. -They were prouder and happier in their new acquirement than they would -have been in the scalping and skinning of the Six Nations. We will -leave them to smoke and chatter and brag, since we have no further use -for them at present. - - - -CHAPTER XVII - -BUT there was no hilarity in the little town that same tranquil -Saturday afternoon. The Harpers, and Aunt Polly's family, were being -put into mourning, with great grief and many tears. An unusual quiet -possessed the village, although it was ordinarily quiet enough, in all -conscience. The villagers conducted their concerns with an absent air, -and talked little; but they sighed often. The Saturday holiday seemed a -burden to the children. They had no heart in their sports, and -gradually gave them up. - -In the afternoon Becky Thatcher found herself moping about the -deserted schoolhouse yard, and feeling very melancholy. But she found -nothing there to comfort her. She soliloquized: - -"Oh, if I only had a brass andiron-knob again! But I haven't got -anything now to remember him by." And she choked back a little sob. - -Presently she stopped, and said to herself: - -"It was right here. Oh, if it was to do over again, I wouldn't say -that--I wouldn't say it for the whole world. But he's gone now; I'll -never, never, never see him any more." - -This thought broke her down, and she wandered away, with tears rolling -down her cheeks. Then quite a group of boys and girls--playmates of -Tom's and Joe's--came by, and stood looking over the paling fence and -talking in reverent tones of how Tom did so-and-so the last time they -saw him, and how Joe said this and that small trifle (pregnant with -awful prophecy, as they could easily see now!)--and each speaker -pointed out the exact spot where the lost lads stood at the time, and -then added something like "and I was a-standing just so--just as I am -now, and as if you was him--I was as close as that--and he smiled, just -this way--and then something seemed to go all over me, like--awful, you -know--and I never thought what it meant, of course, but I can see now!" - -Then there was a dispute about who saw the dead boys last in life, and -many claimed that dismal distinction, and offered evidences, more or -less tampered with by the witness; and when it was ultimately decided -who DID see the departed last, and exchanged the last words with them, -the lucky parties took upon themselves a sort of sacred importance, and -were gaped at and envied by all the rest. One poor chap, who had no -other grandeur to offer, said with tolerably manifest pride in the -remembrance: - -"Well, Tom Sawyer he licked me once." - -But that bid for glory was a failure. Most of the boys could say that, -and so that cheapened the distinction too much. The group loitered -away, still recalling memories of the lost heroes, in awed voices. - -When the Sunday-school hour was finished, the next morning, the bell -began to toll, instead of ringing in the usual way. It was a very still -Sabbath, and the mournful sound seemed in keeping with the musing hush -that lay upon nature. The villagers began to gather, loitering a moment -in the vestibule to converse in whispers about the sad event. But there -was no whispering in the house; only the funereal rustling of dresses -as the women gathered to their seats disturbed the silence there. None -could remember when the little church had been so full before. There -was finally a waiting pause, an expectant dumbness, and then Aunt Polly -entered, followed by Sid and Mary, and they by the Harper family, all -in deep black, and the whole congregation, the old minister as well, -rose reverently and stood until the mourners were seated in the front -pew. There was another communing silence, broken at intervals by -muffled sobs, and then the minister spread his hands abroad and prayed. -A moving hymn was sung, and the text followed: "I am the Resurrection -and the Life." - -As the service proceeded, the clergyman drew such pictures of the -graces, the winning ways, and the rare promise of the lost lads that -every soul there, thinking he recognized these pictures, felt a pang in -remembering that he had persistently blinded himself to them always -before, and had as persistently seen only faults and flaws in the poor -boys. The minister related many a touching incident in the lives of the -departed, too, which illustrated their sweet, generous natures, and the -people could easily see, now, how noble and beautiful those episodes -were, and remembered with grief that at the time they occurred they had -seemed rank rascalities, well deserving of the cowhide. The -congregation became more and more moved, as the pathetic tale went on, -till at last the whole company broke down and joined the weeping -mourners in a chorus of anguished sobs, the preacher himself giving way -to his feelings, and crying in the pulpit. - -There was a rustle in the gallery, which nobody noticed; a moment -later the church door creaked; the minister raised his streaming eyes -above his handkerchief, and stood transfixed! First one and then -another pair of eyes followed the minister's, and then almost with one -impulse the congregation rose and stared while the three dead boys came -marching up the aisle, Tom in the lead, Joe next, and Huck, a ruin of -drooping rags, sneaking sheepishly in the rear! They had been hid in -the unused gallery listening to their own funeral sermon! - -Aunt Polly, Mary, and the Harpers threw themselves upon their restored -ones, smothered them with kisses and poured out thanksgivings, while -poor Huck stood abashed and uncomfortable, not knowing exactly what to -do or where to hide from so many unwelcoming eyes. He wavered, and -started to slink away, but Tom seized him and said: - -"Aunt Polly, it ain't fair. Somebody's got to be glad to see Huck." - -"And so they shall. I'm glad to see him, poor motherless thing!" And -the loving attentions Aunt Polly lavished upon him were the one thing -capable of making him more uncomfortable than he was before. - -Suddenly the minister shouted at the top of his voice: "Praise God -from whom all blessings flow--SING!--and put your hearts in it!" - -And they did. Old Hundred swelled up with a triumphant burst, and -while it shook the rafters Tom Sawyer the Pirate looked around upon the -envying juveniles about him and confessed in his heart that this was -the proudest moment of his life. - -As the "sold" congregation trooped out they said they would almost be -willing to be made ridiculous again to hear Old Hundred sung like that -once more. - -Tom got more cuffs and kisses that day--according to Aunt Polly's -varying moods--than he had earned before in a year; and he hardly knew -which expressed the most gratefulness to God and affection for himself. - - - -CHAPTER XVIII - -THAT was Tom's great secret--the scheme to return home with his -brother pirates and attend their own funerals. They had paddled over to -the Missouri shore on a log, at dusk on Saturday, landing five or six -miles below the village; they had slept in the woods at the edge of the -town till nearly daylight, and had then crept through back lanes and -alleys and finished their sleep in the gallery of the church among a -chaos of invalided benches. - -At breakfast, Monday morning, Aunt Polly and Mary were very loving to -Tom, and very attentive to his wants. There was an unusual amount of -talk. In the course of it Aunt Polly said: - -"Well, I don't say it wasn't a fine joke, Tom, to keep everybody -suffering 'most a week so you boys had a good time, but it is a pity -you could be so hard-hearted as to let me suffer so. If you could come -over on a log to go to your funeral, you could have come over and give -me a hint some way that you warn't dead, but only run off." - -"Yes, you could have done that, Tom," said Mary; "and I believe you -would if you had thought of it." - -"Would you, Tom?" said Aunt Polly, her face lighting wistfully. "Say, -now, would you, if you'd thought of it?" - -"I--well, I don't know. 'Twould 'a' spoiled everything." - -"Tom, I hoped you loved me that much," said Aunt Polly, with a grieved -tone that discomforted the boy. "It would have been something if you'd -cared enough to THINK of it, even if you didn't DO it." - -"Now, auntie, that ain't any harm," pleaded Mary; "it's only Tom's -giddy way--he is always in such a rush that he never thinks of -anything." - -"More's the pity. Sid would have thought. And Sid would have come and -DONE it, too. Tom, you'll look back, some day, when it's too late, and -wish you'd cared a little more for me when it would have cost you so -little." - -"Now, auntie, you know I do care for you," said Tom. - -"I'd know it better if you acted more like it." - -"I wish now I'd thought," said Tom, with a repentant tone; "but I -dreamt about you, anyway. That's something, ain't it?" - -"It ain't much--a cat does that much--but it's better than nothing. -What did you dream?" - -"Why, Wednesday night I dreamt that you was sitting over there by the -bed, and Sid was sitting by the woodbox, and Mary next to him." - -"Well, so we did. So we always do. I'm glad your dreams could take -even that much trouble about us." - -"And I dreamt that Joe Harper's mother was here." - -"Why, she was here! Did you dream any more?" - -"Oh, lots. But it's so dim, now." - -"Well, try to recollect--can't you?" - -"Somehow it seems to me that the wind--the wind blowed the--the--" - -"Try harder, Tom! The wind did blow something. Come!" - -Tom pressed his fingers on his forehead an anxious minute, and then -said: - -"I've got it now! I've got it now! It blowed the candle!" - -"Mercy on us! Go on, Tom--go on!" - -"And it seems to me that you said, 'Why, I believe that that door--'" - -"Go ON, Tom!" - -"Just let me study a moment--just a moment. Oh, yes--you said you -believed the door was open." - -"As I'm sitting here, I did! Didn't I, Mary! Go on!" - -"And then--and then--well I won't be certain, but it seems like as if -you made Sid go and--and--" - -"Well? Well? What did I make him do, Tom? What did I make him do?" - -"You made him--you--Oh, you made him shut it." - -"Well, for the land's sake! I never heard the beat of that in all my -days! Don't tell ME there ain't anything in dreams, any more. Sereny -Harper shall know of this before I'm an hour older. I'd like to see her -get around THIS with her rubbage 'bout superstition. Go on, Tom!" - -"Oh, it's all getting just as bright as day, now. Next you said I -warn't BAD, only mischeevous and harum-scarum, and not any more -responsible than--than--I think it was a colt, or something." - -"And so it was! Well, goodness gracious! Go on, Tom!" - -"And then you began to cry." - -"So I did. So I did. Not the first time, neither. And then--" - -"Then Mrs. Harper she began to cry, and said Joe was just the same, -and she wished she hadn't whipped him for taking cream when she'd -throwed it out her own self--" - -"Tom! The sperrit was upon you! You was a prophesying--that's what you -was doing! Land alive, go on, Tom!" - -"Then Sid he said--he said--" - -"I don't think I said anything," said Sid. - -"Yes you did, Sid," said Mary. - -"Shut your heads and let Tom go on! What did he say, Tom?" - -"He said--I THINK he said he hoped I was better off where I was gone -to, but if I'd been better sometimes--" - -"THERE, d'you hear that! It was his very words!" - -"And you shut him up sharp." - -"I lay I did! There must 'a' been an angel there. There WAS an angel -there, somewheres!" - -"And Mrs. Harper told about Joe scaring her with a firecracker, and -you told about Peter and the Painkiller--" - -"Just as true as I live!" - -"And then there was a whole lot of talk 'bout dragging the river for -us, and 'bout having the funeral Sunday, and then you and old Miss -Harper hugged and cried, and she went." - -"It happened just so! It happened just so, as sure as I'm a-sitting in -these very tracks. Tom, you couldn't told it more like if you'd 'a' -seen it! And then what? Go on, Tom!" - -"Then I thought you prayed for me--and I could see you and hear every -word you said. And you went to bed, and I was so sorry that I took and -wrote on a piece of sycamore bark, 'We ain't dead--we are only off -being pirates,' and put it on the table by the candle; and then you -looked so good, laying there asleep, that I thought I went and leaned -over and kissed you on the lips." - -"Did you, Tom, DID you! I just forgive you everything for that!" And -she seized the boy in a crushing embrace that made him feel like the -guiltiest of villains. - -"It was very kind, even though it was only a--dream," Sid soliloquized -just audibly. - -"Shut up, Sid! A body does just the same in a dream as he'd do if he -was awake. Here's a big Milum apple I've been saving for you, Tom, if -you was ever found again--now go 'long to school. I'm thankful to the -good God and Father of us all I've got you back, that's long-suffering -and merciful to them that believe on Him and keep His word, though -goodness knows I'm unworthy of it, but if only the worthy ones got His -blessings and had His hand to help them over the rough places, there's -few enough would smile here or ever enter into His rest when the long -night comes. Go 'long Sid, Mary, Tom--take yourselves off--you've -hendered me long enough." - -The children left for school, and the old lady to call on Mrs. Harper -and vanquish her realism with Tom's marvellous dream. Sid had better -judgment than to utter the thought that was in his mind as he left the -house. It was this: "Pretty thin--as long a dream as that, without any -mistakes in it!" - -What a hero Tom was become, now! He did not go skipping and prancing, -but moved with a dignified swagger as became a pirate who felt that the -public eye was on him. And indeed it was; he tried not to seem to see -the looks or hear the remarks as he passed along, but they were food -and drink to him. Smaller boys than himself flocked at his heels, as -proud to be seen with him, and tolerated by him, as if he had been the -drummer at the head of a procession or the elephant leading a menagerie -into town. Boys of his own size pretended not to know he had been away -at all; but they were consuming with envy, nevertheless. They would -have given anything to have that swarthy suntanned skin of his, and his -glittering notoriety; and Tom would not have parted with either for a -circus. - -At school the children made so much of him and of Joe, and delivered -such eloquent admiration from their eyes, that the two heroes were not -long in becoming insufferably "stuck-up." They began to tell their -adventures to hungry listeners--but they only began; it was not a thing -likely to have an end, with imaginations like theirs to furnish -material. And finally, when they got out their pipes and went serenely -puffing around, the very summit of glory was reached. - -Tom decided that he could be independent of Becky Thatcher now. Glory -was sufficient. He would live for glory. Now that he was distinguished, -maybe she would be wanting to "make up." Well, let her--she should see -that he could be as indifferent as some other people. Presently she -arrived. Tom pretended not to see her. He moved away and joined a group -of boys and girls and began to talk. Soon he observed that she was -tripping gayly back and forth with flushed face and dancing eyes, -pretending to be busy chasing schoolmates, and screaming with laughter -when she made a capture; but he noticed that she always made her -captures in his vicinity, and that she seemed to cast a conscious eye -in his direction at such times, too. It gratified all the vicious -vanity that was in him; and so, instead of winning him, it only "set -him up" the more and made him the more diligent to avoid betraying that -he knew she was about. Presently she gave over skylarking, and moved -irresolutely about, sighing once or twice and glancing furtively and -wistfully toward Tom. Then she observed that now Tom was talking more -particularly to Amy Lawrence than to any one else. She felt a sharp -pang and grew disturbed and uneasy at once. She tried to go away, but -her feet were treacherous, and carried her to the group instead. She -said to a girl almost at Tom's elbow--with sham vivacity: - -"Why, Mary Austin! you bad girl, why didn't you come to Sunday-school?" - -"I did come--didn't you see me?" - -"Why, no! Did you? Where did you sit?" - -"I was in Miss Peters' class, where I always go. I saw YOU." - -"Did you? Why, it's funny I didn't see you. I wanted to tell you about -the picnic." - -"Oh, that's jolly. Who's going to give it?" - -"My ma's going to let me have one." - -"Oh, goody; I hope she'll let ME come." - -"Well, she will. The picnic's for me. She'll let anybody come that I -want, and I want you." - -"That's ever so nice. When is it going to be?" - -"By and by. Maybe about vacation." - -"Oh, won't it be fun! You going to have all the girls and boys?" - -"Yes, every one that's friends to me--or wants to be"; and she glanced -ever so furtively at Tom, but he talked right along to Amy Lawrence -about the terrible storm on the island, and how the lightning tore the -great sycamore tree "all to flinders" while he was "standing within -three feet of it." - -"Oh, may I come?" said Grace Miller. - -"Yes." - -"And me?" said Sally Rogers. - -"Yes." - -"And me, too?" said Susy Harper. "And Joe?" - -"Yes." - -And so on, with clapping of joyful hands till all the group had begged -for invitations but Tom and Amy. Then Tom turned coolly away, still -talking, and took Amy with him. Becky's lips trembled and the tears -came to her eyes; she hid these signs with a forced gayety and went on -chattering, but the life had gone out of the picnic, now, and out of -everything else; she got away as soon as she could and hid herself and -had what her sex call "a good cry." Then she sat moody, with wounded -pride, till the bell rang. She roused up, now, with a vindictive cast -in her eye, and gave her plaited tails a shake and said she knew what -SHE'D do. - -At recess Tom continued his flirtation with Amy with jubilant -self-satisfaction. And he kept drifting about to find Becky and lacerate -her with the performance. At last he spied her, but there was a sudden -falling of his mercury. She was sitting cosily on a little bench behind -the schoolhouse looking at a picture-book with Alfred Temple--and so -absorbed were they, and their heads so close together over the book, -that they did not seem to be conscious of anything in the world besides. -Jealousy ran red-hot through Tom's veins. He began to hate himself for -throwing away the chance Becky had offered for a reconciliation. He -called himself a fool, and all the hard names he could think of. He -wanted to cry with vexation. Amy chatted happily along, as they walked, -for her heart was singing, but Tom's tongue had lost its function. He -did not hear what Amy was saying, and whenever she paused expectantly he -could only stammer an awkward assent, which was as often misplaced as -otherwise. He kept drifting to the rear of the schoolhouse, again and -again, to sear his eyeballs with the hateful spectacle there. He could -not help it. And it maddened him to see, as he thought he saw, that -Becky Thatcher never once suspected that he was even in the land of the -living. But she did see, nevertheless; and she knew she was winning her -fight, too, and was glad to see him suffer as she had suffered. - -Amy's happy prattle became intolerable. Tom hinted at things he had to -attend to; things that must be done; and time was fleeting. But in -vain--the girl chirped on. Tom thought, "Oh, hang her, ain't I ever -going to get rid of her?" At last he must be attending to those -things--and she said artlessly that she would be "around" when school -let out. And he hastened away, hating her for it. - -"Any other boy!" Tom thought, grating his teeth. "Any boy in the whole -town but that Saint Louis smarty that thinks he dresses so fine and is -aristocracy! Oh, all right, I licked you the first day you ever saw -this town, mister, and I'll lick you again! You just wait till I catch -you out! I'll just take and--" - -And he went through the motions of thrashing an imaginary boy ---pummelling the air, and kicking and gouging. "Oh, you do, do you? You -holler 'nough, do you? Now, then, let that learn you!" And so the -imaginary flogging was finished to his satisfaction. - -Tom fled home at noon. His conscience could not endure any more of -Amy's grateful happiness, and his jealousy could bear no more of the -other distress. Becky resumed her picture inspections with Alfred, but -as the minutes dragged along and no Tom came to suffer, her triumph -began to cloud and she lost interest; gravity and absent-mindedness -followed, and then melancholy; two or three times she pricked up her -ear at a footstep, but it was a false hope; no Tom came. At last she -grew entirely miserable and wished she hadn't carried it so far. When -poor Alfred, seeing that he was losing her, he did not know how, kept -exclaiming: "Oh, here's a jolly one! look at this!" she lost patience -at last, and said, "Oh, don't bother me! I don't care for them!" and -burst into tears, and got up and walked away. - -Alfred dropped alongside and was going to try to comfort her, but she -said: - -"Go away and leave me alone, can't you! I hate you!" - -So the boy halted, wondering what he could have done--for she had said -she would look at pictures all through the nooning--and she walked on, -crying. Then Alfred went musing into the deserted schoolhouse. He was -humiliated and angry. He easily guessed his way to the truth--the girl -had simply made a convenience of him to vent her spite upon Tom Sawyer. -He was far from hating Tom the less when this thought occurred to him. -He wished there was some way to get that boy into trouble without much -risk to himself. Tom's spelling-book fell under his eye. Here was his -opportunity. He gratefully opened to the lesson for the afternoon and -poured ink upon the page. - -Becky, glancing in at a window behind him at the moment, saw the act, -and moved on, without discovering herself. She started homeward, now, -intending to find Tom and tell him; Tom would be thankful and their -troubles would be healed. Before she was half way home, however, she -had changed her mind. The thought of Tom's treatment of her when she -was talking about her picnic came scorching back and filled her with -shame. She resolved to let him get whipped on the damaged -spelling-book's account, and to hate him forever, into the bargain. - - - -CHAPTER XIX - -TOM arrived at home in a dreary mood, and the first thing his aunt -said to him showed him that he had brought his sorrows to an -unpromising market: - -"Tom, I've a notion to skin you alive!" - -"Auntie, what have I done?" - -"Well, you've done enough. Here I go over to Sereny Harper, like an -old softy, expecting I'm going to make her believe all that rubbage -about that dream, when lo and behold you she'd found out from Joe that -you was over here and heard all the talk we had that night. Tom, I -don't know what is to become of a boy that will act like that. It makes -me feel so bad to think you could let me go to Sereny Harper and make -such a fool of myself and never say a word." - -This was a new aspect of the thing. His smartness of the morning had -seemed to Tom a good joke before, and very ingenious. It merely looked -mean and shabby now. He hung his head and could not think of anything -to say for a moment. Then he said: - -"Auntie, I wish I hadn't done it--but I didn't think." - -"Oh, child, you never think. You never think of anything but your own -selfishness. You could think to come all the way over here from -Jackson's Island in the night to laugh at our troubles, and you could -think to fool me with a lie about a dream; but you couldn't ever think -to pity us and save us from sorrow." - -"Auntie, I know now it was mean, but I didn't mean to be mean. I -didn't, honest. And besides, I didn't come over here to laugh at you -that night." - -"What did you come for, then?" - -"It was to tell you not to be uneasy about us, because we hadn't got -drownded." - -"Tom, Tom, I would be the thankfullest soul in this world if I could -believe you ever had as good a thought as that, but you know you never -did--and I know it, Tom." - -"Indeed and 'deed I did, auntie--I wish I may never stir if I didn't." - -"Oh, Tom, don't lie--don't do it. It only makes things a hundred times -worse." - -"It ain't a lie, auntie; it's the truth. I wanted to keep you from -grieving--that was all that made me come." - -"I'd give the whole world to believe that--it would cover up a power -of sins, Tom. I'd 'most be glad you'd run off and acted so bad. But it -ain't reasonable; because, why didn't you tell me, child?" - -"Why, you see, when you got to talking about the funeral, I just got -all full of the idea of our coming and hiding in the church, and I -couldn't somehow bear to spoil it. So I just put the bark back in my -pocket and kept mum." - -"What bark?" - -"The bark I had wrote on to tell you we'd gone pirating. I wish, now, -you'd waked up when I kissed you--I do, honest." - -The hard lines in his aunt's face relaxed and a sudden tenderness -dawned in her eyes. - -"DID you kiss me, Tom?" - -"Why, yes, I did." - -"Are you sure you did, Tom?" - -"Why, yes, I did, auntie--certain sure." - -"What did you kiss me for, Tom?" - -"Because I loved you so, and you laid there moaning and I was so sorry." - -The words sounded like truth. The old lady could not hide a tremor in -her voice when she said: - -"Kiss me again, Tom!--and be off with you to school, now, and don't -bother me any more." - -The moment he was gone, she ran to a closet and got out the ruin of a -jacket which Tom had gone pirating in. Then she stopped, with it in her -hand, and said to herself: - -"No, I don't dare. Poor boy, I reckon he's lied about it--but it's a -blessed, blessed lie, there's such a comfort come from it. I hope the -Lord--I KNOW the Lord will forgive him, because it was such -goodheartedness in him to tell it. But I don't want to find out it's a -lie. I won't look." - -She put the jacket away, and stood by musing a minute. Twice she put -out her hand to take the garment again, and twice she refrained. Once -more she ventured, and this time she fortified herself with the -thought: "It's a good lie--it's a good lie--I won't let it grieve me." -So she sought the jacket pocket. A moment later she was reading Tom's -piece of bark through flowing tears and saying: "I could forgive the -boy, now, if he'd committed a million sins!" - - - -CHAPTER XX - -THERE was something about Aunt Polly's manner, when she kissed Tom, -that swept away his low spirits and made him lighthearted and happy -again. He started to school and had the luck of coming upon Becky -Thatcher at the head of Meadow Lane. His mood always determined his -manner. Without a moment's hesitation he ran to her and said: - -"I acted mighty mean to-day, Becky, and I'm so sorry. I won't ever, -ever do that way again, as long as ever I live--please make up, won't -you?" - -The girl stopped and looked him scornfully in the face: - -"I'll thank you to keep yourself TO yourself, Mr. Thomas Sawyer. I'll -never speak to you again." - -She tossed her head and passed on. Tom was so stunned that he had not -even presence of mind enough to say "Who cares, Miss Smarty?" until the -right time to say it had gone by. So he said nothing. But he was in a -fine rage, nevertheless. He moped into the schoolyard wishing she were -a boy, and imagining how he would trounce her if she were. He presently -encountered her and delivered a stinging remark as he passed. She -hurled one in return, and the angry breach was complete. It seemed to -Becky, in her hot resentment, that she could hardly wait for school to -"take in," she was so impatient to see Tom flogged for the injured -spelling-book. If she had had any lingering notion of exposing Alfred -Temple, Tom's offensive fling had driven it entirely away. - -Poor girl, she did not know how fast she was nearing trouble herself. -The master, Mr. Dobbins, had reached middle age with an unsatisfied -ambition. The darling of his desires was, to be a doctor, but poverty -had decreed that he should be nothing higher than a village -schoolmaster. Every day he took a mysterious book out of his desk and -absorbed himself in it at times when no classes were reciting. He kept -that book under lock and key. There was not an urchin in school but was -perishing to have a glimpse of it, but the chance never came. Every boy -and girl had a theory about the nature of that book; but no two -theories were alike, and there was no way of getting at the facts in -the case. Now, as Becky was passing by the desk, which stood near the -door, she noticed that the key was in the lock! It was a precious -moment. She glanced around; found herself alone, and the next instant -she had the book in her hands. The title-page--Professor Somebody's -ANATOMY--carried no information to her mind; so she began to turn the -leaves. She came at once upon a handsomely engraved and colored -frontispiece--a human figure, stark naked. At that moment a shadow fell -on the page and Tom Sawyer stepped in at the door and caught a glimpse -of the picture. Becky snatched at the book to close it, and had the -hard luck to tear the pictured page half down the middle. She thrust -the volume into the desk, turned the key, and burst out crying with -shame and vexation. - -"Tom Sawyer, you are just as mean as you can be, to sneak up on a -person and look at what they're looking at." - -"How could I know you was looking at anything?" - -"You ought to be ashamed of yourself, Tom Sawyer; you know you're -going to tell on me, and oh, what shall I do, what shall I do! I'll be -whipped, and I never was whipped in school." - -Then she stamped her little foot and said: - -"BE so mean if you want to! I know something that's going to happen. -You just wait and you'll see! Hateful, hateful, hateful!"--and she -flung out of the house with a new explosion of crying. - -Tom stood still, rather flustered by this onslaught. Presently he said -to himself: - -"What a curious kind of a fool a girl is! Never been licked in school! -Shucks! What's a licking! That's just like a girl--they're so -thin-skinned and chicken-hearted. Well, of course I ain't going to tell -old Dobbins on this little fool, because there's other ways of getting -even on her, that ain't so mean; but what of it? Old Dobbins will ask -who it was tore his book. Nobody'll answer. Then he'll do just the way -he always does--ask first one and then t'other, and when he comes to the -right girl he'll know it, without any telling. Girls' faces always tell -on them. They ain't got any backbone. She'll get licked. Well, it's a -kind of a tight place for Becky Thatcher, because there ain't any way -out of it." Tom conned the thing a moment longer, and then added: "All -right, though; she'd like to see me in just such a fix--let her sweat it -out!" - -Tom joined the mob of skylarking scholars outside. In a few moments -the master arrived and school "took in." Tom did not feel a strong -interest in his studies. Every time he stole a glance at the girls' -side of the room Becky's face troubled him. Considering all things, he -did not want to pity her, and yet it was all he could do to help it. He -could get up no exultation that was really worthy the name. Presently -the spelling-book discovery was made, and Tom's mind was entirely full -of his own matters for a while after that. Becky roused up from her -lethargy of distress and showed good interest in the proceedings. She -did not expect that Tom could get out of his trouble by denying that he -spilt the ink on the book himself; and she was right. The denial only -seemed to make the thing worse for Tom. Becky supposed she would be -glad of that, and she tried to believe she was glad of it, but she -found she was not certain. When the worst came to the worst, she had an -impulse to get up and tell on Alfred Temple, but she made an effort and -forced herself to keep still--because, said she to herself, "he'll tell -about me tearing the picture sure. I wouldn't say a word, not to save -his life!" - -Tom took his whipping and went back to his seat not at all -broken-hearted, for he thought it was possible that he had unknowingly -upset the ink on the spelling-book himself, in some skylarking bout--he -had denied it for form's sake and because it was custom, and had stuck -to the denial from principle. - -A whole hour drifted by, the master sat nodding in his throne, the air -was drowsy with the hum of study. By and by, Mr. Dobbins straightened -himself up, yawned, then unlocked his desk, and reached for his book, -but seemed undecided whether to take it out or leave it. Most of the -pupils glanced up languidly, but there were two among them that watched -his movements with intent eyes. Mr. Dobbins fingered his book absently -for a while, then took it out and settled himself in his chair to read! -Tom shot a glance at Becky. He had seen a hunted and helpless rabbit -look as she did, with a gun levelled at its head. Instantly he forgot -his quarrel with her. Quick--something must be done! done in a flash, -too! But the very imminence of the emergency paralyzed his invention. -Good!--he had an inspiration! He would run and snatch the book, spring -through the door and fly. But his resolution shook for one little -instant, and the chance was lost--the master opened the volume. If Tom -only had the wasted opportunity back again! Too late. There was no help -for Becky now, he said. The next moment the master faced the school. -Every eye sank under his gaze. There was that in it which smote even -the innocent with fear. There was silence while one might count ten ---the master was gathering his wrath. Then he spoke: "Who tore this book?" - -There was not a sound. One could have heard a pin drop. The stillness -continued; the master searched face after face for signs of guilt. - -"Benjamin Rogers, did you tear this book?" - -A denial. Another pause. - -"Joseph Harper, did you?" - -Another denial. Tom's uneasiness grew more and more intense under the -slow torture of these proceedings. The master scanned the ranks of -boys--considered a while, then turned to the girls: - -"Amy Lawrence?" - -A shake of the head. - -"Gracie Miller?" - -The same sign. - -"Susan Harper, did you do this?" - -Another negative. The next girl was Becky Thatcher. Tom was trembling -from head to foot with excitement and a sense of the hopelessness of -the situation. - -"Rebecca Thatcher" [Tom glanced at her face--it was white with terror] ---"did you tear--no, look me in the face" [her hands rose in appeal] ---"did you tear this book?" - -A thought shot like lightning through Tom's brain. He sprang to his -feet and shouted--"I done it!" - -The school stared in perplexity at this incredible folly. Tom stood a -moment, to gather his dismembered faculties; and when he stepped -forward to go to his punishment the surprise, the gratitude, the -adoration that shone upon him out of poor Becky's eyes seemed pay -enough for a hundred floggings. Inspired by the splendor of his own -act, he took without an outcry the most merciless flaying that even Mr. -Dobbins had ever administered; and also received with indifference the -added cruelty of a command to remain two hours after school should be -dismissed--for he knew who would wait for him outside till his -captivity was done, and not count the tedious time as loss, either. - -Tom went to bed that night planning vengeance against Alfred Temple; -for with shame and repentance Becky had told him all, not forgetting -her own treachery; but even the longing for vengeance had to give way, -soon, to pleasanter musings, and he fell asleep at last with Becky's -latest words lingering dreamily in his ear-- - -"Tom, how COULD you be so noble!" - - - -CHAPTER XXI - -VACATION was approaching. The schoolmaster, always severe, grew -severer and more exacting than ever, for he wanted the school to make a -good showing on "Examination" day. His rod and his ferule were seldom -idle now--at least among the smaller pupils. Only the biggest boys, and -young ladies of eighteen and twenty, escaped lashing. Mr. Dobbins' -lashings were very vigorous ones, too; for although he carried, under -his wig, a perfectly bald and shiny head, he had only reached middle -age, and there was no sign of feebleness in his muscle. As the great -day approached, all the tyranny that was in him came to the surface; he -seemed to take a vindictive pleasure in punishing the least -shortcomings. The consequence was, that the smaller boys spent their -days in terror and suffering and their nights in plotting revenge. They -threw away no opportunity to do the master a mischief. But he kept -ahead all the time. The retribution that followed every vengeful -success was so sweeping and majestic that the boys always retired from -the field badly worsted. At last they conspired together and hit upon a -plan that promised a dazzling victory. They swore in the sign-painter's -boy, told him the scheme, and asked his help. He had his own reasons -for being delighted, for the master boarded in his father's family and -had given the boy ample cause to hate him. The master's wife would go -on a visit to the country in a few days, and there would be nothing to -interfere with the plan; the master always prepared himself for great -occasions by getting pretty well fuddled, and the sign-painter's boy -said that when the dominie had reached the proper condition on -Examination Evening he would "manage the thing" while he napped in his -chair; then he would have him awakened at the right time and hurried -away to school. - -In the fulness of time the interesting occasion arrived. At eight in -the evening the schoolhouse was brilliantly lighted, and adorned with -wreaths and festoons of foliage and flowers. The master sat throned in -his great chair upon a raised platform, with his blackboard behind him. -He was looking tolerably mellow. Three rows of benches on each side and -six rows in front of him were occupied by the dignitaries of the town -and by the parents of the pupils. To his left, back of the rows of -citizens, was a spacious temporary platform upon which were seated the -scholars who were to take part in the exercises of the evening; rows of -small boys, washed and dressed to an intolerable state of discomfort; -rows of gawky big boys; snowbanks of girls and young ladies clad in -lawn and muslin and conspicuously conscious of their bare arms, their -grandmothers' ancient trinkets, their bits of pink and blue ribbon and -the flowers in their hair. All the rest of the house was filled with -non-participating scholars. - -The exercises began. A very little boy stood up and sheepishly -recited, "You'd scarce expect one of my age to speak in public on the -stage," etc.--accompanying himself with the painfully exact and -spasmodic gestures which a machine might have used--supposing the -machine to be a trifle out of order. But he got through safely, though -cruelly scared, and got a fine round of applause when he made his -manufactured bow and retired. - -A little shamefaced girl lisped, "Mary had a little lamb," etc., -performed a compassion-inspiring curtsy, got her meed of applause, and -sat down flushed and happy. - -Tom Sawyer stepped forward with conceited confidence and soared into -the unquenchable and indestructible "Give me liberty or give me death" -speech, with fine fury and frantic gesticulation, and broke down in the -middle of it. A ghastly stage-fright seized him, his legs quaked under -him and he was like to choke. True, he had the manifest sympathy of the -house but he had the house's silence, too, which was even worse than -its sympathy. The master frowned, and this completed the disaster. Tom -struggled awhile and then retired, utterly defeated. There was a weak -attempt at applause, but it died early. - -"The Boy Stood on the Burning Deck" followed; also "The Assyrian Came -Down," and other declamatory gems. Then there were reading exercises, -and a spelling fight. The meagre Latin class recited with honor. The -prime feature of the evening was in order, now--original "compositions" -by the young ladies. Each in her turn stepped forward to the edge of -the platform, cleared her throat, held up her manuscript (tied with -dainty ribbon), and proceeded to read, with labored attention to -"expression" and punctuation. The themes were the same that had been -illuminated upon similar occasions by their mothers before them, their -grandmothers, and doubtless all their ancestors in the female line -clear back to the Crusades. "Friendship" was one; "Memories of Other -Days"; "Religion in History"; "Dream Land"; "The Advantages of -Culture"; "Forms of Political Government Compared and Contrasted"; -"Melancholy"; "Filial Love"; "Heart Longings," etc., etc. - -A prevalent feature in these compositions was a nursed and petted -melancholy; another was a wasteful and opulent gush of "fine language"; -another was a tendency to lug in by the ears particularly prized words -and phrases until they were worn entirely out; and a peculiarity that -conspicuously marked and marred them was the inveterate and intolerable -sermon that wagged its crippled tail at the end of each and every one -of them. No matter what the subject might be, a brain-racking effort -was made to squirm it into some aspect or other that the moral and -religious mind could contemplate with edification. The glaring -insincerity of these sermons was not sufficient to compass the -banishment of the fashion from the schools, and it is not sufficient -to-day; it never will be sufficient while the world stands, perhaps. -There is no school in all our land where the young ladies do not feel -obliged to close their compositions with a sermon; and you will find -that the sermon of the most frivolous and the least religious girl in -the school is always the longest and the most relentlessly pious. But -enough of this. Homely truth is unpalatable. - -Let us return to the "Examination." The first composition that was -read was one entitled "Is this, then, Life?" Perhaps the reader can -endure an extract from it: - - "In the common walks of life, with what delightful - emotions does the youthful mind look forward to some - anticipated scene of festivity! Imagination is busy - sketching rose-tinted pictures of joy. In fancy, the - voluptuous votary of fashion sees herself amid the - festive throng, 'the observed of all observers.' Her - graceful form, arrayed in snowy robes, is whirling - through the mazes of the joyous dance; her eye is - brightest, her step is lightest in the gay assembly. - - "In such delicious fancies time quickly glides by, - and the welcome hour arrives for her entrance into - the Elysian world, of which she has had such bright - dreams. How fairy-like does everything appear to - her enchanted vision! Each new scene is more charming - than the last. But after a while she finds that - beneath this goodly exterior, all is vanity, the - flattery which once charmed her soul, now grates - harshly upon her ear; the ball-room has lost its - charms; and with wasted health and imbittered heart, - she turns away with the conviction that earthly - pleasures cannot satisfy the longings of the soul!" - -And so forth and so on. There was a buzz of gratification from time to -time during the reading, accompanied by whispered ejaculations of "How -sweet!" "How eloquent!" "So true!" etc., and after the thing had closed -with a peculiarly afflicting sermon the applause was enthusiastic. - -Then arose a slim, melancholy girl, whose face had the "interesting" -paleness that comes of pills and indigestion, and read a "poem." Two -stanzas of it will do: - - "A MISSOURI MAIDEN'S FAREWELL TO ALABAMA - - "Alabama, good-bye! I love thee well! - But yet for a while do I leave thee now! - Sad, yes, sad thoughts of thee my heart doth swell, - And burning recollections throng my brow! - For I have wandered through thy flowery woods; - Have roamed and read near Tallapoosa's stream; - Have listened to Tallassee's warring floods, - And wooed on Coosa's side Aurora's beam. - - "Yet shame I not to bear an o'er-full heart, - Nor blush to turn behind my tearful eyes; - 'Tis from no stranger land I now must part, - 'Tis to no strangers left I yield these sighs. - Welcome and home were mine within this State, - Whose vales I leave--whose spires fade fast from me - And cold must be mine eyes, and heart, and tete, - When, dear Alabama! they turn cold on thee!" - -There were very few there who knew what "tete" meant, but the poem was -very satisfactory, nevertheless. - -Next appeared a dark-complexioned, black-eyed, black-haired young -lady, who paused an impressive moment, assumed a tragic expression, and -began to read in a measured, solemn tone: - - "A VISION - - "Dark and tempestuous was night. Around the - throne on high not a single star quivered; but - the deep intonations of the heavy thunder - constantly vibrated upon the ear; whilst the - terrific lightning revelled in angry mood - through the cloudy chambers of heaven, seeming - to scorn the power exerted over its terror by - the illustrious Franklin! Even the boisterous - winds unanimously came forth from their mystic - homes, and blustered about as if to enhance by - their aid the wildness of the scene. - - "At such a time, so dark, so dreary, for human - sympathy my very spirit sighed; but instead thereof, - - "'My dearest friend, my counsellor, my comforter - and guide--My joy in grief, my second bliss - in joy,' came to my side. She moved like one of - those bright beings pictured in the sunny walks - of fancy's Eden by the romantic and young, a - queen of beauty unadorned save by her own - transcendent loveliness. So soft was her step, it - failed to make even a sound, and but for the - magical thrill imparted by her genial touch, as - other unobtrusive beauties, she would have glided - away un-perceived--unsought. A strange sadness - rested upon her features, like icy tears upon - the robe of December, as she pointed to the - contending elements without, and bade me contemplate - the two beings presented." - -This nightmare occupied some ten pages of manuscript and wound up with -a sermon so destructive of all hope to non-Presbyterians that it took -the first prize. This composition was considered to be the very finest -effort of the evening. The mayor of the village, in delivering the -prize to the author of it, made a warm speech in which he said that it -was by far the most "eloquent" thing he had ever listened to, and that -Daniel Webster himself might well be proud of it. - -It may be remarked, in passing, that the number of compositions in -which the word "beauteous" was over-fondled, and human experience -referred to as "life's page," was up to the usual average. - -Now the master, mellow almost to the verge of geniality, put his chair -aside, turned his back to the audience, and began to draw a map of -America on the blackboard, to exercise the geography class upon. But he -made a sad business of it with his unsteady hand, and a smothered -titter rippled over the house. He knew what the matter was, and set -himself to right it. He sponged out lines and remade them; but he only -distorted them more than ever, and the tittering was more pronounced. -He threw his entire attention upon his work, now, as if determined not -to be put down by the mirth. He felt that all eyes were fastened upon -him; he imagined he was succeeding, and yet the tittering continued; it -even manifestly increased. And well it might. There was a garret above, -pierced with a scuttle over his head; and down through this scuttle -came a cat, suspended around the haunches by a string; she had a rag -tied about her head and jaws to keep her from mewing; as she slowly -descended she curved upward and clawed at the string, she swung -downward and clawed at the intangible air. The tittering rose higher -and higher--the cat was within six inches of the absorbed teacher's -head--down, down, a little lower, and she grabbed his wig with her -desperate claws, clung to it, and was snatched up into the garret in an -instant with her trophy still in her possession! And how the light did -blaze abroad from the master's bald pate--for the sign-painter's boy -had GILDED it! - -That broke up the meeting. The boys were avenged. Vacation had come. - - NOTE:--The pretended "compositions" quoted in - this chapter are taken without alteration from a - volume entitled "Prose and Poetry, by a Western - Lady"--but they are exactly and precisely after - the schoolgirl pattern, and hence are much - happier than any mere imitations could be. - - - -CHAPTER XXII - -TOM joined the new order of Cadets of Temperance, being attracted by -the showy character of their "regalia." He promised to abstain from -smoking, chewing, and profanity as long as he remained a member. Now he -found out a new thing--namely, that to promise not to do a thing is the -surest way in the world to make a body want to go and do that very -thing. Tom soon found himself tormented with a desire to drink and -swear; the desire grew to be so intense that nothing but the hope of a -chance to display himself in his red sash kept him from withdrawing -from the order. Fourth of July was coming; but he soon gave that up ---gave it up before he had worn his shackles over forty-eight hours--and -fixed his hopes upon old Judge Frazer, justice of the peace, who was -apparently on his deathbed and would have a big public funeral, since -he was so high an official. During three days Tom was deeply concerned -about the Judge's condition and hungry for news of it. Sometimes his -hopes ran high--so high that he would venture to get out his regalia -and practise before the looking-glass. But the Judge had a most -discouraging way of fluctuating. At last he was pronounced upon the -mend--and then convalescent. Tom was disgusted; and felt a sense of -injury, too. He handed in his resignation at once--and that night the -Judge suffered a relapse and died. Tom resolved that he would never -trust a man like that again. - -The funeral was a fine thing. The Cadets paraded in a style calculated -to kill the late member with envy. Tom was a free boy again, however ---there was something in that. He could drink and swear, now--but found -to his surprise that he did not want to. The simple fact that he could, -took the desire away, and the charm of it. - -Tom presently wondered to find that his coveted vacation was beginning -to hang a little heavily on his hands. - -He attempted a diary--but nothing happened during three days, and so -he abandoned it. - -The first of all the negro minstrel shows came to town, and made a -sensation. Tom and Joe Harper got up a band of performers and were -happy for two days. - -Even the Glorious Fourth was in some sense a failure, for it rained -hard, there was no procession in consequence, and the greatest man in -the world (as Tom supposed), Mr. Benton, an actual United States -Senator, proved an overwhelming disappointment--for he was not -twenty-five feet high, nor even anywhere in the neighborhood of it. - -A circus came. The boys played circus for three days afterward in -tents made of rag carpeting--admission, three pins for boys, two for -girls--and then circusing was abandoned. - -A phrenologist and a mesmerizer came--and went again and left the -village duller and drearier than ever. - -There were some boys-and-girls' parties, but they were so few and so -delightful that they only made the aching voids between ache the harder. - -Becky Thatcher was gone to her Constantinople home to stay with her -parents during vacation--so there was no bright side to life anywhere. - -The dreadful secret of the murder was a chronic misery. It was a very -cancer for permanency and pain. - -Then came the measles. - -During two long weeks Tom lay a prisoner, dead to the world and its -happenings. He was very ill, he was interested in nothing. When he got -upon his feet at last and moved feebly down-town, a melancholy change -had come over everything and every creature. There had been a -"revival," and everybody had "got religion," not only the adults, but -even the boys and girls. Tom went about, hoping against hope for the -sight of one blessed sinful face, but disappointment crossed him -everywhere. He found Joe Harper studying a Testament, and turned sadly -away from the depressing spectacle. He sought Ben Rogers, and found him -visiting the poor with a basket of tracts. He hunted up Jim Hollis, who -called his attention to the precious blessing of his late measles as a -warning. Every boy he encountered added another ton to his depression; -and when, in desperation, he flew for refuge at last to the bosom of -Huckleberry Finn and was received with a Scriptural quotation, his -heart broke and he crept home and to bed realizing that he alone of all -the town was lost, forever and forever. - -And that night there came on a terrific storm, with driving rain, -awful claps of thunder and blinding sheets of lightning. He covered his -head with the bedclothes and waited in a horror of suspense for his -doom; for he had not the shadow of a doubt that all this hubbub was -about him. He believed he had taxed the forbearance of the powers above -to the extremity of endurance and that this was the result. It might -have seemed to him a waste of pomp and ammunition to kill a bug with a -battery of artillery, but there seemed nothing incongruous about the -getting up such an expensive thunderstorm as this to knock the turf -from under an insect like himself. - -By and by the tempest spent itself and died without accomplishing its -object. The boy's first impulse was to be grateful, and reform. His -second was to wait--for there might not be any more storms. - -The next day the doctors were back; Tom had relapsed. The three weeks -he spent on his back this time seemed an entire age. When he got abroad -at last he was hardly grateful that he had been spared, remembering how -lonely was his estate, how companionless and forlorn he was. He drifted -listlessly down the street and found Jim Hollis acting as judge in a -juvenile court that was trying a cat for murder, in the presence of her -victim, a bird. He found Joe Harper and Huck Finn up an alley eating a -stolen melon. Poor lads! they--like Tom--had suffered a relapse. - - - -CHAPTER XXIII - -AT last the sleepy atmosphere was stirred--and vigorously: the murder -trial came on in the court. It became the absorbing topic of village -talk immediately. Tom could not get away from it. Every reference to -the murder sent a shudder to his heart, for his troubled conscience and -fears almost persuaded him that these remarks were put forth in his -hearing as "feelers"; he did not see how he could be suspected of -knowing anything about the murder, but still he could not be -comfortable in the midst of this gossip. It kept him in a cold shiver -all the time. He took Huck to a lonely place to have a talk with him. -It would be some relief to unseal his tongue for a little while; to -divide his burden of distress with another sufferer. Moreover, he -wanted to assure himself that Huck had remained discreet. - -"Huck, have you ever told anybody about--that?" - -"'Bout what?" - -"You know what." - -"Oh--'course I haven't." - -"Never a word?" - -"Never a solitary word, so help me. What makes you ask?" - -"Well, I was afeard." - -"Why, Tom Sawyer, we wouldn't be alive two days if that got found out. -YOU know that." - -Tom felt more comfortable. After a pause: - -"Huck, they couldn't anybody get you to tell, could they?" - -"Get me to tell? Why, if I wanted that half-breed devil to drownd me -they could get me to tell. They ain't no different way." - -"Well, that's all right, then. I reckon we're safe as long as we keep -mum. But let's swear again, anyway. It's more surer." - -"I'm agreed." - -So they swore again with dread solemnities. - -"What is the talk around, Huck? I've heard a power of it." - -"Talk? Well, it's just Muff Potter, Muff Potter, Muff Potter all the -time. It keeps me in a sweat, constant, so's I want to hide som'ers." - -"That's just the same way they go on round me. I reckon he's a goner. -Don't you feel sorry for him, sometimes?" - -"Most always--most always. He ain't no account; but then he hain't -ever done anything to hurt anybody. Just fishes a little, to get money -to get drunk on--and loafs around considerable; but lord, we all do -that--leastways most of us--preachers and such like. But he's kind of -good--he give me half a fish, once, when there warn't enough for two; -and lots of times he's kind of stood by me when I was out of luck." - -"Well, he's mended kites for me, Huck, and knitted hooks on to my -line. I wish we could get him out of there." - -"My! we couldn't get him out, Tom. And besides, 'twouldn't do any -good; they'd ketch him again." - -"Yes--so they would. But I hate to hear 'em abuse him so like the -dickens when he never done--that." - -"I do too, Tom. Lord, I hear 'em say he's the bloodiest looking -villain in this country, and they wonder he wasn't ever hung before." - -"Yes, they talk like that, all the time. I've heard 'em say that if he -was to get free they'd lynch him." - -"And they'd do it, too." - -The boys had a long talk, but it brought them little comfort. As the -twilight drew on, they found themselves hanging about the neighborhood -of the little isolated jail, perhaps with an undefined hope that -something would happen that might clear away their difficulties. But -nothing happened; there seemed to be no angels or fairies interested in -this luckless captive. - -The boys did as they had often done before--went to the cell grating -and gave Potter some tobacco and matches. He was on the ground floor -and there were no guards. - -His gratitude for their gifts had always smote their consciences -before--it cut deeper than ever, this time. They felt cowardly and -treacherous to the last degree when Potter said: - -"You've been mighty good to me, boys--better'n anybody else in this -town. And I don't forget it, I don't. Often I says to myself, says I, -'I used to mend all the boys' kites and things, and show 'em where the -good fishin' places was, and befriend 'em what I could, and now they've -all forgot old Muff when he's in trouble; but Tom don't, and Huck -don't--THEY don't forget him, says I, 'and I don't forget them.' Well, -boys, I done an awful thing--drunk and crazy at the time--that's the -only way I account for it--and now I got to swing for it, and it's -right. Right, and BEST, too, I reckon--hope so, anyway. Well, we won't -talk about that. I don't want to make YOU feel bad; you've befriended -me. But what I want to say, is, don't YOU ever get drunk--then you won't -ever get here. Stand a litter furder west--so--that's it; it's a prime -comfort to see faces that's friendly when a body's in such a muck of -trouble, and there don't none come here but yourn. Good friendly -faces--good friendly faces. Git up on one another's backs and let me -touch 'em. That's it. Shake hands--yourn'll come through the bars, but -mine's too big. Little hands, and weak--but they've helped Muff Potter -a power, and they'd help him more if they could." - -Tom went home miserable, and his dreams that night were full of -horrors. The next day and the day after, he hung about the court-room, -drawn by an almost irresistible impulse to go in, but forcing himself -to stay out. Huck was having the same experience. They studiously -avoided each other. Each wandered away, from time to time, but the same -dismal fascination always brought them back presently. Tom kept his -ears open when idlers sauntered out of the court-room, but invariably -heard distressing news--the toils were closing more and more -relentlessly around poor Potter. At the end of the second day the -village talk was to the effect that Injun Joe's evidence stood firm and -unshaken, and that there was not the slightest question as to what the -jury's verdict would be. - -Tom was out late, that night, and came to bed through the window. He -was in a tremendous state of excitement. It was hours before he got to -sleep. All the village flocked to the court-house the next morning, for -this was to be the great day. Both sexes were about equally represented -in the packed audience. After a long wait the jury filed in and took -their places; shortly afterward, Potter, pale and haggard, timid and -hopeless, was brought in, with chains upon him, and seated where all -the curious eyes could stare at him; no less conspicuous was Injun Joe, -stolid as ever. There was another pause, and then the judge arrived and -the sheriff proclaimed the opening of the court. The usual whisperings -among the lawyers and gathering together of papers followed. These -details and accompanying delays worked up an atmosphere of preparation -that was as impressive as it was fascinating. - -Now a witness was called who testified that he found Muff Potter -washing in the brook, at an early hour of the morning that the murder -was discovered, and that he immediately sneaked away. After some -further questioning, counsel for the prosecution said: - -"Take the witness." - -The prisoner raised his eyes for a moment, but dropped them again when -his own counsel said: - -"I have no questions to ask him." - -The next witness proved the finding of the knife near the corpse. -Counsel for the prosecution said: - -"Take the witness." - -"I have no questions to ask him," Potter's lawyer replied. - -A third witness swore he had often seen the knife in Potter's -possession. - -"Take the witness." - -Counsel for Potter declined to question him. The faces of the audience -began to betray annoyance. Did this attorney mean to throw away his -client's life without an effort? - -Several witnesses deposed concerning Potter's guilty behavior when -brought to the scene of the murder. They were allowed to leave the -stand without being cross-questioned. - -Every detail of the damaging circumstances that occurred in the -graveyard upon that morning which all present remembered so well was -brought out by credible witnesses, but none of them were cross-examined -by Potter's lawyer. The perplexity and dissatisfaction of the house -expressed itself in murmurs and provoked a reproof from the bench. -Counsel for the prosecution now said: - -"By the oaths of citizens whose simple word is above suspicion, we -have fastened this awful crime, beyond all possibility of question, -upon the unhappy prisoner at the bar. We rest our case here." - -A groan escaped from poor Potter, and he put his face in his hands and -rocked his body softly to and fro, while a painful silence reigned in -the court-room. Many men were moved, and many women's compassion -testified itself in tears. Counsel for the defence rose and said: - -"Your honor, in our remarks at the opening of this trial, we -foreshadowed our purpose to prove that our client did this fearful deed -while under the influence of a blind and irresponsible delirium -produced by drink. We have changed our mind. We shall not offer that -plea." [Then to the clerk:] "Call Thomas Sawyer!" - -A puzzled amazement awoke in every face in the house, not even -excepting Potter's. Every eye fastened itself with wondering interest -upon Tom as he rose and took his place upon the stand. The boy looked -wild enough, for he was badly scared. The oath was administered. - -"Thomas Sawyer, where were you on the seventeenth of June, about the -hour of midnight?" - -Tom glanced at Injun Joe's iron face and his tongue failed him. The -audience listened breathless, but the words refused to come. After a -few moments, however, the boy got a little of his strength back, and -managed to put enough of it into his voice to make part of the house -hear: - -"In the graveyard!" - -"A little bit louder, please. Don't be afraid. You were--" - -"In the graveyard." - -A contemptuous smile flitted across Injun Joe's face. - -"Were you anywhere near Horse Williams' grave?" - -"Yes, sir." - -"Speak up--just a trifle louder. How near were you?" - -"Near as I am to you." - -"Were you hidden, or not?" - -"I was hid." - -"Where?" - -"Behind the elms that's on the edge of the grave." - -Injun Joe gave a barely perceptible start. - -"Any one with you?" - -"Yes, sir. I went there with--" - -"Wait--wait a moment. Never mind mentioning your companion's name. We -will produce him at the proper time. Did you carry anything there with -you." - -Tom hesitated and looked confused. - -"Speak out, my boy--don't be diffident. The truth is always -respectable. What did you take there?" - -"Only a--a--dead cat." - -There was a ripple of mirth, which the court checked. - -"We will produce the skeleton of that cat. Now, my boy, tell us -everything that occurred--tell it in your own way--don't skip anything, -and don't be afraid." - -Tom began--hesitatingly at first, but as he warmed to his subject his -words flowed more and more easily; in a little while every sound ceased -but his own voice; every eye fixed itself upon him; with parted lips -and bated breath the audience hung upon his words, taking no note of -time, rapt in the ghastly fascinations of the tale. The strain upon -pent emotion reached its climax when the boy said: - -"--and as the doctor fetched the board around and Muff Potter fell, -Injun Joe jumped with the knife and--" - -Crash! Quick as lightning the half-breed sprang for a window, tore his -way through all opposers, and was gone! - - - -CHAPTER XXIV - -TOM was a glittering hero once more--the pet of the old, the envy of -the young. His name even went into immortal print, for the village -paper magnified him. There were some that believed he would be -President, yet, if he escaped hanging. - -As usual, the fickle, unreasoning world took Muff Potter to its bosom -and fondled him as lavishly as it had abused him before. But that sort -of conduct is to the world's credit; therefore it is not well to find -fault with it. - -Tom's days were days of splendor and exultation to him, but his nights -were seasons of horror. Injun Joe infested all his dreams, and always -with doom in his eye. Hardly any temptation could persuade the boy to -stir abroad after nightfall. Poor Huck was in the same state of -wretchedness and terror, for Tom had told the whole story to the lawyer -the night before the great day of the trial, and Huck was sore afraid -that his share in the business might leak out, yet, notwithstanding -Injun Joe's flight had saved him the suffering of testifying in court. -The poor fellow had got the attorney to promise secrecy, but what of -that? Since Tom's harassed conscience had managed to drive him to the -lawyer's house by night and wring a dread tale from lips that had been -sealed with the dismalest and most formidable of oaths, Huck's -confidence in the human race was well-nigh obliterated. - -Daily Muff Potter's gratitude made Tom glad he had spoken; but nightly -he wished he had sealed up his tongue. - -Half the time Tom was afraid Injun Joe would never be captured; the -other half he was afraid he would be. He felt sure he never could draw -a safe breath again until that man was dead and he had seen the corpse. - -Rewards had been offered, the country had been scoured, but no Injun -Joe was found. One of those omniscient and awe-inspiring marvels, a -detective, came up from St. Louis, moused around, shook his head, -looked wise, and made that sort of astounding success which members of -that craft usually achieve. That is to say, he "found a clew." But you -can't hang a "clew" for murder, and so after that detective had got -through and gone home, Tom felt just as insecure as he was before. - -The slow days drifted on, and each left behind it a slightly lightened -weight of apprehension. - - - -CHAPTER XXV - -THERE comes a time in every rightly-constructed boy's life when he has -a raging desire to go somewhere and dig for hidden treasure. This -desire suddenly came upon Tom one day. He sallied out to find Joe -Harper, but failed of success. Next he sought Ben Rogers; he had gone -fishing. Presently he stumbled upon Huck Finn the Red-Handed. Huck -would answer. Tom took him to a private place and opened the matter to -him confidentially. Huck was willing. Huck was always willing to take a -hand in any enterprise that offered entertainment and required no -capital, for he had a troublesome superabundance of that sort of time -which is not money. "Where'll we dig?" said Huck. - -"Oh, most anywhere." - -"Why, is it hid all around?" - -"No, indeed it ain't. It's hid in mighty particular places, Huck ---sometimes on islands, sometimes in rotten chests under the end of a -limb of an old dead tree, just where the shadow falls at midnight; but -mostly under the floor in ha'nted houses." - -"Who hides it?" - -"Why, robbers, of course--who'd you reckon? Sunday-school -sup'rintendents?" - -"I don't know. If 'twas mine I wouldn't hide it; I'd spend it and have -a good time." - -"So would I. But robbers don't do that way. They always hide it and -leave it there." - -"Don't they come after it any more?" - -"No, they think they will, but they generally forget the marks, or -else they die. Anyway, it lays there a long time and gets rusty; and by -and by somebody finds an old yellow paper that tells how to find the -marks--a paper that's got to be ciphered over about a week because it's -mostly signs and hy'roglyphics." - -"Hyro--which?" - -"Hy'roglyphics--pictures and things, you know, that don't seem to mean -anything." - -"Have you got one of them papers, Tom?" - -"No." - -"Well then, how you going to find the marks?" - -"I don't want any marks. They always bury it under a ha'nted house or -on an island, or under a dead tree that's got one limb sticking out. -Well, we've tried Jackson's Island a little, and we can try it again -some time; and there's the old ha'nted house up the Still-House branch, -and there's lots of dead-limb trees--dead loads of 'em." - -"Is it under all of them?" - -"How you talk! No!" - -"Then how you going to know which one to go for?" - -"Go for all of 'em!" - -"Why, Tom, it'll take all summer." - -"Well, what of that? Suppose you find a brass pot with a hundred -dollars in it, all rusty and gray, or rotten chest full of di'monds. -How's that?" - -Huck's eyes glowed. - -"That's bully. Plenty bully enough for me. Just you gimme the hundred -dollars and I don't want no di'monds." - -"All right. But I bet you I ain't going to throw off on di'monds. Some -of 'em's worth twenty dollars apiece--there ain't any, hardly, but's -worth six bits or a dollar." - -"No! Is that so?" - -"Cert'nly--anybody'll tell you so. Hain't you ever seen one, Huck?" - -"Not as I remember." - -"Oh, kings have slathers of them." - -"Well, I don' know no kings, Tom." - -"I reckon you don't. But if you was to go to Europe you'd see a raft -of 'em hopping around." - -"Do they hop?" - -"Hop?--your granny! No!" - -"Well, what did you say they did, for?" - -"Shucks, I only meant you'd SEE 'em--not hopping, of course--what do -they want to hop for?--but I mean you'd just see 'em--scattered around, -you know, in a kind of a general way. Like that old humpbacked Richard." - -"Richard? What's his other name?" - -"He didn't have any other name. Kings don't have any but a given name." - -"No?" - -"But they don't." - -"Well, if they like it, Tom, all right; but I don't want to be a king -and have only just a given name, like a nigger. But say--where you -going to dig first?" - -"Well, I don't know. S'pose we tackle that old dead-limb tree on the -hill t'other side of Still-House branch?" - -"I'm agreed." - -So they got a crippled pick and a shovel, and set out on their -three-mile tramp. They arrived hot and panting, and threw themselves -down in the shade of a neighboring elm to rest and have a smoke. - -"I like this," said Tom. - -"So do I." - -"Say, Huck, if we find a treasure here, what you going to do with your -share?" - -"Well, I'll have pie and a glass of soda every day, and I'll go to -every circus that comes along. I bet I'll have a gay time." - -"Well, ain't you going to save any of it?" - -"Save it? What for?" - -"Why, so as to have something to live on, by and by." - -"Oh, that ain't any use. Pap would come back to thish-yer town some -day and get his claws on it if I didn't hurry up, and I tell you he'd -clean it out pretty quick. What you going to do with yourn, Tom?" - -"I'm going to buy a new drum, and a sure-'nough sword, and a red -necktie and a bull pup, and get married." - -"Married!" - -"That's it." - -"Tom, you--why, you ain't in your right mind." - -"Wait--you'll see." - -"Well, that's the foolishest thing you could do. Look at pap and my -mother. Fight! Why, they used to fight all the time. I remember, mighty -well." - -"That ain't anything. The girl I'm going to marry won't fight." - -"Tom, I reckon they're all alike. They'll all comb a body. Now you -better think 'bout this awhile. I tell you you better. What's the name -of the gal?" - -"It ain't a gal at all--it's a girl." - -"It's all the same, I reckon; some says gal, some says girl--both's -right, like enough. Anyway, what's her name, Tom?" - -"I'll tell you some time--not now." - -"All right--that'll do. Only if you get married I'll be more lonesomer -than ever." - -"No you won't. You'll come and live with me. Now stir out of this and -we'll go to digging." - -They worked and sweated for half an hour. No result. They toiled -another half-hour. Still no result. Huck said: - -"Do they always bury it as deep as this?" - -"Sometimes--not always. Not generally. I reckon we haven't got the -right place." - -So they chose a new spot and began again. The labor dragged a little, -but still they made progress. They pegged away in silence for some -time. Finally Huck leaned on his shovel, swabbed the beaded drops from -his brow with his sleeve, and said: - -"Where you going to dig next, after we get this one?" - -"I reckon maybe we'll tackle the old tree that's over yonder on -Cardiff Hill back of the widow's." - -"I reckon that'll be a good one. But won't the widow take it away from -us, Tom? It's on her land." - -"SHE take it away! Maybe she'd like to try it once. Whoever finds one -of these hid treasures, it belongs to him. It don't make any difference -whose land it's on." - -That was satisfactory. The work went on. By and by Huck said: - -"Blame it, we must be in the wrong place again. What do you think?" - -"It is mighty curious, Huck. I don't understand it. Sometimes witches -interfere. I reckon maybe that's what's the trouble now." - -"Shucks! Witches ain't got no power in the daytime." - -"Well, that's so. I didn't think of that. Oh, I know what the matter -is! What a blamed lot of fools we are! You got to find out where the -shadow of the limb falls at midnight, and that's where you dig!" - -"Then consound it, we've fooled away all this work for nothing. Now -hang it all, we got to come back in the night. It's an awful long way. -Can you get out?" - -"I bet I will. We've got to do it to-night, too, because if somebody -sees these holes they'll know in a minute what's here and they'll go -for it." - -"Well, I'll come around and maow to-night." - -"All right. Let's hide the tools in the bushes." - -The boys were there that night, about the appointed time. They sat in -the shadow waiting. It was a lonely place, and an hour made solemn by -old traditions. Spirits whispered in the rustling leaves, ghosts lurked -in the murky nooks, the deep baying of a hound floated up out of the -distance, an owl answered with his sepulchral note. The boys were -subdued by these solemnities, and talked little. By and by they judged -that twelve had come; they marked where the shadow fell, and began to -dig. Their hopes commenced to rise. Their interest grew stronger, and -their industry kept pace with it. The hole deepened and still deepened, -but every time their hearts jumped to hear the pick strike upon -something, they only suffered a new disappointment. It was only a stone -or a chunk. At last Tom said: - -"It ain't any use, Huck, we're wrong again." - -"Well, but we CAN'T be wrong. We spotted the shadder to a dot." - -"I know it, but then there's another thing." - -"What's that?". - -"Why, we only guessed at the time. Like enough it was too late or too -early." - -Huck dropped his shovel. - -"That's it," said he. "That's the very trouble. We got to give this -one up. We can't ever tell the right time, and besides this kind of -thing's too awful, here this time of night with witches and ghosts -a-fluttering around so. I feel as if something's behind me all the time; -and I'm afeard to turn around, becuz maybe there's others in front -a-waiting for a chance. I been creeping all over, ever since I got here." - -"Well, I've been pretty much so, too, Huck. They most always put in a -dead man when they bury a treasure under a tree, to look out for it." - -"Lordy!" - -"Yes, they do. I've always heard that." - -"Tom, I don't like to fool around much where there's dead people. A -body's bound to get into trouble with 'em, sure." - -"I don't like to stir 'em up, either. S'pose this one here was to -stick his skull out and say something!" - -"Don't Tom! It's awful." - -"Well, it just is. Huck, I don't feel comfortable a bit." - -"Say, Tom, let's give this place up, and try somewheres else." - -"All right, I reckon we better." - -"What'll it be?" - -Tom considered awhile; and then said: - -"The ha'nted house. That's it!" - -"Blame it, I don't like ha'nted houses, Tom. Why, they're a dern sight -worse'n dead people. Dead people might talk, maybe, but they don't come -sliding around in a shroud, when you ain't noticing, and peep over your -shoulder all of a sudden and grit their teeth, the way a ghost does. I -couldn't stand such a thing as that, Tom--nobody could." - -"Yes, but, Huck, ghosts don't travel around only at night. They won't -hender us from digging there in the daytime." - -"Well, that's so. But you know mighty well people don't go about that -ha'nted house in the day nor the night." - -"Well, that's mostly because they don't like to go where a man's been -murdered, anyway--but nothing's ever been seen around that house except -in the night--just some blue lights slipping by the windows--no regular -ghosts." - -"Well, where you see one of them blue lights flickering around, Tom, -you can bet there's a ghost mighty close behind it. It stands to -reason. Becuz you know that they don't anybody but ghosts use 'em." - -"Yes, that's so. But anyway they don't come around in the daytime, so -what's the use of our being afeard?" - -"Well, all right. We'll tackle the ha'nted house if you say so--but I -reckon it's taking chances." - -They had started down the hill by this time. There in the middle of -the moonlit valley below them stood the "ha'nted" house, utterly -isolated, its fences gone long ago, rank weeds smothering the very -doorsteps, the chimney crumbled to ruin, the window-sashes vacant, a -corner of the roof caved in. The boys gazed awhile, half expecting to -see a blue light flit past a window; then talking in a low tone, as -befitted the time and the circumstances, they struck far off to the -right, to give the haunted house a wide berth, and took their way -homeward through the woods that adorned the rearward side of Cardiff -Hill. - - - -CHAPTER XXVI - -ABOUT noon the next day the boys arrived at the dead tree; they had -come for their tools. Tom was impatient to go to the haunted house; -Huck was measurably so, also--but suddenly said: - -"Lookyhere, Tom, do you know what day it is?" - -Tom mentally ran over the days of the week, and then quickly lifted -his eyes with a startled look in them-- - -"My! I never once thought of it, Huck!" - -"Well, I didn't neither, but all at once it popped onto me that it was -Friday." - -"Blame it, a body can't be too careful, Huck. We might 'a' got into an -awful scrape, tackling such a thing on a Friday." - -"MIGHT! Better say we WOULD! There's some lucky days, maybe, but -Friday ain't." - -"Any fool knows that. I don't reckon YOU was the first that found it -out, Huck." - -"Well, I never said I was, did I? And Friday ain't all, neither. I had -a rotten bad dream last night--dreampt about rats." - -"No! Sure sign of trouble. Did they fight?" - -"No." - -"Well, that's good, Huck. When they don't fight it's only a sign that -there's trouble around, you know. All we got to do is to look mighty -sharp and keep out of it. We'll drop this thing for to-day, and play. -Do you know Robin Hood, Huck?" - -"No. Who's Robin Hood?" - -"Why, he was one of the greatest men that was ever in England--and the -best. He was a robber." - -"Cracky, I wisht I was. Who did he rob?" - -"Only sheriffs and bishops and rich people and kings, and such like. -But he never bothered the poor. He loved 'em. He always divided up with -'em perfectly square." - -"Well, he must 'a' been a brick." - -"I bet you he was, Huck. Oh, he was the noblest man that ever was. -They ain't any such men now, I can tell you. He could lick any man in -England, with one hand tied behind him; and he could take his yew bow -and plug a ten-cent piece every time, a mile and a half." - -"What's a YEW bow?" - -"I don't know. It's some kind of a bow, of course. And if he hit that -dime only on the edge he would set down and cry--and curse. But we'll -play Robin Hood--it's nobby fun. I'll learn you." - -"I'm agreed." - -So they played Robin Hood all the afternoon, now and then casting a -yearning eye down upon the haunted house and passing a remark about the -morrow's prospects and possibilities there. As the sun began to sink -into the west they took their way homeward athwart the long shadows of -the trees and soon were buried from sight in the forests of Cardiff -Hill. - -On Saturday, shortly after noon, the boys were at the dead tree again. -They had a smoke and a chat in the shade, and then dug a little in -their last hole, not with great hope, but merely because Tom said there -were so many cases where people had given up a treasure after getting -down within six inches of it, and then somebody else had come along and -turned it up with a single thrust of a shovel. The thing failed this -time, however, so the boys shouldered their tools and went away feeling -that they had not trifled with fortune, but had fulfilled all the -requirements that belong to the business of treasure-hunting. - -When they reached the haunted house there was something so weird and -grisly about the dead silence that reigned there under the baking sun, -and something so depressing about the loneliness and desolation of the -place, that they were afraid, for a moment, to venture in. Then they -crept to the door and took a trembling peep. They saw a weed-grown, -floorless room, unplastered, an ancient fireplace, vacant windows, a -ruinous staircase; and here, there, and everywhere hung ragged and -abandoned cobwebs. They presently entered, softly, with quickened -pulses, talking in whispers, ears alert to catch the slightest sound, -and muscles tense and ready for instant retreat. - -In a little while familiarity modified their fears and they gave the -place a critical and interested examination, rather admiring their own -boldness, and wondering at it, too. Next they wanted to look up-stairs. -This was something like cutting off retreat, but they got to daring -each other, and of course there could be but one result--they threw -their tools into a corner and made the ascent. Up there were the same -signs of decay. In one corner they found a closet that promised -mystery, but the promise was a fraud--there was nothing in it. Their -courage was up now and well in hand. They were about to go down and -begin work when-- - -"Sh!" said Tom. - -"What is it?" whispered Huck, blanching with fright. - -"Sh!... There!... Hear it?" - -"Yes!... Oh, my! Let's run!" - -"Keep still! Don't you budge! They're coming right toward the door." - -The boys stretched themselves upon the floor with their eyes to -knot-holes in the planking, and lay waiting, in a misery of fear. - -"They've stopped.... No--coming.... Here they are. Don't whisper -another word, Huck. My goodness, I wish I was out of this!" - -Two men entered. Each boy said to himself: "There's the old deaf and -dumb Spaniard that's been about town once or twice lately--never saw -t'other man before." - -"T'other" was a ragged, unkempt creature, with nothing very pleasant -in his face. The Spaniard was wrapped in a serape; he had bushy white -whiskers; long white hair flowed from under his sombrero, and he wore -green goggles. When they came in, "t'other" was talking in a low voice; -they sat down on the ground, facing the door, with their backs to the -wall, and the speaker continued his remarks. His manner became less -guarded and his words more distinct as he proceeded: - -"No," said he, "I've thought it all over, and I don't like it. It's -dangerous." - -"Dangerous!" grunted the "deaf and dumb" Spaniard--to the vast -surprise of the boys. "Milksop!" - -This voice made the boys gasp and quake. It was Injun Joe's! There was -silence for some time. Then Joe said: - -"What's any more dangerous than that job up yonder--but nothing's come -of it." - -"That's different. Away up the river so, and not another house about. -'Twon't ever be known that we tried, anyway, long as we didn't succeed." - -"Well, what's more dangerous than coming here in the daytime!--anybody -would suspicion us that saw us." - -"I know that. But there warn't any other place as handy after that -fool of a job. I want to quit this shanty. I wanted to yesterday, only -it warn't any use trying to stir out of here, with those infernal boys -playing over there on the hill right in full view." - -"Those infernal boys" quaked again under the inspiration of this -remark, and thought how lucky it was that they had remembered it was -Friday and concluded to wait a day. They wished in their hearts they -had waited a year. - -The two men got out some food and made a luncheon. After a long and -thoughtful silence, Injun Joe said: - -"Look here, lad--you go back up the river where you belong. Wait there -till you hear from me. I'll take the chances on dropping into this town -just once more, for a look. We'll do that 'dangerous' job after I've -spied around a little and think things look well for it. Then for -Texas! We'll leg it together!" - -This was satisfactory. Both men presently fell to yawning, and Injun -Joe said: - -"I'm dead for sleep! It's your turn to watch." - -He curled down in the weeds and soon began to snore. His comrade -stirred him once or twice and he became quiet. Presently the watcher -began to nod; his head drooped lower and lower, both men began to snore -now. - -The boys drew a long, grateful breath. Tom whispered: - -"Now's our chance--come!" - -Huck said: - -"I can't--I'd die if they was to wake." - -Tom urged--Huck held back. At last Tom rose slowly and softly, and -started alone. But the first step he made wrung such a hideous creak -from the crazy floor that he sank down almost dead with fright. He -never made a second attempt. The boys lay there counting the dragging -moments till it seemed to them that time must be done and eternity -growing gray; and then they were grateful to note that at last the sun -was setting. - -Now one snore ceased. Injun Joe sat up, stared around--smiled grimly -upon his comrade, whose head was drooping upon his knees--stirred him -up with his foot and said: - -"Here! YOU'RE a watchman, ain't you! All right, though--nothing's -happened." - -"My! have I been asleep?" - -"Oh, partly, partly. Nearly time for us to be moving, pard. What'll we -do with what little swag we've got left?" - -"I don't know--leave it here as we've always done, I reckon. No use to -take it away till we start south. Six hundred and fifty in silver's -something to carry." - -"Well--all right--it won't matter to come here once more." - -"No--but I'd say come in the night as we used to do--it's better." - -"Yes: but look here; it may be a good while before I get the right -chance at that job; accidents might happen; 'tain't in such a very good -place; we'll just regularly bury it--and bury it deep." - -"Good idea," said the comrade, who walked across the room, knelt down, -raised one of the rearward hearth-stones and took out a bag that -jingled pleasantly. He subtracted from it twenty or thirty dollars for -himself and as much for Injun Joe, and passed the bag to the latter, -who was on his knees in the corner, now, digging with his bowie-knife. - -The boys forgot all their fears, all their miseries in an instant. -With gloating eyes they watched every movement. Luck!--the splendor of -it was beyond all imagination! Six hundred dollars was money enough to -make half a dozen boys rich! Here was treasure-hunting under the -happiest auspices--there would not be any bothersome uncertainty as to -where to dig. They nudged each other every moment--eloquent nudges and -easily understood, for they simply meant--"Oh, but ain't you glad NOW -we're here!" - -Joe's knife struck upon something. - -"Hello!" said he. - -"What is it?" said his comrade. - -"Half-rotten plank--no, it's a box, I believe. Here--bear a hand and -we'll see what it's here for. Never mind, I've broke a hole." - -He reached his hand in and drew it out-- - -"Man, it's money!" - -The two men examined the handful of coins. They were gold. The boys -above were as excited as themselves, and as delighted. - -Joe's comrade said: - -"We'll make quick work of this. There's an old rusty pick over amongst -the weeds in the corner the other side of the fireplace--I saw it a -minute ago." - -He ran and brought the boys' pick and shovel. Injun Joe took the pick, -looked it over critically, shook his head, muttered something to -himself, and then began to use it. The box was soon unearthed. It was -not very large; it was iron bound and had been very strong before the -slow years had injured it. The men contemplated the treasure awhile in -blissful silence. - -"Pard, there's thousands of dollars here," said Injun Joe. - -"'Twas always said that Murrel's gang used to be around here one -summer," the stranger observed. - -"I know it," said Injun Joe; "and this looks like it, I should say." - -"Now you won't need to do that job." - -The half-breed frowned. Said he: - -"You don't know me. Least you don't know all about that thing. 'Tain't -robbery altogether--it's REVENGE!" and a wicked light flamed in his -eyes. "I'll need your help in it. When it's finished--then Texas. Go -home to your Nance and your kids, and stand by till you hear from me." - -"Well--if you say so; what'll we do with this--bury it again?" - -"Yes. [Ravishing delight overhead.] NO! by the great Sachem, no! -[Profound distress overhead.] I'd nearly forgot. That pick had fresh -earth on it! [The boys were sick with terror in a moment.] What -business has a pick and a shovel here? What business with fresh earth -on them? Who brought them here--and where are they gone? Have you heard -anybody?--seen anybody? What! bury it again and leave them to come and -see the ground disturbed? Not exactly--not exactly. We'll take it to my -den." - -"Why, of course! Might have thought of that before. You mean Number -One?" - -"No--Number Two--under the cross. The other place is bad--too common." - -"All right. It's nearly dark enough to start." - -Injun Joe got up and went about from window to window cautiously -peeping out. Presently he said: - -"Who could have brought those tools here? Do you reckon they can be -up-stairs?" - -The boys' breath forsook them. Injun Joe put his hand on his knife, -halted a moment, undecided, and then turned toward the stairway. The -boys thought of the closet, but their strength was gone. The steps came -creaking up the stairs--the intolerable distress of the situation woke -the stricken resolution of the lads--they were about to spring for the -closet, when there was a crash of rotten timbers and Injun Joe landed -on the ground amid the debris of the ruined stairway. He gathered -himself up cursing, and his comrade said: - -"Now what's the use of all that? If it's anybody, and they're up -there, let them STAY there--who cares? If they want to jump down, now, -and get into trouble, who objects? It will be dark in fifteen minutes ---and then let them follow us if they want to. I'm willing. In my -opinion, whoever hove those things in here caught a sight of us and -took us for ghosts or devils or something. I'll bet they're running -yet." - -Joe grumbled awhile; then he agreed with his friend that what daylight -was left ought to be economized in getting things ready for leaving. -Shortly afterward they slipped out of the house in the deepening -twilight, and moved toward the river with their precious box. - -Tom and Huck rose up, weak but vastly relieved, and stared after them -through the chinks between the logs of the house. Follow? Not they. -They were content to reach ground again without broken necks, and take -the townward track over the hill. They did not talk much. They were too -much absorbed in hating themselves--hating the ill luck that made them -take the spade and the pick there. But for that, Injun Joe never would -have suspected. He would have hidden the silver with the gold to wait -there till his "revenge" was satisfied, and then he would have had the -misfortune to find that money turn up missing. Bitter, bitter luck that -the tools were ever brought there! - -They resolved to keep a lookout for that Spaniard when he should come -to town spying out for chances to do his revengeful job, and follow him -to "Number Two," wherever that might be. Then a ghastly thought -occurred to Tom. - -"Revenge? What if he means US, Huck!" - -"Oh, don't!" said Huck, nearly fainting. - -They talked it all over, and as they entered town they agreed to -believe that he might possibly mean somebody else--at least that he -might at least mean nobody but Tom, since only Tom had testified. - -Very, very small comfort it was to Tom to be alone in danger! Company -would be a palpable improvement, he thought. - - - -CHAPTER XXVII - -THE adventure of the day mightily tormented Tom's dreams that night. -Four times he had his hands on that rich treasure and four times it -wasted to nothingness in his fingers as sleep forsook him and -wakefulness brought back the hard reality of his misfortune. As he lay -in the early morning recalling the incidents of his great adventure, he -noticed that they seemed curiously subdued and far away--somewhat as if -they had happened in another world, or in a time long gone by. Then it -occurred to him that the great adventure itself must be a dream! There -was one very strong argument in favor of this idea--namely, that the -quantity of coin he had seen was too vast to be real. He had never seen -as much as fifty dollars in one mass before, and he was like all boys -of his age and station in life, in that he imagined that all references -to "hundreds" and "thousands" were mere fanciful forms of speech, and -that no such sums really existed in the world. He never had supposed -for a moment that so large a sum as a hundred dollars was to be found -in actual money in any one's possession. If his notions of hidden -treasure had been analyzed, they would have been found to consist of a -handful of real dimes and a bushel of vague, splendid, ungraspable -dollars. - -But the incidents of his adventure grew sensibly sharper and clearer -under the attrition of thinking them over, and so he presently found -himself leaning to the impression that the thing might not have been a -dream, after all. This uncertainty must be swept away. He would snatch -a hurried breakfast and go and find Huck. Huck was sitting on the -gunwale of a flatboat, listlessly dangling his feet in the water and -looking very melancholy. Tom concluded to let Huck lead up to the -subject. If he did not do it, then the adventure would be proved to -have been only a dream. - -"Hello, Huck!" - -"Hello, yourself." - -Silence, for a minute. - -"Tom, if we'd 'a' left the blame tools at the dead tree, we'd 'a' got -the money. Oh, ain't it awful!" - -"'Tain't a dream, then, 'tain't a dream! Somehow I most wish it was. -Dog'd if I don't, Huck." - -"What ain't a dream?" - -"Oh, that thing yesterday. I been half thinking it was." - -"Dream! If them stairs hadn't broke down you'd 'a' seen how much dream -it was! I've had dreams enough all night--with that patch-eyed Spanish -devil going for me all through 'em--rot him!" - -"No, not rot him. FIND him! Track the money!" - -"Tom, we'll never find him. A feller don't have only one chance for -such a pile--and that one's lost. I'd feel mighty shaky if I was to see -him, anyway." - -"Well, so'd I; but I'd like to see him, anyway--and track him out--to -his Number Two." - -"Number Two--yes, that's it. I been thinking 'bout that. But I can't -make nothing out of it. What do you reckon it is?" - -"I dono. It's too deep. Say, Huck--maybe it's the number of a house!" - -"Goody!... No, Tom, that ain't it. If it is, it ain't in this -one-horse town. They ain't no numbers here." - -"Well, that's so. Lemme think a minute. Here--it's the number of a -room--in a tavern, you know!" - -"Oh, that's the trick! They ain't only two taverns. We can find out -quick." - -"You stay here, Huck, till I come." - -Tom was off at once. He did not care to have Huck's company in public -places. He was gone half an hour. He found that in the best tavern, No. -2 had long been occupied by a young lawyer, and was still so occupied. -In the less ostentatious house, No. 2 was a mystery. The -tavern-keeper's young son said it was kept locked all the time, and he -never saw anybody go into it or come out of it except at night; he did -not know any particular reason for this state of things; had had some -little curiosity, but it was rather feeble; had made the most of the -mystery by entertaining himself with the idea that that room was -"ha'nted"; had noticed that there was a light in there the night before. - -"That's what I've found out, Huck. I reckon that's the very No. 2 -we're after." - -"I reckon it is, Tom. Now what you going to do?" - -"Lemme think." - -Tom thought a long time. Then he said: - -"I'll tell you. The back door of that No. 2 is the door that comes out -into that little close alley between the tavern and the old rattle trap -of a brick store. Now you get hold of all the door-keys you can find, -and I'll nip all of auntie's, and the first dark night we'll go there -and try 'em. And mind you, keep a lookout for Injun Joe, because he -said he was going to drop into town and spy around once more for a -chance to get his revenge. If you see him, you just follow him; and if -he don't go to that No. 2, that ain't the place." - -"Lordy, I don't want to foller him by myself!" - -"Why, it'll be night, sure. He mightn't ever see you--and if he did, -maybe he'd never think anything." - -"Well, if it's pretty dark I reckon I'll track him. I dono--I dono. -I'll try." - -"You bet I'll follow him, if it's dark, Huck. Why, he might 'a' found -out he couldn't get his revenge, and be going right after that money." - -"It's so, Tom, it's so. I'll foller him; I will, by jingoes!" - -"Now you're TALKING! Don't you ever weaken, Huck, and I won't." - - - -CHAPTER XXVIII - -THAT night Tom and Huck were ready for their adventure. They hung -about the neighborhood of the tavern until after nine, one watching the -alley at a distance and the other the tavern door. Nobody entered the -alley or left it; nobody resembling the Spaniard entered or left the -tavern door. The night promised to be a fair one; so Tom went home with -the understanding that if a considerable degree of darkness came on, -Huck was to come and "maow," whereupon he would slip out and try the -keys. But the night remained clear, and Huck closed his watch and -retired to bed in an empty sugar hogshead about twelve. - -Tuesday the boys had the same ill luck. Also Wednesday. But Thursday -night promised better. Tom slipped out in good season with his aunt's -old tin lantern, and a large towel to blindfold it with. He hid the -lantern in Huck's sugar hogshead and the watch began. An hour before -midnight the tavern closed up and its lights (the only ones -thereabouts) were put out. No Spaniard had been seen. Nobody had -entered or left the alley. Everything was auspicious. The blackness of -darkness reigned, the perfect stillness was interrupted only by -occasional mutterings of distant thunder. - -Tom got his lantern, lit it in the hogshead, wrapped it closely in the -towel, and the two adventurers crept in the gloom toward the tavern. -Huck stood sentry and Tom felt his way into the alley. Then there was a -season of waiting anxiety that weighed upon Huck's spirits like a -mountain. He began to wish he could see a flash from the lantern--it -would frighten him, but it would at least tell him that Tom was alive -yet. It seemed hours since Tom had disappeared. Surely he must have -fainted; maybe he was dead; maybe his heart had burst under terror and -excitement. In his uneasiness Huck found himself drawing closer and -closer to the alley; fearing all sorts of dreadful things, and -momentarily expecting some catastrophe to happen that would take away -his breath. There was not much to take away, for he seemed only able to -inhale it by thimblefuls, and his heart would soon wear itself out, the -way it was beating. Suddenly there was a flash of light and Tom came -tearing by him: "Run!" said he; "run, for your life!" - -He needn't have repeated it; once was enough; Huck was making thirty -or forty miles an hour before the repetition was uttered. The boys -never stopped till they reached the shed of a deserted slaughter-house -at the lower end of the village. Just as they got within its shelter -the storm burst and the rain poured down. As soon as Tom got his breath -he said: - -"Huck, it was awful! I tried two of the keys, just as soft as I could; -but they seemed to make such a power of racket that I couldn't hardly -get my breath I was so scared. They wouldn't turn in the lock, either. -Well, without noticing what I was doing, I took hold of the knob, and -open comes the door! It warn't locked! I hopped in, and shook off the -towel, and, GREAT CAESAR'S GHOST!" - -"What!--what'd you see, Tom?" - -"Huck, I most stepped onto Injun Joe's hand!" - -"No!" - -"Yes! He was lying there, sound asleep on the floor, with his old -patch on his eye and his arms spread out." - -"Lordy, what did you do? Did he wake up?" - -"No, never budged. Drunk, I reckon. I just grabbed that towel and -started!" - -"I'd never 'a' thought of the towel, I bet!" - -"Well, I would. My aunt would make me mighty sick if I lost it." - -"Say, Tom, did you see that box?" - -"Huck, I didn't wait to look around. I didn't see the box, I didn't -see the cross. I didn't see anything but a bottle and a tin cup on the -floor by Injun Joe; yes, I saw two barrels and lots more bottles in the -room. Don't you see, now, what's the matter with that ha'nted room?" - -"How?" - -"Why, it's ha'nted with whiskey! Maybe ALL the Temperance Taverns have -got a ha'nted room, hey, Huck?" - -"Well, I reckon maybe that's so. Who'd 'a' thought such a thing? But -say, Tom, now's a mighty good time to get that box, if Injun Joe's -drunk." - -"It is, that! You try it!" - -Huck shuddered. - -"Well, no--I reckon not." - -"And I reckon not, Huck. Only one bottle alongside of Injun Joe ain't -enough. If there'd been three, he'd be drunk enough and I'd do it." - -There was a long pause for reflection, and then Tom said: - -"Lookyhere, Huck, less not try that thing any more till we know Injun -Joe's not in there. It's too scary. Now, if we watch every night, we'll -be dead sure to see him go out, some time or other, and then we'll -snatch that box quicker'n lightning." - -"Well, I'm agreed. I'll watch the whole night long, and I'll do it -every night, too, if you'll do the other part of the job." - -"All right, I will. All you got to do is to trot up Hooper Street a -block and maow--and if I'm asleep, you throw some gravel at the window -and that'll fetch me." - -"Agreed, and good as wheat!" - -"Now, Huck, the storm's over, and I'll go home. It'll begin to be -daylight in a couple of hours. You go back and watch that long, will -you?" - -"I said I would, Tom, and I will. I'll ha'nt that tavern every night -for a year! I'll sleep all day and I'll stand watch all night." - -"That's all right. Now, where you going to sleep?" - -"In Ben Rogers' hayloft. He lets me, and so does his pap's nigger man, -Uncle Jake. I tote water for Uncle Jake whenever he wants me to, and -any time I ask him he gives me a little something to eat if he can -spare it. That's a mighty good nigger, Tom. He likes me, becuz I don't -ever act as if I was above him. Sometime I've set right down and eat -WITH him. But you needn't tell that. A body's got to do things when -he's awful hungry he wouldn't want to do as a steady thing." - -"Well, if I don't want you in the daytime, I'll let you sleep. I won't -come bothering around. Any time you see something's up, in the night, -just skip right around and maow." - - - -CHAPTER XXIX - -THE first thing Tom heard on Friday morning was a glad piece of news ---Judge Thatcher's family had come back to town the night before. Both -Injun Joe and the treasure sunk into secondary importance for a moment, -and Becky took the chief place in the boy's interest. He saw her and -they had an exhausting good time playing "hi-spy" and "gully-keeper" -with a crowd of their school-mates. The day was completed and crowned -in a peculiarly satisfactory way: Becky teased her mother to appoint -the next day for the long-promised and long-delayed picnic, and she -consented. The child's delight was boundless; and Tom's not more -moderate. The invitations were sent out before sunset, and straightway -the young folks of the village were thrown into a fever of preparation -and pleasurable anticipation. Tom's excitement enabled him to keep -awake until a pretty late hour, and he had good hopes of hearing Huck's -"maow," and of having his treasure to astonish Becky and the picnickers -with, next day; but he was disappointed. No signal came that night. - -Morning came, eventually, and by ten or eleven o'clock a giddy and -rollicking company were gathered at Judge Thatcher's, and everything -was ready for a start. It was not the custom for elderly people to mar -the picnics with their presence. The children were considered safe -enough under the wings of a few young ladies of eighteen and a few -young gentlemen of twenty-three or thereabouts. The old steam ferryboat -was chartered for the occasion; presently the gay throng filed up the -main street laden with provision-baskets. Sid was sick and had to miss -the fun; Mary remained at home to entertain him. The last thing Mrs. -Thatcher said to Becky, was: - -"You'll not get back till late. Perhaps you'd better stay all night -with some of the girls that live near the ferry-landing, child." - -"Then I'll stay with Susy Harper, mamma." - -"Very well. And mind and behave yourself and don't be any trouble." - -Presently, as they tripped along, Tom said to Becky: - -"Say--I'll tell you what we'll do. 'Stead of going to Joe Harper's -we'll climb right up the hill and stop at the Widow Douglas'. She'll -have ice-cream! She has it most every day--dead loads of it. And she'll -be awful glad to have us." - -"Oh, that will be fun!" - -Then Becky reflected a moment and said: - -"But what will mamma say?" - -"How'll she ever know?" - -The girl turned the idea over in her mind, and said reluctantly: - -"I reckon it's wrong--but--" - -"But shucks! Your mother won't know, and so what's the harm? All she -wants is that you'll be safe; and I bet you she'd 'a' said go there if -she'd 'a' thought of it. I know she would!" - -The Widow Douglas' splendid hospitality was a tempting bait. It and -Tom's persuasions presently carried the day. So it was decided to say -nothing anybody about the night's programme. Presently it occurred to -Tom that maybe Huck might come this very night and give the signal. The -thought took a deal of the spirit out of his anticipations. Still he -could not bear to give up the fun at Widow Douglas'. And why should he -give it up, he reasoned--the signal did not come the night before, so -why should it be any more likely to come to-night? The sure fun of the -evening outweighed the uncertain treasure; and, boy-like, he determined -to yield to the stronger inclination and not allow himself to think of -the box of money another time that day. - -Three miles below town the ferryboat stopped at the mouth of a woody -hollow and tied up. The crowd swarmed ashore and soon the forest -distances and craggy heights echoed far and near with shoutings and -laughter. All the different ways of getting hot and tired were gone -through with, and by-and-by the rovers straggled back to camp fortified -with responsible appetites, and then the destruction of the good things -began. After the feast there was a refreshing season of rest and chat -in the shade of spreading oaks. By-and-by somebody shouted: - -"Who's ready for the cave?" - -Everybody was. Bundles of candles were procured, and straightway there -was a general scamper up the hill. The mouth of the cave was up the -hillside--an opening shaped like a letter A. Its massive oaken door -stood unbarred. Within was a small chamber, chilly as an ice-house, and -walled by Nature with solid limestone that was dewy with a cold sweat. -It was romantic and mysterious to stand here in the deep gloom and look -out upon the green valley shining in the sun. But the impressiveness of -the situation quickly wore off, and the romping began again. The moment -a candle was lighted there was a general rush upon the owner of it; a -struggle and a gallant defence followed, but the candle was soon -knocked down or blown out, and then there was a glad clamor of laughter -and a new chase. But all things have an end. By-and-by the procession -went filing down the steep descent of the main avenue, the flickering -rank of lights dimly revealing the lofty walls of rock almost to their -point of junction sixty feet overhead. This main avenue was not more -than eight or ten feet wide. Every few steps other lofty and still -narrower crevices branched from it on either hand--for McDougal's cave -was but a vast labyrinth of crooked aisles that ran into each other and -out again and led nowhere. It was said that one might wander days and -nights together through its intricate tangle of rifts and chasms, and -never find the end of the cave; and that he might go down, and down, -and still down, into the earth, and it was just the same--labyrinth -under labyrinth, and no end to any of them. No man "knew" the cave. -That was an impossible thing. Most of the young men knew a portion of -it, and it was not customary to venture much beyond this known portion. -Tom Sawyer knew as much of the cave as any one. - -The procession moved along the main avenue some three-quarters of a -mile, and then groups and couples began to slip aside into branch -avenues, fly along the dismal corridors, and take each other by -surprise at points where the corridors joined again. Parties were able -to elude each other for the space of half an hour without going beyond -the "known" ground. - -By-and-by, one group after another came straggling back to the mouth -of the cave, panting, hilarious, smeared from head to foot with tallow -drippings, daubed with clay, and entirely delighted with the success of -the day. Then they were astonished to find that they had been taking no -note of time and that night was about at hand. The clanging bell had -been calling for half an hour. However, this sort of close to the day's -adventures was romantic and therefore satisfactory. When the ferryboat -with her wild freight pushed into the stream, nobody cared sixpence for -the wasted time but the captain of the craft. - -Huck was already upon his watch when the ferryboat's lights went -glinting past the wharf. He heard no noise on board, for the young -people were as subdued and still as people usually are who are nearly -tired to death. He wondered what boat it was, and why she did not stop -at the wharf--and then he dropped her out of his mind and put his -attention upon his business. The night was growing cloudy and dark. Ten -o'clock came, and the noise of vehicles ceased, scattered lights began -to wink out, all straggling foot-passengers disappeared, the village -betook itself to its slumbers and left the small watcher alone with the -silence and the ghosts. Eleven o'clock came, and the tavern lights were -put out; darkness everywhere, now. Huck waited what seemed a weary long -time, but nothing happened. His faith was weakening. Was there any use? -Was there really any use? Why not give it up and turn in? - -A noise fell upon his ear. He was all attention in an instant. The -alley door closed softly. He sprang to the corner of the brick store. -The next moment two men brushed by him, and one seemed to have -something under his arm. It must be that box! So they were going to -remove the treasure. Why call Tom now? It would be absurd--the men -would get away with the box and never be found again. No, he would -stick to their wake and follow them; he would trust to the darkness for -security from discovery. So communing with himself, Huck stepped out -and glided along behind the men, cat-like, with bare feet, allowing -them to keep just far enough ahead not to be invisible. - -They moved up the river street three blocks, then turned to the left -up a cross-street. They went straight ahead, then, until they came to -the path that led up Cardiff Hill; this they took. They passed by the -old Welshman's house, half-way up the hill, without hesitating, and -still climbed upward. Good, thought Huck, they will bury it in the old -quarry. But they never stopped at the quarry. They passed on, up the -summit. They plunged into the narrow path between the tall sumach -bushes, and were at once hidden in the gloom. Huck closed up and -shortened his distance, now, for they would never be able to see him. -He trotted along awhile; then slackened his pace, fearing he was -gaining too fast; moved on a piece, then stopped altogether; listened; -no sound; none, save that he seemed to hear the beating of his own -heart. The hooting of an owl came over the hill--ominous sound! But no -footsteps. Heavens, was everything lost! He was about to spring with -winged feet, when a man cleared his throat not four feet from him! -Huck's heart shot into his throat, but he swallowed it again; and then -he stood there shaking as if a dozen agues had taken charge of him at -once, and so weak that he thought he must surely fall to the ground. He -knew where he was. He knew he was within five steps of the stile -leading into Widow Douglas' grounds. Very well, he thought, let them -bury it there; it won't be hard to find. - -Now there was a voice--a very low voice--Injun Joe's: - -"Damn her, maybe she's got company--there's lights, late as it is." - -"I can't see any." - -This was that stranger's voice--the stranger of the haunted house. A -deadly chill went to Huck's heart--this, then, was the "revenge" job! -His thought was, to fly. Then he remembered that the Widow Douglas had -been kind to him more than once, and maybe these men were going to -murder her. He wished he dared venture to warn her; but he knew he -didn't dare--they might come and catch him. He thought all this and -more in the moment that elapsed between the stranger's remark and Injun -Joe's next--which was-- - -"Because the bush is in your way. Now--this way--now you see, don't -you?" - -"Yes. Well, there IS company there, I reckon. Better give it up." - -"Give it up, and I just leaving this country forever! Give it up and -maybe never have another chance. I tell you again, as I've told you -before, I don't care for her swag--you may have it. But her husband was -rough on me--many times he was rough on me--and mainly he was the -justice of the peace that jugged me for a vagrant. And that ain't all. -It ain't a millionth part of it! He had me HORSEWHIPPED!--horsewhipped -in front of the jail, like a nigger!--with all the town looking on! -HORSEWHIPPED!--do you understand? He took advantage of me and died. But -I'll take it out of HER." - -"Oh, don't kill her! Don't do that!" - -"Kill? Who said anything about killing? I would kill HIM if he was -here; but not her. When you want to get revenge on a woman you don't -kill her--bosh! you go for her looks. You slit her nostrils--you notch -her ears like a sow!" - -"By God, that's--" - -"Keep your opinion to yourself! It will be safest for you. I'll tie -her to the bed. If she bleeds to death, is that my fault? I'll not cry, -if she does. My friend, you'll help me in this thing--for MY sake ---that's why you're here--I mightn't be able alone. If you flinch, I'll -kill you. Do you understand that? And if I have to kill you, I'll kill -her--and then I reckon nobody'll ever know much about who done this -business." - -"Well, if it's got to be done, let's get at it. The quicker the -better--I'm all in a shiver." - -"Do it NOW? And company there? Look here--I'll get suspicious of you, -first thing you know. No--we'll wait till the lights are out--there's -no hurry." - -Huck felt that a silence was going to ensue--a thing still more awful -than any amount of murderous talk; so he held his breath and stepped -gingerly back; planted his foot carefully and firmly, after balancing, -one-legged, in a precarious way and almost toppling over, first on one -side and then on the other. He took another step back, with the same -elaboration and the same risks; then another and another, and--a twig -snapped under his foot! His breath stopped and he listened. There was -no sound--the stillness was perfect. His gratitude was measureless. Now -he turned in his tracks, between the walls of sumach bushes--turned -himself as carefully as if he were a ship--and then stepped quickly but -cautiously along. When he emerged at the quarry he felt secure, and so -he picked up his nimble heels and flew. Down, down he sped, till he -reached the Welshman's. He banged at the door, and presently the heads -of the old man and his two stalwart sons were thrust from windows. - -"What's the row there? Who's banging? What do you want?" - -"Let me in--quick! I'll tell everything." - -"Why, who are you?" - -"Huckleberry Finn--quick, let me in!" - -"Huckleberry Finn, indeed! It ain't a name to open many doors, I -judge! But let him in, lads, and let's see what's the trouble." - -"Please don't ever tell I told you," were Huck's first words when he -got in. "Please don't--I'd be killed, sure--but the widow's been good -friends to me sometimes, and I want to tell--I WILL tell if you'll -promise you won't ever say it was me." - -"By George, he HAS got something to tell, or he wouldn't act so!" -exclaimed the old man; "out with it and nobody here'll ever tell, lad." - -Three minutes later the old man and his sons, well armed, were up the -hill, and just entering the sumach path on tiptoe, their weapons in -their hands. Huck accompanied them no further. He hid behind a great -bowlder and fell to listening. There was a lagging, anxious silence, -and then all of a sudden there was an explosion of firearms and a cry. - -Huck waited for no particulars. He sprang away and sped down the hill -as fast as his legs could carry him. - - - -CHAPTER XXX - -AS the earliest suspicion of dawn appeared on Sunday morning, Huck -came groping up the hill and rapped gently at the old Welshman's door. -The inmates were asleep, but it was a sleep that was set on a -hair-trigger, on account of the exciting episode of the night. A call -came from a window: - -"Who's there!" - -Huck's scared voice answered in a low tone: - -"Please let me in! It's only Huck Finn!" - -"It's a name that can open this door night or day, lad!--and welcome!" - -These were strange words to the vagabond boy's ears, and the -pleasantest he had ever heard. He could not recollect that the closing -word had ever been applied in his case before. The door was quickly -unlocked, and he entered. Huck was given a seat and the old man and his -brace of tall sons speedily dressed themselves. - -"Now, my boy, I hope you're good and hungry, because breakfast will be -ready as soon as the sun's up, and we'll have a piping hot one, too ---make yourself easy about that! I and the boys hoped you'd turn up and -stop here last night." - -"I was awful scared," said Huck, "and I run. I took out when the -pistols went off, and I didn't stop for three mile. I've come now becuz -I wanted to know about it, you know; and I come before daylight becuz I -didn't want to run across them devils, even if they was dead." - -"Well, poor chap, you do look as if you'd had a hard night of it--but -there's a bed here for you when you've had your breakfast. No, they -ain't dead, lad--we are sorry enough for that. You see we knew right -where to put our hands on them, by your description; so we crept along -on tiptoe till we got within fifteen feet of them--dark as a cellar -that sumach path was--and just then I found I was going to sneeze. It -was the meanest kind of luck! I tried to keep it back, but no use ---'twas bound to come, and it did come! I was in the lead with my pistol -raised, and when the sneeze started those scoundrels a-rustling to get -out of the path, I sung out, 'Fire boys!' and blazed away at the place -where the rustling was. So did the boys. But they were off in a jiffy, -those villains, and we after them, down through the woods. I judge we -never touched them. They fired a shot apiece as they started, but their -bullets whizzed by and didn't do us any harm. As soon as we lost the -sound of their feet we quit chasing, and went down and stirred up the -constables. They got a posse together, and went off to guard the river -bank, and as soon as it is light the sheriff and a gang are going to -beat up the woods. My boys will be with them presently. I wish we had -some sort of description of those rascals--'twould help a good deal. -But you couldn't see what they were like, in the dark, lad, I suppose?" - -"Oh yes; I saw them down-town and follered them." - -"Splendid! Describe them--describe them, my boy!" - -"One's the old deaf and dumb Spaniard that's ben around here once or -twice, and t'other's a mean-looking, ragged--" - -"That's enough, lad, we know the men! Happened on them in the woods -back of the widow's one day, and they slunk away. Off with you, boys, -and tell the sheriff--get your breakfast to-morrow morning!" - -The Welshman's sons departed at once. As they were leaving the room -Huck sprang up and exclaimed: - -"Oh, please don't tell ANYbody it was me that blowed on them! Oh, -please!" - -"All right if you say it, Huck, but you ought to have the credit of -what you did." - -"Oh no, no! Please don't tell!" - -When the young men were gone, the old Welshman said: - -"They won't tell--and I won't. But why don't you want it known?" - -Huck would not explain, further than to say that he already knew too -much about one of those men and would not have the man know that he -knew anything against him for the whole world--he would be killed for -knowing it, sure. - -The old man promised secrecy once more, and said: - -"How did you come to follow these fellows, lad? Were they looking -suspicious?" - -Huck was silent while he framed a duly cautious reply. Then he said: - -"Well, you see, I'm a kind of a hard lot,--least everybody says so, -and I don't see nothing agin it--and sometimes I can't sleep much, on -account of thinking about it and sort of trying to strike out a new way -of doing. That was the way of it last night. I couldn't sleep, and so I -come along up-street 'bout midnight, a-turning it all over, and when I -got to that old shackly brick store by the Temperance Tavern, I backed -up agin the wall to have another think. Well, just then along comes -these two chaps slipping along close by me, with something under their -arm, and I reckoned they'd stole it. One was a-smoking, and t'other one -wanted a light; so they stopped right before me and the cigars lit up -their faces and I see that the big one was the deaf and dumb Spaniard, -by his white whiskers and the patch on his eye, and t'other one was a -rusty, ragged-looking devil." - -"Could you see the rags by the light of the cigars?" - -This staggered Huck for a moment. Then he said: - -"Well, I don't know--but somehow it seems as if I did." - -"Then they went on, and you--" - -"Follered 'em--yes. That was it. I wanted to see what was up--they -sneaked along so. I dogged 'em to the widder's stile, and stood in the -dark and heard the ragged one beg for the widder, and the Spaniard -swear he'd spile her looks just as I told you and your two--" - -"What! The DEAF AND DUMB man said all that!" - -Huck had made another terrible mistake! He was trying his best to keep -the old man from getting the faintest hint of who the Spaniard might -be, and yet his tongue seemed determined to get him into trouble in -spite of all he could do. He made several efforts to creep out of his -scrape, but the old man's eye was upon him and he made blunder after -blunder. Presently the Welshman said: - -"My boy, don't be afraid of me. I wouldn't hurt a hair of your head -for all the world. No--I'd protect you--I'd protect you. This Spaniard -is not deaf and dumb; you've let that slip without intending it; you -can't cover that up now. You know something about that Spaniard that -you want to keep dark. Now trust me--tell me what it is, and trust me ---I won't betray you." - -Huck looked into the old man's honest eyes a moment, then bent over -and whispered in his ear: - -"'Tain't a Spaniard--it's Injun Joe!" - -The Welshman almost jumped out of his chair. In a moment he said: - -"It's all plain enough, now. When you talked about notching ears and -slitting noses I judged that that was your own embellishment, because -white men don't take that sort of revenge. But an Injun! That's a -different matter altogether." - -During breakfast the talk went on, and in the course of it the old man -said that the last thing which he and his sons had done, before going -to bed, was to get a lantern and examine the stile and its vicinity for -marks of blood. They found none, but captured a bulky bundle of-- - -"Of WHAT?" - -If the words had been lightning they could not have leaped with a more -stunning suddenness from Huck's blanched lips. His eyes were staring -wide, now, and his breath suspended--waiting for the answer. The -Welshman started--stared in return--three seconds--five seconds--ten ---then replied: - -"Of burglar's tools. Why, what's the MATTER with you?" - -Huck sank back, panting gently, but deeply, unutterably grateful. The -Welshman eyed him gravely, curiously--and presently said: - -"Yes, burglar's tools. That appears to relieve you a good deal. But -what did give you that turn? What were YOU expecting we'd found?" - -Huck was in a close place--the inquiring eye was upon him--he would -have given anything for material for a plausible answer--nothing -suggested itself--the inquiring eye was boring deeper and deeper--a -senseless reply offered--there was no time to weigh it, so at a venture -he uttered it--feebly: - -"Sunday-school books, maybe." - -Poor Huck was too distressed to smile, but the old man laughed loud -and joyously, shook up the details of his anatomy from head to foot, -and ended by saying that such a laugh was money in a-man's pocket, -because it cut down the doctor's bill like everything. Then he added: - -"Poor old chap, you're white and jaded--you ain't well a bit--no -wonder you're a little flighty and off your balance. But you'll come -out of it. Rest and sleep will fetch you out all right, I hope." - -Huck was irritated to think he had been such a goose and betrayed such -a suspicious excitement, for he had dropped the idea that the parcel -brought from the tavern was the treasure, as soon as he had heard the -talk at the widow's stile. He had only thought it was not the treasure, -however--he had not known that it wasn't--and so the suggestion of a -captured bundle was too much for his self-possession. But on the whole -he felt glad the little episode had happened, for now he knew beyond -all question that that bundle was not THE bundle, and so his mind was -at rest and exceedingly comfortable. In fact, everything seemed to be -drifting just in the right direction, now; the treasure must be still -in No. 2, the men would be captured and jailed that day, and he and Tom -could seize the gold that night without any trouble or any fear of -interruption. - -Just as breakfast was completed there was a knock at the door. Huck -jumped for a hiding-place, for he had no mind to be connected even -remotely with the late event. The Welshman admitted several ladies and -gentlemen, among them the Widow Douglas, and noticed that groups of -citizens were climbing up the hill--to stare at the stile. So the news -had spread. The Welshman had to tell the story of the night to the -visitors. The widow's gratitude for her preservation was outspoken. - -"Don't say a word about it, madam. There's another that you're more -beholden to than you are to me and my boys, maybe, but he don't allow -me to tell his name. We wouldn't have been there but for him." - -Of course this excited a curiosity so vast that it almost belittled -the main matter--but the Welshman allowed it to eat into the vitals of -his visitors, and through them be transmitted to the whole town, for he -refused to part with his secret. When all else had been learned, the -widow said: - -"I went to sleep reading in bed and slept straight through all that -noise. Why didn't you come and wake me?" - -"We judged it warn't worth while. Those fellows warn't likely to come -again--they hadn't any tools left to work with, and what was the use of -waking you up and scaring you to death? My three negro men stood guard -at your house all the rest of the night. They've just come back." - -More visitors came, and the story had to be told and retold for a -couple of hours more. - -There was no Sabbath-school during day-school vacation, but everybody -was early at church. The stirring event was well canvassed. News came -that not a sign of the two villains had been yet discovered. When the -sermon was finished, Judge Thatcher's wife dropped alongside of Mrs. -Harper as she moved down the aisle with the crowd and said: - -"Is my Becky going to sleep all day? I just expected she would be -tired to death." - -"Your Becky?" - -"Yes," with a startled look--"didn't she stay with you last night?" - -"Why, no." - -Mrs. Thatcher turned pale, and sank into a pew, just as Aunt Polly, -talking briskly with a friend, passed by. Aunt Polly said: - -"Good-morning, Mrs. Thatcher. Good-morning, Mrs. Harper. I've got a -boy that's turned up missing. I reckon my Tom stayed at your house last -night--one of you. And now he's afraid to come to church. I've got to -settle with him." - -Mrs. Thatcher shook her head feebly and turned paler than ever. - -"He didn't stay with us," said Mrs. Harper, beginning to look uneasy. -A marked anxiety came into Aunt Polly's face. - -"Joe Harper, have you seen my Tom this morning?" - -"No'm." - -"When did you see him last?" - -Joe tried to remember, but was not sure he could say. The people had -stopped moving out of church. Whispers passed along, and a boding -uneasiness took possession of every countenance. Children were -anxiously questioned, and young teachers. They all said they had not -noticed whether Tom and Becky were on board the ferryboat on the -homeward trip; it was dark; no one thought of inquiring if any one was -missing. One young man finally blurted out his fear that they were -still in the cave! Mrs. Thatcher swooned away. Aunt Polly fell to -crying and wringing her hands. - -The alarm swept from lip to lip, from group to group, from street to -street, and within five minutes the bells were wildly clanging and the -whole town was up! The Cardiff Hill episode sank into instant -insignificance, the burglars were forgotten, horses were saddled, -skiffs were manned, the ferryboat ordered out, and before the horror -was half an hour old, two hundred men were pouring down highroad and -river toward the cave. - -All the long afternoon the village seemed empty and dead. Many women -visited Aunt Polly and Mrs. Thatcher and tried to comfort them. They -cried with them, too, and that was still better than words. All the -tedious night the town waited for news; but when the morning dawned at -last, all the word that came was, "Send more candles--and send food." -Mrs. Thatcher was almost crazed; and Aunt Polly, also. Judge Thatcher -sent messages of hope and encouragement from the cave, but they -conveyed no real cheer. - -The old Welshman came home toward daylight, spattered with -candle-grease, smeared with clay, and almost worn out. He found Huck -still in the bed that had been provided for him, and delirious with -fever. The physicians were all at the cave, so the Widow Douglas came -and took charge of the patient. She said she would do her best by him, -because, whether he was good, bad, or indifferent, he was the Lord's, -and nothing that was the Lord's was a thing to be neglected. The -Welshman said Huck had good spots in him, and the widow said: - -"You can depend on it. That's the Lord's mark. He don't leave it off. -He never does. Puts it somewhere on every creature that comes from his -hands." - -Early in the forenoon parties of jaded men began to straggle into the -village, but the strongest of the citizens continued searching. All the -news that could be gained was that remotenesses of the cavern were -being ransacked that had never been visited before; that every corner -and crevice was going to be thoroughly searched; that wherever one -wandered through the maze of passages, lights were to be seen flitting -hither and thither in the distance, and shoutings and pistol-shots sent -their hollow reverberations to the ear down the sombre aisles. In one -place, far from the section usually traversed by tourists, the names -"BECKY & TOM" had been found traced upon the rocky wall with -candle-smoke, and near at hand a grease-soiled bit of ribbon. Mrs. -Thatcher recognized the ribbon and cried over it. She said it was the -last relic she should ever have of her child; and that no other memorial -of her could ever be so precious, because this one parted latest from -the living body before the awful death came. Some said that now and -then, in the cave, a far-away speck of light would glimmer, and then a -glorious shout would burst forth and a score of men go trooping down the -echoing aisle--and then a sickening disappointment always followed; the -children were not there; it was only a searcher's light. - -Three dreadful days and nights dragged their tedious hours along, and -the village sank into a hopeless stupor. No one had heart for anything. -The accidental discovery, just made, that the proprietor of the -Temperance Tavern kept liquor on his premises, scarcely fluttered the -public pulse, tremendous as the fact was. In a lucid interval, Huck -feebly led up to the subject of taverns, and finally asked--dimly -dreading the worst--if anything had been discovered at the Temperance -Tavern since he had been ill. - -"Yes," said the widow. - -Huck started up in bed, wild-eyed: - -"What? What was it?" - -"Liquor!--and the place has been shut up. Lie down, child--what a turn -you did give me!" - -"Only tell me just one thing--only just one--please! Was it Tom Sawyer -that found it?" - -The widow burst into tears. "Hush, hush, child, hush! I've told you -before, you must NOT talk. You are very, very sick!" - -Then nothing but liquor had been found; there would have been a great -powwow if it had been the gold. So the treasure was gone forever--gone -forever! But what could she be crying about? Curious that she should -cry. - -These thoughts worked their dim way through Huck's mind, and under the -weariness they gave him he fell asleep. The widow said to herself: - -"There--he's asleep, poor wreck. Tom Sawyer find it! Pity but somebody -could find Tom Sawyer! Ah, there ain't many left, now, that's got hope -enough, or strength enough, either, to go on searching." - - - -CHAPTER XXXI - -NOW to return to Tom and Becky's share in the picnic. They tripped -along the murky aisles with the rest of the company, visiting the -familiar wonders of the cave--wonders dubbed with rather -over-descriptive names, such as "The Drawing-Room," "The Cathedral," -"Aladdin's Palace," and so on. Presently the hide-and-seek frolicking -began, and Tom and Becky engaged in it with zeal until the exertion -began to grow a trifle wearisome; then they wandered down a sinuous -avenue holding their candles aloft and reading the tangled web-work of -names, dates, post-office addresses, and mottoes with which the rocky -walls had been frescoed (in candle-smoke). Still drifting along and -talking, they scarcely noticed that they were now in a part of the cave -whose walls were not frescoed. They smoked their own names under an -overhanging shelf and moved on. Presently they came to a place where a -little stream of water, trickling over a ledge and carrying a limestone -sediment with it, had, in the slow-dragging ages, formed a laced and -ruffled Niagara in gleaming and imperishable stone. Tom squeezed his -small body behind it in order to illuminate it for Becky's -gratification. He found that it curtained a sort of steep natural -stairway which was enclosed between narrow walls, and at once the -ambition to be a discoverer seized him. Becky responded to his call, -and they made a smoke-mark for future guidance, and started upon their -quest. They wound this way and that, far down into the secret depths of -the cave, made another mark, and branched off in search of novelties to -tell the upper world about. In one place they found a spacious cavern, -from whose ceiling depended a multitude of shining stalactites of the -length and circumference of a man's leg; they walked all about it, -wondering and admiring, and presently left it by one of the numerous -passages that opened into it. This shortly brought them to a bewitching -spring, whose basin was incrusted with a frostwork of glittering -crystals; it was in the midst of a cavern whose walls were supported by -many fantastic pillars which had been formed by the joining of great -stalactites and stalagmites together, the result of the ceaseless -water-drip of centuries. Under the roof vast knots of bats had packed -themselves together, thousands in a bunch; the lights disturbed the -creatures and they came flocking down by hundreds, squeaking and -darting furiously at the candles. Tom knew their ways and the danger of -this sort of conduct. He seized Becky's hand and hurried her into the -first corridor that offered; and none too soon, for a bat struck -Becky's light out with its wing while she was passing out of the -cavern. The bats chased the children a good distance; but the fugitives -plunged into every new passage that offered, and at last got rid of the -perilous things. Tom found a subterranean lake, shortly, which -stretched its dim length away until its shape was lost in the shadows. -He wanted to explore its borders, but concluded that it would be best -to sit down and rest awhile, first. Now, for the first time, the deep -stillness of the place laid a clammy hand upon the spirits of the -children. Becky said: - -"Why, I didn't notice, but it seems ever so long since I heard any of -the others." - -"Come to think, Becky, we are away down below them--and I don't know -how far away north, or south, or east, or whichever it is. We couldn't -hear them here." - -Becky grew apprehensive. - -"I wonder how long we've been down here, Tom? We better start back." - -"Yes, I reckon we better. P'raps we better." - -"Can you find the way, Tom? It's all a mixed-up crookedness to me." - -"I reckon I could find it--but then the bats. If they put our candles -out it will be an awful fix. Let's try some other way, so as not to go -through there." - -"Well. But I hope we won't get lost. It would be so awful!" and the -girl shuddered at the thought of the dreadful possibilities. - -They started through a corridor, and traversed it in silence a long -way, glancing at each new opening, to see if there was anything -familiar about the look of it; but they were all strange. Every time -Tom made an examination, Becky would watch his face for an encouraging -sign, and he would say cheerily: - -"Oh, it's all right. This ain't the one, but we'll come to it right -away!" - -But he felt less and less hopeful with each failure, and presently -began to turn off into diverging avenues at sheer random, in desperate -hope of finding the one that was wanted. He still said it was "all -right," but there was such a leaden dread at his heart that the words -had lost their ring and sounded just as if he had said, "All is lost!" -Becky clung to his side in an anguish of fear, and tried hard to keep -back the tears, but they would come. At last she said: - -"Oh, Tom, never mind the bats, let's go back that way! We seem to get -worse and worse off all the time." - -"Listen!" said he. - -Profound silence; silence so deep that even their breathings were -conspicuous in the hush. Tom shouted. The call went echoing down the -empty aisles and died out in the distance in a faint sound that -resembled a ripple of mocking laughter. - -"Oh, don't do it again, Tom, it is too horrid," said Becky. - -"It is horrid, but I better, Becky; they might hear us, you know," and -he shouted again. - -The "might" was even a chillier horror than the ghostly laughter, it -so confessed a perishing hope. The children stood still and listened; -but there was no result. Tom turned upon the back track at once, and -hurried his steps. It was but a little while before a certain -indecision in his manner revealed another fearful fact to Becky--he -could not find his way back! - -"Oh, Tom, you didn't make any marks!" - -"Becky, I was such a fool! Such a fool! I never thought we might want -to come back! No--I can't find the way. It's all mixed up." - -"Tom, Tom, we're lost! we're lost! We never can get out of this awful -place! Oh, why DID we ever leave the others!" - -She sank to the ground and burst into such a frenzy of crying that Tom -was appalled with the idea that she might die, or lose her reason. He -sat down by her and put his arms around her; she buried her face in his -bosom, she clung to him, she poured out her terrors, her unavailing -regrets, and the far echoes turned them all to jeering laughter. Tom -begged her to pluck up hope again, and she said she could not. He fell -to blaming and abusing himself for getting her into this miserable -situation; this had a better effect. She said she would try to hope -again, she would get up and follow wherever he might lead if only he -would not talk like that any more. For he was no more to blame than -she, she said. - -So they moved on again--aimlessly--simply at random--all they could do -was to move, keep moving. For a little while, hope made a show of -reviving--not with any reason to back it, but only because it is its -nature to revive when the spring has not been taken out of it by age -and familiarity with failure. - -By-and-by Tom took Becky's candle and blew it out. This economy meant -so much! Words were not needed. Becky understood, and her hope died -again. She knew that Tom had a whole candle and three or four pieces in -his pockets--yet he must economize. - -By-and-by, fatigue began to assert its claims; the children tried to -pay attention, for it was dreadful to think of sitting down when time -was grown to be so precious, moving, in some direction, in any -direction, was at least progress and might bear fruit; but to sit down -was to invite death and shorten its pursuit. - -At last Becky's frail limbs refused to carry her farther. She sat -down. Tom rested with her, and they talked of home, and the friends -there, and the comfortable beds and, above all, the light! Becky cried, -and Tom tried to think of some way of comforting her, but all his -encouragements were grown threadbare with use, and sounded like -sarcasms. Fatigue bore so heavily upon Becky that she drowsed off to -sleep. Tom was grateful. He sat looking into her drawn face and saw it -grow smooth and natural under the influence of pleasant dreams; and -by-and-by a smile dawned and rested there. The peaceful face reflected -somewhat of peace and healing into his own spirit, and his thoughts -wandered away to bygone times and dreamy memories. While he was deep in -his musings, Becky woke up with a breezy little laugh--but it was -stricken dead upon her lips, and a groan followed it. - -"Oh, how COULD I sleep! I wish I never, never had waked! No! No, I -don't, Tom! Don't look so! I won't say it again." - -"I'm glad you've slept, Becky; you'll feel rested, now, and we'll find -the way out." - -"We can try, Tom; but I've seen such a beautiful country in my dream. -I reckon we are going there." - -"Maybe not, maybe not. Cheer up, Becky, and let's go on trying." - -They rose up and wandered along, hand in hand and hopeless. They tried -to estimate how long they had been in the cave, but all they knew was -that it seemed days and weeks, and yet it was plain that this could not -be, for their candles were not gone yet. A long time after this--they -could not tell how long--Tom said they must go softly and listen for -dripping water--they must find a spring. They found one presently, and -Tom said it was time to rest again. Both were cruelly tired, yet Becky -said she thought she could go a little farther. She was surprised to -hear Tom dissent. She could not understand it. They sat down, and Tom -fastened his candle to the wall in front of them with some clay. -Thought was soon busy; nothing was said for some time. Then Becky broke -the silence: - -"Tom, I am so hungry!" - -Tom took something out of his pocket. - -"Do you remember this?" said he. - -Becky almost smiled. - -"It's our wedding-cake, Tom." - -"Yes--I wish it was as big as a barrel, for it's all we've got." - -"I saved it from the picnic for us to dream on, Tom, the way grown-up -people do with wedding-cake--but it'll be our--" - -She dropped the sentence where it was. Tom divided the cake and Becky -ate with good appetite, while Tom nibbled at his moiety. There was -abundance of cold water to finish the feast with. By-and-by Becky -suggested that they move on again. Tom was silent a moment. Then he -said: - -"Becky, can you bear it if I tell you something?" - -Becky's face paled, but she thought she could. - -"Well, then, Becky, we must stay here, where there's water to drink. -That little piece is our last candle!" - -Becky gave loose to tears and wailings. Tom did what he could to -comfort her, but with little effect. At length Becky said: - -"Tom!" - -"Well, Becky?" - -"They'll miss us and hunt for us!" - -"Yes, they will! Certainly they will!" - -"Maybe they're hunting for us now, Tom." - -"Why, I reckon maybe they are. I hope they are." - -"When would they miss us, Tom?" - -"When they get back to the boat, I reckon." - -"Tom, it might be dark then--would they notice we hadn't come?" - -"I don't know. But anyway, your mother would miss you as soon as they -got home." - -A frightened look in Becky's face brought Tom to his senses and he saw -that he had made a blunder. Becky was not to have gone home that night! -The children became silent and thoughtful. In a moment a new burst of -grief from Becky showed Tom that the thing in his mind had struck hers -also--that the Sabbath morning might be half spent before Mrs. Thatcher -discovered that Becky was not at Mrs. Harper's. - -The children fastened their eyes upon their bit of candle and watched -it melt slowly and pitilessly away; saw the half inch of wick stand -alone at last; saw the feeble flame rise and fall, climb the thin -column of smoke, linger at its top a moment, and then--the horror of -utter darkness reigned! - -How long afterward it was that Becky came to a slow consciousness that -she was crying in Tom's arms, neither could tell. All that they knew -was, that after what seemed a mighty stretch of time, both awoke out of -a dead stupor of sleep and resumed their miseries once more. Tom said -it might be Sunday, now--maybe Monday. He tried to get Becky to talk, -but her sorrows were too oppressive, all her hopes were gone. Tom said -that they must have been missed long ago, and no doubt the search was -going on. He would shout and maybe some one would come. He tried it; -but in the darkness the distant echoes sounded so hideously that he -tried it no more. - -The hours wasted away, and hunger came to torment the captives again. -A portion of Tom's half of the cake was left; they divided and ate it. -But they seemed hungrier than before. The poor morsel of food only -whetted desire. - -By-and-by Tom said: - -"SH! Did you hear that?" - -Both held their breath and listened. There was a sound like the -faintest, far-off shout. Instantly Tom answered it, and leading Becky -by the hand, started groping down the corridor in its direction. -Presently he listened again; again the sound was heard, and apparently -a little nearer. - -"It's them!" said Tom; "they're coming! Come along, Becky--we're all -right now!" - -The joy of the prisoners was almost overwhelming. Their speed was -slow, however, because pitfalls were somewhat common, and had to be -guarded against. They shortly came to one and had to stop. It might be -three feet deep, it might be a hundred--there was no passing it at any -rate. Tom got down on his breast and reached as far down as he could. -No bottom. They must stay there and wait until the searchers came. They -listened; evidently the distant shoutings were growing more distant! a -moment or two more and they had gone altogether. The heart-sinking -misery of it! Tom whooped until he was hoarse, but it was of no use. He -talked hopefully to Becky; but an age of anxious waiting passed and no -sounds came again. - -The children groped their way back to the spring. The weary time -dragged on; they slept again, and awoke famished and woe-stricken. Tom -believed it must be Tuesday by this time. - -Now an idea struck him. There were some side passages near at hand. It -would be better to explore some of these than bear the weight of the -heavy time in idleness. He took a kite-line from his pocket, tied it to -a projection, and he and Becky started, Tom in the lead, unwinding the -line as he groped along. At the end of twenty steps the corridor ended -in a "jumping-off place." Tom got down on his knees and felt below, and -then as far around the corner as he could reach with his hands -conveniently; he made an effort to stretch yet a little farther to the -right, and at that moment, not twenty yards away, a human hand, holding -a candle, appeared from behind a rock! Tom lifted up a glorious shout, -and instantly that hand was followed by the body it belonged to--Injun -Joe's! Tom was paralyzed; he could not move. He was vastly gratified -the next moment, to see the "Spaniard" take to his heels and get -himself out of sight. Tom wondered that Joe had not recognized his -voice and come over and killed him for testifying in court. But the -echoes must have disguised the voice. Without doubt, that was it, he -reasoned. Tom's fright weakened every muscle in his body. He said to -himself that if he had strength enough to get back to the spring he -would stay there, and nothing should tempt him to run the risk of -meeting Injun Joe again. He was careful to keep from Becky what it was -he had seen. He told her he had only shouted "for luck." - -But hunger and wretchedness rise superior to fears in the long run. -Another tedious wait at the spring and another long sleep brought -changes. The children awoke tortured with a raging hunger. Tom believed -that it must be Wednesday or Thursday or even Friday or Saturday, now, -and that the search had been given over. He proposed to explore another -passage. He felt willing to risk Injun Joe and all other terrors. But -Becky was very weak. She had sunk into a dreary apathy and would not be -roused. She said she would wait, now, where she was, and die--it would -not be long. She told Tom to go with the kite-line and explore if he -chose; but she implored him to come back every little while and speak -to her; and she made him promise that when the awful time came, he -would stay by her and hold her hand until all was over. - -Tom kissed her, with a choking sensation in his throat, and made a -show of being confident of finding the searchers or an escape from the -cave; then he took the kite-line in his hand and went groping down one -of the passages on his hands and knees, distressed with hunger and sick -with bodings of coming doom. - - - -CHAPTER XXXII - -TUESDAY afternoon came, and waned to the twilight. The village of St. -Petersburg still mourned. The lost children had not been found. Public -prayers had been offered up for them, and many and many a private -prayer that had the petitioner's whole heart in it; but still no good -news came from the cave. The majority of the searchers had given up the -quest and gone back to their daily avocations, saying that it was plain -the children could never be found. Mrs. Thatcher was very ill, and a -great part of the time delirious. People said it was heartbreaking to -hear her call her child, and raise her head and listen a whole minute -at a time, then lay it wearily down again with a moan. Aunt Polly had -drooped into a settled melancholy, and her gray hair had grown almost -white. The village went to its rest on Tuesday night, sad and forlorn. - -Away in the middle of the night a wild peal burst from the village -bells, and in a moment the streets were swarming with frantic half-clad -people, who shouted, "Turn out! turn out! they're found! they're -found!" Tin pans and horns were added to the din, the population massed -itself and moved toward the river, met the children coming in an open -carriage drawn by shouting citizens, thronged around it, joined its -homeward march, and swept magnificently up the main street roaring -huzzah after huzzah! - -The village was illuminated; nobody went to bed again; it was the -greatest night the little town had ever seen. During the first half-hour -a procession of villagers filed through Judge Thatcher's house, seized -the saved ones and kissed them, squeezed Mrs. Thatcher's hand, tried to -speak but couldn't--and drifted out raining tears all over the place. - -Aunt Polly's happiness was complete, and Mrs. Thatcher's nearly so. It -would be complete, however, as soon as the messenger dispatched with -the great news to the cave should get the word to her husband. Tom lay -upon a sofa with an eager auditory about him and told the history of -the wonderful adventure, putting in many striking additions to adorn it -withal; and closed with a description of how he left Becky and went on -an exploring expedition; how he followed two avenues as far as his -kite-line would reach; how he followed a third to the fullest stretch of -the kite-line, and was about to turn back when he glimpsed a far-off -speck that looked like daylight; dropped the line and groped toward it, -pushed his head and shoulders through a small hole, and saw the broad -Mississippi rolling by! And if it had only happened to be night he would -not have seen that speck of daylight and would not have explored that -passage any more! He told how he went back for Becky and broke the good -news and she told him not to fret her with such stuff, for she was -tired, and knew she was going to die, and wanted to. He described how he -labored with her and convinced her; and how she almost died for joy when -she had groped to where she actually saw the blue speck of daylight; how -he pushed his way out at the hole and then helped her out; how they sat -there and cried for gladness; how some men came along in a skiff and Tom -hailed them and told them their situation and their famished condition; -how the men didn't believe the wild tale at first, "because," said they, -"you are five miles down the river below the valley the cave is in" ---then took them aboard, rowed to a house, gave them supper, made them -rest till two or three hours after dark and then brought them home. - -Before day-dawn, Judge Thatcher and the handful of searchers with him -were tracked out, in the cave, by the twine clews they had strung -behind them, and informed of the great news. - -Three days and nights of toil and hunger in the cave were not to be -shaken off at once, as Tom and Becky soon discovered. They were -bedridden all of Wednesday and Thursday, and seemed to grow more and -more tired and worn, all the time. Tom got about, a little, on -Thursday, was down-town Friday, and nearly as whole as ever Saturday; -but Becky did not leave her room until Sunday, and then she looked as -if she had passed through a wasting illness. - -Tom learned of Huck's sickness and went to see him on Friday, but -could not be admitted to the bedroom; neither could he on Saturday or -Sunday. He was admitted daily after that, but was warned to keep still -about his adventure and introduce no exciting topic. The Widow Douglas -stayed by to see that he obeyed. At home Tom learned of the Cardiff -Hill event; also that the "ragged man's" body had eventually been found -in the river near the ferry-landing; he had been drowned while trying -to escape, perhaps. - -About a fortnight after Tom's rescue from the cave, he started off to -visit Huck, who had grown plenty strong enough, now, to hear exciting -talk, and Tom had some that would interest him, he thought. Judge -Thatcher's house was on Tom's way, and he stopped to see Becky. The -Judge and some friends set Tom to talking, and some one asked him -ironically if he wouldn't like to go to the cave again. Tom said he -thought he wouldn't mind it. The Judge said: - -"Well, there are others just like you, Tom, I've not the least doubt. -But we have taken care of that. Nobody will get lost in that cave any -more." - -"Why?" - -"Because I had its big door sheathed with boiler iron two weeks ago, -and triple-locked--and I've got the keys." - -Tom turned as white as a sheet. - -"What's the matter, boy! Here, run, somebody! Fetch a glass of water!" - -The water was brought and thrown into Tom's face. - -"Ah, now you're all right. What was the matter with you, Tom?" - -"Oh, Judge, Injun Joe's in the cave!" - - - -CHAPTER XXXIII - -WITHIN a few minutes the news had spread, and a dozen skiff-loads of -men were on their way to McDougal's cave, and the ferryboat, well -filled with passengers, soon followed. Tom Sawyer was in the skiff that -bore Judge Thatcher. - -When the cave door was unlocked, a sorrowful sight presented itself in -the dim twilight of the place. Injun Joe lay stretched upon the ground, -dead, with his face close to the crack of the door, as if his longing -eyes had been fixed, to the latest moment, upon the light and the cheer -of the free world outside. Tom was touched, for he knew by his own -experience how this wretch had suffered. His pity was moved, but -nevertheless he felt an abounding sense of relief and security, now, -which revealed to him in a degree which he had not fully appreciated -before how vast a weight of dread had been lying upon him since the day -he lifted his voice against this bloody-minded outcast. - -Injun Joe's bowie-knife lay close by, its blade broken in two. The -great foundation-beam of the door had been chipped and hacked through, -with tedious labor; useless labor, too, it was, for the native rock -formed a sill outside it, and upon that stubborn material the knife had -wrought no effect; the only damage done was to the knife itself. But if -there had been no stony obstruction there the labor would have been -useless still, for if the beam had been wholly cut away Injun Joe could -not have squeezed his body under the door, and he knew it. So he had -only hacked that place in order to be doing something--in order to pass -the weary time--in order to employ his tortured faculties. Ordinarily -one could find half a dozen bits of candle stuck around in the crevices -of this vestibule, left there by tourists; but there were none now. The -prisoner had searched them out and eaten them. He had also contrived to -catch a few bats, and these, also, he had eaten, leaving only their -claws. The poor unfortunate had starved to death. In one place, near at -hand, a stalagmite had been slowly growing up from the ground for ages, -builded by the water-drip from a stalactite overhead. The captive had -broken off the stalagmite, and upon the stump had placed a stone, -wherein he had scooped a shallow hollow to catch the precious drop -that fell once in every three minutes with the dreary regularity of a -clock-tick--a dessertspoonful once in four and twenty hours. That drop -was falling when the Pyramids were new; when Troy fell; when the -foundations of Rome were laid; when Christ was crucified; when the -Conqueror created the British empire; when Columbus sailed; when the -massacre at Lexington was "news." It is falling now; it will still be -falling when all these things shall have sunk down the afternoon of -history, and the twilight of tradition, and been swallowed up in the -thick night of oblivion. Has everything a purpose and a mission? Did -this drop fall patiently during five thousand years to be ready for -this flitting human insect's need? and has it another important object -to accomplish ten thousand years to come? No matter. It is many and -many a year since the hapless half-breed scooped out the stone to catch -the priceless drops, but to this day the tourist stares longest at that -pathetic stone and that slow-dropping water when he comes to see the -wonders of McDougal's cave. Injun Joe's cup stands first in the list of -the cavern's marvels; even "Aladdin's Palace" cannot rival it. - -Injun Joe was buried near the mouth of the cave; and people flocked -there in boats and wagons from the towns and from all the farms and -hamlets for seven miles around; they brought their children, and all -sorts of provisions, and confessed that they had had almost as -satisfactory a time at the funeral as they could have had at the -hanging. - -This funeral stopped the further growth of one thing--the petition to -the governor for Injun Joe's pardon. The petition had been largely -signed; many tearful and eloquent meetings had been held, and a -committee of sappy women been appointed to go in deep mourning and wail -around the governor, and implore him to be a merciful ass and trample -his duty under foot. Injun Joe was believed to have killed five -citizens of the village, but what of that? If he had been Satan himself -there would have been plenty of weaklings ready to scribble their names -to a pardon-petition, and drip a tear on it from their permanently -impaired and leaky water-works. - -The morning after the funeral Tom took Huck to a private place to have -an important talk. Huck had learned all about Tom's adventure from the -Welshman and the Widow Douglas, by this time, but Tom said he reckoned -there was one thing they had not told him; that thing was what he -wanted to talk about now. Huck's face saddened. He said: - -"I know what it is. You got into No. 2 and never found anything but -whiskey. Nobody told me it was you; but I just knowed it must 'a' ben -you, soon as I heard 'bout that whiskey business; and I knowed you -hadn't got the money becuz you'd 'a' got at me some way or other and -told me even if you was mum to everybody else. Tom, something's always -told me we'd never get holt of that swag." - -"Why, Huck, I never told on that tavern-keeper. YOU know his tavern -was all right the Saturday I went to the picnic. Don't you remember you -was to watch there that night?" - -"Oh yes! Why, it seems 'bout a year ago. It was that very night that I -follered Injun Joe to the widder's." - -"YOU followed him?" - -"Yes--but you keep mum. I reckon Injun Joe's left friends behind him, -and I don't want 'em souring on me and doing me mean tricks. If it -hadn't ben for me he'd be down in Texas now, all right." - -Then Huck told his entire adventure in confidence to Tom, who had only -heard of the Welshman's part of it before. - -"Well," said Huck, presently, coming back to the main question, -"whoever nipped the whiskey in No. 2, nipped the money, too, I reckon ---anyways it's a goner for us, Tom." - -"Huck, that money wasn't ever in No. 2!" - -"What!" Huck searched his comrade's face keenly. "Tom, have you got on -the track of that money again?" - -"Huck, it's in the cave!" - -Huck's eyes blazed. - -"Say it again, Tom." - -"The money's in the cave!" - -"Tom--honest injun, now--is it fun, or earnest?" - -"Earnest, Huck--just as earnest as ever I was in my life. Will you go -in there with me and help get it out?" - -"I bet I will! I will if it's where we can blaze our way to it and not -get lost." - -"Huck, we can do that without the least little bit of trouble in the -world." - -"Good as wheat! What makes you think the money's--" - -"Huck, you just wait till we get in there. If we don't find it I'll -agree to give you my drum and every thing I've got in the world. I -will, by jings." - -"All right--it's a whiz. When do you say?" - -"Right now, if you say it. Are you strong enough?" - -"Is it far in the cave? I ben on my pins a little, three or four days, -now, but I can't walk more'n a mile, Tom--least I don't think I could." - -"It's about five mile into there the way anybody but me would go, -Huck, but there's a mighty short cut that they don't anybody but me -know about. Huck, I'll take you right to it in a skiff. I'll float the -skiff down there, and I'll pull it back again all by myself. You -needn't ever turn your hand over." - -"Less start right off, Tom." - -"All right. We want some bread and meat, and our pipes, and a little -bag or two, and two or three kite-strings, and some of these -new-fangled things they call lucifer matches. I tell you, many's -the time I wished I had some when I was in there before." - -A trifle after noon the boys borrowed a small skiff from a citizen who -was absent, and got under way at once. When they were several miles -below "Cave Hollow," Tom said: - -"Now you see this bluff here looks all alike all the way down from the -cave hollow--no houses, no wood-yards, bushes all alike. But do you see -that white place up yonder where there's been a landslide? Well, that's -one of my marks. We'll get ashore, now." - -They landed. - -"Now, Huck, where we're a-standing you could touch that hole I got out -of with a fishing-pole. See if you can find it." - -Huck searched all the place about, and found nothing. Tom proudly -marched into a thick clump of sumach bushes and said: - -"Here you are! Look at it, Huck; it's the snuggest hole in this -country. You just keep mum about it. All along I've been wanting to be -a robber, but I knew I'd got to have a thing like this, and where to -run across it was the bother. We've got it now, and we'll keep it -quiet, only we'll let Joe Harper and Ben Rogers in--because of course -there's got to be a Gang, or else there wouldn't be any style about it. -Tom Sawyer's Gang--it sounds splendid, don't it, Huck?" - -"Well, it just does, Tom. And who'll we rob?" - -"Oh, most anybody. Waylay people--that's mostly the way." - -"And kill them?" - -"No, not always. Hive them in the cave till they raise a ransom." - -"What's a ransom?" - -"Money. You make them raise all they can, off'n their friends; and -after you've kept them a year, if it ain't raised then you kill them. -That's the general way. Only you don't kill the women. You shut up the -women, but you don't kill them. They're always beautiful and rich, and -awfully scared. You take their watches and things, but you always take -your hat off and talk polite. They ain't anybody as polite as robbers ---you'll see that in any book. Well, the women get to loving you, and -after they've been in the cave a week or two weeks they stop crying and -after that you couldn't get them to leave. If you drove them out they'd -turn right around and come back. It's so in all the books." - -"Why, it's real bully, Tom. I believe it's better'n to be a pirate." - -"Yes, it's better in some ways, because it's close to home and -circuses and all that." - -By this time everything was ready and the boys entered the hole, Tom -in the lead. They toiled their way to the farther end of the tunnel, -then made their spliced kite-strings fast and moved on. A few steps -brought them to the spring, and Tom felt a shudder quiver all through -him. He showed Huck the fragment of candle-wick perched on a lump of -clay against the wall, and described how he and Becky had watched the -flame struggle and expire. - -The boys began to quiet down to whispers, now, for the stillness and -gloom of the place oppressed their spirits. They went on, and presently -entered and followed Tom's other corridor until they reached the -"jumping-off place." The candles revealed the fact that it was not -really a precipice, but only a steep clay hill twenty or thirty feet -high. Tom whispered: - -"Now I'll show you something, Huck." - -He held his candle aloft and said: - -"Look as far around the corner as you can. Do you see that? There--on -the big rock over yonder--done with candle-smoke." - -"Tom, it's a CROSS!" - -"NOW where's your Number Two? 'UNDER THE CROSS,' hey? Right yonder's -where I saw Injun Joe poke up his candle, Huck!" - -Huck stared at the mystic sign awhile, and then said with a shaky voice: - -"Tom, less git out of here!" - -"What! and leave the treasure?" - -"Yes--leave it. Injun Joe's ghost is round about there, certain." - -"No it ain't, Huck, no it ain't. It would ha'nt the place where he -died--away out at the mouth of the cave--five mile from here." - -"No, Tom, it wouldn't. It would hang round the money. I know the ways -of ghosts, and so do you." - -Tom began to fear that Huck was right. Misgivings gathered in his -mind. But presently an idea occurred to him-- - -"Lookyhere, Huck, what fools we're making of ourselves! Injun Joe's -ghost ain't a going to come around where there's a cross!" - -The point was well taken. It had its effect. - -"Tom, I didn't think of that. But that's so. It's luck for us, that -cross is. I reckon we'll climb down there and have a hunt for that box." - -Tom went first, cutting rude steps in the clay hill as he descended. -Huck followed. Four avenues opened out of the small cavern which the -great rock stood in. The boys examined three of them with no result. -They found a small recess in the one nearest the base of the rock, with -a pallet of blankets spread down in it; also an old suspender, some -bacon rind, and the well-gnawed bones of two or three fowls. But there -was no money-box. The lads searched and researched this place, but in -vain. Tom said: - -"He said UNDER the cross. Well, this comes nearest to being under the -cross. It can't be under the rock itself, because that sets solid on -the ground." - -They searched everywhere once more, and then sat down discouraged. -Huck could suggest nothing. By-and-by Tom said: - -"Lookyhere, Huck, there's footprints and some candle-grease on the -clay about one side of this rock, but not on the other sides. Now, -what's that for? I bet you the money IS under the rock. I'm going to -dig in the clay." - -"That ain't no bad notion, Tom!" said Huck with animation. - -Tom's "real Barlow" was out at once, and he had not dug four inches -before he struck wood. - -"Hey, Huck!--you hear that?" - -Huck began to dig and scratch now. Some boards were soon uncovered and -removed. They had concealed a natural chasm which led under the rock. -Tom got into this and held his candle as far under the rock as he -could, but said he could not see to the end of the rift. He proposed to -explore. He stooped and passed under; the narrow way descended -gradually. He followed its winding course, first to the right, then to -the left, Huck at his heels. Tom turned a short curve, by-and-by, and -exclaimed: - -"My goodness, Huck, lookyhere!" - -It was the treasure-box, sure enough, occupying a snug little cavern, -along with an empty powder-keg, a couple of guns in leather cases, two -or three pairs of old moccasins, a leather belt, and some other rubbish -well soaked with the water-drip. - -"Got it at last!" said Huck, ploughing among the tarnished coins with -his hand. "My, but we're rich, Tom!" - -"Huck, I always reckoned we'd get it. It's just too good to believe, -but we HAVE got it, sure! Say--let's not fool around here. Let's snake -it out. Lemme see if I can lift the box." - -It weighed about fifty pounds. Tom could lift it, after an awkward -fashion, but could not carry it conveniently. - -"I thought so," he said; "THEY carried it like it was heavy, that day -at the ha'nted house. I noticed that. I reckon I was right to think of -fetching the little bags along." - -The money was soon in the bags and the boys took it up to the cross -rock. - -"Now less fetch the guns and things," said Huck. - -"No, Huck--leave them there. They're just the tricks to have when we -go to robbing. We'll keep them there all the time, and we'll hold our -orgies there, too. It's an awful snug place for orgies." - -"What orgies?" - -"I dono. But robbers always have orgies, and of course we've got to -have them, too. Come along, Huck, we've been in here a long time. It's -getting late, I reckon. I'm hungry, too. We'll eat and smoke when we -get to the skiff." - -They presently emerged into the clump of sumach bushes, looked warily -out, found the coast clear, and were soon lunching and smoking in the -skiff. As the sun dipped toward the horizon they pushed out and got -under way. Tom skimmed up the shore through the long twilight, chatting -cheerily with Huck, and landed shortly after dark. - -"Now, Huck," said Tom, "we'll hide the money in the loft of the -widow's woodshed, and I'll come up in the morning and we'll count it -and divide, and then we'll hunt up a place out in the woods for it -where it will be safe. Just you lay quiet here and watch the stuff till -I run and hook Benny Taylor's little wagon; I won't be gone a minute." - -He disappeared, and presently returned with the wagon, put the two -small sacks into it, threw some old rags on top of them, and started -off, dragging his cargo behind him. When the boys reached the -Welshman's house, they stopped to rest. Just as they were about to move -on, the Welshman stepped out and said: - -"Hallo, who's that?" - -"Huck and Tom Sawyer." - -"Good! Come along with me, boys, you are keeping everybody waiting. -Here--hurry up, trot ahead--I'll haul the wagon for you. Why, it's not -as light as it might be. Got bricks in it?--or old metal?" - -"Old metal," said Tom. - -"I judged so; the boys in this town will take more trouble and fool -away more time hunting up six bits' worth of old iron to sell to the -foundry than they would to make twice the money at regular work. But -that's human nature--hurry along, hurry along!" - -The boys wanted to know what the hurry was about. - -"Never mind; you'll see, when we get to the Widow Douglas'." - -Huck said with some apprehension--for he was long used to being -falsely accused: - -"Mr. Jones, we haven't been doing nothing." - -The Welshman laughed. - -"Well, I don't know, Huck, my boy. I don't know about that. Ain't you -and the widow good friends?" - -"Yes. Well, she's ben good friends to me, anyway." - -"All right, then. What do you want to be afraid for?" - -This question was not entirely answered in Huck's slow mind before he -found himself pushed, along with Tom, into Mrs. Douglas' drawing-room. -Mr. Jones left the wagon near the door and followed. - -The place was grandly lighted, and everybody that was of any -consequence in the village was there. The Thatchers were there, the -Harpers, the Rogerses, Aunt Polly, Sid, Mary, the minister, the editor, -and a great many more, and all dressed in their best. The widow -received the boys as heartily as any one could well receive two such -looking beings. They were covered with clay and candle-grease. Aunt -Polly blushed crimson with humiliation, and frowned and shook her head -at Tom. Nobody suffered half as much as the two boys did, however. Mr. -Jones said: - -"Tom wasn't at home, yet, so I gave him up; but I stumbled on him and -Huck right at my door, and so I just brought them along in a hurry." - -"And you did just right," said the widow. "Come with me, boys." - -She took them to a bedchamber and said: - -"Now wash and dress yourselves. Here are two new suits of clothes ---shirts, socks, everything complete. They're Huck's--no, no thanks, -Huck--Mr. Jones bought one and I the other. But they'll fit both of you. -Get into them. We'll wait--come down when you are slicked up enough." - -Then she left. - - - -CHAPTER XXXIV - -HUCK said: "Tom, we can slope, if we can find a rope. The window ain't -high from the ground." - -"Shucks! what do you want to slope for?" - -"Well, I ain't used to that kind of a crowd. I can't stand it. I ain't -going down there, Tom." - -"Oh, bother! It ain't anything. I don't mind it a bit. I'll take care -of you." - -Sid appeared. - -"Tom," said he, "auntie has been waiting for you all the afternoon. -Mary got your Sunday clothes ready, and everybody's been fretting about -you. Say--ain't this grease and clay, on your clothes?" - -"Now, Mr. Siddy, you jist 'tend to your own business. What's all this -blow-out about, anyway?" - -"It's one of the widow's parties that she's always having. This time -it's for the Welshman and his sons, on account of that scrape they -helped her out of the other night. And say--I can tell you something, -if you want to know." - -"Well, what?" - -"Why, old Mr. Jones is going to try to spring something on the people -here to-night, but I overheard him tell auntie to-day about it, as a -secret, but I reckon it's not much of a secret now. Everybody knows ---the widow, too, for all she tries to let on she don't. Mr. Jones was -bound Huck should be here--couldn't get along with his grand secret -without Huck, you know!" - -"Secret about what, Sid?" - -"About Huck tracking the robbers to the widow's. I reckon Mr. Jones -was going to make a grand time over his surprise, but I bet you it will -drop pretty flat." - -Sid chuckled in a very contented and satisfied way. - -"Sid, was it you that told?" - -"Oh, never mind who it was. SOMEBODY told--that's enough." - -"Sid, there's only one person in this town mean enough to do that, and -that's you. If you had been in Huck's place you'd 'a' sneaked down the -hill and never told anybody on the robbers. You can't do any but mean -things, and you can't bear to see anybody praised for doing good ones. -There--no thanks, as the widow says"--and Tom cuffed Sid's ears and -helped him to the door with several kicks. "Now go and tell auntie if -you dare--and to-morrow you'll catch it!" - -Some minutes later the widow's guests were at the supper-table, and a -dozen children were propped up at little side-tables in the same room, -after the fashion of that country and that day. At the proper time Mr. -Jones made his little speech, in which he thanked the widow for the -honor she was doing himself and his sons, but said that there was -another person whose modesty-- - -And so forth and so on. He sprung his secret about Huck's share in the -adventure in the finest dramatic manner he was master of, but the -surprise it occasioned was largely counterfeit and not as clamorous and -effusive as it might have been under happier circumstances. However, -the widow made a pretty fair show of astonishment, and heaped so many -compliments and so much gratitude upon Huck that he almost forgot the -nearly intolerable discomfort of his new clothes in the entirely -intolerable discomfort of being set up as a target for everybody's gaze -and everybody's laudations. - -The widow said she meant to give Huck a home under her roof and have -him educated; and that when she could spare the money she would start -him in business in a modest way. Tom's chance was come. He said: - -"Huck don't need it. Huck's rich." - -Nothing but a heavy strain upon the good manners of the company kept -back the due and proper complimentary laugh at this pleasant joke. But -the silence was a little awkward. Tom broke it: - -"Huck's got money. Maybe you don't believe it, but he's got lots of -it. Oh, you needn't smile--I reckon I can show you. You just wait a -minute." - -Tom ran out of doors. The company looked at each other with a -perplexed interest--and inquiringly at Huck, who was tongue-tied. - -"Sid, what ails Tom?" said Aunt Polly. "He--well, there ain't ever any -making of that boy out. I never--" - -Tom entered, struggling with the weight of his sacks, and Aunt Polly -did not finish her sentence. Tom poured the mass of yellow coin upon -the table and said: - -"There--what did I tell you? Half of it's Huck's and half of it's mine!" - -The spectacle took the general breath away. All gazed, nobody spoke -for a moment. Then there was a unanimous call for an explanation. Tom -said he could furnish it, and he did. The tale was long, but brimful of -interest. There was scarcely an interruption from any one to break the -charm of its flow. When he had finished, Mr. Jones said: - -"I thought I had fixed up a little surprise for this occasion, but it -don't amount to anything now. This one makes it sing mighty small, I'm -willing to allow." - -The money was counted. The sum amounted to a little over twelve -thousand dollars. It was more than any one present had ever seen at one -time before, though several persons were there who were worth -considerably more than that in property. - - - -CHAPTER XXXV - -THE reader may rest satisfied that Tom's and Huck's windfall made a -mighty stir in the poor little village of St. Petersburg. So vast a -sum, all in actual cash, seemed next to incredible. It was talked -about, gloated over, glorified, until the reason of many of the -citizens tottered under the strain of the unhealthy excitement. Every -"haunted" house in St. Petersburg and the neighboring villages was -dissected, plank by plank, and its foundations dug up and ransacked for -hidden treasure--and not by boys, but men--pretty grave, unromantic -men, too, some of them. Wherever Tom and Huck appeared they were -courted, admired, stared at. The boys were not able to remember that -their remarks had possessed weight before; but now their sayings were -treasured and repeated; everything they did seemed somehow to be -regarded as remarkable; they had evidently lost the power of doing and -saying commonplace things; moreover, their past history was raked up -and discovered to bear marks of conspicuous originality. The village -paper published biographical sketches of the boys. - -The Widow Douglas put Huck's money out at six per cent., and Judge -Thatcher did the same with Tom's at Aunt Polly's request. Each lad had -an income, now, that was simply prodigious--a dollar for every week-day -in the year and half of the Sundays. It was just what the minister got ---no, it was what he was promised--he generally couldn't collect it. A -dollar and a quarter a week would board, lodge, and school a boy in -those old simple days--and clothe him and wash him, too, for that -matter. - -Judge Thatcher had conceived a great opinion of Tom. He said that no -commonplace boy would ever have got his daughter out of the cave. When -Becky told her father, in strict confidence, how Tom had taken her -whipping at school, the Judge was visibly moved; and when she pleaded -grace for the mighty lie which Tom had told in order to shift that -whipping from her shoulders to his own, the Judge said with a fine -outburst that it was a noble, a generous, a magnanimous lie--a lie that -was worthy to hold up its head and march down through history breast to -breast with George Washington's lauded Truth about the hatchet! Becky -thought her father had never looked so tall and so superb as when he -walked the floor and stamped his foot and said that. She went straight -off and told Tom about it. - -Judge Thatcher hoped to see Tom a great lawyer or a great soldier some -day. He said he meant to look to it that Tom should be admitted to the -National Military Academy and afterward trained in the best law school -in the country, in order that he might be ready for either career or -both. - -Huck Finn's wealth and the fact that he was now under the Widow -Douglas' protection introduced him into society--no, dragged him into -it, hurled him into it--and his sufferings were almost more than he -could bear. The widow's servants kept him clean and neat, combed and -brushed, and they bedded him nightly in unsympathetic sheets that had -not one little spot or stain which he could press to his heart and know -for a friend. He had to eat with a knife and fork; he had to use -napkin, cup, and plate; he had to learn his book, he had to go to -church; he had to talk so properly that speech was become insipid in -his mouth; whithersoever he turned, the bars and shackles of -civilization shut him in and bound him hand and foot. - -He bravely bore his miseries three weeks, and then one day turned up -missing. For forty-eight hours the widow hunted for him everywhere in -great distress. The public were profoundly concerned; they searched -high and low, they dragged the river for his body. Early the third -morning Tom Sawyer wisely went poking among some old empty hogsheads -down behind the abandoned slaughter-house, and in one of them he found -the refugee. Huck had slept there; he had just breakfasted upon some -stolen odds and ends of food, and was lying off, now, in comfort, with -his pipe. He was unkempt, uncombed, and clad in the same old ruin of -rags that had made him picturesque in the days when he was free and -happy. Tom routed him out, told him the trouble he had been causing, -and urged him to go home. Huck's face lost its tranquil content, and -took a melancholy cast. He said: - -"Don't talk about it, Tom. I've tried it, and it don't work; it don't -work, Tom. It ain't for me; I ain't used to it. The widder's good to -me, and friendly; but I can't stand them ways. She makes me get up just -at the same time every morning; she makes me wash, they comb me all to -thunder; she won't let me sleep in the woodshed; I got to wear them -blamed clothes that just smothers me, Tom; they don't seem to any air -git through 'em, somehow; and they're so rotten nice that I can't set -down, nor lay down, nor roll around anywher's; I hain't slid on a -cellar-door for--well, it 'pears to be years; I got to go to church and -sweat and sweat--I hate them ornery sermons! I can't ketch a fly in -there, I can't chaw. I got to wear shoes all Sunday. The widder eats by -a bell; she goes to bed by a bell; she gits up by a bell--everything's -so awful reg'lar a body can't stand it." - -"Well, everybody does that way, Huck." - -"Tom, it don't make no difference. I ain't everybody, and I can't -STAND it. It's awful to be tied up so. And grub comes too easy--I don't -take no interest in vittles, that way. I got to ask to go a-fishing; I -got to ask to go in a-swimming--dern'd if I hain't got to ask to do -everything. Well, I'd got to talk so nice it wasn't no comfort--I'd got -to go up in the attic and rip out awhile, every day, to git a taste in -my mouth, or I'd a died, Tom. The widder wouldn't let me smoke; she -wouldn't let me yell, she wouldn't let me gape, nor stretch, nor -scratch, before folks--" [Then with a spasm of special irritation and -injury]--"And dad fetch it, she prayed all the time! I never see such a -woman! I HAD to shove, Tom--I just had to. And besides, that school's -going to open, and I'd a had to go to it--well, I wouldn't stand THAT, -Tom. Looky here, Tom, being rich ain't what it's cracked up to be. It's -just worry and worry, and sweat and sweat, and a-wishing you was dead -all the time. Now these clothes suits me, and this bar'l suits me, and -I ain't ever going to shake 'em any more. Tom, I wouldn't ever got into -all this trouble if it hadn't 'a' ben for that money; now you just take -my sheer of it along with your'n, and gimme a ten-center sometimes--not -many times, becuz I don't give a dern for a thing 'thout it's tollable -hard to git--and you go and beg off for me with the widder." - -"Oh, Huck, you know I can't do that. 'Tain't fair; and besides if -you'll try this thing just a while longer you'll come to like it." - -"Like it! Yes--the way I'd like a hot stove if I was to set on it long -enough. No, Tom, I won't be rich, and I won't live in them cussed -smothery houses. I like the woods, and the river, and hogsheads, and -I'll stick to 'em, too. Blame it all! just as we'd got guns, and a -cave, and all just fixed to rob, here this dern foolishness has got to -come up and spile it all!" - -Tom saw his opportunity-- - -"Lookyhere, Huck, being rich ain't going to keep me back from turning -robber." - -"No! Oh, good-licks; are you in real dead-wood earnest, Tom?" - -"Just as dead earnest as I'm sitting here. But Huck, we can't let you -into the gang if you ain't respectable, you know." - -Huck's joy was quenched. - -"Can't let me in, Tom? Didn't you let me go for a pirate?" - -"Yes, but that's different. A robber is more high-toned than what a -pirate is--as a general thing. In most countries they're awful high up -in the nobility--dukes and such." - -"Now, Tom, hain't you always ben friendly to me? You wouldn't shet me -out, would you, Tom? You wouldn't do that, now, WOULD you, Tom?" - -"Huck, I wouldn't want to, and I DON'T want to--but what would people -say? Why, they'd say, 'Mph! Tom Sawyer's Gang! pretty low characters in -it!' They'd mean you, Huck. You wouldn't like that, and I wouldn't." - -Huck was silent for some time, engaged in a mental struggle. Finally -he said: - -"Well, I'll go back to the widder for a month and tackle it and see if -I can come to stand it, if you'll let me b'long to the gang, Tom." - -"All right, Huck, it's a whiz! Come along, old chap, and I'll ask the -widow to let up on you a little, Huck." - -"Will you, Tom--now will you? That's good. If she'll let up on some of -the roughest things, I'll smoke private and cuss private, and crowd -through or bust. When you going to start the gang and turn robbers?" - -"Oh, right off. We'll get the boys together and have the initiation -to-night, maybe." - -"Have the which?" - -"Have the initiation." - -"What's that?" - -"It's to swear to stand by one another, and never tell the gang's -secrets, even if you're chopped all to flinders, and kill anybody and -all his family that hurts one of the gang." - -"That's gay--that's mighty gay, Tom, I tell you." - -"Well, I bet it is. And all that swearing's got to be done at -midnight, in the lonesomest, awfulest place you can find--a ha'nted -house is the best, but they're all ripped up now." - -"Well, midnight's good, anyway, Tom." - -"Yes, so it is. And you've got to swear on a coffin, and sign it with -blood." - -"Now, that's something LIKE! Why, it's a million times bullier than -pirating. I'll stick to the widder till I rot, Tom; and if I git to be -a reg'lar ripper of a robber, and everybody talking 'bout it, I reckon -she'll be proud she snaked me in out of the wet." - - - -CONCLUSION - -SO endeth this chronicle. It being strictly a history of a BOY, it -must stop here; the story could not go much further without becoming -the history of a MAN. When one writes a novel about grown people, he -knows exactly where to stop--that is, with a marriage; but when he -writes of juveniles, he must stop where he best can. - -Most of the characters that perform in this book still live, and are -prosperous and happy. Some day it may seem worth while to take up the -story of the younger ones again and see what sort of men and women they -turned out to be; therefore it will be wisest not to reveal any of that -part of their lives at present. diff --git a/libgo/go/net/textproto/reader.go b/libgo/go/net/textproto/reader.go index feb464b2f28..2c4f25d5ae6 100644 --- a/libgo/go/net/textproto/reader.go +++ b/libgo/go/net/textproto/reader.go @@ -129,12 +129,13 @@ func (r *Reader) readContinuedLineSlice() ([]byte, error) { } // Optimistically assume that we have started to buffer the next line - // and it starts with an ASCII letter (the next header key), so we can - // avoid copying that buffered data around in memory and skipping over - // non-existent whitespace. + // and it starts with an ASCII letter (the next header key), or a blank + // line, so we can avoid copying that buffered data around in memory + // and skipping over non-existent whitespace. if r.R.Buffered() > 1 { - peek, err := r.R.Peek(1) - if err == nil && isASCIILetter(peek[0]) { + peek, _ := r.R.Peek(2) + if len(peek) > 0 && (isASCIILetter(peek[0]) || peek[0] == '\n') || + len(peek) == 2 && peek[0] == '\r' && peek[1] == '\n' { return trim(line), nil } } diff --git a/libgo/go/net/textproto/reader_test.go b/libgo/go/net/textproto/reader_test.go index 4f379031889..aec193a7cbd 100644 --- a/libgo/go/net/textproto/reader_test.go +++ b/libgo/go/net/textproto/reader_test.go @@ -383,31 +383,25 @@ Non-Interned: test func BenchmarkReadMIMEHeader(b *testing.B) { b.ReportAllocs() - var buf bytes.Buffer - br := bufio.NewReader(&buf) - r := NewReader(br) - for i := 0; i < b.N; i++ { - var want int - var find string - if (i & 1) == 1 { - buf.WriteString(clientHeaders) - want = 10 - find = "Cookie" - } else { - buf.WriteString(serverHeaders) - want = 9 - find = "Via" - } - h, err := r.ReadMIMEHeader() - if err != nil { - b.Fatal(err) - } - if len(h) != want { - b.Fatalf("wrong number of headers: got %d, want %d", len(h), want) - } - if _, ok := h[find]; !ok { - b.Fatalf("did not find key %s", find) - } + for _, set := range []struct { + name string + headers string + }{ + {"client_headers", clientHeaders}, + {"server_headers", serverHeaders}, + } { + b.Run(set.name, func(b *testing.B) { + var buf bytes.Buffer + br := bufio.NewReader(&buf) + r := NewReader(br) + + for i := 0; i < b.N; i++ { + buf.WriteString(set.headers) + if _, err := r.ReadMIMEHeader(); err != nil { + b.Fatal(err) + } + } + }) } } diff --git a/libgo/go/net/timeout_test.go b/libgo/go/net/timeout_test.go index 7c7d0c89938..9599fa1d3e8 100644 --- a/libgo/go/net/timeout_test.go +++ b/libgo/go/net/timeout_test.go @@ -812,6 +812,9 @@ func (b neverEnding) Read(p []byte) (int, error) { } func testVariousDeadlines(t *testing.T) { + if runtime.GOOS == "plan9" { + t.Skip("skipping test on plan9; see golang.org/issue/26945") + } type result struct { n int64 err error diff --git a/libgo/go/net/udpsock_test.go b/libgo/go/net/udpsock_test.go index 494064444ec..397b6649cda 100644 --- a/libgo/go/net/udpsock_test.go +++ b/libgo/go/net/udpsock_test.go @@ -337,6 +337,8 @@ func TestUDPZeroBytePayload(t *testing.T) { switch runtime.GOOS { case "nacl", "plan9": t.Skipf("not supported on %s", runtime.GOOS) + case "darwin": + testenv.SkipFlaky(t, 29225) } c, err := newLocalPacketListener("udp") @@ -353,19 +355,18 @@ func TestUDPZeroBytePayload(t *testing.T) { if n != 0 { t.Errorf("got %d; want 0", n) } - c.SetReadDeadline(time.Now().Add(100 * time.Millisecond)) + c.SetReadDeadline(time.Now().Add(30 * time.Second)) var b [1]byte + var name string if genericRead { _, err = c.(Conn).Read(b[:]) + name = "Read" } else { _, _, err = c.ReadFrom(b[:]) + name = "ReadFrom" } - switch err { - case nil: // ReadFrom succeeds - default: // Read may timeout, it depends on the platform - if nerr, ok := err.(Error); !ok || !nerr.Timeout() { - t.Fatal(err) - } + if err != nil { + t.Errorf("%s of zero byte packet failed: %v", name, err) } } } diff --git a/libgo/go/net/unixsock.go b/libgo/go/net/unixsock.go index 3ae62f6a8b8..ae912a46ddb 100644 --- a/libgo/go/net/unixsock.go +++ b/libgo/go/net/unixsock.go @@ -12,8 +12,11 @@ import ( "time" ) -// BUG(mikio): On JS, NaCl, Plan 9 and Windows, methods and functions -// related to UnixConn and UnixListener are not implemented. +// BUG(mikio): On JS, NaCl and Plan 9, methods and functions related +// to UnixConn and UnixListener are not implemented. + +// BUG(mikio): On Windows, methods and functions related to UnixConn +// and UnixListener don't work for "unixgram" and "unixpacket". // UnixAddr represents the address of a Unix domain socket end point. type UnixAddr struct { diff --git a/libgo/go/net/unixsock_windows_test.go b/libgo/go/net/unixsock_windows_test.go new file mode 100644 index 00000000000..5dccc146533 --- /dev/null +++ b/libgo/go/net/unixsock_windows_test.go @@ -0,0 +1,100 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows + +package net + +import ( + "internal/syscall/windows/registry" + "os" + "reflect" + "runtime" + "strconv" + "testing" +) + +func isBuild17063() bool { + k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.READ) + if err != nil { + return false + } + defer k.Close() + + s, _, err := k.GetStringValue("CurrentBuild") + if err != nil { + return false + } + ver, err := strconv.Atoi(s) + if err != nil { + return false + } + return ver >= 17063 +} + +func TestUnixConnLocalWindows(t *testing.T) { + switch runtime.GOARCH { + case "386": + t.Skip("not supported on windows/386, see golang.org/issue/27943") + case "arm": + t.Skip("not supported on windows/arm, see golang.org/issue/28061") + } + if !isBuild17063() { + t.Skip("unix test") + } + + handler := func(ls *localServer, ln Listener) {} + for _, laddr := range []string{"", testUnixAddr()} { + laddr := laddr + taddr := testUnixAddr() + ta, err := ResolveUnixAddr("unix", taddr) + if err != nil { + t.Fatal(err) + } + ln, err := ListenUnix("unix", ta) + if err != nil { + t.Fatal(err) + } + ls, err := (&streamListener{Listener: ln}).newLocalServer() + if err != nil { + t.Fatal(err) + } + defer ls.teardown() + if err := ls.buildup(handler); err != nil { + t.Fatal(err) + } + + la, err := ResolveUnixAddr("unix", laddr) + if err != nil { + t.Fatal(err) + } + c, err := DialUnix("unix", la, ta) + if err != nil { + t.Fatal(err) + } + defer func() { + c.Close() + if la != nil { + defer os.Remove(laddr) + } + }() + if _, err := c.Write([]byte("UNIXCONN LOCAL AND REMOTE NAME TEST")); err != nil { + t.Fatal(err) + } + + if laddr == "" { + laddr = "@" + } + var connAddrs = [3]struct{ got, want Addr }{ + {ln.Addr(), ta}, + {c.LocalAddr(), &UnixAddr{Name: laddr, Net: "unix"}}, + {c.RemoteAddr(), ta}, + } + for _, ca := range connAddrs { + if !reflect.DeepEqual(ca.got, ca.want) { + t.Fatalf("got %#v, expected %#v", ca.got, ca.want) + } + } + } +} diff --git a/libgo/go/net/url/url.go b/libgo/go/net/url/url.go index 80eb7a86c8d..d84c95adb03 100644 --- a/libgo/go/net/url/url.go +++ b/libgo/go/net/url/url.go @@ -304,7 +304,26 @@ func escape(s string, mode encoding) string { return s } - t := make([]byte, len(s)+2*hexCount) + var buf [64]byte + var t []byte + + required := len(s) + 2*hexCount + if required <= len(buf) { + t = buf[:required] + } else { + t = make([]byte, required) + } + + if hexCount == 0 { + copy(t, s) + for i := 0; i < len(s); i++ { + if s[i] == ' ' { + t[i] = '+' + } + } + return string(t) + } + j := 0 for i := 0; i < len(s); i++ { switch c := s[i]; { @@ -736,6 +755,7 @@ func validOptionalPort(port string) bool { // // If u.Opaque is non-empty, String uses the first form; // otherwise it uses the second form. +// Any non-ASCII characters in host are escaped. // To obtain the path, String uses u.EscapedPath(). // // In the second form, the following rules apply: diff --git a/libgo/go/net/url/url_test.go b/libgo/go/net/url/url_test.go index 9043a844e88..7c4ada245a7 100644 --- a/libgo/go/net/url/url_test.go +++ b/libgo/go/net/url/url_test.go @@ -848,18 +848,18 @@ func TestUnescape(t *testing.T) { in := tt.in out := tt.out if strings.Contains(tt.in, "+") { - in = strings.Replace(tt.in, "+", "%20", -1) + in = strings.ReplaceAll(tt.in, "+", "%20") actual, err := PathUnescape(in) if actual != tt.out || (err != nil) != (tt.err != nil) { t.Errorf("PathUnescape(%q) = %q, %s; want %q, %s", in, actual, err, tt.out, tt.err) } if tt.err == nil { - s, err := QueryUnescape(strings.Replace(tt.in, "+", "XXX", -1)) + s, err := QueryUnescape(strings.ReplaceAll(tt.in, "+", "XXX")) if err != nil { continue } in = tt.in - out = strings.Replace(s, "XXX", "+", -1) + out = strings.ReplaceAll(s, "XXX", "+") } } @@ -1743,3 +1743,106 @@ func TestInvalidUserPassword(t *testing.T) { t.Errorf("error = %q; want substring %q", got, wantsub) } } + +var escapeBenchmarks = []struct { + unescaped string + query string + path string +}{ + { + unescaped: "one two", + query: "one+two", + path: "one%20two", + }, + { + unescaped: "Фотки собак", + query: "%D0%A4%D0%BE%D1%82%D0%BA%D0%B8+%D1%81%D0%BE%D0%B1%D0%B0%D0%BA", + path: "%D0%A4%D0%BE%D1%82%D0%BA%D0%B8%20%D1%81%D0%BE%D0%B1%D0%B0%D0%BA", + }, + + { + unescaped: "shortrun(break)shortrun", + query: "shortrun%28break%29shortrun", + path: "shortrun%28break%29shortrun", + }, + + { + unescaped: "longerrunofcharacters(break)anotherlongerrunofcharacters", + query: "longerrunofcharacters%28break%29anotherlongerrunofcharacters", + path: "longerrunofcharacters%28break%29anotherlongerrunofcharacters", + }, + + { + unescaped: strings.Repeat("padded/with+various%characters?that=need$some@escaping+paddedsowebreak/256bytes", 4), + query: strings.Repeat("padded%2Fwith%2Bvarious%25characters%3Fthat%3Dneed%24some%40escaping%2Bpaddedsowebreak%2F256bytes", 4), + path: strings.Repeat("padded%2Fwith+various%25characters%3Fthat=need$some@escaping+paddedsowebreak%2F256bytes", 4), + }, +} + +func BenchmarkQueryEscape(b *testing.B) { + for _, tc := range escapeBenchmarks { + b.Run("", func(b *testing.B) { + b.ReportAllocs() + var g string + for i := 0; i < b.N; i++ { + g = QueryEscape(tc.unescaped) + } + b.StopTimer() + if g != tc.query { + b.Errorf("QueryEscape(%q) == %q, want %q", tc.unescaped, g, tc.query) + } + + }) + } +} + +func BenchmarkPathEscape(b *testing.B) { + for _, tc := range escapeBenchmarks { + b.Run("", func(b *testing.B) { + b.ReportAllocs() + var g string + for i := 0; i < b.N; i++ { + g = PathEscape(tc.unescaped) + } + b.StopTimer() + if g != tc.path { + b.Errorf("PathEscape(%q) == %q, want %q", tc.unescaped, g, tc.path) + } + + }) + } +} + +func BenchmarkQueryUnescape(b *testing.B) { + for _, tc := range escapeBenchmarks { + b.Run("", func(b *testing.B) { + b.ReportAllocs() + var g string + for i := 0; i < b.N; i++ { + g, _ = QueryUnescape(tc.query) + } + b.StopTimer() + if g != tc.unescaped { + b.Errorf("QueryUnescape(%q) == %q, want %q", tc.query, g, tc.unescaped) + } + + }) + } +} + +func BenchmarkPathUnescape(b *testing.B) { + for _, tc := range escapeBenchmarks { + b.Run("", func(b *testing.B) { + b.ReportAllocs() + var g string + for i := 0; i < b.N; i++ { + g, _ = PathUnescape(tc.path) + } + b.StopTimer() + if g != tc.unescaped { + b.Errorf("PathUnescape(%q) == %q, want %q", tc.path, g, tc.unescaped) + } + + }) + } +} diff --git a/libgo/go/os/dir_gccgo.go b/libgo/go/os/dir_gccgo.go index f66064670df..60f70aa034d 100644 --- a/libgo/go/os/dir_gccgo.go +++ b/libgo/go/os/dir_gccgo.go @@ -16,6 +16,9 @@ import ( //extern pathconf func libc_pathconf(*byte, int) int +//extern fdopendir +func libc_fdopendir(int32) *syscall.DIR + func clen(n []byte) int { for i := 0; i < len(n); i++ { if n[i] == 0 { @@ -48,11 +51,11 @@ func (file *File) readdirnames(n int) (names []string, err error) { } syscall.Entersyscall() - r := libc_opendir(p) + r := libc_fdopendir(int32(file.pfd.Sysfd)) errno := syscall.GetErrno() syscall.Exitsyscall() if r == nil { - return nil, &PathError{"opendir", file.name, errno} + return nil, &PathError{"fdopendir", file.name, errno} } file.dirinfo = new(dirInfo) diff --git a/libgo/go/os/dir_ios.go b/libgo/go/os/dir_ios.go new file mode 100644 index 00000000000..8c14d89508a --- /dev/null +++ b/libgo/go/os/dir_ios.go @@ -0,0 +1,87 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build darwin +// +build arm arm64 + +package os + +import ( + "io" + "runtime" + "syscall" + "unsafe" +) + +// Auxiliary information if the File describes a directory +type dirInfo struct { + dir uintptr // Pointer to DIR structure from dirent.h +} + +func (d *dirInfo) close() { + if d.dir == 0 { + return + } + closedir(d.dir) + d.dir = 0 +} + +func (f *File) readdirnames(n int) (names []string, err error) { + if f.dirinfo == nil { + dir, call, errno := f.pfd.OpenDir() + if errno != nil { + return nil, wrapSyscallError(call, errno) + } + f.dirinfo = &dirInfo{ + dir: dir, + } + } + d := f.dirinfo + + size := n + if size <= 0 { + size = 100 + n = -1 + } + + names = make([]string, 0, size) + var dirent syscall.Dirent + var entptr uintptr + for len(names) < size { + if res := readdir_r(d.dir, uintptr(unsafe.Pointer(&dirent)), uintptr(unsafe.Pointer(&entptr))); res != 0 { + return names, wrapSyscallError("readdir", syscall.Errno(res)) + } + if entptr == 0 { // EOF + break + } + if dirent.Ino == 0 { + continue + } + name := (*[len(syscall.Dirent{}.Name)]byte)(unsafe.Pointer(&dirent.Name))[:] + for i, c := range name { + if c == 0 { + name = name[:i] + break + } + } + // Check for useless names before allocating a string. + if string(name) == "." || string(name) == ".." { + continue + } + names = append(names, string(name)) + runtime.KeepAlive(f) + } + if n >= 0 && len(names) == 0 { + return names, io.EOF + } + return names, nil +} + +// Implemented in syscall/syscall_darwin.go. + +//go:linkname closedir syscall.closedir +func closedir(dir uintptr) (err error) + +//go:linkname readdir_r syscall.readdir_r +func readdir_r(dir, entry, result uintptr) (res int) diff --git a/libgo/go/os/dir_libc64_gccgo.go b/libgo/go/os/dir_libc64_gccgo.go index 95d46634c17..dc3ba7f9228 100644 --- a/libgo/go/os/dir_libc64_gccgo.go +++ b/libgo/go/os/dir_libc64_gccgo.go @@ -8,8 +8,5 @@ package os import "syscall" -//extern opendir64 -func libc_opendir(*byte) *syscall.DIR - //extern closedir64 func libc_closedir(*syscall.DIR) int diff --git a/libgo/go/os/dir_libc_gccgo.go b/libgo/go/os/dir_libc_gccgo.go index 1ee253c2a77..b46eb4cd891 100644 --- a/libgo/go/os/dir_libc_gccgo.go +++ b/libgo/go/os/dir_libc_gccgo.go @@ -8,8 +8,5 @@ package os import "syscall" -//extern opendir -func libc_opendir(*byte) *syscall.DIR - //extern closedir func libc_closedir(*syscall.DIR) int diff --git a/libgo/go/os/dir_unix.go b/libgo/go/os/dir_unix.go deleted file mode 100644 index edfc9eaecac..00000000000 --- a/libgo/go/os/dir_unix.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build aix darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris - -package os - -import ( - "io" -) - -func (f *File) readdir(n int) (fi []FileInfo, err error) { - dirname := f.name - if dirname == "" { - dirname = "." - } - names, err := f.Readdirnames(n) - fi = make([]FileInfo, 0, len(names)) - for _, filename := range names { - fip, lerr := lstat(dirname + "/" + filename) - if IsNotExist(lerr) { - // File disappeared between readdir + stat. - // Just treat it as if it didn't exist. - continue - } - if lerr != nil { - return fi, lerr - } - fi = append(fi, fip) - } - if len(fi) == 0 && err == nil && n > 0 { - // Per File.Readdir, the slice must be non-empty or err - // must be non-nil if n > 0. - err = io.EOF - } - return fi, err -} diff --git a/libgo/go/os/env_unix_test.go b/libgo/go/os/env_unix_test.go index f7b67ebbb80..89430b3e204 100644 --- a/libgo/go/os/env_unix_test.go +++ b/libgo/go/os/env_unix_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd linux netbsd openbsd solaris +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package os_test diff --git a/libgo/go/os/error_posix.go b/libgo/go/os/error_posix.go index 3c81b41706f..0478ba676aa 100644 --- a/libgo/go/os/error_posix.go +++ b/libgo/go/os/error_posix.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris windows +// +build aix darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris windows package os diff --git a/libgo/go/os/error_unix_test.go b/libgo/go/os/error_unix_test.go index 8db98676d10..c47af563320 100644 --- a/libgo/go/os/error_unix_test.go +++ b/libgo/go/os/error_unix_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris +// +build aix darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris package os_test diff --git a/libgo/go/os/example_test.go b/libgo/go/os/example_test.go index e21415a3fda..8b6566e1496 100644 --- a/libgo/go/os/example_test.go +++ b/libgo/go/os/example_test.go @@ -55,6 +55,7 @@ func ExampleFileMode() { log.Fatal(err) } + fmt.Printf("permissions: %#o\n", fi.Mode().Perm()) // 0400, 0777, etc. switch mode := fi.Mode(); { case mode.IsRegular(): fmt.Println("regular file") @@ -70,38 +71,35 @@ func ExampleFileMode() { func ExampleIsNotExist() { filename := "a-nonexistent-file" if _, err := os.Stat(filename); os.IsNotExist(err) { - fmt.Printf("file does not exist") + fmt.Println("file does not exist") } // Output: // file does not exist } -func init() { - os.Setenv("USER", "gopher") - os.Setenv("HOME", "/usr/gopher") - os.Unsetenv("GOPATH") -} - func ExampleExpand() { mapper := func(placeholderName string) string { switch placeholderName { case "DAY_PART": return "morning" - case "USER": + case "NAME": return "Gopher" } return "" } - fmt.Println(os.Expand("Good ${DAY_PART}, $USER!", mapper)) + fmt.Println(os.Expand("Good ${DAY_PART}, $NAME!", mapper)) // Output: // Good morning, Gopher! } func ExampleExpandEnv() { - fmt.Println(os.ExpandEnv("$USER lives in ${HOME}.")) + os.Setenv("NAME", "gopher") + os.Setenv("BURROW", "/usr/gopher") + + fmt.Println(os.ExpandEnv("$NAME lives in ${BURROW}.")) // Output: // gopher lives in /usr/gopher. @@ -117,16 +115,24 @@ func ExampleLookupEnv() { } } - show("USER") - show("GOPATH") + os.Setenv("SOME_KEY", "value") + os.Setenv("EMPTY_KEY", "") + + show("SOME_KEY") + show("EMPTY_KEY") + show("MISSING_KEY") // Output: - // USER=gopher - // GOPATH not set + // SOME_KEY=value + // EMPTY_KEY= + // MISSING_KEY not set } func ExampleGetenv() { - fmt.Printf("%s lives in %s.\n", os.Getenv("USER"), os.Getenv("HOME")) + os.Setenv("NAME", "gopher") + os.Setenv("BURROW", "/usr/gopher") + + fmt.Printf("%s lives in %s.\n", os.Getenv("NAME"), os.Getenv("BURROW")) // Output: // gopher lives in /usr/gopher. diff --git a/libgo/go/os/exec/exec.go b/libgo/go/os/exec/exec.go index 88b0a916992..1aa3ab93dcc 100644 --- a/libgo/go/os/exec/exec.go +++ b/libgo/go/os/exec/exec.go @@ -152,6 +152,15 @@ type Cmd struct { // followed by the elements of arg, so arg should not include the // command name itself. For example, Command("echo", "hello"). // Args[0] is always name, not the possibly resolved Path. +// +// On Windows, processes receive the whole command line as a single string +// and do their own parsing. Command combines and quotes Args into a command +// line string with an algorithm compatible with applications using +// CommandLineToArgvW (which is the most common way). Notable exceptions are +// msiexec.exe and cmd.exe (and thus, all batch files), which have a different +// unquoting algorithm. In these or other similar cases, you can do the +// quoting yourself and provide the full command line in SysProcAttr.CmdLine, +// leaving Args empty. func Command(name string, arg ...string) *Cmd { cmd := &Cmd{ Path: name, diff --git a/libgo/go/os/exec/exec_posix_test.go b/libgo/go/os/exec/exec_posix_test.go index 865b6c3ced2..46799cdbdb6 100644 --- a/libgo/go/os/exec/exec_posix_test.go +++ b/libgo/go/os/exec/exec_posix_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd linux netbsd openbsd solaris +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package exec_test diff --git a/libgo/go/os/exec/exec_test.go b/libgo/go/os/exec/exec_test.go index 1e3828550b8..b7cc9da134d 100644 --- a/libgo/go/os/exec/exec_test.go +++ b/libgo/go/os/exec/exec_test.go @@ -172,6 +172,58 @@ func TestExitStatus(t *testing.T) { } } +func TestExitCode(t *testing.T) { + // Test that exit code are returned correctly + cmd := helperCommand(t, "exit", "42") + cmd.Run() + want := 42 + if runtime.GOOS == "plan9" { + want = 1 + } + got := cmd.ProcessState.ExitCode() + if want != got { + t.Errorf("ExitCode got %d, want %d", got, want) + } + + cmd = helperCommand(t, "/no-exist-executable") + cmd.Run() + want = 2 + if runtime.GOOS == "plan9" { + want = 1 + } + got = cmd.ProcessState.ExitCode() + if want != got { + t.Errorf("ExitCode got %d, want %d", got, want) + } + + cmd = helperCommand(t, "exit", "255") + cmd.Run() + want = 255 + if runtime.GOOS == "plan9" { + want = 1 + } + got = cmd.ProcessState.ExitCode() + if want != got { + t.Errorf("ExitCode got %d, want %d", got, want) + } + + cmd = helperCommand(t, "cat") + cmd.Run() + want = 0 + got = cmd.ProcessState.ExitCode() + if want != got { + t.Errorf("ExitCode got %d, want %d", got, want) + } + + // Test when command does not call Run(). + cmd = helperCommand(t, "cat") + want = -1 + got = cmd.ProcessState.ExitCode() + if want != got { + t.Errorf("ExitCode got %d, want %d", got, want) + } +} + func TestPipes(t *testing.T) { check := func(what string, err error) { if err != nil { @@ -411,7 +463,7 @@ func basefds() uintptr { // The poll (epoll/kqueue) descriptor can be numerically // either between stderr and the testlog-fd, or after // testlog-fd. - if poll.PollDescriptor() == n { + if poll.IsPollDescriptor(n) { n++ } for _, arg := range os.Args { @@ -424,7 +476,7 @@ func basefds() uintptr { func closeUnexpectedFds(t *testing.T, m string) { for fd := basefds(); fd <= 101; fd++ { - if fd == poll.PollDescriptor() { + if poll.IsPollDescriptor(fd) { continue } err := os.NewFile(fd, "").Close() @@ -686,6 +738,8 @@ func TestHelperProcess(*testing.T) { ofcmd = "fstat" case "plan9": ofcmd = "/bin/cat" + case "aix": + ofcmd = "procfiles" } args := os.Args @@ -789,7 +843,7 @@ func TestHelperProcess(*testing.T) { // Now verify that there are no other open fds. var files []*os.File for wantfd := basefds() + 1; wantfd <= 100; wantfd++ { - if wantfd == poll.PollDescriptor() { + if poll.IsPollDescriptor(wantfd) { continue } f, err := os.Open(os.Args[0]) @@ -803,6 +857,8 @@ func TestHelperProcess(*testing.T) { switch runtime.GOOS { case "plan9": args = []string{fmt.Sprintf("/proc/%d/fd", os.Getpid())} + case "aix": + args = []string{fmt.Sprint(os.Getpid())} default: args = []string{"-p", fmt.Sprint(os.Getpid())} } diff --git a/libgo/go/os/exec/lp_unix_test.go b/libgo/go/os/exec/lp_unix_test.go index d467acf5dba..e4656cafb8b 100644 --- a/libgo/go/os/exec/lp_unix_test.go +++ b/libgo/go/os/exec/lp_unix_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd linux netbsd openbsd solaris +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package exec diff --git a/libgo/go/os/exec_plan9.go b/libgo/go/os/exec_plan9.go index 6b4d28c93da..bab16ccad34 100644 --- a/libgo/go/os/exec_plan9.go +++ b/libgo/go/os/exec_plan9.go @@ -136,3 +136,13 @@ func (p *ProcessState) String() string { } return "exit status: " + p.status.Msg } + +// ExitCode returns the exit code of the exited process, or -1 +// if the process hasn't exited or was terminated by a signal. +func (p *ProcessState) ExitCode() int { + // return -1 if the process hasn't started. + if p == nil { + return -1 + } + return p.status.ExitStatus() +} diff --git a/libgo/go/os/exec_posix.go b/libgo/go/os/exec_posix.go index dbbb5df8c4a..4c8261295c0 100644 --- a/libgo/go/os/exec_posix.go +++ b/libgo/go/os/exec_posix.go @@ -10,10 +10,11 @@ import ( "syscall" ) -// The only signal values guaranteed to be present in the os package -// on all systems are Interrupt (send the process an interrupt) and -// Kill (force the process to exit). Interrupt is not implemented on -// Windows; using it with os.Process.Signal will return an error. +// The only signal values guaranteed to be present in the os package on all +// systems are os.Interrupt (send the process an interrupt) and os.Kill (force +// the process to exit). On Windows, sending os.Interrupt to a process with +// os.Process.Signal is not implemented; it will return an error instead of +// sending a signal. var ( Interrupt Signal = syscall.SIGINT Kill Signal = syscall.SIGKILL @@ -106,3 +107,13 @@ func (p *ProcessState) String() string { } return res } + +// ExitCode returns the exit code of the exited process, or -1 +// if the process hasn't exited or was terminated by a signal. +func (p *ProcessState) ExitCode() int { + // return -1 if the process hasn't started. + if p == nil { + return -1 + } + return p.status.ExitStatus() +} diff --git a/libgo/go/os/exec_windows.go b/libgo/go/os/exec_windows.go index d5d553a2f6b..38293a0d285 100644 --- a/libgo/go/os/exec_windows.go +++ b/libgo/go/os/exec_windows.go @@ -38,7 +38,8 @@ func (p *Process) wait() (ps *ProcessState, err error) { // NOTE(brainman): It seems that sometimes process is not dead // when WaitForSingleObject returns. But we do not know any // other way to wait for it. Sleeping for a while seems to do - // the trick sometimes. So we will sleep and smell the roses. + // the trick sometimes. + // See https://golang.org/issue/25965 for details. defer time.Sleep(5 * time.Millisecond) defer p.Release() return &ProcessState{p.Pid, syscall.WaitStatus{ExitCode: ec}, &u}, nil diff --git a/libgo/go/os/executable_test.go b/libgo/go/os/executable_test.go index 4a9a8837be4..d513c8760ee 100644 --- a/libgo/go/os/executable_test.go +++ b/libgo/go/os/executable_test.go @@ -36,8 +36,8 @@ func TestExecutable(t *testing.T) { // forge argv[0] for child, so that we can verify we could correctly // get real path of the executable without influenced by argv[0]. cmd.Args = []string{"-", "-test.run=XXXX"} - if runtime.GOOS == "openbsd" { - // OpenBSD relies on argv[0] + if runtime.GOOS == "openbsd" || runtime.GOOS == "aix" { + // OpenBSD and AIX rely on argv[0] cmd.Args[0] = fn } cmd.Env = append(os.Environ(), fmt.Sprintf("%s=1", executable_EnvVar)) diff --git a/libgo/go/os/file.go b/libgo/go/os/file.go index cba70d78fbf..fdead63bfc4 100644 --- a/libgo/go/os/file.go +++ b/libgo/go/os/file.go @@ -73,7 +73,7 @@ const ( O_CREATE int = syscall.O_CREAT // create a new file if none exists. O_EXCL int = syscall.O_EXCL // used with O_CREATE, file must not exist. O_SYNC int = syscall.O_SYNC // open for synchronous I/O. - O_TRUNC int = syscall.O_TRUNC // if possible, truncate file when opened. + O_TRUNC int = syscall.O_TRUNC // truncate regular writable file when opened. ) // Seek whence values. @@ -381,6 +381,31 @@ func UserCacheDir() (string, error) { return dir, nil } +// UserHomeDir returns the current user's home directory. +// +// On Unix, including macOS, it returns the $HOME environment variable. +// On Windows, it returns %USERPROFILE%. +// On Plan 9, it returns the $home environment variable. +func UserHomeDir() (string, error) { + env, enverr := "HOME", "$HOME" + switch runtime.GOOS { + case "windows": + env, enverr = "USERPROFILE", "%userprofile%" + case "plan9": + env, enverr = "home", "$home" + case "nacl", "android": + return "/", nil + case "darwin": + if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" { + return "/", nil + } + } + if v := Getenv(env); v != "" { + return v, nil + } + return "", errors.New(enverr + " is not defined") +} + // Chmod changes the mode of the named file to mode. // If the file is a symbolic link, it changes the mode of the link's target. // If there is an error, it will be of type *PathError. @@ -448,3 +473,12 @@ func (f *File) SetReadDeadline(t time.Time) error { func (f *File) SetWriteDeadline(t time.Time) error { return f.setWriteDeadline(t) } + +// SyscallConn returns a raw file. +// This implements the syscall.Conn interface. +func (f *File) SyscallConn() (syscall.RawConn, error) { + if err := f.checkValid("SyscallConn"); err != nil { + return nil, err + } + return newRawConn(f) +} diff --git a/libgo/go/os/file_plan9.go b/libgo/go/os/file_plan9.go index 2c744034343..3fa12e68166 100644 --- a/libgo/go/os/file_plan9.go +++ b/libgo/go/os/file_plan9.go @@ -534,3 +534,21 @@ func (f *File) checkValid(op string) error { } return nil } + +type rawConn struct{} + +func (c *rawConn) Control(f func(uintptr)) error { + return syscall.EPLAN9 +} + +func (c *rawConn) Read(f func(uintptr) bool) error { + return syscall.EPLAN9 +} + +func (c *rawConn) Write(f func(uintptr) bool) error { + return syscall.EPLAN9 +} + +func newRawConn(file *File) (*rawConn, error) { + return nil, syscall.EPLAN9 +} diff --git a/libgo/go/os/file_posix.go b/libgo/go/os/file_posix.go index 9bd1cc7b98e..1c0de5c3a16 100644 --- a/libgo/go/os/file_posix.go +++ b/libgo/go/os/file_posix.go @@ -7,6 +7,7 @@ package os import ( + "runtime" "syscall" "time" ) @@ -20,7 +21,7 @@ func Readlink(name string) (string, error) { b := make([]byte, len) n, e := fixCount(syscall.Readlink(fixLongPath(name), b)) // buffer too small - if e == syscall.ERANGE { + if runtime.GOOS == "aix" && e == syscall.ERANGE { continue } if e != nil { diff --git a/libgo/go/os/file_unix.go b/libgo/go/os/file_unix.go index b2aea331ea4..e9ac774988f 100644 --- a/libgo/go/os/file_unix.go +++ b/libgo/go/os/file_unix.go @@ -9,6 +9,7 @@ package os import ( "internal/poll" "internal/syscall/unix" + "io" "runtime" "syscall" ) @@ -116,23 +117,39 @@ func newFile(fd uintptr, name string, kind newFileKind) *File { pollable := kind == kindOpenFile || kind == kindPipe || kind == kindNonBlock - // Don't try to use kqueue with regular files on FreeBSD. - // It crashes the system unpredictably while running all.bash. - // Issue 19093. // If the caller passed a non-blocking filedes (kindNonBlock), // we assume they know what they are doing so we allow it to be // used with kqueue. - if runtime.GOOS == "freebsd" && kind == kindOpenFile { - pollable = false - } - - // On Darwin, kqueue does not work properly with fifos: - // closing the last writer does not cause a kqueue event - // for any readers. See issue #24164. - if runtime.GOOS == "darwin" && kind == kindOpenFile { + if kind == kindOpenFile { var st syscall.Stat_t - if err := syscall.Fstat(fdi, &st); err == nil && st.Mode&syscall.S_IFMT == syscall.S_IFIFO { + switch runtime.GOOS { + case "freebsd": + // On FreeBSD before 10.4 it used to crash the + // system unpredictably while running all.bash. + // When we stop supporting FreeBSD 10 we can merge + // this into the dragonfly/netbsd/openbsd case. + // Issue 27619. pollable = false + + case "dragonfly", "netbsd", "openbsd": + // Don't try to use kqueue with regular files on *BSDs. + // On FreeBSD a regular file is always + // reported as ready for writing. + // On Dragonfly, NetBSD and OpenBSD the fd is signaled + // only once as ready (both read and write). + // Issue 19093. + if err := syscall.Fstat(fdi, &st); err == nil && st.Mode&syscall.S_IFMT == syscall.S_IFREG { + pollable = false + } + + case "darwin": + // In addition to the behavior described above for regular files, + // on Darwin, kqueue does not work properly with fifos: + // closing the last writer does not cause a kqueue event + // for any readers. See issue #24164. + if err := syscall.Fstat(fdi, &st); err == nil && (st.Mode&syscall.S_IFMT == syscall.S_IFIFO || st.Mode&syscall.S_IFMT == syscall.S_IFREG) { + pollable = false + } } } @@ -230,22 +247,22 @@ func (file *file) close() error { return syscall.EINVAL } var err error - if e := file.pfd.Close(); e != nil { - if e == poll.ErrFileClosing { - e = ErrClosed - } - err = &PathError{"close", file.name, e} - } - if file.dirinfo != nil { syscall.Entersyscall() i := libc_closedir(file.dirinfo.dir) errno := syscall.GetErrno() syscall.Exitsyscall() file.dirinfo = nil - if i < 0 && err == nil { + if i < 0 && errno != 0 { err = &PathError{"closedir", file.name, errno} } + } else { + if e := file.pfd.Close(); e != nil { + if e == poll.ErrFileClosing { + e = ErrClosed + } + err = &PathError{"close", file.name, e} + } } // no need for a finalizer anymore @@ -368,3 +385,30 @@ func Symlink(oldname, newname string) error { } return nil } + +func (f *File) readdir(n int) (fi []FileInfo, err error) { + dirname := f.name + if dirname == "" { + dirname = "." + } + names, err := f.Readdirnames(n) + fi = make([]FileInfo, 0, len(names)) + for _, filename := range names { + fip, lerr := lstat(dirname + "/" + filename) + if IsNotExist(lerr) { + // File disappeared between readdir + stat. + // Just treat it as if it didn't exist. + continue + } + if lerr != nil { + return fi, lerr + } + fi = append(fi, fip) + } + if len(fi) == 0 && err == nil && n > 0 { + // Per File.Readdir, the slice must be non-empty or err + // must be non-nil if n > 0. + err = io.EOF + } + return fi, err +} diff --git a/libgo/go/os/os_test.go b/libgo/go/os/os_test.go index 5a77d6631eb..98eba89331a 100644 --- a/libgo/go/os/os_test.go +++ b/libgo/go/os/os_test.go @@ -176,7 +176,6 @@ func TestStatError(t *testing.T) { defer chtmpdir(t)() path := "no-such-file" - Remove(path) // Just in case fi, err := Stat(path) if err == nil { @@ -192,12 +191,10 @@ func TestStatError(t *testing.T) { testenv.MustHaveSymlink(t) link := "symlink" - Remove(link) // Just in case err = Symlink(path, link) if err != nil { t.Fatal(err) } - defer Remove(link) fi, err = Stat(link) if err == nil { @@ -267,7 +264,7 @@ func TestRead0(t *testing.T) { } } -// Reading a closed file should should return ErrClosed error +// Reading a closed file should return ErrClosed error func TestReadClosed(t *testing.T) { path := sfdir + "/" + sfname file, err := Open(path) @@ -686,12 +683,10 @@ func TestHardLink(t *testing.T) { defer chtmpdir(t)() from, to := "hardlinktestfrom", "hardlinktestto" - Remove(from) // Just in case. file, err := Create(to) if err != nil { t.Fatalf("open %q failed: %v", to, err) } - defer Remove(to) if err = file.Close(); err != nil { t.Errorf("close %q failed: %v", to, err) } @@ -707,7 +702,6 @@ func TestHardLink(t *testing.T) { t.Errorf("link %q, %q failed to return a valid error", none, none) } - defer Remove(from) tostat, err := Stat(to) if err != nil { t.Fatalf("stat %q failed: %v", to, err) @@ -743,11 +737,8 @@ func TestHardLink(t *testing.T) { } // chtmpdir changes the working directory to a new temporary directory and -// provides a cleanup function. Used when PWD is read-only. +// provides a cleanup function. func chtmpdir(t *testing.T) func() { - if runtime.GOOS != "darwin" || (runtime.GOARCH != "arm" && runtime.GOARCH != "arm64") { - return func() {} // only needed on darwin/arm{,64} - } oldwd, err := Getwd() if err != nil { t.Fatalf("chtmpdir: %v", err) @@ -772,12 +763,10 @@ func TestSymlink(t *testing.T) { defer chtmpdir(t)() from, to := "symlinktestfrom", "symlinktestto" - Remove(from) // Just in case. file, err := Create(to) if err != nil { t.Fatalf("Create(%q) failed: %v", to, err) } - defer Remove(to) if err = file.Close(); err != nil { t.Errorf("Close(%q) failed: %v", to, err) } @@ -785,7 +774,6 @@ func TestSymlink(t *testing.T) { if err != nil { t.Fatalf("Symlink(%q, %q) failed: %v", to, from, err) } - defer Remove(from) tostat, err := Lstat(to) if err != nil { t.Fatalf("Lstat(%q) failed: %v", to, err) @@ -839,12 +827,10 @@ func TestLongSymlink(t *testing.T) { // Long, but not too long: a common limit is 255. s = s + s + s + s + s + s + s + s + s + s + s + s + s + s + s from := "longsymlinktestfrom" - Remove(from) // Just in case. err := Symlink(s, from) if err != nil { t.Fatalf("symlink %q, %q failed: %v", s, from, err) } - defer Remove(from) r, err := Readlink(from) if err != nil { t.Fatalf("readlink %q failed: %v", from, err) @@ -857,9 +843,6 @@ func TestLongSymlink(t *testing.T) { func TestRename(t *testing.T) { defer chtmpdir(t)() from, to := "renamefrom", "renameto" - // Ensure we are not testing the overwrite case here. - Remove(from) - Remove(to) file, err := Create(from) if err != nil { @@ -872,7 +855,6 @@ func TestRename(t *testing.T) { if err != nil { t.Fatalf("rename %q, %q failed: %v", to, from, err) } - defer Remove(to) _, err = Stat(to) if err != nil { t.Errorf("stat %q failed: %v", to, err) @@ -882,9 +864,6 @@ func TestRename(t *testing.T) { func TestRenameOverwriteDest(t *testing.T) { defer chtmpdir(t)() from, to := "renamefrom", "renameto" - // Just in case. - Remove(from) - Remove(to) toData := []byte("to") fromData := []byte("from") @@ -902,7 +881,6 @@ func TestRenameOverwriteDest(t *testing.T) { if err != nil { t.Fatalf("rename %q, %q failed: %v", to, from, err) } - defer Remove(to) _, err = Stat(from) if err == nil { @@ -923,9 +901,6 @@ func TestRenameOverwriteDest(t *testing.T) { func TestRenameFailed(t *testing.T) { defer chtmpdir(t)() from, to := "renamefrom", "renameto" - // Ensure we are not testing the overwrite case here. - Remove(from) - Remove(to) err := Rename(from, to) switch err := err.(type) { @@ -941,9 +916,6 @@ func TestRenameFailed(t *testing.T) { } case nil: t.Errorf("rename %q, %q: expected error, got nil", from, to) - - // cleanup whatever was placed in "renameto" - Remove(to) default: t.Errorf("rename %q, %q: expected %T, got %T %v", from, to, new(LinkError), err, err) } @@ -954,7 +926,6 @@ func TestRenameNotExisting(t *testing.T) { from, to := "doesnt-exist", "dest" Mkdir(to, 0777) - defer Remove(to) if err := Rename(from, to); !IsNotExist(err) { t.Errorf("Rename(%q, %q) = %v; want an IsNotExist error", from, to, err) @@ -965,12 +936,8 @@ func TestRenameToDirFailed(t *testing.T) { defer chtmpdir(t)() from, to := "renamefrom", "renameto" - Remove(from) - Remove(to) Mkdir(from, 0777) Mkdir(to, 0777) - defer Remove(from) - defer Remove(to) err := Rename(from, to) switch err := err.(type) { @@ -986,9 +953,6 @@ func TestRenameToDirFailed(t *testing.T) { } case nil: t.Errorf("rename %q, %q: expected error, got nil", from, to) - - // cleanup whatever was placed in "renameto" - Remove(to) default: t.Errorf("rename %q, %q: expected %T, got %T %v", from, to, new(LinkError), err, err) } @@ -1483,7 +1447,7 @@ func TestOpenNoName(t *testing.T) { } } -func runBinHostname(t *testing.T, argv []string) string { +func runBinHostname(t *testing.T) string { // Run /bin/hostname and collect output. r, w, err := Pipe() if err != nil { @@ -1491,6 +1455,10 @@ func runBinHostname(t *testing.T, argv []string) string { } defer r.Close() const path = "/bin/hostname" + argv := []string{"hostname"} + if runtime.GOOS == "aix" { + argv = []string{"hostname", "-s"} + } p, err := StartProcess(path, argv, &ProcAttr{Files: []*File{nil, w, Stderr}}) if err != nil { if _, err := Stat(path); IsNotExist(err) { @@ -1561,12 +1529,7 @@ func TestHostname(t *testing.T) { // Check internal Hostname() against the output of /bin/hostname. // Allow that the internal Hostname returns a Fully Qualified Domain Name // and the /bin/hostname only returns the first component - var want string - if runtime.GOOS == "aix" { - want = runBinHostname(t, []string{"hostname", "-s"}) - } else { - want = runBinHostname(t, []string{"hostname"}) - } + want := runBinHostname(t) if hostname != want { i := strings.Index(hostname, ".") if i < 0 || hostname[0:i] != want { @@ -1701,7 +1664,6 @@ func writeFile(t *testing.T, fname string, flag int, text string) string { func TestAppend(t *testing.T) { defer chtmpdir(t)() const f = "append.txt" - defer Remove(f) s := writeFile(t, f, O_CREATE|O_TRUNC|O_RDWR, "new") if s != "new" { t.Fatalf("writeFile: have %q want %q", s, "new") @@ -1768,13 +1730,11 @@ func TestSameFile(t *testing.T) { if err != nil { t.Fatalf("Create(a): %v", err) } - defer Remove(fa.Name()) fa.Close() fb, err := Create("b") if err != nil { t.Fatalf("Create(b): %v", err) } - defer Remove(fb.Name()) fb.Close() ia1, err := Stat("a") @@ -2336,3 +2296,20 @@ func TestDoubleCloseError(t *testing.T) { t.Logf("second close returned expected error %q", err) } } + +func TestUserHomeDir(t *testing.T) { + dir, err := UserHomeDir() + if dir == "" && err == nil { + t.Fatal("UserHomeDir returned an empty string but no error") + } + if err != nil { + t.Skipf("UserHomeDir failed: %v", err) + } + fi, err := Stat(dir) + if err != nil { + t.Fatal(err) + } + if !fi.IsDir() { + t.Fatalf("dir %s is not directory; type = %v", dir, fi.Mode()) + } +} diff --git a/libgo/go/os/os_unix_test.go b/libgo/go/os/os_unix_test.go index 54f121ef4c2..2aa930ea80d 100644 --- a/libgo/go/os/os_unix_test.go +++ b/libgo/go/os/os_unix_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd linux netbsd openbsd solaris +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package os_test @@ -22,6 +22,9 @@ func init() { isReadonlyError = func(err error) bool { return err == syscall.EROFS } } +// For TestRawConnReadWrite. +type syscallDescriptor = int + func checkUidGid(t *testing.T, path string, uid, gid int) { dir, err := Lstat(path) if err != nil { @@ -234,7 +237,7 @@ func newFileTest(t *testing.T, blocking bool) { } defer syscall.Close(p[1]) - // Set the the read-side to non-blocking. + // Set the read-side to non-blocking. if !blocking { if err := syscall.SetNonblock(p[0], true); err != nil { syscall.Close(p[0]) diff --git a/libgo/go/os/path.go b/libgo/go/os/path.go index cdfbc189219..30cc6c8b984 100644 --- a/libgo/go/os/path.go +++ b/libgo/go/os/path.go @@ -5,7 +5,6 @@ package os import ( - "io" "syscall" ) @@ -59,100 +58,13 @@ func MkdirAll(path string, perm FileMode) error { return nil } -// RemoveAll removes path and any children it contains. -// It removes everything it can but returns the first error -// it encounters. If the path does not exist, RemoveAll -// returns nil (no error). -func RemoveAll(path string) error { - // Simple case: if Remove works, we're done. - err := Remove(path) - if err == nil || IsNotExist(err) { - return nil +// endsWithDot reports whether the final component of path is ".". +func endsWithDot(path string) bool { + if path == "." { + return true } - - // Otherwise, is this a directory we need to recurse into? - dir, serr := Lstat(path) - if serr != nil { - if serr, ok := serr.(*PathError); ok && (IsNotExist(serr.Err) || serr.Err == syscall.ENOTDIR) { - return nil - } - return serr - } - if !dir.IsDir() { - // Not a directory; return the error from Remove. - return err - } - - // Remove contents & return first error. - err = nil - for { - fd, err := Open(path) - if err != nil { - if IsNotExist(err) { - // Already deleted by someone else. - return nil - } - return err - } - - const request = 1024 - names, err1 := fd.Readdirnames(request) - - // Removing files from the directory may have caused - // the OS to reshuffle it. Simply calling Readdirnames - // again may skip some entries. The only reliable way - // to avoid this is to close and re-open the - // directory. See issue 20841. - fd.Close() - - for _, name := range names { - err1 := RemoveAll(path + string(PathSeparator) + name) - if err == nil { - err = err1 - } - } - - if err1 == io.EOF { - break - } - // If Readdirnames returned an error, use it. - if err == nil { - err = err1 - } - if len(names) == 0 { - break - } - - // We don't want to re-open unnecessarily, so if we - // got fewer than request names from Readdirnames, try - // simply removing the directory now. If that - // succeeds, we are done. - if len(names) < request { - err1 := Remove(path) - if err1 == nil || IsNotExist(err1) { - return nil - } - - if err != nil { - // We got some error removing the - // directory contents, and since we - // read fewer names than we requested - // there probably aren't more files to - // remove. Don't loop around to read - // the directory again. We'll probably - // just get the same error. - return err - } - } - } - - // Remove directory. - err1 := Remove(path) - if err1 == nil || IsNotExist(err1) { - return nil - } - if err == nil { - err = err1 + if len(path) >= 2 && path[len(path)-1] == '.' && IsPathSeparator(path[len(path)-2]) { + return true } - return err + return false } diff --git a/libgo/go/os/path_test.go b/libgo/go/os/path_test.go index f58c7e746d9..6cb25bcaa71 100644 --- a/libgo/go/os/path_test.go +++ b/libgo/go/os/path_test.go @@ -5,7 +5,6 @@ package os_test import ( - "fmt" "internal/testenv" "io/ioutil" . "os" @@ -76,130 +75,6 @@ func TestMkdirAll(t *testing.T) { } } -func TestRemoveAll(t *testing.T) { - tmpDir := TempDir() - // Work directory. - path := tmpDir + "/_TestRemoveAll_" - fpath := path + "/file" - dpath := path + "/dir" - - // Make directory with 1 file and remove. - if err := MkdirAll(path, 0777); err != nil { - t.Fatalf("MkdirAll %q: %s", path, err) - } - fd, err := Create(fpath) - if err != nil { - t.Fatalf("create %q: %s", fpath, err) - } - fd.Close() - if err = RemoveAll(path); err != nil { - t.Fatalf("RemoveAll %q (first): %s", path, err) - } - if _, err = Lstat(path); err == nil { - t.Fatalf("Lstat %q succeeded after RemoveAll (first)", path) - } - - // Make directory with file and subdirectory and remove. - if err = MkdirAll(dpath, 0777); err != nil { - t.Fatalf("MkdirAll %q: %s", dpath, err) - } - fd, err = Create(fpath) - if err != nil { - t.Fatalf("create %q: %s", fpath, err) - } - fd.Close() - fd, err = Create(dpath + "/file") - if err != nil { - t.Fatalf("create %q: %s", fpath, err) - } - fd.Close() - if err = RemoveAll(path); err != nil { - t.Fatalf("RemoveAll %q (second): %s", path, err) - } - if _, err := Lstat(path); err == nil { - t.Fatalf("Lstat %q succeeded after RemoveAll (second)", path) - } - - // Determine if we should run the following test. - testit := true - if runtime.GOOS == "windows" { - // Chmod is not supported under windows. - testit = false - } else { - // Test fails as root. - testit = Getuid() != 0 - } - if testit { - // Make directory with file and subdirectory and trigger error. - if err = MkdirAll(dpath, 0777); err != nil { - t.Fatalf("MkdirAll %q: %s", dpath, err) - } - - for _, s := range []string{fpath, dpath + "/file1", path + "/zzz"} { - fd, err = Create(s) - if err != nil { - t.Fatalf("create %q: %s", s, err) - } - fd.Close() - } - if err = Chmod(dpath, 0); err != nil { - t.Fatalf("Chmod %q 0: %s", dpath, err) - } - - // No error checking here: either RemoveAll - // will or won't be able to remove dpath; - // either way we want to see if it removes fpath - // and path/zzz. Reasons why RemoveAll might - // succeed in removing dpath as well include: - // * running as root - // * running on a file system without permissions (FAT) - RemoveAll(path) - Chmod(dpath, 0777) - - for _, s := range []string{fpath, path + "/zzz"} { - if _, err = Lstat(s); err == nil { - t.Fatalf("Lstat %q succeeded after partial RemoveAll", s) - } - } - } - if err = RemoveAll(path); err != nil { - t.Fatalf("RemoveAll %q after partial RemoveAll: %s", path, err) - } - if _, err = Lstat(path); err == nil { - t.Fatalf("Lstat %q succeeded after RemoveAll (final)", path) - } -} - -// Test RemoveAll on a large directory. -func TestRemoveAllLarge(t *testing.T) { - if testing.Short() { - t.Skip("skipping in short mode") - } - - tmpDir := TempDir() - // Work directory. - path := tmpDir + "/_TestRemoveAllLarge_" - - // Make directory with 1000 files and remove. - if err := MkdirAll(path, 0777); err != nil { - t.Fatalf("MkdirAll %q: %s", path, err) - } - for i := 0; i < 1000; i++ { - fpath := fmt.Sprintf("%s/file%d", path, i) - fd, err := Create(fpath) - if err != nil { - t.Fatalf("create %q: %s", fpath, err) - } - fd.Close() - } - if err := RemoveAll(path); err != nil { - t.Fatalf("RemoveAll %q: %s", path, err) - } - if _, err := Lstat(path); err == nil { - t.Fatalf("Lstat %q succeeded after RemoveAll", path) - } -} - func TestMkdirAllWithSymlink(t *testing.T) { testenv.MustHaveSymlink(t) diff --git a/libgo/go/os/path_unix.go b/libgo/go/os/path_unix.go index 3cb0e3acc4d..be373a50a91 100644 --- a/libgo/go/os/path_unix.go +++ b/libgo/go/os/path_unix.go @@ -16,7 +16,7 @@ func IsPathSeparator(c uint8) bool { return PathSeparator == c } -// basename removes trailing slashes and the leading directory name from path name +// basename removes trailing slashes and the leading directory name from path name. func basename(name string) string { i := len(name) - 1 // Remove trailing slashes @@ -34,6 +34,32 @@ func basename(name string) string { return name } +// splitPath returns the base name and parent directory. +func splitPath(path string) (string, string) { + // if no better parent is found, the path is relative from "here" + dirname := "." + // if no slashes in path, base is path + basename := path + + i := len(path) - 1 + + // Remove trailing slashes + for ; i > 0 && path[i] == '/'; i-- { + path = path[:i] + } + + // Remove leading directory path + for i--; i >= 0; i-- { + if path[i] == '/' { + dirname = path[:i+1] + basename = path[i+1:] + break + } + } + + return dirname, basename +} + func fixRootDirectory(p string) string { return p } diff --git a/libgo/go/os/path_windows_test.go b/libgo/go/os/path_windows_test.go index 00a3e63bf3c..f1745ad132e 100644 --- a/libgo/go/os/path_windows_test.go +++ b/libgo/go/os/path_windows_test.go @@ -38,10 +38,10 @@ func TestFixLongPath(t *testing.T) { {`\\?\c:\long\foo.txt`, `\\?\c:\long\foo.txt`}, {`\\?\c:\long/foo.txt`, `\\?\c:\long/foo.txt`}, } { - in := strings.Replace(test.in, "long", veryLong, -1) - want := strings.Replace(test.want, "long", veryLong, -1) + in := strings.ReplaceAll(test.in, "long", veryLong) + want := strings.ReplaceAll(test.want, "long", veryLong) if got := os.FixLongPath(in); got != want { - got = strings.Replace(got, veryLong, "long", -1) + got = strings.ReplaceAll(got, veryLong, "long") t.Errorf("fixLongPath(%q) = %q; want %q", test.in, got, test.want) } } diff --git a/libgo/go/os/pipe_test.go b/libgo/go/os/pipe_test.go index 59d31e5837c..779b2bdf85b 100644 --- a/libgo/go/os/pipe_test.go +++ b/libgo/go/os/pipe_test.go @@ -131,7 +131,7 @@ func testClosedPipeRace(t *testing.T, read bool) { if !read { // Get the amount we have to write to overload a pipe // with no reader. - limit = 65537 + limit = 131073 if b, err := ioutil.ReadFile("/proc/sys/fs/pipe-max-size"); err == nil { if i, err := strconv.Atoi(strings.TrimSpace(string(b))); err == nil { limit = i + 1 diff --git a/libgo/go/os/rawconn.go b/libgo/go/os/rawconn.go new file mode 100644 index 00000000000..9e11cda8c9a --- /dev/null +++ b/libgo/go/os/rawconn.go @@ -0,0 +1,47 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !plan9 + +package os + +import ( + "runtime" +) + +// rawConn implements syscall.RawConn. +type rawConn struct { + file *File +} + +func (c *rawConn) Control(f func(uintptr)) error { + if err := c.file.checkValid("SyscallConn.Control"); err != nil { + return err + } + err := c.file.pfd.RawControl(f) + runtime.KeepAlive(c.file) + return err +} + +func (c *rawConn) Read(f func(uintptr) bool) error { + if err := c.file.checkValid("SyscallConn.Read"); err != nil { + return err + } + err := c.file.pfd.RawRead(f) + runtime.KeepAlive(c.file) + return err +} + +func (c *rawConn) Write(f func(uintptr) bool) error { + if err := c.file.checkValid("SyscallConn.Write"); err != nil { + return err + } + err := c.file.pfd.RawWrite(f) + runtime.KeepAlive(c.file) + return err +} + +func newRawConn(file *File) (*rawConn, error) { + return &rawConn{file: file}, nil +} diff --git a/libgo/go/os/rawconn_test.go b/libgo/go/os/rawconn_test.go new file mode 100644 index 00000000000..820150d959b --- /dev/null +++ b/libgo/go/os/rawconn_test.go @@ -0,0 +1,65 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test use of raw connections. +// +build !plan9,!nacl,!js + +package os_test + +import ( + "os" + "syscall" + "testing" +) + +func TestRawConnReadWrite(t *testing.T) { + t.Parallel() + + r, w, err := os.Pipe() + if err != nil { + t.Fatal(err) + } + defer r.Close() + defer w.Close() + + rconn, err := r.SyscallConn() + if err != nil { + t.Fatal(err) + } + wconn, err := w.SyscallConn() + if err != nil { + t.Fatal(err) + } + + var operr error + err = wconn.Write(func(s uintptr) bool { + _, operr = syscall.Write(syscallDescriptor(s), []byte{'b'}) + return operr != syscall.EAGAIN + }) + if err != nil { + t.Fatal(err) + } + if operr != nil { + t.Fatal(err) + } + + var n int + buf := make([]byte, 1) + err = rconn.Read(func(s uintptr) bool { + n, operr = syscall.Read(syscallDescriptor(s), buf) + return operr != syscall.EAGAIN + }) + if err != nil { + t.Fatal(err) + } + if operr != nil { + t.Fatal(operr) + } + if n != 1 { + t.Errorf("read %d bytes, expected 1", n) + } + if buf[0] != 'b' { + t.Errorf("read %q, expected %q", buf, "b") + } +} diff --git a/libgo/go/os/removeall_at.go b/libgo/go/os/removeall_at.go new file mode 100644 index 00000000000..f0fed6dc33f --- /dev/null +++ b/libgo/go/os/removeall_at.go @@ -0,0 +1,138 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris + +package os + +import ( + "internal/syscall/unix" + "io" + "syscall" +) + +func RemoveAll(path string) error { + if path == "" { + // fail silently to retain compatibility with previous behavior + // of RemoveAll. See issue 28830. + return nil + } + + // The rmdir system call does not permit removing ".", + // so we don't permit it either. + if endsWithDot(path) { + return &PathError{"RemoveAll", path, syscall.EINVAL} + } + + // Simple case: if Remove works, we're done. + err := Remove(path) + if err == nil || IsNotExist(err) { + return nil + } + + // RemoveAll recurses by deleting the path base from + // its parent directory + parentDir, base := splitPath(path) + + parent, err := Open(parentDir) + if IsNotExist(err) { + // If parent does not exist, base cannot exist. Fail silently + return nil + } + if err != nil { + return err + } + defer parent.Close() + + return removeAllFrom(parent, base) +} + +func removeAllFrom(parent *File, path string) error { + parentFd := int(parent.Fd()) + // Simple case: if Unlink (aka remove) works, we're done. + err := unix.Unlinkat(parentFd, path, 0) + if err == nil || IsNotExist(err) { + return nil + } + + // If not a "is directory" error, we have a problem + if err != syscall.EISDIR && err != syscall.EPERM { + return err + } + + // Is this a directory we need to recurse into? + var statInfo syscall.Stat_t + statErr := unix.Fstatat(parentFd, path, &statInfo, unix.AT_SYMLINK_NOFOLLOW) + if statErr != nil { + return statErr + } + if statInfo.Mode&syscall.S_IFMT != syscall.S_IFDIR { + // Not a directory; return the error from the Remove + return err + } + + // Remove the directory's entries + var recurseErr error + for { + const request = 1024 + + // Open the directory to recurse into + file, err := openFdAt(parentFd, path) + if err != nil { + if IsNotExist(err) { + return nil + } + return err + } + + names, readErr := file.Readdirnames(request) + // Errors other than EOF should stop us from continuing + if readErr != nil && readErr != io.EOF { + file.Close() + if IsNotExist(readErr) { + return nil + } + return readErr + } + + for _, name := range names { + err := removeAllFrom(file, name) + if err != nil { + recurseErr = err + } + } + + // Removing files from the directory may have caused + // the OS to reshuffle it. Simply calling Readdirnames + // again may skip some entries. The only reliable way + // to avoid this is to close and re-open the + // directory. See issue 20841. + file.Close() + + // Finish when the end of the directory is reached + if len(names) < request { + break + } + } + + // Remove the directory itself + unlinkError := unix.Unlinkat(parentFd, path, unix.AT_REMOVEDIR) + if unlinkError == nil || IsNotExist(unlinkError) { + return nil + } + + if recurseErr != nil { + return recurseErr + } + return unlinkError +} + +func openFdAt(fd int, path string) (*File, error) { + fd, err := unix.Openat(fd, path, O_RDONLY, 0) + if err != nil { + return nil, err + } + + return NewFile(uintptr(fd), path), nil +} diff --git a/libgo/go/os/removeall_noat.go b/libgo/go/os/removeall_noat.go new file mode 100644 index 00000000000..80527e227c9 --- /dev/null +++ b/libgo/go/os/removeall_noat.go @@ -0,0 +1,123 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris + +package os + +import ( + "io" + "syscall" +) + +// RemoveAll removes path and any children it contains. +// It removes everything it can but returns the first error +// it encounters. If the path does not exist, RemoveAll +// returns nil (no error). +func RemoveAll(path string) error { + if path == "" { + // fail silently to retain compatibility with previous behavior + // of RemoveAll. See issue 28830. + return nil + } + + // The rmdir system call permits removing "." on Plan 9, + // so we don't permit it to remain consistent with the + // "at" implementation of RemoveAll. + if endsWithDot(path) { + return &PathError{"RemoveAll", path, syscall.EINVAL} + } + + // Simple case: if Remove works, we're done. + err := Remove(path) + if err == nil || IsNotExist(err) { + return nil + } + + // Otherwise, is this a directory we need to recurse into? + dir, serr := Lstat(path) + if serr != nil { + if serr, ok := serr.(*PathError); ok && (IsNotExist(serr.Err) || serr.Err == syscall.ENOTDIR) { + return nil + } + return serr + } + if !dir.IsDir() { + // Not a directory; return the error from Remove. + return err + } + + // Remove contents & return first error. + err = nil + for { + fd, err := Open(path) + if err != nil { + if IsNotExist(err) { + // Already deleted by someone else. + return nil + } + return err + } + + const request = 1024 + names, err1 := fd.Readdirnames(request) + + // Removing files from the directory may have caused + // the OS to reshuffle it. Simply calling Readdirnames + // again may skip some entries. The only reliable way + // to avoid this is to close and re-open the + // directory. See issue 20841. + fd.Close() + + for _, name := range names { + err1 := RemoveAll(path + string(PathSeparator) + name) + if err == nil { + err = err1 + } + } + + if err1 == io.EOF { + break + } + // If Readdirnames returned an error, use it. + if err == nil { + err = err1 + } + if len(names) == 0 { + break + } + + // We don't want to re-open unnecessarily, so if we + // got fewer than request names from Readdirnames, try + // simply removing the directory now. If that + // succeeds, we are done. + if len(names) < request { + err1 := Remove(path) + if err1 == nil || IsNotExist(err1) { + return nil + } + + if err != nil { + // We got some error removing the + // directory contents, and since we + // read fewer names than we requested + // there probably aren't more files to + // remove. Don't loop around to read + // the directory again. We'll probably + // just get the same error. + return err + } + } + } + + // Remove directory. + err1 := Remove(path) + if err1 == nil || IsNotExist(err1) { + return nil + } + if err == nil { + err = err1 + } + return err +} diff --git a/libgo/go/os/removeall_test.go b/libgo/go/os/removeall_test.go new file mode 100644 index 00000000000..0f7dce078a6 --- /dev/null +++ b/libgo/go/os/removeall_test.go @@ -0,0 +1,294 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package os_test + +import ( + "fmt" + "io/ioutil" + . "os" + "path/filepath" + "runtime" + "strings" + "testing" +) + +func TestRemoveAll(t *testing.T) { + tmpDir, err := ioutil.TempDir("", "TestRemoveAll-") + if err != nil { + t.Fatal(err) + } + defer RemoveAll(tmpDir) + + if err := RemoveAll(""); err != nil { + t.Errorf("RemoveAll(\"\"): %v; want nil", err) + } + + file := filepath.Join(tmpDir, "file") + path := filepath.Join(tmpDir, "_TestRemoveAll_") + fpath := filepath.Join(path, "file") + dpath := filepath.Join(path, "dir") + + // Make a regular file and remove + fd, err := Create(file) + if err != nil { + t.Fatalf("create %q: %s", file, err) + } + fd.Close() + if err = RemoveAll(file); err != nil { + t.Fatalf("RemoveAll %q (first): %s", file, err) + } + if _, err = Lstat(file); err == nil { + t.Fatalf("Lstat %q succeeded after RemoveAll (first)", file) + } + + // Make directory with 1 file and remove. + if err := MkdirAll(path, 0777); err != nil { + t.Fatalf("MkdirAll %q: %s", path, err) + } + fd, err = Create(fpath) + if err != nil { + t.Fatalf("create %q: %s", fpath, err) + } + fd.Close() + if err = RemoveAll(path); err != nil { + t.Fatalf("RemoveAll %q (second): %s", path, err) + } + if _, err = Lstat(path); err == nil { + t.Fatalf("Lstat %q succeeded after RemoveAll (second)", path) + } + + // Make directory with file and subdirectory and remove. + if err = MkdirAll(dpath, 0777); err != nil { + t.Fatalf("MkdirAll %q: %s", dpath, err) + } + fd, err = Create(fpath) + if err != nil { + t.Fatalf("create %q: %s", fpath, err) + } + fd.Close() + fd, err = Create(dpath + "/file") + if err != nil { + t.Fatalf("create %q: %s", fpath, err) + } + fd.Close() + if err = RemoveAll(path); err != nil { + t.Fatalf("RemoveAll %q (third): %s", path, err) + } + if _, err := Lstat(path); err == nil { + t.Fatalf("Lstat %q succeeded after RemoveAll (third)", path) + } + + // Determine if we should run the following test. + testit := true + if runtime.GOOS == "windows" { + // Chmod is not supported under windows. + testit = false + } else { + // Test fails as root. + testit = Getuid() != 0 + } + if testit { + // Make directory with file and subdirectory and trigger error. + if err = MkdirAll(dpath, 0777); err != nil { + t.Fatalf("MkdirAll %q: %s", dpath, err) + } + + for _, s := range []string{fpath, dpath + "/file1", path + "/zzz"} { + fd, err = Create(s) + if err != nil { + t.Fatalf("create %q: %s", s, err) + } + fd.Close() + } + if err = Chmod(dpath, 0); err != nil { + t.Fatalf("Chmod %q 0: %s", dpath, err) + } + + // No error checking here: either RemoveAll + // will or won't be able to remove dpath; + // either way we want to see if it removes fpath + // and path/zzz. Reasons why RemoveAll might + // succeed in removing dpath as well include: + // * running as root + // * running on a file system without permissions (FAT) + RemoveAll(path) + Chmod(dpath, 0777) + + for _, s := range []string{fpath, path + "/zzz"} { + if _, err = Lstat(s); err == nil { + t.Fatalf("Lstat %q succeeded after partial RemoveAll", s) + } + } + } + if err = RemoveAll(path); err != nil { + t.Fatalf("RemoveAll %q after partial RemoveAll: %s", path, err) + } + if _, err = Lstat(path); err == nil { + t.Fatalf("Lstat %q succeeded after RemoveAll (final)", path) + } +} + +// Test RemoveAll on a large directory. +func TestRemoveAllLarge(t *testing.T) { + if testing.Short() { + t.Skip("skipping in short mode") + } + + tmpDir, err := ioutil.TempDir("", "TestRemoveAll-") + if err != nil { + t.Fatal(err) + } + defer RemoveAll(tmpDir) + + path := filepath.Join(tmpDir, "_TestRemoveAllLarge_") + + // Make directory with 1000 files and remove. + if err := MkdirAll(path, 0777); err != nil { + t.Fatalf("MkdirAll %q: %s", path, err) + } + for i := 0; i < 1000; i++ { + fpath := fmt.Sprintf("%s/file%d", path, i) + fd, err := Create(fpath) + if err != nil { + t.Fatalf("create %q: %s", fpath, err) + } + fd.Close() + } + if err := RemoveAll(path); err != nil { + t.Fatalf("RemoveAll %q: %s", path, err) + } + if _, err := Lstat(path); err == nil { + t.Fatalf("Lstat %q succeeded after RemoveAll", path) + } +} + +func TestRemoveAllLongPath(t *testing.T) { + switch runtime.GOOS { + case "aix", "darwin", "dragonfly", "freebsd", "linux", "netbsd", "openbsd", "solaris": + break + default: + t.Skip("skipping for not implemented platforms") + } + + prevDir, err := Getwd() + if err != nil { + t.Fatalf("Could not get wd: %s", err) + } + + startPath, err := ioutil.TempDir("", "TestRemoveAllLongPath-") + if err != nil { + t.Fatalf("Could not create TempDir: %s", err) + } + defer RemoveAll(startPath) + + err = Chdir(startPath) + if err != nil { + t.Fatalf("Could not chdir %s: %s", startPath, err) + } + + // Removing paths with over 4096 chars commonly fails + for i := 0; i < 41; i++ { + name := strings.Repeat("a", 100) + + err = Mkdir(name, 0755) + if err != nil { + t.Fatalf("Could not mkdir %s: %s", name, err) + } + + err = Chdir(name) + if err != nil { + t.Fatalf("Could not chdir %s: %s", name, err) + } + } + + err = Chdir(prevDir) + if err != nil { + t.Fatalf("Could not chdir %s: %s", prevDir, err) + } + + err = RemoveAll(startPath) + if err != nil { + t.Errorf("RemoveAll could not remove long file path %s: %s", startPath, err) + } +} + +func TestRemoveAllDot(t *testing.T) { + prevDir, err := Getwd() + if err != nil { + t.Fatalf("Could not get wd: %s", err) + } + tempDir, err := ioutil.TempDir("", "TestRemoveAllDot-") + if err != nil { + t.Fatalf("Could not create TempDir: %s", err) + } + defer RemoveAll(tempDir) + + err = Chdir(tempDir) + if err != nil { + t.Fatalf("Could not chdir to tempdir: %s", err) + } + + err = RemoveAll(".") + if err == nil { + t.Errorf("RemoveAll succeed to remove .") + } + + err = Chdir(prevDir) + if err != nil { + t.Fatalf("Could not chdir %s: %s", prevDir, err) + } +} + +func TestRemoveAllDotDot(t *testing.T) { + t.Parallel() + + tempDir, err := ioutil.TempDir("", "TestRemoveAllDotDot-") + if err != nil { + t.Fatal(err) + } + defer RemoveAll(tempDir) + + subdir := filepath.Join(tempDir, "x") + subsubdir := filepath.Join(subdir, "y") + if err := MkdirAll(subsubdir, 0777); err != nil { + t.Fatal(err) + } + if err := RemoveAll(filepath.Join(subsubdir, "..")); err != nil { + t.Error(err) + } + for _, dir := range []string{subsubdir, subdir} { + if _, err := Stat(dir); err == nil { + t.Errorf("%s: exists after RemoveAll", dir) + } + } +} + +// Issue #29178. +func TestRemoveReadOnlyDir(t *testing.T) { + t.Parallel() + + tempDir, err := ioutil.TempDir("", "TestRemoveReadOnlyDir-") + if err != nil { + t.Fatal(err) + } + defer RemoveAll(tempDir) + + subdir := filepath.Join(tempDir, "x") + if err := Mkdir(subdir, 0); err != nil { + t.Fatal(err) + } + + // If an error occurs make it more likely that removing the + // temporary directory will succeed. + defer Chmod(subdir, 0777) + + if err := RemoveAll(subdir); err != nil { + t.Fatal(err) + } + + if _, err := Stat(subdir); err == nil { + t.Error("subdirectory was not removed") + } +} diff --git a/libgo/go/os/signal/internal/pty/pty.go b/libgo/go/os/signal/internal/pty/pty.go index e52d19ac30c..a82cf0515f0 100644 --- a/libgo/go/os/signal/internal/pty/pty.go +++ b/libgo/go/os/signal/internal/pty/pty.go @@ -3,6 +3,7 @@ // license that can be found in the LICENSE file. // +build aix darwin dragonfly freebsd linux,!android netbsd openbsd solaris +// +build cgo // Package pty is a simple pseudo-terminal package for Unix systems, // implemented by calling C functions via cgo. diff --git a/libgo/go/os/signal/signal_cgo_test.go b/libgo/go/os/signal/signal_cgo_test.go index 16aeea8221c..3c23090489f 100644 --- a/libgo/go/os/signal/signal_cgo_test.go +++ b/libgo/go/os/signal/signal_cgo_test.go @@ -22,6 +22,7 @@ import ( "os/signal/internal/pty" "strconv" "strings" + "sync" "syscall" "testing" "time" @@ -113,7 +114,11 @@ func TestTerminalSignal(t *testing.T) { const prompt = "prompt> " // Read data from master in the background. + var wg sync.WaitGroup + wg.Add(1) + defer wg.Wait() go func() { + defer wg.Done() input := bufio.NewReader(master) var line, handled []byte for { diff --git a/libgo/go/os/stat_aix.go b/libgo/go/os/stat_aix.go index 265761f98bc..5301827c7bf 100644 --- a/libgo/go/os/stat_aix.go +++ b/libgo/go/os/stat_aix.go @@ -1,4 +1,4 @@ -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/libgo/go/os/stat_test.go b/libgo/go/os/stat_test.go new file mode 100644 index 00000000000..60f3b4c587d --- /dev/null +++ b/libgo/go/os/stat_test.go @@ -0,0 +1,292 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package os_test + +import ( + "internal/testenv" + "io/ioutil" + "os" + "path/filepath" + "runtime" + "testing" +) + +// testStatAndLstat verifies that all os.Stat, os.Lstat os.File.Stat and os.Readdir work. +func testStatAndLstat(t *testing.T, path string, isLink bool, statCheck, lstatCheck func(*testing.T, string, os.FileInfo)) { + // test os.Stat + sfi, err := os.Stat(path) + if err != nil { + t.Error(err) + return + } + statCheck(t, path, sfi) + + // test os.Lstat + lsfi, err := os.Lstat(path) + if err != nil { + t.Error(err) + return + } + lstatCheck(t, path, lsfi) + + if isLink { + if os.SameFile(sfi, lsfi) { + t.Errorf("stat and lstat of %q should not be the same", path) + } + } else { + if !os.SameFile(sfi, lsfi) { + t.Errorf("stat and lstat of %q should be the same", path) + } + } + + // test os.File.Stat + f, err := os.Open(path) + if err != nil { + t.Error(err) + return + } + defer f.Close() + + sfi2, err := f.Stat() + if err != nil { + t.Error(err) + return + } + statCheck(t, path, sfi2) + + if !os.SameFile(sfi, sfi2) { + t.Errorf("stat of open %q file and stat of %q should be the same", path, path) + } + + if isLink { + if os.SameFile(sfi2, lsfi) { + t.Errorf("stat of opened %q file and lstat of %q should not be the same", path, path) + } + } else { + if !os.SameFile(sfi2, lsfi) { + t.Errorf("stat of opened %q file and lstat of %q should be the same", path, path) + } + } + + // test os.FileInfo returned by os.Readdir + if len(path) > 0 && os.IsPathSeparator(path[len(path)-1]) { + // skip os.Readdir test of directories with slash at the end + return + } + parentdir := filepath.Dir(path) + parent, err := os.Open(parentdir) + if err != nil { + t.Error(err) + return + } + defer parent.Close() + + fis, err := parent.Readdir(-1) + if err != nil { + t.Error(err) + return + } + var lsfi2 os.FileInfo + base := filepath.Base(path) + for _, fi2 := range fis { + if fi2.Name() == base { + lsfi2 = fi2 + break + } + } + if lsfi2 == nil { + t.Errorf("failed to find %q in its parent", path) + return + } + lstatCheck(t, path, lsfi2) + + if !os.SameFile(lsfi, lsfi2) { + t.Errorf("lstat of %q file in %q directory and %q should be the same", lsfi2.Name(), parentdir, path) + } +} + +// testIsDir verifies that fi refers to directory. +func testIsDir(t *testing.T, path string, fi os.FileInfo) { + t.Helper() + if !fi.IsDir() { + t.Errorf("%q should be a directory", path) + } + if fi.Mode()&os.ModeSymlink != 0 { + t.Errorf("%q should not be a symlink", path) + } +} + +// testIsSymlink verifies that fi refers to symlink. +func testIsSymlink(t *testing.T, path string, fi os.FileInfo) { + t.Helper() + if fi.IsDir() { + t.Errorf("%q should not be a directory", path) + } + if fi.Mode()&os.ModeSymlink == 0 { + t.Errorf("%q should be a symlink", path) + } +} + +// testIsFile verifies that fi refers to file. +func testIsFile(t *testing.T, path string, fi os.FileInfo) { + t.Helper() + if fi.IsDir() { + t.Errorf("%q should not be a directory", path) + } + if fi.Mode()&os.ModeSymlink != 0 { + t.Errorf("%q should not be a symlink", path) + } +} + +func testDirStats(t *testing.T, path string) { + testStatAndLstat(t, path, false, testIsDir, testIsDir) +} + +func testFileStats(t *testing.T, path string) { + testStatAndLstat(t, path, false, testIsFile, testIsFile) +} + +func testSymlinkStats(t *testing.T, path string, isdir bool) { + if isdir { + testStatAndLstat(t, path, true, testIsDir, testIsSymlink) + } else { + testStatAndLstat(t, path, true, testIsFile, testIsSymlink) + } +} + +func testSymlinkSameFile(t *testing.T, path, link string) { + pathfi, err := os.Stat(path) + if err != nil { + t.Error(err) + return + } + + linkfi, err := os.Stat(link) + if err != nil { + t.Error(err) + return + } + if !os.SameFile(pathfi, linkfi) { + t.Errorf("os.Stat(%q) and os.Stat(%q) are not the same file", path, link) + } + + linkfi, err = os.Lstat(link) + if err != nil { + t.Error(err) + return + } + if os.SameFile(pathfi, linkfi) { + t.Errorf("os.Stat(%q) and os.Lstat(%q) are the same file", path, link) + } +} + +func TestDirAndSymlinkStats(t *testing.T) { + testenv.MustHaveSymlink(t) + + tmpdir, err := ioutil.TempDir("", "TestDirAndSymlinkStats") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(tmpdir) + + dir := filepath.Join(tmpdir, "dir") + err = os.Mkdir(dir, 0777) + if err != nil { + t.Fatal(err) + } + testDirStats(t, dir) + + dirlink := filepath.Join(tmpdir, "link") + err = os.Symlink(dir, dirlink) + if err != nil { + t.Fatal(err) + } + testSymlinkStats(t, dirlink, true) + testSymlinkSameFile(t, dir, dirlink) + + linklink := filepath.Join(tmpdir, "linklink") + err = os.Symlink(dirlink, linklink) + if err != nil { + t.Fatal(err) + } + testSymlinkStats(t, linklink, true) + testSymlinkSameFile(t, dir, linklink) +} + +func TestFileAndSymlinkStats(t *testing.T) { + testenv.MustHaveSymlink(t) + + tmpdir, err := ioutil.TempDir("", "TestFileAndSymlinkStats") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(tmpdir) + + file := filepath.Join(tmpdir, "file") + err = ioutil.WriteFile(file, []byte(""), 0644) + if err != nil { + t.Fatal(err) + } + testFileStats(t, file) + + filelink := filepath.Join(tmpdir, "link") + err = os.Symlink(file, filelink) + if err != nil { + t.Fatal(err) + } + testSymlinkStats(t, filelink, false) + testSymlinkSameFile(t, file, filelink) + + linklink := filepath.Join(tmpdir, "linklink") + err = os.Symlink(filelink, linklink) + if err != nil { + t.Fatal(err) + } + testSymlinkStats(t, linklink, false) + testSymlinkSameFile(t, file, linklink) +} + +// see issue 27225 for details +func TestSymlinkWithTrailingSlash(t *testing.T) { + testenv.MustHaveSymlink(t) + + tmpdir, err := ioutil.TempDir("", "TestSymlinkWithTrailingSlash") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(tmpdir) + + dir := filepath.Join(tmpdir, "dir") + err = os.Mkdir(dir, 0777) + if err != nil { + t.Fatal(err) + } + dirlink := filepath.Join(tmpdir, "link") + err = os.Symlink(dir, dirlink) + if err != nil { + t.Fatal(err) + } + dirlinkWithSlash := dirlink + string(os.PathSeparator) + + if runtime.GOOS == "windows" { + testSymlinkStats(t, dirlinkWithSlash, true) + } else { + testDirStats(t, dirlinkWithSlash) + } + + fi1, err := os.Stat(dir) + if err != nil { + t.Error(err) + return + } + fi2, err := os.Stat(dirlinkWithSlash) + if err != nil { + t.Error(err) + return + } + if !os.SameFile(fi1, fi2) { + t.Errorf("os.Stat(%q) and os.Stat(%q) are not the same file", dir, dirlinkWithSlash) + } +} diff --git a/libgo/go/os/sticky_bsd.go b/libgo/go/os/sticky_bsd.go index 6b54c758c70..ae2744f8175 100644 --- a/libgo/go/os/sticky_bsd.go +++ b/libgo/go/os/sticky_bsd.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd netbsd openbsd solaris +// +build aix darwin dragonfly freebsd netbsd openbsd solaris package os diff --git a/libgo/go/os/sticky_notbsd.go b/libgo/go/os/sticky_notbsd.go index 834e79b0b59..edb5f69bf05 100644 --- a/libgo/go/os/sticky_notbsd.go +++ b/libgo/go/os/sticky_notbsd.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build !aix // +build !darwin // +build !dragonfly // +build !freebsd diff --git a/libgo/go/os/sys_aix.go b/libgo/go/os/sys_aix.go new file mode 100644 index 00000000000..53a40f26772 --- /dev/null +++ b/libgo/go/os/sys_aix.go @@ -0,0 +1,26 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package os + +import "syscall" + +// gethostname syscall cannot be used because it also returns the domain. +// Therefore, hostname is retrieve with uname syscall and the Nodename field. + +func hostname() (name string, err error) { + var u syscall.Utsname + if errno := syscall.Uname(&u); errno != nil { + return "", NewSyscallError("uname", errno) + } + b := make([]byte, len(u.Nodename)) + i := 0 + for ; i < len(u.Nodename); i++ { + if u.Nodename[i] == 0 { + break + } + b[i] = byte(u.Nodename[i]) + } + return string(b[:i]), nil +} diff --git a/libgo/go/os/types.go b/libgo/go/os/types.go index b0b7d8d94d6..4b6c084838b 100644 --- a/libgo/go/os/types.go +++ b/libgo/go/os/types.go @@ -57,7 +57,7 @@ const ( ModeIrregular // ?: non-regular file; nothing else is known about this file // Mask for the type bits. For regular files, none will be set. - ModeType = ModeDir | ModeSymlink | ModeNamedPipe | ModeSocket | ModeDevice | ModeIrregular + ModeType = ModeDir | ModeSymlink | ModeNamedPipe | ModeSocket | ModeDevice | ModeCharDevice | ModeIrregular ModePerm FileMode = 0777 // Unix permission bits ) diff --git a/libgo/go/os/types_windows.go b/libgo/go/os/types_windows.go index f3297c03385..5e33292bec6 100644 --- a/libgo/go/os/types_windows.go +++ b/libgo/go/os/types_windows.go @@ -47,6 +47,21 @@ func newFileStatFromGetFileInformationByHandle(path string, h syscall.Handle) (f if err != nil { return nil, &PathError{"GetFileInformationByHandle", path, err} } + + var ti windows.FILE_ATTRIBUTE_TAG_INFO + err = windows.GetFileInformationByHandleEx(h, windows.FileAttributeTagInfo, (*byte)(unsafe.Pointer(&ti)), uint32(unsafe.Sizeof(ti))) + if err != nil { + if errno, ok := err.(syscall.Errno); ok && errno == windows.ERROR_INVALID_PARAMETER { + // It appears calling GetFileInformationByHandleEx with + // FILE_ATTRIBUTE_TAG_INFO fails on FAT file system with + // ERROR_INVALID_PARAMETER. Clear ti.ReparseTag in that + // instance to indicate no symlinks are possible. + ti.ReparseTag = 0 + } else { + return nil, &PathError{"GetFileInformationByHandleEx", path, err} + } + } + return &fileStat{ name: basename(path), FileAttributes: d.FileAttributes, @@ -58,6 +73,7 @@ func newFileStatFromGetFileInformationByHandle(path string, h syscall.Handle) (f vol: d.VolumeSerialNumber, idxhi: d.FileIndexHigh, idxlo: d.FileIndexLow, + Reserved0: ti.ReparseTag, // fileStat.path is used by os.SameFile to decide if it needs // to fetch vol, idxhi and idxlo. But these are already set, // so set fileStat.path to "" to prevent os.SameFile doing it again. @@ -78,67 +94,6 @@ func newFileStatFromWin32finddata(d *syscall.Win32finddata) *fileStat { } } -// newFileStatFromGetFileAttributesExOrFindFirstFile calls GetFileAttributesEx -// and FindFirstFile to gather all required information about the provided file path pathp. -func newFileStatFromGetFileAttributesExOrFindFirstFile(path string, pathp *uint16) (*fileStat, error) { - // As suggested by Microsoft, use GetFileAttributes() to acquire the file information, - // and if it's a reparse point use FindFirstFile() to get the tag: - // https://msdn.microsoft.com/en-us/library/windows/desktop/aa363940(v=vs.85).aspx - // Notice that always calling FindFirstFile can create performance problems - // (https://golang.org/issues/19922#issuecomment-300031421) - var fa syscall.Win32FileAttributeData - err := syscall.GetFileAttributesEx(pathp, syscall.GetFileExInfoStandard, (*byte)(unsafe.Pointer(&fa))) - if err == nil && fa.FileAttributes&syscall.FILE_ATTRIBUTE_REPARSE_POINT == 0 { - // Not a symlink. - return &fileStat{ - FileAttributes: fa.FileAttributes, - CreationTime: fa.CreationTime, - LastAccessTime: fa.LastAccessTime, - LastWriteTime: fa.LastWriteTime, - FileSizeHigh: fa.FileSizeHigh, - FileSizeLow: fa.FileSizeLow, - }, nil - } - // GetFileAttributesEx returns ERROR_INVALID_NAME if called - // for invalid file name like "*.txt". Do not attempt to call - // FindFirstFile with "*.txt", because FindFirstFile will - // succeed. So just return ERROR_INVALID_NAME instead. - // see https://golang.org/issue/24999 for details. - if errno, _ := err.(syscall.Errno); errno == windows.ERROR_INVALID_NAME { - return nil, &PathError{"GetFileAttributesEx", path, err} - } - // We might have symlink here. But some directories also have - // FileAttributes FILE_ATTRIBUTE_REPARSE_POINT bit set. - // For example, OneDrive directory is like that - // (see golang.org/issue/22579 for details). - // So use FindFirstFile instead to distinguish directories like - // OneDrive from real symlinks (see instructions described at - // https://blogs.msdn.microsoft.com/oldnewthing/20100212-00/?p=14963/ - // and in particular bits about using both FileAttributes and - // Reserved0 fields). - var fd syscall.Win32finddata - sh, err := syscall.FindFirstFile(pathp, &fd) - if err != nil { - return nil, &PathError{"FindFirstFile", path, err} - } - syscall.FindClose(sh) - - return newFileStatFromWin32finddata(&fd), nil -} - -func (fs *fileStat) updatePathAndName(name string) error { - fs.path = name - if !isAbs(fs.path) { - var err error - fs.path, err = syscall.FullPath(fs.path) - if err != nil { - return &PathError{"FullPath", name, err} - } - } - fs.name = basename(name) - return nil -} - func (fs *fileStat) isSymlink() bool { // Use instructions described at // https://blogs.msdn.microsoft.com/oldnewthing/20100212-00/?p=14963/ @@ -211,7 +166,13 @@ func (fs *fileStat) loadFileId() error { if err != nil { return err } - h, err := syscall.CreateFile(pathp, 0, 0, nil, syscall.OPEN_EXISTING, syscall.FILE_FLAG_BACKUP_SEMANTICS, 0) + attrs := uint32(syscall.FILE_FLAG_BACKUP_SEMANTICS) + if fs.isSymlink() { + // Use FILE_FLAG_OPEN_REPARSE_POINT, otherwise CreateFile will follow symlink. + // See https://docs.microsoft.com/en-us/windows/desktop/FileIO/symbolic-link-effects-on-file-systems-functions#createfile-and-createfiletransacted + attrs |= syscall.FILE_FLAG_OPEN_REPARSE_POINT + } + h, err := syscall.CreateFile(pathp, 0, 0, nil, syscall.OPEN_EXISTING, attrs, 0) if err != nil { return err } diff --git a/libgo/go/os/user/lookup.go b/libgo/go/os/user/lookup.go index 2243a25788a..b36b7c01c0b 100644 --- a/libgo/go/os/user/lookup.go +++ b/libgo/go/os/user/lookup.go @@ -7,6 +7,10 @@ package user import "sync" // Current returns the current user. +// +// The first call will cache the current user information. +// Subsequent calls will return the cached value and will not reflect +// changes to the current user. func Current() (*User, error) { cache.Do(func() { cache.u, cache.err = current() }) if cache.err != nil { diff --git a/libgo/go/os/user/lookup_stubs.go b/libgo/go/os/user/lookup_stubs.go index f7d138ff468..61bf1dc7a6f 100644 --- a/libgo/go/os/user/lookup_stubs.go +++ b/libgo/go/os/user/lookup_stubs.go @@ -19,8 +19,15 @@ func init() { } func current() (*User, error) { - u := &User{ - Uid: currentUID(), + uid := currentUID() + // $USER and /etc/passwd may disagree; prefer the latter if we can get it. + // See issue 27524 for more information. + u, err := lookupUserId(uid) + if err == nil { + return u, nil + } + u = &User{ + Uid: uid, Gid: currentGID(), Username: os.Getenv("USER"), Name: "", // ignored @@ -58,8 +65,8 @@ func current() (*User, error) { } func listGroups(*User) ([]string, error) { - if runtime.GOOS == "android" { - return nil, errors.New("user: GroupIds not implemented on Android") + if runtime.GOOS == "android" || runtime.GOOS == "aix" { + return nil, errors.New(fmt.Sprintf("user: GroupIds not implemented on %s", runtime.GOOS)) } return nil, errors.New("user: GroupIds requires cgo") } diff --git a/libgo/go/os/user/lookup_unix.go b/libgo/go/os/user/lookup_unix.go index c4e9ba1e818..be62f4d0c3e 100644 --- a/libgo/go/os/user/lookup_unix.go +++ b/libgo/go/os/user/lookup_unix.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd js,wasm !android,linux nacl netbsd openbsd solaris +// +build aix darwin dragonfly freebsd js,wasm !android,linux nacl netbsd openbsd solaris // +build !cgo osusergo package user diff --git a/libgo/go/os/user/lookup_unix_test.go b/libgo/go/os/user/lookup_unix_test.go index 02c88ab8757..65fe0656de6 100644 --- a/libgo/go/os/user/lookup_unix_test.go +++ b/libgo/go/os/user/lookup_unix_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd !android,linux nacl netbsd openbsd solaris +// +build aix darwin dragonfly freebsd !android,linux nacl netbsd openbsd solaris // +build !cgo package user diff --git a/libgo/go/os/user/user.go b/libgo/go/os/user/user.go index 1f733b80235..c1b8101c862 100644 --- a/libgo/go/os/user/user.go +++ b/libgo/go/os/user/user.go @@ -11,7 +11,7 @@ parses /etc/passwd and /etc/group. The other is cgo-based and relies on the standard C library (libc) routines such as getpwuid_r and getgrnam_r. When cgo is available, cgo-based (libc-backed) code is used by default. -This can be overriden by using osusergo build tag, which enforces +This can be overridden by using osusergo build tag, which enforces the pure Go implementation. */ package user diff --git a/libgo/go/os/user/user_test.go b/libgo/go/os/user/user_test.go index 8fd760e6498..2563077eb2e 100644 --- a/libgo/go/os/user/user_test.go +++ b/libgo/go/os/user/user_test.go @@ -5,33 +5,18 @@ package user import ( - "internal/testenv" - "os" "runtime" "testing" ) func checkUser(t *testing.T) { + t.Helper() if !userImplemented { t.Skip("user: not implemented; skipping tests") } } func TestCurrent(t *testing.T) { - // The Go builders (in particular the ones using containers) - // often have minimal environments without $HOME or $USER set, - // which breaks Current which relies on those working as a - // fallback. - // TODO: we should fix that (Issue 24884) and remove these - // workarounds. - if testenv.Builder() != "" && runtime.GOOS != "windows" && runtime.GOOS != "plan9" { - if os.Getenv("HOME") == "" { - os.Setenv("HOME", "/tmp") - } - if os.Getenv("USER") == "" { - os.Setenv("USER", "gobuilder") - } - } u, err := Current() if err != nil { t.Fatalf("Current: %v (got %#v)", err, u) @@ -108,6 +93,7 @@ func TestLookupId(t *testing.T) { } func checkGroup(t *testing.T) { + t.Helper() if !groupImplemented { t.Skip("user: group not implemented; skipping test") } diff --git a/libgo/go/os/wait_unimp.go b/libgo/go/os/wait_unimp.go index d0706046001..469abf76401 100644 --- a/libgo/go/os/wait_unimp.go +++ b/libgo/go/os/wait_unimp.go @@ -7,7 +7,7 @@ package os // blockUntilWaitable attempts to block until a call to p.Wait will -// succeed immediately, and returns whether it has done so. +// succeed immediately, and reports whether it has done so. // It does not actually call p.Wait. // This version is used on systems that do not implement waitid, // or where we have not implemented it yet. diff --git a/libgo/go/os/wait_wait6.go b/libgo/go/os/wait_wait6.go index 891f242dacd..45bf649015f 100644 --- a/libgo/go/os/wait_wait6.go +++ b/libgo/go/os/wait_wait6.go @@ -14,7 +14,7 @@ import ( const _P_PID = 0 // blockUntilWaitable attempts to block until a call to p.Wait will -// succeed immediately, and returns whether it has done so. +// succeed immediately, and reports whether it has done so. // It does not actually call p.Wait. func (p *Process) blockUntilWaitable() (bool, error) { var errno syscall.Errno diff --git a/libgo/go/os/wait_waitid.go b/libgo/go/os/wait_waitid.go index a6284aad98a..4bb77f9c542 100644 --- a/libgo/go/os/wait_waitid.go +++ b/libgo/go/os/wait_waitid.go @@ -18,7 +18,7 @@ import ( const _P_PID = 1 // blockUntilWaitable attempts to block until a call to p.Wait will -// succeed immediately, and returns whether it has done so. +// succeed immediately, and reports whether it has done so. // It does not actually call p.Wait. func (p *Process) blockUntilWaitable() (bool, error) { // The waitid system call expects a pointer to a siginfo_t, diff --git a/libgo/go/path/filepath/example_unix_test.go b/libgo/go/path/filepath/example_unix_test.go index cd8233ceb6a..20ec8927b46 100644 --- a/libgo/go/path/filepath/example_unix_test.go +++ b/libgo/go/path/filepath/example_unix_test.go @@ -79,3 +79,18 @@ func ExampleJoin() { // a/b/c // a/b/c } + +func ExampleMatch() { + fmt.Println("On Unix:") + fmt.Println(filepath.Match("/home/catch/*", "/home/catch/foo")) + fmt.Println(filepath.Match("/home/catch/*", "/home/catch/foo/bar")) + fmt.Println(filepath.Match("/home/?opher", "/home/gopher")) + fmt.Println(filepath.Match("/home/\\*", "/home/*")) + + // Output: + // On Unix: + // true + // false + // true + // true +} diff --git a/libgo/go/path/filepath/match_test.go b/libgo/go/path/filepath/match_test.go index b73d6d26b48..70db3596fec 100644 --- a/libgo/go/path/filepath/match_test.go +++ b/libgo/go/path/filepath/match_test.go @@ -106,7 +106,7 @@ func TestMatch(t *testing.T) { } } -// contains returns true if vector contains the string s. +// contains reports whether vector contains the string s. func contains(vector []string, s string) bool { for _, elem := range vector { if elem == s { diff --git a/libgo/go/path/filepath/path.go b/libgo/go/path/filepath/path.go index 1508137a33d..bbb90306a7f 100644 --- a/libgo/go/path/filepath/path.go +++ b/libgo/go/path/filepath/path.go @@ -96,14 +96,19 @@ func Clean(path string) string { } return originalPath + "." } + + n := len(path) + if volLen > 2 && n == 1 && os.IsPathSeparator(path[0]) { + // UNC volume name with trailing slash. + return FromSlash(originalPath[:volLen]) + } rooted := os.IsPathSeparator(path[0]) // Invariants: // reading from path; r is index of next byte to process. - // writing to buf; w is index of next byte to write. - // dotdot is index in buf where .. must stop, either because + // writing to out; w is index of next byte to write. + // dotdot is index in out where .. must stop, either because // it is the leading slash or it is a leading ../../.. prefix. - n := len(path) out := lazybuf{path: path, volAndPath: originalPath, volLen: volLen} r, dotdot := 0, 0 if rooted { @@ -166,7 +171,7 @@ func ToSlash(path string) string { if Separator == '/' { return path } - return strings.Replace(path, string(Separator), "/", -1) + return strings.ReplaceAll(path, string(Separator), "/") } // FromSlash returns the result of replacing each slash ('/') character @@ -176,7 +181,7 @@ func FromSlash(path string) string { if Separator == '/' { return path } - return strings.Replace(path, "/", string(Separator), -1) + return strings.ReplaceAll(path, "/", string(Separator)) } // SplitList splits a list of paths joined by the OS-specific ListSeparator, diff --git a/libgo/go/path/filepath/path_test.go b/libgo/go/path/filepath/path_test.go index 5983a9406af..4840f9db068 100644 --- a/libgo/go/path/filepath/path_test.go +++ b/libgo/go/path/filepath/path_test.go @@ -15,6 +15,7 @@ import ( "runtime" "sort" "strings" + "syscall" "testing" ) @@ -92,6 +93,9 @@ var wincleantests = []PathTest{ {`//host/share/foo/../baz`, `\\host\share\baz`}, {`\\a\b\..\c`, `\\a\b\c`}, {`\\a\b`, `\\a\b`}, + {`\\a\b\`, `\\a\b`}, + {`\\folder\share\foo`, `\\folder\share\foo`}, + {`\\folder\share\foo\`, `\\folder\share\foo`}, } func TestClean(t *testing.T) { @@ -274,6 +278,10 @@ var winjointests = []JoinTest{ {[]string{`C:`, `a`}, `C:a`}, {[]string{`C:`, `a\b`}, `C:a\b`}, {[]string{`C:`, `a`, `b`}, `C:a\b`}, + {[]string{`C:`, ``, `b`}, `C:b`}, + {[]string{`C:`, ``, ``, `b`}, `C:b`}, + {[]string{`C:`, ``}, `C:.`}, + {[]string{`C:`, ``, ``}, `C:.`}, {[]string{`C:.`, `a`}, `C:a`}, {[]string{`C:a`, `b`}, `C:a\b`}, {[]string{`C:a`, `b`, `d`}, `C:a\b\d`}, @@ -747,6 +755,11 @@ func TestIsAbs(t *testing.T) { for _, test := range isabstests { tests = append(tests, IsAbsTest{"c:" + test.path, test.isAbs}) } + // Test reserved names. + tests = append(tests, IsAbsTest{os.DevNull, true}) + tests = append(tests, IsAbsTest{"NUL", true}) + tests = append(tests, IsAbsTest{"nul", true}) + tests = append(tests, IsAbsTest{"CON", true}) } else { tests = isabstests } @@ -770,6 +783,18 @@ var EvalSymlinksTestDirs = []EvalSymlinksTest{ {"test/link1", "../test"}, {"test/link2", "dir"}, {"test/linkabs", "/"}, + {"test/link4", "../test2"}, + {"test2", "test/dir"}, + // Issue 23444. + {"src", ""}, + {"src/pool", ""}, + {"src/pool/test", ""}, + {"src/versions", ""}, + {"src/versions/current", "../../version"}, + {"src/versions/v1", ""}, + {"src/versions/v1/modules", ""}, + {"src/versions/v1/modules/test", "../../../pool/test"}, + {"version", "src/versions/v1"}, } var EvalSymlinksTests = []EvalSymlinksTest{ @@ -783,6 +808,8 @@ var EvalSymlinksTests = []EvalSymlinksTest{ {"test/dir/link3", "."}, {"test/link2/link3/test", "test"}, {"test/linkabs", "/"}, + {"test/link4/..", "test"}, + {"src/versions/current/modules/test", "src/pool/test"}, } // simpleJoin builds a file name from the directory and path. @@ -1047,7 +1074,7 @@ func TestAbs(t *testing.T) { } for _, path := range absTests { - path = strings.Replace(path, "$", root, -1) + path = strings.ReplaceAll(path, "$", root) info, err := os.Stat(path) if err != nil { t.Errorf("%s: %s", path, err) @@ -1349,3 +1376,30 @@ func TestWalkSymlink(t *testing.T) { testenv.MustHaveSymlink(t) testWalkSymlink(t, os.Symlink) } + +func TestIssue29372(t *testing.T) { + f, err := ioutil.TempFile("", "issue29372") + if err != nil { + t.Fatal(err) + } + f.Close() + path := f.Name() + defer os.Remove(path) + + pathSeparator := string(filepath.Separator) + tests := []string{ + path + strings.Repeat(pathSeparator, 1), + path + strings.Repeat(pathSeparator, 2), + path + strings.Repeat(pathSeparator, 1) + ".", + path + strings.Repeat(pathSeparator, 2) + ".", + path + strings.Repeat(pathSeparator, 1) + "..", + path + strings.Repeat(pathSeparator, 2) + "..", + } + + for i, test := range tests { + _, err = filepath.EvalSymlinks(test) + if err != syscall.ENOTDIR { + t.Fatalf("test#%d: want %q, got %q", i, syscall.ENOTDIR, err) + } + } +} diff --git a/libgo/go/path/filepath/path_windows.go b/libgo/go/path/filepath/path_windows.go index 409e8d6466a..445c868e414 100644 --- a/libgo/go/path/filepath/path_windows.go +++ b/libgo/go/path/filepath/path_windows.go @@ -13,8 +13,34 @@ func isSlash(c uint8) bool { return c == '\\' || c == '/' } +// reservedNames lists reserved Windows names. Search for PRN in +// https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file +// for details. +var reservedNames = []string{ + "CON", "PRN", "AUX", "NUL", + "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", + "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9", +} + +// isReservedName returns true, if path is Windows reserved name. +// See reservedNames for the full list. +func isReservedName(path string) bool { + if len(path) == 0 { + return false + } + for _, reserved := range reservedNames { + if strings.EqualFold(path, reserved) { + return true + } + } + return false +} + // IsAbs reports whether the path is absolute. func IsAbs(path string) (b bool) { + if isReservedName(path) { + return true + } l := volumeNameLen(path) if l == 0 { return false @@ -100,7 +126,7 @@ func splitList(path string) []string { // Remove quotes. for i, s := range list { - list[i] = strings.Replace(s, `"`, ``, -1) + list[i] = strings.ReplaceAll(s, `"`, ``) } return list @@ -134,7 +160,14 @@ func joinNonEmpty(elem []string) string { if len(elem[0]) == 2 && elem[0][1] == ':' { // First element is drive letter without terminating slash. // Keep path relative to current directory on that drive. - return Clean(elem[0] + strings.Join(elem[1:], string(Separator))) + // Skip empty elements. + i := 1 + for ; i < len(elem); i++ { + if elem[i] != "" { + break + } + } + return Clean(elem[0] + strings.Join(elem[i:], string(Separator))) } // The following logic prevents Join from inadvertently creating a // UNC path on Windows. Unless the first element is a UNC path, Join diff --git a/libgo/go/path/filepath/symlink.go b/libgo/go/path/filepath/symlink.go index 824aee4e490..4b41039e25f 100644 --- a/libgo/go/path/filepath/symlink.go +++ b/libgo/go/path/filepath/symlink.go @@ -10,109 +10,128 @@ import ( "runtime" ) -// isRoot returns true if path is root of file system -// (`/` on unix and `/`, `\`, `c:\` or `c:/` on windows). -func isRoot(path string) bool { - if runtime.GOOS != "windows" { - return path == "/" - } - switch len(path) { - case 1: - return os.IsPathSeparator(path[0]) - case 3: - return path[1] == ':' && os.IsPathSeparator(path[2]) - } - return false -} +func walkSymlinks(path string) (string, error) { + volLen := volumeNameLen(path) + pathSeparator := string(os.PathSeparator) -// isDriveLetter returns true if path is Windows drive letter (like "c:"). -func isDriveLetter(path string) bool { - if runtime.GOOS != "windows" { - return false + if volLen < len(path) && os.IsPathSeparator(path[volLen]) { + volLen++ } - return len(path) == 2 && path[1] == ':' -} + vol := path[:volLen] + dest := vol + linksWalked := 0 + for start, end := volLen, volLen; start < len(path); start = end { + for start < len(path) && os.IsPathSeparator(path[start]) { + start++ + } + end = start + for end < len(path) && !os.IsPathSeparator(path[end]) { + end++ + } -func walkLink(path string, linksWalked *int) (newpath string, islink bool, err error) { - if *linksWalked > 255 { - return "", false, errors.New("EvalSymlinks: too many links") - } - fi, err := os.Lstat(path) - if err != nil { - return "", false, err - } - if fi.Mode()&os.ModeSymlink == 0 { - return path, false, nil - } - newpath, err = os.Readlink(path) - if err != nil { - return "", false, err - } - *linksWalked++ - return newpath, true, nil -} + // On Windows, "." can be a symlink. + // We look it up, and use the value if it is absolute. + // If not, we just return ".". + isWindowsDot := runtime.GOOS == "windows" && path[volumeNameLen(path):] == "." -func walkLinks(path string, linksWalked *int) (string, error) { - switch dir, file := Split(path); { - case dir == "": - newpath, _, err := walkLink(file, linksWalked) - return newpath, err - case file == "": - if isDriveLetter(dir) { - return dir, nil - } - if os.IsPathSeparator(dir[len(dir)-1]) { - if isRoot(dir) { - return dir, nil + // The next path component is in path[start:end]. + if end == start { + // No more path components. + break + } else if path[start:end] == "." && !isWindowsDot { + // Ignore path component ".". + continue + } else if path[start:end] == ".." { + // Back up to previous component if possible. + // Note that volLen includes any leading slash. + var r int + for r = len(dest) - 1; r >= volLen; r-- { + if os.IsPathSeparator(dest[r]) { + break + } + } + if r < volLen { + if len(dest) > volLen { + dest += pathSeparator + } + dest += ".." + } else { + dest = dest[:r] } - return walkLinks(dir[:len(dir)-1], linksWalked) + continue } - newpath, _, err := walkLink(dir, linksWalked) - return newpath, err - default: - newdir, err := walkLinks(dir, linksWalked) - if err != nil { - return "", err + + // Ordinary path component. Add it to result. + + if len(dest) > volumeNameLen(dest) && !os.IsPathSeparator(dest[len(dest)-1]) { + dest += pathSeparator } - newpath, islink, err := walkLink(Join(newdir, file), linksWalked) + + dest += path[start:end] + + // Resolve symlink. + + fi, err := os.Lstat(dest) if err != nil { return "", err } - if !islink { - return newpath, nil + + if fi.Mode()&os.ModeSymlink == 0 { + if !fi.Mode().IsDir() && end < len(path) { + return "", slashAfterFilePathError + } + continue } - if IsAbs(newpath) || os.IsPathSeparator(newpath[0]) { - return newpath, nil + + // Found symlink. + + linksWalked++ + if linksWalked > 255 { + return "", errors.New("EvalSymlinks: too many links") } - return Join(newdir, newpath), nil - } -} -func walkSymlinks(path string) (string, error) { - if path == "" { - return path, nil - } - var linksWalked int // to protect against cycles - for { - i := linksWalked - newpath, err := walkLinks(path, &linksWalked) + link, err := os.Readlink(dest) if err != nil { return "", err } - if runtime.GOOS == "windows" { - // walkLinks(".", ...) always returns "." on unix. - // But on windows it returns symlink target, if current - // directory is a symlink. Stop the walk, if symlink - // target is not absolute path, and return "." - // to the caller (just like unix does). - // Same for "C:.". - if path[volumeNameLen(path):] == "." && !IsAbs(newpath) { - return path, nil - } + + if isWindowsDot && !IsAbs(link) { + // On Windows, if "." is a relative symlink, + // just return ".". + break } - if i == linksWalked { - return Clean(newpath), nil + + path = link + path[end:] + + v := volumeNameLen(link) + if v > 0 { + // Symlink to drive name is an absolute path. + if v < len(link) && os.IsPathSeparator(link[v]) { + v++ + } + vol = link[:v] + dest = vol + end = len(vol) + } else if len(link) > 0 && os.IsPathSeparator(link[0]) { + // Symlink to absolute path. + dest = link[:1] + end = 1 + } else { + // Symlink to relative path; replace last + // path component in dest. + var r int + for r = len(dest) - 1; r >= volLen; r-- { + if os.IsPathSeparator(dest[r]) { + break + } + } + if r < volLen { + dest = vol + } else { + dest = dest[:r] + } + end = 0 } - path = newpath } + return Clean(dest), nil } diff --git a/libgo/go/path/filepath/symlink_unix.go b/libgo/go/path/filepath/symlink_unix.go index d20e63a987e..b57e7f2277e 100644 --- a/libgo/go/path/filepath/symlink_unix.go +++ b/libgo/go/path/filepath/symlink_unix.go @@ -2,6 +2,15 @@ package filepath +import ( + "syscall" +) + +// walkSymlinks returns slashAfterFilePathError error for paths like +// //path/to/existing_file/ and /path/to/existing_file/. and /path/to/existing_file/.. + +var slashAfterFilePathError = syscall.ENOTDIR + func evalSymlinks(path string) (string, error) { return walkSymlinks(path) } diff --git a/libgo/go/path/filepath/symlink_windows.go b/libgo/go/path/filepath/symlink_windows.go index 78cde4aa090..531dc26fc0e 100644 --- a/libgo/go/path/filepath/symlink_windows.go +++ b/libgo/go/path/filepath/symlink_windows.go @@ -43,7 +43,7 @@ func normBase(path string) (string, error) { return syscall.UTF16ToString(data.FileName[:]), nil } -// baseIsDotDot returns whether the last element of path is "..". +// baseIsDotDot reports whether the last element of path is "..". // The given path should be 'Clean'-ed in advance. func baseIsDotDot(path string) bool { i := strings.LastIndexByte(path, Separator) @@ -171,8 +171,16 @@ func samefile(path1, path2 string) bool { return os.SameFile(fi1, fi2) } +// walkSymlinks returns slashAfterFilePathError error for paths like +// //path/to/existing_file/ and /path/to/existing_file/. and /path/to/existing_file/.. + +var slashAfterFilePathError = errors.New("attempting to walk past file path.") + func evalSymlinks(path string) (string, error) { newpath, err := walkSymlinks(path) + if err == slashAfterFilePathError { + return "", syscall.ENOTDIR + } if err != nil { newpath2, err2 := evalSymlinksUsingGetFinalPathNameByHandle(path) if err2 == nil { diff --git a/libgo/go/plugin/plugin_dlopen.go b/libgo/go/plugin/plugin_dlopen.go index 47f2b29a80b..f24093989fd 100644 --- a/libgo/go/plugin/plugin_dlopen.go +++ b/libgo/go/plugin/plugin_dlopen.go @@ -39,16 +39,6 @@ import ( "unsafe" ) -// avoid a dependency on strings -func lastIndexByte(s string, c byte) int { - for i := len(s) - 1; i >= 0; i-- { - if s[i] == c { - return i - } - } - return -1 -} - func open(name string) (*Plugin, error) { cPath := make([]byte, C.PATH_MAX+1) cRelName := make([]byte, len(name)+1) diff --git a/libgo/go/plugin/plugin_test.go b/libgo/go/plugin/plugin_test.go new file mode 100644 index 00000000000..b334c5cf0ec --- /dev/null +++ b/libgo/go/plugin/plugin_test.go @@ -0,0 +1,18 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !nacl +// +build !linux linux,!arm64 + +package plugin_test + +import ( + _ "plugin" + "testing" +) + +func TestPlugin(t *testing.T) { + // This test makes sure that executable that imports plugin + // package can actually run. See issue #28789 for details. +} diff --git a/libgo/go/reflect/all_test.go b/libgo/go/reflect/all_test.go index 472988fe856..599ab272e79 100644 --- a/libgo/go/reflect/all_test.go +++ b/libgo/go/reflect/all_test.go @@ -1009,6 +1009,7 @@ func TestIsNil(t *testing.T) { struct{ x func() bool }{}, struct{ x chan int }{}, struct{ x []string }{}, + struct{ x unsafe.Pointer }{}, } for _, ts := range doNil { ty := TypeOf(ts).Field(0).Type @@ -1696,9 +1697,9 @@ func TestCallReturnsEmpty(t *testing.T) { // nonzero-sized frame and zero-sized return value. runtime.GC() var finalized uint32 - f := func() (emptyStruct, *int) { - i := new(int) - runtime.SetFinalizer(i, func(*int) { atomic.StoreUint32(&finalized, 1) }) + f := func() (emptyStruct, *[2]int64) { + i := new([2]int64) // big enough to not be tinyalloc'd, so finalizer always runs when i dies + runtime.SetFinalizer(i, func(*[2]int64) { atomic.StoreUint32(&finalized, 1) }) return emptyStruct{}, i } v := ValueOf(f).Call(nil)[0] // out[0] should not alias out[1]'s memory, so the finalizer should run. @@ -5039,6 +5040,21 @@ func TestStructOfWithInterface(t *testing.T) { } */ +func TestStructOfTooManyFields(t *testing.T) { + if runtime.Compiler == "gccgo" { + t.Skip("gccgo does not yet implement embedded fields with methods") + } + + // Bug Fix: #25402 - this should not panic + tt := StructOf([]StructField{ + {Name: "Time", Type: TypeOf(time.Time{}), Anonymous: true}, + }) + + if _, present := tt.MethodByName("After"); !present { + t.Errorf("Expected method `After` to be found") + } +} + func TestChanOf(t *testing.T) { // check construction and use of type not in binary type T string @@ -6009,7 +6025,8 @@ func TestFuncLayout(t *testing.T) { func verifyGCBits(t *testing.T, typ Type, bits []byte) { heapBits := GCBits(New(typ).Interface()) if !bytes.Equal(heapBits, bits) { - t.Errorf("heapBits incorrect for %v\nhave %v\nwant %v", typ, heapBits, bits) + _, _, line, _ := runtime.Caller(1) + t.Errorf("line %d: heapBits incorrect for %v\nhave %v\nwant %v", line, typ, heapBits, bits) } } @@ -6610,3 +6627,124 @@ func TestIssue22073(t *testing.T) { // Shouldn't panic. m.Call(nil) } + +func TestMapIterNonEmptyMap(t *testing.T) { + m := map[string]int{"one": 1, "two": 2, "three": 3} + iter := ValueOf(m).MapRange() + if got, want := iterateToString(iter), `[one: 1, three: 3, two: 2]`; got != want { + t.Errorf("iterator returned %s (after sorting), want %s", got, want) + } +} + +func TestMapIterNilMap(t *testing.T) { + var m map[string]int + iter := ValueOf(m).MapRange() + if got, want := iterateToString(iter), `[]`; got != want { + t.Errorf("non-empty result iteratoring nil map: %s", got) + } +} + +func TestMapIterSafety(t *testing.T) { + // Using a zero MapIter causes a panic, but not a crash. + func() { + defer func() { recover() }() + new(MapIter).Key() + t.Fatal("Key did not panic") + }() + func() { + defer func() { recover() }() + new(MapIter).Value() + t.Fatal("Value did not panic") + }() + func() { + defer func() { recover() }() + new(MapIter).Next() + t.Fatal("Next did not panic") + }() + + // Calling Key/Value on a MapIter before Next + // causes a panic, but not a crash. + var m map[string]int + iter := ValueOf(m).MapRange() + + func() { + defer func() { recover() }() + iter.Key() + t.Fatal("Key did not panic") + }() + func() { + defer func() { recover() }() + iter.Value() + t.Fatal("Value did not panic") + }() + + // Calling Next, Key, or Value on an exhausted iterator + // causes a panic, but not a crash. + iter.Next() // -> false + func() { + defer func() { recover() }() + iter.Key() + t.Fatal("Key did not panic") + }() + func() { + defer func() { recover() }() + iter.Value() + t.Fatal("Value did not panic") + }() + func() { + defer func() { recover() }() + iter.Next() + t.Fatal("Next did not panic") + }() +} + +func TestMapIterNext(t *testing.T) { + // The first call to Next should reflect any + // insertions to the map since the iterator was created. + m := map[string]int{} + iter := ValueOf(m).MapRange() + m["one"] = 1 + if got, want := iterateToString(iter), `[one: 1]`; got != want { + t.Errorf("iterator returned deleted elements: got %s, want %s", got, want) + } +} + +func TestMapIterDelete0(t *testing.T) { + // Delete all elements before first iteration. + m := map[string]int{"one": 1, "two": 2, "three": 3} + iter := ValueOf(m).MapRange() + delete(m, "one") + delete(m, "two") + delete(m, "three") + if got, want := iterateToString(iter), `[]`; got != want { + t.Errorf("iterator returned deleted elements: got %s, want %s", got, want) + } +} + +func TestMapIterDelete1(t *testing.T) { + // Delete all elements after first iteration. + m := map[string]int{"one": 1, "two": 2, "three": 3} + iter := ValueOf(m).MapRange() + var got []string + for iter.Next() { + got = append(got, fmt.Sprint(iter.Key(), iter.Value())) + delete(m, "one") + delete(m, "two") + delete(m, "three") + } + if len(got) != 1 { + t.Errorf("iterator returned wrong number of elements: got %d, want 1", len(got)) + } +} + +// iterateToString returns the set of elements +// returned by an iterator in readable form. +func iterateToString(it *MapIter) string { + var got []string + for it.Next() { + line := fmt.Sprintf("%v: %v", it.Key(), it.Value()) + got = append(got, line) + } + sort.Strings(got) + return "[" + strings.Join(got, ", ") + "]" +} diff --git a/libgo/go/reflect/example_test.go b/libgo/go/reflect/example_test.go index f959b958463..23c08e49500 100644 --- a/libgo/go/reflect/example_test.go +++ b/libgo/go/reflect/example_test.go @@ -13,6 +13,24 @@ import ( "reflect" ) +func ExampleKind() { + for _, v := range []interface{}{"hi", 42, func() {}} { + switch v := reflect.ValueOf(v); v.Kind() { + case reflect.String: + fmt.Println(v.String()) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + fmt.Println(v.Int()) + default: + fmt.Printf("unhandled kind %s", v.Kind()) + } + } + + // Output: + // hi + // 42 + // unhandled kind func +} + func ExampleMakeFunc() { // swap is the implementation passed to MakeFunc. // It must work in terms of reflect.Values so that it is possible diff --git a/libgo/go/reflect/type.go b/libgo/go/reflect/type.go index e4a9326d083..ea97b7d93fb 100644 --- a/libgo/go/reflect/type.go +++ b/libgo/go/reflect/type.go @@ -419,6 +419,7 @@ const ( kindMask = (1 << 5) - 1 ) +// String returns the name of k. func (k Kind) String() string { if int(k) < len(kindNames) { return kindNames[k] @@ -1904,7 +1905,7 @@ var structLookupCache struct { m sync.Map } -// isLetter returns true if a given 'rune' is classified as a Letter. +// isLetter reports whether a given 'rune' is classified as a Letter. func isLetter(ch rune) bool { return 'a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z' || ch == '_' || ch >= utf8.RuneSelf && unicode.IsLetter(ch) } diff --git a/libgo/go/reflect/value.go b/libgo/go/reflect/value.go index 9f05744f8d1..d3a6243f95d 100644 --- a/libgo/go/reflect/value.go +++ b/libgo/go/reflect/value.go @@ -851,7 +851,7 @@ func (v Value) InterfaceData() [2]uintptr { func (v Value) IsNil() bool { k := v.kind() switch k { - case Chan, Func, Map, Ptr: + case Chan, Func, Map, Ptr, UnsafePointer: if v.flag&flagMethod != 0 { return false } @@ -935,14 +935,7 @@ func (v Value) MapIndex(key Value) Value { typ := tt.elem fl := (v.flag | key.flag).ro() fl |= flag(typ.Kind()) - if !ifaceIndir(typ) { - return Value{typ, *(*unsafe.Pointer)(e), fl} - } - // Copy result so future changes to the map - // won't change the underlying value. - c := unsafe_New(typ) - typedmemmove(typ, c, e) - return Value{typ, c, fl | flagIndir} + return copyVal(typ, fl, e) } // MapKeys returns a slice containing all the keys present in the map, @@ -972,20 +965,96 @@ func (v Value) MapKeys() []Value { // we can do about it. break } - if ifaceIndir(keyType) { - // Copy result so future changes to the map - // won't change the underlying value. - c := unsafe_New(keyType) - typedmemmove(keyType, c, key) - a[i] = Value{keyType, c, fl | flagIndir} - } else { - a[i] = Value{keyType, *(*unsafe.Pointer)(key), fl} - } + a[i] = copyVal(keyType, fl, key) mapiternext(it) } return a[:i] } +// A MapIter is an iterator for ranging over a map. +// See Value.MapRange. +type MapIter struct { + m Value + it unsafe.Pointer +} + +// Key returns the key of the iterator's current map entry. +func (it *MapIter) Key() Value { + if it.it == nil { + panic("MapIter.Key called before Next") + } + if mapiterkey(it.it) == nil { + panic("MapIter.Key called on exhausted iterator") + } + + t := (*mapType)(unsafe.Pointer(it.m.typ)) + ktype := t.key + return copyVal(ktype, it.m.flag.ro()|flag(ktype.Kind()), mapiterkey(it.it)) +} + +// Value returns the value of the iterator's current map entry. +func (it *MapIter) Value() Value { + if it.it == nil { + panic("MapIter.Value called before Next") + } + if mapiterkey(it.it) == nil { + panic("MapIter.Value called on exhausted iterator") + } + + t := (*mapType)(unsafe.Pointer(it.m.typ)) + vtype := t.elem + return copyVal(vtype, it.m.flag.ro()|flag(vtype.Kind()), mapitervalue(it.it)) +} + +// Next advances the map iterator and reports whether there is another +// entry. It returns false when the iterator is exhausted; subsequent +// calls to Key, Value, or Next will panic. +func (it *MapIter) Next() bool { + if it.it == nil { + it.it = mapiterinit(it.m.typ, it.m.pointer()) + } else { + if mapiterkey(it.it) == nil { + panic("MapIter.Next called on exhausted iterator") + } + mapiternext(it.it) + } + return mapiterkey(it.it) != nil +} + +// MapRange returns a range iterator for a map. +// It panics if v's Kind is not Map. +// +// Call Next to advance the iterator, and Key/Value to access each entry. +// Next returns false when the iterator is exhausted. +// MapRange follows the same iteration semantics as a range statement. +// +// Example: +// +// iter := reflect.ValueOf(m).MapRange() +// for iter.Next() { +// k := iter.Key() +// v := iter.Value() +// ... +// } +// +func (v Value) MapRange() *MapIter { + v.mustBe(Map) + return &MapIter{m: v} +} + +// copyVal returns a Value containing the map key or value at ptr, +// allocating a new variable as needed. +func copyVal(typ *rtype, fl flag, ptr unsafe.Pointer) Value { + if ifaceIndir(typ) { + // Copy result so future changes to the map + // won't change the underlying value. + c := unsafe_New(typ) + typedmemmove(typ, c, ptr) + return Value{typ, c, fl | flagIndir} + } + return Value{typ, *(*unsafe.Pointer)(ptr), fl} +} + // Method returns a function value corresponding to v's i'th method. // The arguments to a Call on the returned function should not include // a receiver; the returned function will always use v as the receiver. @@ -2394,11 +2463,16 @@ func mapiterinit(t *rtype, m unsafe.Pointer) unsafe.Pointer //go:noescape func mapiterkey(it unsafe.Pointer) (key unsafe.Pointer) +//go:noescape +func mapitervalue(it unsafe.Pointer) (value unsafe.Pointer) + //go:noescape func mapiternext(it unsafe.Pointer) //go:noescape func maplen(m unsafe.Pointer) int + +//go:linkname call runtime.reflectcall func call(typ *funcType, fnaddr unsafe.Pointer, isInterface bool, isMethod bool, params *unsafe.Pointer, results *unsafe.Pointer) func ifaceE2I(t *rtype, src interface{}, dst unsafe.Pointer) diff --git a/libgo/go/regexp/all_test.go b/libgo/go/regexp/all_test.go index 0fabeae59fc..623f82df72d 100644 --- a/libgo/go/regexp/all_test.go +++ b/libgo/go/regexp/all_test.go @@ -550,8 +550,8 @@ func TestOnePassCutoff(t *testing.T) { if err != nil { t.Fatalf("compile: %v", err) } - if compileOnePass(p) != notOnePass { - t.Fatalf("makeOnePass succeeded; wanted notOnePass") + if compileOnePass(p) != nil { + t.Fatalf("makeOnePass succeeded; wanted nil") } } @@ -859,3 +859,26 @@ func BenchmarkQuoteMetaNone(b *testing.B) { sink = QuoteMeta(s) } } + +func TestDeepEqual(t *testing.T) { + re1 := MustCompile("a.*b.*c.*d") + re2 := MustCompile("a.*b.*c.*d") + if !reflect.DeepEqual(re1, re2) { // has always been true, since Go 1. + t.Errorf("DeepEqual(re1, re2) = false, want true") + } + + re1.MatchString("abcdefghijklmn") + if !reflect.DeepEqual(re1, re2) { + t.Errorf("DeepEqual(re1, re2) = false, want true") + } + + re2.MatchString("abcdefghijklmn") + if !reflect.DeepEqual(re1, re2) { + t.Errorf("DeepEqual(re1, re2) = false, want true") + } + + re2.MatchString(strings.Repeat("abcdefghijklmn", 100)) + if !reflect.DeepEqual(re1, re2) { + t.Errorf("DeepEqual(re1, re2) = false, want true") + } +} diff --git a/libgo/go/regexp/backtrack.go b/libgo/go/regexp/backtrack.go index 440bf7ffc59..9fb7d1e4937 100644 --- a/libgo/go/regexp/backtrack.go +++ b/libgo/go/regexp/backtrack.go @@ -14,7 +14,10 @@ package regexp -import "regexp/syntax" +import ( + "regexp/syntax" + "sync" +) // A job is an entry on the backtracker's job stack. It holds // the instruction pc and the position in the input. @@ -32,15 +35,29 @@ const ( // bitState holds state for the backtracker. type bitState struct { - prog *syntax.Prog + end int + cap []int + matchcap []int + jobs []job + visited []uint32 + + inputs inputs +} + +var bitStatePool sync.Pool - end int - cap []int - jobs []job - visited []uint32 +func newBitState() *bitState { + b, ok := bitStatePool.Get().(*bitState) + if !ok { + b = new(bitState) + } + return b } -var notBacktrack *bitState = nil +func freeBitState(b *bitState) { + b.inputs.clear() + bitStatePool.Put(b) +} // maxBitStateLen returns the maximum length of a string to search with // the backtracker using prog. @@ -51,18 +68,6 @@ func maxBitStateLen(prog *syntax.Prog) int { return maxBacktrackVector / len(prog.Inst) } -// newBitState returns a new bitState for the given prog, -// or notBacktrack if the size of the prog exceeds the maximum size that -// the backtracker will be run for. -func newBitState(prog *syntax.Prog) *bitState { - if !shouldBacktrack(prog) { - return notBacktrack - } - return &bitState{ - prog: prog, - } -} - // shouldBacktrack reports whether the program is too // long for the backtracker to run. func shouldBacktrack(prog *syntax.Prog) bool { @@ -72,7 +77,7 @@ func shouldBacktrack(prog *syntax.Prog) bool { // reset resets the state of the backtracker. // end is the end position in the input. // ncap is the number of captures. -func (b *bitState) reset(end int, ncap int) { +func (b *bitState) reset(prog *syntax.Prog, end int, ncap int) { b.end = end if cap(b.jobs) == 0 { @@ -81,7 +86,7 @@ func (b *bitState) reset(end int, ncap int) { b.jobs = b.jobs[:0] } - visitedSize := (len(b.prog.Inst)*(end+1) + visitedBits - 1) / visitedBits + visitedSize := (len(prog.Inst)*(end+1) + visitedBits - 1) / visitedBits if cap(b.visited) < visitedSize { b.visited = make([]uint32, visitedSize, maxBacktrackVector/visitedBits) } else { @@ -99,6 +104,15 @@ func (b *bitState) reset(end int, ncap int) { for i := range b.cap { b.cap[i] = -1 } + + if cap(b.matchcap) < ncap { + b.matchcap = make([]int, ncap) + } else { + b.matchcap = b.matchcap[:ncap] + } + for i := range b.matchcap { + b.matchcap[i] = -1 + } } // shouldVisit reports whether the combination of (pc, pos) has not @@ -114,20 +128,19 @@ func (b *bitState) shouldVisit(pc uint32, pos int) bool { // push pushes (pc, pos, arg) onto the job stack if it should be // visited. -func (b *bitState) push(pc uint32, pos int, arg bool) { +func (b *bitState) push(re *Regexp, pc uint32, pos int, arg bool) { // Only check shouldVisit when arg is false. // When arg is true, we are continuing a previous visit. - if b.prog.Inst[pc].Op != syntax.InstFail && (arg || b.shouldVisit(pc, pos)) { + if re.prog.Inst[pc].Op != syntax.InstFail && (arg || b.shouldVisit(pc, pos)) { b.jobs = append(b.jobs, job{pc: pc, arg: arg, pos: pos}) } } // tryBacktrack runs a backtracking search starting at pos. -func (m *machine) tryBacktrack(b *bitState, i input, pc uint32, pos int) bool { - longest := m.re.longest - m.matched = false +func (re *Regexp) tryBacktrack(b *bitState, i input, pc uint32, pos int) bool { + longest := re.longest - b.push(pc, pos, false) + b.push(re, pc, pos, false) for len(b.jobs) > 0 { l := len(b.jobs) - 1 // Pop job off the stack. @@ -150,7 +163,7 @@ func (m *machine) tryBacktrack(b *bitState, i input, pc uint32, pos int) bool { } Skip: - inst := b.prog.Inst[pc] + inst := re.prog.Inst[pc] switch inst.Op { default: @@ -172,23 +185,23 @@ func (m *machine) tryBacktrack(b *bitState, i input, pc uint32, pos int) bool { pc = inst.Arg goto CheckAndLoop } else { - b.push(pc, pos, true) + b.push(re, pc, pos, true) pc = inst.Out goto CheckAndLoop } case syntax.InstAltMatch: // One opcode consumes runes; the other leads to match. - switch b.prog.Inst[inst.Out].Op { + switch re.prog.Inst[inst.Out].Op { case syntax.InstRune, syntax.InstRune1, syntax.InstRuneAny, syntax.InstRuneAnyNotNL: // inst.Arg is the match. - b.push(inst.Arg, pos, false) + b.push(re, inst.Arg, pos, false) pc = inst.Arg pos = b.end goto CheckAndLoop } // inst.Out is the match - non-greedy - b.push(inst.Out, b.end, false) + b.push(re, inst.Out, b.end, false) pc = inst.Out goto CheckAndLoop @@ -236,7 +249,7 @@ func (m *machine) tryBacktrack(b *bitState, i input, pc uint32, pos int) bool { } else { if 0 <= inst.Arg && inst.Arg < uint32(len(b.cap)) { // Capture pos to register, but save old value. - b.push(pc, b.cap[inst.Arg], true) // come back when we're done. + b.push(re, pc, b.cap[inst.Arg], true) // come back when we're done. b.cap[inst.Arg] = pos } pc = inst.Out @@ -244,7 +257,8 @@ func (m *machine) tryBacktrack(b *bitState, i input, pc uint32, pos int) bool { } case syntax.InstEmptyWidth: - if syntax.EmptyOp(inst.Arg)&^i.context(pos) != 0 { + flag := i.context(pos) + if !flag.match(syntax.EmptyOp(inst.Arg)) { continue } pc = inst.Out @@ -258,8 +272,7 @@ func (m *machine) tryBacktrack(b *bitState, i input, pc uint32, pos int) bool { // We found a match. If the caller doesn't care // where the match is, no point going further. if len(b.cap) == 0 { - m.matched = true - return m.matched + return true } // Record best match so far. @@ -268,19 +281,18 @@ func (m *machine) tryBacktrack(b *bitState, i input, pc uint32, pos int) bool { if len(b.cap) > 1 { b.cap[1] = pos } - if !m.matched || (longest && pos > 0 && pos > m.matchcap[1]) { - copy(m.matchcap, b.cap) + if old := b.matchcap[1]; old == -1 || (longest && pos > 0 && pos > old) { + copy(b.matchcap, b.cap) } - m.matched = true // If going for first match, we're done. if !longest { - return m.matched + return true } // If we used the entire text, no longer match is possible. if pos == b.end { - return m.matched + return true } // Otherwise, continue on in hope of a longer match. @@ -288,65 +300,68 @@ func (m *machine) tryBacktrack(b *bitState, i input, pc uint32, pos int) bool { } } - return m.matched + return longest && len(b.matchcap) > 1 && b.matchcap[1] >= 0 } // backtrack runs a backtracking search of prog on the input starting at pos. -func (m *machine) backtrack(i input, pos int, end int, ncap int) bool { - if !i.canCheckPrefix() { - panic("backtrack called for a RuneReader") - } - - startCond := m.re.cond +func (re *Regexp) backtrack(ib []byte, is string, pos int, ncap int, dstCap []int) []int { + startCond := re.cond if startCond == ^syntax.EmptyOp(0) { // impossible - return false + return nil } if startCond&syntax.EmptyBeginText != 0 && pos != 0 { // Anchored match, past beginning of text. - return false + return nil } - b := m.b - b.reset(end, ncap) - - m.matchcap = m.matchcap[:ncap] - for i := range m.matchcap { - m.matchcap[i] = -1 - } + b := newBitState() + i, end := b.inputs.init(nil, ib, is) + b.reset(re.prog, end, ncap) // Anchored search must start at the beginning of the input if startCond&syntax.EmptyBeginText != 0 { if len(b.cap) > 0 { b.cap[0] = pos } - return m.tryBacktrack(b, i, uint32(m.p.Start), pos) - } + if !re.tryBacktrack(b, i, uint32(re.prog.Start), pos) { + freeBitState(b) + return nil + } + } else { - // Unanchored search, starting from each possible text position. - // Notice that we have to try the empty string at the end of - // the text, so the loop condition is pos <= end, not pos < end. - // This looks like it's quadratic in the size of the text, - // but we are not clearing visited between calls to TrySearch, - // so no work is duplicated and it ends up still being linear. - width := -1 - for ; pos <= end && width != 0; pos += width { - if len(m.re.prefix) > 0 { - // Match requires literal prefix; fast search for it. - advance := i.index(m.re, pos) - if advance < 0 { - return false + // Unanchored search, starting from each possible text position. + // Notice that we have to try the empty string at the end of + // the text, so the loop condition is pos <= end, not pos < end. + // This looks like it's quadratic in the size of the text, + // but we are not clearing visited between calls to TrySearch, + // so no work is duplicated and it ends up still being linear. + width := -1 + for ; pos <= end && width != 0; pos += width { + if len(re.prefix) > 0 { + // Match requires literal prefix; fast search for it. + advance := i.index(re, pos) + if advance < 0 { + freeBitState(b) + return nil + } + pos += advance } - pos += advance - } - if len(b.cap) > 0 { - b.cap[0] = pos - } - if m.tryBacktrack(b, i, uint32(m.p.Start), pos) { - // Match must be leftmost; done. - return true + if len(b.cap) > 0 { + b.cap[0] = pos + } + if re.tryBacktrack(b, i, uint32(re.prog.Start), pos) { + // Match must be leftmost; done. + goto Match + } + _, width = i.step(pos) } - _, width = i.step(pos) + freeBitState(b) + return nil } - return false + +Match: + dstCap = append(dstCap, b.matchcap...) + freeBitState(b) + return dstCap } diff --git a/libgo/go/regexp/exec.go b/libgo/go/regexp/exec.go index 1c7b02d1cd8..efe764e2dca 100644 --- a/libgo/go/regexp/exec.go +++ b/libgo/go/regexp/exec.go @@ -7,6 +7,7 @@ package regexp import ( "io" "regexp/syntax" + "sync" ) // A queue is a 'sparse array' holding pending threads of execution. @@ -35,54 +36,60 @@ type thread struct { // A machine holds all the state during an NFA simulation for p. type machine struct { - re *Regexp // corresponding Regexp - p *syntax.Prog // compiled program - op *onePassProg // compiled onepass program, or notOnePass - maxBitStateLen int // max length of string to search with bitstate - b *bitState // state for backtracker, allocated lazily - q0, q1 queue // two queues for runq, nextq - pool []*thread // pool of available threads - matched bool // whether a match was found - matchcap []int // capture information for the match + re *Regexp // corresponding Regexp + p *syntax.Prog // compiled program + q0, q1 queue // two queues for runq, nextq + pool []*thread // pool of available threads + matched bool // whether a match was found + matchcap []int // capture information for the match + inputs inputs +} + +type inputs struct { // cached inputs, to avoid allocation - inputBytes inputBytes - inputString inputString - inputReader inputReader + bytes inputBytes + string inputString + reader inputReader } -func (m *machine) newInputBytes(b []byte) input { - m.inputBytes.str = b - return &m.inputBytes +func (i *inputs) newBytes(b []byte) input { + i.bytes.str = b + return &i.bytes } -func (m *machine) newInputString(s string) input { - m.inputString.str = s - return &m.inputString +func (i *inputs) newString(s string) input { + i.string.str = s + return &i.string } -func (m *machine) newInputReader(r io.RuneReader) input { - m.inputReader.r = r - m.inputReader.atEOT = false - m.inputReader.pos = 0 - return &m.inputReader +func (i *inputs) newReader(r io.RuneReader) input { + i.reader.r = r + i.reader.atEOT = false + i.reader.pos = 0 + return &i.reader +} + +func (i *inputs) clear() { + // We need to clear 1 of these. + // Avoid the expense of clearing the others (pointer write barrier). + if i.bytes.str != nil { + i.bytes.str = nil + } else if i.reader.r != nil { + i.reader.r = nil + } else { + i.string.str = "" + } } -// progMachine returns a new machine running the prog p. -func progMachine(p *syntax.Prog, op *onePassProg) *machine { - m := &machine{p: p, op: op} - n := len(m.p.Inst) - m.q0 = queue{make([]uint32, n), make([]entry, 0, n)} - m.q1 = queue{make([]uint32, n), make([]entry, 0, n)} - ncap := p.NumCap - if ncap < 2 { - ncap = 2 +func (i *inputs) init(r io.RuneReader, b []byte, s string) (input, int) { + if r != nil { + return i.newReader(r), 0 } - if op == notOnePass { - m.maxBitStateLen = maxBitStateLen(p) + if b != nil { + return i.newBytes(b), len(b) } - m.matchcap = make([]int, ncap) - return m + return i.newString(s), len(s) } func (m *machine) init(ncap int) { @@ -107,6 +114,61 @@ func (m *machine) alloc(i *syntax.Inst) *thread { return t } +// A lazyFlag is a lazily-evaluated syntax.EmptyOp, +// for checking zero-width flags like ^ $ \A \z \B \b. +// It records the pair of relevant runes and does not +// determine the implied flags until absolutely necessary +// (most of the time, that means never). +type lazyFlag uint64 + +func newLazyFlag(r1, r2 rune) lazyFlag { + return lazyFlag(uint64(r1)<<32 | uint64(uint32(r2))) +} + +func (f lazyFlag) match(op syntax.EmptyOp) bool { + if op == 0 { + return true + } + r1 := rune(f >> 32) + if op&syntax.EmptyBeginLine != 0 { + if r1 != '\n' && r1 >= 0 { + return false + } + op &^= syntax.EmptyBeginLine + } + if op&syntax.EmptyBeginText != 0 { + if r1 >= 0 { + return false + } + op &^= syntax.EmptyBeginText + } + if op == 0 { + return true + } + r2 := rune(f) + if op&syntax.EmptyEndLine != 0 { + if r2 != '\n' && r2 >= 0 { + return false + } + op &^= syntax.EmptyEndLine + } + if op&syntax.EmptyEndText != 0 { + if r2 >= 0 { + return false + } + op &^= syntax.EmptyEndText + } + if op == 0 { + return true + } + if syntax.IsWordChar(r1) != syntax.IsWordChar(r2) { + op &^= syntax.EmptyWordBoundary + } else { + op &^= syntax.EmptyNoWordBoundary + } + return op == 0 +} + // match runs the machine over the input starting at pos. // It reports whether a match was found. // If so, m.matchcap holds the submatch information. @@ -126,9 +188,9 @@ func (m *machine) match(i input, pos int) bool { if r != endOfText { r1, width1 = i.step(pos + width) } - var flag syntax.EmptyOp + var flag lazyFlag if pos == 0 { - flag = syntax.EmptyOpContext(-1, r) + flag = newLazyFlag(-1, r) } else { flag = i.context(pos) } @@ -157,10 +219,10 @@ func (m *machine) match(i input, pos int) bool { if len(m.matchcap) > 0 { m.matchcap[0] = pos } - m.add(runq, uint32(m.p.Start), pos, m.matchcap, flag, nil) + m.add(runq, uint32(m.p.Start), pos, m.matchcap, &flag, nil) } - flag = syntax.EmptyOpContext(r, r1) - m.step(runq, nextq, pos, pos+width, r, flag) + flag = newLazyFlag(r, r1) + m.step(runq, nextq, pos, pos+width, r, &flag) if width == 0 { break } @@ -195,7 +257,7 @@ func (m *machine) clear(q *queue) { // The step processes the rune c (which may be endOfText), // which starts at position pos and ends at nextPos. // nextCond gives the setting for the empty-width flags after c. -func (m *machine) step(runq, nextq *queue, pos, nextPos int, c rune, nextCond syntax.EmptyOp) { +func (m *machine) step(runq, nextq *queue, pos, nextPos int, c rune, nextCond *lazyFlag) { longest := m.re.longest for j := 0; j < len(runq.dense); j++ { d := &runq.dense[j] @@ -252,7 +314,8 @@ func (m *machine) step(runq, nextq *queue, pos, nextPos int, c rune, nextCond sy // It also recursively adds an entry for all instructions reachable from pc by following // empty-width conditions satisfied by cond. pos gives the current position // in the input. -func (m *machine) add(q *queue, pc uint32, pos int, cap []int, cond syntax.EmptyOp, t *thread) *thread { +func (m *machine) add(q *queue, pc uint32, pos int, cap []int, cond *lazyFlag, t *thread) *thread { +Again: if pc == 0 { return t } @@ -275,13 +338,16 @@ func (m *machine) add(q *queue, pc uint32, pos int, cap []int, cond syntax.Empty // nothing case syntax.InstAlt, syntax.InstAltMatch: t = m.add(q, i.Out, pos, cap, cond, t) - t = m.add(q, i.Arg, pos, cap, cond, t) + pc = i.Arg + goto Again case syntax.InstEmptyWidth: - if syntax.EmptyOp(i.Arg)&^cond == 0 { - t = m.add(q, i.Out, pos, cap, cond, t) + if cond.match(syntax.EmptyOp(i.Arg)) { + pc = i.Out + goto Again } case syntax.InstNop: - t = m.add(q, i.Out, pos, cap, cond, t) + pc = i.Out + goto Again case syntax.InstCapture: if int(i.Arg) < len(cap) { opos := cap[i.Arg] @@ -289,7 +355,8 @@ func (m *machine) add(q *queue, pc uint32, pos int, cap []int, cond syntax.Empty m.add(q, i.Out, pos, cap, cond, nil) cap[i.Arg] = opos } else { - t = m.add(q, i.Out, pos, cap, cond, t) + pc = i.Out + goto Again } case syntax.InstMatch, syntax.InstRune, syntax.InstRune1, syntax.InstRuneAny, syntax.InstRuneAnyNotNL: if t == nil { @@ -306,85 +373,112 @@ func (m *machine) add(q *queue, pc uint32, pos int, cap []int, cond syntax.Empty return t } -// onepass runs the machine over the input starting at pos. -// It reports whether a match was found. -// If so, m.matchcap holds the submatch information. -// ncap is the number of captures. -func (m *machine) onepass(i input, pos, ncap int) bool { - startCond := m.re.cond +type onePassMachine struct { + inputs inputs + matchcap []int +} + +var onePassPool sync.Pool + +func newOnePassMachine() *onePassMachine { + m, ok := onePassPool.Get().(*onePassMachine) + if !ok { + m = new(onePassMachine) + } + return m +} + +func freeOnePassMachine(m *onePassMachine) { + m.inputs.clear() + onePassPool.Put(m) +} + +// doOnePass implements r.doExecute using the one-pass execution engine. +func (re *Regexp) doOnePass(ir io.RuneReader, ib []byte, is string, pos, ncap int, dstCap []int) []int { + startCond := re.cond if startCond == ^syntax.EmptyOp(0) { // impossible - return false + return nil } - m.matched = false - m.matchcap = m.matchcap[:ncap] + + m := newOnePassMachine() + if cap(m.matchcap) < ncap { + m.matchcap = make([]int, ncap) + } else { + m.matchcap = m.matchcap[:ncap] + } + + matched := false for i := range m.matchcap { m.matchcap[i] = -1 } + + i, _ := m.inputs.init(ir, ib, is) + r, r1 := endOfText, endOfText width, width1 := 0, 0 r, width = i.step(pos) if r != endOfText { r1, width1 = i.step(pos + width) } - var flag syntax.EmptyOp + var flag lazyFlag if pos == 0 { - flag = syntax.EmptyOpContext(-1, r) + flag = newLazyFlag(-1, r) } else { flag = i.context(pos) } - pc := m.op.Start - inst := m.op.Inst[pc] + pc := re.onepass.Start + inst := re.onepass.Inst[pc] // If there is a simple literal prefix, skip over it. - if pos == 0 && syntax.EmptyOp(inst.Arg)&^flag == 0 && - len(m.re.prefix) > 0 && i.canCheckPrefix() { + if pos == 0 && flag.match(syntax.EmptyOp(inst.Arg)) && + len(re.prefix) > 0 && i.canCheckPrefix() { // Match requires literal prefix; fast search for it. - if !i.hasPrefix(m.re) { - return m.matched + if !i.hasPrefix(re) { + goto Return } - pos += len(m.re.prefix) + pos += len(re.prefix) r, width = i.step(pos) r1, width1 = i.step(pos + width) flag = i.context(pos) - pc = int(m.re.prefixEnd) + pc = int(re.prefixEnd) } for { - inst = m.op.Inst[pc] + inst = re.onepass.Inst[pc] pc = int(inst.Out) switch inst.Op { default: panic("bad inst") case syntax.InstMatch: - m.matched = true + matched = true if len(m.matchcap) > 0 { m.matchcap[0] = 0 m.matchcap[1] = pos } - return m.matched + goto Return case syntax.InstRune: if !inst.MatchRune(r) { - return m.matched + goto Return } case syntax.InstRune1: if r != inst.Rune[0] { - return m.matched + goto Return } case syntax.InstRuneAny: // Nothing case syntax.InstRuneAnyNotNL: if r == '\n' { - return m.matched + goto Return } // peek at the input rune to see which branch of the Alt to take case syntax.InstAlt, syntax.InstAltMatch: pc = int(onePassNext(&inst, r)) continue case syntax.InstFail: - return m.matched + goto Return case syntax.InstNop: continue case syntax.InstEmptyWidth: - if syntax.EmptyOp(inst.Arg)&^flag != 0 { - return m.matched + if !flag.match(syntax.EmptyOp(inst.Arg)) { + goto Return } continue case syntax.InstCapture: @@ -396,14 +490,23 @@ func (m *machine) onepass(i input, pos, ncap int) bool { if width == 0 { break } - flag = syntax.EmptyOpContext(r, r1) + flag = newLazyFlag(r, r1) pos += width r, width = r1, width1 if r != endOfText { r1, width1 = i.step(pos + width) } } - return m.matched + +Return: + if !matched { + freeOnePassMachine(m) + return nil + } + + dstCap = append(dstCap, m.matchcap...) + freeOnePassMachine(m) + return dstCap } // doMatch reports whether either r, b or s match the regexp. @@ -416,43 +519,28 @@ func (re *Regexp) doMatch(r io.RuneReader, b []byte, s string) bool { // // nil is returned if no matches are found and non-nil if matches are found. func (re *Regexp) doExecute(r io.RuneReader, b []byte, s string, pos int, ncap int, dstCap []int) []int { - m := re.get() - var i input - var size int - if r != nil { - i = m.newInputReader(r) - } else if b != nil { - i = m.newInputBytes(b) - size = len(b) - } else { - i = m.newInputString(s) - size = len(s) + if dstCap == nil { + // Make sure 'return dstCap' is non-nil. + dstCap = arrayNoInts[:0:0] } - if m.op != notOnePass { - if !m.onepass(i, pos, ncap) { - re.put(m) - return nil - } - } else if size < m.maxBitStateLen && r == nil { - if m.b == nil { - m.b = newBitState(m.p) - } - if !m.backtrack(i, pos, size, ncap) { - re.put(m) - return nil - } - } else { - m.init(ncap) - if !m.match(i, pos) { - re.put(m) - return nil - } + + if re.onepass != nil { + return re.doOnePass(r, b, s, pos, ncap, dstCap) } - dstCap = append(dstCap, m.matchcap...) - if dstCap == nil { - // Keep the promise of returning non-nil value on match. - dstCap = arrayNoInts[:0] + if r == nil && len(b)+len(s) < re.maxBitStateLen { + return re.backtrack(b, s, pos, ncap, dstCap) } + + m := re.get() + i, _ := m.inputs.init(r, b, s) + + m.init(ncap) + if !m.match(i, pos) { + re.put(m) + return nil + } + + dstCap = append(dstCap, m.matchcap...) re.put(m) return dstCap } diff --git a/libgo/go/regexp/exec_test.go b/libgo/go/regexp/exec_test.go index 5f8e747b17b..14892193289 100644 --- a/libgo/go/regexp/exec_test.go +++ b/libgo/go/regexp/exec_test.go @@ -684,7 +684,7 @@ func BenchmarkMatch(b *testing.B) { func BenchmarkMatch_onepass_regex(b *testing.B) { isRaceBuilder := strings.HasSuffix(testenv.Builder(), "-race") r := MustCompile(`(?s)\A.*\z`) - if r.get().op == notOnePass { + if r.onepass == nil { b.Fatalf("want onepass regex, but %q is not onepass", r) } for _, size := range benchSizes { @@ -692,18 +692,12 @@ func BenchmarkMatch_onepass_regex(b *testing.B) { continue } t := makeText(size.n) - bs := make([][]byte, len(t)) - for i, s := range t { - bs[i] = []byte{s} - } b.Run(size.name, func(b *testing.B) { b.SetBytes(int64(size.n)) b.ReportAllocs() for i := 0; i < b.N; i++ { - for _, byts := range bs { - if !r.Match(byts) { - b.Fatal("not match!") - } + if !r.Match(t) { + b.Fatal("not match!") } } }) diff --git a/libgo/go/regexp/onepass.go b/libgo/go/regexp/onepass.go index 125be59a7d8..2f3ce6f9f6c 100644 --- a/libgo/go/regexp/onepass.go +++ b/libgo/go/regexp/onepass.go @@ -294,12 +294,12 @@ var anyRune = []rune{0, unicode.MaxRune} // makeOnePass creates a onepass Prog, if possible. It is possible if at any alt, // the match engine can always tell which branch to take. The routine may modify // p if it is turned into a onepass Prog. If it isn't possible for this to be a -// onepass Prog, the Prog notOnePass is returned. makeOnePass is recursive +// onepass Prog, the Prog nil is returned. makeOnePass is recursive // to the size of the Prog. func makeOnePass(p *onePassProg) *onePassProg { // If the machine is very long, it's not worth the time to check if we can use one pass. if len(p.Inst) >= 1000 { - return notOnePass + return nil } var ( @@ -446,11 +446,11 @@ func makeOnePass(p *onePassProg) *onePassProg { visitQueue.clear() pc := instQueue.next() if !check(pc, m) { - p = notOnePass + p = nil break } } - if p != notOnePass { + if p != nil { for i := range p.Inst { p.Inst[i].Rune = onePassRunes[i] } @@ -458,20 +458,18 @@ func makeOnePass(p *onePassProg) *onePassProg { return p } -var notOnePass *onePassProg = nil - // compileOnePass returns a new *syntax.Prog suitable for onePass execution if the original Prog -// can be recharacterized as a one-pass regexp program, or syntax.notOnePass if the +// can be recharacterized as a one-pass regexp program, or syntax.nil if the // Prog cannot be converted. For a one pass prog, the fundamental condition that must // be true is: at any InstAlt, there must be no ambiguity about what branch to take. func compileOnePass(prog *syntax.Prog) (p *onePassProg) { if prog.Start == 0 { - return notOnePass + return nil } // onepass regexp is anchored if prog.Inst[prog.Start].Op != syntax.InstEmptyWidth || syntax.EmptyOp(prog.Inst[prog.Start].Arg)&syntax.EmptyBeginText != syntax.EmptyBeginText { - return notOnePass + return nil } // every instruction leading to InstMatch must be EmptyEndText for _, inst := range prog.Inst { @@ -479,18 +477,18 @@ func compileOnePass(prog *syntax.Prog) (p *onePassProg) { switch inst.Op { default: if opOut == syntax.InstMatch { - return notOnePass + return nil } case syntax.InstAlt, syntax.InstAltMatch: if opOut == syntax.InstMatch || prog.Inst[inst.Arg].Op == syntax.InstMatch { - return notOnePass + return nil } case syntax.InstEmptyWidth: if opOut == syntax.InstMatch { if syntax.EmptyOp(inst.Arg)&syntax.EmptyEndText == syntax.EmptyEndText { continue } - return notOnePass + return nil } } } @@ -501,7 +499,7 @@ func compileOnePass(prog *syntax.Prog) (p *onePassProg) { // checkAmbiguity on InstAlts, build onepass Prog if possible p = makeOnePass(p) - if p != notOnePass { + if p != nil { cleanupOnePass(p, prog) } return p diff --git a/libgo/go/regexp/onepass_test.go b/libgo/go/regexp/onepass_test.go index b1caa445150..a0f2e390489 100644 --- a/libgo/go/regexp/onepass_test.go +++ b/libgo/go/regexp/onepass_test.go @@ -134,47 +134,45 @@ func TestMergeRuneSet(t *testing.T) { } } -var onePass = &onePassProg{} - var onePassTests = []struct { - re string - onePass *onePassProg + re string + isOnePass bool }{ - {`^(?:a|(?:a*))$`, notOnePass}, - {`^(?:(a)|(?:a*))$`, notOnePass}, - {`^(?:(?:(?:.(?:$))?))$`, onePass}, - {`^abcd$`, onePass}, - {`^(?:(?:a{0,})*?)$`, onePass}, - {`^(?:(?:a+)*)$`, onePass}, - {`^(?:(?:a|(?:aa)))$`, onePass}, - {`^(?:[^\s\S])$`, onePass}, - {`^(?:(?:a{3,4}){0,})$`, notOnePass}, - {`^(?:(?:(?:a*)+))$`, onePass}, - {`^[a-c]+$`, onePass}, - {`^[a-c]*$`, onePass}, - {`^(?:a*)$`, onePass}, - {`^(?:(?:aa)|a)$`, onePass}, - {`^[a-c]*`, notOnePass}, - {`^...$`, onePass}, - {`^(?:a|(?:aa))$`, onePass}, - {`^a((b))c$`, onePass}, - {`^a.[l-nA-Cg-j]?e$`, onePass}, - {`^a((b))$`, onePass}, - {`^a(?:(b)|(c))c$`, onePass}, - {`^a(?:(b*)|(c))c$`, notOnePass}, - {`^a(?:b|c)$`, onePass}, - {`^a(?:b?|c)$`, onePass}, - {`^a(?:b?|c?)$`, notOnePass}, - {`^a(?:b?|c+)$`, onePass}, - {`^a(?:b+|(bc))d$`, notOnePass}, - {`^a(?:bc)+$`, onePass}, - {`^a(?:[bcd])+$`, onePass}, - {`^a((?:[bcd])+)$`, onePass}, - {`^a(:?b|c)*d$`, onePass}, - {`^.bc(d|e)*$`, onePass}, - {`^(?:(?:aa)|.)$`, notOnePass}, - {`^(?:(?:a{1,2}){1,2})$`, notOnePass}, - {`^l` + strings.Repeat("o", 2<<8) + `ng$`, onePass}, + {`^(?:a|(?:a*))$`, false}, + {`^(?:(a)|(?:a*))$`, false}, + {`^(?:(?:(?:.(?:$))?))$`, true}, + {`^abcd$`, true}, + {`^(?:(?:a{0,})*?)$`, true}, + {`^(?:(?:a+)*)$`, true}, + {`^(?:(?:a|(?:aa)))$`, true}, + {`^(?:[^\s\S])$`, true}, + {`^(?:(?:a{3,4}){0,})$`, false}, + {`^(?:(?:(?:a*)+))$`, true}, + {`^[a-c]+$`, true}, + {`^[a-c]*$`, true}, + {`^(?:a*)$`, true}, + {`^(?:(?:aa)|a)$`, true}, + {`^[a-c]*`, false}, + {`^...$`, true}, + {`^(?:a|(?:aa))$`, true}, + {`^a((b))c$`, true}, + {`^a.[l-nA-Cg-j]?e$`, true}, + {`^a((b))$`, true}, + {`^a(?:(b)|(c))c$`, true}, + {`^a(?:(b*)|(c))c$`, false}, + {`^a(?:b|c)$`, true}, + {`^a(?:b?|c)$`, true}, + {`^a(?:b?|c?)$`, false}, + {`^a(?:b?|c+)$`, true}, + {`^a(?:b+|(bc))d$`, false}, + {`^a(?:bc)+$`, true}, + {`^a(?:[bcd])+$`, true}, + {`^a((?:[bcd])+)$`, true}, + {`^a(:?b|c)*d$`, true}, + {`^.bc(d|e)*$`, true}, + {`^(?:(?:aa)|.)$`, false}, + {`^(?:(?:a{1,2}){1,2})$`, false}, + {`^l` + strings.Repeat("o", 2<<8) + `ng$`, true}, } func TestCompileOnePass(t *testing.T) { @@ -194,9 +192,9 @@ func TestCompileOnePass(t *testing.T) { t.Errorf("Compile(%q) got err:%s, want success", test.re, err) continue } - onePass = compileOnePass(p) - if (onePass == notOnePass) != (test.onePass == notOnePass) { - t.Errorf("CompileOnePass(%q) got %v, expected %v", test.re, onePass, test.onePass) + isOnePass := compileOnePass(p) != nil + if isOnePass != test.isOnePass { + t.Errorf("CompileOnePass(%q) got isOnePass=%v, expected %v", test.re, isOnePass, test.isOnePass) } } } @@ -216,8 +214,8 @@ func TestRunOnePass(t *testing.T) { t.Errorf("Compile(%q): got err: %s", test.re, err) continue } - if re.onepass == notOnePass { - t.Errorf("Compile(%q): got notOnePass, want one-pass", test.re) + if re.onepass == nil { + t.Errorf("Compile(%q): got nil, want one-pass", test.re) continue } if !re.MatchString(test.match) { @@ -227,21 +225,11 @@ func TestRunOnePass(t *testing.T) { } func BenchmarkCompileOnepass(b *testing.B) { - for _, test := range onePassTests { - if test.onePass == notOnePass { - continue - } - name := test.re - if len(name) > 20 { - name = name[:20] + "..." + b.ReportAllocs() + const re = `^a.[l-nA-Cg-j]?e$` + for i := 0; i < b.N; i++ { + if _, err := Compile(re); err != nil { + b.Fatal(err) } - b.Run(name, func(b *testing.B) { - b.ReportAllocs() - for i := 0; i < b.N; i++ { - if _, err := Compile(test.re); err != nil { - b.Fatal(err) - } - } - }) } } diff --git a/libgo/go/regexp/regexp.go b/libgo/go/regexp/regexp.go index 61ed9c5059f..38b3c86d9f6 100644 --- a/libgo/go/regexp/regexp.go +++ b/libgo/go/regexp/regexp.go @@ -79,27 +79,24 @@ import ( // A Regexp is safe for concurrent use by multiple goroutines, // except for configuration methods, such as Longest. type Regexp struct { - // read-only after Compile - regexpRO - - // cache of machines for running regexp - mu sync.Mutex - machine []*machine -} - -type regexpRO struct { - expr string // as passed to Compile - prog *syntax.Prog // compiled program - onepass *onePassProg // onepass program or nil + expr string // as passed to Compile + prog *syntax.Prog // compiled program + onepass *onePassProg // onepass program or nil + numSubexp int + maxBitStateLen int + subexpNames []string prefix string // required prefix in unanchored matches prefixBytes []byte // prefix, as a []byte - prefixComplete bool // prefix is the entire regexp prefixRune rune // first rune in prefix prefixEnd uint32 // pc for last rune in prefix + mpool int // pool for machines + matchcap int // size of recorded match lengths + prefixComplete bool // prefix is the entire regexp cond syntax.EmptyOp // empty-width conditions required at start of match - numSubexp int - subexpNames []string - longest bool + + // This field can be modified by the Longest method, + // but it is otherwise read-only. + longest bool // whether regexp prefers leftmost-longest match } // String returns the source text used to compile the regular expression. @@ -108,15 +105,16 @@ func (re *Regexp) String() string { } // Copy returns a new Regexp object copied from re. +// Calling Longest on one copy does not affect another. // -// When using a Regexp in multiple goroutines, giving each goroutine -// its own copy helps to avoid lock contention. +// Deprecated: In earlier releases, when using a Regexp in multiple goroutines, +// giving each goroutine its own copy helped to avoid lock contention. +// As of Go 1.12, using Copy is no longer necessary to avoid lock contention. +// Copy may still be appropriate if the reason for its use is to make +// two copies with different Longest settings. func (re *Regexp) Copy() *Regexp { - // It is not safe to copy Regexp by value - // since it contains a sync.Mutex. - return &Regexp{ - regexpRO: re.regexpRO, - } + re2 := *re + return &re2 } // Compile parses a regular expression and returns, if successful, @@ -179,19 +177,23 @@ func compile(expr string, mode syntax.Flags, longest bool) (*Regexp, error) { if err != nil { return nil, err } + matchcap := prog.NumCap + if matchcap < 2 { + matchcap = 2 + } regexp := &Regexp{ - regexpRO: regexpRO{ - expr: expr, - prog: prog, - onepass: compileOnePass(prog), - numSubexp: maxCap, - subexpNames: capNames, - cond: prog.StartCond(), - longest: longest, - }, - } - if regexp.onepass == notOnePass { + expr: expr, + prog: prog, + onepass: compileOnePass(prog), + numSubexp: maxCap, + subexpNames: capNames, + cond: prog.StartCond(), + longest: longest, + matchcap: matchcap, + } + if regexp.onepass == nil { regexp.prefix, regexp.prefixComplete = prog.Prefix() + regexp.maxBitStateLen = maxBitStateLen(prog) } else { regexp.prefix, regexp.prefixComplete, regexp.prefixEnd = onePassPrefix(prog) } @@ -201,39 +203,64 @@ func compile(expr string, mode syntax.Flags, longest bool) (*Regexp, error) { regexp.prefixBytes = []byte(regexp.prefix) regexp.prefixRune, _ = utf8.DecodeRuneInString(regexp.prefix) } + + n := len(prog.Inst) + i := 0 + for matchSize[i] != 0 && matchSize[i] < n { + i++ + } + regexp.mpool = i + return regexp, nil } +// Pools of *machine for use during (*Regexp).doExecute, +// split up by the size of the execution queues. +// matchPool[i] machines have queue size matchSize[i]. +// On a 64-bit system each queue entry is 16 bytes, +// so matchPool[0] has 16*2*128 = 4kB queues, etc. +// The final matchPool is a catch-all for very large queues. +var ( + matchSize = [...]int{128, 512, 2048, 16384, 0} + matchPool [len(matchSize)]sync.Pool +) + // get returns a machine to use for matching re. // It uses the re's machine cache if possible, to avoid // unnecessary allocation. func (re *Regexp) get() *machine { - re.mu.Lock() - if n := len(re.machine); n > 0 { - z := re.machine[n-1] - re.machine = re.machine[:n-1] - re.mu.Unlock() - return z - } - re.mu.Unlock() - z := progMachine(re.prog, re.onepass) - z.re = re - return z -} - -// put returns a machine to the re's machine cache. -// There is no attempt to limit the size of the cache, so it will -// grow to the maximum number of simultaneous matches -// run using re. (The cache empties when re gets garbage collected.) -func (re *Regexp) put(z *machine) { - // Remove references to input data that we no longer need. - z.inputBytes.str = nil - z.inputString.str = "" - z.inputReader.r = nil - - re.mu.Lock() - re.machine = append(re.machine, z) - re.mu.Unlock() + m, ok := matchPool[re.mpool].Get().(*machine) + if !ok { + m = new(machine) + } + m.re = re + m.p = re.prog + if cap(m.matchcap) < re.matchcap { + m.matchcap = make([]int, re.matchcap) + for _, t := range m.pool { + t.cap = make([]int, re.matchcap) + } + } + + // Allocate queues if needed. + // Or reallocate, for "large" match pool. + n := matchSize[re.mpool] + if n == 0 { // large pool + n = len(re.prog.Inst) + } + if len(m.q0.sparse) < n { + m.q0 = queue{make([]uint32, n), make([]entry, 0, n)} + m.q1 = queue{make([]uint32, n), make([]entry, 0, n)} + } + return m +} + +// put returns a machine to the correct machine pool. +func (re *Regexp) put(m *machine) { + m.re = nil + m.p = nil + m.inputs.clear() + matchPool[re.mpool].Put(m) } // MustCompile is like Compile but panics if the expression cannot be parsed. @@ -288,7 +315,7 @@ type input interface { canCheckPrefix() bool // can we look ahead without losing info? hasPrefix(re *Regexp) bool index(re *Regexp, pos int) int - context(pos int) syntax.EmptyOp + context(pos int) lazyFlag } // inputString scans a string. @@ -319,7 +346,7 @@ func (i *inputString) index(re *Regexp, pos int) int { return strings.Index(i.str[pos:], re.prefix) } -func (i *inputString) context(pos int) syntax.EmptyOp { +func (i *inputString) context(pos int) lazyFlag { r1, r2 := endOfText, endOfText // 0 < pos && pos <= len(i.str) if uint(pos-1) < uint(len(i.str)) { @@ -335,7 +362,7 @@ func (i *inputString) context(pos int) syntax.EmptyOp { r2, _ = utf8.DecodeRuneInString(i.str[pos:]) } } - return syntax.EmptyOpContext(r1, r2) + return newLazyFlag(r1, r2) } // inputBytes scans a byte slice. @@ -366,7 +393,7 @@ func (i *inputBytes) index(re *Regexp, pos int) int { return bytes.Index(i.str[pos:], re.prefixBytes) } -func (i *inputBytes) context(pos int) syntax.EmptyOp { +func (i *inputBytes) context(pos int) lazyFlag { r1, r2 := endOfText, endOfText // 0 < pos && pos <= len(i.str) if uint(pos-1) < uint(len(i.str)) { @@ -382,7 +409,7 @@ func (i *inputBytes) context(pos int) syntax.EmptyOp { r2, _ = utf8.DecodeRune(i.str[pos:]) } } - return syntax.EmptyOpContext(r1, r2) + return newLazyFlag(r1, r2) } // inputReader scans a RuneReader. @@ -418,8 +445,8 @@ func (i *inputReader) index(re *Regexp, pos int) int { return -1 } -func (i *inputReader) context(pos int) syntax.EmptyOp { - return 0 +func (i *inputReader) context(pos int) lazyFlag { + return 0 // not used } // LiteralPrefix returns a literal string that must begin any match @@ -469,7 +496,7 @@ func MatchString(pattern string, s string) (matched bool, err error) { return re.MatchString(s), nil } -// MatchString reports whether the byte slice b +// Match reports whether the byte slice b // contains any match of the regular expression pattern. // More complicated queries need to use Compile and the full Regexp interface. func Match(pattern string, b []byte) (matched bool, err error) { diff --git a/libgo/go/regexp/syntax/prog.go b/libgo/go/regexp/syntax/prog.go index 49a06bbfad4..ae7a9a2fe01 100644 --- a/libgo/go/regexp/syntax/prog.go +++ b/libgo/go/regexp/syntax/prog.go @@ -201,8 +201,12 @@ func (i *Inst) MatchRune(r rune) bool { func (i *Inst) MatchRunePos(r rune) int { rune := i.Rune - // Special case: single-rune slice is from literal string, not char class. - if len(rune) == 1 { + switch len(rune) { + case 0: + return noMatch + + case 1: + // Special case: single-rune slice is from literal string, not char class. r0 := rune[0] if r == r0 { return 0 @@ -215,17 +219,25 @@ func (i *Inst) MatchRunePos(r rune) int { } } return noMatch - } - // Peek at the first few pairs. - // Should handle ASCII well. - for j := 0; j < len(rune) && j <= 8; j += 2 { - if r < rune[j] { - return noMatch + case 2: + if r >= rune[0] && r <= rune[1] { + return 0 } - if r <= rune[j+1] { - return j / 2 + return noMatch + + case 4, 6, 8: + // Linear search for a few pairs. + // Should handle ASCII well. + for j := 0; j < len(rune); j += 2 { + if r < rune[j] { + return noMatch + } + if r <= rune[j+1] { + return j / 2 + } } + return noMatch } // Otherwise binary search. diff --git a/libgo/go/regexp/syntax/regexp.go b/libgo/go/regexp/syntax/regexp.go index a3f56f8c902..ae5fa053f98 100644 --- a/libgo/go/regexp/syntax/regexp.go +++ b/libgo/go/regexp/syntax/regexp.go @@ -59,7 +59,7 @@ const ( const opPseudo Op = 128 // where pseudo-ops start -// Equal returns true if x and y have identical structure. +// Equal reports whether x and y have identical structure. func (x *Regexp) Equal(y *Regexp) bool { if x == nil || y == nil { return x == y diff --git a/libgo/go/runtime/atomic_pointer.go b/libgo/go/runtime/atomic_pointer.go index 03d8d6a48d5..49b0f2b84fd 100644 --- a/libgo/go/runtime/atomic_pointer.go +++ b/libgo/go/runtime/atomic_pointer.go @@ -13,8 +13,6 @@ import ( // because while ptr does not escape, new does. // If new is marked as not escaping, the compiler will make incorrect // escape analysis decisions about the pointer value being stored. -// Instead, these are wrappers around the actual atomics (casp1 and so on) -// that use noescape to convey which arguments do not escape. // atomicwb performs a write barrier before an atomic pointer write. // The caller should guard the call with "if writeBarrier.enabled". @@ -37,17 +35,6 @@ func atomicstorep(ptr unsafe.Pointer, new unsafe.Pointer) { atomic.StorepNoWB(noescape(ptr), new) } -//go:nosplit -func casp(ptr *unsafe.Pointer, old, new unsafe.Pointer) bool { - // The write barrier is only necessary if the CAS succeeds, - // but since it needs to happen before the write becomes - // public, we have to do it conservatively all the time. - if writeBarrier.enabled { - atomicwb(ptr, new) - } - return atomic.Casp1((*unsafe.Pointer)(noescape(unsafe.Pointer(ptr))), noescape(old), new) -} - // Like above, but implement in terms of sync/atomic's uintptr operations. // We cannot just call the runtime routines, because the race detector expects // to be able to intercept the sync/atomic forms but not the runtime forms. diff --git a/libgo/go/runtime/cgo_gccgo.go b/libgo/go/runtime/cgo_gccgo.go index e689b0e2616..aff8130a27c 100644 --- a/libgo/go/runtime/cgo_gccgo.go +++ b/libgo/go/runtime/cgo_gccgo.go @@ -84,8 +84,8 @@ func CgocallBack() { lockOSThread() - exitsyscall() gp.m.incgo = false + exitsyscall() if gp.m.ncgo == 0 { // The C call to Go came from a thread created by C. @@ -108,37 +108,41 @@ func CgocallBack() { func CgocallBackDone() { unlockOSThread() - // If we are the top level Go function called from C/C++, then - // we need to release the m. But don't release it if we are - // panicing; since this is the top level, we are going to - // crash the program, and we need the g and m to print the - // panic values. - // - // Dropping the m is going to clear g. This function is being - // called as a deferred function, so we will return to - // deferreturn which will want to clear the _defer field. - // As soon as we call dropm another thread may call needm and - // start using g, so we must not tamper with the _defer field - // after dropm. So clear _defer now. + // We are going to stop running in Go mode and return to C mode. + // We were almost certainly called by defer; if so, clean up + // the defer struct now, before we leave Go mode. But don't + // leave Go mode if we are panicing or called from Goexit, + // since in those cases we will continue executing deferred functions. gp := getg() mp := gp.m drop := false - if mp.dropextram && mp.ncgo == 0 && gp._panic == nil { + if gp.deferring && gp._panic == nil && !gp.goexiting { d := gp._defer - if d == nil || d.link != nil { - throw("unexpected g._defer in CgocallBackDone") + if d == nil { + throw("no defer struct when deferring") } - gp._defer = nil + gp._defer = d.link freedefer(d) - drop = true + + // If we are the top level Go function called from C, + // then we need to release the m. + if mp.dropextram && mp.ncgo == 0 { + drop = true + } } - gp.m.incgo = true - entersyscall() + // Don't go back to C mode if we are panicing. Just let the + // panic walk up through the Go stack. + if gp._panic == nil && !gp.goexiting { + gp.m.incgo = true + entersyscall() + } if drop { mp.dropextram = false dropm() + } else if gp.deferring && gp._panic == nil && !gp.goexiting { + gp.ranCgocallBackDone = true } } diff --git a/libgo/go/runtime/cgocall.go b/libgo/go/runtime/cgocall.go index 24bf749e5a7..57b42ff2eae 100644 --- a/libgo/go/runtime/cgocall.go +++ b/libgo/go/runtime/cgocall.go @@ -254,7 +254,7 @@ func cgoCheckUnknownPointer(p unsafe.Pointer, msg string) (base, i uintptr) { return } -// cgoIsGoPointer returns whether the pointer is a Go pointer--a +// cgoIsGoPointer reports whether the pointer is a Go pointer--a // pointer to Go memory. We only care about Go memory that might // contain pointers. //go:nosplit @@ -283,7 +283,7 @@ func cgoIsGoPointer(p unsafe.Pointer) bool { return false } -// cgoInRange returns whether p is between start and end. +// cgoInRange reports whether p is between start and end. //go:nosplit //go:nowritebarrierrec func cgoInRange(p unsafe.Pointer, start, end uintptr) bool { diff --git a/libgo/go/runtime/cgocheck.go b/libgo/go/runtime/cgocheck.go index d896fb7d79d..c9e40473771 100644 --- a/libgo/go/runtime/cgocheck.go +++ b/libgo/go/runtime/cgocheck.go @@ -43,6 +43,13 @@ func cgoCheckWriteBarrier(dst *uintptr, src uintptr) { return } + // It's OK if writing to memory allocated by persistentalloc. + // Do this check last because it is more expensive and rarely true. + // If it is false the expense doesn't matter since we are crashing. + if inPersistentAlloc(uintptr(unsafe.Pointer(dst))) { + return + } + systemstack(func() { println("write of Go pointer", hex(src), "to non-Go memory", hex(uintptr(unsafe.Pointer(dst)))) throw(cgoWriteBarrierFail) @@ -127,7 +134,7 @@ func cgoCheckTypedBlock(typ *_type, src unsafe.Pointer, off, size uintptr) { } s := spanOfUnchecked(uintptr(src)) - if s.state == _MSpanManual { + if s.state == mSpanManual { // There are no heap bits for value stored on the stack. // For a channel receive src might be on the stack of some // other goroutine, so we can't unwind the stack even if diff --git a/libgo/go/runtime/chan.go b/libgo/go/runtime/chan.go index cb369effb8c..6dfe2f3fc3e 100644 --- a/libgo/go/runtime/chan.go +++ b/libgo/go/runtime/chan.go @@ -19,6 +19,7 @@ package runtime import ( "runtime/internal/atomic" + "runtime/internal/math" "unsafe" ) @@ -88,7 +89,8 @@ func makechan(t *chantype, size int) *hchan { throw("makechan: bad alignment") } - if size < 0 || uintptr(size) > maxSliceCap(elem.size) || uintptr(size)*elem.size > maxAlloc-hchanSize { + mem, overflow := math.MulUintptr(elem.size, uintptr(size)) + if overflow || mem > maxAlloc-hchanSize || size < 0 { panic(plainError("makechan: size out of range")) } @@ -98,7 +100,7 @@ func makechan(t *chantype, size int) *hchan { // TODO(dvyukov,rlh): Rethink when collector can move allocated objects. var c *hchan switch { - case size == 0 || elem.size == 0: + case mem == 0: // Queue or element size is zero. c = (*hchan)(mallocgc(hchanSize, nil, true)) // Race detector uses this location for synchronization. @@ -106,12 +108,12 @@ func makechan(t *chantype, size int) *hchan { case elem.kind&kindNoPointers != 0: // Elements do not contain pointers. // Allocate hchan and buf in one call. - c = (*hchan)(mallocgc(hchanSize+uintptr(size)*elem.size, nil, true)) + c = (*hchan)(mallocgc(hchanSize+mem, nil, true)) c.buf = add(unsafe.Pointer(c), hchanSize) default: // Elements contain pointers. c = new(hchan) - c.buf = mallocgc(uintptr(size)*elem.size, elem, true) + c.buf = mallocgc(mem, elem, true) } c.elemsize = uint16(elem.size) @@ -247,6 +249,11 @@ func chansend(c *hchan, ep unsafe.Pointer, block bool, callerpc uintptr) bool { gp.param = nil c.sendq.enqueue(mysg) goparkunlock(&c.lock, waitReasonChanSend, traceEvGoBlockSend, 3) + // Ensure the value being sent is kept alive until the + // receiver copies it out. The sudog has a pointer to the + // stack object, but sudogs aren't considered as roots of the + // stack tracer. + KeepAlive(ep) // someone woke us up. if mysg != gp.waiting { @@ -358,7 +365,7 @@ func closechan(c *hchan) { c.closed = 1 - var glist *g + var glist gList // release all readers for { @@ -378,8 +385,7 @@ func closechan(c *hchan) { if raceenabled { raceacquireg(gp, c.raceaddr()) } - gp.schedlink.set(glist) - glist = gp + glist.push(gp) } // release all writers (they will panic) @@ -397,15 +403,13 @@ func closechan(c *hchan) { if raceenabled { raceacquireg(gp, c.raceaddr()) } - gp.schedlink.set(glist) - glist = gp + glist.push(gp) } unlock(&c.lock) // Ready all Gs now that we've dropped the channel lock. - for glist != nil { - gp := glist - glist = glist.schedlink.ptr() + for !glist.empty() { + gp := glist.pop() gp.schedlink = 0 goready(gp, 3) } diff --git a/libgo/go/runtime/crash_cgo_test.go b/libgo/go/runtime/crash_cgo_test.go index 770f85e96d4..f437b9a7e0f 100644 --- a/libgo/go/runtime/crash_cgo_test.go +++ b/libgo/go/runtime/crash_cgo_test.go @@ -269,7 +269,7 @@ func TestCgoTracebackContext(t *testing.T) { } } -func testCgoPprof(t *testing.T, buildArg, runArg string) { +func testCgoPprof(t *testing.T, buildArg, runArg, top, bottom string) { t.Parallel() if runtime.GOOS != "linux" || (runtime.GOARCH != "amd64" && runtime.GOARCH != "ppc64le") { t.Skipf("not yet supported on %s/%s", runtime.GOOS, runtime.GOARCH) @@ -296,7 +296,7 @@ func testCgoPprof(t *testing.T, buildArg, runArg string) { defer os.Remove(fn) for try := 0; try < 2; try++ { - cmd := testenv.CleanCmdEnv(exec.Command(testenv.GoToolPath(t), "tool", "pprof", "-top", "-nodecount=1")) + cmd := testenv.CleanCmdEnv(exec.Command(testenv.GoToolPath(t), "tool", "pprof", "-traces")) // Check that pprof works both with and without explicit executable on command line. if try == 0 { cmd.Args = append(cmd.Args, exe, fn) @@ -316,30 +316,38 @@ func testCgoPprof(t *testing.T, buildArg, runArg string) { cmd.Env = append(cmd.Env, "PPROF_TMPDIR="+os.TempDir()) } - top, err := cmd.CombinedOutput() - t.Logf("%s:\n%s", cmd.Args, top) + out, err := cmd.CombinedOutput() + t.Logf("%s:\n%s", cmd.Args, out) if err != nil { t.Error(err) - } else if !bytes.Contains(top, []byte("cpuHog")) { - t.Error("missing cpuHog in pprof output") + continue + } + + trace := findTrace(string(out), top) + if len(trace) == 0 { + t.Errorf("%s traceback missing.", top) + continue + } + if trace[len(trace)-1] != bottom { + t.Errorf("invalid traceback origin: got=%v; want=[%s ... %s]", trace, top, bottom) } } } func TestCgoPprof(t *testing.T) { - testCgoPprof(t, "", "CgoPprof") + testCgoPprof(t, "", "CgoPprof", "cpuHog", "runtime.main") } func TestCgoPprofPIE(t *testing.T) { - testCgoPprof(t, "-buildmode=pie", "CgoPprof") + testCgoPprof(t, "-buildmode=pie", "CgoPprof", "cpuHog", "runtime.main") } func TestCgoPprofThread(t *testing.T) { - testCgoPprof(t, "", "CgoPprofThread") + testCgoPprof(t, "", "CgoPprofThread", "cpuHogThread", "cpuHogThread2") } func TestCgoPprofThreadNoTraceback(t *testing.T) { - testCgoPprof(t, "", "CgoPprofThreadNoTraceback") + testCgoPprof(t, "", "CgoPprofThreadNoTraceback", "cpuHogThread", "runtime._ExternalCode") } func TestRaceProf(t *testing.T) { @@ -521,3 +529,35 @@ func TestBigStackCallbackCgo(t *testing.T) { t.Errorf("expected %q got %v", want, got) } } + +func nextTrace(lines []string) ([]string, []string) { + var trace []string + for n, line := range lines { + if strings.HasPrefix(line, "---") { + return trace, lines[n+1:] + } + fields := strings.Fields(strings.TrimSpace(line)) + if len(fields) == 0 { + continue + } + // Last field contains the function name. + trace = append(trace, fields[len(fields)-1]) + } + return nil, nil +} + +func findTrace(text, top string) []string { + lines := strings.Split(text, "\n") + _, lines = nextTrace(lines) // Skip the header. + for len(lines) > 0 { + var t []string + t, lines = nextTrace(lines) + if len(t) == 0 { + continue + } + if t[0] == top { + return t + } + } + return nil +} diff --git a/libgo/go/runtime/crash_test.go b/libgo/go/runtime/crash_test.go index 91a5c161097..6627bdc6726 100644 --- a/libgo/go/runtime/crash_test.go +++ b/libgo/go/runtime/crash_test.go @@ -657,6 +657,9 @@ func TestTimePprof(t *testing.T) { if runtime.Compiler == "gccgo" { t.Skip("gccgo may not have the pprof tool") } + if runtime.GOOS == "aix" { + t.Skip("pprof not yet available on AIX (see golang.org/issue/28555)") + } fn := runTestProg(t, "testprog", "TimeProf") fn = strings.TrimSpace(fn) defer os.Remove(fn) diff --git a/libgo/go/runtime/debug/mod.go b/libgo/go/runtime/debug/mod.go new file mode 100644 index 00000000000..f2948c65cbd --- /dev/null +++ b/libgo/go/runtime/debug/mod.go @@ -0,0 +1,112 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package debug + +import ( + "strings" + _ "unsafe" // for go:linkname +) + +// set using cmd/go/internal/modload.ModInfoProg +var modinfo string + +// setmodinfo is visible to code generated by cmd/go/internal/modload.ModInfoProg. +//go:linkname setmodinfo runtime..z2fdebug.setmodinfo +func setmodinfo(s string) { + modinfo = s +} + +// ReadBuildInfo returns the build information embedded +// in the running binary. The information is available only +// in binaries built with module support. +func ReadBuildInfo() (info *BuildInfo, ok bool) { + return readBuildInfo(modinfo) +} + +// BuildInfo represents the build information read from +// the running binary. +type BuildInfo struct { + Path string // The main package path + Main Module // The main module information + Deps []*Module // Module dependencies +} + +// Module represents a module. +type Module struct { + Path string // module path + Version string // module version + Sum string // checksum + Replace *Module // replaced by this module +} + +func readBuildInfo(data string) (*BuildInfo, bool) { + if len(data) < 32 { + return nil, false + } + data = data[16 : len(data)-16] + + const ( + pathLine = "path\t" + modLine = "mod\t" + depLine = "dep\t" + repLine = "=>\t" + ) + + info := &BuildInfo{} + + var line string + // Reverse of cmd/go/internal/modload.PackageBuildInfo + for len(data) > 0 { + i := strings.IndexByte(data, '\n') + if i < 0 { + break + } + line, data = data[:i], data[i+1:] + switch { + case strings.HasPrefix(line, pathLine): + elem := line[len(pathLine):] + info.Path = elem + case strings.HasPrefix(line, modLine): + elem := strings.Split(line[len(modLine):], "\t") + if len(elem) != 3 { + return nil, false + } + info.Main = Module{ + Path: elem[0], + Version: elem[1], + Sum: elem[2], + } + case strings.HasPrefix(line, depLine): + elem := strings.Split(line[len(depLine):], "\t") + if len(elem) != 2 && len(elem) != 3 { + return nil, false + } + sum := "" + if len(elem) == 3 { + sum = elem[2] + } + info.Deps = append(info.Deps, &Module{ + Path: elem[0], + Version: elem[1], + Sum: sum, + }) + case strings.HasPrefix(line, repLine): + elem := strings.Split(line[len(repLine):], "\t") + if len(elem) != 3 { + return nil, false + } + last := len(info.Deps) - 1 + if last < 0 { + return nil, false + } + info.Deps[last].Replace = &Module{ + Path: elem[0], + Version: elem[1], + Sum: elem[2], + } + } + } + return info, true +} diff --git a/libgo/go/runtime/debug_test.go b/libgo/go/runtime/debug_test.go index 38c764fadb3..12d93de3047 100644 --- a/libgo/go/runtime/debug_test.go +++ b/libgo/go/runtime/debug_test.go @@ -18,6 +18,8 @@ package runtime_test import ( "fmt" + "io/ioutil" + "regexp" "runtime" "runtime/debug" "sync/atomic" @@ -26,12 +28,23 @@ import ( ) func startDebugCallWorker(t *testing.T) (g *runtime.G, after func()) { + // This can deadlock if run under a debugger because it + // depends on catching SIGTRAP, which is usually swallowed by + // a debugger. + skipUnderDebugger(t) + // This can deadlock if there aren't enough threads or if a GC - // tries to interrupt an atomic loop (see issue #10958). - ogomaxprocs := runtime.GOMAXPROCS(2) + // tries to interrupt an atomic loop (see issue #10958). We + // use 8 Ps so there's room for the debug call worker, + // something that's trying to preempt the call worker, and the + // goroutine that's trying to stop the call worker. + ogomaxprocs := runtime.GOMAXPROCS(8) ogcpercent := debug.SetGCPercent(-1) - ready := make(chan *runtime.G) + // ready is a buffered channel so debugCallWorker won't block + // on sending to it. This makes it less likely we'll catch + // debugCallWorker while it's in the runtime. + ready := make(chan *runtime.G, 1) var stop uint32 done := make(chan error) go debugCallWorker(ready, &stop, done) @@ -61,6 +74,10 @@ func debugCallWorker(ready chan<- *runtime.G, stop *uint32, done chan<- error) { close(done) } +// Don't inline this function, since we want to test adjusting +// pointers in the arguments. +// +//go:noinline func debugCallWorker2(stop *uint32, x *int) { for atomic.LoadUint32(stop) == 0 { // Strongly encourage x to live in a register so we @@ -74,6 +91,28 @@ func debugCallTKill(tid int) error { return syscall.Tgkill(syscall.Getpid(), tid, syscall.SIGTRAP) } +// skipUnderDebugger skips the current test when running under a +// debugger (specifically if this process has a tracer). This is +// Linux-specific. +func skipUnderDebugger(t *testing.T) { + pid := syscall.Getpid() + status, err := ioutil.ReadFile(fmt.Sprintf("/proc/%d/status", pid)) + if err != nil { + t.Logf("couldn't get proc tracer: %s", err) + return + } + re := regexp.MustCompile(`TracerPid:\s+([0-9]+)`) + sub := re.FindSubmatch(status) + if sub == nil { + t.Logf("couldn't find proc tracer PID") + return + } + if string(sub[1]) == "0" { + return + } + t.Skip("test will deadlock under a debugger") +} + func TestDebugCall(t *testing.T) { g, after := startDebugCallWorker(t) defer after() @@ -161,9 +200,11 @@ func debugCallUnsafePointWorker(gpp **runtime.G, ready, stop *uint32) { } func TestDebugCallUnsafePoint(t *testing.T) { + skipUnderDebugger(t) + // This can deadlock if there aren't enough threads or if a GC // tries to interrupt an atomic loop (see issue #10958). - defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(2)) + defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(8)) defer debug.SetGCPercent(debug.SetGCPercent(-1)) // Test that the runtime refuses call injection at unsafe points. @@ -182,8 +223,10 @@ func TestDebugCallUnsafePoint(t *testing.T) { } func TestDebugCallPanic(t *testing.T) { + skipUnderDebugger(t) + // This can deadlock if there aren't enough threads. - defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(2)) + defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(8)) ready := make(chan *runtime.G) var stop uint32 diff --git a/libgo/go/runtime/env_posix.go b/libgo/go/runtime/env_posix.go index 399e88f420d..7e44f14edfc 100644 --- a/libgo/go/runtime/env_posix.go +++ b/libgo/go/runtime/env_posix.go @@ -12,9 +12,32 @@ func gogetenv(key string) string { throw("getenv before env init") } for _, s := range env { - if len(s) > len(key) && s[len(key)] == '=' && s[:len(key)] == key { + if len(s) > len(key) && s[len(key)] == '=' && envKeyEqual(s[:len(key)], key) { return s[len(key)+1:] } } return "" } + +// envKeyEqual reports whether a == b, with ASCII-only case insensitivity +// on Windows. The two strings must have the same length. +func envKeyEqual(a, b string) bool { + if GOOS == "windows" { // case insensitive + for i := 0; i < len(a); i++ { + ca, cb := a[i], b[i] + if ca == cb || lowerASCII(ca) == lowerASCII(cb) { + continue + } + return false + } + return true + } + return a == b +} + +func lowerASCII(c byte) byte { + if 'A' <= c && c <= 'Z' { + return c + ('a' - 'A') + } + return c +} diff --git a/libgo/go/runtime/export_debug_test.go b/libgo/go/runtime/export_debug_test.go index 2d2d5356edc..608d7567808 100644 --- a/libgo/go/runtime/export_debug_test.go +++ b/libgo/go/runtime/export_debug_test.go @@ -51,19 +51,31 @@ func InjectDebugCall(gp *g, fn, args interface{}, tkill func(tid int) error) (in h.gp = gp h.fv, h.argp, h.argSize = fv, argp, argSize h.handleF = h.handle // Avoid allocating closure during signal - noteclear(&h.done) defer func() { testSigtrap = nil }() - testSigtrap = h.inject - if err := tkill(tid); err != nil { - return nil, err - } - // Wait for completion. - notetsleepg(&h.done, -1) - if len(h.err) != 0 { - return nil, h.err + for i := 0; ; i++ { + testSigtrap = h.inject + noteclear(&h.done) + h.err = "" + + if err := tkill(tid); err != nil { + return nil, err + } + // Wait for completion. + notetsleepg(&h.done, -1) + if h.err != "" { + switch h.err { + case "retry _Grunnable", "executing on Go runtime stack": + // These are transient states. Try to get out of them. + if i < 100 { + Gosched() + continue + } + } + return nil, h.err + } + return h.panic, nil } - return h.panic, nil } type debugCallHandler struct { @@ -100,12 +112,18 @@ func (h *debugCallHandler) inject(info *siginfo, ctxt *sigctxt, gp2 *g) bool { h.savedRegs.fpstate = nil // Set PC to debugCallV1. ctxt.set_rip(uint64(funcPC(debugCallV1))) + // Call injected. Switch to the debugCall protocol. + testSigtrap = h.handleF + case _Grunnable: + // Ask InjectDebugCall to pause for a bit and then try + // again to interrupt this goroutine. + h.err = plainError("retry _Grunnable") + notewakeup(&h.done) default: h.err = plainError("goroutine in unexpected state at call inject") - return true + notewakeup(&h.done) } - // Switch to the debugCall protocol and resume execution. - testSigtrap = h.handleF + // Resume execution. return true } @@ -116,7 +134,7 @@ func (h *debugCallHandler) handle(info *siginfo, ctxt *sigctxt, gp2 *g) bool { return false } f := findfunc(uintptr(ctxt.rip())) - if !(hasprefix(funcname(f), "runtime.debugCall") || hasprefix(funcname(f), "debugCall")) { + if !(hasPrefix(funcname(f), "runtime.debugCall") || hasPrefix(funcname(f), "debugCall")) { println("trap in unknown function", funcname(f)) return false } @@ -150,6 +168,7 @@ func (h *debugCallHandler) handle(info *siginfo, ctxt *sigctxt, gp2 *g) bool { sp := ctxt.rsp() reason := *(*string)(unsafe.Pointer(uintptr(sp))) h.err = plainError(reason) + // Don't wake h.done. We need to transition to status 16 first. case 16: // Restore all registers except RIP and RSP. rip, rsp := ctxt.rip(), ctxt.rsp() @@ -163,6 +182,7 @@ func (h *debugCallHandler) handle(info *siginfo, ctxt *sigctxt, gp2 *g) bool { notewakeup(&h.done) default: h.err = plainError("unexpected debugCallV1 status") + notewakeup(&h.done) } // Resume execution. return true diff --git a/libgo/go/runtime/export_test.go b/libgo/go/runtime/export_test.go index 7f4811c5a0c..d919e0486b2 100644 --- a/libgo/go/runtime/export_test.go +++ b/libgo/go/runtime/export_test.go @@ -292,6 +292,7 @@ func ReadMemStatsSlow() (base, slow MemStats) { slow.TotalAlloc = 0 slow.Mallocs = 0 slow.Frees = 0 + slow.HeapReleased = 0 var bySize [_NumSizeClasses]struct { Mallocs, Frees uint64 } @@ -331,6 +332,10 @@ func ReadMemStatsSlow() (base, slow MemStats) { slow.BySize[i].Frees = bySize[i].Frees } + for i := mheap_.scav.start(); i.valid(); i = i.next() { + slow.HeapReleased += uint64(i.span().released()) + } + getg().m.mallocing-- }) @@ -454,3 +459,39 @@ func stackOverflow(x *byte) { var buf [256]byte stackOverflow(&buf[0]) } + +func MapTombstoneCheck(m map[int]int) { + // Make sure emptyOne and emptyRest are distributed correctly. + // We should have a series of filled and emptyOne cells, followed by + // a series of emptyRest cells. + h := *(**hmap)(unsafe.Pointer(&m)) + i := interface{}(m) + t := *(**maptype)(unsafe.Pointer(&i)) + + for x := 0; x < 1<= n && b.tophash[i] != emptyRest { + panic("late non-emptyRest") + } + if k == n-1 && b.tophash[i] == emptyOne { + panic("last non-emptyRest entry is emptyOne") + } + k++ + } + } + } +} diff --git a/libgo/go/runtime/extern.go b/libgo/go/runtime/extern.go index c9d10f16801..d07a5ed024f 100644 --- a/libgo/go/runtime/extern.go +++ b/libgo/go/runtime/extern.go @@ -50,19 +50,13 @@ It is a comma-separated list of name=val pairs setting these named variables: gcshrinkstackoff: setting gcshrinkstackoff=1 disables moving goroutines onto smaller stacks. In this mode, a goroutine's stack can only grow. - gcrescanstacks: setting gcrescanstacks=1 enables stack - re-scanning during the STW mark termination phase. This is - helpful for debugging if objects are being prematurely - garbage collected. - gcstoptheworld: setting gcstoptheworld=1 disables concurrent garbage collection, making every garbage collection a stop-the-world event. Setting gcstoptheworld=2 also disables concurrent sweeping after the garbage collection finishes. gctrace: setting gctrace=1 causes the garbage collector to emit a single line to standard error at each collection, summarizing the amount of memory collected and the - length of the pause. Setting gctrace=2 emits the same summary but also - repeats each collection. The format of this line is subject to change. + length of the pause. The format of this line is subject to change. Currently, it is: gc # @#s #%: #+#+# ms clock, #+#/#/#+# ms cpu, #->#-># MB, # MB goal, # P where the fields are as follows: @@ -95,6 +89,11 @@ It is a comma-separated list of name=val pairs setting these named variables: released: # MB released to the system consumed: # MB allocated from the system + madvdontneed: setting madvdontneed=1 will use MADV_DONTNEED + instead of MADV_FREE on Linux when returning memory to the + kernel. This is less efficient, but causes RSS numbers to drop + more quickly. + memprofilerate: setting memprofilerate=X will update the value of runtime.MemProfileRate. When set to 0 memory profiling is disabled. Refer to the description of MemProfileRate for the default value. @@ -206,6 +205,7 @@ func Version() string { // GOOS is the running program's operating system target: // one of darwin, freebsd, linux, and so on. +// To view possible combinations of GOOS and GOARCH, run "go tool dist list". const GOOS string = sys.GOOS // GOARCH is the running program's architecture target: diff --git a/libgo/go/runtime/fastlog2table.go b/libgo/go/runtime/fastlog2table.go index c36d5835f64..6ba4a7d3f24 100644 --- a/libgo/go/runtime/fastlog2table.go +++ b/libgo/go/runtime/fastlog2table.go @@ -1,4 +1,4 @@ -// AUTO-GENERATED by mkfastlog2table.go +// Code generated by mkfastlog2table.go; DO NOT EDIT. // Run go generate from src/runtime to update. // See mkfastlog2table.go for comments. diff --git a/libgo/go/runtime/gc_test.go b/libgo/go/runtime/gc_test.go index 180919bf3c4..384b75f2de3 100644 --- a/libgo/go/runtime/gc_test.go +++ b/libgo/go/runtime/gc_test.go @@ -22,6 +22,12 @@ func TestGcSys(t *testing.T) { if os.Getenv("GOGC") == "off" { t.Skip("skipping test; GOGC=off in environment") } + if runtime.GOOS == "windows" { + t.Skip("skipping test; GOOS=windows http://golang.org/issue/27156") + } + if runtime.GOOS == "linux" && runtime.GOARCH == "arm64" { + t.Skip("skipping test; GOOS=linux GOARCH=arm64 https://github.com/golang/go/issues/27636") + } got := runTestProg(t, "testprog", "GCSys") want := "OK\n" if got != want { @@ -571,8 +577,8 @@ func BenchmarkWriteBarrier(b *testing.B) { n := &node{mkTree(level - 1), mkTree(level - 1)} if level == 10 { // Seed GC with enough early pointers so it - // doesn't accidentally switch to mark 2 when - // it only has the top of the tree. + // doesn't start termination barriers when it + // only has the top of the tree. wbRoots = append(wbRoots, n) } return n diff --git a/libgo/go/runtime/gcinfo_test.go b/libgo/go/runtime/gcinfo_test.go index ca012bbcd45..89144d520e3 100644 --- a/libgo/go/runtime/gcinfo_test.go +++ b/libgo/go/runtime/gcinfo_test.go @@ -21,14 +21,46 @@ const ( func TestGCInfo(t *testing.T) { t.Skip("skipping on gccgo for now") - verifyGCInfo(t, "stack Ptr", new(Ptr), infoPtr) - verifyGCInfo(t, "stack ScalarPtr", new(ScalarPtr), infoScalarPtr) - verifyGCInfo(t, "stack PtrScalar", new(PtrScalar), infoPtrScalar) - verifyGCInfo(t, "stack BigStruct", new(BigStruct), infoBigStruct()) - verifyGCInfo(t, "stack string", new(string), infoString) - verifyGCInfo(t, "stack slice", new([]string), infoSlice) - verifyGCInfo(t, "stack eface", new(interface{}), infoEface) - verifyGCInfo(t, "stack iface", new(Iface), infoIface) + { + var x Ptr + verifyGCInfo(t, "stack Ptr", &x, infoPtr) + runtime.KeepAlive(x) + } + { + var x ScalarPtr + verifyGCInfo(t, "stack ScalarPtr", &x, infoScalarPtr) + runtime.KeepAlive(x) + } + { + var x PtrScalar + verifyGCInfo(t, "stack PtrScalar", &x, infoPtrScalar) + runtime.KeepAlive(x) + } + { + var x BigStruct + verifyGCInfo(t, "stack BigStruct", &x, infoBigStruct()) + runtime.KeepAlive(x) + } + { + var x string + verifyGCInfo(t, "stack string", &x, infoString) + runtime.KeepAlive(x) + } + { + var x []string + verifyGCInfo(t, "stack slice", &x, infoSlice) + runtime.KeepAlive(x) + } + { + var x interface{} + verifyGCInfo(t, "stack eface", &x, infoEface) + runtime.KeepAlive(x) + } + { + var x Iface + verifyGCInfo(t, "stack iface", &x, infoIface) + runtime.KeepAlive(x) + } for i := 0; i < 10; i++ { verifyGCInfo(t, "heap Ptr", escape(new(Ptr)), trimDead(padDead(infoPtr))) diff --git a/libgo/go/runtime/hash_test.go b/libgo/go/runtime/hash_test.go index 070edb6e9b6..d57be4c8f73 100644 --- a/libgo/go/runtime/hash_test.go +++ b/libgo/go/runtime/hash_test.go @@ -177,13 +177,13 @@ func twoNonZero(h *HashSet, n int) { b := make([]byte, n) // all zero - h.addB(b[:]) + h.addB(b) // one non-zero byte for i := 0; i < n; i++ { for x := 1; x < 256; x++ { b[i] = byte(x) - h.addB(b[:]) + h.addB(b) b[i] = 0 } } @@ -195,7 +195,7 @@ func twoNonZero(h *HashSet, n int) { for j := i + 1; j < n; j++ { for y := 1; y < 256; y++ { b[j] = byte(y) - h.addB(b[:]) + h.addB(b) b[j] = 0 } } diff --git a/libgo/go/runtime/heapdump.go b/libgo/go/runtime/heapdump.go index 5ebebf69474..3aa9e8a23f2 100644 --- a/libgo/go/runtime/heapdump.go +++ b/libgo/go/runtime/heapdump.go @@ -250,7 +250,7 @@ func dumpgoroutine(gp *g) { dumpint(uint64(gp.goid)) dumpint(uint64(gp.gopc)) dumpint(uint64(readgstatus(gp))) - dumpbool(isSystemGoroutine(gp)) + dumpbool(isSystemGoroutine(gp, false)) dumpbool(false) // isbackground dumpint(uint64(gp.waitsince)) dumpstr(gp.waitreason.String()) @@ -313,7 +313,7 @@ func finq_callback(fn *funcval, obj unsafe.Pointer, ft *functype, ot *ptrtype) { func dumproots() { // MSpan.types for _, s := range mheap_.allspans { - if s.state == _MSpanInUse { + if s.state == mSpanInUse { // Finalizers for sp := s.specials; sp != nil; sp = sp.next { if sp.kind != _KindSpecialFinalizer { @@ -336,7 +336,7 @@ var freemark [_PageSize / 8]bool func dumpobjs() { for _, s := range mheap_.allspans { - if s.state != _MSpanInUse { + if s.state != mSpanInUse { continue } p := s.base() @@ -485,7 +485,7 @@ func dumpmemprof_callback(b *bucket, nstk uintptr, pstk *location, size, allocs, func dumpmemprof() { iterate_memprof(dumpmemprof_callback) for _, s := range mheap_.allspans { - if s.state != _MSpanInUse { + if s.state != mSpanInUse { continue } for sp := s.specials; sp != nil; sp = sp.next { @@ -506,7 +506,7 @@ var dumphdr = []byte("go1.7 heap dump\n") func mdump() { // make sure we're done sweeping for _, s := range mheap_.allspans { - if s.state == _MSpanInUse { + if s.state == mSpanInUse { s.ensureSwept() } } @@ -529,7 +529,7 @@ func writeheapdump_m(fd uintptr) { _g_.waitreason = waitReasonDumpingHeap // Update stats so we can dump them. - // As a side effect, flushes all the MCaches so the MSpan.freelist + // As a side effect, flushes all the mcaches so the mspan.freelist // lists contain all the free objects. updatememstats() diff --git a/libgo/go/runtime/internal/atomic/atomic.c b/libgo/go/runtime/internal/atomic/atomic.c index b87fae96bd3..17c83a28c1c 100644 --- a/libgo/go/runtime/internal/atomic/atomic.c +++ b/libgo/go/runtime/internal/atomic/atomic.c @@ -13,7 +13,7 @@ uint32_t Load (uint32_t *ptr) uint32_t Load (uint32_t *ptr) { - return __atomic_load_n (ptr, __ATOMIC_ACQUIRE); + return __atomic_load_n (ptr, __ATOMIC_SEQ_CST); } void *Loadp (void *ptr) @@ -23,7 +23,7 @@ void *Loadp (void *ptr) void * Loadp (void *ptr) { - return __atomic_load_n ((void **) ptr, __ATOMIC_ACQUIRE); + return __atomic_load_n ((void **) ptr, __ATOMIC_SEQ_CST); } uint64_t Load64 (uint64_t *ptr) @@ -35,6 +35,16 @@ Load64 (uint64_t *ptr) { if (((uintptr_t) ptr & 7) != 0) panicmem (); + return __atomic_load_n (ptr, __ATOMIC_SEQ_CST); +} + +uint32_t LoadAcq (uint32_t *ptr) + __asm__ (GOSYM_PREFIX "runtime..z2finternal..z2fatomic.LoadAcq") + __attribute__ ((no_split_stack)); + +uint32_t +LoadAcq (uint32_t *ptr) +{ return __atomic_load_n (ptr, __ATOMIC_ACQUIRE); } @@ -45,7 +55,7 @@ uintptr_t Loaduintptr (uintptr_t *ptr) uintptr_t Loaduintptr (uintptr_t *ptr) { - return __atomic_load_n (ptr, __ATOMIC_ACQUIRE); + return __atomic_load_n (ptr, __ATOMIC_SEQ_CST); } uintgo Loaduint (uintgo *ptr) @@ -55,7 +65,7 @@ uintgo Loaduint (uintgo *ptr) uintgo Loaduint (uintgo *ptr) { - return __atomic_load_n (ptr, __ATOMIC_ACQUIRE); + return __atomic_load_n (ptr, __ATOMIC_SEQ_CST); } int64_t Loadint64 (int64_t *ptr) @@ -67,7 +77,7 @@ Loadint64 (int64_t *ptr) { if (((uintptr_t) ptr & 7) != 0) panicmem (); - return __atomic_load_n (ptr, __ATOMIC_ACQUIRE); + return __atomic_load_n (ptr, __ATOMIC_SEQ_CST); } uint32_t Xadd (uint32_t *ptr, int32_t delta) @@ -188,6 +198,16 @@ Cas64 (uint64_t *ptr, uint64_t old, uint64_t new) return __atomic_compare_exchange_n (ptr, &old, new, false, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED); } +_Bool CasRel (uint32_t *ptr, uint32_t old, uint32_t new) + __asm__ (GOSYM_PREFIX "runtime..z2finternal..z2fatomic.CasRel") + __attribute__ ((no_split_stack)); + +_Bool +CasRel (uint32_t *ptr, uint32_t old, uint32_t new) +{ + return __atomic_compare_exchange_n (ptr, &old, new, false, __ATOMIC_RELEASE, __ATOMIC_RELAXED); +} + _Bool Casp1 (void **ptr, void *old, void *new) __asm__ (GOSYM_PREFIX "runtime..z2finternal..z2fatomic.Casp1") __attribute__ ((no_split_stack)); @@ -230,6 +250,16 @@ Store64 (uint64_t *ptr, uint64_t val) __atomic_store_n (ptr, val, __ATOMIC_SEQ_CST); } +void StoreRel (uint32_t *ptr, uint32_t val) + __asm__ (GOSYM_PREFIX "runtime..z2finternal..z2fatomic.StoreRel") + __attribute__ ((no_split_stack)); + +void +StoreRel (uint32_t *ptr, uint32_t val) +{ + __atomic_store_n (ptr, val, __ATOMIC_RELEASE); +} + void Storeuintptr (uintptr_t *ptr, uintptr_t val) __asm__ (GOSYM_PREFIX "runtime..z2finternal..z2fatomic.Storeuintptr") __attribute__ ((no_split_stack)); diff --git a/libgo/go/runtime/internal/atomic/gccgo.go b/libgo/go/runtime/internal/atomic/gccgo.go index 696736465fd..e5edbfb17f1 100644 --- a/libgo/go/runtime/internal/atomic/gccgo.go +++ b/libgo/go/runtime/internal/atomic/gccgo.go @@ -17,6 +17,9 @@ func Loadp(ptr unsafe.Pointer) unsafe.Pointer //go:noescape func Load64(ptr *uint64) uint64 +//go:noescape +func LoadAcq(ptr *uint32) uint32 + //go:noescape func Xadd(ptr *uint32, delta int32) uint32 @@ -46,12 +49,18 @@ func Or8(ptr *uint8, val uint8) //go:noescape func Cas64(ptr *uint64, old, new uint64) bool +//go:noescape +func CasRel(ptr *uint32, old, new uint32) bool + //go:noescape func Store(ptr *uint32, val uint32) //go:noescape func Store64(ptr *uint64, val uint64) +//go:noescape +func StoreRel(ptr *uint32, val uint32) + // StorepNoWB performs *ptr = val atomically and without a write // barrier. // diff --git a/libgo/go/runtime/internal/math/math.go b/libgo/go/runtime/internal/math/math.go new file mode 100644 index 00000000000..5385f5dd868 --- /dev/null +++ b/libgo/go/runtime/internal/math/math.go @@ -0,0 +1,19 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package math + +import "runtime/internal/sys" + +const MaxUintptr = ^uintptr(0) + +// MulUintptr returns a * b and whether the multiplication overflowed. +// On supported platforms this is an intrinsic lowered by the compiler. +func MulUintptr(a, b uintptr) (uintptr, bool) { + if a|b < 1<<(4*sys.PtrSize) || a == 0 { + return a * b, false + } + overflow := b > MaxUintptr/a + return a * b, overflow +} diff --git a/libgo/go/runtime/internal/math/math_test.go b/libgo/go/runtime/internal/math/math_test.go new file mode 100644 index 00000000000..303eb63405a --- /dev/null +++ b/libgo/go/runtime/internal/math/math_test.go @@ -0,0 +1,79 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package math_test + +import ( + . "runtime/internal/math" + "testing" +) + +const ( + UintptrSize = 32 << (^uintptr(0) >> 63) +) + +type mulUintptrTest struct { + a uintptr + b uintptr + overflow bool +} + +var mulUintptrTests = []mulUintptrTest{ + {0, 0, false}, + {1000, 1000, false}, + {MaxUintptr, 0, false}, + {MaxUintptr, 1, false}, + {MaxUintptr / 2, 2, false}, + {MaxUintptr / 2, 3, true}, + {MaxUintptr, 10, true}, + {MaxUintptr, 100, true}, + {MaxUintptr / 100, 100, false}, + {MaxUintptr / 1000, 1001, true}, + {1<<(UintptrSize/2) - 1, 1<<(UintptrSize/2) - 1, false}, + {1 << (UintptrSize / 2), 1 << (UintptrSize / 2), true}, + {MaxUintptr >> 32, MaxUintptr >> 32, false}, + {MaxUintptr, MaxUintptr, true}, +} + +func TestMulUintptr(t *testing.T) { + for _, test := range mulUintptrTests { + a, b := test.a, test.b + for i := 0; i < 2; i++ { + mul, overflow := MulUintptr(a, b) + if mul != a*b || overflow != test.overflow { + t.Errorf("MulUintptr(%v, %v) = %v, %v want %v, %v", + a, b, mul, overflow, a*b, test.overflow) + } + a, b = b, a + } + } +} + +var SinkUintptr uintptr +var SinkBool bool + +var x, y uintptr + +func BenchmarkMulUintptr(b *testing.B) { + x, y = 1, 2 + b.Run("small", func(b *testing.B) { + for i := 0; i < b.N; i++ { + var overflow bool + SinkUintptr, overflow = MulUintptr(x, y) + if overflow { + SinkUintptr = 0 + } + } + }) + x, y = MaxUintptr, MaxUintptr-1 + b.Run("large", func(b *testing.B) { + for i := 0; i < b.N; i++ { + var overflow bool + SinkUintptr, overflow = MulUintptr(x, y) + if overflow { + SinkUintptr = 0 + } + } + }) +} diff --git a/libgo/go/runtime/lfstack_64bit.go b/libgo/go/runtime/lfstack_64bit.go index 401f83d9d5b..de40a00324a 100644 --- a/libgo/go/runtime/lfstack_64bit.go +++ b/libgo/go/runtime/lfstack_64bit.go @@ -41,8 +41,8 @@ const ( ia64CntBits = 64 - ia64AddrBits + 3 // On AIX, 64-bit addresses are split into 36-bit segment number and 28-bit - // offset in segment. Segment numbers in the range 0x070000000-0x07FFFFFFF - // and 0x0A0000000-0x0AFFFFFFF(LSA) are available for mmap. + // offset in segment. Segment numbers in the range 0x0A0000000-0x0AFFFFFFF(LSA) + // are available for mmap. // We assume all lfnode addresses are from memory allocated with mmap. // We use one bit to distinguish between the two ranges. aixAddrBits = 57 @@ -77,11 +77,7 @@ func lfstackUnpack(val uint64) *lfnode { return (*lfnode)(unsafe.Pointer(uintptr(((val & (1<<(64-3) - 1)) >> ia64CntBits << 3) | val&^(1<<(64-3)-1)))) } if GOARCH == "ppc64" && GOOS == "aix" { - if val&(1<<63) != 0 { - return (*lfnode)(unsafe.Pointer(uintptr((val >> aixCntBits << 3) | 0x7<<56))) - } else { - return (*lfnode)(unsafe.Pointer(uintptr((val >> aixCntBits << 3) | 0xa<<56))) - } + return (*lfnode)(unsafe.Pointer(uintptr((val >> aixCntBits << 3) | 0xa<<56))) } return (*lfnode)(unsafe.Pointer(uintptr(val >> cntBits << 3))) } diff --git a/libgo/go/runtime/lock_futex.go b/libgo/go/runtime/lock_futex.go index f7ca1f036e5..9cede2d41c3 100644 --- a/libgo/go/runtime/lock_futex.go +++ b/libgo/go/runtime/lock_futex.go @@ -242,7 +242,7 @@ func notetsleepg(n *note, ns int64) bool { return ok } -func pauseSchedulerUntilCallback() bool { +func beforeIdle() bool { return false } diff --git a/libgo/go/runtime/lock_js.go b/libgo/go/runtime/lock_js.go index df321e51963..f58c915b630 100644 --- a/libgo/go/runtime/lock_js.go +++ b/libgo/go/runtime/lock_js.go @@ -92,7 +92,7 @@ func notetsleepg(n *note, ns int64) bool { delay = 1<<31 - 1 // cap to max int32 } - id := scheduleCallback(delay) + id := scheduleTimeoutEvent(delay) mp := acquirem() notes[n] = gp notesWithTimeout[n] = noteWithTimeout{gp: gp, deadline: deadline} @@ -100,7 +100,7 @@ func notetsleepg(n *note, ns int64) bool { gopark(nil, nil, waitReasonSleep, traceEvNone, 1) - clearScheduledCallback(id) // note might have woken early, clear timeout + clearTimeoutEvent(id) // note might have woken early, clear timeout mp = acquirem() delete(notes, n) delete(notesWithTimeout, n) @@ -127,46 +127,68 @@ func notetsleepg(n *note, ns int64) bool { func checkTimeouts() { now := nanotime() for n, nt := range notesWithTimeout { - if n.key == note_cleared && now > nt.deadline { + if n.key == note_cleared && now >= nt.deadline { n.key = note_timeout goready(nt.gp, 1) } } } -var waitingForCallback *g +var returnedEventHandler *g -// sleepUntilCallback puts the current goroutine to sleep until a callback is triggered. -// It is currently only used by the callback routine of the syscall/js package. -//go:linkname sleepUntilCallback syscall/js.sleepUntilCallback -func sleepUntilCallback() { - waitingForCallback = getg() +func init() { + // At the toplevel we need an extra goroutine that handles asynchronous events. + initg := getg() + go func() { + returnedEventHandler = getg() + goready(initg, 1) + + gopark(nil, nil, waitReasonZero, traceEvNone, 1) + returnedEventHandler = nil + + pause(getcallersp() - 16) + }() gopark(nil, nil, waitReasonZero, traceEvNone, 1) - waitingForCallback = nil } -// pauseSchedulerUntilCallback gets called from the scheduler and pauses the execution -// of Go's WebAssembly code until a callback is triggered. Then it checks for note timeouts -// and resumes goroutines that are waiting for a callback. -func pauseSchedulerUntilCallback() bool { - if waitingForCallback == nil && len(notesWithTimeout) == 0 { - return false +// beforeIdle gets called by the scheduler if no goroutine is awake. +// We resume the event handler (if available) which will pause the execution. +func beforeIdle() bool { + if returnedEventHandler != nil { + goready(returnedEventHandler, 1) + return true } + return false +} + +// pause sets SP to newsp and pauses the execution of Go's WebAssembly code until an event is triggered. +func pause(newsp uintptr) + +// scheduleTimeoutEvent tells the WebAssembly environment to trigger an event after ms milliseconds. +// It returns a timer id that can be used with clearTimeoutEvent. +func scheduleTimeoutEvent(ms int64) int32 + +// clearTimeoutEvent clears a timeout event scheduled by scheduleTimeoutEvent. +func clearTimeoutEvent(id int32) + +func handleEvent() { + prevReturnedEventHandler := returnedEventHandler + returnedEventHandler = nil - pause() checkTimeouts() - if waitingForCallback != nil { - goready(waitingForCallback, 1) - } - return true -} + eventHandler() + + returnedEventHandler = getg() + gopark(nil, nil, waitReasonZero, traceEvNone, 1) + + returnedEventHandler = prevReturnedEventHandler -// pause pauses the execution of Go's WebAssembly code until a callback is triggered. -func pause() + pause(getcallersp() - 16) +} -// scheduleCallback tells the WebAssembly environment to trigger a callback after ms milliseconds. -// It returns a timer id that can be used with clearScheduledCallback. -func scheduleCallback(ms int64) int32 +var eventHandler func() -// clearScheduledCallback clears a callback scheduled by scheduleCallback. -func clearScheduledCallback(id int32) +//go:linkname setEventHandler syscall/js.setEventHandler +func setEventHandler(fn func()) { + eventHandler = fn +} diff --git a/libgo/go/runtime/lock_sema.go b/libgo/go/runtime/lock_sema.go index 237513ca0cb..c748ca70ec3 100644 --- a/libgo/go/runtime/lock_sema.go +++ b/libgo/go/runtime/lock_sema.go @@ -295,7 +295,7 @@ func notetsleepg(n *note, ns int64) bool { return ok } -func pauseSchedulerUntilCallback() bool { +func beforeIdle() bool { return false } diff --git a/libgo/go/runtime/malloc.go b/libgo/go/runtime/malloc.go index ac4759ffbf1..36417fb54f4 100644 --- a/libgo/go/runtime/malloc.go +++ b/libgo/go/runtime/malloc.go @@ -106,6 +106,7 @@ package runtime import ( "runtime/internal/atomic" + "runtime/internal/math" "runtime/internal/sys" "unsafe" ) @@ -135,8 +136,6 @@ const ( // have the most objects per span. maxObjsPerSpan = pageSize / 8 - mSpanInUse = _MSpanInUse - concurrentSweep = _ConcurrentSweep _PageSize = 1 << _PageShift @@ -149,8 +148,7 @@ const ( _TinySize = 16 _TinySizeClass = int8(2) - _FixAllocChunk = 16 << 10 // Chunk size for FixAlloc - _MaxMHeapList = 1 << (20 - _PageShift) // Maximum page length for fixed-size list in MHeap. + _FixAllocChunk = 16 << 10 // Chunk size for FixAlloc // Per-P, per order stack segment cache size. _StackCacheSize = 32 * 1024 @@ -173,7 +171,7 @@ const ( // amd64, addresses are sign-extended beyond heapAddrBits. On // other arches, they are zero-extended. // - // On 64-bit platforms, we limit this to 48 bits based on a + // On most 64-bit platforms, we limit this to 48 bits based on a // combination of hardware and OS limitations. // // amd64 hardware limits addresses to 48 bits, sign-extended @@ -191,10 +189,9 @@ const ( // bits, in the range [0, 1<<48). // // ppc64, mips64, and s390x support arbitrary 64 bit addresses - // in hardware. However, since Go only supports Linux on - // these, we lean on OS limits. Based on Linux's processor.h, - // the user address space is limited as follows on 64-bit - // architectures: + // in hardware. On Linux, Go leans on stricter OS limits. Based + // on Linux's processor.h, the user address space is limited as + // follows on 64-bit architectures: // // Architecture Name Maximum Value (exclusive) // --------------------------------------------------------------------- @@ -211,13 +208,17 @@ const ( // exceed Go's 48 bit limit, it's extremely unlikely in // practice. // + // On aix/ppc64, the limits is increased to 1<<60 to accept addresses + // returned by mmap syscall. These are in range: + // 0x0a00000000000000 - 0x0afffffffffffff + // // On 32-bit platforms, we accept the full 32-bit address // space because doing so is cheap. // mips32 only has access to the low 2GB of virtual memory, so // we further limit it to 31 bits. // // WebAssembly currently has a limit of 4GB linear memory. - heapAddrBits = (_64bit*(1-sys.GoarchWasm))*48 + (1-_64bit+sys.GoarchWasm)*(32-(sys.GoarchMips+sys.GoarchMipsle)) + heapAddrBits = (_64bit*(1-sys.GoarchWasm)*(1-sys.GoosAix))*48 + (1-_64bit+sys.GoarchWasm)*(32-(sys.GoarchMips+sys.GoarchMipsle)) + 60*sys.GoosAix // maxAlloc is the maximum size of an allocation. On 64-bit, // it's theoretically possible to allocate 1<= 0; i-- { var p uintptr switch { @@ -443,10 +448,11 @@ func mallocinit() { p = uintptr(i)<<40 | uintptrMask&(0x0040<<32) case GOOS == "aix": if i == 0 { - p = uintptrMask&(1<<42) | uintptrMask&(0xa0<<52) - } else { - p = uintptr(i)<<42 | uintptrMask&(0x70<<52) + // We don't use addresses directly after 0x0A00000000000000 + // to avoid collisions with others mmaps done by non-go programs. + continue } + p = uintptr(i)<<40 | uintptrMask&(0xa0<<52) case raceenabled: // The TSAN runtime requires the heap // to be in the range [0x00c000000000, @@ -480,7 +486,7 @@ func mallocinit() { // 3. We try to stake out a reasonably large initial // heap reservation. - const arenaMetaSize = unsafe.Sizeof([1 << arenaBits]heapArena{}) + const arenaMetaSize = (1 << arenaBits) * unsafe.Sizeof(heapArena{}) meta := uintptr(sysReserve(nil, arenaMetaSize)) if meta != 0 { mheap_.heapArenaAlloc.init(meta, arenaMetaSize) @@ -663,6 +669,27 @@ mapped: } } + // Add the arena to the arenas list. + if len(h.allArenas) == cap(h.allArenas) { + size := 2 * uintptr(cap(h.allArenas)) * sys.PtrSize + if size == 0 { + size = physPageSize + } + newArray := (*notInHeap)(persistentalloc(size, sys.PtrSize, &memstats.gc_sys)) + if newArray == nil { + throw("out of memory allocating allArenas") + } + oldSlice := h.allArenas + *(*notInHeapSlice)(unsafe.Pointer(&h.allArenas)) = notInHeapSlice{newArray, len(h.allArenas), int(size / sys.PtrSize)} + copy(h.allArenas, oldSlice) + // Do not free the old backing array because + // there may be concurrent readers. Since we + // double the array each time, this can lead + // to at most 2x waste. + } + h.allArenas = h.allArenas[:len(h.allArenas)+1] + h.allArenas[len(h.allArenas)-1] = ri + // Store atomically just in case an object from the // new heap arena becomes visible before the heap lock // is released (which shouldn't happen, but there's @@ -755,6 +782,9 @@ func nextFreeFast(s *mspan) gclinkptr { // weight allocation. If it is a heavy weight allocation the caller must // determine whether a new GC cycle needs to be started or if the GC is active // whether this goroutine needs to assist the GC. +// +// Must run in a non-preemptible context since otherwise the owner of +// c could change. func (c *mcache) nextFree(spc spanClass) (v gclinkptr, s *mspan, shouldhelpgc bool) { s = c.alloc[spc] shouldhelpgc = false @@ -765,9 +795,7 @@ func (c *mcache) nextFree(spc spanClass) (v gclinkptr, s *mspan, shouldhelpgc bo println("runtime: s.allocCount=", s.allocCount, "s.nelems=", s.nelems) throw("s.allocCount != s.nelems && freeIndex == s.nelems") } - systemstack(func() { - c.refill(spc) - }) + c.refill(spc) shouldhelpgc = true s = c.alloc[spc] @@ -1018,7 +1046,7 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer { if shouldhelpgc { if t := (gcTrigger{kind: gcTriggerHeap}); t.test() { - gcStart(gcBackgroundMode, t) + gcStart(t) } } @@ -1076,10 +1104,11 @@ func newarray(typ *_type, n int) unsafe.Pointer { if n == 1 { return mallocgc(typ.size, typ, true) } - if n < 0 || uintptr(n) > maxSliceCap(typ.size) { + mem, overflow := math.MulUintptr(typ.size, uintptr(n)) + if overflow || mem > maxAlloc || n < 0 { panic(plainError("runtime: allocation size out of range")) } - return mallocgc(typ.size*uintptr(n), typ, true) + return mallocgc(mem, typ, true) } //go:linkname reflect_unsafe_NewArray reflect.unsafe_NewArray @@ -1164,6 +1193,15 @@ var globalAlloc struct { persistentAlloc } +// persistentChunkSize is the number of bytes we allocate when we grow +// a persistentAlloc. +const persistentChunkSize = 256 << 10 + +// persistentChunks is a list of all the persistent chunks we have +// allocated. The list is maintained through the first word in the +// persistent chunk. This is updated atomically. +var persistentChunks *notInHeap + // Wrapper around sysAlloc that can allocate small chunks. // There is no associated free operation. // Intended for things like function/type/debug-related persistent data. @@ -1184,7 +1222,6 @@ func persistentalloc(size, align uintptr, sysStat *uint64) unsafe.Pointer { //go:systemstack func persistentalloc1(size, align uintptr, sysStat *uint64) *notInHeap { const ( - chunk = 256 << 10 maxBlock = 64 << 10 // VM reservation granularity is 64K on windows ) @@ -1215,15 +1252,24 @@ func persistentalloc1(size, align uintptr, sysStat *uint64) *notInHeap { persistent = &globalAlloc.persistentAlloc } persistent.off = round(persistent.off, align) - if persistent.off+size > chunk || persistent.base == nil { - persistent.base = (*notInHeap)(sysAlloc(chunk, &memstats.other_sys)) + if persistent.off+size > persistentChunkSize || persistent.base == nil { + persistent.base = (*notInHeap)(sysAlloc(persistentChunkSize, &memstats.other_sys)) if persistent.base == nil { if persistent == &globalAlloc.persistentAlloc { unlock(&globalAlloc.mutex) } throw("runtime: cannot allocate memory") } - persistent.off = 0 + + // Add the new chunk to the persistentChunks list. + for { + chunks := uintptr(unsafe.Pointer(persistentChunks)) + *(*uintptr)(unsafe.Pointer(persistent.base)) = chunks + if atomic.Casuintptr((*uintptr)(unsafe.Pointer(&persistentChunks)), chunks, uintptr(unsafe.Pointer(persistent.base))) { + break + } + } + persistent.off = sys.PtrSize } p := persistent.base.add(persistent.off) persistent.off += size @@ -1239,6 +1285,21 @@ func persistentalloc1(size, align uintptr, sysStat *uint64) *notInHeap { return p } +// inPersistentAlloc reports whether p points to memory allocated by +// persistentalloc. This must be nosplit because it is called by the +// cgo checker code, which is called by the write barrier code. +//go:nosplit +func inPersistentAlloc(p uintptr) bool { + chunk := atomic.Loaduintptr((*uintptr)(unsafe.Pointer(&persistentChunks))) + for chunk != 0 { + if p >= chunk && p < chunk+persistentChunkSize { + return true + } + chunk = *(*uintptr)(unsafe.Pointer(chunk)) + } + return false +} + // linearAlloc is a simple linear allocator that pre-reserves a region // of memory and then maps that region as needed. The caller is // responsible for locking. diff --git a/libgo/go/runtime/malloc_test.go b/libgo/go/runtime/malloc_test.go index 30a7d844c63..c9282bae55e 100644 --- a/libgo/go/runtime/malloc_test.go +++ b/libgo/go/runtime/malloc_test.go @@ -170,6 +170,14 @@ func TestTinyAlloc(t *testing.T) { } } +func TestPhysicalMemoryUtilization(t *testing.T) { + got := runTestProg(t, "testprog", "GCPhys") + want := "OK\n" + if got != want { + t.Fatalf("expected %q, but got %q", want, got) + } +} + type acLink struct { x [1 << 20]byte } @@ -177,6 +185,14 @@ type acLink struct { var arenaCollisionSink []*acLink func TestArenaCollision(t *testing.T) { + if GOOS == "darwin" && race.Enabled { + // Skip this test on Darwin in race mode because Darwin 10.10 has + // issues following arena hints and runs out of them in race mode, so + // MAP_FIXED is used to ensure we keep the heap in the memory region the + // race detector expects. + // TODO(mknyszek): Delete this when Darwin 10.10 is no longer supported. + t.Skip("disabled on Darwin with race mode since MAP_FIXED is used") + } testenv.MustHaveExec(t) // Test that mheap.sysAlloc handles collisions with other diff --git a/libgo/go/runtime/map.go b/libgo/go/runtime/map.go index 52462c7e117..5dd5283e1ec 100644 --- a/libgo/go/runtime/map.go +++ b/libgo/go/runtime/map.go @@ -55,6 +55,7 @@ package runtime import ( "runtime/internal/atomic" + "runtime/internal/math" "runtime/internal/sys" "unsafe" ) @@ -103,11 +104,12 @@ const ( // Each bucket (including its overflow buckets, if any) will have either all or none of its // entries in the evacuated* states (except during the evacuate() method, which only happens // during map writes and thus no one else can observe the map during that time). - empty = 0 // cell is empty - evacuatedEmpty = 1 // cell is empty, bucket is evacuated. + emptyRest = 0 // this cell is empty, and there are no more non-empty cells at higher indexes or overflows. + emptyOne = 1 // this cell is empty evacuatedX = 2 // key/value is valid. Entry has been evacuated to first half of larger table. evacuatedY = 3 // same as above, but evacuated to second half of larger table. - minTopHash = 4 // minimum tophash for a normal filled cell. + evacuatedEmpty = 4 // cell is empty, bucket is evacuated. + minTopHash = 5 // minimum tophash for a normal filled cell. // flags iterator = 1 // there may be an iterator using buckets @@ -119,6 +121,11 @@ const ( noCheck = 1<<(8*sys.PtrSize) - 1 ) +// isEmpty reports whether the given tophash array entry represents an empty bucket entry. +func isEmpty(x uint8) bool { + return x <= emptyOne +} + // A header for a Go map. type hmap struct { // Note: the format of the hmap is also encoded in cmd/compile/internal/gc/reflect.go. @@ -211,7 +218,7 @@ func tophash(hash uintptr) uint8 { func evacuated(b *bmap) bool { h := b.tophash[0] - return h > empty && h < minTopHash + return h > emptyOne && h < minTopHash } func (b *bmap) overflow(t *maptype) *bmap { @@ -311,7 +318,8 @@ func makemap_small() *hmap { // If h != nil, the map can be created directly in h. // If h.buckets != nil, bucket pointed to can be used as the first bucket. func makemap(t *maptype, hint int, h *hmap) *hmap { - if hint < 0 || hint > int(maxSliceCap(t.bucket.size)) { + mem, overflow := math.MulUintptr(uintptr(hint), t.bucket.size) + if overflow || mem > maxAlloc { hint = 0 } @@ -321,7 +329,8 @@ func makemap(t *maptype, hint int, h *hmap) *hmap { } h.hash0 = fastrand() - // find size parameter which will hold the requested # of elements + // Find the size parameter B which will hold the requested # of elements. + // For hint < 0 overLoadFactor returns false since hint < bucketCnt. B := uint8(0) for overLoadFactor(hint, B) { B++ @@ -439,9 +448,13 @@ func mapaccess1(t *maptype, h *hmap, key unsafe.Pointer) unsafe.Pointer { } } top := tophash(hash) +bucketloop: for ; b != nil; b = b.overflow(t) { for i := uintptr(0); i < bucketCnt; i++ { if b.tophash[i] != top { + if b.tophash[i] == emptyRest { + break bucketloop + } continue } k := add(unsafe.Pointer(b), dataOffset+i*uintptr(t.keysize)) @@ -500,9 +513,13 @@ func mapaccess2(t *maptype, h *hmap, key unsafe.Pointer) (unsafe.Pointer, bool) } } top := tophash(hash) +bucketloop: for ; b != nil; b = b.overflow(t) { for i := uintptr(0); i < bucketCnt; i++ { if b.tophash[i] != top { + if b.tophash[i] == emptyRest { + break bucketloop + } continue } k := add(unsafe.Pointer(b), dataOffset+i*uintptr(t.keysize)) @@ -547,9 +564,13 @@ func mapaccessK(t *maptype, h *hmap, key unsafe.Pointer) (unsafe.Pointer, unsafe } } top := tophash(hash) +bucketloop: for ; b != nil; b = b.overflow(t) { for i := uintptr(0); i < bucketCnt; i++ { if b.tophash[i] != top { + if b.tophash[i] == emptyRest { + break bucketloop + } continue } k := add(unsafe.Pointer(b), dataOffset+i*uintptr(t.keysize)) @@ -612,7 +633,7 @@ func mapassign(t *maptype, h *hmap, key unsafe.Pointer) unsafe.Pointer { // Set hashWriting after calling alg.hash, since alg.hash may panic, // in which case we have not actually done a write. - h.flags |= hashWriting + h.flags ^= hashWriting if h.buckets == nil { h.buckets = newobject(t.bucket) // newarray(t.bucket, 1) @@ -629,14 +650,18 @@ again: var inserti *uint8 var insertk unsafe.Pointer var val unsafe.Pointer +bucketloop: for { for i := uintptr(0); i < bucketCnt; i++ { if b.tophash[i] != top { - if b.tophash[i] == empty && inserti == nil { + if isEmpty(b.tophash[i]) && inserti == nil { inserti = &b.tophash[i] insertk = add(unsafe.Pointer(b), dataOffset+i*uintptr(t.keysize)) val = add(unsafe.Pointer(b), dataOffset+bucketCnt*uintptr(t.keysize)+i*uintptr(t.valuesize)) } + if b.tophash[i] == emptyRest { + break bucketloop + } continue } k := add(unsafe.Pointer(b), dataOffset+i*uintptr(t.keysize)) @@ -728,18 +753,22 @@ func mapdelete(t *maptype, h *hmap, key unsafe.Pointer) { // Set hashWriting after calling alg.hash, since alg.hash may panic, // in which case we have not actually done a write (delete). - h.flags |= hashWriting + h.flags ^= hashWriting bucket := hash & bucketMask(h.B) if h.growing() { growWork(t, h, bucket) } b := (*bmap)(add(h.buckets, bucket*uintptr(t.bucketsize))) + bOrig := b top := tophash(hash) search: for ; b != nil; b = b.overflow(t) { for i := uintptr(0); i < bucketCnt; i++ { if b.tophash[i] != top { + if b.tophash[i] == emptyRest { + break search + } continue } k := add(unsafe.Pointer(b), dataOffset+i*uintptr(t.keysize)) @@ -764,7 +793,39 @@ search: } else { memclrNoHeapPointers(v, t.elem.size) } - b.tophash[i] = empty + b.tophash[i] = emptyOne + // If the bucket now ends in a bunch of emptyOne states, + // change those to emptyRest states. + // It would be nice to make this a separate function, but + // for loops are not currently inlineable. + if i == bucketCnt-1 { + if b.overflow(t) != nil && b.overflow(t).tophash[0] != emptyRest { + goto notLast + } + } else { + if b.tophash[i+1] != emptyRest { + goto notLast + } + } + for { + b.tophash[i] = emptyRest + if i == 0 { + if b == bOrig { + break // beginning of initial bucket, we're done. + } + // Find previous bucket, continue at its last entry. + c := b + for b = bOrig; b.overflow(t) != c; b = b.overflow(t) { + } + i = bucketCnt - 1 + } else { + i-- + } + if b.tophash[i] != emptyOne { + break + } + } + notLast: h.count-- break search } @@ -899,7 +960,9 @@ next: } for ; i < bucketCnt; i++ { offi := (i + it.offset) & (bucketCnt - 1) - if b.tophash[offi] == empty || b.tophash[offi] == evacuatedEmpty { + if isEmpty(b.tophash[offi]) || b.tophash[offi] == evacuatedEmpty { + // TODO: emptyRest is hard to use here, as we start iterating + // in the middle of a bucket. It's feasible, just tricky. continue } k := add(unsafe.Pointer(b), dataOffset+uintptr(offi)*uintptr(t.keysize)) @@ -990,7 +1053,7 @@ func mapclear(t *maptype, h *hmap) { throw("concurrent map writes") } - h.flags |= hashWriting + h.flags ^= hashWriting h.flags &^= sameSizeGrow h.oldbuckets = nil @@ -1158,7 +1221,7 @@ func evacuate(t *maptype, h *hmap, oldbucket uintptr) { v := add(k, bucketCnt*uintptr(t.keysize)) for i := 0; i < bucketCnt; i, k, v = i+1, add(k, uintptr(t.keysize)), add(v, uintptr(t.valuesize)) { top := b.tophash[i] - if top == empty { + if isEmpty(top) { b.tophash[i] = evacuatedEmpty continue } @@ -1195,7 +1258,7 @@ func evacuate(t *maptype, h *hmap, oldbucket uintptr) { } } - if evacuatedX+1 != evacuatedY { + if evacuatedX+1 != evacuatedY || evacuatedX^1 != evacuatedY { throw("bad evacuatedN") } @@ -1351,6 +1414,11 @@ func reflect_mapiterkey(it *hiter) unsafe.Pointer { return it.key } +//go:linkname reflect_mapitervalue reflect.mapitervalue +func reflect_mapitervalue(it *hiter) unsafe.Pointer { + return it.value +} + //go:linkname reflect_maplen reflect.maplen func reflect_maplen(h *hmap) int { if h == nil { diff --git a/libgo/go/runtime/map_benchmark_test.go b/libgo/go/runtime/map_benchmark_test.go index 025c0398d3b..d37dadcb569 100644 --- a/libgo/go/runtime/map_benchmark_test.go +++ b/libgo/go/runtime/map_benchmark_test.go @@ -5,6 +5,7 @@ package runtime_test import ( "fmt" + "math/rand" "strconv" "strings" "testing" @@ -206,6 +207,67 @@ func BenchmarkIntMap(b *testing.B) { } } +func BenchmarkMapFirst(b *testing.B) { + for n := 1; n <= 16; n++ { + b.Run(fmt.Sprintf("%d", n), func(b *testing.B) { + m := make(map[int]bool) + for i := 0; i < n; i++ { + m[i] = true + } + b.ResetTimer() + for i := 0; i < b.N; i++ { + _ = m[0] + } + }) + } +} +func BenchmarkMapMid(b *testing.B) { + for n := 1; n <= 16; n++ { + b.Run(fmt.Sprintf("%d", n), func(b *testing.B) { + m := make(map[int]bool) + for i := 0; i < n; i++ { + m[i] = true + } + b.ResetTimer() + for i := 0; i < b.N; i++ { + _ = m[n>>1] + } + }) + } +} +func BenchmarkMapLast(b *testing.B) { + for n := 1; n <= 16; n++ { + b.Run(fmt.Sprintf("%d", n), func(b *testing.B) { + m := make(map[int]bool) + for i := 0; i < n; i++ { + m[i] = true + } + b.ResetTimer() + for i := 0; i < b.N; i++ { + _ = m[n-1] + } + }) + } +} + +func BenchmarkMapCycle(b *testing.B) { + // Arrange map entries to be a permuation, so that + // we hit all entries, and one lookup is data dependent + // on the previous lookup. + const N = 3127 + p := rand.New(rand.NewSource(1)).Perm(N) + m := map[int]int{} + for i := 0; i < N; i++ { + m[i] = p[i] + } + b.ResetTimer() + j := 0 + for i := 0; i < b.N; i++ { + j = m[j] + } + sink = uint64(j) +} + // Accessing the same keys in a row. func benchmarkRepeatedLookup(b *testing.B, lookupKeySize int) { m := make(map[string]bool) @@ -228,6 +290,23 @@ func benchmarkRepeatedLookup(b *testing.B, lookupKeySize int) { func BenchmarkRepeatedLookupStrMapKey32(b *testing.B) { benchmarkRepeatedLookup(b, 32) } func BenchmarkRepeatedLookupStrMapKey1M(b *testing.B) { benchmarkRepeatedLookup(b, 1<<20) } +func BenchmarkMakeMap(b *testing.B) { + b.Run("[Byte]Byte", func(b *testing.B) { + var m map[byte]byte + for i := 0; i < b.N; i++ { + m = make(map[byte]byte, 10) + } + hugeSink = m + }) + b.Run("[Int]Int", func(b *testing.B) { + var m map[int]int + for i := 0; i < b.N; i++ { + m = make(map[int]int, 10) + } + hugeSink = m + }) +} + func BenchmarkNewEmptyMap(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { @@ -370,3 +449,37 @@ func BenchmarkGoMapClear(b *testing.B) { } }) } + +func BenchmarkMapStringConversion(b *testing.B) { + for _, length := range []int{32, 64} { + b.Run(strconv.Itoa(length), func(b *testing.B) { + bytes := make([]byte, length) + b.Run("simple", func(b *testing.B) { + b.ReportAllocs() + m := make(map[string]int) + m[string(bytes)] = 0 + for i := 0; i < b.N; i++ { + _ = m[string(bytes)] + } + }) + b.Run("struct", func(b *testing.B) { + b.ReportAllocs() + type stringstruct struct{ s string } + m := make(map[stringstruct]int) + m[stringstruct{string(bytes)}] = 0 + for i := 0; i < b.N; i++ { + _ = m[stringstruct{string(bytes)}] + } + }) + b.Run("array", func(b *testing.B) { + b.ReportAllocs() + type stringarray [1]string + m := make(map[stringarray]int) + m[stringarray{string(bytes)}] = 0 + for i := 0; i < b.N; i++ { + _ = m[stringarray{string(bytes)}] + } + }) + }) + } +} diff --git a/libgo/go/runtime/map_fast32.go b/libgo/go/runtime/map_fast32.go index a9a06a85c26..1fa5cd968e4 100644 --- a/libgo/go/runtime/map_fast32.go +++ b/libgo/go/runtime/map_fast32.go @@ -41,7 +41,7 @@ func mapaccess1_fast32(t *maptype, h *hmap, key uint32) unsafe.Pointer { } for ; b != nil; b = b.overflow(t) { for i, k := uintptr(0), b.keys(); i < bucketCnt; i, k = i+1, add(k, 4) { - if *(*uint32)(k) == key && b.tophash[i] != empty { + if *(*uint32)(k) == key && !isEmpty(b.tophash[i]) { return add(unsafe.Pointer(b), dataOffset+bucketCnt*4+i*uintptr(t.valuesize)) } } @@ -81,7 +81,7 @@ func mapaccess2_fast32(t *maptype, h *hmap, key uint32) (unsafe.Pointer, bool) { } for ; b != nil; b = b.overflow(t) { for i, k := uintptr(0), b.keys(); i < bucketCnt; i, k = i+1, add(k, 4) { - if *(*uint32)(k) == key && b.tophash[i] != empty { + if *(*uint32)(k) == key && !isEmpty(b.tophash[i]) { return add(unsafe.Pointer(b), dataOffset+bucketCnt*4+i*uintptr(t.valuesize)), true } } @@ -103,7 +103,7 @@ func mapassign_fast32(t *maptype, h *hmap, key uint32) unsafe.Pointer { hash := t.key.hashfn(noescape(unsafe.Pointer(&key)), uintptr(h.hash0)) // Set hashWriting after calling alg.hash for consistency with mapassign. - h.flags |= hashWriting + h.flags ^= hashWriting if h.buckets == nil { h.buckets = newobject(t.bucket) // newarray(t.bucket, 1) @@ -120,13 +120,17 @@ again: var inserti uintptr var insertk unsafe.Pointer +bucketloop: for { for i := uintptr(0); i < bucketCnt; i++ { - if b.tophash[i] == empty { + if isEmpty(b.tophash[i]) { if insertb == nil { inserti = i insertb = b } + if b.tophash[i] == emptyRest { + break bucketloop + } continue } k := *((*uint32)(add(unsafe.Pointer(b), dataOffset+i*4))) @@ -189,7 +193,7 @@ func mapassign_fast32ptr(t *maptype, h *hmap, key unsafe.Pointer) unsafe.Pointer hash := t.key.hashfn(noescape(unsafe.Pointer(&key)), uintptr(h.hash0)) // Set hashWriting after calling alg.hash for consistency with mapassign. - h.flags |= hashWriting + h.flags ^= hashWriting if h.buckets == nil { h.buckets = newobject(t.bucket) // newarray(t.bucket, 1) @@ -206,13 +210,17 @@ again: var inserti uintptr var insertk unsafe.Pointer +bucketloop: for { for i := uintptr(0); i < bucketCnt; i++ { - if b.tophash[i] == empty { + if isEmpty(b.tophash[i]) { if insertb == nil { inserti = i insertb = b } + if b.tophash[i] == emptyRest { + break bucketloop + } continue } k := *((*unsafe.Pointer)(add(unsafe.Pointer(b), dataOffset+i*4))) @@ -276,17 +284,18 @@ func mapdelete_fast32(t *maptype, h *hmap, key uint32) { hash := t.key.hashfn(noescape(unsafe.Pointer(&key)), uintptr(h.hash0)) // Set hashWriting after calling alg.hash for consistency with mapdelete - h.flags |= hashWriting + h.flags ^= hashWriting bucket := hash & bucketMask(h.B) if h.growing() { growWork_fast32(t, h, bucket) } b := (*bmap)(add(h.buckets, bucket*uintptr(t.bucketsize))) + bOrig := b search: for ; b != nil; b = b.overflow(t) { for i, k := uintptr(0), b.keys(); i < bucketCnt; i, k = i+1, add(k, 4) { - if key != *(*uint32)(k) || b.tophash[i] == empty { + if key != *(*uint32)(k) || isEmpty(b.tophash[i]) { continue } // Only clear key if there are pointers in it. @@ -299,7 +308,37 @@ search: } else { memclrNoHeapPointers(v, t.elem.size) } - b.tophash[i] = empty + b.tophash[i] = emptyOne + // If the bucket now ends in a bunch of emptyOne states, + // change those to emptyRest states. + if i == bucketCnt-1 { + if b.overflow(t) != nil && b.overflow(t).tophash[0] != emptyRest { + goto notLast + } + } else { + if b.tophash[i+1] != emptyRest { + goto notLast + } + } + for { + b.tophash[i] = emptyRest + if i == 0 { + if b == bOrig { + break // beginning of initial bucket, we're done. + } + // Find previous bucket, continue at its last entry. + c := b + for b = bOrig; b.overflow(t) != c; b = b.overflow(t) { + } + i = bucketCnt - 1 + } else { + i-- + } + if b.tophash[i] != emptyOne { + break + } + } + notLast: h.count-- break search } @@ -350,7 +389,7 @@ func evacuate_fast32(t *maptype, h *hmap, oldbucket uintptr) { v := add(k, bucketCnt*4) for i := 0; i < bucketCnt; i, k, v = i+1, add(k, 4), add(v, uintptr(t.valuesize)) { top := b.tophash[i] - if top == empty { + if isEmpty(top) { b.tophash[i] = evacuatedEmpty continue } diff --git a/libgo/go/runtime/map_fast64.go b/libgo/go/runtime/map_fast64.go index a2a51fcac6a..d23ac23eb14 100644 --- a/libgo/go/runtime/map_fast64.go +++ b/libgo/go/runtime/map_fast64.go @@ -41,7 +41,7 @@ func mapaccess1_fast64(t *maptype, h *hmap, key uint64) unsafe.Pointer { } for ; b != nil; b = b.overflow(t) { for i, k := uintptr(0), b.keys(); i < bucketCnt; i, k = i+1, add(k, 8) { - if *(*uint64)(k) == key && b.tophash[i] != empty { + if *(*uint64)(k) == key && !isEmpty(b.tophash[i]) { return add(unsafe.Pointer(b), dataOffset+bucketCnt*8+i*uintptr(t.valuesize)) } } @@ -81,7 +81,7 @@ func mapaccess2_fast64(t *maptype, h *hmap, key uint64) (unsafe.Pointer, bool) { } for ; b != nil; b = b.overflow(t) { for i, k := uintptr(0), b.keys(); i < bucketCnt; i, k = i+1, add(k, 8) { - if *(*uint64)(k) == key && b.tophash[i] != empty { + if *(*uint64)(k) == key && !isEmpty(b.tophash[i]) { return add(unsafe.Pointer(b), dataOffset+bucketCnt*8+i*uintptr(t.valuesize)), true } } @@ -103,7 +103,7 @@ func mapassign_fast64(t *maptype, h *hmap, key uint64) unsafe.Pointer { hash := t.key.hashfn(noescape(unsafe.Pointer(&key)), uintptr(h.hash0)) // Set hashWriting after calling alg.hash for consistency with mapassign. - h.flags |= hashWriting + h.flags ^= hashWriting if h.buckets == nil { h.buckets = newobject(t.bucket) // newarray(t.bucket, 1) @@ -120,13 +120,17 @@ again: var inserti uintptr var insertk unsafe.Pointer +bucketloop: for { for i := uintptr(0); i < bucketCnt; i++ { - if b.tophash[i] == empty { + if isEmpty(b.tophash[i]) { if insertb == nil { insertb = b inserti = i } + if b.tophash[i] == emptyRest { + break bucketloop + } continue } k := *((*uint64)(add(unsafe.Pointer(b), dataOffset+i*8))) @@ -189,7 +193,7 @@ func mapassign_fast64ptr(t *maptype, h *hmap, key unsafe.Pointer) unsafe.Pointer hash := t.key.hashfn(noescape(unsafe.Pointer(&key)), uintptr(h.hash0)) // Set hashWriting after calling alg.hash for consistency with mapassign. - h.flags |= hashWriting + h.flags ^= hashWriting if h.buckets == nil { h.buckets = newobject(t.bucket) // newarray(t.bucket, 1) @@ -206,13 +210,17 @@ again: var inserti uintptr var insertk unsafe.Pointer +bucketloop: for { for i := uintptr(0); i < bucketCnt; i++ { - if b.tophash[i] == empty { + if isEmpty(b.tophash[i]) { if insertb == nil { insertb = b inserti = i } + if b.tophash[i] == emptyRest { + break bucketloop + } continue } k := *((*unsafe.Pointer)(add(unsafe.Pointer(b), dataOffset+i*8))) @@ -276,17 +284,18 @@ func mapdelete_fast64(t *maptype, h *hmap, key uint64) { hash := t.key.hashfn(noescape(unsafe.Pointer(&key)), uintptr(h.hash0)) // Set hashWriting after calling alg.hash for consistency with mapdelete - h.flags |= hashWriting + h.flags ^= hashWriting bucket := hash & bucketMask(h.B) if h.growing() { growWork_fast64(t, h, bucket) } b := (*bmap)(add(h.buckets, bucket*uintptr(t.bucketsize))) + bOrig := b search: for ; b != nil; b = b.overflow(t) { for i, k := uintptr(0), b.keys(); i < bucketCnt; i, k = i+1, add(k, 8) { - if key != *(*uint64)(k) || b.tophash[i] == empty { + if key != *(*uint64)(k) || isEmpty(b.tophash[i]) { continue } // Only clear key if there are pointers in it. @@ -299,7 +308,37 @@ search: } else { memclrNoHeapPointers(v, t.elem.size) } - b.tophash[i] = empty + b.tophash[i] = emptyOne + // If the bucket now ends in a bunch of emptyOne states, + // change those to emptyRest states. + if i == bucketCnt-1 { + if b.overflow(t) != nil && b.overflow(t).tophash[0] != emptyRest { + goto notLast + } + } else { + if b.tophash[i+1] != emptyRest { + goto notLast + } + } + for { + b.tophash[i] = emptyRest + if i == 0 { + if b == bOrig { + break // beginning of initial bucket, we're done. + } + // Find previous bucket, continue at its last entry. + c := b + for b = bOrig; b.overflow(t) != c; b = b.overflow(t) { + } + i = bucketCnt - 1 + } else { + i-- + } + if b.tophash[i] != emptyOne { + break + } + } + notLast: h.count-- break search } @@ -350,7 +389,7 @@ func evacuate_fast64(t *maptype, h *hmap, oldbucket uintptr) { v := add(k, bucketCnt*8) for i := 0; i < bucketCnt; i, k, v = i+1, add(k, 8), add(v, uintptr(t.valuesize)) { top := b.tophash[i] - if top == empty { + if isEmpty(top) { b.tophash[i] = evacuatedEmpty continue } diff --git a/libgo/go/runtime/map_faststr.go b/libgo/go/runtime/map_faststr.go index 5812b3f1049..eced15a6d5d 100644 --- a/libgo/go/runtime/map_faststr.go +++ b/libgo/go/runtime/map_faststr.go @@ -28,7 +28,10 @@ func mapaccess1_faststr(t *maptype, h *hmap, ky string) unsafe.Pointer { // short key, doing lots of comparisons is ok for i, kptr := uintptr(0), b.keys(); i < bucketCnt; i, kptr = i+1, add(kptr, 2*sys.PtrSize) { k := (*stringStruct)(kptr) - if k.len != key.len || b.tophash[i] == empty { + if k.len != key.len || isEmpty(b.tophash[i]) { + if b.tophash[i] == emptyRest { + break + } continue } if k.str == key.str || memequal(k.str, key.str, uintptr(key.len)) { @@ -41,7 +44,10 @@ func mapaccess1_faststr(t *maptype, h *hmap, ky string) unsafe.Pointer { keymaybe := uintptr(bucketCnt) for i, kptr := uintptr(0), b.keys(); i < bucketCnt; i, kptr = i+1, add(kptr, 2*sys.PtrSize) { k := (*stringStruct)(kptr) - if k.len != key.len || b.tophash[i] == empty { + if k.len != key.len || isEmpty(b.tophash[i]) { + if b.tophash[i] == emptyRest { + break + } continue } if k.str == key.str { @@ -117,7 +123,10 @@ func mapaccess2_faststr(t *maptype, h *hmap, ky string) (unsafe.Pointer, bool) { // short key, doing lots of comparisons is ok for i, kptr := uintptr(0), b.keys(); i < bucketCnt; i, kptr = i+1, add(kptr, 2*sys.PtrSize) { k := (*stringStruct)(kptr) - if k.len != key.len || b.tophash[i] == empty { + if k.len != key.len || isEmpty(b.tophash[i]) { + if b.tophash[i] == emptyRest { + break + } continue } if k.str == key.str || memequal(k.str, key.str, uintptr(key.len)) { @@ -130,7 +139,10 @@ func mapaccess2_faststr(t *maptype, h *hmap, ky string) (unsafe.Pointer, bool) { keymaybe := uintptr(bucketCnt) for i, kptr := uintptr(0), b.keys(); i < bucketCnt; i, kptr = i+1, add(kptr, 2*sys.PtrSize) { k := (*stringStruct)(kptr) - if k.len != key.len || b.tophash[i] == empty { + if k.len != key.len || isEmpty(b.tophash[i]) { + if b.tophash[i] == emptyRest { + break + } continue } if k.str == key.str { @@ -202,7 +214,7 @@ func mapassign_faststr(t *maptype, h *hmap, s string) unsafe.Pointer { hash := t.key.hashfn(noescape(unsafe.Pointer(&s)), uintptr(h.hash0)) // Set hashWriting after calling alg.hash for consistency with mapassign. - h.flags |= hashWriting + h.flags ^= hashWriting if h.buckets == nil { h.buckets = newobject(t.bucket) // newarray(t.bucket, 1) @@ -220,13 +232,17 @@ again: var inserti uintptr var insertk unsafe.Pointer +bucketloop: for { for i := uintptr(0); i < bucketCnt; i++ { if b.tophash[i] != top { - if b.tophash[i] == empty && insertb == nil { + if isEmpty(b.tophash[i]) && insertb == nil { insertb = b inserti = i } + if b.tophash[i] == emptyRest { + break bucketloop + } continue } k := (*stringStruct)(add(unsafe.Pointer(b), dataOffset+i*2*sys.PtrSize)) @@ -294,13 +310,14 @@ func mapdelete_faststr(t *maptype, h *hmap, ky string) { hash := t.key.hashfn(noescape(unsafe.Pointer(&ky)), uintptr(h.hash0)) // Set hashWriting after calling alg.hash for consistency with mapdelete - h.flags |= hashWriting + h.flags ^= hashWriting bucket := hash & bucketMask(h.B) if h.growing() { growWork_faststr(t, h, bucket) } b := (*bmap)(add(h.buckets, bucket*uintptr(t.bucketsize))) + bOrig := b top := tophash(hash) search: for ; b != nil; b = b.overflow(t) { @@ -320,7 +337,37 @@ search: } else { memclrNoHeapPointers(v, t.elem.size) } - b.tophash[i] = empty + b.tophash[i] = emptyOne + // If the bucket now ends in a bunch of emptyOne states, + // change those to emptyRest states. + if i == bucketCnt-1 { + if b.overflow(t) != nil && b.overflow(t).tophash[0] != emptyRest { + goto notLast + } + } else { + if b.tophash[i+1] != emptyRest { + goto notLast + } + } + for { + b.tophash[i] = emptyRest + if i == 0 { + if b == bOrig { + break // beginning of initial bucket, we're done. + } + // Find previous bucket, continue at its last entry. + c := b + for b = bOrig; b.overflow(t) != c; b = b.overflow(t) { + } + i = bucketCnt - 1 + } else { + i-- + } + if b.tophash[i] != emptyOne { + break + } + } + notLast: h.count-- break search } @@ -371,7 +418,7 @@ func evacuate_faststr(t *maptype, h *hmap, oldbucket uintptr) { v := add(k, bucketCnt*2*sys.PtrSize) for i := 0; i < bucketCnt; i, k, v = i+1, add(k, 2*sys.PtrSize), add(v, uintptr(t.valuesize)) { top := b.tophash[i] - if top == empty { + if isEmpty(top) { b.tophash[i] = evacuatedEmpty continue } diff --git a/libgo/go/runtime/map_test.go b/libgo/go/runtime/map_test.go index 13f1d2ea62a..bc5f738c4fa 100644 --- a/libgo/go/runtime/map_test.go +++ b/libgo/go/runtime/map_test.go @@ -1147,3 +1147,28 @@ func TestIncrementAfterBulkClearKeyStringValueInt(t *testing.T) { t.Errorf("incremented 0 to %d", n2) } } + +func TestMapTombstones(t *testing.T) { + m := map[int]int{} + const N = 10000 + // Fill a map. + for i := 0; i < N; i++ { + m[i] = i + } + runtime.MapTombstoneCheck(m) + // Delete half of the entries. + for i := 0; i < N; i += 2 { + delete(m, i) + } + runtime.MapTombstoneCheck(m) + // Add new entries to fill in holes. + for i := N; i < 3*N/2; i++ { + m[i] = i + } + runtime.MapTombstoneCheck(m) + // Delete everything. + for i := 0; i < 3*N/2; i++ { + delete(m, i) + } + runtime.MapTombstoneCheck(m) +} diff --git a/libgo/go/runtime/mbarrier.go b/libgo/go/runtime/mbarrier.go index 48713157601..d3ffd3c518d 100644 --- a/libgo/go/runtime/mbarrier.go +++ b/libgo/go/runtime/mbarrier.go @@ -215,8 +215,6 @@ func reflect_typedmemmovepartial(typ *_type, dst, src unsafe.Pointer, off, size //go:nosplit func typedslicecopy(typ *_type, dst, src slice) int { - // TODO(rsc): If typedslicecopy becomes faster than calling - // typedmemmove repeatedly, consider using during func growslice. n := dst.len if n > src.len { n = src.len diff --git a/libgo/go/runtime/mbitmap.go b/libgo/go/runtime/mbitmap.go index 42c2015ee44..9c25a215f35 100644 --- a/libgo/go/runtime/mbitmap.go +++ b/libgo/go/runtime/mbitmap.go @@ -242,7 +242,7 @@ func (s *mspan) nextFreeIndex() uintptr { return result } -// isFree returns whether the index'th object in s is unallocated. +// isFree reports whether the index'th object in s is unallocated. func (s *mspan) isFree(index uintptr) bool { if index < s.freeindex { return false @@ -283,9 +283,7 @@ func (m markBits) isMarked() bool { return *m.bytep&m.mask != 0 } -// setMarked sets the marked bit in the markbits, atomically. Some compilers -// are not able to inline atomic.Or8 function so if it appears as a hot spot consider -// inlining it manually. +// setMarked sets the marked bit in the markbits, atomically. func (m markBits) setMarked() { // Might be racing with other updates, so use atomic update always. // We used to be clever here and use a non-atomic update in certain @@ -368,7 +366,7 @@ func findObject(p, refBase, refOff uintptr, forStack bool) (base uintptr, s *msp s = spanOf(p) // If p is a bad pointer, it may not be in s's bounds. if s == nil || p < s.base() || p >= s.limit || s.state != mSpanInUse { - if s == nil || s.state == _MSpanManual || forStack { + if s == nil || s.state == mSpanManual || forStack { // If s is nil, the virtual address has never been part of the heap. // This pointer may be to some mmap'd region, so we allow it. // Pointers into stacks are also ok, the runtime manages these explicitly. @@ -533,7 +531,7 @@ func (h heapBits) bits() uint32 { return uint32(*h.bitp) >> (h.shift & 31) } -// morePointers returns true if this word and all remaining words in this object +// morePointers reports whether this word and all remaining words in this object // are scalars. // h must not describe the second word of the object. func (h heapBits) morePointers() bool { @@ -631,7 +629,7 @@ func bulkBarrierPreWrite(dst, src, size uintptr) { } } return - } else if s.state != _MSpanInUse || dst < s.base() || s.limit <= dst { + } else if s.state != mSpanInUse || dst < s.base() || s.limit <= dst { // dst was heap memory at some point, but isn't now. // It can't be a global. It must be either our stack, // or in the case of direct channel sends, it could be @@ -667,6 +665,35 @@ func bulkBarrierPreWrite(dst, src, size uintptr) { } } +// bulkBarrierPreWriteSrcOnly is like bulkBarrierPreWrite but +// does not execute write barriers for [dst, dst+size). +// +// In addition to the requirements of bulkBarrierPreWrite +// callers need to ensure [dst, dst+size) is zeroed. +// +// This is used for special cases where e.g. dst was just +// created and zeroed with malloc. +//go:nosplit +func bulkBarrierPreWriteSrcOnly(dst, src, size uintptr) { + if (dst|src|size)&(sys.PtrSize-1) != 0 { + throw("bulkBarrierPreWrite: unaligned arguments") + } + if !writeBarrier.needed { + return + } + buf := &getg().m.p.ptr().wbBuf + h := heapBitsForAddr(dst) + for i := uintptr(0); i < size; i += sys.PtrSize { + if h.isPointer() { + srcx := (*uintptr)(unsafe.Pointer(src + i)) + if !buf.putFast(0, *srcx) { + wbBufFlush(nil, 0) + } + } + h = h.next() + } +} + // bulkBarrierBitmap executes write barriers for copying from [src, // src+size) to [dst, dst+size) using a 1-bit pointer bitmap. src is // assumed to start maskOffset bytes into the data covered by the @@ -1902,6 +1929,20 @@ Run: return totalBits } +// materializeGCProg allocates space for the (1-bit) pointer bitmask +// for an object of size ptrdata. Then it fills that space with the +// pointer bitmask specified by the program prog. +// The bitmask starts at s.startAddr. +// The result must be deallocated with dematerializeGCProg. +func materializeGCProg(ptrdata uintptr, prog *byte) *mspan { + s := mheap_.allocManual((ptrdata/(8*sys.PtrSize)+pageSize-1)/pageSize, &memstats.gc_sys) + runGCProg(addb(prog, 4), nil, (*byte)(unsafe.Pointer(s.startAddr)), 1) + return s +} +func dematerializeGCProg(s *mspan) { + mheap_.freeManual(s, &memstats.gc_sys) +} + func dumpGCProg(p *byte) { nptr := 0 for { @@ -1962,7 +2003,9 @@ func reflect_gcbits(x interface{}) []byte { return ret } -// Returns GC type info for object p for testing. +// Returns GC type info for the pointer stored in ep for testing. +// If ep points to the stack, only static live information will be returned +// (i.e. not for objects which are only dynamically live stack objects). func getgcmask(ep interface{}) (mask []byte) { e := *efaceOf(&ep) p := e.data diff --git a/libgo/go/runtime/mcache.go b/libgo/go/runtime/mcache.go index 3dacf9692ec..2045158636a 100644 --- a/libgo/go/runtime/mcache.go +++ b/libgo/go/runtime/mcache.go @@ -4,7 +4,10 @@ package runtime -import "unsafe" +import ( + "runtime/internal/atomic" + "unsafe" +) // Per-thread (in Go, per-P) cache for small objects. // No locking needed because it is per-thread (per-P). @@ -40,6 +43,12 @@ type mcache struct { local_largefree uintptr // bytes freed for large objects (>maxsmallsize) local_nlargefree uintptr // number of frees for large objects (>maxsmallsize) local_nsmallfree [_NumSizeClasses]uintptr // number of frees for small objects (<=maxsmallsize) + + // flushGen indicates the sweepgen during which this mcache + // was last flushed. If flushGen != mheap_.sweepgen, the spans + // in this mcache are stale and need to the flushed so they + // can be swept. This is done in acquirep. + flushGen uint32 } // A gclink is a node in a linked list of blocks, like mlink, @@ -63,12 +72,13 @@ func (p gclinkptr) ptr() *gclink { return (*gclink)(unsafe.Pointer(p)) } -// dummy MSpan that contains no free objects. +// dummy mspan that contains no free objects. var emptymspan mspan func allocmcache() *mcache { lock(&mheap_.lock) c := (*mcache)(mheap_.cachealloc.alloc()) + c.flushGen = mheap_.sweepgen unlock(&mheap_.lock) for i := range c.alloc { c.alloc[i] = &emptymspan @@ -93,21 +103,24 @@ func freemcache(c *mcache) { }) } -// Gets a span that has a free object in it and assigns it -// to be the cached span for the given sizeclass. Returns this span. +// refill acquires a new span of span class spc for c. This span will +// have at least one free object. The current span in c must be full. +// +// Must run in a non-preemptible context since otherwise the owner of +// c could change. func (c *mcache) refill(spc spanClass) { - _g_ := getg() - - _g_.m.locks++ // Return the current cached span to the central lists. s := c.alloc[spc] if uintptr(s.allocCount) != s.nelems { throw("refill of span with free space remaining") } - if s != &emptymspan { - s.incache = false + // Mark this span as no longer cached. + if s.sweepgen != mheap_.sweepgen+3 { + throw("bad sweepgen in refill") + } + atomic.Store(&s.sweepgen, mheap_.sweepgen) } // Get a new cached span from the central lists. @@ -120,8 +133,11 @@ func (c *mcache) refill(spc spanClass) { throw("span has no free space") } + // Indicate that this span is cached and prevent asynchronous + // sweeping in the next sweep phase. + s.sweepgen = mheap_.sweepgen + 3 + c.alloc[spc] = s - _g_.m.locks-- } func (c *mcache) releaseAll() { @@ -136,3 +152,25 @@ func (c *mcache) releaseAll() { c.tiny = 0 c.tinyoffset = 0 } + +// prepareForSweep flushes c if the system has entered a new sweep phase +// since c was populated. This must happen between the sweep phase +// starting and the first allocation from c. +func (c *mcache) prepareForSweep() { + // Alternatively, instead of making sure we do this on every P + // between starting the world and allocating on that P, we + // could leave allocate-black on, allow allocation to continue + // as usual, use a ragged barrier at the beginning of sweep to + // ensure all cached spans are swept, and then disable + // allocate-black. However, with this approach it's difficult + // to avoid spilling mark bits into the *next* GC cycle. + sg := mheap_.sweepgen + if c.flushGen == sg { + return + } else if c.flushGen != sg-2 { + println("bad flushGen", c.flushGen, "in prepareForSweep; sweepgen", sg) + throw("bad flushGen") + } + c.releaseAll() + atomic.Store(&c.flushGen, mheap_.sweepgen) // Synchronizes with gcStart +} diff --git a/libgo/go/runtime/mcentral.go b/libgo/go/runtime/mcentral.go index 50a4791e8e6..0196ba44c5d 100644 --- a/libgo/go/runtime/mcentral.go +++ b/libgo/go/runtime/mcentral.go @@ -6,8 +6,8 @@ // // See malloc.go for an overview. // -// The MCentral doesn't actually contain the list of free objects; the MSpan does. -// Each MCentral is two lists of MSpans: those with free objects (c->nonempty) +// The mcentral doesn't actually contain the list of free objects; the mspan does. +// Each mcentral is two lists of mspans: those with free objects (c->nonempty) // and those that are completely allocated (c->empty). package runtime @@ -36,7 +36,7 @@ func (c *mcentral) init(spc spanClass) { c.empty.init() } -// Allocate a span to use in an MCache. +// Allocate a span to use in an mcache. func (c *mcentral) cacheSpan() *mspan { // Deduct credit for this span allocation and sweep if necessary. spanBytes := uintptr(class_to_allocnpages[c.spanclass.sizeclass()]) * _PageSize @@ -126,8 +126,7 @@ havespan: if trace.enabled && !traceDone { traceGCSweepDone() } - cap := int32((s.npages << _PageShift) / s.elemsize) - n := cap - int32(s.allocCount) + n := int(s.nelems) - int(s.allocCount) if n == 0 || s.freeindex == s.nelems || uintptr(s.allocCount) == s.nelems { throw("span has no free objects") } @@ -144,7 +143,6 @@ havespan: // heap_live changed. gcController.revise() } - s.incache = true freeByteBase := s.freeindex &^ (64 - 1) whichByte := freeByteBase / 8 // Init alloc bits cache. @@ -157,30 +155,56 @@ havespan: return s } -// Return span from an MCache. +// Return span from an mcache. func (c *mcentral) uncacheSpan(s *mspan) { - lock(&c.lock) - - s.incache = false - if s.allocCount == 0 { throw("uncaching span but s.allocCount == 0") } - cap := int32((s.npages << _PageShift) / s.elemsize) - n := cap - int32(s.allocCount) + sg := mheap_.sweepgen + stale := s.sweepgen == sg+1 + if stale { + // Span was cached before sweep began. It's our + // responsibility to sweep it. + // + // Set sweepgen to indicate it's not cached but needs + // sweeping and can't be allocated from. sweep will + // set s.sweepgen to indicate s is swept. + atomic.Store(&s.sweepgen, sg-1) + } else { + // Indicate that s is no longer cached. + atomic.Store(&s.sweepgen, sg) + } + + n := int(s.nelems) - int(s.allocCount) if n > 0 { - c.empty.remove(s) - c.nonempty.insert(s) - // mCentral_CacheSpan conservatively counted - // unallocated slots in heap_live. Undo this. - atomic.Xadd64(&memstats.heap_live, -int64(n)*int64(s.elemsize)) // cacheSpan updated alloc assuming all objects on s // were going to be allocated. Adjust for any that - // weren't. + // weren't. We must do this before potentially + // sweeping the span. atomic.Xadd64(&c.nmalloc, -int64(n)) + + lock(&c.lock) + c.empty.remove(s) + c.nonempty.insert(s) + if !stale { + // mCentral_CacheSpan conservatively counted + // unallocated slots in heap_live. Undo this. + // + // If this span was cached before sweep, then + // heap_live was totally recomputed since + // caching this span, so we don't do this for + // stale spans. + atomic.Xadd64(&memstats.heap_live, -int64(n)*int64(s.elemsize)) + } + unlock(&c.lock) + } + + if stale { + // Now that s is in the right mcentral list, we can + // sweep it. + s.sweep(false) } - unlock(&c.lock) } // freeSpan updates c and s after sweeping s. @@ -188,17 +212,17 @@ func (c *mcentral) uncacheSpan(s *mspan) { // and, based on the number of free objects in s, // moves s to the appropriate list of c or returns it // to the heap. -// freeSpan returns true if s was returned to the heap. +// freeSpan reports whether s was returned to the heap. // If preserve=true, it does not move s (the caller // must take care of it). func (c *mcentral) freeSpan(s *mspan, preserve bool, wasempty bool) bool { - if s.incache { + if sg := mheap_.sweepgen; s.sweepgen == sg+1 || s.sweepgen == sg+3 { throw("freeSpan given cached span") } s.needzero = 1 if preserve { - // preserve is set only when called from MCentral_CacheSpan above, + // preserve is set only when called from (un)cacheSpan above, // the span must be in the empty list. if !s.inList() { throw("can't preserve unlinked span") @@ -216,7 +240,7 @@ func (c *mcentral) freeSpan(s *mspan, preserve bool, wasempty bool) bool { } // delay updating sweepgen until here. This is the signal that - // the span may be used in an MCache, so it must come after the + // the span may be used in an mcache, so it must come after the // linked list operations above (actually, just after the // lock of c above.) atomic.Store(&s.sweepgen, mheap_.sweepgen) @@ -228,7 +252,7 @@ func (c *mcentral) freeSpan(s *mspan, preserve bool, wasempty bool) bool { c.nonempty.remove(s) unlock(&c.lock) - mheap_.freeSpan(s, 0) + mheap_.freeSpan(s, false) return true } diff --git a/libgo/go/runtime/mfinal.go b/libgo/go/runtime/mfinal.go index 1a7792c2205..caf2e7e1cce 100644 --- a/libgo/go/runtime/mfinal.go +++ b/libgo/go/runtime/mfinal.go @@ -135,6 +135,7 @@ func runfinq() { ) gp := getg() + gp.isFinalizerGoroutine = true for { lock(&finlock) fb := finq diff --git a/libgo/go/runtime/mfixalloc.go b/libgo/go/runtime/mfixalloc.go index 1febe782bb6..f9dd6ca474d 100644 --- a/libgo/go/runtime/mfixalloc.go +++ b/libgo/go/runtime/mfixalloc.go @@ -12,7 +12,7 @@ import "unsafe" // FixAlloc is a simple free-list allocator for fixed size objects. // Malloc uses a FixAlloc wrapped around sysAlloc to manage its -// MCache and MSpan objects. +// mcache and mspan objects. // // Memory returned by fixalloc.alloc is zeroed by default, but the // caller may take responsibility for zeroing allocations by setting diff --git a/libgo/go/runtime/mgc.go b/libgo/go/runtime/mgc.go index de84084b391..0973f1de6f7 100644 --- a/libgo/go/runtime/mgc.go +++ b/libgo/go/runtime/mgc.go @@ -28,8 +28,7 @@ // b. Sweep any unswept spans. There will only be unswept spans if // this GC cycle was forced before the expected time. // -// 2. GC performs the "mark 1" sub-phase. In this sub-phase, Ps are -// allowed to locally cache parts of the work queue. +// 2. GC performs the mark phase. // // a. Prepare for the mark phase by setting gcphase to _GCmark // (from _GCoff), enabling the write barrier, enabling mutator @@ -54,28 +53,21 @@ // object to black and shading all pointers found in the object // (which in turn may add those pointers to the work queue). // -// 3. Once the global work queue is empty (but local work queue caches -// may still contain work), GC performs the "mark 2" sub-phase. +// e. Because GC work is spread across local caches, GC uses a +// distributed termination algorithm to detect when there are no +// more root marking jobs or grey objects (see gcMarkDone). At this +// point, GC transitions to mark termination. // -// a. GC stops all workers, disables local work queue caches, -// flushes each P's local work queue cache to the global work queue -// cache, and reenables workers. -// -// b. GC again drains the work queue, as in 2d above. -// -// 4. Once the work queue is empty, GC performs mark termination. +// 3. GC performs mark termination. // // a. Stop the world. // // b. Set gcphase to _GCmarktermination, and disable workers and // assists. // -// c. Drain any remaining work from the work queue (typically there -// will be none). -// -// d. Perform other housekeeping like flushing mcaches. +// c. Perform housekeeping like flushing mcaches. // -// 5. GC performs the sweep phase. +// 4. GC performs the sweep phase. // // a. Prepare for the sweep phase by setting gcphase to _GCoff, // setting up sweep state and disabling the write barrier. @@ -86,7 +78,7 @@ // c. GC does concurrent sweeping in the background and in response // to allocation. See description below. // -// 6. When sufficient allocation has taken place, replay the sequence +// 5. When sufficient allocation has taken place, replay the sequence // starting with 1 above. See discussion of GC rate below. // Concurrent sweep. @@ -137,8 +129,8 @@ package runtime import ( + "internal/cpu" "runtime/internal/atomic" - "runtime/internal/sys" "unsafe" ) @@ -262,21 +254,6 @@ var writeBarrier struct { // gcphase == _GCmark. var gcBlackenEnabled uint32 -// gcBlackenPromptly indicates that optimizations that may -// hide work from the global work queue should be disabled. -// -// If gcBlackenPromptly is true, per-P gcWork caches should -// be flushed immediately and new objects should be allocated black. -// -// There is a tension between allocating objects white and -// allocating them black. If white and the objects die before being -// marked they can be collected during this GC cycle. On the other -// hand allocating them black will reduce _GCmarktermination latency -// since more work is done in the mark phase. This tension is resolved -// by allocating white until the mark phase is approaching its end and -// then allocating black for the remainder of the mark phase. -var gcBlackenPromptly bool - const ( _GCoff = iota // GC not running; sweeping in background, write barrier disabled _GCmark // GC marking roots and workbufs: allocate black, write barrier ENABLED @@ -408,14 +385,14 @@ type gcControllerState struct { // each P that isn't running a dedicated worker. // // For example, if the utilization goal is 25% and there are - // no dedicated workers, this will be 0.25. If there goal is + // no dedicated workers, this will be 0.25. If the goal is // 25%, there is one dedicated worker, and GOMAXPROCS is 5, // this will be 0.05 to make up the missing 5%. // // If this is zero, no fractional workers are needed. fractionalUtilizationGoal float64 - _ [sys.CacheLineSize]byte + _ cpu.CacheLinePad } // startCycle resets the GC controller's state and computes estimates @@ -479,6 +456,12 @@ func (c *gcControllerState) startCycle() { c.fractionalUtilizationGoal = 0 } + // In STW mode, we just want dedicated workers. + if debug.gcstoptheworld > 0 { + c.dedicatedMarkWorkersNeeded = int64(gomaxprocs) + c.fractionalUtilizationGoal = 0 + } + // Clear per-P state for _, p := range allp { p.gcAssistTime = 0 @@ -753,7 +736,7 @@ func (c *gcControllerState) findRunnableGCWorker(_p_ *p) *g { return gp } -// pollFractionalWorkerExit returns true if a fractional mark worker +// pollFractionalWorkerExit reports whether a fractional mark worker // should self-preempt. It assumes it is called from the fractional // worker. func pollFractionalWorkerExit() bool { @@ -807,7 +790,7 @@ func gcSetTriggerRatio(triggerRatio float64) { trigger = uint64(float64(memstats.heap_marked) * (1 + triggerRatio)) // Don't trigger below the minimum heap size. minTrigger := heapminimum - if !gosweepdone() { + if !isSweepDone() { // Concurrent sweep happens in the heap growth // from heap_live to gc_trigger, so ensure // that concurrent sweep has some heap growth @@ -852,7 +835,7 @@ func gcSetTriggerRatio(triggerRatio float64) { } // Update sweep pacing. - if gosweepdone() { + if isSweepDone() { mheap_.sweepPagesPerByte = 0 } else { // Concurrent sweep needs to sweep all of the in-use @@ -902,7 +885,7 @@ const gcGoalUtilization = 0.30 // mutator latency. const gcBackgroundUtilization = 0.25 -// gcCreditSlack is the amount of scan work credit that can can +// gcCreditSlack is the amount of scan work credit that can // accumulate locally before updating gcController.scanWork and, // optionally, gcController.bgScanCredit. Lower values give a more // accurate assist ratio and make it more likely that assists will @@ -920,9 +903,9 @@ const gcAssistTimeSlack = 5000 const gcOverAssistWork = 64 << 10 var work struct { - full lfstack // lock-free list of full blocks workbuf - empty lfstack // lock-free list of empty blocks workbuf - pad0 [sys.CacheLineSize]uint8 // prevents false-sharing between full/empty and nproc/nwait + full lfstack // lock-free list of full blocks workbuf + empty lfstack // lock-free list of empty blocks workbuf + pad0 cpu.CacheLinePad // prevents false-sharing between full/empty and nproc/nwait wbufSpans struct { lock mutex @@ -956,32 +939,15 @@ var work struct { markrootNext uint32 // next markroot job markrootJobs uint32 // number of markroot jobs - nproc uint32 - tstart int64 - nwait uint32 - ndone uint32 - alldone note - - // helperDrainBlock indicates that GC mark termination helpers - // should pass gcDrainBlock to gcDrain to block in the - // getfull() barrier. Otherwise, they should pass gcDrainNoBlock. - // - // TODO: This is a temporary fallback to work around races - // that cause early mark termination. - helperDrainBlock bool + nproc uint32 + tstart int64 + nwait uint32 + ndone uint32 // Number of roots of various root types. Set by gcMarkRootPrepare. nFlushCacheRoots int nDataRoots, nSpanRoots, nStackRoots int - // markrootDone indicates that roots have been marked at least - // once during the current GC cycle. This is checked by root - // marking operations that have to happen only during the - // first root marking pass, whether that's during the - // concurrent mark phase in current GC or mark termination in - // STW GC. - markrootDone bool - // Each type of GC state transition is protected by a lock. // Since multiple threads can simultaneously detect the state // transition condition, any thread that detects a transition @@ -997,8 +963,7 @@ var work struct { // startSema protects the transition from "off" to mark or // mark termination. startSema uint32 - // markDoneSema protects transitions from mark 1 to mark 2 and - // from mark 2 to mark termination. + // markDoneSema protects transitions from mark to mark termination. markDoneSema uint32 bgMarkReady note // signal background mark worker has started @@ -1024,15 +989,15 @@ var work struct { // there was neither enough credit to steal or enough work to // do. assistQueue struct { - lock mutex - head, tail guintptr + lock mutex + q gQueue } // sweepWaiters is a list of blocked goroutines to wake when // we transition from mark termination to sweep. sweepWaiters struct { lock mutex - head guintptr + list gList } // cycles is the number of completed GC cycles, where a GC @@ -1088,7 +1053,7 @@ func GC() { // We're now in sweep N or later. Trigger GC cycle N+1, which // will first finish sweep N if necessary and then enter sweep // termination N+1. - gcStart(gcBackgroundMode, gcTrigger{kind: gcTriggerCycle, n: n + 1}) + gcStart(gcTrigger{kind: gcTriggerCycle, n: n + 1}) // Wait for mark termination N+1 to complete. gcWaitOnMark(n + 1) @@ -1097,7 +1062,7 @@ func GC() { // complete the cycle and because runtime.GC() is often used // as part of tests and benchmarks to get the system into a // relatively stable and isolated state. - for atomic.Load(&work.cycles) == n+1 && gosweepone() != ^uintptr(0) { + for atomic.Load(&work.cycles) == n+1 && sweepone() != ^uintptr(0) { sweep.nbgsweep++ Gosched() } @@ -1147,9 +1112,7 @@ func gcWaitOnMark(n uint32) { // Wait until sweep termination, mark, and mark // termination of cycle N complete. - gp := getg() - gp.schedlink = work.sweepWaiters.head - work.sweepWaiters.head.set(gp) + work.sweepWaiters.list.push(getg()) goparkunlock(&work.sweepWaiters.lock, waitReasonWaitForGCCycle, traceEvGoBlock, 1) } } @@ -1195,7 +1158,7 @@ const ( gcTriggerCycle ) -// test returns true if the trigger condition is satisfied, meaning +// test reports whether the trigger condition is satisfied, meaning // that the exit condition for the _GCoff phase has been met. The exit // condition should be tested when allocating. func (t gcTrigger) test() bool { @@ -1228,13 +1191,13 @@ func (t gcTrigger) test() bool { return true } -// gcStart transitions the GC from _GCoff to _GCmark (if -// !mode.stwMark) or _GCmarktermination (if mode.stwMark) by -// performing sweep termination and GC initialization. +// gcStart starts the GC. It transitions from _GCoff to _GCmark (if +// debug.gcstoptheworld == 0) or performs all of GC (if +// debug.gcstoptheworld != 0). // // This may return without performing this transition in some cases, // such as when called on a system stack or with locks held. -func gcStart(mode gcMode, trigger gcTrigger) { +func gcStart(trigger gcTrigger) { // Since this is called from malloc and malloc is called in // the guts of a number of libraries that might be holding // locks, don't attempt to start GC in non-preemptible or @@ -1257,7 +1220,7 @@ func gcStart(mode gcMode, trigger gcTrigger) { // // We check the transition condition continuously here in case // this G gets delayed in to the next GC cycle. - for trigger.test() && gosweepone() != ^uintptr(0) { + for trigger.test() && sweepone() != ^uintptr(0) { sweep.nbgsweep++ } @@ -1277,12 +1240,11 @@ func gcStart(mode gcMode, trigger gcTrigger) { // We do this after re-checking the transition condition so // that multiple goroutines that detect the heap trigger don't // start multiple STW GCs. - if mode == gcBackgroundMode { - if debug.gcstoptheworld == 1 { - mode = gcForceMode - } else if debug.gcstoptheworld == 2 { - mode = gcForceBlockMode - } + mode := gcBackgroundMode + if debug.gcstoptheworld == 1 { + mode = gcForceMode + } else if debug.gcstoptheworld == 2 { + mode = gcForceBlockMode } // Ok, we're doing it! Stop everybody else @@ -1292,10 +1254,16 @@ func gcStart(mode gcMode, trigger gcTrigger) { traceGCStart() } - if mode == gcBackgroundMode { - gcBgMarkStartWorkers() + // Check that all Ps have finished deferred mcache flushes. + for _, p := range allp { + if fg := atomic.Load(&p.mcache.flushGen); fg != mheap_.sweepgen { + println("runtime: p", p.id, "flushGen", fg, "!= sweepgen", mheap_.sweepgen) + throw("p mcache not flushed") + } } + gcBgMarkStartWorkers() + gcResetMarkState() work.stwprocs, work.maxprocs = gomaxprocs, gomaxprocs @@ -1324,199 +1292,299 @@ func gcStart(mode gcMode, trigger gcTrigger) { clearpools() work.cycles++ - if mode == gcBackgroundMode { // Do as much work concurrently as possible - gcController.startCycle() - work.heapGoal = memstats.next_gc - // Enter concurrent mark phase and enable - // write barriers. - // - // Because the world is stopped, all Ps will - // observe that write barriers are enabled by - // the time we start the world and begin - // scanning. - // - // Write barriers must be enabled before assists are - // enabled because they must be enabled before - // any non-leaf heap objects are marked. Since - // allocations are blocked until assists can - // happen, we want enable assists as early as - // possible. - setGCPhase(_GCmark) - - gcBgMarkPrepare() // Must happen before assist enable. - gcMarkRootPrepare() - - // Mark all active tinyalloc blocks. Since we're - // allocating from these, they need to be black like - // other allocations. The alternative is to blacken - // the tiny block on every allocation from it, which - // would slow down the tiny allocator. - gcMarkTinyAllocs() - - // At this point all Ps have enabled the write - // barrier, thus maintaining the no white to - // black invariant. Enable mutator assists to - // put back-pressure on fast allocating - // mutators. - atomic.Store(&gcBlackenEnabled, 1) - - // Assists and workers can start the moment we start - // the world. - gcController.markStartTime = now - - // Concurrent mark. - systemstack(func() { - now = startTheWorldWithSema(trace.enabled) - }) + gcController.startCycle() + work.heapGoal = memstats.next_gc + + // In STW mode, disable scheduling of user Gs. This may also + // disable scheduling of this goroutine, so it may block as + // soon as we start the world again. + if mode != gcBackgroundMode { + schedEnableUser(false) + } + + // Enter concurrent mark phase and enable + // write barriers. + // + // Because the world is stopped, all Ps will + // observe that write barriers are enabled by + // the time we start the world and begin + // scanning. + // + // Write barriers must be enabled before assists are + // enabled because they must be enabled before + // any non-leaf heap objects are marked. Since + // allocations are blocked until assists can + // happen, we want enable assists as early as + // possible. + setGCPhase(_GCmark) + + gcBgMarkPrepare() // Must happen before assist enable. + gcMarkRootPrepare() + + // Mark all active tinyalloc blocks. Since we're + // allocating from these, they need to be black like + // other allocations. The alternative is to blacken + // the tiny block on every allocation from it, which + // would slow down the tiny allocator. + gcMarkTinyAllocs() + + // At this point all Ps have enabled the write + // barrier, thus maintaining the no white to + // black invariant. Enable mutator assists to + // put back-pressure on fast allocating + // mutators. + atomic.Store(&gcBlackenEnabled, 1) + + // Assists and workers can start the moment we start + // the world. + gcController.markStartTime = now + + // Concurrent mark. + systemstack(func() { + now = startTheWorldWithSema(trace.enabled) work.pauseNS += now - work.pauseStart work.tMark = now - } else { - if trace.enabled { - // Switch to mark termination STW. - traceGCSTWDone() - traceGCSTWStart(0) - } - t := nanotime() - work.tMark, work.tMarkTerm = t, t - work.heapGoal = work.heap0 - - // Perform mark termination. This will restart the world. - gcMarkTermination(memstats.triggerRatio) + }) + // In STW mode, we could block the instant systemstack + // returns, so don't do anything important here. Make sure we + // block rather than returning to user code. + if mode != gcBackgroundMode { + Gosched() } semrelease(&work.startSema) } -// gcMarkDone transitions the GC from mark 1 to mark 2 and from mark 2 -// to mark termination. +// gcMarkDoneFlushed counts the number of P's with flushed work. // -// This should be called when all mark work has been drained. In mark -// 1, this includes all root marking jobs, global work buffers, and -// active work buffers in assists and background workers; however, -// work may still be cached in per-P work buffers. In mark 2, per-P -// caches are disabled. +// Ideally this would be a captured local in gcMarkDone, but forEachP +// escapes its callback closure, so it can't capture anything. +// +// This is protected by markDoneSema. +var gcMarkDoneFlushed uint32 + +// debugCachedWork enables extra checks for debugging premature mark +// termination. +// +// For debugging issue #27993. +const debugCachedWork = false + +// gcWorkPauseGen is for debugging the mark completion algorithm. +// gcWork put operations spin while gcWork.pauseGen == gcWorkPauseGen. +// Only used if debugCachedWork is true. +// +// For debugging issue #27993. +var gcWorkPauseGen uint32 = 1 + +// gcMarkDone transitions the GC from mark to mark termination if all +// reachable objects have been marked (that is, there are no grey +// objects and can be no more in the future). Otherwise, it flushes +// all local work to the global queues where it can be discovered by +// other workers. +// +// This should be called when all local mark work has been drained and +// there are no remaining workers. Specifically, when +// +// work.nwait == work.nproc && !gcMarkWorkAvailable(p) // // The calling context must be preemptible. // -// Note that it is explicitly okay to have write barriers in this -// function because completion of concurrent mark is best-effort -// anyway. Any work created by write barriers here will be cleaned up -// by mark termination. +// Flushing local work is important because idle Ps may have local +// work queued. This is the only way to make that work visible and +// drive GC to completion. +// +// It is explicitly okay to have write barriers in this function. If +// it does transition to mark termination, then all reachable objects +// have been marked, so the write barrier cannot shade any more +// objects. func gcMarkDone() { -top: + // Ensure only one thread is running the ragged barrier at a + // time. semacquire(&work.markDoneSema) +top: // Re-check transition condition under transition lock. + // + // It's critical that this checks the global work queues are + // empty before performing the ragged barrier. Otherwise, + // there could be global work that a P could take after the P + // has passed the ragged barrier. if !(gcphase == _GCmark && work.nwait == work.nproc && !gcMarkWorkAvailable(nil)) { semrelease(&work.markDoneSema) return } - // Disallow starting new workers so that any remaining workers - // in the current mark phase will drain out. - // - // TODO(austin): Should dedicated workers keep an eye on this - // and exit gcDrain promptly? - atomic.Xaddint64(&gcController.dedicatedMarkWorkersNeeded, -0xffffffff) - prevFractionalGoal := gcController.fractionalUtilizationGoal - gcController.fractionalUtilizationGoal = 0 - - if !gcBlackenPromptly { - // Transition from mark 1 to mark 2. - // - // The global work list is empty, but there can still be work - // sitting in the per-P work caches. - // Flush and disable work caches. - - // Disallow caching workbufs and indicate that we're in mark 2. - gcBlackenPromptly = true - - // Prevent completion of mark 2 until we've flushed - // cached workbufs. - atomic.Xadd(&work.nwait, -1) - - // GC is set up for mark 2. Let Gs blocked on the - // transition lock go while we flush caches. - semrelease(&work.markDoneSema) - - systemstack(func() { - // Flush all currently cached workbufs and - // ensure all Ps see gcBlackenPromptly. This - // also blocks until any remaining mark 1 - // workers have exited their loop so we can - // start new mark 2 workers. - forEachP(func(_p_ *p) { - wbBufFlush1(_p_) - _p_.gcw.dispose() - }) + // Flush all local buffers and collect flushedWork flags. + gcMarkDoneFlushed = 0 + systemstack(func() { + gp := getg().m.curg + // Mark the user stack as preemptible so that it may be scanned. + // Otherwise, our attempt to force all P's to a safepoint could + // result in a deadlock as we attempt to preempt a worker that's + // trying to preempt us (e.g. for a stack scan). + casgstatus(gp, _Grunning, _Gwaiting) + forEachP(func(_p_ *p) { + // Flush the write barrier buffer, since this may add + // work to the gcWork. + wbBufFlush1(_p_) + // For debugging, shrink the write barrier + // buffer so it flushes immediately. + // wbBuf.reset will keep it at this size as + // long as throwOnGCWork is set. + if debugCachedWork { + b := &_p_.wbBuf + b.end = uintptr(unsafe.Pointer(&b.buf[wbBufEntryPointers])) + b.debugGen = gcWorkPauseGen + } + // Flush the gcWork, since this may create global work + // and set the flushedWork flag. + // + // TODO(austin): Break up these workbufs to + // better distribute work. + _p_.gcw.dispose() + // Collect the flushedWork flag. + if _p_.gcw.flushedWork { + atomic.Xadd(&gcMarkDoneFlushed, 1) + _p_.gcw.flushedWork = false + } else if debugCachedWork { + // For debugging, freeze the gcWork + // until we know whether we've reached + // completion or not. If we think + // we've reached completion, but + // there's a paused gcWork, then + // that's a bug. + _p_.gcw.pauseGen = gcWorkPauseGen + // Capture the G's stack. + for i := range _p_.gcw.pauseStack { + _p_.gcw.pauseStack[i].pc = 0 + } + callers(1, _p_.gcw.pauseStack[:]) + } }) + casgstatus(gp, _Gwaiting, _Grunning) + }) - // Check that roots are marked. We should be able to - // do this before the forEachP, but based on issue - // #16083 there may be a (harmless) race where we can - // enter mark 2 while some workers are still scanning - // stacks. The forEachP ensures these scans are done. - // - // TODO(austin): Figure out the race and fix this - // properly. - gcMarkRootCheck() + if gcMarkDoneFlushed != 0 { + if debugCachedWork { + // Release paused gcWorks. + atomic.Xadd(&gcWorkPauseGen, 1) + } + // More grey objects were discovered since the + // previous termination check, so there may be more + // work to do. Keep going. It's possible the + // transition condition became true again during the + // ragged barrier, so re-check it. + goto top + } - // Now we can start up mark 2 workers. - atomic.Xaddint64(&gcController.dedicatedMarkWorkersNeeded, 0xffffffff) - gcController.fractionalUtilizationGoal = prevFractionalGoal + if debugCachedWork { + throwOnGCWork = true + // Release paused gcWorks. If there are any, they + // should now observe throwOnGCWork and panic. + atomic.Xadd(&gcWorkPauseGen, 1) + } - incnwait := atomic.Xadd(&work.nwait, +1) - if incnwait == work.nproc && !gcMarkWorkAvailable(nil) { - // This loop will make progress because - // gcBlackenPromptly is now true, so it won't - // take this same "if" branch. - goto top + // There was no global work, no local work, and no Ps + // communicated work since we took markDoneSema. Therefore + // there are no grey objects and no more objects can be + // shaded. Transition to mark termination. + now := nanotime() + work.tMarkTerm = now + work.pauseStart = now + getg().m.preemptoff = "gcing" + if trace.enabled { + traceGCSTWStart(0) + } + systemstack(stopTheWorldWithSema) + // The gcphase is _GCmark, it will transition to _GCmarktermination + // below. The important thing is that the wb remains active until + // all marking is complete. This includes writes made by the GC. + + if debugCachedWork { + // For debugging, double check that no work was added after we + // went around above and disable write barrier buffering. + for _, p := range allp { + gcw := &p.gcw + if !gcw.empty() { + printlock() + print("runtime: P ", p.id, " flushedWork ", gcw.flushedWork) + if gcw.wbuf1 == nil { + print(" wbuf1=") + } else { + print(" wbuf1.n=", gcw.wbuf1.nobj) + } + if gcw.wbuf2 == nil { + print(" wbuf2=") + } else { + print(" wbuf2.n=", gcw.wbuf2.nobj) + } + print("\n") + if gcw.pauseGen == gcw.putGen { + println("runtime: checkPut already failed at this generation") + } + throw("throwOnGCWork") + } } } else { - // Transition to mark termination. - now := nanotime() - work.tMarkTerm = now - work.pauseStart = now - getg().m.preemptoff = "gcing" - if trace.enabled { - traceGCSTWStart(0) + // For unknown reasons (see issue #27993), there is + // sometimes work left over when we enter mark + // termination. Detect this and resume concurrent + // mark. This is obviously unfortunate. + // + // Switch to the system stack to call wbBufFlush1, + // though in this case it doesn't matter because we're + // non-preemptible anyway. + restart := false + systemstack(func() { + for _, p := range allp { + wbBufFlush1(p) + if !p.gcw.empty() { + restart = true + break + } + } + }) + if restart { + getg().m.preemptoff = "" + systemstack(func() { + now := startTheWorldWithSema(true) + work.pauseNS += now - work.pauseStart + }) + goto top } - systemstack(stopTheWorldWithSema) - // The gcphase is _GCmark, it will transition to _GCmarktermination - // below. The important thing is that the wb remains active until - // all marking is complete. This includes writes made by the GC. + } - // Record that one root marking pass has completed. - work.markrootDone = true + // Disable assists and background workers. We must do + // this before waking blocked assists. + atomic.Store(&gcBlackenEnabled, 0) - // Disable assists and background workers. We must do - // this before waking blocked assists. - atomic.Store(&gcBlackenEnabled, 0) + // Wake all blocked assists. These will run when we + // start the world again. + gcWakeAllAssists() - // Wake all blocked assists. These will run when we - // start the world again. - gcWakeAllAssists() + // Likewise, release the transition lock. Blocked + // workers and assists will run when we start the + // world again. + semrelease(&work.markDoneSema) - // Likewise, release the transition lock. Blocked - // workers and assists will run when we start the - // world again. - semrelease(&work.markDoneSema) + // In STW mode, re-enable user goroutines. These will be + // queued to run after we start the world. + schedEnableUser(true) - // endCycle depends on all gcWork cache stats being - // flushed. This is ensured by mark 2. - nextTriggerRatio := gcController.endCycle() + // endCycle depends on all gcWork cache stats being flushed. + // The termination algorithm above ensured that up to + // allocations since the ragged barrier. + nextTriggerRatio := gcController.endCycle() - // Perform mark termination. This will restart the world. - gcMarkTermination(nextTriggerRatio) - } + // Perform mark termination. This will restart the world. + gcMarkTermination(nextTriggerRatio) } func gcMarkTermination(nextTriggerRatio float64) { // World is stopped. // Start marktermination which includes enabling the write barrier. atomic.Store(&gcBlackenEnabled, 0) - gcBlackenPromptly = false setGCPhase(_GCmarktermination) work.heap1 = memstats.heap_live @@ -1549,35 +1617,22 @@ func gcMarkTermination(nextTriggerRatio float64) { systemstack(func() { work.heap2 = work.bytesMarked if debug.gccheckmark > 0 { - // Run a full stop-the-world mark using checkmark bits, - // to check that we didn't forget to mark anything during - // the concurrent mark process. + // Run a full non-parallel, stop-the-world + // mark using checkmark bits, to check that we + // didn't forget to mark anything during the + // concurrent mark process. gcResetMarkState() initCheckmarks() - gcMark(startTime) + gcw := &getg().m.p.ptr().gcw + gcDrain(gcw, 0) + wbBufFlush1(getg().m.p.ptr()) + gcw.dispose() clearCheckmarks() } // marking is complete so we can turn the write barrier off setGCPhase(_GCoff) gcSweep(work.mode) - - if debug.gctrace > 1 { - startTime = nanotime() - // The g stacks have been scanned so - // they have gcscanvalid==true and gcworkdone==true. - // Reset these so that all stacks will be rescanned. - gcResetMarkState() - finishsweep_m() - - // Still in STW but gcphase is _GCoff, reset to _GCmarktermination - // At this point all objects will be found during the gcMark which - // does a complete STW mark and object scan. - setGCPhase(_GCmarktermination) - gcMark(startTime) - setGCPhase(_GCoff) // marking is done, turn off wb. - gcSweep(work.mode) - } }) _g_.m.traceback = 0 @@ -1633,8 +1688,7 @@ func gcMarkTermination(nextTriggerRatio float64) { // Bump GC cycle count and wake goroutines waiting on sweep. lock(&work.sweepWaiters.lock) memstats.numgc++ - injectglist(work.sweepWaiters.head.ptr()) - work.sweepWaiters.head = 0 + injectglist(&work.sweepWaiters.list) unlock(&work.sweepWaiters.lock) // Finish the current heap profiling cycle and start a new @@ -1653,6 +1707,16 @@ func gcMarkTermination(nextTriggerRatio float64) { // asynchronously because it can take non-trivial time. prepareFreeWorkbufs() + // Ensure all mcaches are flushed. Each P will flush its own + // mcache before allocating, but idle Ps may not. Since this + // is necessary to sweep all spans, we need to ensure all + // mcaches are flushed before we start the next GC cycle. + systemstack(func() { + forEachP(func(_p_ *p) { + _p_.mcache.prepareForSweep() + }) + }) + // Print gctrace before dropping worldsema. As soon as we drop // worldsema another cycle could start and smash the stats // we're trying to print. @@ -1856,7 +1920,7 @@ func gcBgMarkWorker(_p_ *p) { } // Go back to draining, this time // without preemption. - gcDrain(&_p_.gcw, gcDrainNoBlock|gcDrainFlushBgCredit) + gcDrain(&_p_.gcw, gcDrainFlushBgCredit) case gcMarkWorkerFractionalMode: gcDrain(&_p_.gcw, gcDrainFractional|gcDrainUntilPreempt|gcDrainFlushBgCredit) case gcMarkWorkerIdleMode: @@ -1865,16 +1929,6 @@ func gcBgMarkWorker(_p_ *p) { casgstatus(gp, _Gwaiting, _Grunning) }) - // If we are nearing the end of mark, dispose - // of the cache promptly. We must do this - // before signaling that we're no longer - // working so that other workers can't observe - // no workers and no work while we have this - // cached, and before we compute done. - if gcBlackenPromptly { - _p_.gcw.dispose() - } - // Account for time. duration := nanotime() - startTime switch _p_.gcMarkWorkerMode { @@ -1921,7 +1975,7 @@ func gcBgMarkWorker(_p_ *p) { } } -// gcMarkWorkAvailable returns true if executing a mark worker +// gcMarkWorkAvailable reports whether executing a mark worker // on p is potentially useful. p may be nil, in which case it only // checks the global sources of work. func gcMarkWorkAvailable(p *p) bool { @@ -1951,50 +2005,11 @@ func gcMark(start_time int64) { } work.tstart = start_time - // Queue root marking jobs. - gcMarkRootPrepare() - - work.nwait = 0 - work.ndone = 0 - work.nproc = uint32(gcprocs()) - - if work.full == 0 && work.nDataRoots+work.nSpanRoots+work.nStackRoots == 0 { - // There's no work on the work queue and no root jobs - // that can produce work, so don't bother entering the - // getfull() barrier. - // - // This will be the situation the vast majority of the - // time after concurrent mark. However, we still need - // a fallback for STW GC and because there are some - // known races that occasionally leave work around for - // mark termination. - // - // We're still hedging our bets here: if we do - // accidentally produce some work, we'll still process - // it, just not necessarily in parallel. - // - // TODO(austin): Fix the races and and remove - // work draining from mark termination so we don't - // need the fallback path. - work.helperDrainBlock = false - } else { - work.helperDrainBlock = true - } - - if work.nproc > 1 { - noteclear(&work.alldone) - helpgc(int32(work.nproc)) - } - - gchelperstart() - - gcw := &getg().m.p.ptr().gcw - if work.helperDrainBlock { - gcDrain(gcw, gcDrainBlock) - } else { - gcDrain(gcw, gcDrainNoBlock) + // Check that there's no marking work remaining. + if work.full != 0 || work.markrootNext < work.markrootJobs { + print("runtime: full=", hex(work.full), " next=", work.markrootNext, " jobs=", work.markrootJobs, " nDataRoots=", work.nDataRoots, " nSpanRoots=", work.nSpanRoots, " nStackRoots=", work.nStackRoots, "\n") + panic("non-empty mark queue after concurrent mark") } - gcw.dispose() if debug.gccheckmark > 0 { // This is expensive when there's a large number of @@ -2005,25 +2020,52 @@ func gcMark(start_time int64) { throw("work.full != 0") } - if work.nproc > 1 { - notesleep(&work.alldone) - } - - // Record that at least one root marking pass has completed. - work.markrootDone = true - - // Double-check that all gcWork caches are empty. This should - // be ensured by mark 2 before we enter mark termination. + // Clear out buffers and double-check that all gcWork caches + // are empty. This should be ensured by gcMarkDone before we + // enter mark termination. + // + // TODO: We could clear out buffers just before mark if this + // has a non-negligible impact on STW time. for _, p := range allp { + // The write barrier may have buffered pointers since + // the gcMarkDone barrier. However, since the barrier + // ensured all reachable objects were marked, all of + // these must be pointers to black objects. Hence we + // can just discard the write barrier buffer. + if debug.gccheckmark > 0 || throwOnGCWork { + // For debugging, flush the buffer and make + // sure it really was all marked. + wbBufFlush1(p) + } else { + p.wbBuf.reset() + } + gcw := &p.gcw if !gcw.empty() { + printlock() + print("runtime: P ", p.id, " flushedWork ", gcw.flushedWork) + if gcw.wbuf1 == nil { + print(" wbuf1=") + } else { + print(" wbuf1.n=", gcw.wbuf1.nobj) + } + if gcw.wbuf2 == nil { + print(" wbuf2=") + } else { + print(" wbuf2.n=", gcw.wbuf2.nobj) + } + print("\n") throw("P has cached GC work at end of mark termination") } - if gcw.scanWork != 0 || gcw.bytesMarked != 0 { - throw("P has unflushed stats at end of mark termination") - } + // There may still be cached empty buffers, which we + // need to flush since we're going to free them. Also, + // there may be non-zero stats because we allocated + // black after the gcMarkDone barrier. + gcw.dispose() } + throwOnGCWork = false + cachestats() // Update the marked heap stat. @@ -2055,6 +2097,9 @@ func gcSweep(mode gcMode) { throw("non-empty swept list") } mheap_.pagesSwept = 0 + mheap_.sweepArenas = mheap_.allArenas + mheap_.reclaimIndex = 0 + mheap_.reclaimCredit = 0 unlock(&mheap_.lock) if !_ConcurrentSweep || mode == gcForceBlockMode { @@ -2104,9 +2149,20 @@ func gcResetMarkState() { } unlock(&allglock) + // Clear page marks. This is just 1MB per 64GB of heap, so the + // time here is pretty trivial. + lock(&mheap_.lock) + arenas := mheap_.allArenas + unlock(&mheap_.lock) + for _, ai := range arenas { + ha := mheap_.arenas[ai.l1()][ai.l2()] + for i := range ha.pageMarks { + ha.pageMarks[i] = 0 + } + } + work.bytesMarked = 0 work.initialHeapLive = atomic.Load64(&memstats.heap_live) - work.markrootDone = false } // Hooks for other packages @@ -2151,48 +2207,6 @@ func clearpools() { unlock(&sched.deferlock) } -// gchelper runs mark termination tasks on Ps other than the P -// coordinating mark termination. -// -// The caller is responsible for ensuring that this has a P to run on, -// even though it's running during STW. Because of this, it's allowed -// to have write barriers. -// -//go:yeswritebarrierrec -func gchelper() { - _g_ := getg() - _g_.m.traceback = 2 - gchelperstart() - - // Parallel mark over GC roots and heap - if gcphase == _GCmarktermination { - gcw := &_g_.m.p.ptr().gcw - if work.helperDrainBlock { - gcDrain(gcw, gcDrainBlock) // blocks in getfull - } else { - gcDrain(gcw, gcDrainNoBlock) - } - gcw.dispose() - } - - nproc := atomic.Load(&work.nproc) // work.nproc can change right after we increment work.ndone - if atomic.Xadd(&work.ndone, +1) == nproc-1 { - notewakeup(&work.alldone) - } - _g_.m.traceback = 0 -} - -func gchelperstart() { - _g_ := getg() - - if _g_.m.helpgc < 0 || _g_.m.helpgc >= _MaxGcproc { - throw("gchelperstart: bad m->helpgc") - } - if _g_ != _g_.m.g0 { - throw("gchelper not running on g0 stack") - } -} - // Timing // itoaDiv formats val/(10**dec) into buf. diff --git a/libgo/go/runtime/mgc_gccgo.go b/libgo/go/runtime/mgc_gccgo.go index b396d35146c..85045170b3c 100644 --- a/libgo/go/runtime/mgc_gccgo.go +++ b/libgo/go/runtime/mgc_gccgo.go @@ -146,7 +146,7 @@ func registerGCRoots(r *gcRootList) { // and carries on. func checkPreempt() { gp := getg() - if !gp.preempt || gp != gp.m.curg || gp.m.locks != 0 || gp.m.mallocing != 0 || gp.m.preemptoff != "" { + if !gp.preempt || gp != gp.m.curg || gp.m.locks != 0 || gp.m.mallocing != 0 || gp.m.preemptoff != "" || gp.m.incgo { return } @@ -165,9 +165,6 @@ func checkPreempt() { mp := acquirem() gcw := &gp.m.p.ptr().gcw scanstack(gp, gcw) - if gcBlackenPromptly { - gcw.dispose() - } releasem(mp) gp.gcscandone = true } diff --git a/libgo/go/runtime/mgclarge.go b/libgo/go/runtime/mgclarge.go index e7fa831937a..7b01a117808 100644 --- a/libgo/go/runtime/mgclarge.go +++ b/libgo/go/runtime/mgclarge.go @@ -46,13 +46,57 @@ type treapNode struct { priority uint32 // random number used by treap algorithm to keep tree probabilistically balanced } -func (t *treapNode) init() { - t.right = nil - t.left = nil - t.parent = nil - t.spanKey = nil - t.npagesKey = 0 - t.priority = 0 +func (t *treapNode) pred() *treapNode { + if t.left != nil { + // If it has a left child, its predecessor will be + // its right most left (grand)child. + t = t.left + for t.right != nil { + t = t.right + } + return t + } + // If it has no left child, its predecessor will be + // the first grandparent who's right child is its + // ancestor. + // + // We compute this by walking up the treap until the + // current node's parent is its parent's right child. + // + // If we find at any point walking up the treap + // that the current node doesn't have a parent, + // we've hit the root. This means that t is already + // the left-most node in the treap and therefore + // has no predecessor. + for t.parent != nil && t.parent.right != t { + if t.parent.left != t { + println("runtime: predecessor t=", t, "t.spanKey=", t.spanKey) + throw("node is not its parent's child") + } + t = t.parent + } + return t.parent +} + +func (t *treapNode) succ() *treapNode { + if t.right != nil { + // If it has a right child, its successor will be + // its left-most right (grand)child. + t = t.right + for t.left != nil { + t = t.left + } + return t + } + // See pred. + for t.parent != nil && t.parent.left != t { + if t.parent.right != t { + println("runtime: predecessor t=", t, "t.spanKey=", t.spanKey) + throw("node is not its parent's child") + } + t = t.parent + } + return t.parent } // isSpanInTreap is handy for debugging. One should hold the heap lock, usually @@ -109,6 +153,68 @@ func checkTreapNode(t *treapNode) { } } +// treapIter is a bidirectional iterator type which may be used to iterate over a +// an mTreap in-order forwards (increasing order) or backwards (decreasing order). +// Its purpose is to hide details about the treap from users when trying to iterate +// over it. +// +// To create iterators over the treap, call start or end on an mTreap. +type treapIter struct { + t *treapNode +} + +// span returns the span at the current position in the treap. +// If the treap is not valid, span will panic. +func (i *treapIter) span() *mspan { + return i.t.spanKey +} + +// valid returns whether the iterator represents a valid position +// in the mTreap. +func (i *treapIter) valid() bool { + return i.t != nil +} + +// next moves the iterator forward by one. Once the iterator +// ceases to be valid, calling next will panic. +func (i treapIter) next() treapIter { + i.t = i.t.succ() + return i +} + +// prev moves the iterator backwards by one. Once the iterator +// ceases to be valid, calling prev will panic. +func (i treapIter) prev() treapIter { + i.t = i.t.pred() + return i +} + +// start returns an iterator which points to the start of the treap (the +// left-most node in the treap). +func (root *mTreap) start() treapIter { + t := root.treap + if t == nil { + return treapIter{} + } + for t.left != nil { + t = t.left + } + return treapIter{t: t} +} + +// end returns an iterator which points to the end of the treap (the +// right-most node in the treap). +func (root *mTreap) end() treapIter { + t := root.treap + if t == nil { + return treapIter{} + } + for t.right != nil { + t = t.right + } + return treapIter{t: t} +} + // insert adds span to the large span treap. func (root *mTreap) insert(span *mspan) { npages := span.npages @@ -120,10 +226,10 @@ func (root *mTreap) insert(span *mspan) { pt = &t.right } else if t.npagesKey > npages { pt = &t.left - } else if uintptr(unsafe.Pointer(t.spanKey)) < uintptr(unsafe.Pointer(span)) { + } else if t.spanKey.base() < span.base() { // t.npagesKey == npages, so sort on span addresses. pt = &t.right - } else if uintptr(unsafe.Pointer(t.spanKey)) > uintptr(unsafe.Pointer(span)) { + } else if t.spanKey.base() > span.base() { pt = &t.left } else { throw("inserting span already in treap") @@ -140,7 +246,6 @@ func (root *mTreap) insert(span *mspan) { // https://faculty.washington.edu/aragon/pubs/rst89.pdf t := (*treapNode)(mheap_.treapalloc.alloc()) - t.init() t.npagesKey = span.npages t.priority = fastrand() t.spanKey = span @@ -168,7 +273,6 @@ func (root *mTreap) removeNode(t *treapNode) { if t.spanKey.npages != t.npagesKey { throw("span and treap node npages do not match") } - // Rotate t down to be leaf of tree for removal, respecting priorities. for t.right != nil || t.left != nil { if t.right == nil || t.left != nil && t.left.priority < t.right.priority { @@ -188,19 +292,16 @@ func (root *mTreap) removeNode(t *treapNode) { root.treap = nil } // Return the found treapNode's span after freeing the treapNode. - t.spanKey = nil - t.npagesKey = 0 mheap_.treapalloc.free(unsafe.Pointer(t)) } -// remove searches for, finds, removes from the treap, and returns the smallest -// span that can hold npages. If no span has at least npages return nil. +// find searches for, finds, and returns the treap node containing the +// smallest span that can hold npages. If no span has at least npages +// it returns nil. // This is slightly more complicated than a simple binary tree search // since if an exact match is not found the next larger node is // returned. -// If the last node inspected > npagesKey not holding -// a left node (a smaller npages) is the "best fit" node. -func (root *mTreap) remove(npages uintptr) *mspan { +func (root *mTreap) find(npages uintptr) *treapNode { t := root.treap for t != nil { if t.spanKey == nil { @@ -211,9 +312,7 @@ func (root *mTreap) remove(npages uintptr) *mspan { } else if t.left != nil && t.left.npagesKey >= npages { t = t.left } else { - result := t.spanKey - root.removeNode(t) - return result + return t } } return nil @@ -231,24 +330,21 @@ func (root *mTreap) removeSpan(span *mspan) { t = t.right } else if t.npagesKey > npages { t = t.left - } else if uintptr(unsafe.Pointer(t.spanKey)) < uintptr(unsafe.Pointer(span)) { + } else if t.spanKey.base() < span.base() { t = t.right - } else if uintptr(unsafe.Pointer(t.spanKey)) > uintptr(unsafe.Pointer(span)) { + } else if t.spanKey.base() > span.base() { t = t.left } } root.removeNode(t) } -// scavengetreap visits each node in the treap and scavenges the -// treapNode's span. -func scavengetreap(treap *treapNode, now, limit uint64) uintptr { - if treap == nil { - return 0 - } - return scavengeTreapNode(treap, now, limit) + - scavengetreap(treap.left, now, limit) + - scavengetreap(treap.right, now, limit) +// erase removes the element referred to by the current position of the +// iterator. This operation consumes the given iterator, so it should no +// longer be used. It is up to the caller to get the next or previous +// iterator before calling erase, if need be. +func (root *mTreap) erase(i treapIter) { + root.removeNode(i.t) } // rotateLeft rotates the tree rooted at node x. diff --git a/libgo/go/runtime/mgcmark.go b/libgo/go/runtime/mgcmark.go index 631c4d7133b..9da881ed2ab 100644 --- a/libgo/go/runtime/mgcmark.go +++ b/libgo/go/runtime/mgcmark.go @@ -52,62 +52,37 @@ const ( // //go:nowritebarrier func gcMarkRootPrepare() { - if gcphase == _GCmarktermination { - work.nFlushCacheRoots = int(gomaxprocs) - } else { - work.nFlushCacheRoots = 0 - } + work.nFlushCacheRoots = 0 work.nDataRoots = 0 // Only scan globals once per cycle; preferably concurrently. - if !work.markrootDone { - roots := gcRoots - for roots != nil { - work.nDataRoots++ - roots = roots.next - } + roots := gcRoots + for roots != nil { + work.nDataRoots++ + roots = roots.next } - if !work.markrootDone { - // On the first markroot, we need to scan span roots. - // In concurrent GC, this happens during concurrent - // mark and we depend on addfinalizer to ensure the - // above invariants for objects that get finalizers - // after concurrent mark. In STW GC, this will happen - // during mark termination. - // - // We're only interested in scanning the in-use spans, - // which will all be swept at this point. More spans - // may be added to this list during concurrent GC, but - // we only care about spans that were allocated before - // this mark phase. - work.nSpanRoots = mheap_.sweepSpans[mheap_.sweepgen/2%2].numBlocks() - - // On the first markroot, we need to scan all Gs. Gs - // may be created after this point, but it's okay that - // we ignore them because they begin life without any - // roots, so there's nothing to scan, and any roots - // they create during the concurrent phase will be - // scanned during mark termination. During mark - // termination, allglen isn't changing, so we'll scan - // all Gs. - work.nStackRoots = int(atomic.Loaduintptr(&allglen)) - } else { - // We've already scanned span roots and kept the scan - // up-to-date during concurrent mark. - work.nSpanRoots = 0 - - // The hybrid barrier ensures that stacks can't - // contain pointers to unmarked objects, so on the - // second markroot, there's no need to scan stacks. - work.nStackRoots = 0 - - if debug.gcrescanstacks > 0 { - // Scan stacks anyway for debugging. - work.nStackRoots = int(atomic.Loaduintptr(&allglen)) - } - } + // Scan span roots for finalizer specials. + // + // We depend on addfinalizer to mark objects that get + // finalizers after root marking. + // + // We're only interested in scanning the in-use spans, + // which will all be swept at this point. More spans + // may be added to this list during concurrent GC, but + // we only care about spans that were allocated before + // this mark phase. + work.nSpanRoots = mheap_.sweepSpans[mheap_.sweepgen/2%2].numBlocks() + + // Scan stacks. + // + // Gs may be created after this point, but it's okay that we + // ignore them because they begin life without any roots, so + // there's nothing to scan, and any roots they create during + // the concurrent phase will be scanned during mark + // termination. + work.nStackRoots = int(atomic.Loaduintptr(&allglen)) work.markrootNext = 0 work.markrootJobs = uint32(fixedRootCount + work.nFlushCacheRoots + work.nDataRoots + work.nSpanRoots + work.nStackRoots) @@ -124,19 +99,10 @@ func gcMarkRootCheck() { lock(&allglock) // Check that stacks have been scanned. var gp *g - if gcphase == _GCmarktermination && debug.gcrescanstacks > 0 { - for i := 0; i < len(allgs); i++ { - gp = allgs[i] - if !(gp.gcscandone && gp.gcscanvalid) && readgstatus(gp) != _Gdead { - goto fail - } - } - } else { - for i := 0; i < work.nStackRoots; i++ { - gp = allgs[i] - if !gp.gcscandone { - goto fail - } + for i := 0; i < work.nStackRoots; i++ { + gp = allgs[i] + if !gp.gcscandone { + goto fail } } unlock(&allglock) @@ -188,11 +154,6 @@ func markroot(gcw *gcWork, i uint32) { } case i == fixedRootFinalizers: - // Only do this once per GC cycle since we don't call - // queuefinalizer during marking. - if work.markrootDone { - break - } for fb := allfin; fb != nil; fb = fb.alllink { cnt := uintptr(atomic.Load(&fb.cnt)) scanblock(uintptr(unsafe.Pointer(&fb.fin[0])), cnt*unsafe.Sizeof(fb.fin[0]), &finptrmask[0], gcw) @@ -202,7 +163,7 @@ func markroot(gcw *gcWork, i uint32) { // FIXME: We don't do this for gccgo. case baseSpans <= i && i < baseStacks: - // mark MSpan.specials + // mark mspan.specials markrootSpans(gcw, int(i-baseSpans)) default: @@ -278,10 +239,6 @@ func markrootSpans(gcw *gcWork, shard int) { // TODO(austin): There are several ideas for making this more // efficient in issue #11485. - if work.markrootDone { - throw("markrootSpans during second markroot") - } - sg := mheap_.sweepgen spans := mheap_.sweepSpans[mheap_.sweepgen/2%2].block(shard) // Note that work.spans may not include spans that were @@ -294,7 +251,8 @@ func markrootSpans(gcw *gcWork, shard int) { if s.state != mSpanInUse { continue } - if !useCheckmark && s.sweepgen != sg { + // Check that this span was swept (it may be cached or uncached). + if !useCheckmark && !(s.sweepgen == sg || s.sweepgen == sg+3) { // sweepgen was updated (+2) during non-checkmark GC pass print("sweep ", s.sweepgen, " ", sg, "\n") throw("gc: unswept span") @@ -492,11 +450,6 @@ func gcAssistAlloc1(gp *g, scanWork int64) { // will be more cache friendly. gcw := &getg().m.p.ptr().gcw workDone := gcDrainN(gcw, scanWork) - // If we are near the end of the mark phase - // dispose of the gcw. - if gcBlackenPromptly { - gcw.dispose() - } casgstatus(gp, _Gwaiting, _Grunning) @@ -513,8 +466,7 @@ func gcAssistAlloc1(gp *g, scanWork int64) { incnwait := atomic.Xadd(&work.nwait, +1) if incnwait > work.nproc { println("runtime: work.nwait=", incnwait, - "work.nproc=", work.nproc, - "gcBlackenPromptly=", gcBlackenPromptly) + "work.nproc=", work.nproc) throw("work.nwait > work.nproc") } @@ -539,15 +491,14 @@ func gcAssistAlloc1(gp *g, scanWork int64) { // new assists from going to sleep after this point. func gcWakeAllAssists() { lock(&work.assistQueue.lock) - injectglist(work.assistQueue.head.ptr()) - work.assistQueue.head.set(nil) - work.assistQueue.tail.set(nil) + list := work.assistQueue.q.popList() + injectglist(&list) unlock(&work.assistQueue.lock) } // gcParkAssist puts the current goroutine on the assist queue and parks. // -// gcParkAssist returns whether the assist is now satisfied. If it +// gcParkAssist reports whether the assist is now satisfied. If it // returns false, the caller must retry the assist. // //go:nowritebarrier @@ -562,24 +513,17 @@ func gcParkAssist() bool { } gp := getg() - oldHead, oldTail := work.assistQueue.head, work.assistQueue.tail - if oldHead == 0 { - work.assistQueue.head.set(gp) - } else { - oldTail.ptr().schedlink.set(gp) - } - work.assistQueue.tail.set(gp) - gp.schedlink.set(nil) + oldList := work.assistQueue.q + work.assistQueue.q.pushBack(gp) // Recheck for background credit now that this G is in // the queue, but can still back out. This avoids a // race in case background marking has flushed more // credit since we checked above. if atomic.Loadint64(&gcController.bgScanCredit) > 0 { - work.assistQueue.head = oldHead - work.assistQueue.tail = oldTail - if oldTail != 0 { - oldTail.ptr().schedlink.set(nil) + work.assistQueue.q = oldList + if oldList.tail != 0 { + oldList.tail.ptr().schedlink.set(nil) } unlock(&work.assistQueue.lock) return false @@ -600,7 +544,7 @@ func gcParkAssist() bool { // //go:nowritebarrierrec func gcFlushBgCredit(scanWork int64) { - if work.assistQueue.head == 0 { + if work.assistQueue.q.empty() { // Fast path; there are no blocked assists. There's a // small window here where an assist may add itself to // the blocked queue and park. If that happens, we'll @@ -612,23 +556,21 @@ func gcFlushBgCredit(scanWork int64) { scanBytes := int64(float64(scanWork) * gcController.assistBytesPerWork) lock(&work.assistQueue.lock) - gp := work.assistQueue.head.ptr() - for gp != nil && scanBytes > 0 { + for !work.assistQueue.q.empty() && scanBytes > 0 { + gp := work.assistQueue.q.pop() // Note that gp.gcAssistBytes is negative because gp // is in debt. Think carefully about the signs below. if scanBytes+gp.gcAssistBytes >= 0 { // Satisfy this entire assist debt. scanBytes += gp.gcAssistBytes gp.gcAssistBytes = 0 - xgp := gp - gp = gp.schedlink.ptr() - // It's important that we *not* put xgp in + // It's important that we *not* put gp in // runnext. Otherwise, it's possible for user // code to exploit the GC worker's high // scheduler priority to get itself always run // before other goroutines and always in the // fresh quantum started by GC. - ready(xgp, 0, false) + ready(gp, 0, false) } else { // Partially satisfy this assist. gp.gcAssistBytes += scanBytes @@ -637,23 +579,10 @@ func gcFlushBgCredit(scanWork int64) { // back of the queue so that large assists // can't clog up the assist queue and // substantially delay small assists. - xgp := gp - gp = gp.schedlink.ptr() - if gp == nil { - // gp is the only assist in the queue. - gp = xgp - } else { - xgp.schedlink = 0 - work.assistQueue.tail.ptr().schedlink.set(xgp) - work.assistQueue.tail.set(xgp) - } + work.assistQueue.q.pushBack(gp) break } } - work.assistQueue.head.set(gp) - if gp == nil { - work.assistQueue.tail.set(nil) - } if scanBytes > 0 { // Convert from scan bytes back to work. @@ -707,11 +636,6 @@ func scanstack(gp *g, gcw *gcWork) { // ok } - mp := gp.m - if mp != nil && mp.helpgc != 0 { - throw("can't scan gchelper stack") - } - // Scan the stack. if usestackmaps { g := getg() @@ -775,34 +699,26 @@ type gcDrainFlags int const ( gcDrainUntilPreempt gcDrainFlags = 1 << iota - gcDrainNoBlock gcDrainFlushBgCredit gcDrainIdle gcDrainFractional - - // gcDrainBlock means neither gcDrainUntilPreempt or - // gcDrainNoBlock. It is the default, but callers should use - // the constant for documentation purposes. - gcDrainBlock gcDrainFlags = 0 ) // gcDrain scans roots and objects in work buffers, blackening grey -// objects until all roots and work buffers have been drained. +// objects until it is unable to get more work. It may return before +// GC is done; it's the caller's responsibility to balance work from +// other Ps. // // If flags&gcDrainUntilPreempt != 0, gcDrain returns when g.preempt -// is set. This implies gcDrainNoBlock. +// is set. // // If flags&gcDrainIdle != 0, gcDrain returns when there is other work -// to do. This implies gcDrainNoBlock. +// to do. // // If flags&gcDrainFractional != 0, gcDrain self-preempts when // pollFractionalWorkerExit() returns true. This implies // gcDrainNoBlock. // -// If flags&gcDrainNoBlock != 0, gcDrain returns as soon as it is -// unable to get more work. Otherwise, it will block until all -// blocking calls are blocked in gcDrain. -// // If flags&gcDrainFlushBgCredit != 0, gcDrain flushes scan work // credit to gcController.bgScanCredit every gcCreditSlack units of // scan work. @@ -815,7 +731,6 @@ func gcDrain(gcw *gcWork, flags gcDrainFlags) { gp := getg().m.curg preemptible := flags&gcDrainUntilPreempt != 0 - blocking := flags&(gcDrainUntilPreempt|gcDrainIdle|gcDrainFractional|gcDrainNoBlock) == 0 flushBgCredit := flags&gcDrainFlushBgCredit != 0 idle := flags&gcDrainIdle != 0 @@ -859,17 +774,19 @@ func gcDrain(gcw *gcWork, flags gcDrainFlags) { gcw.balance() } - var b uintptr - if blocking { - b = gcw.get() - } else { - b = gcw.tryGetFast() + b := gcw.tryGetFast() + if b == 0 { + b = gcw.tryGet() if b == 0 { + // Flush the write barrier + // buffer; this may create + // more work. + wbBufFlush(nil, 0) b = gcw.tryGet() } } if b == 0 { - // work barrier reached or tryGet failed. + // Unable to get work. break } scanobject(b, gcw) @@ -895,10 +812,6 @@ func gcDrain(gcw *gcWork, flags gcDrainFlags) { } } - // In blocking mode, write barriers are not allowed after this - // point because we must preserve the condition that the work - // buffers are empty. - done: // Flush remaining scan work credit. if gcw.scanWork > 0 { @@ -947,6 +860,12 @@ func gcDrainN(gcw *gcWork, scanWork int64) int64 { b := gcw.tryGetFast() if b == 0 { b = gcw.tryGet() + if b == 0 { + // Flush the write barrier buffer; + // this may create more work. + wbBufFlush(nil, 0) + b = gcw.tryGet() + } } if b == 0 { @@ -1005,9 +924,9 @@ func scanblock(b0, n0 uintptr, ptrmask *uint8, gcw *gcWork) { for j := 0; j < 8 && i < n; j++ { if bits&1 != 0 { // Same work as in scanobject; see comments there. - obj := *(*uintptr)(unsafe.Pointer(b + i)) - if obj != 0 { - if obj, span, objIndex := findObject(obj, b, i, false); obj != 0 { + p := *(*uintptr)(unsafe.Pointer(b + i)) + if p != 0 { + if obj, span, objIndex := findObject(p, b, i, false); obj != 0 { greyobject(obj, b, i, span, gcw, objIndex, false) } } @@ -1163,7 +1082,7 @@ func scanstackblockwithmap(pc, b0, n0 uintptr, ptrmask *uint8, gcw *gcWork) { if obj != 0 { o, span, objIndex := findObject(obj, b, i, false) if obj < minPhysPageSize || - span != nil && span.state != _MSpanManual && + span != nil && span.state != mSpanManual && (obj < span.base() || obj >= span.limit || span.state != mSpanInUse) { print("runtime: found in object at *(", hex(b), "+", hex(i), ") = ", hex(obj), ", pc=", hex(pc), "\n") name, file, line := funcfileline(pc, -1) @@ -1190,11 +1109,6 @@ func shade(b uintptr) { if obj, span, objIndex := findObject(b, 0, 0, true); obj != 0 { gcw := &getg().m.p.ptr().gcw greyobject(obj, 0, 0, span, gcw, objIndex, true) - if gcphase == _GCmarktermination || gcBlackenPromptly { - // Ps aren't allowed to cache work during mark - // termination. - gcw.dispose() - } } } @@ -1262,8 +1176,14 @@ func greyobject(obj, base, off uintptr, span *mspan, gcw *gcWork, objIndex uintp if mbits.isMarked() { return } - // mbits.setMarked() // Avoid extra call overhead with manual inlining. - atomic.Or8(mbits.bytep, mbits.mask) + mbits.setMarked() + + // Mark span. + arena, pageIdx, pageMask := pageIndexOf(span.base()) + if arena.pageMarks[pageIdx]&pageMask == 0 { + atomic.Or8(&arena.pageMarks[pageIdx], pageMask) + } + // If this is a noscan object, fast-track it to black // instead of greying it. if span.spanclass.noscan() { @@ -1301,7 +1221,7 @@ func gcDumpObject(label string, obj, off uintptr) { skipped := false size := s.elemsize - if s.state == _MSpanManual && size == 0 { + if s.state == mSpanManual && size == 0 { // We're printing something from a stack frame. We // don't know how big it is, so just show up to an // including off. @@ -1338,18 +1258,13 @@ func gcDumpObject(label string, obj, off uintptr) { //go:nowritebarrier //go:nosplit func gcmarknewobject(obj, size, scanSize uintptr) { - if useCheckmark && !gcBlackenPromptly { // The world should be stopped so this should not happen. + if useCheckmark { // The world should be stopped so this should not happen. throw("gcmarknewobject called while doing checkmark") } markBitsForAddr(obj).setMarked() gcw := &getg().m.p.ptr().gcw gcw.bytesMarked += uint64(size) gcw.scanWork += int64(scanSize) - if gcBlackenPromptly { - // There shouldn't be anything in the work queue, but - // we still need to flush stats. - gcw.dispose() - } } // gcMarkTinyAllocs greys all active tiny alloc blocks. @@ -1364,9 +1279,6 @@ func gcMarkTinyAllocs() { _, span, objIndex := findObject(c.tiny, 0, 0, false) gcw := &p.gcw greyobject(c.tiny, 0, 0, span, gcw, objIndex, false) - if gcBlackenPromptly { - gcw.dispose() - } } } @@ -1397,7 +1309,7 @@ var useCheckmark = false func initCheckmarks() { useCheckmark = true for _, s := range mheap_.allspans { - if s.state == _MSpanInUse { + if s.state == mSpanInUse { heapBitsForAddr(s.base()).initCheckmarkSpan(s.layout()) } } @@ -1406,7 +1318,7 @@ func initCheckmarks() { func clearCheckmarks() { useCheckmark = false for _, s := range mheap_.allspans { - if s.state == _MSpanInUse { + if s.state == mSpanInUse { heapBitsForAddr(s.base()).clearCheckmarkSpan(s.layout()) } } diff --git a/libgo/go/runtime/mgcsweep.go b/libgo/go/runtime/mgcsweep.go index 39dd54ea2eb..dcaeb106dc4 100644 --- a/libgo/go/runtime/mgcsweep.go +++ b/libgo/go/runtime/mgcsweep.go @@ -4,6 +4,24 @@ // Garbage collector: sweeping +// The sweeper consists of two different algorithms: +// +// * The object reclaimer finds and frees unmarked slots in spans. It +// can free a whole span if none of the objects are marked, but that +// isn't its goal. This can be driven either synchronously by +// mcentral.cacheSpan for mcentral spans, or asynchronously by +// sweepone from the list of all in-use spans in mheap_.sweepSpans. +// +// * The span reclaimer looks for spans that contain no marked objects +// and frees whole spans. This is a separate algorithm because +// freeing whole spans is the hardest task for the object reclaimer, +// but is critical when allocating new spans. The entry point for +// this is mheap_.reclaim and it's driven by a sequential scan of +// the page marks bitmap in the heap arenas. +// +// Both algorithms ultimately call mspan.sweep, which sweeps a single +// heap span. + package runtime import ( @@ -54,7 +72,7 @@ func bgsweep(c chan int) { goparkunlock(&sweep.lock, waitReasonGCSweepWait, traceEvGoBlock, 1) for { - for gosweepone() != ^uintptr(0) { + for sweepone() != ^uintptr(0) { sweep.nbgsweep++ Gosched() } @@ -62,7 +80,7 @@ func bgsweep(c chan int) { Gosched() } lock(&sweep.lock) - if !gosweepdone() { + if !isSweepDone() { // This can happen if a GC runs between // gosweepone returning ^0 above // and the lock being acquired. @@ -74,9 +92,8 @@ func bgsweep(c chan int) { } } -// sweeps one span -// returns number of pages returned to heap, or ^uintptr(0) if there is nothing to sweep -//go:nowritebarrier +// sweepone sweeps some unswept heap span and returns the number of pages returned +// to the heap, or ^uintptr(0) if there was nothing to sweep. func sweepone() uintptr { _g_ := getg() sweepRatio := mheap_.sweepPagesPerByte // For debugging @@ -90,10 +107,11 @@ func sweepone() uintptr { } atomic.Xadd(&mheap_.sweepers, +1) - npages := ^uintptr(0) + // Find a span to sweep. + var s *mspan sg := mheap_.sweepgen for { - s := mheap_.sweepSpans[1-sg/2%2].pop() + s = mheap_.sweepSpans[1-sg/2%2].pop() if s == nil { atomic.Store(&mheap_.sweepdone, 1) break @@ -102,23 +120,32 @@ func sweepone() uintptr { // This can happen if direct sweeping already // swept this span, but in that case the sweep // generation should always be up-to-date. - if s.sweepgen != sg { + if !(s.sweepgen == sg || s.sweepgen == sg+3) { print("runtime: bad span s.state=", s.state, " s.sweepgen=", s.sweepgen, " sweepgen=", sg, "\n") throw("non in-use span in unswept list") } continue } - if s.sweepgen != sg-2 || !atomic.Cas(&s.sweepgen, sg-2, sg-1) { - continue + if s.sweepgen == sg-2 && atomic.Cas(&s.sweepgen, sg-2, sg-1) { + break } + } + + // Sweep the span we found. + npages := ^uintptr(0) + if s != nil { npages = s.npages - if !s.sweep(false) { + if s.sweep(false) { + // Whole span was freed. Count it toward the + // page reclaimer credit since these pages can + // now be used for span allocation. + atomic.Xadduintptr(&mheap_.reclaimCredit, npages) + } else { // Span is still in-use, so this returned no // pages to the heap and the span needs to // move to the swept in-use list. npages = 0 } - break } // Decrement the number of active sweepers and if this is the @@ -132,17 +159,13 @@ func sweepone() uintptr { return npages } -//go:nowritebarrier -func gosweepone() uintptr { - var ret uintptr - systemstack(func() { - ret = sweepone() - }) - return ret -} - -//go:nowritebarrier -func gosweepdone() bool { +// isSweepDone reports whether all spans are swept or currently being swept. +// +// Note that this condition may transition from false to true at any +// time as the sweeper runs. It may transition from true to false if a +// GC runs; to prevent that the caller must be non-preemptible or must +// somehow block GC progress. +func isSweepDone() bool { return mheap_.sweepdone != 0 } @@ -154,20 +177,25 @@ func (s *mspan) ensureSwept() { // (if GC is triggered on another goroutine). _g_ := getg() if _g_.m.locks == 0 && _g_.m.mallocing == 0 && _g_ != _g_.m.g0 { - throw("MSpan_EnsureSwept: m is not locked") + throw("mspan.ensureSwept: m is not locked") } sg := mheap_.sweepgen - if atomic.Load(&s.sweepgen) == sg { + spangen := atomic.Load(&s.sweepgen) + if spangen == sg || spangen == sg+3 { return } - // The caller must be sure that the span is a MSpanInUse span. + // The caller must be sure that the span is a mSpanInUse span. if atomic.Cas(&s.sweepgen, sg-2, sg-1) { s.sweep(false) return } // unfortunate condition, and we don't have efficient means to wait - for atomic.Load(&s.sweepgen) != sg { + for { + spangen := atomic.Load(&s.sweepgen) + if spangen == sg || spangen == sg+3 { + break + } osyield() } } @@ -175,7 +203,7 @@ func (s *mspan) ensureSwept() { // Sweep frees or collects finalizers for blocks not marked in the mark phase. // It clears the mark bits in preparation for the next GC round. // Returns true if the span was returned to heap. -// If preserve=true, don't return it to heap nor relink in MCentral lists; +// If preserve=true, don't return it to heap nor relink in mcentral lists; // caller takes care of it. //TODO go:nowritebarrier func (s *mspan) sweep(preserve bool) bool { @@ -183,12 +211,12 @@ func (s *mspan) sweep(preserve bool) bool { // GC must not start while we are in the middle of this function. _g_ := getg() if _g_.m.locks == 0 && _g_.m.mallocing == 0 && _g_ != _g_.m.g0 { - throw("MSpan_Sweep: m is not locked") + throw("mspan.sweep: m is not locked") } sweepgen := mheap_.sweepgen if s.state != mSpanInUse || s.sweepgen != sweepgen-1 { - print("MSpan_Sweep: state=", s.state, " sweepgen=", s.sweepgen, " mheap.sweepgen=", sweepgen, "\n") - throw("MSpan_Sweep: bad span state") + print("mspan.sweep: state=", s.state, " sweepgen=", s.sweepgen, " mheap.sweepgen=", sweepgen, "\n") + throw("mspan.sweep: bad span state") } if trace.enabled { @@ -345,8 +373,8 @@ func (s *mspan) sweep(preserve bool) bool { // The span must be in our exclusive ownership until we update sweepgen, // check for potential races. if s.state != mSpanInUse || s.sweepgen != sweepgen-1 { - print("MSpan_Sweep: state=", s.state, " sweepgen=", s.sweepgen, " mheap.sweepgen=", sweepgen, "\n") - throw("MSpan_Sweep: bad span state after sweep") + print("mspan.sweep: state=", s.state, " sweepgen=", s.sweepgen, " mheap.sweepgen=", sweepgen, "\n") + throw("mspan.sweep: bad span state after sweep") } // Serialization point. // At this point the mark bits are cleared and allocation ready @@ -360,29 +388,29 @@ func (s *mspan) sweep(preserve bool) bool { if nfreedSigned > 0 && spc.sizeclass() != 0 { res = mheap_.central[spc].mcentral.freeSpan(s, preserve, wasempty) - // MCentral_FreeSpan updates sweepgen + // mcentral.freeSpan updates sweepgen } else if freeToHeap { // Free large span to heap // NOTE(rsc,dvyukov): The original implementation of efence - // in CL 22060046 used SysFree instead of SysFault, so that + // in CL 22060046 used sysFree instead of sysFault, so that // the operating system would eventually give the memory // back to us again, so that an efence program could run // longer without running out of memory. Unfortunately, - // calling SysFree here without any kind of adjustment of the + // calling sysFree here without any kind of adjustment of the // heap data structures means that when the memory does // come back to us, we have the wrong metadata for it, either in - // the MSpan structures or in the garbage collection bitmap. - // Using SysFault here means that the program will run out of + // the mspan structures or in the garbage collection bitmap. + // Using sysFault here means that the program will run out of // memory fairly quickly in efence mode, but at least it won't // have mysterious crashes due to confused memory reuse. - // It should be possible to switch back to SysFree if we also - // implement and then call some kind of MHeap_DeleteSpan. + // It should be possible to switch back to sysFree if we also + // implement and then call some kind of mheap.deleteSpan. if debug.efence > 0 { s.limit = 0 // prevent mlookup from finding this span sysFault(unsafe.Pointer(s.base()), size) } else { - mheap_.freeSpan(s, 1) + mheap_.freeSpan(s, true) } c.local_nlargefree++ c.local_largefree += size @@ -430,7 +458,7 @@ retry: newHeapLive := uintptr(atomic.Load64(&memstats.heap_live)-mheap_.sweepHeapLiveBasis) + spanBytes pagesTarget := int64(mheap_.sweepPagesPerByte*float64(newHeapLive)) - int64(callerSweepPages) for pagesTarget > int64(atomic.Load64(&mheap_.pagesSwept)-sweptBasis) { - if gosweepone() == ^uintptr(0) { + if sweepone() == ^uintptr(0) { mheap_.sweepPagesPerByte = 0 break } diff --git a/libgo/go/runtime/mgcsweepbuf.go b/libgo/go/runtime/mgcsweepbuf.go index 6c1118e3857..0491f7ccf6c 100644 --- a/libgo/go/runtime/mgcsweepbuf.go +++ b/libgo/go/runtime/mgcsweepbuf.go @@ -5,6 +5,7 @@ package runtime import ( + "internal/cpu" "runtime/internal/atomic" "runtime/internal/sys" "unsafe" @@ -83,7 +84,7 @@ retry: if newCap == 0 { newCap = gcSweepBufInitSpineCap } - newSpine := persistentalloc(newCap*sys.PtrSize, sys.CacheLineSize, &memstats.gc_sys) + newSpine := persistentalloc(newCap*sys.PtrSize, cpu.CacheLineSize, &memstats.gc_sys) if b.spineCap != 0 { // Blocks are allocated off-heap, so // no write barriers. @@ -102,7 +103,7 @@ retry: } // Allocate a new block and add it to the spine. - block = (*gcSweepBlock)(persistentalloc(unsafe.Sizeof(gcSweepBlock{}), sys.CacheLineSize, &memstats.gc_sys)) + block = (*gcSweepBlock)(persistentalloc(unsafe.Sizeof(gcSweepBlock{}), cpu.CacheLineSize, &memstats.gc_sys)) blockp := add(b.spine, sys.PtrSize*top) // Blocks are allocated off-heap, so no write barrier. atomic.StorepNoWB(blockp, unsafe.Pointer(block)) diff --git a/libgo/go/runtime/mgcwork.go b/libgo/go/runtime/mgcwork.go index 99771e2e57f..89d1e0e38e9 100644 --- a/libgo/go/runtime/mgcwork.go +++ b/libgo/go/runtime/mgcwork.go @@ -22,6 +22,13 @@ const ( workbufAlloc = 32 << 10 ) +// throwOnGCWork causes any operations that add pointers to a gcWork +// buffer to throw. +// +// TODO(austin): This is a temporary debugging measure for issue +// #27993. To be removed before release. +var throwOnGCWork bool + func init() { if workbufAlloc%pageSize != 0 || workbufAlloc%_WorkbufSize != 0 { throw("bad workbufAlloc") @@ -46,10 +53,7 @@ func init() { // // (preemption must be disabled) // gcw := &getg().m.p.ptr().gcw -// .. call gcw.put() to produce and gcw.get() to consume .. -// if gcBlackenPromptly { -// gcw.dispose() -// } +// .. call gcw.put() to produce and gcw.tryGet() to consume .. // // It's important that any use of gcWork during the mark phase prevent // the garbage collector from transitioning to mark termination since @@ -83,6 +87,23 @@ type gcWork struct { // Scan work performed on this gcWork. This is aggregated into // gcController by dispose and may also be flushed by callers. scanWork int64 + + // flushedWork indicates that a non-empty work buffer was + // flushed to the global work list since the last gcMarkDone + // termination check. Specifically, this indicates that this + // gcWork may have communicated work to another gcWork. + flushedWork bool + + // pauseGen causes put operations to spin while pauseGen == + // gcWorkPauseGen if debugCachedWork is true. + pauseGen uint32 + + // putGen is the pauseGen of the last putGen. + putGen uint32 + + // pauseStack is the stack at which this P was paused if + // debugCachedWork is true. + pauseStack [16]location } // Most of the methods of gcWork are go:nowritebarrierrec because the @@ -101,10 +122,59 @@ func (w *gcWork) init() { w.wbuf2 = wbuf2 } +func (w *gcWork) checkPut(ptr uintptr, ptrs []uintptr) { + if debugCachedWork { + alreadyFailed := w.putGen == w.pauseGen + w.putGen = w.pauseGen + if m := getg().m; m.locks > 0 || m.mallocing != 0 || m.preemptoff != "" || m.p.ptr().status != _Prunning { + // If we were to spin, the runtime may + // deadlock: the condition above prevents + // preemption (see newstack), which could + // prevent gcMarkDone from finishing the + // ragged barrier and releasing the spin. + return + } + for atomic.Load(&gcWorkPauseGen) == w.pauseGen { + } + if throwOnGCWork { + printlock() + if alreadyFailed { + println("runtime: checkPut already failed at this generation") + } + println("runtime: late gcWork put") + if ptr != 0 { + gcDumpObject("ptr", ptr, ^uintptr(0)) + } + for _, ptr := range ptrs { + gcDumpObject("ptrs", ptr, ^uintptr(0)) + } + println("runtime: paused at") + for _, loc := range w.pauseStack { + if loc.pc == 0 { + break + } + if loc.function != "" { + // Obviously this doesn't + // relate to ancestor + // tracebacks, but this + // function prints what we + // want. + printAncestorTracebackFuncInfo(loc.function, loc.filename, loc.lineno, loc.pc) + } else { + println("\tunknown PC ", hex(loc.pc), "\n") + } + } + throw("throwOnGCWork") + } + } +} + // put enqueues a pointer for the garbage collector to trace. // obj must point to the beginning of a heap object or an oblet. //go:nowritebarrierrec func (w *gcWork) put(obj uintptr) { + w.checkPut(obj, nil) + flushed := false wbuf := w.wbuf1 if wbuf == nil { @@ -116,6 +186,7 @@ func (w *gcWork) put(obj uintptr) { wbuf = w.wbuf1 if wbuf.nobj == len(wbuf.obj) { putfull(wbuf) + w.flushedWork = true wbuf = getempty() w.wbuf1 = wbuf flushed = true @@ -134,10 +205,12 @@ func (w *gcWork) put(obj uintptr) { } } -// putFast does a put and returns true if it can be done quickly +// putFast does a put and reports whether it can be done quickly // otherwise it returns false and the caller needs to call put. //go:nowritebarrierrec func (w *gcWork) putFast(obj uintptr) bool { + w.checkPut(obj, nil) + wbuf := w.wbuf1 if wbuf == nil { return false @@ -159,6 +232,8 @@ func (w *gcWork) putBatch(obj []uintptr) { return } + w.checkPut(0, obj) + flushed := false wbuf := w.wbuf1 if wbuf == nil { @@ -169,6 +244,7 @@ func (w *gcWork) putBatch(obj []uintptr) { for len(obj) > 0 { for wbuf.nobj == len(wbuf.obj) { putfull(wbuf) + w.flushedWork = true w.wbuf1, w.wbuf2 = w.wbuf2, getempty() wbuf = w.wbuf1 flushed = true @@ -231,37 +307,6 @@ func (w *gcWork) tryGetFast() uintptr { return wbuf.obj[wbuf.nobj] } -// get dequeues a pointer for the garbage collector to trace, blocking -// if necessary to ensure all pointers from all queues and caches have -// been retrieved. get returns 0 if there are no pointers remaining. -//go:nowritebarrierrec -func (w *gcWork) get() uintptr { - wbuf := w.wbuf1 - if wbuf == nil { - w.init() - wbuf = w.wbuf1 - // wbuf is empty at this point. - } - if wbuf.nobj == 0 { - w.wbuf1, w.wbuf2 = w.wbuf2, w.wbuf1 - wbuf = w.wbuf1 - if wbuf.nobj == 0 { - owbuf := wbuf - wbuf = getfull() - if wbuf == nil { - return 0 - } - putempty(owbuf) - w.wbuf1 = wbuf - } - } - - // TODO: This might be a good place to add prefetch code - - wbuf.nobj-- - return wbuf.obj[wbuf.nobj] -} - // dispose returns any cached pointers to the global queue. // The buffers are being put on the full queue so that the // write barriers will not simply reacquire them before the @@ -275,6 +320,7 @@ func (w *gcWork) dispose() { putempty(wbuf) } else { putfull(wbuf) + w.flushedWork = true } w.wbuf1 = nil @@ -283,6 +329,7 @@ func (w *gcWork) dispose() { putempty(wbuf) } else { putfull(wbuf) + w.flushedWork = true } w.wbuf2 = nil } @@ -308,10 +355,14 @@ func (w *gcWork) balance() { return } if wbuf := w.wbuf2; wbuf.nobj != 0 { + w.checkPut(0, wbuf.obj[:wbuf.nobj]) putfull(wbuf) + w.flushedWork = true w.wbuf2 = getempty() } else if wbuf := w.wbuf1; wbuf.nobj > 4 { + w.checkPut(0, wbuf.obj[:wbuf.nobj]) w.wbuf1 = handoff(wbuf) + w.flushedWork = true // handoff did putfull } else { return } @@ -321,7 +372,7 @@ func (w *gcWork) balance() { } } -// empty returns true if w has no mark work available. +// empty reports whether w has no mark work available. //go:nowritebarrierrec func (w *gcWork) empty() bool { return w.wbuf1 == nil || (w.wbuf1.nobj == 0 && w.wbuf2.nobj == 0) @@ -440,61 +491,6 @@ func trygetfull() *workbuf { return b } -// Get a full work buffer off the work.full list. -// If nothing is available wait until all the other gc helpers have -// finished and then return nil. -// getfull acts as a barrier for work.nproc helpers. As long as one -// gchelper is actively marking objects it -// may create a workbuffer that the other helpers can work on. -// The for loop either exits when a work buffer is found -// or when _all_ of the work.nproc GC helpers are in the loop -// looking for work and thus not capable of creating new work. -// This is in fact the termination condition for the STW mark -// phase. -//go:nowritebarrier -func getfull() *workbuf { - b := (*workbuf)(work.full.pop()) - if b != nil { - b.checknonempty() - return b - } - - incnwait := atomic.Xadd(&work.nwait, +1) - if incnwait > work.nproc { - println("runtime: work.nwait=", incnwait, "work.nproc=", work.nproc) - throw("work.nwait > work.nproc") - } - for i := 0; ; i++ { - if work.full != 0 { - decnwait := atomic.Xadd(&work.nwait, -1) - if decnwait == work.nproc { - println("runtime: work.nwait=", decnwait, "work.nproc=", work.nproc) - throw("work.nwait > work.nproc") - } - b = (*workbuf)(work.full.pop()) - if b != nil { - b.checknonempty() - return b - } - incnwait := atomic.Xadd(&work.nwait, +1) - if incnwait > work.nproc { - println("runtime: work.nwait=", incnwait, "work.nproc=", work.nproc) - throw("work.nwait > work.nproc") - } - } - if work.nwait == work.nproc && work.markrootNext >= work.markrootJobs { - return nil - } - if i < 10 { - procyield(20) - } else if i < 20 { - osyield() - } else { - usleep(100) - } - } -} - //go:nowritebarrier func handoff(b *workbuf) *workbuf { // Make new buffer with half of b's pointers. diff --git a/libgo/go/runtime/mheap.go b/libgo/go/runtime/mheap.go index eb98083fecc..7139b0e94e7 100644 --- a/libgo/go/runtime/mheap.go +++ b/libgo/go/runtime/mheap.go @@ -9,6 +9,7 @@ package runtime import ( + "internal/cpu" "runtime/internal/atomic" "runtime/internal/sys" "unsafe" @@ -20,7 +21,7 @@ import ( const minPhysPageSize = 4096 // Main malloc heap. -// The heap itself is the "free[]" and "large" arrays, +// The heap itself is the "free" and "scav" treaps, // but all the other global data is here too. // // mheap must not be heap-allocated because it contains mSpanLists, @@ -29,13 +30,11 @@ const minPhysPageSize = 4096 //go:notinheap type mheap struct { lock mutex - free [_MaxMHeapList]mSpanList // free lists of given length up to _MaxMHeapList - freelarge mTreap // free treap of length >= _MaxMHeapList - busy [_MaxMHeapList]mSpanList // busy lists of large spans of given length - busylarge mSpanList // busy lists of large spans length >= _MaxMHeapList - sweepgen uint32 // sweep generation, see comment in mspan - sweepdone uint32 // all spans are swept - sweepers uint32 // number of active sweepone calls + free mTreap // free and non-scavenged spans + scav mTreap // free and scavenged spans + sweepgen uint32 // sweep generation, see comment in mspan + sweepdone uint32 // all spans are swept + sweepers uint32 // number of active sweepone calls // allspans is a slice of all mspans ever created. Each mspan // appears exactly once. @@ -61,7 +60,7 @@ type mheap struct { // on the swept stack. sweepSpans [2]gcSweepBuf - //_ uint32 // align uint64 fields on 32-bit for atomics + _ uint32 // align uint64 fields on 32-bit for atomics // Proportional sweep // @@ -81,7 +80,7 @@ type mheap struct { // accounting for current progress. If we could only adjust // the slope, it would create a discontinuity in debt if any // progress has already been made. - pagesInUse uint64 // pages of spans in stats _MSpanInUse; R/W with mheap.lock + pagesInUse uint64 // pages of spans in stats mSpanInUse; R/W with mheap.lock pagesSwept uint64 // pages swept this cycle; updated atomically pagesSweptBasis uint64 // pagesSwept to use as the origin of the sweep ratio; updated atomically sweepHeapLiveBasis uint64 // value of heap_live to use as the origin of sweep ratio; written with lock, read without @@ -89,6 +88,25 @@ type mheap struct { // TODO(austin): pagesInUse should be a uintptr, but the 386 // compiler can't 8-byte align fields. + // Page reclaimer state + + // reclaimIndex is the page index in allArenas of next page to + // reclaim. Specifically, it refers to page (i % + // pagesPerArena) of arena allArenas[i / pagesPerArena]. + // + // If this is >= 1<<63, the page reclaimer is done scanning + // the page marks. + // + // This is accessed atomically. + reclaimIndex uint64 + // reclaimCredit is spare credit for extra pages swept. Since + // the page reclaimer works in large chunks, it may reclaim + // more than requested. Any spare pages released go to this + // credit pool. + // + // This is accessed atomically. + reclaimCredit uintptr + // Malloc stats. largealloc uint64 // bytes allocated for large objects nlargealloc uint64 // number of large object allocations @@ -133,21 +151,35 @@ type mheap struct { // (the actual arenas). This is only used on 32-bit. arena linearAlloc - //_ uint32 // ensure 64-bit alignment of central + // allArenas is the arenaIndex of every mapped arena. This can + // be used to iterate through the address space. + // + // Access is protected by mheap_.lock. However, since this is + // append-only and old backing arrays are never freed, it is + // safe to acquire mheap_.lock, copy the slice header, and + // then release mheap_.lock. + allArenas []arenaIdx + + // sweepArenas is a snapshot of allArenas taken at the + // beginning of the sweep cycle. This can be read safely by + // simply blocking GC (by disabling preemption). + sweepArenas []arenaIdx + + _ uint32 // ensure 64-bit alignment of central // central free lists for small size classes. - // the padding makes sure that the MCentrals are - // spaced CacheLineSize bytes apart, so that each MCentral.lock + // the padding makes sure that the mcentrals are + // spaced CacheLinePadSize bytes apart, so that each mcentral.lock // gets its own cache line. // central is indexed by spanClass. central [numSpanClasses]struct { mcentral mcentral - pad [sys.CacheLineSize - unsafe.Sizeof(mcentral{})%sys.CacheLineSize]byte + pad [cpu.CacheLinePadSize - unsafe.Sizeof(mcentral{})%cpu.CacheLinePadSize]byte } spanalloc fixalloc // allocator for span* cachealloc fixalloc // allocator for mcache* - treapalloc fixalloc // allocator for treapNodes* used by large objects + treapalloc fixalloc // allocator for treapNodes* specialfinalizeralloc fixalloc // allocator for specialfinalizer* specialprofilealloc fixalloc // allocator for specialprofile* speciallock mutex // lock for special record allocators. @@ -184,6 +216,29 @@ type heapArena struct { // must not be a safe-point between establishing that an // address is live and looking it up in the spans array. spans [pagesPerArena]*mspan + + // pageInUse is a bitmap that indicates which spans are in + // state mSpanInUse. This bitmap is indexed by page number, + // but only the bit corresponding to the first page in each + // span is used. + // + // Writes are protected by mheap_.lock. + pageInUse [pagesPerArena / 8]uint8 + + // pageMarks is a bitmap that indicates which spans have any + // marked objects on them. Like pageInUse, only the bit + // corresponding to the first page in each span is used. + // + // Writes are done atomically during marking. Reads are + // non-atomic and lock-free since they only occur during + // sweeping (and hence never race with writes). + // + // This is used to quickly find whole spans that can be freed. + // + // TODO(austin): It would be nice if this was uint64 for + // faster scanning, but we don't have 64-bit atomic bit + // operations. + pageMarks [pagesPerArena / 8]uint8 } // arenaHint is a hint for where to grow the heap arenas. See @@ -196,20 +251,21 @@ type arenaHint struct { next *arenaHint } -// An MSpan is a run of pages. +// An mspan is a run of pages. // -// When a MSpan is in the heap free list, state == MSpanFree +// When a mspan is in the heap free treap, state == mSpanFree // and heapmap(s->start) == span, heapmap(s->start+s->npages-1) == span. +// If the mspan is in the heap scav treap, then in addition to the +// above scavenged == true. scavenged == false in all other cases. // -// When a MSpan is allocated, state == MSpanInUse or MSpanManual +// When a mspan is allocated, state == mSpanInUse or mSpanManual // and heapmap(i) == span for all s->start <= i < s->start+s->npages. -// Every MSpan is in one doubly-linked list, -// either one of the MHeap's free lists or one of the -// MCentral's span lists. +// Every mspan is in one doubly-linked list, either in the mheap's +// busy list or one of the mcentral's span lists. -// An MSpan representing actual memory has state _MSpanInUse, -// _MSpanManual, or _MSpanFree. Transitions between these states are +// An mspan representing actual memory has state mSpanInUse, +// mSpanManual, or mSpanFree. Transitions between these states are // constrained as follows: // // * A span may transition from free to in-use or manual during any GC @@ -225,19 +281,19 @@ type arenaHint struct { type mSpanState uint8 const ( - _MSpanDead mSpanState = iota - _MSpanInUse // allocated for garbage collected heap - _MSpanManual // allocated for manual management (e.g., stack allocator) - _MSpanFree + mSpanDead mSpanState = iota + mSpanInUse // allocated for garbage collected heap + mSpanManual // allocated for manual management (e.g., stack allocator) + mSpanFree ) // mSpanStateNames are the names of the span states, indexed by // mSpanState. var mSpanStateNames = []string{ - "_MSpanDead", - "_MSpanInUse", - "_MSpanManual", - "_MSpanFree", + "mSpanDead", + "mSpanInUse", + "mSpanManual", + "mSpanFree", } // mSpanList heads a linked list of spans. @@ -257,7 +313,7 @@ type mspan struct { startAddr uintptr // address of first byte of span aka s.base() npages uintptr // number of pages in span - manualFreeList gclinkptr // list of free objects in _MSpanManual spans + manualFreeList gclinkptr // list of free objects in mSpanManual spans // freeindex is the slot index between 0 and nelems at which to begin scanning // for the next free object in this span. @@ -316,6 +372,8 @@ type mspan struct { // if sweepgen == h->sweepgen - 2, the span needs sweeping // if sweepgen == h->sweepgen - 1, the span is currently being swept // if sweepgen == h->sweepgen, the span is swept and ready to use + // if sweepgen == h->sweepgen + 1, the span was cached before sweep began and is still cached, and needs sweeping + // if sweepgen == h->sweepgen + 3, the span was swept and then cached and is still cached // h->sweepgen is incremented by 2 after every GC sweepgen uint32 @@ -323,14 +381,13 @@ type mspan struct { baseMask uint16 // if non-0, elemsize is a power of 2, & this will get object allocation base allocCount uint16 // number of allocated objects spanclass spanClass // size class and noscan (uint8) - incache bool // being used by an mcache state mSpanState // mspaninuse etc needzero uint8 // needs to be zeroed before allocation divShift uint8 // for divide by elemsize - divMagic.shift divShift2 uint8 // for divide by elemsize - divMagic.shift2 + scavenged bool // whether this span has had its pages released to the OS elemsize uintptr // computed from sizeclass or from npages unusedsince int64 // first time spotted by gc in mspanfree state - npreleased uintptr // number of pages released to the os limit uintptr // end of data in span speciallock mutex // guards specials list specials *special // linked list of special records sorted by offset. @@ -349,6 +406,45 @@ func (s *mspan) layout() (size, n, total uintptr) { return } +// physPageBounds returns the start and end of the span +// rounded in to the physical page size. +func (s *mspan) physPageBounds() (uintptr, uintptr) { + start := s.base() + end := start + s.npages<<_PageShift + if physPageSize > _PageSize { + // Round start and end in. + start = (start + physPageSize - 1) &^ (physPageSize - 1) + end &^= physPageSize - 1 + } + return start, end +} + +func (s *mspan) scavenge() uintptr { + // start and end must be rounded in, otherwise madvise + // will round them *out* and release more memory + // than we want. + start, end := s.physPageBounds() + if end <= start { + // start and end don't span a whole physical page. + return 0 + } + released := end - start + memstats.heap_released += uint64(released) + s.scavenged = true + sysUnused(unsafe.Pointer(start), released) + return released +} + +// released returns the number of bytes in this span +// which were returned back to the OS. +func (s *mspan) released() uintptr { + if !s.scavenged { + return 0 + } + start, end := s.physPageBounds() + return end - start +} + // recordspan adds a newly allocated span to h.allspans. // // This only happens the first time a span is allocated from @@ -457,7 +553,7 @@ func (i arenaIdx) l2() uint { } // inheap reports whether b is a pointer into a (potentially dead) heap object. -// It returns false for pointers into _MSpanManual spans. +// It returns false for pointers into mSpanManual spans. // Non-preemptible because it is used by write barriers. //go:nowritebarrier //go:nosplit @@ -476,7 +572,7 @@ func inHeapOrStack(b uintptr) bool { return false } switch s.state { - case mSpanInUse, _MSpanManual: + case mSpanInUse, mSpanManual: return b < s.limit default: return false @@ -550,6 +646,16 @@ func spanOfHeap(p uintptr) *mspan { return s } +// pageIndexOf returns the arena, page index, and page mask for pointer p. +// The caller must ensure p is in the heap. +func pageIndexOf(p uintptr) (arena *heapArena, pageIdx uintptr, pageMask uint8) { + ai := arenaIndex(p) + arena = mheap_.arenas[ai.l1()][ai.l2()] + pageIdx = ((p / pageSize) / 8) % uintptr(len(arena.pageInUse)) + pageMask = byte(1 << ((p / pageSize) % 8)) + return +} + // Initialize the heap. func (h *mheap) init() { h.treapalloc.init(unsafe.Sizeof(treapNode{}), nil, nil, &memstats.other_sys) @@ -569,117 +675,182 @@ func (h *mheap) init() { h.spanalloc.zero = false // h->mapcache needs no init - for i := range h.free { - h.free[i].init() - h.busy[i].init() - } - h.busylarge.init() for i := range h.central { h.central[i].mcentral.init(spanClass(i)) } } -// Sweeps spans in list until reclaims at least npages into heap. -// Returns the actual number of pages reclaimed. -func (h *mheap) reclaimList(list *mSpanList, npages uintptr) uintptr { - n := uintptr(0) - sg := mheap_.sweepgen -retry: - for s := list.first; s != nil; s = s.next { - if s.sweepgen == sg-2 && atomic.Cas(&s.sweepgen, sg-2, sg-1) { - list.remove(s) - // swept spans are at the end of the list - list.insertBack(s) // Puts it back on a busy list. s is not in the treap at this point. - unlock(&h.lock) - snpages := s.npages - if s.sweep(false) { - n += snpages +// reclaim sweeps and reclaims at least npage pages into the heap. +// It is called before allocating npage pages to keep growth in check. +// +// reclaim implements the page-reclaimer half of the sweeper. +// +// h must NOT be locked. +func (h *mheap) reclaim(npage uintptr) { + // This scans pagesPerChunk at a time. Higher values reduce + // contention on h.reclaimPos, but increase the minimum + // latency of performing a reclaim. + // + // Must be a multiple of the pageInUse bitmap element size. + // + // The time required by this can vary a lot depending on how + // many spans are actually freed. Experimentally, it can scan + // for pages at ~300 GB/ms on a 2.6GHz Core i7, but can only + // free spans at ~32 MB/ms. Using 512 pages bounds this at + // roughly 100µs. + // + // TODO(austin): Half of the time spent freeing spans is in + // locking/unlocking the heap (even with low contention). We + // could make the slow path here several times faster by + // batching heap frees. + const pagesPerChunk = 512 + + // Bail early if there's no more reclaim work. + if atomic.Load64(&h.reclaimIndex) >= 1<<63 { + return + } + + // Disable preemption so the GC can't start while we're + // sweeping, so we can read h.sweepArenas, and so + // traceGCSweepStart/Done pair on the P. + mp := acquirem() + + if trace.enabled { + traceGCSweepStart() + } + + arenas := h.sweepArenas + locked := false + for npage > 0 { + // Pull from accumulated credit first. + if credit := atomic.Loaduintptr(&h.reclaimCredit); credit > 0 { + take := credit + if take > npage { + // Take only what we need. + take = npage } - lock(&h.lock) - if n >= npages { - return n + if atomic.Casuintptr(&h.reclaimCredit, credit, credit-take) { + npage -= take } - // the span could have been moved elsewhere - goto retry - } - if s.sweepgen == sg-1 { - // the span is being swept by background sweeper, skip continue } - // already swept empty span, - // all subsequent ones must also be either swept or in process of sweeping - break - } - return n -} -// Sweeps and reclaims at least npage pages into heap. -// Called before allocating npage pages. -func (h *mheap) reclaim(npage uintptr) { - // First try to sweep busy spans with large objects of size >= npage, - // this has good chances of reclaiming the necessary space. - for i := int(npage); i < len(h.busy); i++ { - if h.reclaimList(&h.busy[i], npage) != 0 { - return // Bingo! + // Claim a chunk of work. + idx := uintptr(atomic.Xadd64(&h.reclaimIndex, pagesPerChunk) - pagesPerChunk) + if idx/pagesPerArena >= uintptr(len(arenas)) { + // Page reclaiming is done. + atomic.Store64(&h.reclaimIndex, 1<<63) + break } - } - // Then -- even larger objects. - if h.reclaimList(&h.busylarge, npage) != 0 { - return // Bingo! - } + if !locked { + // Lock the heap for reclaimChunk. + lock(&h.lock) + locked = true + } - // Now try smaller objects. - // One such object is not enough, so we need to reclaim several of them. - reclaimed := uintptr(0) - for i := 0; i < int(npage) && i < len(h.busy); i++ { - reclaimed += h.reclaimList(&h.busy[i], npage-reclaimed) - if reclaimed >= npage { - return + // Scan this chunk. + nfound := h.reclaimChunk(arenas, idx, pagesPerChunk) + if nfound <= npage { + npage -= nfound + } else { + // Put spare pages toward global credit. + atomic.Xadduintptr(&h.reclaimCredit, nfound-npage) + npage = 0 } } + if locked { + unlock(&h.lock) + } - // Now sweep everything that is not yet swept. - unlock(&h.lock) - for { - n := sweepone() - if n == ^uintptr(0) { // all spans are swept - break + if trace.enabled { + traceGCSweepDone() + } + releasem(mp) +} + +// reclaimChunk sweeps unmarked spans that start at page indexes [pageIdx, pageIdx+n). +// It returns the number of pages returned to the heap. +// +// h.lock must be held and the caller must be non-preemptible. +func (h *mheap) reclaimChunk(arenas []arenaIdx, pageIdx, n uintptr) uintptr { + // The heap lock must be held because this accesses the + // heapArena.spans arrays using potentially non-live pointers. + // In particular, if a span were freed and merged concurrently + // with this probing heapArena.spans, it would be possible to + // observe arbitrary, stale span pointers. + n0 := n + var nFreed uintptr + sg := h.sweepgen + for n > 0 { + ai := arenas[pageIdx/pagesPerArena] + ha := h.arenas[ai.l1()][ai.l2()] + + // Get a chunk of the bitmap to work on. + arenaPage := uint(pageIdx % pagesPerArena) + inUse := ha.pageInUse[arenaPage/8:] + marked := ha.pageMarks[arenaPage/8:] + if uintptr(len(inUse)) > n/8 { + inUse = inUse[:n/8] + marked = marked[:n/8] } - reclaimed += n - if reclaimed >= npage { - break + + // Scan this bitmap chunk for spans that are in-use + // but have no marked objects on them. + for i := range inUse { + inUseUnmarked := inUse[i] &^ marked[i] + if inUseUnmarked == 0 { + continue + } + + for j := uint(0); j < 8; j++ { + if inUseUnmarked&(1< ts.spanKey.npages) { + s = ts.spanKey + h.scav.removeNode(ts) + } + return s +} + // Allocates a span of the given size. h must be locked. // The returned span has been removed from the -// free list, but its state is still MSpanFree. +// free structures, but its state is still mSpanFree. func (h *mheap) allocSpanLocked(npage uintptr, stat *uint64) *mspan { - var list *mSpanList var s *mspan - // Try in fixed-size lists up to max. - for i := int(npage); i < len(h.free); i++ { - list = &h.free[i] - if !list.isEmpty() { - s = list.first - list.remove(s) - goto HaveSpan - } + s = h.pickFreeSpan(npage) + if s != nil { + goto HaveSpan } - // Best fit in list of large spans. - s = h.allocLarge(npage) // allocLarge removed s from h.freelarge for us - if s == nil { - if !h.grow(npage) { - return nil - } - s = h.allocLarge(npage) - if s == nil { - return nil - } + // On failure, grow the heap and try again. + if !h.grow(npage) { + return nil + } + s = h.pickFreeSpan(npage) + if s != nil { + goto HaveSpan } + throw("grew heap, but no adequate free span found") HaveSpan: // Mark span in use. - if s.state != _MSpanFree { - throw("MHeap_AllocLocked - MSpan not free") + if s.state != mSpanFree { + throw("candidate mspan for allocation is not free") } if s.npages < npage { - throw("MHeap_AllocLocked - bad npages") - } - if s.npreleased > 0 { - sysUsed(unsafe.Pointer(s.base()), s.npages<<_PageShift) - memstats.heap_released -= uint64(s.npreleased << _PageShift) - s.npreleased = 0 + throw("candidate mspan for allocation is too small") } + // First, subtract any memory that was released back to + // the OS from s. We will re-scavenge the trimmed section + // if necessary. + memstats.heap_released -= uint64(s.released()) + if s.npages > npage { // Trim extra and put it back in the heap. t := (*mspan)(h.spanalloc.alloc()) @@ -874,10 +1062,25 @@ HaveSpan: h.setSpan(t.base(), t) h.setSpan(t.base()+t.npages*pageSize-1, t) t.needzero = s.needzero - s.state = _MSpanManual // prevent coalescing with s - t.state = _MSpanManual + // If s was scavenged, then t may be scavenged. + start, end := t.physPageBounds() + if s.scavenged && start < end { + memstats.heap_released += uint64(end - start) + t.scavenged = true + } + s.state = mSpanManual // prevent coalescing with s + t.state = mSpanManual h.freeSpanLocked(t, false, false, s.unusedsince) - s.state = _MSpanFree + s.state = mSpanFree + } + // "Unscavenge" s only AFTER splitting so that + // we only sysUsed whatever we actually need. + if s.scavenged { + // sysUsed all the pages that are actually available + // in the span. Note that we don't need to decrement + // heap_released since we already did so earlier. + sysUsed(unsafe.Pointer(s.base()), s.npages<<_PageShift) + s.scavenged = false } s.unusedsince = 0 @@ -893,21 +1096,6 @@ HaveSpan: return s } -// Large spans have a minimum size of 1MByte. The maximum number of large spans to support -// 1TBytes is 1 million, experimentation using random sizes indicates that the depth of -// the tree is less that 2x that of a perfectly balanced tree. For 1TByte can be referenced -// by a perfectly balanced tree with a depth of 20. Twice that is an acceptable 40. -func (h *mheap) isLargeSpan(npages uintptr) bool { - return npages >= uintptr(len(h.free)) -} - -// allocLarge allocates a span of at least npage pages from the treap of large spans. -// Returns nil if no such span currently exists. -func (h *mheap) allocLarge(npage uintptr) *mspan { - // Search treap for smallest span with >= npage pages. - return h.freelarge.remove(npage) -} - // Try to add at least npage pages of memory to the heap, // returning whether it worked. // @@ -920,20 +1108,31 @@ func (h *mheap) grow(npage uintptr) bool { return false } + // Scavenge some pages out of the free treap to make up for + // the virtual memory space we just allocated. We prefer to + // scavenge the largest spans first since the cost of scavenging + // is proportional to the number of sysUnused() calls rather than + // the number of pages released, so we make fewer of those calls + // with larger spans. + h.scavengeLargest(size) + // Create a fake "in use" span and free it, so that the // right coalescing happens. s := (*mspan)(h.spanalloc.alloc()) s.init(uintptr(v), size/pageSize) h.setSpans(s.base(), s.npages, s) atomic.Store(&s.sweepgen, h.sweepgen) - s.state = _MSpanInUse + s.state = mSpanInUse h.pagesInUse += uint64(s.npages) h.freeSpanLocked(s, false, true, 0) return true } // Free the span back into the heap. -func (h *mheap) freeSpan(s *mspan, acct int32) { +// +// large must match the value of large passed to mheap.alloc. This is +// used for accounting. +func (h *mheap) freeSpan(s *mspan, large bool) { systemstack(func() { mp := getg().m lock(&h.lock) @@ -947,7 +1146,8 @@ func (h *mheap) freeSpan(s *mspan, acct int32) { bytes := s.npages << _PageShift msanfree(base, bytes) } - if acct != 0 { + if large { + // Match accounting done in mheap.alloc. memstats.heap_objects-- } if gcBlackenEnabled != 0 { @@ -979,21 +1179,25 @@ func (h *mheap) freeManual(s *mspan, stat *uint64) { unlock(&h.lock) } -// s must be on a busy list (h.busy or h.busylarge) or unlinked. +// s must be on the busy list or unlinked. func (h *mheap) freeSpanLocked(s *mspan, acctinuse, acctidle bool, unusedsince int64) { switch s.state { - case _MSpanManual: + case mSpanManual: if s.allocCount != 0 { - throw("MHeap_FreeSpanLocked - invalid stack free") + throw("mheap.freeSpanLocked - invalid stack free") } - case _MSpanInUse: + case mSpanInUse: if s.allocCount != 0 || s.sweepgen != h.sweepgen { - print("MHeap_FreeSpanLocked - span ", s, " ptr ", hex(s.base()), " allocCount ", s.allocCount, " sweepgen ", s.sweepgen, "/", h.sweepgen, "\n") - throw("MHeap_FreeSpanLocked - invalid free") + print("mheap.freeSpanLocked - span ", s, " ptr ", hex(s.base()), " allocCount ", s.allocCount, " sweepgen ", s.sweepgen, "/", h.sweepgen, "\n") + throw("mheap.freeSpanLocked - invalid free") } h.pagesInUse -= uint64(s.npages) + + // Clear in-use bit in arena page bitmap. + arena, pageIdx, pageMask := pageIndexOf(s.base()) + arena.pageInUse[pageIdx] &^= pageMask default: - throw("MHeap_FreeSpanLocked - invalid span state") + throw("mheap.freeSpanLocked - invalid span state") } if acctinuse { @@ -1002,10 +1206,7 @@ func (h *mheap) freeSpanLocked(s *mspan, acctinuse, acctidle bool, unusedsince i if acctidle { memstats.heap_idle += uint64(s.npages << _PageShift) } - s.state = _MSpanFree - if s.inList() { - h.busyList(s.npages).remove(s) - } + s.state = mSpanFree // Stamp newly unused spans. The scavenger will use that // info to potentially give back some pages to the OS. @@ -1013,133 +1214,122 @@ func (h *mheap) freeSpanLocked(s *mspan, acctinuse, acctidle bool, unusedsince i if unusedsince == 0 { s.unusedsince = nanotime() } - s.npreleased = 0 + + // We scavenge s at the end after coalescing if s or anything + // it merged with is marked scavenged. + needsScavenge := false + prescavenged := s.released() // number of bytes already scavenged. // Coalesce with earlier, later spans. - if before := spanOf(s.base() - 1); before != nil && before.state == _MSpanFree { + if before := spanOf(s.base() - 1); before != nil && before.state == mSpanFree { // Now adjust s. s.startAddr = before.startAddr s.npages += before.npages - s.npreleased = before.npreleased // absorb released pages s.needzero |= before.needzero h.setSpan(before.base(), s) + // If before or s are scavenged, then we need to scavenge the final coalesced span. + needsScavenge = needsScavenge || before.scavenged || s.scavenged + prescavenged += before.released() // The size is potentially changing so the treap needs to delete adjacent nodes and // insert back as a combined node. - if h.isLargeSpan(before.npages) { - // We have a t, it is large so it has to be in the treap so we can remove it. - h.freelarge.removeSpan(before) + if before.scavenged { + h.scav.removeSpan(before) } else { - h.freeList(before.npages).remove(before) + h.free.removeSpan(before) } - before.state = _MSpanDead + before.state = mSpanDead h.spanalloc.free(unsafe.Pointer(before)) } // Now check to see if next (greater addresses) span is free and can be coalesced. - if after := spanOf(s.base() + s.npages*pageSize); after != nil && after.state == _MSpanFree { + if after := spanOf(s.base() + s.npages*pageSize); after != nil && after.state == mSpanFree { s.npages += after.npages - s.npreleased += after.npreleased s.needzero |= after.needzero h.setSpan(s.base()+s.npages*pageSize-1, s) - if h.isLargeSpan(after.npages) { - h.freelarge.removeSpan(after) + needsScavenge = needsScavenge || after.scavenged || s.scavenged + prescavenged += after.released() + if after.scavenged { + h.scav.removeSpan(after) } else { - h.freeList(after.npages).remove(after) + h.free.removeSpan(after) } - after.state = _MSpanDead + after.state = mSpanDead h.spanalloc.free(unsafe.Pointer(after)) } - // Insert s into appropriate list or treap. - if h.isLargeSpan(s.npages) { - h.freelarge.insert(s) + if needsScavenge { + // When coalescing spans, some physical pages which + // were not returned to the OS previously because + // they were only partially covered by the span suddenly + // become available for scavenging. We want to make sure + // those holes are filled in, and the span is properly + // scavenged. Rather than trying to detect those holes + // directly, we collect how many bytes were already + // scavenged above and subtract that from heap_released + // before re-scavenging the entire newly-coalesced span, + // which will implicitly bump up heap_released. + memstats.heap_released -= uint64(prescavenged) + s.scavenge() + } + + // Insert s into the appropriate treap. + if s.scavenged { + h.scav.insert(s) } else { - h.freeList(s.npages).insert(s) - } -} - -func (h *mheap) freeList(npages uintptr) *mSpanList { - return &h.free[npages] -} - -func (h *mheap) busyList(npages uintptr) *mSpanList { - if npages < uintptr(len(h.busy)) { - return &h.busy[npages] - } - return &h.busylarge -} - -func scavengeTreapNode(t *treapNode, now, limit uint64) uintptr { - s := t.spanKey - var sumreleased uintptr - if (now-uint64(s.unusedsince)) > limit && s.npreleased != s.npages { - start := s.base() - end := start + s.npages<<_PageShift - if physPageSize > _PageSize { - // We can only release pages in - // physPageSize blocks, so round start - // and end in. (Otherwise, madvise - // will round them *out* and release - // more memory than we want.) - start = (start + physPageSize - 1) &^ (physPageSize - 1) - end &^= physPageSize - 1 - if end <= start { - // start and end don't span a - // whole physical page. - return sumreleased - } - } - len := end - start - released := len - (s.npreleased << _PageShift) - if physPageSize > _PageSize && released == 0 { - return sumreleased - } - memstats.heap_released += uint64(released) - sumreleased += released - s.npreleased = len >> _PageShift - sysUnused(unsafe.Pointer(start), len) - } - return sumreleased -} - -func scavengelist(list *mSpanList, now, limit uint64) uintptr { - if list.isEmpty() { - return 0 - } - - var sumreleased uintptr - for s := list.first; s != nil; s = s.next { - if (now-uint64(s.unusedsince)) <= limit || s.npreleased == s.npages { - continue + h.free.insert(s) + } +} + +// scavengeLargest scavenges nbytes worth of spans in unscav +// starting from the largest span and working down. It then takes those spans +// and places them in scav. h must be locked. +func (h *mheap) scavengeLargest(nbytes uintptr) { + // Iterate over the treap backwards (from largest to smallest) scavenging spans + // until we've reached our quota of nbytes. + released := uintptr(0) + for t := h.free.end(); released < nbytes && t.valid(); { + s := t.span() + r := s.scavenge() + if r == 0 { + // Since we're going in order of largest-to-smallest span, this + // means all other spans are no bigger than s. There's a high + // chance that the other spans don't even cover a full page, + // (though they could) but iterating further just for a handful + // of pages probably isn't worth it, so just stop here. + // + // This check also preserves the invariant that spans that have + // `scavenged` set are only ever in the `scav` treap, and + // those which have it unset are only in the `free` treap. + return } - start := s.base() - end := start + s.npages<<_PageShift - if physPageSize > _PageSize { - // We can only release pages in - // physPageSize blocks, so round start - // and end in. (Otherwise, madvise - // will round them *out* and release - // more memory than we want.) - start = (start + physPageSize - 1) &^ (physPageSize - 1) - end &^= physPageSize - 1 - if end <= start { - // start and end don't span a - // whole physical page. - continue + n := t.prev() + h.free.erase(t) + t = n + h.scav.insert(s) + released += r + } +} + +// scavengeAll visits each node in the unscav treap and scavenges the +// treapNode's span. It then removes the scavenged span from +// unscav and adds it into scav before continuing. h must be locked. +func (h *mheap) scavengeAll(now, limit uint64) uintptr { + // Iterate over the treap scavenging spans if unused for at least limit time. + released := uintptr(0) + for t := h.free.start(); t.valid(); { + s := t.span() + n := t.next() + if (now - uint64(s.unusedsince)) > limit { + r := s.scavenge() + if r != 0 { + h.free.erase(t) + h.scav.insert(s) + released += r } } - len := end - start - - released := len - (s.npreleased << _PageShift) - if physPageSize > _PageSize && released == 0 { - continue - } - memstats.heap_released += uint64(released) - sumreleased += released - s.npreleased = len >> _PageShift - sysUnused(unsafe.Pointer(start), len) + t = n } - return sumreleased + return released } func (h *mheap) scavenge(k int32, now, limit uint64) { @@ -1149,17 +1339,13 @@ func (h *mheap) scavenge(k int32, now, limit uint64) { gp := getg() gp.m.mallocing++ lock(&h.lock) - var sumreleased uintptr - for i := 0; i < len(h.free); i++ { - sumreleased += scavengelist(&h.free[i], now, limit) - } - sumreleased += scavengetreap(h.freelarge.treap, now, limit) + released := h.scavengeAll(now, limit) unlock(&h.lock) gp.m.mallocing-- if debug.gctrace > 0 { - if sumreleased > 0 { - print("scvg", k, ": ", sumreleased>>20, " MB released\n") + if released > 0 { + print("scvg", k, ": ", released>>20, " MB released\n") } print("scvg", k, ": inuse: ", memstats.heap_inuse>>20, ", idle: ", memstats.heap_idle>>20, ", sys: ", memstats.heap_sys>>20, ", released: ", memstats.heap_released>>20, ", consumed: ", (memstats.heap_sys-memstats.heap_released)>>20, " (MB)\n") } @@ -1181,11 +1367,10 @@ func (span *mspan) init(base uintptr, npages uintptr) { span.npages = npages span.allocCount = 0 span.spanclass = 0 - span.incache = false span.elemsize = 0 - span.state = _MSpanDead + span.state = mSpanDead span.unusedsince = 0 - span.npreleased = 0 + span.scavenged = false span.speciallock.key = 0 span.specials = nil span.needzero = 0 @@ -1206,9 +1391,9 @@ func (list *mSpanList) init() { func (list *mSpanList) remove(span *mspan) { if span.list != list { - print("runtime: failed MSpanList_Remove span.npages=", span.npages, + print("runtime: failed mSpanList.remove span.npages=", span.npages, " span=", span, " prev=", span.prev, " span.list=", span.list, " list=", list, "\n") - throw("MSpanList_Remove") + throw("mSpanList.remove") } if list.first == span { list.first = span.next @@ -1231,8 +1416,8 @@ func (list *mSpanList) isEmpty() bool { func (list *mSpanList) insert(span *mspan) { if span.next != nil || span.prev != nil || span.list != nil { - println("runtime: failed MSpanList_Insert", span, span.next, span.prev, span.list) - throw("MSpanList_Insert") + println("runtime: failed mSpanList.insert", span, span.next, span.prev, span.list) + throw("mSpanList.insert") } span.next = list.first if list.first != nil { @@ -1249,8 +1434,8 @@ func (list *mSpanList) insert(span *mspan) { func (list *mSpanList) insertBack(span *mspan) { if span.next != nil || span.prev != nil || span.list != nil { - println("runtime: failed MSpanList_InsertBack", span, span.next, span.prev, span.list) - throw("MSpanList_InsertBack") + println("runtime: failed mSpanList.insertBack", span, span.next, span.prev, span.list) + throw("mSpanList.insertBack") } span.prev = list.last if list.last != nil { @@ -1432,9 +1617,6 @@ func addfinalizer(p unsafe.Pointer, f *funcval, ft *functype, ot *ptrtype) bool // Mark the finalizer itself, since the // special isn't part of the GC'd heap. scanblock(uintptr(unsafe.Pointer(&s.fn)), sys.PtrSize, &oneptrmask[0], gcw) - if gcBlackenPromptly { - gcw.dispose() - } releasem(mp) } return true @@ -1479,7 +1661,7 @@ func setprofilebucket(p unsafe.Pointer, b *bucket) { } // Do whatever cleanup needs to be done to deallocate s. It has -// already been unlinked from the MSpan specials list. +// already been unlinked from the mspan specials list. func freespecial(s *special, p unsafe.Pointer, size uintptr) { switch s.kind { case _KindSpecialFinalizer: diff --git a/libgo/go/runtime/mkfastlog2table.go b/libgo/go/runtime/mkfastlog2table.go index 587ebf476d3..305c84a7c11 100644 --- a/libgo/go/runtime/mkfastlog2table.go +++ b/libgo/go/runtime/mkfastlog2table.go @@ -20,7 +20,7 @@ import ( func main() { var buf bytes.Buffer - fmt.Fprintln(&buf, "// AUTO-GENERATED by mkfastlog2table.go") + fmt.Fprintln(&buf, "// Code generated by mkfastlog2table.go; DO NOT EDIT.") fmt.Fprintln(&buf, "// Run go generate from src/runtime to update.") fmt.Fprintln(&buf, "// See mkfastlog2table.go for comments.") fmt.Fprintln(&buf) diff --git a/libgo/go/runtime/mprof.go b/libgo/go/runtime/mprof.go index 2bbf37a63e4..ab975696fe6 100644 --- a/libgo/go/runtime/mprof.go +++ b/libgo/go/runtime/mprof.go @@ -734,7 +734,7 @@ func GoroutineProfile(p []StackRecord) (n int, ok bool) { isOK := func(gp1 *g) bool { // Checking isSystemGoroutine here makes GoroutineProfile // consistent with both NumGoroutine and Stack. - return gp1 != gp && readgstatus(gp1) != _Gdead && !isSystemGoroutine(gp1) + return gp1 != gp && readgstatus(gp1) != _Gdead && !isSystemGoroutine(gp1, false) } stopTheWorld("profile") diff --git a/libgo/go/runtime/mstats.go b/libgo/go/runtime/mstats.go index 8aac8502e0b..cd9da02afda 100644 --- a/libgo/go/runtime/mstats.go +++ b/libgo/go/runtime/mstats.go @@ -38,24 +38,10 @@ type mstats struct { heap_alloc uint64 // bytes allocated and not yet freed (same as alloc above) heap_sys uint64 // virtual address space obtained from system for GC'd heap heap_idle uint64 // bytes in idle spans - heap_inuse uint64 // bytes in _MSpanInUse spans + heap_inuse uint64 // bytes in mSpanInUse spans heap_released uint64 // bytes released to the os heap_objects uint64 // total number of allocated objects - // TODO(austin): heap_released is both useless and inaccurate - // in its current form. It's useless because, from the user's - // and OS's perspectives, there's no difference between a page - // that has not yet been faulted in and a page that has been - // released back to the OS. We could fix this by considering - // newly mapped spans to be "released". It's inaccurate - // because when we split a large span for allocation, we - // "unrelease" all pages in the large span and not just the - // ones we split off for use. This is trickier to fix because - // we currently don't know which pages of a span we've - // released. We could fix it by separating "free" and - // "released" spans, but then we have to allocate from runs of - // free and released spans. - // Statistics about allocation of low-level fixed-size structures. // Protected by FixAlloc locks. stacks_inuse uint64 // bytes in manually-managed stack spans @@ -543,7 +529,7 @@ func updatememstats() { memstats.by_size[i].nfree = 0 } - // Flush MCache's to MCentral. + // Flush mcache's to mcentral. systemstack(flushallmcaches) // Aggregate local stats. diff --git a/libgo/go/runtime/mwbbuf.go b/libgo/go/runtime/mwbbuf.go index 39d13709069..4c875ff2d15 100644 --- a/libgo/go/runtime/mwbbuf.go +++ b/libgo/go/runtime/mwbbuf.go @@ -23,6 +23,7 @@ package runtime import ( + "runtime/internal/atomic" "runtime/internal/sys" "unsafe" ) @@ -56,6 +57,12 @@ type wbBuf struct { // on. This must be a multiple of wbBufEntryPointers because // the write barrier only checks for overflow once per entry. buf [wbBufEntryPointers * wbBufEntries]uintptr + + // debugGen causes the write barrier buffer to flush after + // every write barrier if equal to gcWorkPauseGen. This is for + // debugging #27993. This is only set if debugCachedWork is + // set. + debugGen uint32 } const ( @@ -79,7 +86,7 @@ const ( func (b *wbBuf) reset() { start := uintptr(unsafe.Pointer(&b.buf[0])) b.next = start - if gcBlackenPromptly || writeBarrier.cgo { + if writeBarrier.cgo || (debugCachedWork && (throwOnGCWork || b.debugGen == atomic.Load(&gcWorkPauseGen))) { // Effectively disable the buffer by forcing a flush // on every barrier. b.end = uintptr(unsafe.Pointer(&b.buf[wbBufEntryPointers])) @@ -107,6 +114,11 @@ func (b *wbBuf) discard() { b.next = uintptr(unsafe.Pointer(&b.buf[0])) } +// empty reports whether b contains no pointers. +func (b *wbBuf) empty() bool { + return b.next == uintptr(unsafe.Pointer(&b.buf[0])) +} + // putFast adds old and new to the write barrier buffer and returns // false if a flush is necessary. Callers should use this as: // @@ -192,10 +204,32 @@ func wbBufFlush(dst *uintptr, src uintptr) { // Switch to the system stack so we don't have to worry about // the untyped stack slots or safe points. systemstack(func() { - wbBufFlush1(getg().m.p.ptr()) + if debugCachedWork { + // For debugging, include the old value of the + // slot and some other data in the traceback. + wbBuf := &getg().m.p.ptr().wbBuf + var old uintptr + if dst != nil { + // dst may be nil in direct calls to wbBufFlush. + old = *dst + } + wbBufFlush1Debug(old, wbBuf.buf[0], wbBuf.buf[1], &wbBuf.buf[0], wbBuf.next) + } else { + wbBufFlush1(getg().m.p.ptr()) + } }) } +// wbBufFlush1Debug is a temporary function for debugging issue +// #27993. It exists solely to add some context to the traceback. +// +//go:nowritebarrierrec +//go:systemstack +//go:noinline +func wbBufFlush1Debug(old, buf1, buf2 uintptr, start *uintptr, next uintptr) { + wbBufFlush1(getg().m.p.ptr()) +} + // wbBufFlush1 flushes p's write barrier buffer to the GC work queue. // // This must not have write barriers because it is part of the write @@ -212,14 +246,16 @@ func wbBufFlush1(_p_ *p) { n := (_p_.wbBuf.next - start) / unsafe.Sizeof(_p_.wbBuf.buf[0]) ptrs := _p_.wbBuf.buf[:n] - // Reset the buffer. - _p_.wbBuf.reset() + // Poison the buffer to make extra sure nothing is enqueued + // while we're processing the buffer. + _p_.wbBuf.next = 0 if useCheckmark { // Slow path for checkmark mode. for _, ptr := range ptrs { shade(ptr) } + _p_.wbBuf.reset() return } @@ -270,9 +306,6 @@ func wbBufFlush1(_p_ *p) { // Enqueue the greyed objects. gcw.putBatch(ptrs[:pos]) - if gcphase == _GCmarktermination || gcBlackenPromptly { - // Ps aren't allowed to cache work during mark - // termination. - gcw.dispose() - } + + _p_.wbBuf.reset() } diff --git a/libgo/go/runtime/netpoll.go b/libgo/go/runtime/netpoll.go index 6016b7d64f5..fa7f1fad71c 100644 --- a/libgo/go/runtime/netpoll.go +++ b/libgo/go/runtime/netpoll.go @@ -59,14 +59,15 @@ type pollDesc struct { lock mutex // protects the following fields fd uintptr closing bool - seq uintptr // protects from stale timers and ready notifications + user uint32 // user settable cookie + rseq uintptr // protects from stale read timers rg uintptr // pdReady, pdWait, G waiting for read or nil rt timer // read deadline timer (set if rt.f != nil) rd int64 // read deadline + wseq uintptr // protects from stale write timers wg uintptr // pdReady, pdWait, G waiting for write or nil wt timer // write deadline timer wd int64 // write deadline - user uint32 // user settable cookie } type pollCache struct { @@ -95,12 +96,19 @@ func netpollinited() bool { return atomic.Load(&netpollInited) != 0 } -//go:linkname poll_runtime_pollServerDescriptor internal..z2fpoll.runtime_pollServerDescriptor +//go:linkname poll_runtime_isPollServerDescriptor internal..z2fpoll.runtime_isPollServerDescriptor -// poll_runtime_pollServerDescriptor returns the descriptor being used, -// or ^uintptr(0) if the system does not use a poll descriptor. -func poll_runtime_pollServerDescriptor() uintptr { - return netpolldescriptor() +// poll_runtime_isPollServerDescriptor reports whether fd is a +// descriptor being used by netpoll. +func poll_runtime_isPollServerDescriptor(fd uintptr) bool { + fds := netpolldescriptor() + if GOOS != "aix" { + return fd == fds + } else { + // AIX have a pipe in its netpoll implementation. + // Therefore, two fd are returned by netpolldescriptor using a mask. + return fd == fds&0xFFFF || fd == (fds>>16)&0xFFFF + } } //go:linkname poll_runtime_pollOpen internal..z2fpoll.runtime_pollOpen @@ -115,9 +123,10 @@ func poll_runtime_pollOpen(fd uintptr) (*pollDesc, int) { } pd.fd = fd pd.closing = false - pd.seq++ + pd.rseq++ pd.rg = 0 pd.rd = 0 + pd.wseq++ pd.wg = 0 pd.wd = 0 unlock(&pd.lock) @@ -200,19 +209,15 @@ func poll_runtime_pollSetDeadline(pd *pollDesc, d int64, mode int) { unlock(&pd.lock) return } - pd.seq++ // invalidate current timers - // Reset current timers. - if pd.rt.f != nil { - deltimer(&pd.rt) - pd.rt.f = nil - } - if pd.wt.f != nil { - deltimer(&pd.wt) - pd.wt.f = nil - } - // Setup new timers. - if d != 0 && d <= nanotime() { - d = -1 + rd0, wd0 := pd.rd, pd.wd + combo0 := rd0 > 0 && rd0 == wd0 + if d > 0 { + d += nanotime() + if d <= 0 { + // If the user has a deadline in the future, but the delay calculation + // overflows, then set the deadline to the maximum possible value. + d = 1<<63 - 1 + } } if mode == 'r' || mode == 'r'+'w' { pd.rd = d @@ -220,39 +225,58 @@ func poll_runtime_pollSetDeadline(pd *pollDesc, d int64, mode int) { if mode == 'w' || mode == 'r'+'w' { pd.wd = d } - if pd.rd > 0 && pd.rd == pd.wd { - pd.rt.f = netpollDeadline - pd.rt.when = pd.rd - // Copy current seq into the timer arg. - // Timer func will check the seq against current descriptor seq, - // if they differ the descriptor was reused or timers were reset. - pd.rt.arg = pd - pd.rt.seq = pd.seq - addtimer(&pd.rt) - } else { + combo := pd.rd > 0 && pd.rd == pd.wd + rtf := netpollReadDeadline + if combo { + rtf = netpollDeadline + } + if pd.rt.f == nil { if pd.rd > 0 { - pd.rt.f = netpollReadDeadline + pd.rt.f = rtf pd.rt.when = pd.rd + // Copy current seq into the timer arg. + // Timer func will check the seq against current descriptor seq, + // if they differ the descriptor was reused or timers were reset. pd.rt.arg = pd - pd.rt.seq = pd.seq + pd.rt.seq = pd.rseq addtimer(&pd.rt) } - if pd.wd > 0 { + } else if pd.rd != rd0 || combo != combo0 { + pd.rseq++ // invalidate current timers + if pd.rd > 0 { + modtimer(&pd.rt, pd.rd, 0, rtf, pd, pd.rseq) + } else { + deltimer(&pd.rt) + pd.rt.f = nil + } + } + if pd.wt.f == nil { + if pd.wd > 0 && !combo { pd.wt.f = netpollWriteDeadline pd.wt.when = pd.wd pd.wt.arg = pd - pd.wt.seq = pd.seq + pd.wt.seq = pd.wseq addtimer(&pd.wt) } + } else if pd.wd != wd0 || combo != combo0 { + pd.wseq++ // invalidate current timers + if pd.wd > 0 && !combo { + modtimer(&pd.wt, pd.wd, 0, netpollWriteDeadline, pd, pd.wseq) + } else { + deltimer(&pd.wt) + pd.wt.f = nil + } } // If we set the new deadline in the past, unblock currently pending IO if any. var rg, wg *g - atomicstorep(unsafe.Pointer(&wg), nil) // full memory barrier between stores to rd/wd and load of rg/wg in netpollunblock - if pd.rd < 0 { - rg = netpollunblock(pd, 'r', false) - } - if pd.wd < 0 { - wg = netpollunblock(pd, 'w', false) + if pd.rd < 0 || pd.wd < 0 { + atomic.StorepNoWB(noescape(unsafe.Pointer(&wg)), nil) // full memory barrier between stores to rd/wd and load of rg/wg in netpollunblock + if pd.rd < 0 { + rg = netpollunblock(pd, 'r', false) + } + if pd.wd < 0 { + wg = netpollunblock(pd, 'w', false) + } } unlock(&pd.lock) if rg != nil { @@ -270,9 +294,10 @@ func poll_runtime_pollUnblock(pd *pollDesc) { throw("runtime: unblock on closing polldesc") } pd.closing = true - pd.seq++ + pd.rseq++ + pd.wseq++ var rg, wg *g - atomicstorep(unsafe.Pointer(&rg), nil) // full memory barrier between store to closing and read of rg/wg in netpollunblock + atomic.StorepNoWB(noescape(unsafe.Pointer(&rg)), nil) // full memory barrier between store to closing and read of rg/wg in netpollunblock rg = netpollunblock(pd, 'r', false) wg = netpollunblock(pd, 'w', false) if pd.rt.f != nil { @@ -292,24 +317,22 @@ func poll_runtime_pollUnblock(pd *pollDesc) { } } -// make pd ready, newly runnable goroutines (if any) are returned in rg/wg +// make pd ready, newly runnable goroutines (if any) are added to toRun. // May run during STW, so write barriers are not allowed. //go:nowritebarrier -func netpollready(gpp *guintptr, pd *pollDesc, mode int32) { - var rg, wg guintptr +func netpollready(toRun *gList, pd *pollDesc, mode int32) { + var rg, wg *g if mode == 'r' || mode == 'r'+'w' { - rg.set(netpollunblock(pd, 'r', true)) + rg = netpollunblock(pd, 'r', true) } if mode == 'w' || mode == 'r'+'w' { - wg.set(netpollunblock(pd, 'w', true)) + wg = netpollunblock(pd, 'w', true) } - if rg != 0 { - rg.ptr().schedlink = *gpp - *gpp = rg + if rg != nil { + toRun.push(rg) } - if wg != 0 { - wg.ptr().schedlink = *gpp - *gpp = wg + if wg != nil { + toRun.push(wg) } } @@ -409,7 +432,11 @@ func netpolldeadlineimpl(pd *pollDesc, seq uintptr, read, write bool) { lock(&pd.lock) // Seq arg is seq when the timer was set. // If it's stale, ignore the timer event. - if seq != pd.seq { + currentSeq := pd.rseq + if !read { + currentSeq = pd.wseq + } + if seq != currentSeq { // The descriptor was reused or timers were reset. unlock(&pd.lock) return @@ -420,7 +447,7 @@ func netpolldeadlineimpl(pd *pollDesc, seq uintptr, read, write bool) { throw("runtime: inconsistent read deadline") } pd.rd = -1 - atomicstorep(unsafe.Pointer(&pd.rt.f), nil) // full memory barrier between store to rd and load of rg in netpollunblock + atomic.StorepNoWB(unsafe.Pointer(&pd.rt.f), nil) // full memory barrier between store to rd and load of rg in netpollunblock rg = netpollunblock(pd, 'r', false) } var wg *g @@ -429,7 +456,7 @@ func netpolldeadlineimpl(pd *pollDesc, seq uintptr, read, write bool) { throw("runtime: inconsistent write deadline") } pd.wd = -1 - atomicstorep(unsafe.Pointer(&pd.wt.f), nil) // full memory barrier between store to wd and load of wg in netpollunblock + atomic.StorepNoWB(unsafe.Pointer(&pd.wt.f), nil) // full memory barrier between store to wd and load of wg in netpollunblock wg = netpollunblock(pd, 'w', false) } unlock(&pd.lock) diff --git a/libgo/go/runtime/netpoll_aix.go b/libgo/go/runtime/netpoll_aix.go index cbeb8c9ed18..86c3e960f42 100644 --- a/libgo/go/runtime/netpoll_aix.go +++ b/libgo/go/runtime/netpoll_aix.go @@ -1,4 +1,4 @@ -// Copyright 2017 The Go Authors. All rights reserved. +// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. @@ -8,17 +8,7 @@ import "unsafe" // This is based on the former libgo/runtime/netpoll_select.c implementation // except that it uses poll instead of select and is written in Go. - -type pollfd struct { - fd int32 - events int16 - revents int16 -} - -const _POLLIN = 0x0001 -const _POLLOUT = 0x0002 -const _POLLHUP = 0x2000 -const _POLLERR = 0x4000 +// It's also based on Solaris implementation for the arming mechanisms //go:noescape //extern poll @@ -31,62 +21,95 @@ func libc_pipe(fd *int32) int32 //extern __go_fcntl_uintptr func fcntlUintptr(fd, cmd, arg uintptr) (uintptr, uintptr) -func fcntl(fd, cmd int32, arg uintptr) uintptr { +func fcntl(fd, cmd int32, arg uintptr) int32 { r, _ := fcntlUintptr(uintptr(fd), uintptr(cmd), arg) - return r + return int32(r) } +// pollfd represents the poll structure for AIX operating system. +type pollfd struct { + fd int32 + events int16 + revents int16 +} + +const _POLLIN = 0x0001 +const _POLLOUT = 0x0002 +const _POLLHUP = 0x2000 +const _POLLERR = 0x4000 +const _O_NONBLOCK = 0x4 + var ( - pfds []pollfd - pds []*pollDesc - mtxpoll mutex - mtxset mutex - rdwake int32 - wrwake int32 - needsUpdate bool + pfds []pollfd + pds []*pollDesc + mtxpoll mutex + mtxset mutex + rdwake int32 + wrwake int32 + pendingUpdates int32 ) +const pollVerbose = false + func netpollinit() { var p [2]int32 // Create the pipe we use to wakeup poll. if err := libc_pipe(&p[0]); err < 0 { - throw("runtime: netpollinit failed to create pipe") + throw("netpollinit: failed to create pipe") } rdwake = p[0] wrwake = p[1] - fl := fcntl(rdwake, _F_GETFL, 0) + fl := uintptr(fcntl(rdwake, _F_GETFL, 0)) fcntl(rdwake, _F_SETFL, fl|_O_NONBLOCK) fcntl(rdwake, _F_SETFD, _FD_CLOEXEC) - fl = fcntl(wrwake, _F_GETFL, 0) + fl = uintptr(fcntl(wrwake, _F_GETFL, 0)) + fcntl(wrwake, _F_SETFL, fl|_O_NONBLOCK) fcntl(wrwake, _F_SETFD, _FD_CLOEXEC) // Pre-allocate array of pollfd structures for poll. + if pollVerbose { + println("*** allocating") + } pfds = make([]pollfd, 1, 128) + if pollVerbose { + println("*** allocating done", &pfds[0]) + } + // Poll the read side of the pipe. pfds[0].fd = rdwake pfds[0].events = _POLLIN - // Allocate index to pd array pds = make([]*pollDesc, 1, 128) pds[0] = nil } func netpolldescriptor() uintptr { - return ^uintptr(0) + // Both fd must be returned + if rdwake > 0xFFFF || wrwake > 0xFFFF { + throw("netpolldescriptor: invalid fd number") + } + return uintptr(rdwake<<16 | wrwake) } +// netpollwakeup writes on wrwake to wakeup poll before any changes. func netpollwakeup() { - if !needsUpdate { - needsUpdate = true + if pendingUpdates == 0 { + pendingUpdates = 1 + if pollVerbose { + println("*** writing 1 byte") + } b := [1]byte{0} write(uintptr(wrwake), unsafe.Pointer(&b[0]), 1) } } func netpollopen(fd uintptr, pd *pollDesc) int32 { + if pollVerbose { + println("*** netpollopen", fd) + } lock(&mtxpoll) netpollwakeup() @@ -94,15 +117,16 @@ func netpollopen(fd uintptr, pd *pollDesc) int32 { unlock(&mtxpoll) pd.user = uint32(len(pfds)) - var pfd pollfd - pfd.fd = int32(fd) - pfds = append(pfds, pfd) + pfds = append(pfds, pollfd{fd: int32(fd)}) pds = append(pds, pd) unlock(&mtxset) return 0 } func netpollclose(fd uintptr) int32 { + if pollVerbose { + println("*** netpollclose", fd) + } lock(&mtxpoll) netpollwakeup() @@ -125,6 +149,9 @@ func netpollclose(fd uintptr) int32 { } func netpollarm(pd *pollDesc, mode int) { + if pollVerbose { + println("*** netpollarm", pd.fd, mode) + } lock(&mtxpoll) netpollwakeup() @@ -141,23 +168,36 @@ func netpollarm(pd *pollDesc, mode int) { } //go:nowritebarrierrec -func netpoll(block bool) *g { +func netpoll(block bool) gList { timeout := ^uintptr(0) if !block { timeout = 0 - return nil + return gList{} + } + if pollVerbose { + println("*** netpoll", block) } retry: lock(&mtxpoll) lock(&mtxset) - needsUpdate = false + pendingUpdates = 0 unlock(&mtxpoll) + if pollVerbose { + println("*** netpoll before poll") + } n := libc_poll(&pfds[0], uintptr(len(pfds)), timeout) + if pollVerbose { + println("*** netpoll after poll", n) + } if n < 0 { e := errno() if e != _EINTR { - throw("runtime: poll failed") + println("errno=", e, " len(pfds)=", len(pfds)) + throw("poll failed") + } + if pollVerbose { + println("*** poll failed") } unlock(&mtxset) goto retry @@ -166,13 +206,16 @@ retry: if n != 0 && pfds[0].revents&(_POLLIN|_POLLHUP|_POLLERR) != 0 { var b [1]byte for read(rdwake, unsafe.Pointer(&b[0]), 1) == 1 { + if pollVerbose { + println("*** read 1 byte from pipe") + } } // Do not look at the other fds in this case as the mode may have changed // XXX only additions of flags are made, so maybe it is ok unlock(&mtxset) goto retry } - var gp guintptr + var toRun gList for i := 0; i < len(pfds) && n > 0; i++ { pfd := &pfds[i] @@ -186,13 +229,19 @@ retry: pfd.events &= ^_POLLOUT } if mode != 0 { - netpollready(&gp, pds[i], mode) + if pollVerbose { + println("*** netpollready i=", i, "revents=", pfd.revents, "events=", pfd.events, "pd=", pds[i]) + } + netpollready(&toRun, pds[i], mode) n-- } } unlock(&mtxset) - if block && gp == 0 { + if block && toRun.empty() { goto retry } - return gp.ptr() + if pollVerbose { + println("*** netpoll returning end") + } + return toRun } diff --git a/libgo/go/runtime/netpoll_epoll.go b/libgo/go/runtime/netpoll_epoll.go index ced399d781e..2004fbc4da8 100644 --- a/libgo/go/runtime/netpoll_epoll.go +++ b/libgo/go/runtime/netpoll_epoll.go @@ -75,9 +75,9 @@ func netpollarm(pd *pollDesc, mode int) { // polls for ready network connections // returns list of goroutines that become runnable -func netpoll(block bool) *g { +func netpoll(block bool) gList { if epfd == -1 { - return nil + return gList{} } waitms := int32(-1) if !block { @@ -94,7 +94,7 @@ retry: } goto retry } - var gp guintptr + var toRun gList for i := int32(0); i < n; i++ { ev := &events[i] if ev.events == 0 { @@ -110,11 +110,11 @@ retry: if mode != 0 { pd := *(**pollDesc)(unsafe.Pointer(&ev.data)) - netpollready(&gp, pd, mode) + netpollready(&toRun, pd, mode) } } - if block && gp == 0 { + if block && toRun.empty() { goto retry } - return gp.ptr() + return toRun } diff --git a/libgo/go/runtime/netpoll_fake.go b/libgo/go/runtime/netpoll_fake.go index aab18dc8468..5b1a63a8787 100644 --- a/libgo/go/runtime/netpoll_fake.go +++ b/libgo/go/runtime/netpoll_fake.go @@ -27,6 +27,6 @@ func netpollclose(fd uintptr) int32 { func netpollarm(pd *pollDesc, mode int) { } -func netpoll(block bool) *g { - return nil +func netpoll(block bool) gList { + return gList{} } diff --git a/libgo/go/runtime/netpoll_kqueue.go b/libgo/go/runtime/netpoll_kqueue.go index 1f68effbf9d..3d6265092e6 100644 --- a/libgo/go/runtime/netpoll_kqueue.go +++ b/libgo/go/runtime/netpoll_kqueue.go @@ -73,9 +73,9 @@ func netpollarm(pd *pollDesc, mode int) { // Polls for ready network connections. // Returns list of goroutines that become runnable. -func netpoll(block bool) *g { +func netpoll(block bool) gList { if kq == -1 { - return nil + return gList{} } var tp *timespec var ts timespec @@ -93,7 +93,7 @@ retry: } goto retry } - var gp guintptr + var toRun gList for i := 0; i < int(n); i++ { ev := &events[i] var mode int32 @@ -117,11 +117,11 @@ retry: mode += 'w' } if mode != 0 { - netpollready(&gp, (*pollDesc)(unsafe.Pointer(ev.udata)), mode) + netpollready(&toRun, (*pollDesc)(unsafe.Pointer(ev.udata)), mode) } } - if block && gp == 0 { + if block && toRun.empty() { goto retry } - return gp.ptr() + return toRun } diff --git a/libgo/go/runtime/netpoll_solaris.go b/libgo/go/runtime/netpoll_solaris.go index a960e93b8bf..b8baffdfc12 100644 --- a/libgo/go/runtime/netpoll_solaris.go +++ b/libgo/go/runtime/netpoll_solaris.go @@ -166,9 +166,9 @@ func netpollarm(pd *pollDesc, mode int) { // polls for ready network connections // returns list of goroutines that become runnable -func netpoll(block bool) *g { +func netpoll(block bool) gList { if portfd == -1 { - return nil + return gList{} } var wait *timespec @@ -188,7 +188,7 @@ retry: goto retry } - var gp guintptr + var toRun gList for i := 0; i < int(n); i++ { ev := &events[i] @@ -219,12 +219,12 @@ retry: } if mode != 0 { - netpollready(&gp, pd, mode) + netpollready(&toRun, pd, mode) } } - if block && gp == 0 { + if block && toRun.empty() { goto retry } - return gp.ptr() + return toRun } diff --git a/libgo/go/runtime/netpoll_stub.go b/libgo/go/runtime/netpoll_stub.go index a4d6b4608ac..f585333579d 100644 --- a/libgo/go/runtime/netpoll_stub.go +++ b/libgo/go/runtime/netpoll_stub.go @@ -10,10 +10,10 @@ var netpollWaiters uint32 // Polls for ready network connections. // Returns list of goroutines that become runnable. -func netpoll(block bool) (gp *g) { +func netpoll(block bool) gList { // Implementation for platforms that do not support // integrated network poller. - return + return gList{} } func netpollinited() bool { diff --git a/libgo/go/runtime/netpoll_windows.go b/libgo/go/runtime/netpoll_windows.go index 134071f5e3c..07ef15ce2f3 100644 --- a/libgo/go/runtime/netpoll_windows.go +++ b/libgo/go/runtime/netpoll_windows.go @@ -63,17 +63,17 @@ func netpollarm(pd *pollDesc, mode int) { // Polls for completed network IO. // Returns list of goroutines that become runnable. -func netpoll(block bool) *g { +func netpoll(block bool) gList { var entries [64]overlappedEntry var wait, qty, key, flags, n, i uint32 var errno int32 var op *net_op - var gp guintptr + var toRun gList mp := getg().m if iocphandle == _INVALID_HANDLE_VALUE { - return nil + return gList{} } wait = 0 if block { @@ -92,7 +92,7 @@ retry: mp.blocked = false errno = int32(getlasterror()) if !block && errno == _WAIT_TIMEOUT { - return nil + return gList{} } println("runtime: GetQueuedCompletionStatusEx failed (errno=", errno, ")") throw("runtime: netpoll failed") @@ -105,7 +105,7 @@ retry: if stdcall5(_WSAGetOverlappedResult, op.pd.fd, uintptr(unsafe.Pointer(op)), uintptr(unsafe.Pointer(&qty)), 0, uintptr(unsafe.Pointer(&flags))) == 0 { errno = int32(getlasterror()) } - handlecompletion(&gp, op, errno, qty) + handlecompletion(&toRun, op, errno, qty) } } else { op = nil @@ -118,7 +118,7 @@ retry: mp.blocked = false errno = int32(getlasterror()) if !block && errno == _WAIT_TIMEOUT { - return nil + return gList{} } if op == nil { println("runtime: GetQueuedCompletionStatus failed (errno=", errno, ")") @@ -127,15 +127,15 @@ retry: // dequeued failed IO packet, so report that } mp.blocked = false - handlecompletion(&gp, op, errno, qty) + handlecompletion(&toRun, op, errno, qty) } - if block && gp == 0 { + if block && toRun.empty() { goto retry } - return gp.ptr() + return toRun } -func handlecompletion(gpp *guintptr, op *net_op, errno int32, qty uint32) { +func handlecompletion(toRun *gList, op *net_op, errno int32, qty uint32) { if op == nil { println("runtime: GetQueuedCompletionStatus returned op == nil") throw("runtime: netpoll failed") @@ -147,5 +147,5 @@ func handlecompletion(gpp *guintptr, op *net_op, errno int32, qty uint32) { } op.errno = errno op.qty = qty - netpollready(gpp, op.pd, mode) + netpollready(toRun, op.pd, mode) } diff --git a/libgo/go/runtime/os_aix.go b/libgo/go/runtime/os_aix.go index 246b9c3c944..10036162c76 100644 --- a/libgo/go/runtime/os_aix.go +++ b/libgo/go/runtime/os_aix.go @@ -1,7 +1,9 @@ -// Copyright 2017 The Go Authors. All rights reserved. +// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build aix + package runtime import "unsafe" @@ -55,17 +57,16 @@ func semacreate(mp *m) { func semasleep(ns int64) int32 { _m_ := getg().m if ns >= 0 { - const CLOCK_REALTIME int64 = 9 var ts timespec - if clock_gettime(CLOCK_REALTIME, &ts) != 0 { + if clock_gettime(_CLOCK_REALTIME, &ts) != 0 { throw("clock_gettime") } - ts.tv_sec += timespec_sec_t(ns / 1000000000) - ts.tv_nsec += timespec_nsec_t(ns % 1000000000) - if ts.tv_nsec >= 1000000000 { - ts.tv_sec += timespec_sec_t(1) - ts.tv_nsec -= timespec_nsec_t(1000000000) + ts.tv_sec += ns / 1e9 + ts.tv_nsec += ns % 1e9 + if ts.tv_nsec >= 1e9 { + ts.tv_sec++ + ts.tv_nsec -= 1e9 } if sem_timedwait((*semt)(unsafe.Pointer(_m_.mos.waitsema)), &ts) != 0 { @@ -73,6 +74,7 @@ func semasleep(ns int64) int32 { if err == _ETIMEDOUT || err == _EAGAIN || err == _EINTR { return -1 } + println("sem_timedwait err ", err, " ts.tv_sec ", ts.tv_sec, " ts.tv_nsec ", ts.tv_nsec, " ns ", ns, " id ", _m_.id) throw("sem_timedwait") } return 0 @@ -96,3 +98,8 @@ func semawakeup(mp *m) { throw("sem_post") } } + +const ( + _CLOCK_REALTIME = 9 + _CLOCK_MONOTONIC = 10 +) diff --git a/libgo/go/runtime/os_freebsd.go b/libgo/go/runtime/os_freebsd.go index 34939c56f03..4cce6fdb7f4 100644 --- a/libgo/go/runtime/os_freebsd.go +++ b/libgo/go/runtime/os_freebsd.go @@ -63,3 +63,42 @@ func futexwakeup(addr *uint32, cnt uint32) { print("umtx_wake_addr=", addr, " ret=", ret, "\n") }) } + +func sysargs(argc int32, argv **byte) { + n := argc + 1 + + // skip over argv, envp to get to auxv + for argv_index(argv, n) != nil { + n++ + } + + // skip NULL separator + n++ + + // now argv+n is auxv + auxv := (*[1 << 28]uintptr)(add(unsafe.Pointer(argv), uintptr(n)*sys.PtrSize)) + sysauxv(auxv[:]) +} + +const ( + _AT_NULL = 0 // Terminates the vector + _AT_PAGESZ = 6 // Page size in bytes + _AT_TIMEKEEP = 22 // Pointer to timehands. + _AT_HWCAP = 25 // CPU feature flags + _AT_HWCAP2 = 26 // CPU feature flags 2 +) + +func sysauxv(auxv []uintptr) { + for i := 0; auxv[i] != _AT_NULL; i += 2 { + tag, val := auxv[i], auxv[i+1] + switch tag { + // _AT_NCPUS from auxv shouldn't be used due to golang.org/issue/15206 + case _AT_PAGESZ: + physPageSize = val + case _AT_TIMEKEEP: + timekeepSharedPage = (*vdsoTimekeep)(unsafe.Pointer(val)) + } + + archauxv(tag, val) + } +} diff --git a/libgo/go/runtime/os_linux_arm64.go b/libgo/go/runtime/os_linux_arm64.go index 013e7ae17ac..30d63bfbdbc 100644 --- a/libgo/go/runtime/os_linux_arm64.go +++ b/libgo/go/runtime/os_linux_arm64.go @@ -22,7 +22,15 @@ func archauxv(tag, val uintptr) { case _AT_HWCAP: // arm64 doesn't have a 'cpuid' instruction equivalent and relies on // HWCAP/HWCAP2 bits for hardware capabilities. - cpu.HWCap = uint(val) + hwcap := uint(val) + if GOOS == "android" { + // The Samsung S9+ kernel reports support for atomics, but not all cores + // actually support them, resulting in SIGILL. See issue #28431. + // TODO(elias.naur): Only disable the optimization on bad chipsets. + const hwcap_ATOMICS = 1 << 8 + hwcap &= ^uint(hwcap_ATOMICS) + } + cpu.HWCap = hwcap case _AT_HWCAP2: cpu.HWCap2 = uint(val) } diff --git a/libgo/go/runtime/os_windows_arm.go b/libgo/go/runtime/os_windows_arm.go new file mode 100644 index 00000000000..10aff75e311 --- /dev/null +++ b/libgo/go/runtime/os_windows_arm.go @@ -0,0 +1,22 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package runtime + +import "unsafe" + +//go:nosplit +func cputicks() int64 { + var counter int64 + stdcall1(_QueryPerformanceCounter, uintptr(unsafe.Pointer(&counter))) + return counter +} + +func checkgoarm() { + if goarm < 7 { + print("Need atomic synchronization instructions, coprocessor ", + "access instructions. Recompile using GOARM=7.\n") + exit(1) + } +} diff --git a/libgo/go/runtime/panic.go b/libgo/go/runtime/panic.go index 752bf7185f7..bfd2f2d542b 100644 --- a/libgo/go/runtime/panic.go +++ b/libgo/go/runtime/panic.go @@ -54,7 +54,7 @@ var indexError = error(errorString("index out of range")) func panicindex() { name, _, _ := funcfileline(getcallerpc(), -1) - if hasprefix(name, "runtime.") { + if hasPrefix(name, "runtime.") { throw(string(indexError.(errorString))) } panicCheckMalloc(indexError) @@ -65,7 +65,7 @@ var sliceError = error(errorString("slice bounds out of range")) func panicslice() { name, _, _ := funcfileline(getcallerpc(), -1) - if hasprefix(name, "runtime.") { + if hasPrefix(name, "runtime.") { throw(string(sliceError.(errorString))) } panicCheckMalloc(sliceError) @@ -151,6 +151,14 @@ func newdefer() *_defer { systemstack(func() { d = new(_defer) }) + if debugCachedWork { + // Duplicate the tail below so if there's a + // crash in checkPut we can tell if d was just + // allocated or came from the pool. + d.link = gp._defer + gp._defer = d + return d + } } d.link = gp._defer gp._defer = d @@ -242,17 +250,22 @@ func deferreturn(frame *bool) { // code in jmpdefer. var fn func(unsafe.Pointer) *(*uintptr)(unsafe.Pointer(&fn)) = uintptr(noescape(unsafe.Pointer(&pfn))) + gp.deferring = true fn(d.arg) + gp.deferring = false } - // If we are returning from a Go function called by a - // C function running in a C thread, g may now be nil, - // in which case CgocallBackDone will have cleared _defer. - // In that case some other goroutine may already be using gp. + // If that was CgocallBackDone, it will have freed the + // defer for us, since we are no longer running as Go code. if getg() == nil { *frame = true return } + if gp.ranCgocallBackDone { + gp.ranCgocallBackDone = false + *frame = true + return + } gp._defer = d.link @@ -316,7 +329,9 @@ func checkdefer(frame *bool) { var fn func(unsafe.Pointer) *(*uintptr)(unsafe.Pointer(&fn)) = uintptr(noescape(unsafe.Pointer(&pfn))) + gp.deferring = true fn(d.arg) + gp.deferring = false freedefer(d) @@ -389,6 +404,7 @@ func Goexit() { // This code is similar to gopanic, see that implementation // for detailed comments. gp := getg() + gp.goexiting = true for { d := gp._defer if d == nil { @@ -409,7 +425,9 @@ func Goexit() { var fn func(unsafe.Pointer) *(*uintptr)(unsafe.Pointer(&fn)) = uintptr(noescape(unsafe.Pointer(&pfn))) + gp.deferring = true fn(d.arg) + gp.deferring = false if gp._defer != d { throw("bad defer entry in Goexit") @@ -419,6 +437,7 @@ func Goexit() { freedefer(d) // Note: we ignore recovers here because Goexit isn't a panic } + gp.goexiting = false goexit1() } @@ -532,7 +551,9 @@ func gopanic(e interface{}) { var fn func(unsafe.Pointer) *(*uintptr)(unsafe.Pointer(&fn)) = uintptr(noescape(unsafe.Pointer(&pfn))) + gp.deferring = true fn(d.arg) + gp.deferring = false if gp._defer != d { throw("bad defer entry in panic") @@ -649,7 +670,7 @@ func canrecover(retaddr uintptr) bool { } name := locs[1].function - if hasprefix(name, "runtime.") { + if hasPrefix(name, "runtime.") { return true } @@ -676,7 +697,7 @@ func canrecover(retaddr uintptr) bool { } // Ignore function in libffi. - if hasprefix(name, "ffi_") { + if hasPrefix(name, "ffi_") { continue } @@ -690,7 +711,7 @@ func canrecover(retaddr uintptr) bool { } // Ignore other functions in the reflect package. - if hasprefix(name, "reflect.") || hasprefix(name, ".1reflect.") { + if hasPrefix(name, "reflect.") || hasPrefix(name, ".1reflect.") { continue } @@ -700,7 +721,7 @@ func canrecover(retaddr uintptr) bool { if i < n { name = locs[i].function - if hasprefix(name, "runtime.") { + if hasPrefix(name, "runtime.") { return true } } @@ -734,7 +755,7 @@ func makefuncfficanrecover(loc []location) { } name := loc[1].function - if hasprefix(name, "runtime.") { + if hasPrefix(name, "runtime.") { d.makefunccanrecover = true } } @@ -935,10 +956,13 @@ func fatalpanic(msgs *_panic) { // It returns true if panic messages should be printed, or false if // the runtime is in bad shape and should just print stacks. // -// It can have write barriers because the write barrier explicitly -// ignores writes once dying > 0. +// It must not have write barriers even though the write barrier +// explicitly ignores writes once dying > 0. Write barriers still +// assume that g.m.p != nil, and this function may not have P +// in some contexts (e.g. a panic in a signal handler for a signal +// sent to an M with no P). // -//go:yeswritebarrierrec +//go:nowritebarrierrec func startpanic_m() bool { _g_ := getg() if mheap_.cachealloc.size == 0 { // very early @@ -958,8 +982,8 @@ func startpanic_m() bool { switch _g_.m.dying { case 0: + // Setting dying >0 has the side-effect of disabling this G's writebuf. _g_.m.dying = 1 - _g_.writebuf = nil atomic.Xadd(&panicking, 1) lock(&paniclk) if debug.schedtrace > 0 || debug.scheddetail > 0 { @@ -1061,7 +1085,7 @@ func canpanic(gp *g) bool { return true } -// isAbortPC returns true if pc is the program counter at which +// isAbortPC reports whether pc is the program counter at which // runtime.abort raises a signal. // // It is nosplit because it's part of the isgoexception diff --git a/libgo/go/runtime/pprof/internal/profile/filter.go b/libgo/go/runtime/pprof/internal/profile/filter.go index 1baa096a49c..9cad866df8c 100644 --- a/libgo/go/runtime/pprof/internal/profile/filter.go +++ b/libgo/go/runtime/pprof/internal/profile/filter.go @@ -55,7 +55,7 @@ func (p *Profile) FilterSamplesByName(focus, ignore, hide *regexp.Regexp) (fm, i return } -// matchesName returns whether the function name or file in the +// matchesName reports whether the function name or file in the // location matches the regular expression. func (loc *Location) matchesName(re *regexp.Regexp) bool { for _, ln := range loc.Line { diff --git a/libgo/go/runtime/pprof/internal/profile/profile.go b/libgo/go/runtime/pprof/internal/profile/profile.go index 64c3e3f054d..a6f8354b1e8 100644 --- a/libgo/go/runtime/pprof/internal/profile/profile.go +++ b/libgo/go/runtime/pprof/internal/profile/profile.go @@ -200,7 +200,7 @@ var libRx = regexp.MustCompile(`([.]so$|[.]so[._][0-9]+)`) // first. func (p *Profile) setMain() { for i := 0; i < len(p.Mapping); i++ { - file := strings.TrimSpace(strings.Replace(p.Mapping[i].File, "(deleted)", "", -1)) + file := strings.TrimSpace(strings.ReplaceAll(p.Mapping[i].File, "(deleted)", "")) if len(file) == 0 { continue } @@ -415,16 +415,16 @@ func (p *Profile) String() string { for _, m := range p.Mapping { bits := "" if m.HasFunctions { - bits = bits + "[FN]" + bits += "[FN]" } if m.HasFilenames { - bits = bits + "[FL]" + bits += "[FL]" } if m.HasLineNumbers { - bits = bits + "[LN]" + bits += "[LN]" } if m.HasInlineFrames { - bits = bits + "[IN]" + bits += "[IN]" } ss = append(ss, fmt.Sprintf("%d: %#x/%#x/%#x %s %s %s", m.ID, @@ -573,7 +573,7 @@ func (p *Profile) Demangle(d Demangler) error { return nil } -// Empty returns true if the profile contains no samples. +// Empty reports whether the profile contains no samples. func (p *Profile) Empty() bool { return len(p.Sample) == 0 } diff --git a/libgo/go/runtime/pprof/pprof.go b/libgo/go/runtime/pprof/pprof.go index 5128c22b338..996b3cbf468 100644 --- a/libgo/go/runtime/pprof/pprof.go +++ b/libgo/go/runtime/pprof/pprof.go @@ -28,6 +28,7 @@ // if err != nil { // log.Fatal("could not create CPU profile: ", err) // } +// defer f.Close() // if err := pprof.StartCPUProfile(f); err != nil { // log.Fatal("could not start CPU profile: ", err) // } @@ -41,11 +42,11 @@ // if err != nil { // log.Fatal("could not create memory profile: ", err) // } +// defer f.Close() // runtime.GC() // get up-to-date statistics // if err := pprof.WriteHeapProfile(f); err != nil { // log.Fatal("could not write memory profile: ", err) // } -// f.Close() // } // } // diff --git a/libgo/go/runtime/pprof/pprof_test.go b/libgo/go/runtime/pprof/pprof_test.go index fd05a049b5a..bf9f5266e29 100644 --- a/libgo/go/runtime/pprof/pprof_test.go +++ b/libgo/go/runtime/pprof/pprof_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !nacl,!js +// +build !aix,!nacl,!js package pprof @@ -82,14 +82,14 @@ func avoidFunctions() []string { } func TestCPUProfile(t *testing.T) { - testCPUProfile(t, []string{"pprof.cpuHog1"}, avoidFunctions(), func(dur time.Duration) { + testCPUProfile(t, stackContains, []string{"pprof.cpuHog1"}, avoidFunctions(), func(dur time.Duration) { cpuHogger(cpuHog1, &salt1, dur) }) } func TestCPUProfileMultithreaded(t *testing.T) { defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(2)) - testCPUProfile(t, []string{"pprof.cpuHog1", "pprof.cpuHog2"}, avoidFunctions(), func(dur time.Duration) { + testCPUProfile(t, stackContains, []string{"pprof.cpuHog1", "pprof.cpuHog2"}, avoidFunctions(), func(dur time.Duration) { c := make(chan int) go func() { cpuHogger(cpuHog1, &salt1, dur) @@ -101,7 +101,7 @@ func TestCPUProfileMultithreaded(t *testing.T) { } func TestCPUProfileInlining(t *testing.T) { - testCPUProfile(t, []string{"pprof.inlinedCallee", "pprof.inlinedCaller"}, avoidFunctions(), func(dur time.Duration) { + testCPUProfile(t, stackContains, []string{"pprof.inlinedCallee", "pprof.inlinedCaller"}, avoidFunctions(), func(dur time.Duration) { cpuHogger(inlinedCaller, &salt1, dur) }) } @@ -139,7 +139,9 @@ func parseProfile(t *testing.T, valBytes []byte, f func(uintptr, []*profile.Loca } } -func testCPUProfile(t *testing.T, need []string, avoid []string, f func(dur time.Duration)) { +// testCPUProfile runs f under the CPU profiler, checking for some conditions specified by need, +// as interpreted by matches. +func testCPUProfile(t *testing.T, matches matchFunc, need []string, avoid []string, f func(dur time.Duration)) { switch runtime.GOOS { case "darwin": switch runtime.GOARCH { @@ -178,7 +180,7 @@ func testCPUProfile(t *testing.T, need []string, avoid []string, f func(dur time f(duration) StopCPUProfile() - if profileOk(t, need, avoid, prof, duration) { + if profileOk(t, matches, need, avoid, prof, duration) { return } @@ -191,6 +193,10 @@ func testCPUProfile(t *testing.T, need []string, avoid []string, f func(dur time switch runtime.GOOS { case "darwin", "dragonfly", "netbsd", "solaris": t.Skipf("ignoring failure on %s; see golang.org/issue/13841", runtime.GOOS) + case "openbsd": + if runtime.GOARCH == "arm" { + t.Skipf("ignoring failure on %s/%s; see golang.org/issue/13841", runtime.GOOS, runtime.GOARCH) + } } // Ignore the failure if the tests are running in a QEMU-based emulator, // QEMU is not perfect at emulating everything. @@ -211,7 +217,21 @@ func contains(slice []string, s string) bool { return false } -func profileOk(t *testing.T, need []string, avoid []string, prof bytes.Buffer, duration time.Duration) (ok bool) { +// stackContains matches if a function named spec appears anywhere in the stack trace. +func stackContains(spec string, count uintptr, stk []*profile.Location, labels map[string][]string) bool { + for _, loc := range stk { + for _, line := range loc.Line { + if strings.Contains(line.Function.Name, spec) { + return true + } + } + } + return false +} + +type matchFunc func(spec string, count uintptr, stk []*profile.Location, labels map[string][]string) bool + +func profileOk(t *testing.T, matches matchFunc, need []string, avoid []string, prof bytes.Buffer, duration time.Duration) (ok bool) { ok = true // Check that profile is well formed, contains 'need', and does not contain @@ -224,18 +244,16 @@ func profileOk(t *testing.T, need []string, avoid []string, prof bytes.Buffer, d fmt.Fprintf(&buf, "%d:", count) fprintStack(&buf, stk) samples += count - for i, name := range need { - if semi := strings.Index(name, ";"); semi > -1 { - kv := strings.SplitN(name[semi+1:], "=", 2) - if len(kv) != 2 || !contains(labels[kv[0]], kv[1]) { - continue - } - name = name[:semi] + for i, spec := range need { + if matches(spec, count, stk, labels) { + have[i] += count } + } + for i, name := range avoid { for _, loc := range stk { for _, line := range loc.Line { if strings.Contains(line.Function.Name, name) { - have[i] += count + avoidSamples[i] += count } } } @@ -316,6 +334,10 @@ func TestCPUProfileWithFork(t *testing.T) { // Use smaller size for Android to avoid crash. heap = 100 << 20 } + if runtime.GOOS == "windows" && runtime.GOARCH == "arm" { + // Use smaller heap for Windows/ARM to avoid crash. + heap = 100 << 20 + } if testing.Short() { heap = 100 << 20 } @@ -408,7 +430,7 @@ func fprintStack(w io.Writer, stk []*profile.Location) { // Test that profiling of division operations is okay, especially on ARM. See issue 6681. func TestMathBigDivide(t *testing.T) { - testCPUProfile(t, nil, nil, func(duration time.Duration) { + testCPUProfile(t, nil, nil, nil, func(duration time.Duration) { t := time.After(duration) pi := new(big.Int) for { @@ -426,6 +448,51 @@ func TestMathBigDivide(t *testing.T) { }) } +// stackContainsAll matches if all functions in spec (comma-separated) appear somewhere in the stack trace. +func stackContainsAll(spec string, count uintptr, stk []*profile.Location, labels map[string][]string) bool { + for _, f := range strings.Split(spec, ",") { + if !stackContains(f, count, stk, labels) { + return false + } + } + return true +} + +func TestMorestack(t *testing.T) { + if runtime.Compiler == "gccgo" { + t.Skip("no runtime.newstack in gccgo") + } + testCPUProfile(t, stackContainsAll, []string{"runtime.newstack,runtime/pprof.growstack"}, avoidFunctions(), func(duration time.Duration) { + t := time.After(duration) + c := make(chan bool) + for { + go func() { + growstack1() + c <- true + }() + select { + case <-t: + return + case <-c: + } + } + }) +} + +//go:noinline +func growstack1() { + growstack() +} + +//go:noinline +func growstack() { + var buf [8 << 10]byte + use(buf) +} + +//go:noinline +func use(x [8 << 10]byte) {} + func TestBlockProfile(t *testing.T) { t.Skip("lots of details are different for gccgo; FIXME") type TestCase struct { @@ -556,7 +623,7 @@ func TestBlockProfile(t *testing.T) { } for _, test := range tests { - if !regexp.MustCompile(strings.Replace(test.re, "\t", "\t+", -1)).MatchString(prof) { + if !regexp.MustCompile(strings.ReplaceAll(test.re, "\t", "\t+")).MatchString(prof) { t.Errorf("Bad %v entry, expect:\n%v\ngot:\n%v", test.name, test.re, prof) } } @@ -887,8 +954,25 @@ func TestEmptyCallStack(t *testing.T) { } } +// stackContainsLabeled takes a spec like funcname;key=value and matches if the stack has that key +// and value and has funcname somewhere in the stack. +func stackContainsLabeled(spec string, count uintptr, stk []*profile.Location, labels map[string][]string) bool { + semi := strings.Index(spec, ";") + if semi == -1 { + panic("no semicolon in key/value spec") + } + kv := strings.SplitN(spec[semi+1:], "=", 2) + if len(kv) != 2 { + panic("missing = in key/value spec") + } + if !contains(labels[kv[0]], kv[1]) { + return false + } + return stackContains(spec[:semi], count, stk, labels) +} + func TestCPUProfileLabel(t *testing.T) { - testCPUProfile(t, []string{"pprof.cpuHogger;key=value"}, avoidFunctions(), func(dur time.Duration) { + testCPUProfile(t, stackContainsLabeled, []string{"pprof.cpuHogger;key=value"}, avoidFunctions(), func(dur time.Duration) { Do(context.Background(), Labels("key", "value"), func(context.Context) { cpuHogger(cpuHog1, &salt1, dur) }) @@ -899,7 +983,7 @@ func TestLabelRace(t *testing.T) { // Test the race detector annotations for synchronization // between settings labels and consuming them from the // profile. - testCPUProfile(t, []string{"pprof.cpuHogger;key=value"}, avoidFunctions(), func(dur time.Duration) { + testCPUProfile(t, stackContainsLabeled, []string{"pprof.cpuHogger;key=value"}, nil, func(dur time.Duration) { start := time.Now() var wg sync.WaitGroup for time.Since(start) < dur { diff --git a/libgo/go/runtime/pprof/proto.go b/libgo/go/runtime/pprof/proto.go index d8456befd3d..b82e738f941 100644 --- a/libgo/go/runtime/pprof/proto.go +++ b/libgo/go/runtime/pprof/proto.go @@ -213,7 +213,7 @@ func (b *profileBuilder) pbMapping(tag int, id, base, limit, offset uint64, file } // locForPC returns the location ID for addr. -// addr must be a return PC. This returns the location of the call. +// addr must a return PC or 1 + the PC of an inline marker. This returns the location of the corresponding call. // It may emit to b.pb, so there must be no message encoding in progress. func (b *profileBuilder) locForPC(addr uintptr) uint64 { id := uint64(b.locs[addr]) @@ -529,6 +529,14 @@ func parseProcSelfMaps(data []byte, addMapping func(lo, hi, offset uint64, file, continue } file := string(line) + + // Trim deleted file marker. + deletedStr := " (deleted)" + deletedLen := len(deletedStr) + if len(file) >= deletedLen && file[len(file)-deletedLen:] == deletedStr { + file = file[:len(file)-deletedLen] + } + if len(inode) == 1 && inode[0] == '0' && file == "" { // Huge-page text mappings list the initial fragment of // mapped but unpopulated memory as being inode 0. diff --git a/libgo/go/runtime/pprof/proto_test.go b/libgo/go/runtime/pprof/proto_test.go index 604628ce457..5a915fb4c3a 100644 --- a/libgo/go/runtime/pprof/proto_test.go +++ b/libgo/go/runtime/pprof/proto_test.go @@ -218,24 +218,89 @@ c000000000-c000036000 rw-p 00000000 00:00 0 07000000 07093000 06c00000 /path/to/gobench_server_main ` +var profSelfMapsTestsWithDeleted = ` +00400000-0040b000 r-xp 00000000 fc:01 787766 /bin/cat (deleted) +0060a000-0060b000 r--p 0000a000 fc:01 787766 /bin/cat (deleted) +0060b000-0060c000 rw-p 0000b000 fc:01 787766 /bin/cat (deleted) +014ab000-014cc000 rw-p 00000000 00:00 0 [heap] +7f7d76af8000-7f7d7797c000 r--p 00000000 fc:01 1318064 /usr/lib/locale/locale-archive +7f7d7797c000-7f7d77b36000 r-xp 00000000 fc:01 1180226 /lib/x86_64-linux-gnu/libc-2.19.so +7f7d77b36000-7f7d77d36000 ---p 001ba000 fc:01 1180226 /lib/x86_64-linux-gnu/libc-2.19.so +7f7d77d36000-7f7d77d3a000 r--p 001ba000 fc:01 1180226 /lib/x86_64-linux-gnu/libc-2.19.so +7f7d77d3a000-7f7d77d3c000 rw-p 001be000 fc:01 1180226 /lib/x86_64-linux-gnu/libc-2.19.so +7f7d77d3c000-7f7d77d41000 rw-p 00000000 00:00 0 +7f7d77d41000-7f7d77d64000 r-xp 00000000 fc:01 1180217 /lib/x86_64-linux-gnu/ld-2.19.so +7f7d77f3f000-7f7d77f42000 rw-p 00000000 00:00 0 +7f7d77f61000-7f7d77f63000 rw-p 00000000 00:00 0 +7f7d77f63000-7f7d77f64000 r--p 00022000 fc:01 1180217 /lib/x86_64-linux-gnu/ld-2.19.so +7f7d77f64000-7f7d77f65000 rw-p 00023000 fc:01 1180217 /lib/x86_64-linux-gnu/ld-2.19.so +7f7d77f65000-7f7d77f66000 rw-p 00000000 00:00 0 +7ffc342a2000-7ffc342c3000 rw-p 00000000 00:00 0 [stack] +7ffc34343000-7ffc34345000 r-xp 00000000 00:00 0 [vdso] +ffffffffff600000-ffffffffff601000 r-xp 00000090 00:00 0 [vsyscall] +-> +00400000 0040b000 00000000 /bin/cat +7f7d7797c000 7f7d77b36000 00000000 /lib/x86_64-linux-gnu/libc-2.19.so +7f7d77d41000 7f7d77d64000 00000000 /lib/x86_64-linux-gnu/ld-2.19.so +7ffc34343000 7ffc34345000 00000000 [vdso] +ffffffffff600000 ffffffffff601000 00000090 [vsyscall] + +00400000-0040b000 r-xp 00000000 fc:01 787766 /bin/cat with space +0060a000-0060b000 r--p 0000a000 fc:01 787766 /bin/cat with space +0060b000-0060c000 rw-p 0000b000 fc:01 787766 /bin/cat with space +014ab000-014cc000 rw-p 00000000 00:00 0 [heap] +7f7d76af8000-7f7d7797c000 r--p 00000000 fc:01 1318064 /usr/lib/locale/locale-archive +7f7d7797c000-7f7d77b36000 r-xp 00000000 fc:01 1180226 /lib/x86_64-linux-gnu/libc-2.19.so +7f7d77b36000-7f7d77d36000 ---p 001ba000 fc:01 1180226 /lib/x86_64-linux-gnu/libc-2.19.so +7f7d77d36000-7f7d77d3a000 r--p 001ba000 fc:01 1180226 /lib/x86_64-linux-gnu/libc-2.19.so +7f7d77d3a000-7f7d77d3c000 rw-p 001be000 fc:01 1180226 /lib/x86_64-linux-gnu/libc-2.19.so +7f7d77d3c000-7f7d77d41000 rw-p 00000000 00:00 0 +7f7d77d41000-7f7d77d64000 r-xp 00000000 fc:01 1180217 /lib/x86_64-linux-gnu/ld-2.19.so +7f7d77f3f000-7f7d77f42000 rw-p 00000000 00:00 0 +7f7d77f61000-7f7d77f63000 rw-p 00000000 00:00 0 +7f7d77f63000-7f7d77f64000 r--p 00022000 fc:01 1180217 /lib/x86_64-linux-gnu/ld-2.19.so +7f7d77f64000-7f7d77f65000 rw-p 00023000 fc:01 1180217 /lib/x86_64-linux-gnu/ld-2.19.so +7f7d77f65000-7f7d77f66000 rw-p 00000000 00:00 0 +7ffc342a2000-7ffc342c3000 rw-p 00000000 00:00 0 [stack] +7ffc34343000-7ffc34345000 r-xp 00000000 00:00 0 [vdso] +ffffffffff600000-ffffffffff601000 r-xp 00000090 00:00 0 [vsyscall] +-> +00400000 0040b000 00000000 /bin/cat with space +7f7d7797c000 7f7d77b36000 00000000 /lib/x86_64-linux-gnu/libc-2.19.so +7f7d77d41000 7f7d77d64000 00000000 /lib/x86_64-linux-gnu/ld-2.19.so +7ffc34343000 7ffc34345000 00000000 [vdso] +ffffffffff600000 ffffffffff601000 00000090 [vsyscall] +` + func TestProcSelfMaps(t *testing.T) { - for tx, tt := range strings.Split(profSelfMapsTests, "\n\n") { - i := strings.Index(tt, "->\n") - if i < 0 { - t.Fatal("malformed test case") - } - in, out := tt[:i], tt[i+len("->\n"):] - if len(out) > 0 && out[len(out)-1] != '\n' { - out += "\n" - } - var buf bytes.Buffer - parseProcSelfMaps([]byte(in), func(lo, hi, offset uint64, file, buildID string) { - fmt.Fprintf(&buf, "%08x %08x %08x %s\n", lo, hi, offset, file) - }) - if buf.String() != out { - t.Errorf("#%d: have:\n%s\nwant:\n%s\n%q\n%q", tx, buf.String(), out, buf.String(), out) + + f := func(t *testing.T, input string) { + for tx, tt := range strings.Split(input, "\n\n") { + i := strings.Index(tt, "->\n") + if i < 0 { + t.Fatal("malformed test case") + } + in, out := tt[:i], tt[i+len("->\n"):] + if len(out) > 0 && out[len(out)-1] != '\n' { + out += "\n" + } + var buf bytes.Buffer + parseProcSelfMaps([]byte(in), func(lo, hi, offset uint64, file, buildID string) { + fmt.Fprintf(&buf, "%08x %08x %08x %s\n", lo, hi, offset, file) + }) + if buf.String() != out { + t.Errorf("#%d: have:\n%s\nwant:\n%s\n%q\n%q", tx, buf.String(), out, buf.String(), out) + } } } + + t.Run("Normal", func(t *testing.T) { + f(t, profSelfMapsTests) + }) + + t.Run("WithDeletedFile", func(t *testing.T) { + f(t, profSelfMapsTestsWithDeleted) + }) } // TestMapping checkes the mapping section of CPU profiles diff --git a/libgo/go/runtime/pprof/protomem.go b/libgo/go/runtime/pprof/protomem.go index 82565d5245b..1c88aae43a0 100644 --- a/libgo/go/runtime/pprof/protomem.go +++ b/libgo/go/runtime/pprof/protomem.go @@ -56,8 +56,8 @@ func writeHeapProto(w io.Writer, p []runtime.MemProfileRecord, rate int64, defau values[0], values[1] = scaleHeapSample(r.AllocObjects, r.AllocBytes, rate) values[2], values[3] = scaleHeapSample(r.InUseObjects(), r.InUseBytes(), rate) var blockSize int64 - if values[0] > 0 { - blockSize = values[1] / values[0] + if r.AllocObjects > 0 { + blockSize = r.AllocBytes / r.AllocObjects } b.pbSample(values, locs, func() { if blockSize != 0 { diff --git a/libgo/go/runtime/pprof/protomem_test.go b/libgo/go/runtime/pprof/protomem_test.go index 315d5f0b4d8..471b1ae9c32 100644 --- a/libgo/go/runtime/pprof/protomem_test.go +++ b/libgo/go/runtime/pprof/protomem_test.go @@ -48,7 +48,7 @@ func TestConvertMemProfile(t *testing.T) { {ID: 3, Mapping: map2, Address: addr2 + 1}, {ID: 4, Mapping: map2, Address: addr2 + 2}, }, - NumLabel: map[string][]int64{"bytes": {829411}}, + NumLabel: map[string][]int64{"bytes": {512 * 1024}}, }, { Value: []int64{1, 829411, 0, 0}, @@ -57,7 +57,7 @@ func TestConvertMemProfile(t *testing.T) { {ID: 6, Mapping: map1, Address: addr1 + 2}, {ID: 7, Mapping: map2, Address: addr2 + 3}, }, - NumLabel: map[string][]int64{"bytes": {829411}}, + NumLabel: map[string][]int64{"bytes": {512 * 1024}}, }, } for _, tc := range []struct { diff --git a/libgo/go/runtime/print.go b/libgo/go/runtime/print.go index 3da05ad5f9e..8c396442862 100644 --- a/libgo/go/runtime/print.go +++ b/libgo/go/runtime/print.go @@ -110,7 +110,12 @@ func gwrite(b []byte) { } recordForPanic(b) gp := getg() - if gp == nil || gp.writebuf == nil { + // Don't use the writebuf if gp.m is dying. We want anything + // written through gwrite to appear in the terminal rather + // than be written to in some buffer, if we're in a panicking state. + // Note that we can't just clear writebuf in the gp.m.dying case + // because a panic isn't allowed to have any write barriers. + if gp == nil || gp.writebuf == nil || gp.m.dying > 0 { writeErr(b) return } diff --git a/libgo/go/runtime/proc.go b/libgo/go/runtime/proc.go index 80b04ab4a5d..05dd53d886f 100644 --- a/libgo/go/runtime/proc.go +++ b/libgo/go/runtime/proc.go @@ -20,7 +20,6 @@ import ( //go:linkname incidlelocked runtime.incidlelocked //go:linkname schedinit runtime.schedinit //go:linkname ready runtime.ready -//go:linkname gcprocs runtime.gcprocs //go:linkname stopm runtime.stopm //go:linkname handoffp runtime.handoffp //go:linkname wakep runtime.wakep @@ -32,7 +31,6 @@ import ( //go:linkname reentersyscallblock runtime.reentersyscallblock //go:linkname exitsyscall runtime.exitsyscall //go:linkname gfget runtime.gfget -//go:linkname helpgc runtime.helpgc //go:linkname kickoff runtime.kickoff //go:linkname mstart1 runtime.mstart1 //go:linkname mexit runtime.mexit @@ -196,8 +194,7 @@ func main() { } }() - // Record when the world started. Must be after runtime_init - // because nanotime on some platforms depends on startNano. + // Record when the world started. runtimeInitTime = nanotime() main_init_done = make(chan bool) @@ -285,7 +282,7 @@ func forcegchelper() { println("GC forced") } // Time-triggered, fully concurrent. - gcStart(gcBackgroundMode, gcTrigger{kind: gcTriggerTime, now: nanotime()}) + gcStart(gcTrigger{kind: gcTriggerTime, now: nanotime()}) } } @@ -479,17 +476,18 @@ const ( _GoidCacheBatch = 16 ) -// cpuinit extracts the environment variable GODEBUGCPU from the environment on -// Linux and Darwin if the GOEXPERIMENT debugcpu was set and calls internal/cpu.Initialize. +// cpuinit extracts the environment variable GODEBUG from the environment on +// Unix-like operating systems and calls internal/cpu.Initialize. func cpuinit() { - const prefix = "GODEBUGCPU=" + const prefix = "GODEBUG=" var env string - if haveexperiment("debugcpu") && (GOOS == "linux" || GOOS == "darwin") { + switch GOOS { + case "aix", "darwin", "dragonfly", "freebsd", "netbsd", "openbsd", "solaris", "linux": cpu.DebugOptions = true // Similar to goenv_unix but extracts the environment value for - // GODEBUGCPU directly. + // GODEBUG directly. // TODO(moehrmann): remove when general goenvs() can be called before cpuinit() n := int32(0) for argv_index(argv, argc+1+n) != nil { @@ -500,7 +498,7 @@ func cpuinit() { p := argv_index(argv, argc+1+i) s := *(*string)(unsafe.Pointer(&stringStruct{unsafe.Pointer(p), findnull(p)})) - if hasprefix(s, prefix) { + if hasPrefix(s, prefix) { env = gostring(p)[len(prefix):] break } @@ -643,59 +641,6 @@ func ready(gp *g, traceskip int, next bool) { _g_.m.locks-- } -func gcprocs() int32 { - // Figure out how many CPUs to use during GC. - // Limited by gomaxprocs, number of actual CPUs, and MaxGcproc. - lock(&sched.lock) - n := gomaxprocs - if n > ncpu { - n = ncpu - } - if n > _MaxGcproc { - n = _MaxGcproc - } - if n > sched.nmidle+1 { // one M is currently running - n = sched.nmidle + 1 - } - unlock(&sched.lock) - return n -} - -func needaddgcproc() bool { - lock(&sched.lock) - n := gomaxprocs - if n > ncpu { - n = ncpu - } - if n > _MaxGcproc { - n = _MaxGcproc - } - n -= sched.nmidle + 1 // one M is currently running - unlock(&sched.lock) - return n > 0 -} - -func helpgc(nproc int32) { - _g_ := getg() - lock(&sched.lock) - pos := 0 - for n := int32(1); n < nproc; n++ { // one M is currently running - if allp[pos].mcache == _g_.m.mcache { - pos++ - } - mp := mget() - if mp == nil { - throw("gcprocs inconsistency") - } - mp.helpgc = n - mp.p.set(allp[pos]) - mp.mcache = allp[pos].mcache - pos++ - notewakeup(&mp.park) - } - unlock(&sched.lock) -} - // freezeStopWait is a large value that freezetheworld sets // sched.stopwait to in order to request that all Gs permanently stop. const freezeStopWait = 0x7fffffff @@ -1154,20 +1099,14 @@ func stopTheWorldWithSema() { } } -func mhelpgc() { - _g_ := getg() - _g_.m.helpgc = -1 -} - func startTheWorldWithSema(emitTraceEvent bool) int64 { _g_ := getg() _g_.m.locks++ // disable preemption because it can be holding p in a local var if netpollinited() { - gp := netpoll(false) // non-blocking - injectglist(gp) + list := netpoll(false) // non-blocking + injectglist(&list) } - add := needaddgcproc() lock(&sched.lock) procs := gomaxprocs @@ -1197,7 +1136,6 @@ func startTheWorldWithSema(emitTraceEvent bool) int64 { } else { // Start M to run P. Do not start another M below. newm(nil, p) - add = false } } @@ -1214,16 +1152,6 @@ func startTheWorldWithSema(emitTraceEvent bool) int64 { wakep() } - if add { - // If GC could have used another helper proc, start one now, - // in the hope that it will be available next time. - // It would have been even better to start it before the collection, - // but doing so requires allocating memory, so it's tricky to - // coordinate. This lazy approach works out in practice: - // we don't mind if the first couple gc rounds don't have quite - // the maximum number of procs. - newm(mhelpgc, nil) - } _g_.m.locks-- return startTime @@ -1288,10 +1216,7 @@ func mstart1() { fn() } - if _g_.m.helpgc != 0 { - _g_.m.helpgc = 0 - stopm() - } else if _g_.m != &m0 { + if _g_.m != &m0 { acquirep(_g_.m.nextp.ptr()) _g_.m.nextp = 0 } @@ -1591,7 +1516,7 @@ func allocm(_p_ *p, fn func(), allocatestack bool) (mp *m, g0Stack unsafe.Pointe // the following strategy: there is a stack of available m's // that can be stolen. Using compare-and-swap // to pop from the stack has ABA races, so we simulate -// a lock by doing an exchange (via casp) to steal the stack +// a lock by doing an exchange (via Casuintptr) to steal the stack // head and replace the top pointer with MLOCKED (1). // This serves as a simple spin lock that we can use even // without an m. The thread that locks the stack in this way @@ -1925,7 +1850,7 @@ func startTemplateThread() { // templateThread is a thread in a known-good state that exists solely // to start new threads in known-good states when the calling thread -// may not be a a good state. +// may not be in a good state. // // Many programs never need this, so templateThread is started lazily // when we first enter a state that might lead to running on a thread @@ -1977,21 +1902,11 @@ func stopm() { throw("stopm spinning") } -retry: lock(&sched.lock) mput(_g_.m) unlock(&sched.lock) notesleep(&_g_.m.park) noteclear(&_g_.m.park) - if _g_.m.helpgc != 0 { - // helpgc() set _g_.m.p and _g_.m.mcache, so we have a P. - gchelper() - // Undo the effects of helpgc(). - _g_.m.helpgc = 0 - _g_.m.mcache = nil - _g_.m.p = 0 - goto retry - } acquirep(_g_.m.nextp.ptr()) _g_.m.nextp = 0 } @@ -2279,9 +2194,9 @@ top: // not set lastpoll yet), this thread will do blocking netpoll below // anyway. if netpollinited() && atomic.Load(&netpollWaiters) > 0 && atomic.Load64(&sched.lastpoll) != 0 { - if gp := netpoll(false); gp != nil { // non-blocking - // netpoll returns list of goroutines linked by schedlink. - injectglist(gp.schedlink.ptr()) + if list := netpoll(false); !list.empty() { // non-blocking + gp := list.pop() + injectglist(&list) casgstatus(gp, _Gwaiting, _Grunnable) if trace.enabled { traceGoUnpark(gp, 0) @@ -2336,10 +2251,10 @@ stop: } // wasm only: - // Check if a goroutine is waiting for a callback from the WebAssembly host. - // If yes, pause the execution until a callback was triggered. - if pauseSchedulerUntilCallback() { - // A callback was triggered and caused at least one goroutine to wake up. + // If a callback returned and no other goroutine is awake, + // then pause execution until a callback was triggered. + if beforeIdle() { + // At least one goroutine got woken. goto top } @@ -2433,29 +2348,30 @@ stop: if _g_.m.spinning { throw("findrunnable: netpoll with spinning") } - gp := netpoll(true) // block until new work is available + list := netpoll(true) // block until new work is available atomic.Store64(&sched.lastpoll, uint64(nanotime())) - if gp != nil { + if !list.empty() { lock(&sched.lock) _p_ = pidleget() unlock(&sched.lock) if _p_ != nil { acquirep(_p_) - injectglist(gp.schedlink.ptr()) + gp := list.pop() + injectglist(&list) casgstatus(gp, _Gwaiting, _Grunnable) if trace.enabled { traceGoUnpark(gp, 0) } return gp, false } - injectglist(gp) + injectglist(&list) } } stopm() goto top } -// pollWork returns true if there is non-background work this P could +// pollWork reports whether there is non-background work this P could // be doing. This is a fairly lightweight check to be used for // background work loops, like idle GC. It checks a subset of the // conditions checked by the actual scheduler. @@ -2468,8 +2384,8 @@ func pollWork() bool { return true } if netpollinited() && atomic.Load(&netpollWaiters) > 0 && sched.lastpoll != 0 { - if gp := netpoll(false); gp != nil { - injectglist(gp) + if list := netpoll(false); !list.empty() { + injectglist(&list) return true } } @@ -2494,22 +2410,21 @@ func resetspinning() { } } -// Injects the list of runnable G's into the scheduler. +// Injects the list of runnable G's into the scheduler and clears glist. // Can run concurrently with GC. -func injectglist(glist *g) { - if glist == nil { +func injectglist(glist *gList) { + if glist.empty() { return } if trace.enabled { - for gp := glist; gp != nil; gp = gp.schedlink.ptr() { + for gp := glist.head.ptr(); gp != nil; gp = gp.schedlink.ptr() { traceGoUnpark(gp, 0) } } lock(&sched.lock) var n int - for n = 0; glist != nil; n++ { - gp := glist - glist = gp.schedlink.ptr() + for n = 0; !glist.empty(); n++ { + gp := glist.pop() casgstatus(gp, _Gwaiting, _Grunnable) globrunqput(gp) } @@ -2517,6 +2432,7 @@ func injectglist(glist *g) { for ; n != 0 && sched.npidle != 0; n-- { startm(nil, false) } + *glist = gList{} } // One round of scheduler: find a runnable goroutine and execute it. @@ -2602,6 +2518,23 @@ top: resetspinning() } + if sched.disable.user && !schedEnabled(gp) { + // Scheduling of this goroutine is disabled. Put it on + // the list of pending runnable goroutines for when we + // re-enable user scheduling and look again. + lock(&sched.lock) + if schedEnabled(gp) { + // Something re-enabled scheduling while we + // were acquiring the lock. + unlock(&sched.lock) + } else { + sched.disable.runnable.pushBack(gp) + sched.disable.n++ + unlock(&sched.lock) + goto top + } + } + if gp.lockedm != 0 { // Hands off own p to the locked m, // then blocks waiting for a new p. @@ -2714,7 +2647,7 @@ func goexit0(gp *g) { _g_ := getg() casgstatus(gp, _Grunning, _Gdead) - if isSystemGoroutine(gp) { + if isSystemGoroutine(gp, false) { atomic.Xadd(&sched.ngsys, -1) gp.isSystemGoroutine = false } @@ -2755,7 +2688,6 @@ func goexit0(gp *g) { print("invalid m->lockedInt = ", _g_.m.lockedInt, "\n") throw("internal lockOSThread error") } - _g_.m.lockedExt = 0 gfput(_g_.m.p.ptr(), gp) if locked { // The goroutine may have locked this thread because @@ -2767,6 +2699,10 @@ func goexit0(gp *g) { if GOOS != "plan9" { // See golang.org/issue/22227. _g_.m.exiting = true gogo(_g_.m.g0) + } else { + // Clear lockedExt on plan9 since we may end up re-using + // this thread. + _g_.m.lockedExt = 0 } } schedule() @@ -2823,8 +2759,11 @@ func reentersyscall(pc, sp uintptr) { _g_.m.syscalltick = _g_.m.p.ptr().syscalltick _g_.sysblocktraced = true _g_.m.mcache = nil - _g_.m.p.ptr().m = 0 - atomic.Store(&_g_.m.p.ptr().status, _Psyscall) + pp := _g_.m.p.ptr() + pp.m = 0 + _g_.m.oldp.set(pp) + _g_.m.p = 0 + atomic.Store(&pp.status, _Psyscall) if sched.gcwaiting != 0 { systemstack(entersyscall_gcwait) } @@ -2843,7 +2782,7 @@ func entersyscall_sysmon() { func entersyscall_gcwait() { _g_ := getg() - _p_ := _g_.m.p.ptr() + _p_ := _g_.m.oldp.ptr() lock(&sched.lock) if sched.stopwait > 0 && atomic.Cas(&_p_.status, _Psyscall, _Pgcstop) { @@ -2900,8 +2839,9 @@ func exitsyscall() { _g_.m.locks++ // see comment in entersyscall _g_.waitsince = 0 - oldp := _g_.m.p.ptr() - if exitsyscallfast() { + oldp := _g_.m.oldp.ptr() + _g_.m.oldp = 0 + if exitsyscallfast(oldp) { if _g_.m.mcache == nil { throw("lost mcache") } @@ -2924,6 +2864,12 @@ func exitsyscall() { if getg().preempt { checkPreempt() } + _g_.throwsplit = false + + if sched.disable.user && !schedEnabled(_g_) { + // Scheduling of this goroutine is disabled. + Gosched() + } return } @@ -2964,27 +2910,23 @@ func exitsyscall() { } //go:nosplit -func exitsyscallfast() bool { +func exitsyscallfast(oldp *p) bool { _g_ := getg() // Freezetheworld sets stopwait but does not retake P's. if sched.stopwait == freezeStopWait { - _g_.m.mcache = nil - _g_.m.p = 0 return false } // Try to re-acquire the last P. - if _g_.m.p != 0 && _g_.m.p.ptr().status == _Psyscall && atomic.Cas(&_g_.m.p.ptr().status, _Psyscall, _Prunning) { + if oldp != nil && oldp.status == _Psyscall && atomic.Cas(&oldp.status, _Psyscall, _Pidle) { // There's a cpu for us, so we can run. + wirep(oldp) exitsyscallfast_reacquired() return true } // Try to get any other idle P. - oldp := _g_.m.p.ptr() - _g_.m.mcache = nil - _g_.m.p = 0 if sched.pidle != 0 { var ok bool systemstack(func() { @@ -3011,15 +2953,9 @@ func exitsyscallfast() bool { // has successfully reacquired the P it was running on before the // syscall. // -// This function is allowed to have write barriers because exitsyscall -// has acquired a P at this point. -// -//go:yeswritebarrierrec //go:nosplit func exitsyscallfast_reacquired() { _g_ := getg() - _g_.m.mcache = _g_.m.p.ptr().mcache - _g_.m.p.ptr().m.set(_g_.m) if _g_.m.syscalltick != _g_.m.p.ptr().syscalltick { if trace.enabled { // The p was retaken and then enter into syscall again (since _g_.m.syscalltick has changed). @@ -3062,7 +2998,10 @@ func exitsyscall0(gp *g) { dropg() casgstatus(gp, _Gexitingsyscall, _Grunnable) lock(&sched.lock) - _p_ := pidleget() + var _p_ *p + if schedEnabled(_g_) { + _p_ = pidleget() + } if _p_ == nil { globrunqput(gp) } else if atomic.Load(&sched.sysmonwait) != 0 { @@ -3229,11 +3168,12 @@ func newproc(fn uintptr, arg unsafe.Pointer) *g { newg.param = arg newg.gopc = getcallerpc() + newg.ancestors = saveAncestors(_g_) newg.startpc = fn if _g_.m.curg != nil { newg.labels = _g_.m.curg.labels } - if isSystemGoroutine(newg) { + if isSystemGoroutine(newg, false) { atomic.Xadd(&sched.ngsys, +1) } newg.gcscanvalid = false @@ -3342,20 +3282,17 @@ func gfput(_p_ *p, gp *g) { throw("gfput: bad status (not Gdead)") } - gp.schedlink.set(_p_.gfree) - _p_.gfree = gp - _p_.gfreecnt++ - if _p_.gfreecnt >= 64 { - lock(&sched.gflock) - for _p_.gfreecnt >= 32 { - _p_.gfreecnt-- - gp = _p_.gfree - _p_.gfree = gp.schedlink.ptr() - gp.schedlink.set(sched.gfree) - sched.gfree = gp - sched.ngfree++ + _p_.gFree.push(gp) + _p_.gFree.n++ + if _p_.gFree.n >= 64 { + lock(&sched.gFree.lock) + for _p_.gFree.n >= 32 { + _p_.gFree.n-- + gp = _p_.gFree.pop() + sched.gFree.list.push(gp) + sched.gFree.n++ } - unlock(&sched.gflock) + unlock(&sched.gFree.lock) } } @@ -3363,43 +3300,39 @@ func gfput(_p_ *p, gp *g) { // If local list is empty, grab a batch from global list. func gfget(_p_ *p) *g { retry: - gp := _p_.gfree - if gp == nil && sched.gfree != nil { - lock(&sched.gflock) - for _p_.gfreecnt < 32 { - if sched.gfree != nil { - gp = sched.gfree - sched.gfree = gp.schedlink.ptr() - } else { + if _p_.gFree.empty() && !sched.gFree.list.empty() { + lock(&sched.gFree.lock) + // Move a batch of free Gs to the P. + for _p_.gFree.n < 32 { + gp := sched.gFree.list.pop() + if gp == nil { break } - _p_.gfreecnt++ - sched.ngfree-- - gp.schedlink.set(_p_.gfree) - _p_.gfree = gp + sched.gFree.n-- + _p_.gFree.push(gp) + _p_.gFree.n++ } - unlock(&sched.gflock) + unlock(&sched.gFree.lock) goto retry } - if gp != nil { - _p_.gfree = gp.schedlink.ptr() - _p_.gfreecnt-- + gp := _p_.gFree.pop() + if gp == nil { + return nil } + _p_.gFree.n-- return gp } // Purge all cached G's from gfree list to the global list. func gfpurge(_p_ *p) { - lock(&sched.gflock) - for _p_.gfreecnt != 0 { - _p_.gfreecnt-- - gp := _p_.gfree - _p_.gfree = gp.schedlink.ptr() - gp.schedlink.set(sched.gfree) - sched.gfree = gp - sched.ngfree++ + lock(&sched.gFree.lock) + for !_p_.gFree.empty() { + gp := _p_.gFree.pop() + _p_.gFree.n-- + sched.gFree.list.push(gp) + sched.gFree.n++ } - unlock(&sched.gflock) + unlock(&sched.gFree.lock) } // Breakpoint executes a breakpoint trap. @@ -3512,9 +3445,9 @@ func badunlockosthread() { } func gcount() int32 { - n := int32(allglen) - sched.ngfree - int32(atomic.Load(&sched.ngsys)) + n := int32(allglen) - sched.gFree.n - int32(atomic.Load(&sched.ngsys)) for _, _p_ := range allp { - n -= _p_.gfreecnt + n -= _p_.gFree.n } // All these variables can be changed concurrently, so the result can be inconsistent. @@ -3627,7 +3560,7 @@ func sigprof(pc uintptr, gp *g, mp *m) { // Account it against abstract "System" or "GC". n = 2 stk[0] = pc - if mp.preemptoff != "" || mp.helpgc != 0 { + if mp.preemptoff != "" { stk[1] = _GCPC + sys.PCQuantum } else { stk[1] = _SystemPC + sys.PCQuantum @@ -3854,6 +3787,7 @@ func procresize(nprocs int32) *p { if _g_.m.p != 0 && _g_.m.p.ptr().id < nprocs { // continue to use the current P _g_.m.p.ptr().status = _Prunning + _g_.m.p.ptr().mcache.prepareForSweep() } else { // release the current P and acquire allp[0] if _g_.m.p != 0 { @@ -3898,36 +3832,40 @@ func procresize(nprocs int32) *p { //go:yeswritebarrierrec func acquirep(_p_ *p) { // Do the part that isn't allowed to have write barriers. - acquirep1(_p_) + wirep(_p_) - // have p; write barriers now allowed - _g_ := getg() - _g_.m.mcache = _p_.mcache + // Have p; write barriers now allowed. + + // Perform deferred mcache flush before this P can allocate + // from a potentially stale mcache. + _p_.mcache.prepareForSweep() if trace.enabled { traceProcStart() } } -// acquirep1 is the first step of acquirep, which actually acquires -// _p_. This is broken out so we can disallow write barriers for this -// part, since we don't yet have a P. +// wirep is the first step of acquirep, which actually associates the +// current M to _p_. This is broken out so we can disallow write +// barriers for this part, since we don't yet have a P. // //go:nowritebarrierrec -func acquirep1(_p_ *p) { +//go:nosplit +func wirep(_p_ *p) { _g_ := getg() if _g_.m.p != 0 || _g_.m.mcache != nil { - throw("acquirep: already in go") + throw("wirep: already in go") } if _p_.m != 0 || _p_.status != _Pidle { id := int64(0) if _p_.m != 0 { id = _p_.m.ptr().id } - print("acquirep: p->m=", _p_.m, "(", id, ") p->status=", _p_.status, "\n") - throw("acquirep: invalid p state") + print("wirep: p->m=", _p_.m, "(", id, ") p->status=", _p_.status, "\n") + throw("wirep: invalid p state") } + _g_.m.mcache = _p_.mcache _g_.m.p.set(_p_) _p_.m.set(_g_.m) _p_.status = _Prunning @@ -4005,7 +3943,7 @@ func checkdead() { lock(&allglock) for i := 0; i < len(allgs); i++ { gp := allgs[i] - if isSystemGoroutine(gp) { + if isSystemGoroutine(gp, false) { continue } s := readgstatus(gp) @@ -4134,8 +4072,8 @@ func sysmon() { now := nanotime() if netpollinited() && lastpoll != 0 && lastpoll+10*1000*1000 < now { atomic.Cas64(&sched.lastpoll, uint64(lastpoll), uint64(now)) - gp := netpoll(false) // non-blocking - returns list of goroutines - if gp != nil { + list := netpoll(false) // non-blocking - returns list of goroutines + if !list.empty() { // Need to decrement number of idle locked M's // (pretending that one more is running) before injectglist. // Otherwise it can lead to the following situation: @@ -4144,7 +4082,7 @@ func sysmon() { // observes that there is no work to do and no other running M's // and reports deadlock. incidlelocked(-1) - injectglist(gp) + injectglist(&list) incidlelocked(1) } } @@ -4159,8 +4097,9 @@ func sysmon() { if t := (gcTrigger{kind: gcTriggerTime, now: now}); t.test() && atomic.Load(&forcegc.idle) != 0 { lock(&forcegc.lock) forcegc.idle = 0 - forcegc.g.schedlink = 0 - injectglist(forcegc.g) + var list gList + list.push(forcegc.g) + injectglist(&list) unlock(&forcegc.lock) } // scavenge heap once in a while @@ -4337,7 +4276,7 @@ func schedtrace(detailed bool) { if mp != nil { id = mp.id } - print(" P", i, ": status=", _p_.status, " schedtick=", _p_.schedtick, " syscalltick=", _p_.syscalltick, " m=", id, " runqsize=", t-h, " gfreecnt=", _p_.gfreecnt, "\n") + print(" P", i, ": status=", _p_.status, " schedtick=", _p_.schedtick, " syscalltick=", _p_.syscalltick, " m=", id, " runqsize=", t-h, " gfreecnt=", _p_.gFree.n, "\n") } else { // In non-detailed mode format lengths of per-P run queues as: // [len1 len2 len3 len4] @@ -4373,7 +4312,7 @@ func schedtrace(detailed bool) { if lockedg != nil { id3 = lockedg.goid } - print(" M", mp.id, ": p=", id1, " curg=", id2, " mallocing=", mp.mallocing, " throwing=", mp.throwing, " preemptoff=", mp.preemptoff, ""+" locks=", mp.locks, " dying=", mp.dying, " helpgc=", mp.helpgc, " spinning=", mp.spinning, " blocked=", mp.blocked, " lockedg=", id3, "\n") + print(" M", mp.id, ": p=", id1, " curg=", id2, " mallocing=", mp.mallocing, " throwing=", mp.throwing, " preemptoff=", mp.preemptoff, ""+" locks=", mp.locks, " dying=", mp.dying, " spinning=", mp.spinning, " blocked=", mp.blocked, " lockedg=", id3, "\n") } lock(&allglock) @@ -4395,6 +4334,40 @@ func schedtrace(detailed bool) { unlock(&sched.lock) } +// schedEnableUser enables or disables the scheduling of user +// goroutines. +// +// This does not stop already running user goroutines, so the caller +// should first stop the world when disabling user goroutines. +func schedEnableUser(enable bool) { + lock(&sched.lock) + if sched.disable.user == !enable { + unlock(&sched.lock) + return + } + sched.disable.user = !enable + if enable { + n := sched.disable.n + sched.disable.n = 0 + globrunqputbatch(&sched.disable.runnable, n) + unlock(&sched.lock) + for ; n != 0 && sched.npidle != 0; n-- { + startm(nil, false) + } + } else { + unlock(&sched.lock) + } +} + +// schedEnabled reports whether gp should be scheduled. It returns +// false is scheduling of gp is disabled. +func schedEnabled(gp *g) bool { + if sched.disable.user { + return isSystemGoroutine(gp, true) + } + return true +} + // Put mp on midle list. // Sched must be locked. // May run during STW, so write barriers are not allowed. @@ -4424,13 +4397,7 @@ func mget() *m { // May run during STW, so write barriers are not allowed. //go:nowritebarrierrec func globrunqput(gp *g) { - gp.schedlink = 0 - if sched.runqtail != 0 { - sched.runqtail.ptr().schedlink.set(gp) - } else { - sched.runqhead.set(gp) - } - sched.runqtail.set(gp) + sched.runq.pushBack(gp) sched.runqsize++ } @@ -4439,25 +4406,17 @@ func globrunqput(gp *g) { // May run during STW, so write barriers are not allowed. //go:nowritebarrierrec func globrunqputhead(gp *g) { - gp.schedlink = sched.runqhead - sched.runqhead.set(gp) - if sched.runqtail == 0 { - sched.runqtail.set(gp) - } + sched.runq.push(gp) sched.runqsize++ } // Put a batch of runnable goroutines on the global runnable queue. +// This clears *batch. // Sched must be locked. -func globrunqputbatch(ghead *g, gtail *g, n int32) { - gtail.schedlink = 0 - if sched.runqtail != 0 { - sched.runqtail.ptr().schedlink.set(ghead) - } else { - sched.runqhead.set(ghead) - } - sched.runqtail.set(gtail) +func globrunqputbatch(batch *gQueue, n int32) { + sched.runq.pushBackAll(*batch) sched.runqsize += n + *batch = gQueue{} } // Try get a batch of G's from the global runnable queue. @@ -4479,16 +4438,11 @@ func globrunqget(_p_ *p, max int32) *g { } sched.runqsize -= n - if sched.runqsize == 0 { - sched.runqtail = 0 - } - gp := sched.runqhead.ptr() - sched.runqhead = gp.schedlink + gp := sched.runq.pop() n-- for ; n > 0; n-- { - gp1 := sched.runqhead.ptr() - sched.runqhead = gp1.schedlink + gp1 := sched.runq.pop() runqput(_p_, gp1, false) } return gp @@ -4520,7 +4474,7 @@ func pidleget() *p { return _p_ } -// runqempty returns true if _p_ has no Gs on its local run queue. +// runqempty reports whether _p_ has no Gs on its local run queue. // It never returns true spuriously. func runqempty(_p_ *p) bool { // Defend against a race where 1) _p_ has G1 in runqnext but runqhead == runqtail, @@ -4572,11 +4526,11 @@ func runqput(_p_ *p, gp *g, next bool) { } retry: - h := atomic.Load(&_p_.runqhead) // load-acquire, synchronize with consumers + h := atomic.LoadAcq(&_p_.runqhead) // load-acquire, synchronize with consumers t := _p_.runqtail if t-h < uint32(len(_p_.runq)) { _p_.runq[t%uint32(len(_p_.runq))].set(gp) - atomic.Store(&_p_.runqtail, t+1) // store-release, makes the item available for consumption + atomic.StoreRel(&_p_.runqtail, t+1) // store-release, makes the item available for consumption return } if runqputslow(_p_, gp, h, t) { @@ -4600,7 +4554,7 @@ func runqputslow(_p_ *p, gp *g, h, t uint32) bool { for i := uint32(0); i < n; i++ { batch[i] = _p_.runq[(h+i)%uint32(len(_p_.runq))].ptr() } - if !atomic.Cas(&_p_.runqhead, h, h+n) { // cas-release, commits consume + if !atomic.CasRel(&_p_.runqhead, h, h+n) { // cas-release, commits consume return false } batch[n] = gp @@ -4616,10 +4570,13 @@ func runqputslow(_p_ *p, gp *g, h, t uint32) bool { for i := uint32(0); i < n; i++ { batch[i].schedlink.set(batch[i+1]) } + var q gQueue + q.head.set(batch[0]) + q.tail.set(batch[n]) // Now put the batch on global queue. lock(&sched.lock) - globrunqputbatch(batch[0], batch[n], int32(n+1)) + globrunqputbatch(&q, int32(n+1)) unlock(&sched.lock) return true } @@ -4641,13 +4598,13 @@ func runqget(_p_ *p) (gp *g, inheritTime bool) { } for { - h := atomic.Load(&_p_.runqhead) // load-acquire, synchronize with other consumers + h := atomic.LoadAcq(&_p_.runqhead) // load-acquire, synchronize with other consumers t := _p_.runqtail if t == h { return nil, false } gp := _p_.runq[h%uint32(len(_p_.runq))].ptr() - if atomic.Cas(&_p_.runqhead, h, h+1) { // cas-release, commits consume + if atomic.CasRel(&_p_.runqhead, h, h+1) { // cas-release, commits consume return gp, false } } @@ -4659,8 +4616,8 @@ func runqget(_p_ *p) (gp *g, inheritTime bool) { // Can be executed by any P. func runqgrab(_p_ *p, batch *[256]guintptr, batchHead uint32, stealRunNextG bool) uint32 { for { - h := atomic.Load(&_p_.runqhead) // load-acquire, synchronize with other consumers - t := atomic.Load(&_p_.runqtail) // load-acquire, synchronize with the producer + h := atomic.LoadAcq(&_p_.runqhead) // load-acquire, synchronize with other consumers + t := atomic.LoadAcq(&_p_.runqtail) // load-acquire, synchronize with the producer n := t - h n = n - n/2 if n == 0 { @@ -4703,7 +4660,7 @@ func runqgrab(_p_ *p, batch *[256]guintptr, batchHead uint32, stealRunNextG bool g := _p_.runq[(h+i)%uint32(len(_p_.runq))] batch[(batchHead+i)%uint32(len(batch))] = g } - if atomic.Cas(&_p_.runqhead, h, h+n) { // cas-release, commits consume + if atomic.CasRel(&_p_.runqhead, h, h+n) { // cas-release, commits consume return n } } @@ -4723,11 +4680,112 @@ func runqsteal(_p_, p2 *p, stealRunNextG bool) *g { if n == 0 { return gp } - h := atomic.Load(&_p_.runqhead) // load-acquire, synchronize with consumers + h := atomic.LoadAcq(&_p_.runqhead) // load-acquire, synchronize with consumers if t-h+n >= uint32(len(_p_.runq)) { throw("runqsteal: runq overflow") } - atomic.Store(&_p_.runqtail, t+n) // store-release, makes the item available for consumption + atomic.StoreRel(&_p_.runqtail, t+n) // store-release, makes the item available for consumption + return gp +} + +// A gQueue is a dequeue of Gs linked through g.schedlink. A G can only +// be on one gQueue or gList at a time. +type gQueue struct { + head guintptr + tail guintptr +} + +// empty reports whether q is empty. +func (q *gQueue) empty() bool { + return q.head == 0 +} + +// push adds gp to the head of q. +func (q *gQueue) push(gp *g) { + gp.schedlink = q.head + q.head.set(gp) + if q.tail == 0 { + q.tail.set(gp) + } +} + +// pushBack adds gp to the tail of q. +func (q *gQueue) pushBack(gp *g) { + gp.schedlink = 0 + if q.tail != 0 { + q.tail.ptr().schedlink.set(gp) + } else { + q.head.set(gp) + } + q.tail.set(gp) +} + +// pushBackAll adds all Gs in l2 to the tail of q. After this q2 must +// not be used. +func (q *gQueue) pushBackAll(q2 gQueue) { + if q2.tail == 0 { + return + } + q2.tail.ptr().schedlink = 0 + if q.tail != 0 { + q.tail.ptr().schedlink = q2.head + } else { + q.head = q2.head + } + q.tail = q2.tail +} + +// pop removes and returns the head of queue q. It returns nil if +// q is empty. +func (q *gQueue) pop() *g { + gp := q.head.ptr() + if gp != nil { + q.head = gp.schedlink + if q.head == 0 { + q.tail = 0 + } + } + return gp +} + +// popList takes all Gs in q and returns them as a gList. +func (q *gQueue) popList() gList { + stack := gList{q.head} + *q = gQueue{} + return stack +} + +// A gList is a list of Gs linked through g.schedlink. A G can only be +// on one gQueue or gList at a time. +type gList struct { + head guintptr +} + +// empty reports whether l is empty. +func (l *gList) empty() bool { + return l.head == 0 +} + +// push adds gp to the head of l. +func (l *gList) push(gp *g) { + gp.schedlink = l.head + l.head.set(gp) +} + +// pushAll prepends all Gs in q to l. +func (l *gList) pushAll(q gQueue) { + if !q.empty() { + q.tail.ptr().schedlink = l.head + l.head = q.head + } +} + +// pop removes and returns the head of l. If l is empty, it returns nil. +func (l *gList) pop() *g { + gp := l.head.ptr() + if gp != nil { + l.head = gp.schedlink + } return gp } diff --git a/libgo/go/runtime/proc_test.go b/libgo/go/runtime/proc_test.go index 82a2fe486a9..da5ffbbdee2 100644 --- a/libgo/go/runtime/proc_test.go +++ b/libgo/go/runtime/proc_test.go @@ -898,11 +898,22 @@ func testLockOSThreadExit(t *testing.T, prog string) { output := runTestProg(t, prog, "LockOSThreadMain", "GOMAXPROCS=1") want := "OK\n" if output != want { - t.Errorf("want %s, got %s\n", want, output) + t.Errorf("want %q, got %q", want, output) } output = runTestProg(t, prog, "LockOSThreadAlt") if output != want { - t.Errorf("want %s, got %s\n", want, output) + t.Errorf("want %q, got %q", want, output) + } +} + +func TestLockOSThreadAvoidsStatePropagation(t *testing.T) { + want := "OK\n" + skip := "unshare not permitted\n" + output := runTestProg(t, "testprog", "LockOSThreadAvoidsStatePropagation", "GOMAXPROCS=1") + if output == skip { + t.Skip("unshare syscall not permitted on this system") + } else if output != want { + t.Errorf("want %q, got %q", want, output) } } diff --git a/libgo/go/runtime/runtime1.go b/libgo/go/runtime/runtime1.go index 050f180c407..4e771629b0e 100644 --- a/libgo/go/runtime/runtime1.go +++ b/libgo/go/runtime/runtime1.go @@ -157,7 +157,7 @@ func check() { h uint64 i, i1 float32 j, j1 float64 - k, k1 unsafe.Pointer + k unsafe.Pointer l *uint16 m [4]byte ) @@ -246,21 +246,6 @@ func check() { throw("cas6") } - k = unsafe.Pointer(uintptr(0xfedcb123)) - if sys.PtrSize == 8 { - k = unsafe.Pointer(uintptr(k) << 10) - } - if casp(&k, nil, nil) { - throw("casp1") - } - k1 = add(k, 1) - if !casp(&k, k, k1) { - throw("casp2") - } - if k != k1 { - throw("casp3") - } - m = [4]byte{1, 1, 1, 1} atomic.Or8(&m[1], 0xf0) if m[0] != 1 || m[1] != 0xf1 || m[2] != 1 || m[3] != 1 { @@ -332,10 +317,10 @@ var debug struct { gccheckmark int32 gcpacertrace int32 gcshrinkstackoff int32 - gcrescanstacks int32 gcstoptheworld int32 gctrace int32 invalidptr int32 + madvdontneed int32 // for Linux; issue 28466 sbrk int32 scavenge int32 scheddetail int32 @@ -350,10 +335,10 @@ var dbgvars = []dbgVar{ {"gccheckmark", &debug.gccheckmark}, {"gcpacertrace", &debug.gcpacertrace}, {"gcshrinkstackoff", &debug.gcshrinkstackoff}, - {"gcrescanstacks", &debug.gcrescanstacks}, {"gcstoptheworld", &debug.gcstoptheworld}, {"gctrace", &debug.gctrace}, {"invalidptr", &debug.invalidptr}, + {"madvdontneed", &debug.madvdontneed}, {"sbrk", &debug.sbrk}, {"scavenge", &debug.scavenge}, {"scheddetail", &debug.scheddetail}, @@ -454,7 +439,9 @@ func timediv(v int64, div int32, rem *int32) int32 { for bit := 30; bit >= 0; bit-- { if v >= int64(div)<= int64(div) { diff --git a/libgo/go/runtime/runtime2.go b/libgo/go/runtime/runtime2.go index 0e9cf63c10d..4cd68da2ea2 100644 --- a/libgo/go/runtime/runtime2.go +++ b/libgo/go/runtime/runtime2.go @@ -5,6 +5,7 @@ package runtime import ( + "internal/cpu" "runtime/internal/atomic" "runtime/internal/sys" "unsafe" @@ -439,7 +440,12 @@ type g struct { scang uintptr // the g that wants to scan this g's stack (uintptr to avoid write barrier) scangcw uintptr // gc worker for scanning stack (uintptr to avoid write barrier) - isSystemGoroutine bool // whether goroutine is a "system" goroutine + isSystemGoroutine bool // whether goroutine is a "system" goroutine + isFinalizerGoroutine bool // whether goroutine is the finalizer goroutine + + deferring bool // whether we are running a deferred function + goexiting bool // whether we are running Goexit + ranCgocallBackDone bool // whether we deferred CgocallBackDone traceback uintptr // stack traceback buffer @@ -463,6 +469,7 @@ type m struct { caughtsig guintptr // goroutine running during fatal signal p puintptr // attached p for executing go code (nil if not executing go code) nextp puintptr + oldp puintptr // the p that was attached before executing a syscall id int64 mallocing int32 throwing int32 @@ -471,7 +478,6 @@ type m struct { softfloat int32 dying int32 profilehz int32 - helpgc int32 spinning bool // m is out of work and is actively looking for work blocked bool // m is blocked on a note inwb bool // m is executing a write barrier @@ -564,8 +570,10 @@ type p struct { runnext guintptr // Available G's (status == Gdead) - gfree *g - gfreecnt int32 + gFree struct { + gList + n int32 + } sudogcache []*sudog sudogbuf [128]*sudog @@ -604,7 +612,7 @@ type p struct { runSafePointFn uint32 // if 1, run sched.safePointFn at next safe point - pad [sys.CacheLineSize]byte + pad cpu.CacheLinePad } type schedt struct { @@ -632,14 +640,27 @@ type schedt struct { nmspinning uint32 // See "Worker thread parking/unparking" comment in proc.go. // Global runnable queue. - runqhead guintptr - runqtail guintptr + runq gQueue runqsize int32 + // disable controls selective disabling of the scheduler. + // + // Use schedEnableUser to control this. + // + // disable is protected by sched.lock. + disable struct { + // user disables scheduling of user goroutines. + user bool + runnable gQueue // pending runnable Gs + n int32 // length of runnable + } + // Global cache of dead G's. - gflock mutex - gfree *g - ngfree int32 + gFree struct { + lock mutex + list gList // Gs + n int32 + } // Central cache of sudog structs. sudoglock mutex diff --git a/libgo/go/runtime/select.go b/libgo/go/runtime/select.go index fb8373f53b5..d658a349ed2 100644 --- a/libgo/go/runtime/select.go +++ b/libgo/go/runtime/select.go @@ -105,7 +105,7 @@ func block() { // // selectgo returns the index of the chosen scase, which matches the // ordinal position of its respective select{recv,send,default} call. -// Also, if the chosen scase was a receive operation, it returns whether +// Also, if the chosen scase was a receive operation, it reports whether // a value was received. func selectgo(cas0 *scase, order0 *uint16, ncases int) (int, bool) { if debugSelect { diff --git a/libgo/go/runtime/sema.go b/libgo/go/runtime/sema.go index 273e8aa54d9..2c7ad329662 100644 --- a/libgo/go/runtime/sema.go +++ b/libgo/go/runtime/sema.go @@ -20,8 +20,8 @@ package runtime import ( + "internal/cpu" "runtime/internal/atomic" - "runtime/internal/sys" "unsafe" ) @@ -48,7 +48,7 @@ const semTabSize = 251 var semtable [semTabSize]struct { root semaRoot - pad [sys.CacheLineSize - unsafe.Sizeof(semaRoot{})]byte + pad [cpu.CacheLinePadSize - unsafe.Sizeof(semaRoot{})]byte } //go:linkname sync_runtime_Semacquire sync.runtime_Semacquire diff --git a/libgo/go/runtime/semasleep_test.go b/libgo/go/runtime/semasleep_test.go new file mode 100644 index 00000000000..5b2cc64483f --- /dev/null +++ b/libgo/go/runtime/semasleep_test.go @@ -0,0 +1,88 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//+build !nacl,!plan9,!windows,!js + +package runtime_test + +import ( + "internal/testenv" + "io/ioutil" + "os" + "os/exec" + "path/filepath" + "syscall" + "testing" + "time" +) + +// Issue #27250. Spurious wakeups to pthread_cond_timedwait_relative_np +// shouldn't cause semasleep to retry with the same timeout which would +// cause indefinite spinning. +func TestSpuriousWakeupsNeverHangSemasleep(t *testing.T) { + testenv.MustHaveGoBuild(t) + tempDir, err := ioutil.TempDir("", "issue-27250") + if err != nil { + t.Fatalf("Failed to create the temp directory: %v", err) + } + defer os.RemoveAll(tempDir) + + repro := ` + package main + + import "time" + + func main() { + <-time.After(1 * time.Second) + } + ` + mainPath := filepath.Join(tempDir, "main.go") + if err := ioutil.WriteFile(mainPath, []byte(repro), 0644); err != nil { + t.Fatalf("Failed to create temp file for repro.go: %v", err) + } + binaryPath := filepath.Join(tempDir, "binary") + + // Build the binary so that we can send the signal to its PID. + out, err := exec.Command(testenv.GoToolPath(t), "build", "-o", binaryPath, mainPath).CombinedOutput() + if err != nil { + t.Fatalf("Failed to compile the binary: err: %v\nOutput: %s\n", err, out) + } + if err := os.Chmod(binaryPath, 0755); err != nil { + t.Fatalf("Failed to chmod binary: %v", err) + } + + // Now run the binary. + cmd := exec.Command(binaryPath) + if err := cmd.Start(); err != nil { + t.Fatalf("Failed to start command: %v", err) + } + doneCh := make(chan error, 1) + go func() { + doneCh <- cmd.Wait() + }() + + // With the repro running, we can continuously send to it + // a non-terminal signal such as SIGIO, to spuriously + // wakeup pthread_cond_timedwait_relative_np. + unfixedTimer := time.NewTimer(2 * time.Second) + for { + select { + case <-time.After(200 * time.Millisecond): + // Send the pesky signal that toggles spinning + // indefinitely if #27520 is not fixed. + cmd.Process.Signal(syscall.SIGIO) + + case <-unfixedTimer.C: + t.Error("Program failed to return on time and has to be killed, issue #27520 still exists") + cmd.Process.Signal(syscall.SIGKILL) + return + + case err := <-doneCh: + if err != nil { + t.Fatalf("The program returned but unfortunately with an error: %v", err) + } + return + } + } +} diff --git a/libgo/go/runtime/signal_unix.go b/libgo/go/runtime/signal_unix.go index 84623d33c66..0a2cf724c0d 100644 --- a/libgo/go/runtime/signal_unix.go +++ b/libgo/go/runtime/signal_unix.go @@ -725,7 +725,7 @@ func unminitSignals() { } } -// blockableSig returns whether sig may be blocked by the signal mask. +// blockableSig reports whether sig may be blocked by the signal mask. // We never want to block the signals marked _SigUnblock; // these are the synchronous signals that turn into a Go panic. // In a Go program--not a c-archive/c-shared--we never want to block diff --git a/libgo/go/runtime/slice.go b/libgo/go/runtime/slice.go index 7f9db4efa9e..335532d126b 100644 --- a/libgo/go/runtime/slice.go +++ b/libgo/go/runtime/slice.go @@ -5,6 +5,7 @@ package runtime import ( + "runtime/internal/math" "runtime/internal/sys" "unsafe" ) @@ -31,28 +32,6 @@ type notInHeapSlice struct { cap int } -// maxElems is a lookup table containing the maximum capacity for a slice. -// The index is the size of the slice element. -var maxElems = [...]uintptr{ - ^uintptr(0), - maxAlloc / 1, maxAlloc / 2, maxAlloc / 3, maxAlloc / 4, - maxAlloc / 5, maxAlloc / 6, maxAlloc / 7, maxAlloc / 8, - maxAlloc / 9, maxAlloc / 10, maxAlloc / 11, maxAlloc / 12, - maxAlloc / 13, maxAlloc / 14, maxAlloc / 15, maxAlloc / 16, - maxAlloc / 17, maxAlloc / 18, maxAlloc / 19, maxAlloc / 20, - maxAlloc / 21, maxAlloc / 22, maxAlloc / 23, maxAlloc / 24, - maxAlloc / 25, maxAlloc / 26, maxAlloc / 27, maxAlloc / 28, - maxAlloc / 29, maxAlloc / 30, maxAlloc / 31, maxAlloc / 32, -} - -// maxSliceCap returns the maximum capacity for a slice. -func maxSliceCap(elemsize uintptr) uintptr { - if elemsize < uintptr(len(maxElems)) { - return maxElems[elemsize] - } - return maxAlloc / elemsize -} - func panicmakeslicelen() { panic(errorString("makeslice: len out of range")) } @@ -62,21 +41,21 @@ func panicmakeslicecap() { } func makeslice(et *_type, len, cap int) unsafe.Pointer { - // NOTE: The len > maxElements check here is not strictly necessary, - // but it produces a 'len out of range' error instead of a 'cap out of range' error - // when someone does make([]T, bignumber). 'cap out of range' is true too, - // but since the cap is only being supplied implicitly, saying len is clearer. - // See issue 4085. - maxElements := maxSliceCap(et.size) - if len < 0 || uintptr(len) > maxElements { - panicmakeslicelen() - } - - if cap < len || uintptr(cap) > maxElements { + mem, overflow := math.MulUintptr(et.size, uintptr(cap)) + if overflow || mem > maxAlloc || len < 0 || len > cap { + // NOTE: Produce a 'len out of range' error instead of a + // 'cap out of range' error when someone does make([]T, bignumber). + // 'cap out of range' is true too, but since the cap is only being + // supplied implicitly, saying len is clearer. + // See golang.org/issue/4085. + mem, overflow := math.MulUintptr(et.size, uintptr(len)) + if overflow || mem > maxAlloc || len < 0 { + panicmakeslicelen() + } panicmakeslicecap() } - return mallocgc(et.size*uintptr(cap), et, true) + return mallocgc(mem, et, true) } func makeslice64(et *_type, len64, cap64 int64) unsafe.Pointer { @@ -107,10 +86,11 @@ func growslice(et *_type, old slice, cap int) slice { msanread(old.array, uintptr(old.len*int(et.size))) } + if cap < old.cap { + panic(errorString("growslice: cap out of range")) + } + if et.size == 0 { - if cap < old.cap { - panic(errorString("growslice: cap out of range")) - } // append should not create a slice with nil pointer but non-zero len. // We assume that append doesn't need to preserve old.array in this case. return slice{unsafe.Pointer(&zerobase), cap, cap} @@ -172,15 +152,14 @@ func growslice(et *_type, old slice, cap int) slice { default: lenmem = uintptr(old.len) * et.size newlenmem = uintptr(cap) * et.size - capmem = roundupsize(uintptr(newcap) * et.size) - overflow = uintptr(newcap) > maxSliceCap(et.size) + capmem, overflow = math.MulUintptr(et.size, uintptr(newcap)) + capmem = roundupsize(capmem) newcap = int(capmem / et.size) } - // The check of overflow (uintptr(newcap) > maxSliceCap(et.size)) - // in addition to capmem > _MaxMem is needed to prevent an overflow - // which can be used to trigger a segfault on 32bit architectures - // with this example program: + // The check of overflow in addition to capmem > maxAlloc is needed + // to prevent an overflow which can be used to trigger a segfault + // on 32bit architectures with this example program: // // type T [1<<27 + 1]int64 // @@ -191,28 +170,26 @@ func growslice(et *_type, old slice, cap int) slice { // s = append(s, d, d, d, d) // print(len(s), "\n") // } - if cap < old.cap || overflow || capmem > maxAlloc { + if overflow || capmem > maxAlloc { panic(errorString("growslice: cap out of range")) } var p unsafe.Pointer if et.kind&kindNoPointers != 0 { p = mallocgc(capmem, nil, false) - memmove(p, old.array, lenmem) // The append() that calls growslice is going to overwrite from old.len to cap (which will be the new length). // Only clear the part that will not be overwritten. memclrNoHeapPointers(add(p, newlenmem), capmem-newlenmem) } else { // Note: can't use rawmem (which avoids zeroing of memory), because then GC can scan uninitialized memory. p = mallocgc(capmem, et, true) - if !writeBarrier.enabled { - memmove(p, old.array, lenmem) - } else { - for i := uintptr(0); i < lenmem; i += et.size { - typedmemmove(et, add(p, i), add(old.array, i)) - } + if writeBarrier.enabled { + // Only shade the pointers in old.array since we know the destination slice p + // only contains nil pointers because it has been cleared during alloc. + bulkBarrierPreWriteSrcOnly(uintptr(p), uintptr(old.array), lenmem) } } + memmove(p, old.array, lenmem) return slice{p, cap, newcap} } diff --git a/libgo/go/runtime/slice_test.go b/libgo/go/runtime/slice_test.go index c2dfb7afd19..0463fc70a76 100644 --- a/libgo/go/runtime/slice_test.go +++ b/libgo/go/runtime/slice_test.go @@ -10,20 +10,68 @@ import ( const N = 20 -func BenchmarkMakeSlice(b *testing.B) { - var x []byte - for i := 0; i < b.N; i++ { - x = make([]byte, 32) - _ = x - } -} - type ( struct24 struct{ a, b, c int64 } struct32 struct{ a, b, c, d int64 } struct40 struct{ a, b, c, d, e int64 } ) +func BenchmarkMakeSlice(b *testing.B) { + const length = 2 + b.Run("Byte", func(b *testing.B) { + var x []byte + for i := 0; i < b.N; i++ { + x = make([]byte, length, 2*length) + _ = x + } + }) + b.Run("Int16", func(b *testing.B) { + var x []int16 + for i := 0; i < b.N; i++ { + x = make([]int16, length, 2*length) + _ = x + } + }) + b.Run("Int", func(b *testing.B) { + var x []int + for i := 0; i < b.N; i++ { + x = make([]int, length, 2*length) + _ = x + } + }) + b.Run("Ptr", func(b *testing.B) { + var x []*byte + for i := 0; i < b.N; i++ { + x = make([]*byte, length, 2*length) + _ = x + } + }) + b.Run("Struct", func(b *testing.B) { + b.Run("24", func(b *testing.B) { + var x []struct24 + for i := 0; i < b.N; i++ { + x = make([]struct24, length, 2*length) + _ = x + } + }) + b.Run("32", func(b *testing.B) { + var x []struct32 + for i := 0; i < b.N; i++ { + x = make([]struct32, length, 2*length) + _ = x + } + }) + b.Run("40", func(b *testing.B) { + var x []struct40 + for i := 0; i < b.N; i++ { + x = make([]struct40, length, 2*length) + _ = x + } + }) + + }) +} + func BenchmarkGrowSlice(b *testing.B) { b.Run("Byte", func(b *testing.B) { x := make([]byte, 9) diff --git a/libgo/go/runtime/string.go b/libgo/go/runtime/string.go index 5296ebddf39..025ea7a3bd7 100644 --- a/libgo/go/runtime/string.go +++ b/libgo/go/runtime/string.go @@ -146,7 +146,8 @@ func rawstringtmp(buf *tmpBuf, l int) (s string, b []byte) { // and otherwise intrinsified by the compiler. // // Some internal compiler optimizations use this function. -// - Used for m[string(k)] lookup where m is a string-keyed map and k is a []byte. +// - Used for m[T1{... Tn{..., string(k), ...} ...}] and m[string(k)] +// where k is []byte, T1 to Tn is a nesting of struct and array literals. // - Used for "<"+string(b)+">" concatenation where b is []byte. // - Used for string(b)=="foo" comparison where b is []byte. func slicebytetostringtmp(b []byte) string { @@ -344,7 +345,7 @@ func index(s, t string) int { return 0 } for i := 0; i < len(s); i++ { - if s[i] == t[0] && hasprefix(s[i:], t) { + if s[i] == t[0] && hasPrefix(s[i:], t) { return i } } @@ -355,8 +356,8 @@ func contains(s, t string) bool { return index(s, t) >= 0 } -func hasprefix(s, t string) bool { - return len(s) >= len(t) && s[:len(t)] == t +func hasPrefix(s, prefix string) bool { + return len(s) >= len(prefix) && s[:len(prefix)] == prefix } const ( diff --git a/libgo/go/runtime/string_test.go b/libgo/go/runtime/string_test.go index 03327bbb1e2..ec83bb4d458 100644 --- a/libgo/go/runtime/string_test.go +++ b/libgo/go/runtime/string_test.go @@ -243,6 +243,36 @@ func TestCompareTempString(t *testing.T) { } } +func TestStringIndexHaystack(t *testing.T) { + // See issue 25864. + haystack := []byte("hello") + needle := "ll" + n := testing.AllocsPerRun(1000, func() { + if strings.Index(string(haystack), needle) != 2 { + t.Fatalf("needle not found") + } + }) + // was n != 0, changed for gccgo. + if n > 1 { + t.Fatalf("want 0 allocs, got %v", n) + } +} + +func TestStringIndexNeedle(t *testing.T) { + // See issue 25864. + haystack := "hello" + needle := []byte("ll") + n := testing.AllocsPerRun(1000, func() { + if strings.Index(haystack, string(needle)) != 2 { + t.Fatalf("needle not found") + } + }) + // was n != 0, changed for gccgo + if n > 1 { + t.Fatalf("want 0 allocs, got %v", n) + } +} + func TestStringOnStack(t *testing.T) { s := "" for i := 0; i < 3; i++ { diff --git a/libgo/go/runtime/stubs.go b/libgo/go/runtime/stubs.go index 4caa39d5e94..f2b0ee8abaa 100644 --- a/libgo/go/runtime/stubs.go +++ b/libgo/go/runtime/stubs.go @@ -84,12 +84,12 @@ func badsystemstack() { // used only when the caller knows that *ptr contains no heap pointers // because either: // -// 1. *ptr is initialized memory and its type is pointer-free. +// *ptr is initialized memory and its type is pointer-free, or // -// 2. *ptr is uninitialized memory (e.g., memory that's being reused -// for a new allocation) and hence contains only "junk". +// *ptr is uninitialized memory (e.g., memory that's being reused +// for a new allocation) and hence contains only "junk". // -// in memclr_*.s +// The (CPU-specific) implementations of this function are in memclr_*.s. //go:noescape func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr) @@ -164,7 +164,7 @@ func breakpoint() func asminit() {} -//go:linkname reflectcall reflect.call +//go:linkname reflectcall runtime.reflectcall //go:noescape func reflectcall(fntype *functype, fn *funcval, isInterface, isMethod bool, params, results *unsafe.Pointer) @@ -454,3 +454,15 @@ var usestackmaps bool // probestackmaps detects whether there are stack maps. //go:linkname probestackmaps runtime.probestackmaps func probestackmaps() bool + +// For the math/bits packages for gccgo. +//go:linkname getDivideError runtime.getDivideError +func getDivideError() error { + return divideError +} + +// For the math/bits packages for gccgo. +//go:linkname getOverflowError runtime.getOverflowError +func getOverflowError() error { + return overflowError +} diff --git a/libgo/go/runtime/stubs2.go b/libgo/go/runtime/stubs2.go index 1cb910cd111..304c8e4da37 100644 --- a/libgo/go/runtime/stubs2.go +++ b/libgo/go/runtime/stubs2.go @@ -7,6 +7,7 @@ // +build !nacl // +build !js // +build !darwin +// +build !aix package runtime diff --git a/libgo/go/runtime/stubs3.go b/libgo/go/runtime/stubs3.go index 1af693be2e6..d3e331ab9da 100644 --- a/libgo/go/runtime/stubs3.go +++ b/libgo/go/runtime/stubs3.go @@ -7,6 +7,7 @@ // +build !nacl // +build !freebsd // +build !darwin +// +build !aix package runtime diff --git a/libgo/go/runtime/symtab.go b/libgo/go/runtime/symtab.go index d137122137c..d7e8c18b517 100644 --- a/libgo/go/runtime/symtab.go +++ b/libgo/go/runtime/symtab.go @@ -7,7 +7,7 @@ package runtime // Frames may be used to get function/file/line information for a // slice of PC values returned by Callers. type Frames struct { - // callers is a slice of PCs that have not yet been expanded. + // callers is a slice of PCs that have not yet been expanded to frames. callers []uintptr // The last PC we saw. @@ -125,7 +125,7 @@ type Func struct { // Note that in some situations involving plugins, there may be multiple // copies of a particular special runtime function. // Note: this list must match the list in cmd/internal/objabi/funcid.go. -type funcID uint32 +type funcID uint8 const ( funcID_normal funcID = iota // not a special function @@ -146,13 +146,17 @@ const ( funcID_gogo funcID_externalthreadhandler funcID_debugCallV1 + funcID_gopanic + funcID_panicwrap + funcID_wrapper // any autogenerated code (hash/eq algorithms, method wrappers, etc.) ) // FuncForPC returns a *Func describing the function that contains the // given program counter address, or else nil. // // If pc represents multiple functions because of inlining, it returns -// the *Func describing the outermost function. +// the a *Func describing the innermost function, but with an entry +// of the outermost function. func FuncForPC(pc uintptr) *Func { name, _, _ := funcfileline(pc, -1) if name == "" { diff --git a/libgo/go/runtime/sys_darwin.go b/libgo/go/runtime/sys_darwin.go index 7efbef746cd..f34ac883524 100644 --- a/libgo/go/runtime/sys_darwin.go +++ b/libgo/go/runtime/sys_darwin.go @@ -50,6 +50,61 @@ func libcCall(fn, arg unsafe.Pointer) int32 { return res } +// The X versions of syscall expect the libc call to return a 64-bit result. +// Otherwise (the non-X version) expects a 32-bit result. +// This distinction is required because an error is indicated by returning -1, +// and we need to know whether to check 32 or 64 bits of the result. +// (Some libc functions that return 32 bits put junk in the upper 32 bits of AX.) + +//go:linkname syscall_syscall syscall.syscall +//go:nosplit +//go:cgo_unsafe_args +func syscall_syscall(fn, a1, a2, a3 uintptr) (r1, r2, err uintptr) { + entersyscallblock() + libcCall(unsafe.Pointer(funcPC(syscall)), unsafe.Pointer(&fn)) + exitsyscall() + return +} +func syscall() + +//go:linkname syscall_syscall6 syscall.syscall6 +//go:nosplit +//go:cgo_unsafe_args +func syscall_syscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) { + entersyscallblock() + libcCall(unsafe.Pointer(funcPC(syscall6)), unsafe.Pointer(&fn)) + exitsyscall() + return +} +func syscall6() + +//go:linkname syscall_syscall6X syscall.syscall6X +//go:nosplit +//go:cgo_unsafe_args +func syscall_syscall6X(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) { + entersyscallblock() + libcCall(unsafe.Pointer(funcPC(syscall6X)), unsafe.Pointer(&fn)) + exitsyscall() + return +} +func syscall6X() + +//go:linkname syscall_rawSyscall syscall.rawSyscall +//go:nosplit +//go:cgo_unsafe_args +func syscall_rawSyscall(fn, a1, a2, a3 uintptr) (r1, r2, err uintptr) { + libcCall(unsafe.Pointer(funcPC(syscall)), unsafe.Pointer(&fn)) + return +} + +//go:linkname syscall_rawSyscall6 syscall.rawSyscall6 +//go:nosplit +//go:cgo_unsafe_args +func syscall_rawSyscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) { + libcCall(unsafe.Pointer(funcPC(syscall6)), unsafe.Pointer(&fn)) + return +} + // The *_trampoline functions convert from the Go calling convention to the C calling convention // and then call the underlying libc function. They are defined in sys_darwin_$ARCH.s. @@ -370,5 +425,5 @@ func closeonexec(fd int32) { //go:cgo_import_dynamic libc_pthread_cond_signal pthread_cond_signal "/usr/lib/libSystem.B.dylib" // Magic incantation to get libSystem actually dynamically linked. -// TODO: Why does the code require this? See cmd/compile/internal/ld/go.go:210 +// TODO: Why does the code require this? See cmd/link/internal/ld/go.go //go:cgo_import_dynamic _ _ "/usr/lib/libSystem.B.dylib" diff --git a/libgo/go/runtime/sys_darwin_32.go b/libgo/go/runtime/sys_darwin_32.go new file mode 100644 index 00000000000..2f17091327d --- /dev/null +++ b/libgo/go/runtime/sys_darwin_32.go @@ -0,0 +1,32 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build darwin +// +build 386 arm + +package runtime + +import "unsafe" + +//go:linkname syscall_syscall9 syscall.syscall9 +//go:nosplit +//go:cgo_unsafe_args +func syscall_syscall9(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2, err uintptr) { + entersyscallblock() + libcCall(unsafe.Pointer(funcPC(syscall9)), unsafe.Pointer(&fn)) + exitsyscall() + return +} +func syscall9() + +//go:linkname syscall_syscallPtr syscall.syscallPtr +//go:nosplit +//go:cgo_unsafe_args +func syscall_syscallPtr(fn, a1, a2, a3 uintptr) (r1, r2, err uintptr) { + entersyscallblock() + libcCall(unsafe.Pointer(funcPC(syscallPtr)), unsafe.Pointer(&fn)) + exitsyscall() + return +} +func syscallPtr() diff --git a/libgo/go/runtime/sys_darwin_64.go b/libgo/go/runtime/sys_darwin_64.go new file mode 100644 index 00000000000..8c128811b9f --- /dev/null +++ b/libgo/go/runtime/sys_darwin_64.go @@ -0,0 +1,32 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build darwin +// +build amd64 arm64 + +package runtime + +import "unsafe" + +//go:linkname syscall_syscallX syscall.syscallX +//go:nosplit +//go:cgo_unsafe_args +func syscall_syscallX(fn, a1, a2, a3 uintptr) (r1, r2, err uintptr) { + entersyscallblock() + libcCall(unsafe.Pointer(funcPC(syscallX)), unsafe.Pointer(&fn)) + exitsyscall() + return +} +func syscallX() + +//go:linkname syscall_syscallXPtr syscall.syscallXPtr +//go:nosplit +//go:cgo_unsafe_args +func syscall_syscallXPtr(fn, a1, a2, a3 uintptr) (r1, r2, err uintptr) { + entersyscallblock() + libcCall(unsafe.Pointer(funcPC(syscallXPtr)), unsafe.Pointer(&fn)) + exitsyscall() + return +} +func syscallXPtr() diff --git a/libgo/go/runtime/testdata/testprog/gc.go b/libgo/go/runtime/testdata/testprog/gc.go index 542451753b7..6b308e073b9 100644 --- a/libgo/go/runtime/testdata/testprog/gc.go +++ b/libgo/go/runtime/testdata/testprog/gc.go @@ -17,6 +17,7 @@ func init() { register("GCFairness", GCFairness) register("GCFairness2", GCFairness2) register("GCSys", GCSys) + register("GCPhys", GCPhys) } func GCSys() { @@ -51,8 +52,11 @@ func GCSys() { fmt.Printf("OK\n") } +var sink []byte + func workthegc() []byte { - return make([]byte, 1029) + sink = make([]byte, 1029) + return sink } func GCFairness() { @@ -124,3 +128,85 @@ func GCFairness2() { } fmt.Println("OK") } + +var maybeSaved []byte + +func GCPhys() { + // In this test, we construct a very specific scenario. We first + // allocate N objects and drop half of their pointers on the floor, + // effectively creating N/2 'holes' in our allocated arenas. We then + // try to allocate objects twice as big. At the end, we measure the + // physical memory overhead of large objects. + // + // The purpose of this test is to ensure that the GC scavenges free + // spans eagerly to ensure high physical memory utilization even + // during fragmentation. + const ( + // Unfortunately, measuring actual used physical pages is + // difficult because HeapReleased doesn't include the parts + // of an arena that haven't yet been touched. So, we just + // make objects and size sufficiently large such that even + // 64 MB overhead is relatively small in the final + // calculation. + // + // Currently, we target 480MiB worth of memory for our test, + // computed as size * objects + (size*2) * (objects/2) + // = 2 * size * objects + // + // Size must be also large enough to be considered a large + // object (not in any size-segregated span). + size = 1 << 20 + objects = 240 + ) + // Save objects which we want to survive, and condemn objects which we don't. + // Note that we condemn objects in this way and release them all at once in + // order to avoid having the GC start freeing up these objects while the loop + // is still running and filling in the holes we intend to make. + saved := make([][]byte, 0, objects) + condemned := make([][]byte, 0, objects/2+1) + for i := 0; i < objects; i++ { + // Write into a global, to prevent this from being optimized away by + // the compiler in the future. + maybeSaved = make([]byte, size) + if i%2 == 0 { + saved = append(saved, maybeSaved) + } else { + condemned = append(condemned, maybeSaved) + } + } + condemned = nil + // Clean up the heap. This will free up every other object created above + // (i.e. everything in condemned) creating holes in the heap. + runtime.GC() + // Allocate many new objects of 2x size. + for i := 0; i < objects/2; i++ { + saved = append(saved, make([]byte, size*2)) + } + // Clean up the heap again just to put it in a known state. + runtime.GC() + // heapBacked is an estimate of the amount of physical memory used by + // this test. HeapSys is an estimate of the size of the mapped virtual + // address space (which may or may not be backed by physical pages) + // whereas HeapReleased is an estimate of the amount of bytes returned + // to the OS. Their difference then roughly corresponds to the amount + // of virtual address space that is backed by physical pages. + var stats runtime.MemStats + runtime.ReadMemStats(&stats) + heapBacked := stats.HeapSys - stats.HeapReleased + // If heapBacked exceeds the amount of memory actually used for heap + // allocated objects by 10% (post-GC HeapAlloc should be quite close to + // the size of the working set), then fail. + // + // In the context of this test, that indicates a large amount of + // fragmentation with physical pages that are otherwise unused but not + // returned to the OS. + overuse := (float64(heapBacked) - float64(stats.HeapAlloc)) / float64(stats.HeapAlloc) + if overuse > 0.1 { + fmt.Printf("exceeded physical memory overuse threshold of 10%%: %3.2f%%\n"+ + "(alloc: %d, sys: %d, rel: %d, objs: %d)\n", overuse*100, stats.HeapAlloc, + stats.HeapSys, stats.HeapReleased, len(saved)) + return + } + fmt.Println("OK") + runtime.KeepAlive(saved) +} diff --git a/libgo/go/runtime/testdata/testprog/gettid.go b/libgo/go/runtime/testdata/testprog/gettid.go deleted file mode 100644 index 1b3e29ab08e..00000000000 --- a/libgo/go/runtime/testdata/testprog/gettid.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build linux - -package main - -import ( - "bytes" - "fmt" - "io/ioutil" - "os" - "syscall" -) - -func gettid() int { - return syscall.Gettid() -} - -func tidExists(tid int) (exists, supported bool) { - stat, err := ioutil.ReadFile(fmt.Sprintf("/proc/self/task/%d/stat", tid)) - if os.IsNotExist(err) { - return false, true - } - // Check if it's a zombie thread. - state := bytes.Fields(stat)[2] - return !(len(state) == 1 && state[0] == 'Z'), true -} diff --git a/libgo/go/runtime/testdata/testprog/lockosthread.go b/libgo/go/runtime/testdata/testprog/lockosthread.go index 88c0d12e4c1..fd3123e6474 100644 --- a/libgo/go/runtime/testdata/testprog/lockosthread.go +++ b/libgo/go/runtime/testdata/testprog/lockosthread.go @@ -24,6 +24,12 @@ func init() { runtime.LockOSThread() }) register("LockOSThreadAlt", LockOSThreadAlt) + + registerInit("LockOSThreadAvoidsStatePropagation", func() { + // Lock the OS thread now so main runs on the main thread. + runtime.LockOSThread() + }) + register("LockOSThreadAvoidsStatePropagation", LockOSThreadAvoidsStatePropagation) } func LockOSThreadMain() { @@ -92,3 +98,100 @@ func LockOSThreadAlt() { ok: println("OK") } + +func LockOSThreadAvoidsStatePropagation() { + // This test is similar to LockOSThreadAlt in that it will detect if a thread + // which should have died is still running. However, rather than do this with + // thread IDs, it does this by unsharing state on that thread. This way, it + // also detects whether new threads were cloned from the dead thread, and not + // from a clean thread. Cloning from a locked thread is undesirable since + // cloned threads will inherit potentially unwanted OS state. + // + // unshareFs, getcwd, and chdir("/tmp") are only guaranteed to work on + // Linux, so on other platforms this just checks that the runtime doesn't + // do anything terrible. + // + // This is running locked to the main OS thread. + + // GOMAXPROCS=1 makes this fail much more reliably if a tainted thread is + // cloned from. + if runtime.GOMAXPROCS(-1) != 1 { + println("requires GOMAXPROCS=1") + os.Exit(1) + } + + if err := chdir("/"); err != nil { + println("failed to chdir:", err.Error()) + os.Exit(1) + } + // On systems other than Linux, cwd == "". + cwd, err := getcwd() + if err != nil { + println("failed to get cwd:", err.Error()) + os.Exit(1) + } + if cwd != "" && cwd != "/" { + println("unexpected cwd", cwd, " wanted /") + os.Exit(1) + } + + ready := make(chan bool, 1) + go func() { + // This goroutine must be running on a new thread. + runtime.LockOSThread() + + // Unshare details about the FS, like the CWD, with + // the rest of the process on this thread. + // On systems other than Linux, this is a no-op. + if err := unshareFs(); err != nil { + if err == errNotPermitted { + println("unshare not permitted") + os.Exit(0) + } + println("failed to unshare fs:", err.Error()) + os.Exit(1) + } + // Chdir to somewhere else on this thread. + // On systems other than Linux, this is a no-op. + if err := chdir("/tmp"); err != nil { + println("failed to chdir:", err.Error()) + os.Exit(1) + } + + // The state on this thread is now considered "tainted", but it + // should no longer be observable in any other context. + + ready <- true + // Exit with the thread locked. + }() + <-ready + + // Spawn yet another goroutine and lock it. Since GOMAXPROCS=1, if + // for some reason state from the (hopefully dead) locked thread above + // propagated into a newly created thread (via clone), or that thread + // is actually being re-used, then we should get scheduled on such a + // thread with high likelihood. + done := make(chan bool) + go func() { + runtime.LockOSThread() + + // Get the CWD and check if this is the same as the main thread's + // CWD. Every thread should share the same CWD. + // On systems other than Linux, wd == "". + wd, err := getcwd() + if err != nil { + println("failed to get cwd:", err.Error()) + os.Exit(1) + } + if wd != cwd { + println("bad state from old thread propagated after it should have died") + os.Exit(1) + } + <-done + + runtime.UnlockOSThread() + }() + done <- true + runtime.UnlockOSThread() + println("OK") +} diff --git a/libgo/go/cmd/vet/testdata/cgo/cgo3.go b/libgo/go/runtime/testdata/testprog/syscalls.go similarity index 55% rename from libgo/go/cmd/vet/testdata/cgo/cgo3.go rename to libgo/go/runtime/testdata/testprog/syscalls.go index 0b1518e1f93..098d5cadf8a 100644 --- a/libgo/go/cmd/vet/testdata/cgo/cgo3.go +++ b/libgo/go/runtime/testdata/testprog/syscalls.go @@ -2,12 +2,10 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Used by TestVetVerbose to test that vet -v doesn't fail because it -// can't find "C". +package main -package testdata +import ( + "errors" +) -import "C" - -func F() { -} +var errNotPermitted = errors.New("operation not permitted") diff --git a/libgo/go/runtime/testdata/testprog/syscalls_linux.go b/libgo/go/runtime/testdata/testprog/syscalls_linux.go new file mode 100644 index 00000000000..b8ac0876269 --- /dev/null +++ b/libgo/go/runtime/testdata/testprog/syscalls_linux.go @@ -0,0 +1,59 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "bytes" + "fmt" + "io/ioutil" + "os" + "syscall" +) + +func gettid() int { + return syscall.Gettid() +} + +func tidExists(tid int) (exists, supported bool) { + stat, err := ioutil.ReadFile(fmt.Sprintf("/proc/self/task/%d/stat", tid)) + if os.IsNotExist(err) { + return false, true + } + // Check if it's a zombie thread. + state := bytes.Fields(stat)[2] + return !(len(state) == 1 && state[0] == 'Z'), true +} + +func getcwd() (string, error) { + if !syscall.ImplementsGetwd { + return "", nil + } + // Use the syscall to get the current working directory. + // This is imperative for checking for OS thread state + // after an unshare since os.Getwd might just check the + // environment, or use some other mechanism. + var buf [4096]byte + n, err := syscall.Getcwd(buf[:]) + if err != nil { + return "", err + } + // Subtract one for null terminator. + return string(buf[:n-1]), nil +} + +func unshareFs() error { + err := syscall.Unshare(syscall.CLONE_FS) + if err != nil { + errno, ok := err.(syscall.Errno) + if ok && errno == syscall.EPERM { + return errNotPermitted + } + } + return err +} + +func chdir(path string) error { + return syscall.Chdir(path) +} diff --git a/libgo/go/runtime/testdata/testprog/gettid_none.go b/libgo/go/runtime/testdata/testprog/syscalls_none.go similarity index 68% rename from libgo/go/runtime/testdata/testprog/gettid_none.go rename to libgo/go/runtime/testdata/testprog/syscalls_none.go index 036db87e10e..7f8ded3994f 100644 --- a/libgo/go/runtime/testdata/testprog/gettid_none.go +++ b/libgo/go/runtime/testdata/testprog/syscalls_none.go @@ -13,3 +13,15 @@ func gettid() int { func tidExists(tid int) (exists, supported bool) { return false, false } + +func getcwd() (string, error) { + return "", nil +} + +func unshareFs() error { + return nil +} + +func chdir(path string) error { + return nil +} diff --git a/libgo/go/runtime/testdata/testprog/traceback_ancestors.go b/libgo/go/runtime/testdata/testprog/traceback_ancestors.go index fe57c1c157e..0ee402c4bdc 100644 --- a/libgo/go/runtime/testdata/testprog/traceback_ancestors.go +++ b/libgo/go/runtime/testdata/testprog/traceback_ancestors.go @@ -5,8 +5,10 @@ package main import ( + "bytes" "fmt" "runtime" + "strings" ) func init() { @@ -18,25 +20,50 @@ const numFrames = 2 func TracebackAncestors() { w := make(chan struct{}) - recurseThenCallGo(w, numGoroutines, numFrames) + recurseThenCallGo(w, numGoroutines, numFrames, true) <-w printStack() close(w) } +var ignoreGoroutines = make(map[string]bool) + func printStack() { buf := make([]byte, 1024) for { n := runtime.Stack(buf, true) if n < len(buf) { - fmt.Print(string(buf[:n])) + tb := string(buf[:n]) + + // Delete any ignored goroutines, if present. + pos := 0 + for pos < len(tb) { + next := pos + strings.Index(tb[pos:], "\n\n") + if next < pos { + next = len(tb) + } else { + next += len("\n\n") + } + + if strings.HasPrefix(tb[pos:], "goroutine ") { + id := tb[pos+len("goroutine "):] + id = id[:strings.IndexByte(id, ' ')] + if ignoreGoroutines[id] { + tb = tb[:pos] + tb[next:] + next = pos + } + } + pos = next + } + + fmt.Print(tb) return } buf = make([]byte, 2*len(buf)) } } -func recurseThenCallGo(w chan struct{}, frames int, goroutines int) { +func recurseThenCallGo(w chan struct{}, frames int, goroutines int, main bool) { if frames == 0 { // Signal to TracebackAncestors that we are done recursing and starting goroutines. w <- struct{}{} @@ -44,10 +71,29 @@ func recurseThenCallGo(w chan struct{}, frames int, goroutines int) { return } if goroutines == 0 { + // Record which goroutine this is so we can ignore it + // in the traceback if it hasn't finished exiting by + // the time we printStack. + if !main { + ignoreGoroutines[goroutineID()] = true + } + // Start the next goroutine now that there are no more recursions left // for this current goroutine. - go recurseThenCallGo(w, frames-1, numFrames) + go recurseThenCallGo(w, frames-1, numFrames, false) return } - recurseThenCallGo(w, frames, goroutines-1) + recurseThenCallGo(w, frames, goroutines-1, main) +} + +func goroutineID() string { + buf := make([]byte, 128) + runtime.Stack(buf, false) + const prefix = "goroutine " + if !bytes.HasPrefix(buf, []byte(prefix)) { + panic(fmt.Sprintf("expected %q at beginning of traceback:\n%s", prefix, buf)) + } + buf = buf[len(prefix):] + n := bytes.IndexByte(buf, ' ') + return string(buf[:n]) } diff --git a/libgo/go/runtime/testdata/testprogcgo/exec.go b/libgo/go/runtime/testdata/testprogcgo/exec.go index 2e948401c87..94da5dc526b 100644 --- a/libgo/go/runtime/testdata/testprogcgo/exec.go +++ b/libgo/go/runtime/testdata/testprogcgo/exec.go @@ -75,6 +75,14 @@ func CgoExecSignalMask() { cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { + // An overloaded system + // may fail with EAGAIN. + // This doesn't tell us + // anything useful; ignore it. + // Issue #27731. + if isEAGAIN(err) { + return + } fmt.Printf("iteration %d: %v\n", j, err) os.Exit(1) } @@ -87,3 +95,11 @@ func CgoExecSignalMask() { fmt.Println("OK") } + +// isEAGAIN reports whether err is an EAGAIN error from a process execution. +func isEAGAIN(err error) bool { + if p, ok := err.(*os.PathError); ok { + err = p.Err + } + return err == syscall.EAGAIN +} diff --git a/libgo/go/runtime/testdata/testprogcgo/pprof.go b/libgo/go/runtime/testdata/testprogcgo/pprof.go index c4fde0251ae..9fa5c1b518a 100644 --- a/libgo/go/runtime/testdata/testprogcgo/pprof.go +++ b/libgo/go/runtime/testdata/testprogcgo/pprof.go @@ -28,6 +28,9 @@ void cpuHog() { salt2 = foo; } +void cpuHog2() { +} + static int cpuHogCount; struct cgoTracebackArg { @@ -39,10 +42,13 @@ struct cgoTracebackArg { // pprofCgoTraceback is passed to runtime.SetCgoTraceback. // For testing purposes it pretends that all CPU hits in C code are in cpuHog. +// Issue #29034: At least 2 frames are required to verify all frames are captured +// since runtime/pprof ignores the runtime.goexit base frame if it exists. void pprofCgoTraceback(void* parg) { struct cgoTracebackArg* arg = (struct cgoTracebackArg*)(parg); arg->buf[0] = (uintptr_t)(cpuHog) + 0x10; - arg->buf[1] = 0; + arg->buf[1] = (uintptr_t)(cpuHog2) + 0x4; + arg->buf[2] = 0; ++cpuHogCount; } diff --git a/libgo/go/runtime/testdata/testprogcgo/threadpprof.go b/libgo/go/runtime/testdata/testprogcgo/threadpprof.go index bec4ef50d76..f803511c526 100644 --- a/libgo/go/runtime/testdata/testprogcgo/threadpprof.go +++ b/libgo/go/runtime/testdata/testprogcgo/threadpprof.go @@ -31,6 +31,9 @@ void cpuHogThread() { threadSalt2 = foo; } +void cpuHogThread2() { +} + static int cpuHogThreadCount; struct cgoTracebackArg { @@ -45,7 +48,8 @@ struct cgoTracebackArg { void pprofCgoThreadTraceback(void* parg) { struct cgoTracebackArg* arg = (struct cgoTracebackArg*)(parg); arg->buf[0] = (uintptr_t)(cpuHogThread) + 0x10; - arg->buf[1] = 0; + arg->buf[1] = (uintptr_t)(cpuHogThread2) + 0x4; + arg->buf[2] = 0; __sync_add_and_fetch(&cpuHogThreadCount, 1); } diff --git a/libgo/go/runtime/time.go b/libgo/go/runtime/time.go index ea61baa9195..71e7556776e 100644 --- a/libgo/go/runtime/time.go +++ b/libgo/go/runtime/time.go @@ -7,7 +7,7 @@ package runtime import ( - "runtime/internal/sys" + "internal/cpu" "unsafe" ) @@ -50,7 +50,7 @@ var timers [timersLen]struct { // The padding should eliminate false sharing // between timersBucket values. - pad [sys.CacheLineSize - unsafe.Sizeof(timersBucket{})%sys.CacheLineSize]byte + pad [cpu.CacheLinePadSize - unsafe.Sizeof(timersBucket{})%cpu.CacheLinePadSize]byte } func (t *timer) assignBucket() *timersBucket { @@ -156,7 +156,7 @@ func (tb *timersBucket) addtimerLocked(t *timer) bool { } if t.i == 0 { // siftup moved to top: new earliest deadline. - if tb.sleeping { + if tb.sleeping && tb.sleepUntil > t.when { tb.sleeping = false notewakeup(&tb.waitnote) } @@ -164,11 +164,11 @@ func (tb *timersBucket) addtimerLocked(t *timer) bool { tb.rescheduling = false goready(tb.gp, 0) } - } - if !tb.created { - tb.created = true - expectSystemGoroutine() - go timerproc(tb) + if !tb.created { + tb.created = true + expectSystemGoroutine() + go timerproc(tb) + } } return true } @@ -188,14 +188,22 @@ func deltimer(t *timer) bool { tb := t.tb lock(&tb.lock) + removed, ok := tb.deltimerLocked(t) + unlock(&tb.lock) + if !ok { + badTimer() + } + return removed +} + +func (tb *timersBucket) deltimerLocked(t *timer) (removed, ok bool) { // t may not be registered anymore and may have // a bogus i (typically 0, if generated by Go). // Verify it before proceeding. i := t.i last := len(tb.t) - 1 if i < 0 || i > last || tb.t[i] != t { - unlock(&tb.lock) - return false + return false, true } if i != last { tb.t[i] = tb.t[last] @@ -203,7 +211,7 @@ func deltimer(t *timer) bool { } tb.t[last] = nil tb.t = tb.t[:last] - ok := true + ok = true if i != last { if !siftupTimer(tb.t, i) { ok = false @@ -212,11 +220,26 @@ func deltimer(t *timer) bool { ok = false } } + return true, ok +} + +func modtimer(t *timer, when, period int64, f func(interface{}, uintptr), arg interface{}, seq uintptr) { + tb := t.tb + + lock(&tb.lock) + _, ok := tb.deltimerLocked(t) + if ok { + t.when = when + t.period = period + t.f = f + t.arg = arg + t.seq = seq + ok = tb.addtimerLocked(t) + } unlock(&tb.lock) if !ok { badTimer() } - return true } // Timerproc runs the time-driven events. @@ -438,23 +461,3 @@ func siftdownTimer(t []*timer, i int) bool { func badTimer() { panic(errorString("racy use of timers")) } - -// Entry points for net, time to call nanotime. - -//go:linkname poll_runtimeNano internal..z2fpoll.runtimeNano -func poll_runtimeNano() int64 { - return nanotime() -} - -//go:linkname time_runtimeNano time.runtimeNano -func time_runtimeNano() int64 { - return nanotime() -} - -// Monotonic times are reported as offsets from startNano. -// We initialize startNano to nanotime() - 1 so that on systems where -// monotonic time resolution is fairly low (e.g. Windows 2008 -// which appears to have a default resolution of 15ms), -// we avoid ever reporting a nanotime of 0. -// (Callers may want to use 0 as "time not set".) -var startNano int64 = nanotime() - 1 diff --git a/libgo/go/runtime/timeasm.go b/libgo/go/runtime/timeasm.go index 55b0d0729fb..6bfaa8a8f0e 100644 --- a/libgo/go/runtime/timeasm.go +++ b/libgo/go/runtime/timeasm.go @@ -3,8 +3,6 @@ // license that can be found in the LICENSE file. // Declarations for operating systems implementing time.now directly in assembly. -// Those systems are also expected to have nanotime subtract startNano, -// so that time.now and nanotime return the same monotonic clock readings. // +build ignore // +build windows diff --git a/libgo/go/runtime/timestub.go b/libgo/go/runtime/timestub.go index 9f1d111f4fd..14165cee974 100644 --- a/libgo/go/runtime/timestub.go +++ b/libgo/go/runtime/timestub.go @@ -14,5 +14,5 @@ import _ "unsafe" // for go:linkname //go:linkname time_now time.now func time_now() (sec int64, nsec int32, mono int64) { sec, nsec = walltime() - return sec, nsec, nanotime() - startNano + return sec, nsec, nanotime() } diff --git a/libgo/go/runtime/timestub2.go b/libgo/go/runtime/timestub2.go index 9ddc6fed918..00c2c55f461 100644 --- a/libgo/go/runtime/timestub2.go +++ b/libgo/go/runtime/timestub2.go @@ -5,6 +5,7 @@ // +build !darwin // +build !windows // +build !freebsd +// +build !aix package runtime diff --git a/libgo/go/runtime/trace.go b/libgo/go/runtime/trace.go index 530d5e4c86e..6db5b62558e 100644 --- a/libgo/go/runtime/trace.go +++ b/libgo/go/runtime/trace.go @@ -533,12 +533,12 @@ func traceEvent(ev byte, skip int, args ...uint64) { } func traceEventLocked(extraBytes int, mp *m, pid int32, bufp *traceBufPtr, ev byte, skip int, args ...uint64) { - buf := (*bufp).ptr() + buf := bufp.ptr() // TODO: test on non-zero extraBytes param. maxSize := 2 + 5*traceBytesPerNumber + extraBytes // event type, length, sequence, timestamp, stack id and two add params if buf == nil || len(buf.arr)-buf.pos < maxSize { buf = traceFlush(traceBufPtrOf(buf), pid).ptr() - (*bufp).set(buf) + bufp.set(buf) } ticks := uint64(cputicks()) / traceTickDiv @@ -585,7 +585,7 @@ func traceStackID(mp *m, buf []location, skip int) uint64 { gp := mp.curg var nstk int if gp == _g_ { - nstk = callers(skip+1, buf[:]) + nstk = callers(skip+1, buf) } else if gp != nil { // FIXME: get stack trace of different goroutine. } @@ -689,11 +689,11 @@ func traceString(bufp *traceBufPtr, pid int32, s string) (uint64, *traceBufPtr) // so there must be no memory allocation or any activities // that causes tracing after this point. - buf := (*bufp).ptr() + buf := bufp.ptr() size := 1 + 2*traceBytesPerNumber + len(s) if buf == nil || len(buf.arr)-buf.pos < size { buf = traceFlush(traceBufPtrOf(buf), pid).ptr() - (*bufp).set(buf) + bufp.set(buf) } buf.byte(traceEvString) buf.varint(id) @@ -708,7 +708,7 @@ func traceString(bufp *traceBufPtr, pid int32, s string) (uint64, *traceBufPtr) buf.varint(uint64(slen)) buf.pos += copy(buf.arr[buf.pos:], s[:slen]) - (*bufp).set(buf) + bufp.set(buf) return id, bufp } @@ -1201,7 +1201,7 @@ func trace_userLog(id uint64, category, message string) { traceEventLocked(extraSpace, mp, pid, bufp, traceEvUserLog, 3, id, categoryID) // traceEventLocked reserved extra space for val and len(val) // in buf, so buf now has room for the following. - buf := (*bufp).ptr() + buf := bufp.ptr() // double-check the message and its length can fit. // Otherwise, truncate the message. diff --git a/libgo/go/runtime/trace/annotation.go b/libgo/go/runtime/trace/annotation.go index d5a7d003fe2..82cb232dba9 100644 --- a/libgo/go/runtime/trace/annotation.go +++ b/libgo/go/runtime/trace/annotation.go @@ -171,7 +171,7 @@ func (r *Region) End() { userRegion(r.id, regionEndCode, r.regionType) } -// IsEnabled returns whether tracing is enabled. +// IsEnabled reports whether tracing is enabled. // The information is advisory only. The tracing status // may have changed by the time this function returns. func IsEnabled() bool { diff --git a/libgo/go/runtime/traceback_gccgo.go b/libgo/go/runtime/traceback_gccgo.go index 72a83a5ab2d..7581798e852 100644 --- a/libgo/go/runtime/traceback_gccgo.go +++ b/libgo/go/runtime/traceback_gccgo.go @@ -21,16 +21,20 @@ func printcreatedby(gp *g) { tracepc -= sys.PCQuantum } function, file, line := funcfileline(tracepc, -1) - if function != "" && showframe(function, gp) && gp.goid != 1 { - print("created by ", function, "\n") - print("\t", file, ":", line) - if entry != 0 && pc > entry { - print(" +", hex(pc-entry)) - } - print("\n") + if function != "" && showframe(function, gp, false) && gp.goid != 1 { + printcreatedby1(function, file, line, entry, pc) } } +func printcreatedby1(function, file string, line int, entry, pc uintptr) { + print("created by ", function, "\n") + print("\t", file, ":", line) + if entry != 0 && pc > entry { + print(" +", hex(pc-entry)) + } + print("\n") +} + // tracebackg is used to collect stack traces from other goroutines. type tracebackg struct { gp *g @@ -63,50 +67,108 @@ func callers(skip int, locbuf []location) int { func traceback(skip int32) { var locbuf [100]location c := c_callers(skip+1, &locbuf[0], int32(len(locbuf)), false) - printtrace(locbuf[:c], getg()) - printcreatedby(getg()) + gp := getg() + printtrace(locbuf[:c], gp) + printcreatedby(gp) + + if gp.ancestors == nil { + return + } + for _, ancestor := range *gp.ancestors { + printAncestorTraceback(ancestor) + } +} + +// printAncestorTraceback prints the traceback of the given ancestor. +func printAncestorTraceback(ancestor ancestorInfo) { + print("[originating from goroutine ", ancestor.goid, "]:\n") + for fidx, pc := range ancestor.pcs { + function, file, line := funcfileline(pc, -1) + if showfuncinfo(function, fidx == 0) { + printAncestorTracebackFuncInfo(function, file, line, pc) + } + } + if len(ancestor.pcs) == _TracebackMaxFrames { + print("...additional frames elided...\n") + } + // Show what created goroutine, except main goroutine (goid 1). + function, file, line := funcfileline(ancestor.gopc, -1) + if function != "" && showfuncinfo(function, false) && ancestor.goid != 1 { + printcreatedby1(function, file, line, funcentry(ancestor.gopc), ancestor.gopc) + } +} + +// printAncestorTraceback prints the given function info at a given pc +// within an ancestor traceback. The precision of this info is reduced +// due to only have access to the pcs at the time of the caller +// goroutine being created. +func printAncestorTracebackFuncInfo(name, file string, line int, pc uintptr) { + if name == "runtime.gopanic" { + name = "panic" + } + print(name, "(...)\n") + print("\t", file, ":", line) + entry := funcentry(pc) + if pc > entry { + print(" +", hex(pc-entry)) + } + print("\n") } // printtrace prints a traceback from locbuf. func printtrace(locbuf []location, gp *g) { + nprint := 0 for i := range locbuf { - if showframe(locbuf[i].function, gp) { + if showframe(locbuf[i].function, gp, nprint == 0) { name := locbuf[i].function if name == "runtime.gopanic" { name = "panic" } print(name, "\n\t", locbuf[i].filename, ":", locbuf[i].lineno, "\n") + nprint++ } } } // showframe returns whether to print a frame in a traceback. // name is the function name. -func showframe(name string, gp *g) bool { +func showframe(name string, gp *g, firstFrame bool) bool { g := getg() if g.m.throwing > 0 && gp != nil && (gp == g.m.curg || gp == g.m.caughtsig.ptr()) { return true } + return showfuncinfo(name, firstFrame) +} +func showfuncinfo(name string, firstFrame bool) bool { // Gccgo can trace back through C functions called via cgo. // We want to print those in the traceback. // But unless GOTRACEBACK > 1 (checked below), still skip // internal C functions and cgo-generated functions. - if name != "" && !contains(name, ".") && !hasprefix(name, "__go_") && !hasprefix(name, "_cgo_") { + if name != "" && !contains(name, ".") && !hasPrefix(name, "__go_") && !hasPrefix(name, "_cgo_") { return true } level, _, _ := gotraceback() + if level > 1 { + // Show all frames. + return true + } + + if name == "" { + return false + } - // Special case: always show runtime.gopanic frame, so that we can - // see where a panic started in the middle of a stack trace. + // Special case: always show runtime.gopanic frame + // in the middle of a stack trace, so that we can + // see the boundary between ordinary code and + // panic-induced deferred code. // See golang.org/issue/5832. - // __go_panic is the current gccgo name. - if name == "runtime.gopanic" || name == "__go_panic" { + if name == "runtime.gopanic" && !firstFrame { return true } - return level > 1 || contains(name, ".") && (!hasprefix(name, "runtime.") || isExportedRuntime(name)) + return contains(name, ".") && (!hasPrefix(name, "runtime.") || isExportedRuntime(name)) } // isExportedRuntime reports whether name is an exported runtime function. @@ -115,7 +177,7 @@ func showframe(name string, gp *g) bool { // "runtime..z2f". func isExportedRuntime(name string) bool { const n = len("runtime.") - if hasprefix(name, "runtime..z2f") { + if hasPrefix(name, "runtime..z2f") { return true } return len(name) > n && name[:n] == "runtime." && 'A' <= name[n] && name[n] <= 'Z' @@ -169,10 +231,24 @@ func goroutineheader(gp *g) { print("]:\n") } -// isSystemGoroutine reports whether the goroutine g must be omitted in -// stack dumps and deadlock detector. -func isSystemGoroutine(gp *g) bool { - return gp.isSystemGoroutine +// isSystemGoroutine reports whether the goroutine g must be omitted +// in stack dumps and deadlock detector. This is any goroutine that +// starts at a runtime.* entry point, except for runtime.main and +// sometimes runtime.runfinq. +// +// If fixed is true, any goroutine that can vary between user and +// system (that is, the finalizer goroutine) is considered a user +// goroutine. +func isSystemGoroutine(gp *g, fixed bool) bool { + if !gp.isSystemGoroutine { + return false + } + if fixed && gp.isFinalizerGoroutine { + // This goroutine can vary. In fixed mode, + // always consider it a user goroutine. + return false + } + return true } func tracebackothers(me *g) { @@ -200,7 +276,7 @@ func tracebackothers(me *g) { lock(&allglock) for _, gp := range allgs { - if gp == me || gp == g.m.curg || readgstatus(gp) == _Gdead || isSystemGoroutine(gp) && level < 2 { + if gp == me || gp == g.m.curg || readgstatus(gp) == _Gdead || isSystemGoroutine(gp, false) && level < 2 { continue } print("\n") diff --git a/libgo/go/strconv/atoi.go b/libgo/go/strconv/atoi.go index bebed048204..ff33d555e49 100644 --- a/libgo/go/strconv/atoi.go +++ b/libgo/go/strconv/atoi.go @@ -44,7 +44,7 @@ const intSize = 32 << (^uint(0) >> 63) // IntSize is the size in bits of an int or uint value. const IntSize = intSize -const maxUint64 = (1<<64 - 1) +const maxUint64 = 1<<64 - 1 // ParseUint is like ParseInt but for unsigned numbers. func ParseUint(s string, base int, bitSize int) (uint64, error) { @@ -198,7 +198,7 @@ func ParseInt(s string, base int, bitSize int) (i int64, err error) { return n, nil } -// Atoi returns the result of ParseInt(s, 10, 0) converted to type int. +// Atoi is equivalent to ParseInt(s, 10, 0), converted to type int. func Atoi(s string) (int, error) { const fnAtoi = "Atoi" diff --git a/libgo/go/strconv/doc.go b/libgo/go/strconv/doc.go index cba898426af..8db725f96ae 100644 --- a/libgo/go/strconv/doc.go +++ b/libgo/go/strconv/doc.go @@ -46,8 +46,8 @@ // The latter guarantees that the result is an ASCII string, by escaping // any non-ASCII Unicode with \u: // -// q := Quote("Hello, 世界") -// q := QuoteToASCII("Hello, 世界") +// q := strconv.Quote("Hello, 世界") +// q := strconv.QuoteToASCII("Hello, 世界") // // QuoteRune and QuoteRuneToASCII are similar but accept runes and // return quoted Go rune literals. diff --git a/libgo/go/strconv/example_test.go b/libgo/go/strconv/example_test.go index 5c2e8a9b560..2d1a2a9dbfd 100644 --- a/libgo/go/strconv/example_test.go +++ b/libgo/go/strconv/example_test.go @@ -167,6 +167,22 @@ func ExampleFormatUint() { // string, 2a } +func ExampleIsGraphic() { + shamrock := strconv.IsGraphic('☘') + fmt.Println(shamrock) + + a := strconv.IsGraphic('a') + fmt.Println(a) + + bel := strconv.IsGraphic('\007') + fmt.Println(bel) + + // Output: + // true + // true + // false +} + func ExampleIsPrint() { c := strconv.IsPrint('\u263a') fmt.Println(c) @@ -249,7 +265,7 @@ func ExampleParseUint() { } func ExampleQuote() { - s := strconv.Quote(`"Fran & Freddie's Diner ☺"`) + s := strconv.Quote(`"Fran & Freddie's Diner ☺"`) // there is a tab character inside the string literal fmt.Println(s) // Output: @@ -272,14 +288,50 @@ func ExampleQuoteRuneToASCII() { // '\u263a' } +func ExampleQuoteRuneToGraphic() { + s := strconv.QuoteRuneToGraphic('☺') + fmt.Println(s) + + s = strconv.QuoteRuneToGraphic('\u263a') + fmt.Println(s) + + s = strconv.QuoteRuneToGraphic('\u000a') + fmt.Println(s) + + s = strconv.QuoteRuneToGraphic(' ') // tab character + fmt.Println(s) + + // Output: + // '☺' + // '☺' + // '\n' + // '\t' +} + func ExampleQuoteToASCII() { - s := strconv.QuoteToASCII(`"Fran & Freddie's Diner ☺"`) + s := strconv.QuoteToASCII(`"Fran & Freddie's Diner ☺"`) // there is a tab character inside the string literal fmt.Println(s) // Output: // "\"Fran & Freddie's Diner\t\u263a\"" } +func ExampleQuoteToGraphic() { + s := strconv.QuoteToGraphic("☺") + fmt.Println(s) + + s = strconv.QuoteToGraphic("This is a \u263a \u000a") // there is a tab character inside the string literal + fmt.Println(s) + + s = strconv.QuoteToGraphic(`" This is a ☺ \n "`) + fmt.Println(s) + + // Output: + // "☺" + // "This is a ☺\t\n" + // "\" This is a ☺ \\n \"" +} + func ExampleUnquote() { s, err := strconv.Unquote("You can't unquote a string without quotes") fmt.Printf("%q, %v\n", s, err) diff --git a/libgo/go/strconv/itoa.go b/libgo/go/strconv/itoa.go index 8afe7af2517..45e4192c82e 100644 --- a/libgo/go/strconv/itoa.go +++ b/libgo/go/strconv/itoa.go @@ -30,7 +30,7 @@ func FormatInt(i int64, base int) string { return s } -// Itoa is shorthand for FormatInt(int64(i), 10). +// Itoa is equivalent to FormatInt(int64(i), 10). func Itoa(i int) string { return FormatInt(int64(i), 10) } @@ -152,10 +152,14 @@ func formatBits(dst []byte, u uint64, base int, neg, append_ bool) (d []byte, s } } else if isPowerOfTwo(base) { - // It is known that base is a power of two and - // 2 <= base <= len(digits). // Use shifts and masks instead of / and %. - shift := uint(bits.TrailingZeros(uint(base))) & 31 + // Base is a power of 2 and 2 <= base <= len(digits) where len(digits) is 36. + // The largest power of 2 below or equal to 36 is 32, which is 1 << 5; + // i.e., the largest possible shift count is 5. By &-ind that value with + // the constant 7 we tell the compiler that the shift count is always + // less than 8 which is smaller than any register width. This allows + // the compiler to generate better code for the shift operation. + shift := uint(bits.TrailingZeros(uint(base))) & 7 b := uint64(base) m := uint(base) - 1 // == 1<= b { diff --git a/libgo/go/strconv/quote.go b/libgo/go/strconv/quote.go index 9b7194a0f04..6cd2f93068c 100644 --- a/libgo/go/strconv/quote.go +++ b/libgo/go/strconv/quote.go @@ -6,7 +6,10 @@ package strconv -import "unicode/utf8" +import ( + "internal/bytealg" + "unicode/utf8" +) const lowerhex = "0123456789abcdef" @@ -424,12 +427,7 @@ func Unquote(s string) (string, error) { // contains reports whether the string contains the byte c. func contains(s string, c byte) bool { - for i := 0; i < len(s); i++ { - if s[i] == c { - return true - } - } - return false + return bytealg.IndexByteString(s, c) != -1 } // bsearch16 returns the smallest i such that a[i] >= x. diff --git a/libgo/go/strings/builder.go b/libgo/go/strings/builder.go index ac58f34e1de..3f33a875087 100644 --- a/libgo/go/strings/builder.go +++ b/libgo/go/strings/builder.go @@ -50,6 +50,11 @@ func (b *Builder) String() string { // Len returns the number of accumulated bytes; b.Len() == len(b.String()). func (b *Builder) Len() int { return len(b.buf) } +// Cap returns the capacity of the builder's underlying byte slice. It is the +// total space allocated for the string being built and includes any bytes +// already written. +func (b *Builder) Cap() int { return cap(b.buf) } + // Reset resets the Builder to be empty. func (b *Builder) Reset() { b.addr = nil diff --git a/libgo/go/strings/builder_test.go b/libgo/go/strings/builder_test.go index da6c021001a..63130d2b674 100644 --- a/libgo/go/strings/builder_test.go +++ b/libgo/go/strings/builder_test.go @@ -21,6 +21,9 @@ func check(t *testing.T, b *Builder, want string) { if n := b.Len(); n != len(got) { t.Errorf("Len: got %d; but len(String()) is %d", n, len(got)) } + if n := b.Cap(); n < len(got) { + t.Errorf("Cap: got %d; but len(String()) is %d", n, len(got)) + } } func TestBuilder(t *testing.T) { @@ -93,6 +96,9 @@ func TestBuilderGrow(t *testing.T) { allocs := testing.AllocsPerRun(100, func() { var b Builder b.Grow(growLen) // should be only alloc, when growLen > 0 + if b.Cap() < growLen { + t.Fatalf("growLen=%d: Cap() is lower than growLen", growLen) + } b.Write(p) if b.String() != string(p) { t.Fatalf("growLen=%d: bad data written after Grow", growLen) @@ -233,6 +239,16 @@ func TestBuilderCopyPanic(t *testing.T) { b.Len() }, }, + { + name: "Cap", + wantPanic: false, + fn: func() { + var a Builder + a.WriteByte('x') + b := a + b.Cap() + }, + }, { name: "Reset", wantPanic: false, diff --git a/libgo/go/strings/compare_test.go b/libgo/go/strings/compare_test.go index 5d5334461c3..94554e0af79 100644 --- a/libgo/go/strings/compare_test.go +++ b/libgo/go/strings/compare_test.go @@ -11,6 +11,7 @@ import ( "internal/testenv" . "strings" "testing" + "unsafe" ) var compareTests = []struct { @@ -53,6 +54,12 @@ func TestCompareIdenticalString(t *testing.T) { } func TestCompareStrings(t *testing.T) { + // unsafeString converts a []byte to a string with no allocation. + // The caller must not modify b while the result string is in use. + unsafeString := func(b []byte) string { + return *(*string)(unsafe.Pointer(&b)) + } + lengths := make([]int, 0) // lengths to test in ascending order for i := 0; i <= 128; i++ { lengths = append(lengths, i) @@ -79,7 +86,7 @@ func TestCompareStrings(t *testing.T) { b[i] = 9 } - sa, sb := string(a), string(b) + sa, sb := unsafeString(a), unsafeString(b) cmp := Compare(sa[:len], sb[:len]) if cmp != 0 { t.Errorf(`CompareIdentical(%d) = %d`, len, cmp) @@ -96,12 +103,12 @@ func TestCompareStrings(t *testing.T) { } for k := lastLen; k < len; k++ { b[k] = a[k] - 1 - cmp = Compare(string(a[:len]), string(b[:len])) + cmp = Compare(unsafeString(a[:len]), unsafeString(b[:len])) if cmp != 1 { t.Errorf(`CompareAbigger(%d,%d) = %d`, len, k, cmp) } b[k] = a[k] + 1 - cmp = Compare(string(a[:len]), string(b[:len])) + cmp = Compare(unsafeString(a[:len]), unsafeString(b[:len])) if cmp != -1 { t.Errorf(`CompareBbigger(%d,%d) = %d`, len, k, cmp) } diff --git a/libgo/go/strings/example_test.go b/libgo/go/strings/example_test.go index 607e4a0a70e..e31054a4e0b 100644 --- a/libgo/go/strings/example_test.go +++ b/libgo/go/strings/example_test.go @@ -205,6 +205,12 @@ func ExampleReplace() { // moo moo moo } +func ExampleReplaceAll() { + fmt.Println(strings.ReplaceAll("oink oink oink", "oink", "moo")) + // Output: + // moo moo moo +} + func ExampleSplit() { fmt.Printf("%q\n", strings.Split("a,b,c", ",")) fmt.Printf("%q\n", strings.Split("a man a plan a canal panama", "a ")) diff --git a/libgo/go/strings/export_test.go b/libgo/go/strings/export_test.go index 17c806aa563..b39cee6b1de 100644 --- a/libgo/go/strings/export_test.go +++ b/libgo/go/strings/export_test.go @@ -5,10 +5,12 @@ package strings func (r *Replacer) Replacer() interface{} { + r.once.Do(r.buildOnce) return r.r } func (r *Replacer) PrintTrie() string { + r.once.Do(r.buildOnce) gen := r.r.(*genericReplacer) return gen.printNode(&gen.root, 0) } diff --git a/libgo/go/strings/indexbyte.c b/libgo/go/strings/indexbyte.c deleted file mode 100644 index 27f4240b44c..00000000000 --- a/libgo/go/strings/indexbyte.c +++ /dev/null @@ -1,29 +0,0 @@ -/* indexbyte.c -- implement strings.IndexByte for Go. - - Copyright 2013 The Go Authors. All rights reserved. - Use of this source code is governed by a BSD-style - license that can be found in the LICENSE file. */ - -#include - -#include "runtime.h" -#include "go-string.h" - -/* This is in C so that the compiler can optimize it appropriately. - We deliberately don't split the stack in case it does call the - library function, which shouldn't need much stack space. */ - -intgo IndexByte (String, char) - __asm__ (GOSYM_PREFIX "strings.IndexByte") - __attribute__ ((no_split_stack)); - -intgo -IndexByte (String s, char b) -{ - const char *p; - - p = __builtin_memchr ((const char *) s.str, b, s.len); - if (p == NULL) - return -1; - return p - (const char *) s.str; -} diff --git a/libgo/go/strings/reader.go b/libgo/go/strings/reader.go index 6c1a5064c0d..eb2fa1164c0 100644 --- a/libgo/go/strings/reader.go +++ b/libgo/go/strings/reader.go @@ -13,6 +13,7 @@ import ( // A Reader implements the io.Reader, io.ReaderAt, io.Seeker, io.WriterTo, // io.ByteScanner, and io.RuneScanner interfaces by reading // from a string. +// The zero value for Reader operates like a Reader of an empty string. type Reader struct { s string i int64 // current reading index @@ -70,10 +71,10 @@ func (r *Reader) ReadByte() (byte, error) { } func (r *Reader) UnreadByte() error { - r.prevRune = -1 if r.i <= 0 { return errors.New("strings.Reader.UnreadByte: at beginning of string") } + r.prevRune = -1 r.i-- return nil } @@ -94,6 +95,9 @@ func (r *Reader) ReadRune() (ch rune, size int, err error) { } func (r *Reader) UnreadRune() error { + if r.i <= 0 { + return errors.New("strings.Reader.UnreadRune: at beginning of string") + } if r.prevRune < 0 { return errors.New("strings.Reader.UnreadRune: previous operation was not ReadRune") } diff --git a/libgo/go/strings/reader_test.go b/libgo/go/strings/reader_test.go index bf40eb1a31e..a4c211d699f 100644 --- a/libgo/go/strings/reader_test.go +++ b/libgo/go/strings/reader_test.go @@ -190,3 +190,45 @@ func TestReaderReset(t *testing.T) { t.Errorf("ReadAll: got %q, want %q", got, want) } } + +func TestReaderZero(t *testing.T) { + if l := (&strings.Reader{}).Len(); l != 0 { + t.Errorf("Len: got %d, want 0", l) + } + + if n, err := (&strings.Reader{}).Read(nil); n != 0 || err != io.EOF { + t.Errorf("Read: got %d, %v; want 0, io.EOF", n, err) + } + + if n, err := (&strings.Reader{}).ReadAt(nil, 11); n != 0 || err != io.EOF { + t.Errorf("ReadAt: got %d, %v; want 0, io.EOF", n, err) + } + + if b, err := (&strings.Reader{}).ReadByte(); b != 0 || err != io.EOF { + t.Errorf("ReadByte: got %d, %v; want 0, io.EOF", b, err) + } + + if ch, size, err := (&strings.Reader{}).ReadRune(); ch != 0 || size != 0 || err != io.EOF { + t.Errorf("ReadRune: got %d, %d, %v; want 0, 0, io.EOF", ch, size, err) + } + + if offset, err := (&strings.Reader{}).Seek(11, io.SeekStart); offset != 11 || err != nil { + t.Errorf("Seek: got %d, %v; want 11, nil", offset, err) + } + + if s := (&strings.Reader{}).Size(); s != 0 { + t.Errorf("Size: got %d, want 0", s) + } + + if (&strings.Reader{}).UnreadByte() == nil { + t.Errorf("UnreadByte: got nil, want error") + } + + if (&strings.Reader{}).UnreadRune() == nil { + t.Errorf("UnreadRune: got nil, want error") + } + + if n, err := (&strings.Reader{}).WriteTo(ioutil.Discard); n != 0 || err != nil { + t.Errorf("WriteTo: got %d, %v; want 0, nil", n, err) + } +} diff --git a/libgo/go/strings/replace.go b/libgo/go/strings/replace.go index 58a11a63dbe..ace0b8d646e 100644 --- a/libgo/go/strings/replace.go +++ b/libgo/go/strings/replace.go @@ -4,12 +4,17 @@ package strings -import "io" +import ( + "io" + "sync" +) // Replacer replaces a list of strings with replacements. // It is safe for concurrent use by multiple goroutines. type Replacer struct { - r replacer + once sync.Once // guards buildOnce method + r replacer + oldnew []string } // replacer is the interface that a replacement algorithm needs to implement. @@ -25,15 +30,24 @@ func NewReplacer(oldnew ...string) *Replacer { if len(oldnew)%2 == 1 { panic("strings.NewReplacer: odd argument count") } + return &Replacer{oldnew: append([]string(nil), oldnew...)} +} + +func (r *Replacer) buildOnce() { + r.r = r.build() + r.oldnew = nil +} +func (b *Replacer) build() replacer { + oldnew := b.oldnew if len(oldnew) == 2 && len(oldnew[0]) > 1 { - return &Replacer{r: makeSingleStringReplacer(oldnew[0], oldnew[1])} + return makeSingleStringReplacer(oldnew[0], oldnew[1]) } allNewBytes := true for i := 0; i < len(oldnew); i += 2 { if len(oldnew[i]) != 1 { - return &Replacer{r: makeGenericReplacer(oldnew)} + return makeGenericReplacer(oldnew) } if len(oldnew[i+1]) != 1 { allNewBytes = false @@ -52,7 +66,7 @@ func NewReplacer(oldnew ...string) *Replacer { n := oldnew[i+1][0] r[o] = n } - return &Replacer{r: &r} + return &r } r := byteStringReplacer{toReplace: make([]string, 0, len(oldnew)/2)} @@ -71,16 +85,18 @@ func NewReplacer(oldnew ...string) *Replacer { r.replacements[o] = []byte(n) } - return &Replacer{r: &r} + return &r } // Replace returns a copy of s with all replacements performed. func (r *Replacer) Replace(s string) string { + r.once.Do(r.buildOnce) return r.r.Replace(s) } // WriteString writes s to w with all replacements performed. func (r *Replacer) WriteString(w io.Writer, s string) (n int, err error) { + r.once.Do(r.buildOnce) return r.r.WriteString(w, s) } @@ -292,10 +308,6 @@ func (w *appendSliceWriter) WriteString(s string) (int, error) { return len(s), nil } -type stringWriterIface interface { - WriteString(string) (int, error) -} - type stringWriter struct { w io.Writer } @@ -304,8 +316,8 @@ func (w stringWriter) WriteString(s string) (int, error) { return w.w.Write([]byte(s)) } -func getStringWriter(w io.Writer) stringWriterIface { - sw, ok := w.(stringWriterIface) +func getStringWriter(w io.Writer) io.StringWriter { + sw, ok := w.(io.StringWriter) if !ok { sw = stringWriter{w} } @@ -447,7 +459,7 @@ func (r *byteReplacer) WriteString(w io.Writer, s string) (n int, err error) { buf := make([]byte, bufsize) for len(s) > 0 { - ncopy := copy(buf, s[:]) + ncopy := copy(buf, s) s = s[ncopy:] for i, b := range buf[:ncopy] { buf[i] = r[b] diff --git a/libgo/go/strings/strings.go b/libgo/go/strings/strings.go index 20868be2694..a98f5d8ff13 100644 --- a/libgo/go/strings/strings.go +++ b/libgo/go/strings/strings.go @@ -146,6 +146,11 @@ func LastIndex(s, substr string) int { return -1 } +// IndexByte returns the index of the first instance of c in s, or -1 if c is not present in s. +func IndexByte(s string, c byte) int { + return bytealg.IndexByteString(s, c) +} + // IndexRune returns the index of the first instance of the Unicode code point // r, or -1 if rune is not present in s. // If r is utf8.RuneError, it returns the first instance of any @@ -423,27 +428,20 @@ func Join(a []string, sep string) string { return "" case 1: return a[0] - case 2: - // Special case for common small values. - // Remove if golang.org/issue/6714 is fixed - return a[0] + sep + a[1] - case 3: - // Special case for common small values. - // Remove if golang.org/issue/6714 is fixed - return a[0] + sep + a[1] + sep + a[2] } n := len(sep) * (len(a) - 1) for i := 0; i < len(a); i++ { n += len(a[i]) } - b := make([]byte, n) - bp := copy(b, a[0]) + var b Builder + b.Grow(n) + b.WriteString(a[0]) for _, s := range a[1:] { - bp += copy(b[bp:], sep) - bp += copy(b[bp:], s) + b.WriteString(sep) + b.WriteString(s) } - return string(b) + return b.String() } // HasPrefix tests whether the string s begins with prefix. @@ -466,68 +464,56 @@ func Map(mapping func(rune) rune, s string) string { // The output buffer b is initialized on demand, the first // time a character differs. - var b []byte - // nbytes is the number of bytes encoded in b. - var nbytes int + var b Builder for i, c := range s { r := mapping(c) - if r == c { + if r == c && c != utf8.RuneError { continue } - b = make([]byte, len(s)+utf8.UTFMax) - nbytes = copy(b, s[:i]) - if r >= 0 { - if r < utf8.RuneSelf { - b[nbytes] = byte(r) - nbytes++ - } else { - nbytes += utf8.EncodeRune(b[nbytes:], r) + var width int + if c == utf8.RuneError { + c, width = utf8.DecodeRuneInString(s[i:]) + if width != 1 && r == c { + continue } + } else { + width = utf8.RuneLen(c) } - if c == utf8.RuneError { - // RuneError is the result of either decoding - // an invalid sequence or '\uFFFD'. Determine - // the correct number of bytes we need to advance. - _, w := utf8.DecodeRuneInString(s[i:]) - i += w - } else { - i += utf8.RuneLen(c) + b.Grow(len(s) + utf8.UTFMax) + b.WriteString(s[:i]) + if r >= 0 { + b.WriteRune(r) } - s = s[i:] + s = s[i+width:] break } - if b == nil { + // Fast path for unchanged input + if b.Cap() == 0 { // didn't call b.Grow above return s } for _, c := range s { r := mapping(c) - // common case - if (0 <= r && r < utf8.RuneSelf) && nbytes < len(b) { - b[nbytes] = byte(r) - nbytes++ - continue - } - - // b is not big enough or r is not a ASCII rune. if r >= 0 { - if nbytes+utf8.UTFMax >= len(b) { - // Grow the buffer. - nb := make([]byte, 2*len(b)) - copy(nb, b[:nbytes]) - b = nb + // common case + // Due to inlining, it is more performant to determine if WriteByte should be + // invoked rather than always call WriteRune + if r < utf8.RuneSelf { + b.WriteByte(byte(r)) + } else { + // r is not a ASCII rune. + b.WriteRune(r) } - nbytes += utf8.EncodeRune(b[nbytes:], r) } } - return string(b[:nbytes]) + return b.String() } // Repeat returns a new string consisting of count copies of the string s. @@ -535,23 +521,33 @@ func Map(mapping func(rune) rune, s string) string { // It panics if count is negative or if // the result of (len(s) * count) overflows. func Repeat(s string, count int) string { + if count == 0 { + return "" + } + // Since we cannot return an error on overflow, // we should panic if the repeat will generate // an overflow. // See Issue golang.org/issue/16237 if count < 0 { panic("strings: negative Repeat count") - } else if count > 0 && len(s)*count/count != len(s) { + } else if len(s)*count/count != len(s) { panic("strings: Repeat count causes overflow") } - b := make([]byte, len(s)*count) - bp := copy(b, s) - for bp < len(b) { - copy(b[bp:], b[:bp]) - bp *= 2 + n := len(s) * count + var b Builder + b.Grow(n) + b.WriteString(s) + for b.Len() < n { + if b.Len() <= n/2 { + b.WriteString(b.String()) + } else { + b.WriteString(b.String()[:n-b.Len()]) + break + } } - return string(b) + return b.String() } // ToUpper returns a copy of the string s with all Unicode letters mapped to their upper case. @@ -570,15 +566,16 @@ func ToUpper(s string) string { if !hasLower { return s } - b := make([]byte, len(s)) + var b Builder + b.Grow(len(s)) for i := 0; i < len(s); i++ { c := s[i] if c >= 'a' && c <= 'z' { c -= 'a' - 'A' } - b[i] = c + b.WriteByte(c) } - return string(b) + return b.String() } return Map(unicode.ToUpper, s) } @@ -599,15 +596,16 @@ func ToLower(s string) string { if !hasUpper { return s } - b := make([]byte, len(s)) + var b Builder + b.Grow(len(s)) for i := 0; i < len(s); i++ { c := s[i] if c >= 'A' && c <= 'Z' { c += 'a' - 'A' } - b[i] = c + b.WriteByte(c) } - return string(b) + return b.String() } return Map(unicode.ToLower, s) } @@ -616,21 +614,21 @@ func ToLower(s string) string { func ToTitle(s string) string { return Map(unicode.ToTitle, s) } // ToUpperSpecial returns a copy of the string s with all Unicode letters mapped to their -// upper case, giving priority to the special casing rules. +// upper case using the case mapping specified by c. func ToUpperSpecial(c unicode.SpecialCase, s string) string { - return Map(func(r rune) rune { return c.ToUpper(r) }, s) + return Map(c.ToUpper, s) } // ToLowerSpecial returns a copy of the string s with all Unicode letters mapped to their -// lower case, giving priority to the special casing rules. +// lower case using the case mapping specified by c. func ToLowerSpecial(c unicode.SpecialCase, s string) string { - return Map(func(r rune) rune { return c.ToLower(r) }, s) + return Map(c.ToLower, s) } // ToTitleSpecial returns a copy of the string s with all Unicode letters mapped to their // title case, giving priority to the special casing rules. func ToTitleSpecial(c unicode.SpecialCase, s string) string { - return Map(func(r rune) rune { return c.ToTitle(r) }, s) + return Map(c.ToTitle, s) } // isSeparator reports whether the rune could mark a word boundary. @@ -881,6 +879,15 @@ func Replace(s, old, new string, n int) string { return string(t[0:w]) } +// ReplaceAll returns a copy of the string s with all +// non-overlapping instances of old replaced by new. +// If old is empty, it matches at the beginning of the string +// and after each UTF-8 sequence, yielding up to k+1 replacements +// for a k-rune string. +func ReplaceAll(s, old, new string) string { + return Replace(s, old, new, -1) +} + // EqualFold reports whether s and t, interpreted as UTF-8 strings, // are equal under Unicode case-folding. func EqualFold(s, t string) bool { @@ -956,21 +963,22 @@ func Index(s, substr string) int { if len(s) <= bytealg.MaxBruteForce { return bytealg.IndexString(s, substr) } - c := substr[0] + c0 := substr[0] + c1 := substr[1] i := 0 - t := s[:len(s)-n+1] + t := len(s) - n + 1 fails := 0 - for i < len(t) { - if t[i] != c { + for i < t { + if s[i] != c0 { // IndexByte is faster than bytealg.IndexString, so use it as long as // we're not getting lots of false positives. - o := IndexByte(t[i:], c) + o := IndexByte(s[i:t], c0) if o < 0 { return -1 } i += o } - if s[i:i+n] == substr { + if s[i+1] == c1 && s[i:i+n] == substr { return i } fails++ @@ -986,24 +994,25 @@ func Index(s, substr string) int { } return -1 } - c := substr[0] + c0 := substr[0] + c1 := substr[1] i := 0 - t := s[:len(s)-n+1] + t := len(s) - n + 1 fails := 0 - for i < len(t) { - if t[i] != c { - o := IndexByte(t[i:], c) + for i < t { + if s[i] != c0 { + o := IndexByte(s[i:t], c0) if o < 0 { return -1 } i += o } - if s[i:i+n] == substr { + if s[i+1] == c1 && s[i:i+n] == substr { return i } i++ fails++ - if fails >= 4+i>>4 && i < len(t) { + if fails >= 4+i>>4 && i < t { // See comment in ../bytes/bytes_generic.go. j := indexRabinKarp(s[i:], substr) if j < 0 { @@ -1036,5 +1045,4 @@ func indexRabinKarp(s, substr string) int { } } return -1 - } diff --git a/libgo/go/strings/strings_decl.go b/libgo/go/strings/strings_decl.go deleted file mode 100644 index 98194445e1c..00000000000 --- a/libgo/go/strings/strings_decl.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package strings - -// IndexByte returns the index of the first instance of c in s, or -1 if c is not present in s. -func IndexByte(s string, c byte) int // in internal/bytealg diff --git a/libgo/go/strings/strings_test.go b/libgo/go/strings/strings_test.go index 3f0c7909094..ae17eba8c93 100644 --- a/libgo/go/strings/strings_test.go +++ b/libgo/go/strings/strings_test.go @@ -11,6 +11,7 @@ import ( "math/rand" "reflect" "runtime" + "strconv" . "strings" "testing" "unicode" @@ -649,10 +650,10 @@ func TestMap(t *testing.T) { if unicode.Is(unicode.Latin, r) { return r } - return '?' + return utf8.RuneError } m = Map(replaceNotLatin, "Hello\255World") - expect = "Hello?World" + expect = "Hello\uFFFDWorld" if m != expect { t.Errorf("replace invalid sequence: expected %q got %q", expect, m) } @@ -677,6 +678,19 @@ func TestMap(t *testing.T) { if m != s { t.Errorf("encoding not handled correctly: expected %q got %q", s, m) } + + // 9. Check mapping occurs in the front, middle and back + trimSpaces := func(r rune) rune { + if unicode.IsSpace(r) { + return -1 + } + return r + } + m = Map(trimSpaces, " abc 123 ") + expect = "abc123" + if m != expect { + t.Errorf("trimSpaces: expected %q got %q", expect, m) + } } func TestToUpper(t *testing.T) { runStringTests(t, ToUpper, "ToUpper", upperTests) } @@ -1233,6 +1247,12 @@ func TestReplace(t *testing.T) { if s := Replace(tt.in, tt.old, tt.new, tt.n); s != tt.out { t.Errorf("Replace(%q, %q, %q, %d) = %q, want %q", tt.in, tt.old, tt.new, tt.n, s, tt.out) } + if tt.n == -1 { + s := ReplaceAll(tt.in, tt.old, tt.new) + if s != tt.out { + t.Errorf("ReplaceAll(%q, %q, %q) = %q, want %q", tt.in, tt.old, tt.new, s, tt.out) + } + } } } @@ -1651,8 +1671,15 @@ func BenchmarkSplitNMultiByteSeparator(b *testing.B) { } func BenchmarkRepeat(b *testing.B) { - for i := 0; i < b.N; i++ { - Repeat("-", 80) + s := "0123456789" + for _, n := range []int{5, 10} { + for _, c := range []int{1, 2, 6} { + b.Run(fmt.Sprintf("%dx%d", n, c), func(b *testing.B) { + for i := 0; i < b.N; i++ { + Repeat(s[:n], c) + } + }) + } } } @@ -1695,3 +1722,16 @@ func BenchmarkIndexPeriodic(b *testing.B) { }) } } + +func BenchmarkJoin(b *testing.B) { + vals := []string{"red", "yellow", "pink", "green", "purple", "orange", "blue"} + for l := 0; l <= len(vals); l++ { + b.Run(strconv.Itoa(l), func(b *testing.B) { + b.ReportAllocs() + vals := vals[:l] + for i := 0; i < b.N; i++ { + Join(vals, " and ") + } + }) + } +} diff --git a/libgo/go/sync/map.go b/libgo/go/sync/map.go index c4a0dc4194a..c6aa3088565 100644 --- a/libgo/go/sync/map.go +++ b/libgo/go/sync/map.go @@ -167,18 +167,14 @@ func (m *Map) Store(key, value interface{}) { // If the entry is expunged, tryStore returns false and leaves the entry // unchanged. func (e *entry) tryStore(i *interface{}) bool { - p := atomic.LoadPointer(&e.p) - if p == expunged { - return false - } for { - if atomic.CompareAndSwapPointer(&e.p, p, unsafe.Pointer(i)) { - return true - } - p = atomic.LoadPointer(&e.p) + p := atomic.LoadPointer(&e.p) if p == expunged { return false } + if atomic.CompareAndSwapPointer(&e.p, p, unsafe.Pointer(i)) { + return true + } } } diff --git a/libgo/go/sync/runtime.go b/libgo/go/sync/runtime.go index be16bcc8f7b..b6b9e480a4e 100644 --- a/libgo/go/sync/runtime.go +++ b/libgo/go/sync/runtime.go @@ -54,7 +54,7 @@ func init() { } // Active spinning runtime support. -// runtime_canSpin returns true is spinning makes sense at the moment. +// runtime_canSpin reports whether spinning makes sense at the moment. func runtime_canSpin(i int) bool // runtime_doSpin does active spinning. diff --git a/libgo/go/syscall/bpf_bsd.go b/libgo/go/syscall/bpf_bsd.go index 8b587559edb..f67ee6064bf 100644 --- a/libgo/go/syscall/bpf_bsd.go +++ b/libgo/go/syscall/bpf_bsd.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd netbsd openbsd +// +build dragonfly freebsd netbsd openbsd // Berkeley packet filter for BSD variants diff --git a/libgo/go/syscall/bpf_darwin.go b/libgo/go/syscall/bpf_darwin.go new file mode 100644 index 00000000000..fb86049ae92 --- /dev/null +++ b/libgo/go/syscall/bpf_darwin.go @@ -0,0 +1,185 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Berkeley packet filter for Darwin + +package syscall + +import ( + "unsafe" +) + +// Deprecated: Use golang.org/x/net/bpf instead. +func BpfStmt(code, k int) *BpfInsn { + return &BpfInsn{Code: uint16(code), K: uint32(k)} +} + +// Deprecated: Use golang.org/x/net/bpf instead. +func BpfJump(code, k, jt, jf int) *BpfInsn { + return &BpfInsn{Code: uint16(code), Jt: uint8(jt), Jf: uint8(jf), K: uint32(k)} +} + +// Deprecated: Use golang.org/x/net/bpf instead. +func BpfBuflen(fd int) (int, error) { + var l int + err := ioctlPtr(fd, BIOCGBLEN, unsafe.Pointer(&l)) + if err != nil { + return 0, err + } + return l, nil +} + +// Deprecated: Use golang.org/x/net/bpf instead. +func SetBpfBuflen(fd, l int) (int, error) { + err := ioctlPtr(fd, BIOCSBLEN, unsafe.Pointer(&l)) + if err != nil { + return 0, err + } + return l, nil +} + +// Deprecated: Use golang.org/x/net/bpf instead. +func BpfDatalink(fd int) (int, error) { + var t int + err := ioctlPtr(fd, BIOCGDLT, unsafe.Pointer(&t)) + if err != nil { + return 0, err + } + return t, nil +} + +// Deprecated: Use golang.org/x/net/bpf instead. +func SetBpfDatalink(fd, t int) (int, error) { + err := ioctlPtr(fd, BIOCSDLT, unsafe.Pointer(&t)) + if err != nil { + return 0, err + } + return t, nil +} + +// Deprecated: Use golang.org/x/net/bpf instead. +func SetBpfPromisc(fd, m int) error { + err := ioctlPtr(fd, BIOCPROMISC, unsafe.Pointer(&m)) + if err != nil { + return err + } + return nil +} + +// Deprecated: Use golang.org/x/net/bpf instead. +func FlushBpf(fd int) error { + err := ioctlPtr(fd, BIOCFLUSH, nil) + if err != nil { + return err + } + return nil +} + +type ivalue struct { + name [IFNAMSIZ]byte + value int16 +} + +// Deprecated: Use golang.org/x/net/bpf instead. +func BpfInterface(fd int, name string) (string, error) { + var iv ivalue + err := ioctlPtr(fd, BIOCGETIF, unsafe.Pointer(&iv)) + if err != nil { + return "", err + } + return name, nil +} + +// Deprecated: Use golang.org/x/net/bpf instead. +func SetBpfInterface(fd int, name string) error { + var iv ivalue + copy(iv.name[:], []byte(name)) + err := ioctlPtr(fd, BIOCSETIF, unsafe.Pointer(&iv)) + if err != nil { + return err + } + return nil +} + +// Deprecated: Use golang.org/x/net/bpf instead. +func BpfTimeout(fd int) (*Timeval, error) { + var tv Timeval + err := ioctlPtr(fd, BIOCGRTIMEOUT, unsafe.Pointer(&tv)) + if err != nil { + return nil, err + } + return &tv, nil +} + +// Deprecated: Use golang.org/x/net/bpf instead. +func SetBpfTimeout(fd int, tv *Timeval) error { + err := ioctlPtr(fd, BIOCSRTIMEOUT, unsafe.Pointer(tv)) + if err != nil { + return err + } + return nil +} + +// Deprecated: Use golang.org/x/net/bpf instead. +func BpfStats(fd int) (*BpfStat, error) { + var s BpfStat + err := ioctlPtr(fd, BIOCGSTATS, unsafe.Pointer(&s)) + if err != nil { + return nil, err + } + return &s, nil +} + +// Deprecated: Use golang.org/x/net/bpf instead. +func SetBpfImmediate(fd, m int) error { + err := ioctlPtr(fd, BIOCIMMEDIATE, unsafe.Pointer(&m)) + if err != nil { + return err + } + return nil +} + +// Deprecated: Use golang.org/x/net/bpf instead. +func SetBpf(fd int, i []BpfInsn) error { + var p BpfProgram + p.Len = uint32(len(i)) + p.Insns = (*BpfInsn)(unsafe.Pointer(&i[0])) + err := ioctlPtr(fd, BIOCSETF, unsafe.Pointer(&p)) + if err != nil { + return err + } + return nil +} + +// Deprecated: Use golang.org/x/net/bpf instead. +func CheckBpfVersion(fd int) error { + var v BpfVersion + err := ioctlPtr(fd, BIOCVERSION, unsafe.Pointer(&v)) + if err != nil { + return err + } + if v.Major != BPF_MAJOR_VERSION || v.Minor != BPF_MINOR_VERSION { + return EINVAL + } + return nil +} + +// Deprecated: Use golang.org/x/net/bpf instead. +func BpfHeadercmpl(fd int) (int, error) { + var f int + err := ioctlPtr(fd, BIOCGHDRCMPLT, unsafe.Pointer(&f)) + if err != nil { + return 0, err + } + return f, nil +} + +// Deprecated: Use golang.org/x/net/bpf instead. +func SetBpfHeadercmpl(fd, f int) error { + err := ioctlPtr(fd, BIOCSHDRCMPLT, unsafe.Pointer(&f)) + if err != nil { + return err + } + return nil +} diff --git a/libgo/go/syscall/dirent_bsd_test.go b/libgo/go/syscall/dirent_bsd_test.go new file mode 100644 index 00000000000..e5f5eb3f8aa --- /dev/null +++ b/libgo/go/syscall/dirent_bsd_test.go @@ -0,0 +1,76 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build darwin,!arm,!arm64 dragonfly freebsd netbsd openbsd + +package syscall_test + +import ( + "bytes" + "io/ioutil" + "os" + "path/filepath" + "sort" + "strconv" + "strings" + "syscall" + "testing" +) + +func TestDirent(t *testing.T) { + const ( + direntBufSize = 2048 + filenameMinSize = 11 + ) + + d, err := ioutil.TempDir("", "dirent-test") + if err != nil { + t.Fatalf("tempdir: %v", err) + } + defer os.RemoveAll(d) + t.Logf("tmpdir: %s", d) + + for i, c := range []byte("0123456789") { + name := string(bytes.Repeat([]byte{c}, filenameMinSize+i)) + err = ioutil.WriteFile(filepath.Join(d, name), nil, 0644) + if err != nil { + t.Fatalf("writefile: %v", err) + } + } + + buf := bytes.Repeat([]byte("DEADBEAF"), direntBufSize/8) + fd, err := syscall.Open(d, syscall.O_RDONLY, 0) + defer syscall.Close(fd) + if err != nil { + t.Fatalf("syscall.open: %v", err) + } + n, err := syscall.ReadDirent(fd, buf) + if err != nil { + t.Fatalf("syscall.readdir: %v", err) + } + buf = buf[:n] + + names := make([]string, 0, 10) + for len(buf) > 0 { + var bc int + bc, _, names = syscall.ParseDirent(buf, -1, names) + buf = buf[bc:] + } + + sort.Strings(names) + t.Logf("names: %q", names) + + if len(names) != 10 { + t.Errorf("got %d names; expected 10", len(names)) + } + for i, name := range names { + ord, err := strconv.Atoi(name[:1]) + if err != nil { + t.Fatalf("names[%d] is non-integer %q: %v", i, names[i], err) + } + if expected := string(strings.Repeat(name[:1], filenameMinSize+ord)); name != expected { + t.Errorf("names[%d] is %q (len %d); expected %q (len %d)", i, name, len(name), expected, len(expected)) + } + } +} diff --git a/libgo/go/syscall/exec_aix_test.go b/libgo/go/syscall/exec_aix_test.go new file mode 100644 index 00000000000..22b752cf271 --- /dev/null +++ b/libgo/go/syscall/exec_aix_test.go @@ -0,0 +1,37 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build aix + +package syscall + +import "unsafe" + +//go:cgo_import_dynamic libc_Getpgid getpgid "libc.a/shr_64.o" +//go:cgo_import_dynamic libc_Getpgrp getpgrp "libc.a/shr_64.o" + +//go:linkname libc_Getpgid libc_Getpgid +//go:linkname libc_Getpgrp libc_Getpgrp + +var ( + libc_Getpgid, + libc_Getpgrp libcFunc +) + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := syscall6(uintptr(unsafe.Pointer(&libc_Getpgid)), 1, uintptr(pid), 0, 0, 0, 0, 0) + pgid = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func Getpgrp() (pgrp int) { + r0, _, _ := syscall6(uintptr(unsafe.Pointer(&libc_Getpgrp)), 0, 0, 0, 0, 0, 0, 0) + pgrp = int(r0) + return +} + +var Ioctl = ioctl diff --git a/libgo/go/syscall/exec_darwin.go b/libgo/go/syscall/exec_darwin.go new file mode 100644 index 00000000000..f860f4628eb --- /dev/null +++ b/libgo/go/syscall/exec_darwin.go @@ -0,0 +1,248 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syscall + +import ( + "unsafe" +) + +type SysProcAttr struct { + Chroot string // Chroot. + Credential *Credential // Credential. + Ptrace bool // Enable tracing. + Setsid bool // Create session. + Setpgid bool // Set process group ID to Pgid, or, if Pgid == 0, to new pid. + Setctty bool // Set controlling terminal to fd Ctty + Noctty bool // Detach fd 0 from controlling terminal + Ctty int // Controlling TTY fd + Foreground bool // Place child's process group in foreground. (Implies Setpgid. Uses Ctty as fd of controlling TTY) + Pgid int // Child's process group ID if Setpgid. +} + +// Implemented in runtime package. +func runtime_BeforeFork() +func runtime_AfterFork() +func runtime_AfterForkInChild() + +// Fork, dup fd onto 0..len(fd), and exec(argv0, argvv, envv) in child. +// If a dup or exec fails, write the errno error to pipe. +// (Pipe is close-on-exec so if exec succeeds, it will be closed.) +// In the child, this function must not acquire any locks, because +// they might have been locked at the time of the fork. This means +// no rescheduling, no malloc calls, and no new stack segments. +// For the same reason compiler does not race instrument it. +// The calls to rawSyscall are okay because they are assembly +// functions that do not grow the stack. +//go:norace +func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr *ProcAttr, sys *SysProcAttr, pipe int) (pid int, err Errno) { + // Declare all variables at top in case any + // declarations require heap allocation (e.g., err1). + var ( + r1 uintptr + err1 Errno + nextfd int + i int + ) + + // guard against side effects of shuffling fds below. + // Make sure that nextfd is beyond any currently open files so + // that we can't run the risk of overwriting any of them. + fd := make([]int, len(attr.Files)) + nextfd = len(attr.Files) + for i, ufd := range attr.Files { + if nextfd < int(ufd) { + nextfd = int(ufd) + } + fd[i] = int(ufd) + } + nextfd++ + + // About to call fork. + // No more allocation or calls of non-assembly functions. + runtime_BeforeFork() + r1, _, err1 = rawSyscall(funcPC(libc_fork_trampoline), 0, 0, 0) + if err1 != 0 { + runtime_AfterFork() + return 0, err1 + } + + if r1 != 0 { + // parent; return PID + runtime_AfterFork() + return int(r1), 0 + } + + // Fork succeeded, now in child. + + runtime_AfterForkInChild() + + // Enable tracing if requested. + if sys.Ptrace { + _, _, err1 = rawSyscall(funcPC(libc_ptrace_trampoline), uintptr(PTRACE_TRACEME), 0, 0) + if err1 != 0 { + goto childerror + } + } + + // Session ID + if sys.Setsid { + _, _, err1 = rawSyscall(funcPC(libc_setsid_trampoline), 0, 0, 0) + if err1 != 0 { + goto childerror + } + } + + // Set process group + if sys.Setpgid || sys.Foreground { + // Place child in process group. + _, _, err1 = rawSyscall(funcPC(libc_setpgid_trampoline), 0, uintptr(sys.Pgid), 0) + if err1 != 0 { + goto childerror + } + } + + if sys.Foreground { + pgrp := sys.Pgid + if pgrp == 0 { + r1, _, err1 = rawSyscall(funcPC(libc_getpid_trampoline), 0, 0, 0) + if err1 != 0 { + goto childerror + } + + pgrp = int(r1) + } + + // Place process group in foreground. + _, _, err1 = rawSyscall(funcPC(libc_ioctl_trampoline), uintptr(sys.Ctty), uintptr(TIOCSPGRP), uintptr(unsafe.Pointer(&pgrp))) + if err1 != 0 { + goto childerror + } + } + + // Chroot + if chroot != nil { + _, _, err1 = rawSyscall(funcPC(libc_chroot_trampoline), uintptr(unsafe.Pointer(chroot)), 0, 0) + if err1 != 0 { + goto childerror + } + } + + // User and groups + if cred := sys.Credential; cred != nil { + ngroups := uintptr(len(cred.Groups)) + groups := uintptr(0) + if ngroups > 0 { + groups = uintptr(unsafe.Pointer(&cred.Groups[0])) + } + if !cred.NoSetGroups { + _, _, err1 = rawSyscall(funcPC(libc_setgroups_trampoline), ngroups, groups, 0) + if err1 != 0 { + goto childerror + } + } + _, _, err1 = rawSyscall(funcPC(libc_setgid_trampoline), uintptr(cred.Gid), 0, 0) + if err1 != 0 { + goto childerror + } + _, _, err1 = rawSyscall(funcPC(libc_setuid_trampoline), uintptr(cred.Uid), 0, 0) + if err1 != 0 { + goto childerror + } + } + + // Chdir + if dir != nil { + _, _, err1 = rawSyscall(funcPC(libc_chdir_trampoline), uintptr(unsafe.Pointer(dir)), 0, 0) + if err1 != 0 { + goto childerror + } + } + + // Pass 1: look for fd[i] < i and move those up above len(fd) + // so that pass 2 won't stomp on an fd it needs later. + if pipe < nextfd { + _, _, err1 = rawSyscall(funcPC(libc_dup2_trampoline), uintptr(pipe), uintptr(nextfd), 0) + if err1 != 0 { + goto childerror + } + rawSyscall(funcPC(libc_fcntl_trampoline), uintptr(nextfd), F_SETFD, FD_CLOEXEC) + pipe = nextfd + nextfd++ + } + for i = 0; i < len(fd); i++ { + if fd[i] >= 0 && fd[i] < int(i) { + if nextfd == pipe { // don't stomp on pipe + nextfd++ + } + _, _, err1 = rawSyscall(funcPC(libc_dup2_trampoline), uintptr(fd[i]), uintptr(nextfd), 0) + if err1 != 0 { + goto childerror + } + rawSyscall(funcPC(libc_fcntl_trampoline), uintptr(nextfd), F_SETFD, FD_CLOEXEC) + fd[i] = nextfd + nextfd++ + } + } + + // Pass 2: dup fd[i] down onto i. + for i = 0; i < len(fd); i++ { + if fd[i] == -1 { + rawSyscall(funcPC(libc_close_trampoline), uintptr(i), 0, 0) + continue + } + if fd[i] == int(i) { + // dup2(i, i) won't clear close-on-exec flag on Linux, + // probably not elsewhere either. + _, _, err1 = rawSyscall(funcPC(libc_fcntl_trampoline), uintptr(fd[i]), F_SETFD, 0) + if err1 != 0 { + goto childerror + } + continue + } + // The new fd is created NOT close-on-exec, + // which is exactly what we want. + _, _, err1 = rawSyscall(funcPC(libc_dup2_trampoline), uintptr(fd[i]), uintptr(i), 0) + if err1 != 0 { + goto childerror + } + } + + // By convention, we don't close-on-exec the fds we are + // started with, so if len(fd) < 3, close 0, 1, 2 as needed. + // Programs that know they inherit fds >= 3 will need + // to set them close-on-exec. + for i = len(fd); i < 3; i++ { + rawSyscall(funcPC(libc_close_trampoline), uintptr(i), 0, 0) + } + + // Detach fd 0 from tty + if sys.Noctty { + _, _, err1 = rawSyscall(funcPC(libc_ioctl_trampoline), 0, uintptr(TIOCNOTTY), 0) + if err1 != 0 { + goto childerror + } + } + + // Set the controlling TTY to Ctty + if sys.Setctty { + _, _, err1 = rawSyscall(funcPC(libc_ioctl_trampoline), uintptr(sys.Ctty), uintptr(TIOCSCTTY), 0) + if err1 != 0 { + goto childerror + } + } + + // Time to exec. + _, _, err1 = rawSyscall(funcPC(libc_execve_trampoline), + uintptr(unsafe.Pointer(argv0)), + uintptr(unsafe.Pointer(&argv[0])), + uintptr(unsafe.Pointer(&envv[0]))) + +childerror: + // send error code on pipe + rawSyscall(funcPC(libc_write_trampoline), uintptr(pipe), uintptr(unsafe.Pointer(&err1)), unsafe.Sizeof(err1)) + for { + rawSyscall(funcPC(libc_exit_trampoline), 253, 0, 0) + } +} diff --git a/libgo/go/syscall/exec_linux.go b/libgo/go/syscall/exec_linux.go index e5ccc690155..f035e6b07e1 100644 --- a/libgo/go/syscall/exec_linux.go +++ b/libgo/go/syscall/exec_linux.go @@ -28,9 +28,12 @@ type SysProcIDMap struct { } type SysProcAttr struct { - Chroot string // Chroot. - Credential *Credential // Credential. - Ptrace bool // Enable tracing. + Chroot string // Chroot. + Credential *Credential // Credential. + // Ptrace tells the child to call ptrace(PTRACE_TRACEME). + // Call runtime.LockOSThread before starting a process with this set, + // and don't call UnlockOSThread until done with PtraceSyscall calls. + Ptrace bool Setsid bool // Create session. Setpgid bool // Set process group ID to Pgid, or, if Pgid == 0, to new pid. Setctty bool // Set controlling terminal to fd Ctty (only meaningful if Setsid is set) diff --git a/libgo/go/syscall/exec_linux_test.go b/libgo/go/syscall/exec_linux_test.go index f551e87736d..ac5745bc80b 100644 --- a/libgo/go/syscall/exec_linux_test.go +++ b/libgo/go/syscall/exec_linux_test.go @@ -16,6 +16,7 @@ import ( "os/exec" "os/user" "path/filepath" + "runtime" "strconv" "strings" "syscall" @@ -524,6 +525,11 @@ func TestAmbientCaps(t *testing.T) { t.Skip("skipping test on Kubernetes-based builders; see Issue 12815") } + // skip on android, due to lack of lookup support + if runtime.GOOS == "android" { + t.Skip("skipping test on android; see Issue 27327") + } + caps, err := getCaps() if err != nil { t.Fatal(err) diff --git a/libgo/go/syscall/exec_unix.go b/libgo/go/syscall/exec_unix.go index 8d83e911380..54e322c748c 100644 --- a/libgo/go/syscall/exec_unix.go +++ b/libgo/go/syscall/exec_unix.go @@ -297,9 +297,10 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle func runtime_BeforeExec() func runtime_AfterExec() -// execveSolaris is non-nil on Solaris, set to execve in exec_solaris.go; this +// execveLibc is non-nil on OS using libc syscall, set to execve in exec_libc.go; this // avoids a build dependency for other platforms. -var execveSolaris func(path uintptr, argv uintptr, envp uintptr) (err Errno) +var execveLibc func(path uintptr, argv uintptr, envp uintptr) Errno +var execveDarwin func(path *byte, argv **byte, envp **byte) error // Exec invokes the execve(2) system call. func Exec(argv0 string, argv []string, envv []string) (err error) { @@ -317,7 +318,22 @@ func Exec(argv0 string, argv []string, envv []string) (err error) { } runtime_BeforeExec() - err1 := raw_execve(argv0p, &argvp[0], &envvp[0]) + var err1 error + if runtime.GOOS == "solaris" || runtime.GOOS == "aix" { + // RawSyscall should never be used on Solaris or AIX. + err1 = execveLibc( + uintptr(unsafe.Pointer(argv0p)), + uintptr(unsafe.Pointer(&argvp[0])), + uintptr(unsafe.Pointer(&envvp[0]))) + } else if runtime.GOOS == "darwin" { + // Similarly on Darwin. + err1 = execveDarwin(argv0p, &argvp[0], &envvp[0]) + } else { + _, _, err1 = RawSyscall(SYS_EXECVE, + uintptr(unsafe.Pointer(argv0p)), + uintptr(unsafe.Pointer(&argvp[0])), + uintptr(unsafe.Pointer(&envvp[0]))) + } runtime_AfterExec() - return Errno(err1) + return err1 } diff --git a/libgo/go/syscall/export_freebsd_test.go b/libgo/go/syscall/export_freebsd_test.go new file mode 100644 index 00000000000..d47f09024f7 --- /dev/null +++ b/libgo/go/syscall/export_freebsd_test.go @@ -0,0 +1,12 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syscall + +type Dirent_freebsd11 = dirent_freebsd11 + +var ( + Roundup = roundup + ConvertFromDirents11 = convertFromDirents11 +) diff --git a/libgo/go/syscall/flock_aix.go b/libgo/go/syscall/flock_aix.go new file mode 100644 index 00000000000..c9eab43b6bc --- /dev/null +++ b/libgo/go/syscall/flock_aix.go @@ -0,0 +1,18 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syscall + +import "unsafe" + +// On AIX, there is no flock() system call. + +// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. +func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) (err error) { + _, _, e1 := syscall6(uintptr(unsafe.Pointer(&libc_fcntl)), 3, uintptr(fd), uintptr(cmd), uintptr(unsafe.Pointer(lk)), 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/libgo/go/syscall/flock_darwin.go b/libgo/go/syscall/flock_darwin.go new file mode 100644 index 00000000000..d2bd84130c3 --- /dev/null +++ b/libgo/go/syscall/flock_darwin.go @@ -0,0 +1,13 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syscall + +import "unsafe" + +// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. +func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { + _, err := fcntlPtr(int(fd), cmd, unsafe.Pointer(lk)) + return err +} diff --git a/libgo/go/syscall/forkpipe.go b/libgo/go/syscall/forkpipe.go index 71890a29bad..d9999cb8b86 100644 --- a/libgo/go/syscall/forkpipe.go +++ b/libgo/go/syscall/forkpipe.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly solaris +// +build aix darwin dragonfly solaris package syscall diff --git a/libgo/go/syscall/fs_js.go b/libgo/go/syscall/fs_js.go index 00d6c769791..fcc5f038b82 100644 --- a/libgo/go/syscall/fs_js.go +++ b/libgo/go/syscall/fs_js.go @@ -81,15 +81,15 @@ func Open(path string, openmode int, perm uint32) (int, error) { return 0, errors.New("syscall.Open: O_SYNC is not supported by js/wasm") } - jsFD, err := fsCall("openSync", path, flags, perm) + jsFD, err := fsCall("open", path, flags, perm) if err != nil { return 0, err } fd := jsFD.Int() var entries []string - if stat, err := fsCall("fstatSync", fd); err == nil && stat.Call("isDirectory").Bool() { - dir, err := fsCall("readdirSync", path) + if stat, err := fsCall("fstat", fd); err == nil && stat.Call("isDirectory").Bool() { + dir, err := fsCall("readdir", path) if err != nil { return 0, err } @@ -113,7 +113,7 @@ func Close(fd int) error { filesMu.Lock() delete(files, fd) filesMu.Unlock() - _, err := fsCall("closeSync", fd) + _, err := fsCall("close", fd) return err } @@ -125,7 +125,7 @@ func Mkdir(path string, perm uint32) error { if err := checkPath(path); err != nil { return err } - _, err := fsCall("mkdirSync", path, perm) + _, err := fsCall("mkdir", path, perm) return err } @@ -182,7 +182,7 @@ func Stat(path string, st *Stat_t) error { if err := checkPath(path); err != nil { return err } - jsSt, err := fsCall("statSync", path) + jsSt, err := fsCall("stat", path) if err != nil { return err } @@ -194,7 +194,7 @@ func Lstat(path string, st *Stat_t) error { if err := checkPath(path); err != nil { return err } - jsSt, err := fsCall("lstatSync", path) + jsSt, err := fsCall("lstat", path) if err != nil { return err } @@ -203,7 +203,7 @@ func Lstat(path string, st *Stat_t) error { } func Fstat(fd int, st *Stat_t) error { - jsSt, err := fsCall("fstatSync", fd) + jsSt, err := fsCall("fstat", fd) if err != nil { return err } @@ -215,7 +215,7 @@ func Unlink(path string) error { if err := checkPath(path); err != nil { return err } - _, err := fsCall("unlinkSync", path) + _, err := fsCall("unlink", path) return err } @@ -223,7 +223,7 @@ func Rmdir(path string) error { if err := checkPath(path); err != nil { return err } - _, err := fsCall("rmdirSync", path) + _, err := fsCall("rmdir", path) return err } @@ -231,12 +231,12 @@ func Chmod(path string, mode uint32) error { if err := checkPath(path); err != nil { return err } - _, err := fsCall("chmodSync", path, mode) + _, err := fsCall("chmod", path, mode) return err } func Fchmod(fd int, mode uint32) error { - _, err := fsCall("fchmodSync", fd, mode) + _, err := fsCall("fchmod", fd, mode) return err } @@ -267,7 +267,7 @@ func UtimesNano(path string, ts []Timespec) error { } atime := ts[0].Sec mtime := ts[1].Sec - _, err := fsCall("utimesSync", path, atime, mtime) + _, err := fsCall("utimes", path, atime, mtime) return err } @@ -278,7 +278,7 @@ func Rename(from, to string) error { if err := checkPath(to); err != nil { return err } - _, err := fsCall("renameSync", from, to) + _, err := fsCall("rename", from, to) return err } @@ -286,12 +286,12 @@ func Truncate(path string, length int64) error { if err := checkPath(path); err != nil { return err } - _, err := fsCall("truncateSync", path, length) + _, err := fsCall("truncate", path, length) return err } func Ftruncate(fd int, length int64) error { - _, err := fsCall("ftruncateSync", fd, length) + _, err := fsCall("ftruncate", fd, length) return err } @@ -299,7 +299,7 @@ func Getcwd(buf []byte) (n int, err error) { defer recoverErr(&err) cwd := jsProcess.Call("cwd").String() n = copy(buf, cwd) - return n, nil + return } func Chdir(path string) (err error) { @@ -323,7 +323,7 @@ func Readlink(path string, buf []byte) (n int, err error) { if err := checkPath(path); err != nil { return 0, err } - dst, err := fsCall("readlinkSync", path) + dst, err := fsCall("readlink", path) if err != nil { return 0, err } @@ -338,7 +338,7 @@ func Link(path, link string) error { if err := checkPath(link); err != nil { return err } - _, err := fsCall("linkSync", path, link) + _, err := fsCall("link", path, link) return err } @@ -349,12 +349,12 @@ func Symlink(path, link string) error { if err := checkPath(link); err != nil { return err } - _, err := fsCall("symlinkSync", path, link) + _, err := fsCall("symlink", path, link) return err } func Fsync(fd int) error { - _, err := fsCall("fsyncSync", fd) + _, err := fsCall("fsync", fd) return err } @@ -371,7 +371,7 @@ func Read(fd int, b []byte) (int, error) { } a := js.TypedArrayOf(b) - n, err := fsCall("readSync", fd, a, 0, len(b)) + n, err := fsCall("read", fd, a, 0, len(b), nil) a.Release() if err != nil { return 0, err @@ -394,7 +394,7 @@ func Write(fd int, b []byte) (int, error) { } a := js.TypedArrayOf(b) - n, err := fsCall("writeSync", fd, a, 0, len(b)) + n, err := fsCall("write", fd, a, 0, len(b), nil) a.Release() if err != nil { return 0, err @@ -406,7 +406,7 @@ func Write(fd int, b []byte) (int, error) { func Pread(fd int, b []byte, offset int64) (int, error) { a := js.TypedArrayOf(b) - n, err := fsCall("readSync", fd, a, 0, len(b), offset) + n, err := fsCall("read", fd, a, 0, len(b), offset) a.Release() if err != nil { return 0, err @@ -416,7 +416,7 @@ func Pread(fd int, b []byte, offset int64) (int, error) { func Pwrite(fd int, b []byte, offset int64) (int, error) { a := js.TypedArrayOf(b) - n, err := fsCall("writeSync", fd, a, 0, len(b), offset) + n, err := fsCall("write", fd, a, 0, len(b), offset) a.Release() if err != nil { return 0, err @@ -467,10 +467,32 @@ func Pipe(fd []int) error { return ENOSYS } -func fsCall(name string, args ...interface{}) (res js.Value, err error) { - defer recoverErr(&err) - res = jsFS.Call(name, args...) - return +func fsCall(name string, args ...interface{}) (js.Value, error) { + type callResult struct { + val js.Value + err error + } + + c := make(chan callResult, 1) + jsFS.Call(name, append(args, js.FuncOf(func(this js.Value, args []js.Value) interface{} { + var res callResult + + if len(args) >= 1 { // on Node.js 8, fs.utimes calls the callback without any arguments + if jsErr := args[0]; jsErr != js.Null() { + res.err = mapJSError(jsErr) + } + } + + res.val = js.Undefined() + if len(args) >= 2 { + res.val = args[1] + } + + c <- res + return nil + }))...) + res := <-c + return res.val, res.err } // checkPath checks that the path is not empty and that it contains no null characters. @@ -492,10 +514,15 @@ func recoverErr(errPtr *error) { if !ok { panic(err) } - errno, ok := errnoByCode[jsErr.Get("code").String()] - if !ok { - panic(err) - } - *errPtr = errnoErr(Errno(errno)) + *errPtr = mapJSError(jsErr.Value) + } +} + +// mapJSError maps an error given by Node.js to the appropriate Go error +func mapJSError(jsErr js.Value) error { + errno, ok := errnoByCode[jsErr.Get("code").String()] + if !ok { + panic(jsErr) } + return errnoErr(Errno(errno)) } diff --git a/libgo/go/syscall/js/callback.go b/libgo/go/syscall/js/callback.go deleted file mode 100644 index 9d573074cbd..00000000000 --- a/libgo/go/syscall/js/callback.go +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build js,wasm - -package js - -import "sync" - -var ( - pendingCallbacks = Global().Get("Array").New() - makeCallbackHelper = Global().Get("Go").Get("_makeCallbackHelper") - makeEventCallbackHelper = Global().Get("Go").Get("_makeEventCallbackHelper") -) - -var ( - callbacksMu sync.Mutex - callbacks = make(map[uint32]func([]Value)) - nextCallbackID uint32 = 1 -) - -// Callback is a Go function that got wrapped for use as a JavaScript callback. -type Callback struct { - Value // the JavaScript function that queues the callback for execution - id uint32 -} - -// NewCallback returns a wrapped callback function. -// -// Invoking the callback in JavaScript will queue the Go function fn for execution. -// This execution happens asynchronously on a special goroutine that handles all callbacks and preserves -// the order in which the callbacks got called. -// As a consequence, if one callback blocks this goroutine, other callbacks will not be processed. -// A blocking callback should therefore explicitly start a new goroutine. -// -// Callback.Release must be called to free up resources when the callback will not be used any more. -func NewCallback(fn func(args []Value)) Callback { - callbackLoopOnce.Do(func() { - go callbackLoop() - }) - - callbacksMu.Lock() - id := nextCallbackID - nextCallbackID++ - callbacks[id] = fn - callbacksMu.Unlock() - return Callback{ - Value: makeCallbackHelper.Invoke(id, pendingCallbacks, jsGo), - id: id, - } -} - -type EventCallbackFlag int - -const ( - // PreventDefault can be used with NewEventCallback to call event.preventDefault synchronously. - PreventDefault EventCallbackFlag = 1 << iota - // StopPropagation can be used with NewEventCallback to call event.stopPropagation synchronously. - StopPropagation - // StopImmediatePropagation can be used with NewEventCallback to call event.stopImmediatePropagation synchronously. - StopImmediatePropagation -) - -// NewEventCallback returns a wrapped callback function, just like NewCallback, but the callback expects to have -// exactly one argument, the event. Depending on flags, it will synchronously call event.preventDefault, -// event.stopPropagation and/or event.stopImmediatePropagation before queuing the Go function fn for execution. -func NewEventCallback(flags EventCallbackFlag, fn func(event Value)) Callback { - c := NewCallback(func(args []Value) { - fn(args[0]) - }) - return Callback{ - Value: makeEventCallbackHelper.Invoke( - flags&PreventDefault != 0, - flags&StopPropagation != 0, - flags&StopImmediatePropagation != 0, - c, - ), - id: c.id, - } -} - -// Release frees up resources allocated for the callback. -// The callback must not be invoked after calling Release. -func (c Callback) Release() { - callbacksMu.Lock() - delete(callbacks, c.id) - callbacksMu.Unlock() -} - -var callbackLoopOnce sync.Once - -func callbackLoop() { - for !jsGo.Get("_callbackShutdown").Bool() { - sleepUntilCallback() - for { - cb := pendingCallbacks.Call("shift") - if cb == Undefined() { - break - } - - id := uint32(cb.Get("id").Int()) - callbacksMu.Lock() - f, ok := callbacks[id] - callbacksMu.Unlock() - if !ok { - Global().Get("console").Call("error", "call to closed callback") - continue - } - - argsObj := cb.Get("args") - args := make([]Value, argsObj.Length()) - for i := range args { - args[i] = argsObj.Index(i) - } - f(args) - } - } -} - -// sleepUntilCallback is defined in the runtime package -func sleepUntilCallback() diff --git a/libgo/go/syscall/js/func.go b/libgo/go/syscall/js/func.go new file mode 100644 index 00000000000..6b7f39b8784 --- /dev/null +++ b/libgo/go/syscall/js/func.go @@ -0,0 +1,92 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build js,wasm + +package js + +import "sync" + +var ( + funcsMu sync.Mutex + funcs = make(map[uint32]func(Value, []Value) interface{}) + nextFuncID uint32 = 1 +) + +var _ Wrapper = Func{} // Func must implement Wrapper + +// Func is a wrapped Go function to be called by JavaScript. +type Func struct { + Value // the JavaScript function that invokes the Go function + id uint32 +} + +// FuncOf returns a wrapped function. +// +// Invoking the JavaScript function will synchronously call the Go function fn with the value of JavaScript's +// "this" keyword and the arguments of the invocation. +// The return value of the invocation is the result of the Go function mapped back to JavaScript according to ValueOf. +// +// A wrapped function triggered during a call from Go to JavaScript gets executed on the same goroutine. +// A wrapped function triggered by JavaScript's event loop gets executed on an extra goroutine. +// Blocking operations in the wrapped function will block the event loop. +// As a consequence, if one wrapped function blocks, other wrapped funcs will not be processed. +// A blocking function should therefore explicitly start a new goroutine. +// +// Func.Release must be called to free up resources when the function will not be used any more. +func FuncOf(fn func(this Value, args []Value) interface{}) Func { + funcsMu.Lock() + id := nextFuncID + nextFuncID++ + funcs[id] = fn + funcsMu.Unlock() + return Func{ + id: id, + Value: jsGo.Call("_makeFuncWrapper", id), + } +} + +// Release frees up resources allocated for the function. +// The function must not be invoked after calling Release. +func (c Func) Release() { + funcsMu.Lock() + delete(funcs, c.id) + funcsMu.Unlock() +} + +// setEventHandler is defined in the runtime package. +func setEventHandler(fn func()) + +func init() { + setEventHandler(handleEvent) +} + +func handleEvent() { + cb := jsGo.Get("_pendingEvent") + if cb == Null() { + return + } + jsGo.Set("_pendingEvent", Null()) + + id := uint32(cb.Get("id").Int()) + if id == 0 { // zero indicates deadlock + select {} + } + funcsMu.Lock() + f, ok := funcs[id] + funcsMu.Unlock() + if !ok { + Global().Get("console").Call("error", "call to released function") + return + } + + this := cb.Get("this") + argsObj := cb.Get("args") + args := make([]Value, argsObj.Length()) + for i := range args { + args[i] = argsObj.Index(i) + } + result := f(this, args) + cb.Set("result", result) +} diff --git a/libgo/go/syscall/js/js.go b/libgo/go/syscall/js/js.go index 336586ca2dd..0893db022d3 100644 --- a/libgo/go/syscall/js/js.go +++ b/libgo/go/syscall/js/js.go @@ -16,19 +16,32 @@ import ( ) // ref is used to identify a JavaScript value, since the value itself can not be passed to WebAssembly. -// A JavaScript number (64-bit float, except NaN) is represented by its IEEE 754 binary representation. +// +// The JavaScript value "undefined" is represented by the value 0. +// A JavaScript number (64-bit float, except 0 and NaN) is represented by its IEEE 754 binary representation. // All other values are represented as an IEEE 754 binary representation of NaN with bits 0-31 used as // an ID and bits 32-33 used to differentiate between string, symbol, function and object. type ref uint64 -// nanHead are the upper 32 bits of a ref which are set if the value is not a JavaScript number or NaN itself. +// nanHead are the upper 32 bits of a ref which are set if the value is not encoded as an IEEE 754 number (see above). const nanHead = 0x7FF80000 -// Value represents a JavaScript value. +// Wrapper is implemented by types that are backed by a JavaScript value. +type Wrapper interface { + // JSValue returns a JavaScript value associated with an object. + JSValue() Value +} + +// Value represents a JavaScript value. The zero value is the JavaScript value "undefined". type Value struct { ref ref } +// JSValue implements Wrapper interface. +func (v Value) JSValue() Value { + return v +} + func makeValue(v ref) Value { return Value{ref: v} } @@ -38,6 +51,9 @@ func predefValue(id uint32) Value { } func floatValue(f float64) Value { + if f == 0 { + return valueZero + } if f != f { return valueNaN } @@ -56,8 +72,9 @@ func (e Error) Error() string { } var ( + valueUndefined = Value{ref: 0} valueNaN = predefValue(0) - valueUndefined = predefValue(1) + valueZero = predefValue(1) valueNull = predefValue(2) valueTrue = predefValue(3) valueFalse = predefValue(4) @@ -90,21 +107,21 @@ func Global() Value { // | ---------------------- | ---------------------- | // | js.Value | [its value] | // | js.TypedArray | typed array | -// | js.Callback | function | +// | js.Func | function | // | nil | null | // | bool | boolean | // | integers and floats | number | // | string | string | // | []interface{} | new array | // | map[string]interface{} | new object | +// +// Panics if x is not one of the expected types. func ValueOf(x interface{}) Value { switch x := x.(type) { - case Value: + case Value: // should precede Wrapper to avoid a loop return x - case TypedArray: - return x.Value - case Callback: - return x.Value + case Wrapper: + return x.JSValue() case nil: return valueNull case bool: @@ -318,13 +335,18 @@ func (v Value) New(args ...interface{}) Value { func valueNew(v ref, args []ref) (ref, bool) func (v Value) isNumber() bool { - return v.ref>>32&nanHead != nanHead || v.ref == valueNaN.ref + return v.ref == valueZero.ref || + v.ref == valueNaN.ref || + (v.ref != valueUndefined.ref && v.ref>>32&nanHead != nanHead) } func (v Value) float(method string) float64 { if !v.isNumber() { panic(&ValueError{method, v.Type()}) } + if v.ref == valueZero.ref { + return 0 + } return *(*float64)(unsafe.Pointer(&v.ref)) } @@ -350,6 +372,26 @@ func (v Value) Bool() bool { } } +// Truthy returns the JavaScript "truthiness" of the value v. In JavaScript, +// false, 0, "", null, undefined, and NaN are "falsy", and everything else is +// "truthy". See https://developer.mozilla.org/en-US/docs/Glossary/Truthy. +func (v Value) Truthy() bool { + switch v.Type() { + case TypeUndefined, TypeNull: + return false + case TypeBoolean: + return v.Bool() + case TypeNumber: + return v.ref != valueNaN.ref && v.ref != valueZero.ref + case TypeString: + return v.String() != "" + case TypeSymbol, TypeFunction, TypeObject: + return true + default: + panic("bad type") + } +} + // String returns the value v converted to string according to JavaScript type conversions. func (v Value) String() string { str, length := valuePrepareString(v.ref) diff --git a/libgo/go/syscall/js/js_test.go b/libgo/go/syscall/js/js_test.go index 9cc931a31d3..c14d2cc24c9 100644 --- a/libgo/go/syscall/js/js_test.go +++ b/libgo/go/syscall/js/js_test.go @@ -4,6 +4,15 @@ // +build js,wasm +// To run these tests: +// +// - Install Node +// - Add /path/to/go/misc/wasm to your $PATH (so that "go test" can find +// "go_js_wasm_exec"). +// - GOOS=js GOARCH=wasm go test +// +// See -exec in "go help test", and "go help run" for details. + package js_test import ( @@ -19,10 +28,19 @@ var dummys = js.Global().Call("eval", `({ someInt: 42, someFloat: 42.123, someArray: [41, 42, 43], + someDate: new Date(), add: function(a, b) { return a + b; }, + zero: 0, + stringZero: "0", NaN: NaN, + emptyObj: {}, + emptyArray: [], + Infinity: Infinity, + NegInfinity: -Infinity, + objNumber0: new Number(0), + objBooleanFalse: new Boolean(false), })`) func TestBool(t *testing.T) { @@ -74,6 +92,9 @@ func TestInt(t *testing.T) { if dummys.Get("someInt") != dummys.Get("someInt") { t.Errorf("same value not equal") } + if got := dummys.Get("zero").Int(); got != 0 { + t.Errorf("got %#v, want %#v", got, 0) + } } func TestIntConversion(t *testing.T) { @@ -237,6 +258,9 @@ func TestType(t *testing.T) { if got, want := js.ValueOf(true).Type(), js.TypeBoolean; got != want { t.Errorf("got %s, want %s", got, want) } + if got, want := js.ValueOf(0).Type(), js.TypeNumber; got != want { + t.Errorf("got %s, want %s", got, want) + } if got, want := js.ValueOf(42).Type(), js.TypeNumber; got != want { t.Errorf("got %s, want %s", got, want) } @@ -269,51 +293,89 @@ func TestValueOf(t *testing.T) { } } -func TestCallback(t *testing.T) { +func TestZeroValue(t *testing.T) { + var v js.Value + if v != js.Undefined() { + t.Error("zero js.Value is not js.Undefined()") + } +} + +func TestFuncOf(t *testing.T) { c := make(chan struct{}) - cb := js.NewCallback(func(args []js.Value) { + cb := js.FuncOf(func(this js.Value, args []js.Value) interface{} { if got := args[0].Int(); got != 42 { t.Errorf("got %#v, want %#v", got, 42) } c <- struct{}{} + return nil }) defer cb.Release() js.Global().Call("setTimeout", cb, 0, 42) <-c } -func TestEventCallback(t *testing.T) { - for _, name := range []string{"preventDefault", "stopPropagation", "stopImmediatePropagation"} { - c := make(chan struct{}) - var flags js.EventCallbackFlag - switch name { - case "preventDefault": - flags = js.PreventDefault - case "stopPropagation": - flags = js.StopPropagation - case "stopImmediatePropagation": - flags = js.StopImmediatePropagation - } - cb := js.NewEventCallback(flags, func(event js.Value) { - c <- struct{}{} +func TestInvokeFunction(t *testing.T) { + called := false + cb := js.FuncOf(func(this js.Value, args []js.Value) interface{} { + cb2 := js.FuncOf(func(this js.Value, args []js.Value) interface{} { + called = true + return 42 }) - defer cb.Release() - - event := js.Global().Call("eval", fmt.Sprintf("({ called: false, %s: function() { this.called = true; } })", name)) - cb.Invoke(event) - if !event.Get("called").Bool() { - t.Errorf("%s not called", name) - } - - <-c + defer cb2.Release() + return cb2.Invoke() + }) + defer cb.Release() + if got := cb.Invoke().Int(); got != 42 { + t.Errorf("got %#v, want %#v", got, 42) + } + if !called { + t.Error("function not called") } } -func ExampleNewCallback() { - var cb js.Callback - cb = js.NewCallback(func(args []js.Value) { +func ExampleFuncOf() { + var cb js.Func + cb = js.FuncOf(func(this js.Value, args []js.Value) interface{} { fmt.Println("button clicked") - cb.Release() // release the callback if the button will not be clicked again + cb.Release() // release the function if the button will not be clicked again + return nil }) js.Global().Get("document").Call("getElementById", "myButton").Call("addEventListener", "click", cb) } + +// See +// - https://developer.mozilla.org/en-US/docs/Glossary/Truthy +// - https://stackoverflow.com/questions/19839952/all-falsey-values-in-javascript/19839953#19839953 +// - http://www.ecma-international.org/ecma-262/5.1/#sec-9.2 +func TestTruthy(t *testing.T) { + want := true + for _, key := range []string{ + "someBool", "someString", "someInt", "someFloat", "someArray", "someDate", + "stringZero", // "0" is truthy + "add", // functions are truthy + "emptyObj", "emptyArray", "Infinity", "NegInfinity", + // All objects are truthy, even if they're Number(0) or Boolean(false). + "objNumber0", "objBooleanFalse", + } { + if got := dummys.Get(key).Truthy(); got != want { + t.Errorf("%s: got %#v, want %#v", key, got, want) + } + } + + want = false + if got := dummys.Get("zero").Truthy(); got != want { + t.Errorf("got %#v, want %#v", got, want) + } + if got := dummys.Get("NaN").Truthy(); got != want { + t.Errorf("got %#v, want %#v", got, want) + } + if got := js.ValueOf("").Truthy(); got != want { + t.Errorf("got %#v, want %#v", got, want) + } + if got := js.Null().Truthy(); got != want { + t.Errorf("got %#v, want %#v", got, want) + } + if got := js.Undefined().Truthy(); got != want { + t.Errorf("got %#v, want %#v", got, want) + } +} diff --git a/libgo/go/syscall/js/typedarray.go b/libgo/go/syscall/js/typedarray.go index afa15488ec7..aa56cf69f3c 100644 --- a/libgo/go/syscall/js/typedarray.go +++ b/libgo/go/syscall/js/typedarray.go @@ -22,6 +22,8 @@ var ( float64Array = Global().Get("Float64Array") ) +var _ Wrapper = TypedArray{} // TypedArray must implement Wrapper + // TypedArray represents a JavaScript typed array. type TypedArray struct { Value diff --git a/libgo/go/syscall/mkasm_darwin.go b/libgo/go/syscall/mkasm_darwin.go new file mode 100644 index 00000000000..f6f75f99f6b --- /dev/null +++ b/libgo/go/syscall/mkasm_darwin.go @@ -0,0 +1,58 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +// mkasm_darwin.go generates assembly trampolines to call libSystem routines from Go. +//This program must be run after mksyscall.pl. +package main + +import ( + "bytes" + "fmt" + "io/ioutil" + "log" + "os" + "strings" +) + +func main() { + in1, err := ioutil.ReadFile("syscall_darwin.go") + if err != nil { + log.Fatalf("can't open syscall_darwin.go: %s", err) + } + arch := os.Args[1] + in2, err := ioutil.ReadFile(fmt.Sprintf("syscall_darwin_%s.go", arch)) + if err != nil { + log.Fatalf("can't open syscall_darwin_%s.go: %s", arch, err) + } + in3, err := ioutil.ReadFile(fmt.Sprintf("zsyscall_darwin_%s.go", arch)) + if err != nil { + log.Fatalf("can't open zsyscall_darwin_%s.go: %s", arch, err) + } + in := string(in1) + string(in2) + string(in3) + + trampolines := map[string]bool{} + + var out bytes.Buffer + + fmt.Fprintf(&out, "// go run mkasm_darwin.go %s\n", strings.Join(os.Args[1:], " ")) + fmt.Fprintf(&out, "// Code generated by the command above; DO NOT EDIT.\n") + fmt.Fprintf(&out, "#include \"textflag.h\"\n") + for _, line := range strings.Split(in, "\n") { + if !strings.HasPrefix(line, "func ") || !strings.HasSuffix(line, "_trampoline()") { + continue + } + fn := line[5 : len(line)-13] + if !trampolines[fn] { + trampolines[fn] = true + fmt.Fprintf(&out, "TEXT ·%s_trampoline(SB),NOSPLIT,$0-0\n", fn) + fmt.Fprintf(&out, "\tJMP\t%s(SB)\n", fn) + } + } + err = ioutil.WriteFile(fmt.Sprintf("zsyscall_darwin_%s.s", arch), out.Bytes(), 0644) + if err != nil { + log.Fatalf("can't write zsyscall_darwin_%s.s: %s", arch, err) + } +} diff --git a/libgo/go/syscall/net.go b/libgo/go/syscall/net.go index 272d3afc387..531fa80d8f1 100644 --- a/libgo/go/syscall/net.go +++ b/libgo/go/syscall/net.go @@ -26,7 +26,7 @@ type RawConn interface { Write(f func(fd uintptr) (done bool)) error } -// Conn is implemented by some types in the net package to provide +// Conn is implemented by some types in the net and os packages to provide // access to the underlying file descriptor or handle. type Conn interface { // SyscallConn returns a raw network connection. diff --git a/libgo/go/syscall/route_freebsd.go b/libgo/go/syscall/route_freebsd.go index 2c2de7474a4..2b47faff429 100644 --- a/libgo/go/syscall/route_freebsd.go +++ b/libgo/go/syscall/route_freebsd.go @@ -6,11 +6,7 @@ package syscall import "unsafe" -// See http://www.freebsd.org/doc/en/books/porters-handbook/freebsd-versions.html. -var freebsdVersion uint32 - func init() { - freebsdVersion, _ = SysctlUint32("kern.osreldate") conf, _ := Sysctl("kern.conftxt") for i, j := 0, 0; j < len(conf); j++ { if conf[j] != '\n' { diff --git a/libgo/go/syscall/route_freebsd_32bit.go b/libgo/go/syscall/route_freebsd_32bit.go index ec6f6b7f8bc..aed8682237a 100644 --- a/libgo/go/syscall/route_freebsd_32bit.go +++ b/libgo/go/syscall/route_freebsd_32bit.go @@ -22,7 +22,7 @@ func (any *anyMessage) parseInterfaceMessage(b []byte) *InterfaceMessage { // FreeBSD 10 and beyond have a restructured mbuf // packet header view. // See https://svnweb.freebsd.org/base?view=revision&revision=254804. - if freebsdVersion >= 1000000 { + if supportsABI(1000000) { m := (*ifMsghdr)(unsafe.Pointer(any)) p.Header.Data.Hwassist = uint32(m.Data.Hwassist) p.Header.Data.Epoch = m.Data.Epoch diff --git a/libgo/go/syscall/sockcmsg_unix.go b/libgo/go/syscall/sockcmsg_unix.go index c01602f718a..53082a2d5b6 100644 --- a/libgo/go/syscall/sockcmsg_unix.go +++ b/libgo/go/syscall/sockcmsg_unix.go @@ -16,17 +16,22 @@ import ( // Round the length of a raw sockaddr up to align it properly. func cmsgAlignOf(salen int) int { salign := int(sizeofPtr) - // NOTE: It seems like 64-bit Darwin, DragonFly BSD and - // Solaris kernels still require 32-bit aligned access to - // network subsystem. - if darwin64Bit || dragonfly64Bit || solaris64Bit { - salign = 4 - } - // NOTE: Solaris always uses 32-bit alignment, - // cf. _CMSG_DATA_ALIGNMENT in . - if runtime.GOOS == "solaris" { - salign = 4 + + switch runtime.GOOS { + case "darwin", "dragonfly", "solaris": + // NOTE: It seems like 64-bit Darwin, DragonFly BSD and + // Solaris kernels still require 32-bit aligned access to + // network subsystem. + if sizeofPtr == 8 { + salign = 4 + } + case "openbsd": + // OpenBSD armv7 requires 64-bit alignment. + if runtime.GOARCH == "arm" { + salign = 8 + } } + return (salen + salign - 1) & ^(salign - 1) } diff --git a/libgo/go/syscall/syscall_freebsd.go b/libgo/go/syscall/syscall_freebsd.go index c67550a011d..e48dc8f9844 100644 --- a/libgo/go/syscall/syscall_freebsd.go +++ b/libgo/go/syscall/syscall_freebsd.go @@ -4,7 +4,34 @@ package syscall -import "unsafe" +import ( + "sync" + "unsafe" +) + +const ( + _SYS_FSTAT_FREEBSD12 = 551 // { int fstat(int fd, _Out_ struct stat *sb); } + _SYS_FSTATAT_FREEBSD12 = 552 // { int fstatat(int fd, _In_z_ char *path, \ + _SYS_GETDIRENTRIES_FREEBSD12 = 554 // { ssize_t getdirentries(int fd, \ + _SYS_STATFS_FREEBSD12 = 555 // { int statfs(_In_z_ char *path, \ + _SYS_FSTATFS_FREEBSD12 = 556 // { int fstatfs(int fd, \ + _SYS_GETFSSTAT_FREEBSD12 = 557 // { int getfsstat( \ + _SYS_MKNODAT_FREEBSD12 = 559 // { int mknodat(int fd, _In_z_ char *path, \ +) + +// See https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/versions.html. +var ( + osreldateOnce sync.Once + osreldate uint32 +) + +// INO64_FIRST from /usr/src/lib/libc/sys/compat-ino64.h +const _ino64First = 1200031 + +func supportsABI(ver uint32) bool { + osreldateOnce.Do(func() { osreldate, _ = SysctlUint32("kern.osreldate") }) + return osreldate >= ver +} func direntIno(buf []byte) (uint64, bool) { return readInt(buf, unsafe.Offsetof(Dirent{}.Fileno), unsafe.Sizeof(Dirent{}.Fileno)) diff --git a/libgo/go/syscall/syscall_freebsd_test.go b/libgo/go/syscall/syscall_freebsd_test.go new file mode 100644 index 00000000000..3ccfe5d463f --- /dev/null +++ b/libgo/go/syscall/syscall_freebsd_test.go @@ -0,0 +1,54 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build freebsd + +package syscall_test + +import ( + "fmt" + "syscall" + "testing" + "unsafe" +) + +func TestConvertFromDirent11(t *testing.T) { + const ( + filenameFmt = "%04d" + numFiles = 64 + fixedHdrSize = int(unsafe.Offsetof(syscall.Dirent_freebsd11{}.Name)) + ) + + namlen := len(fmt.Sprintf(filenameFmt, 0)) + reclen := syscall.Roundup(fixedHdrSize+namlen+1, 4) + old := make([]byte, numFiles*reclen) + for i := 0; i < numFiles; i++ { + dent := syscall.Dirent_freebsd11{ + Fileno: uint32(i + 1), + Reclen: uint16(reclen), + Type: syscall.DT_REG, + Namlen: uint8(namlen), + } + rec := make([]byte, reclen) + copy(rec, (*[fixedHdrSize]byte)(unsafe.Pointer(&dent))[:]) + copy(rec[fixedHdrSize:], fmt.Sprintf(filenameFmt, i+1)) + copy(old[i*reclen:], rec) + } + + buf := make([]byte, 2*len(old)) + n := syscall.ConvertFromDirents11(buf, old) + + names := make([]string, 0, numFiles) + _, _, names = syscall.ParseDirent(buf[:n], -1, names) + + if len(names) != numFiles { + t.Errorf("expected %d files, have %d; names: %q", numFiles, len(names), names) + } + + for i, name := range names { + if expected := fmt.Sprintf(filenameFmt, i+1); name != expected { + t.Errorf("expected names[%d] to be %q; got %q", i, expected, name) + } + } +} diff --git a/libgo/go/syscall/syscall_js.go b/libgo/go/syscall/syscall_js.go index 6822eec8359..2e1a9ec9f1f 100644 --- a/libgo/go/syscall/syscall_js.go +++ b/libgo/go/syscall/syscall_js.go @@ -74,6 +74,7 @@ const ( SIGKILL SIGTRAP SIGQUIT + SIGTERM ) func (s Signal) Signal() {} diff --git a/libgo/go/syscall/syscall_linux_test.go b/libgo/go/syscall/syscall_linux_test.go index 77a822d97e7..261ca155dcd 100644 --- a/libgo/go/syscall/syscall_linux_test.go +++ b/libgo/go/syscall/syscall_linux_test.go @@ -19,6 +19,7 @@ import ( "syscall" "testing" "time" + "unsafe" ) // chtmpdir changes the working directory to a new temporary directory and @@ -294,7 +295,7 @@ func TestSyscallNoError(t *testing.T) { // On Linux there are currently no syscalls which don't fail and return // a value larger than 0xfffffffffffff001 so we could test RawSyscall // vs. RawSyscallNoError on 64bit architectures. - if runtime.GOARCH != "386" && runtime.GOARCH != "arm" { + if unsafe.Sizeof(uintptr(0)) != 4 { t.Skip("skipping on non-32bit architecture") } @@ -306,6 +307,10 @@ func TestSyscallNoError(t *testing.T) { t.Skip("skipping because there is no geteuid system call") } + if runtime.GOOS == "android" { + t.Skip("skipping on rooted android, see issue 27364") + } + // Copy the test binary to a location that a non-root user can read/execute // after we drop privileges tempDir, err := ioutil.TempDir("", "TestSyscallNoError") diff --git a/libgo/go/syscall/syscall_unix_test.go b/libgo/go/syscall/syscall_unix_test.go index 637aece4395..085afb29411 100644 --- a/libgo/go/syscall/syscall_unix_test.go +++ b/libgo/go/syscall/syscall_unix_test.go @@ -315,6 +315,12 @@ func TestRlimit(t *testing.T) { } set := rlimit set.Cur = set.Max - 1 + if runtime.GOOS == "darwin" && set.Cur > 10240 { + // The max file limit is 10240, even though + // the max returned by Getrlimit is 1<<63-1. + // This is OPEN_MAX in sys/syslimits.h. + set.Cur = 10240 + } err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &set) if err != nil { t.Fatalf("Setrlimit: set failed: %#v %v", set, err) @@ -326,15 +332,11 @@ func TestRlimit(t *testing.T) { } set = rlimit set.Cur = set.Max - 1 + if runtime.GOOS == "darwin" && set.Cur > 10240 { + set.Cur = 10240 + } if set != get { - // Seems like Darwin requires some privilege to - // increase the soft limit of rlimit sandbox, though - // Setrlimit never reports an error. - switch runtime.GOOS { - case "darwin": - default: - t.Fatalf("Rlimit: change failed: wanted %#v got %#v", set, get) - } + t.Fatalf("Rlimit: change failed: wanted %#v got %#v", set, get) } err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlimit) if err != nil { diff --git a/libgo/go/testdata/Isaac.Newton-Opticks.txt b/libgo/go/testdata/Isaac.Newton-Opticks.txt new file mode 100644 index 00000000000..15bb4c54d0b --- /dev/null +++ b/libgo/go/testdata/Isaac.Newton-Opticks.txt @@ -0,0 +1,9286 @@ +Produced by Suzanne Lybarger, steve harris, Josephine +Paolucci and the Online Distributed Proofreading Team at +http://www.pgdp.net. + + + + + + +OPTICKS: + +OR, A + +TREATISE + +OF THE + +_Reflections_, _Refractions_, +_Inflections_ and _Colours_ + +OF + +LIGHT. + +_The_ FOURTH EDITION, _corrected_. + +By Sir _ISAAC NEWTON_, Knt. + +LONDON: + +Printed for WILLIAM INNYS at the West-End of St. _Paul's_. MDCCXXX. + +TITLE PAGE OF THE 1730 EDITION + + + + +SIR ISAAC NEWTON'S ADVERTISEMENTS + + + + +Advertisement I + + +_Part of the ensuing Discourse about Light was written at the Desire of +some Gentlemen of the_ Royal-Society, _in the Year 1675, and then sent +to their Secretary, and read at their Meetings, and the rest was added +about twelve Years after to complete the Theory; except the third Book, +and the last Proposition of the Second, which were since put together +out of scatter'd Papers. To avoid being engaged in Disputes about these +Matters, I have hitherto delayed the printing, and should still have +delayed it, had not the Importunity of Friends prevailed upon me. If any +other Papers writ on this Subject are got out of my Hands they are +imperfect, and were perhaps written before I had tried all the +Experiments here set down, and fully satisfied my self about the Laws of +Refractions and Composition of Colours. I have here publish'd what I +think proper to come abroad, wishing that it may not be translated into +another Language without my Consent._ + +_The Crowns of Colours, which sometimes appear about the Sun and Moon, I +have endeavoured to give an Account of; but for want of sufficient +Observations leave that Matter to be farther examined. The Subject of +the Third Book I have also left imperfect, not having tried all the +Experiments which I intended when I was about these Matters, nor +repeated some of those which I did try, until I had satisfied my self +about all their Circumstances. To communicate what I have tried, and +leave the rest to others for farther Enquiry, is all my Design in +publishing these Papers._ + +_In a Letter written to Mr._ Leibnitz _in the year 1679, and published +by Dr._ Wallis, _I mention'd a Method by which I had found some general +Theorems about squaring Curvilinear Figures, or comparing them with the +Conic Sections, or other the simplest Figures with which they may be +compared. And some Years ago I lent out a Manuscript containing such +Theorems, and having since met with some Things copied out of it, I have +on this Occasion made it publick, prefixing to it an_ Introduction, _and +subjoining a_ Scholium _concerning that Method. And I have joined with +it another small Tract concerning the Curvilinear Figures of the Second +Kind, which was also written many Years ago, and made known to some +Friends, who have solicited the making it publick._ + + _I. N._ + +April 1, 1704. + + +Advertisement II + +_In this Second Edition of these Opticks I have omitted the Mathematical +Tracts publish'd at the End of the former Edition, as not belonging to +the Subject. And at the End of the Third Book I have added some +Questions. And to shew that I do not take Gravity for an essential +Property of Bodies, I have added one Question concerning its Cause, +chusing to propose it by way of a Question, because I am not yet +satisfied about it for want of Experiments._ + + _I. N._ + +July 16, 1717. + + +Advertisement to this Fourth Edition + +_This new Edition of Sir_ Isaac Newton's Opticks _is carefully printed +from the Third Edition, as it was corrected by the Author's own Hand, +and left before his Death with the Bookseller. Since Sir_ Isaac's +Lectiones Opticæ, _which he publickly read in the University of_ +Cambridge _in the Years 1669, 1670, and 1671, are lately printed, it has +been thought proper to make at the bottom of the Pages several Citations +from thence, where may be found the Demonstrations, which the Author +omitted in these_ Opticks. + + * * * * * + +Transcriber's Note: There are several greek letters used in the +descriptions of the illustrations. They are signified by [Greek: +letter]. Square roots are noted by the letters sqrt before the equation. + + * * * * * + +THE FIRST BOOK OF OPTICKS + + + + +_PART I._ + + +My Design in this Book is not to explain the Properties of Light by +Hypotheses, but to propose and prove them by Reason and Experiments: In +order to which I shall premise the following Definitions and Axioms. + + + + +_DEFINITIONS_ + + +DEFIN. I. + +_By the Rays of Light I understand its least Parts, and those as well +Successive in the same Lines, as Contemporary in several Lines._ For it +is manifest that Light consists of Parts, both Successive and +Contemporary; because in the same place you may stop that which comes +one moment, and let pass that which comes presently after; and in the +same time you may stop it in any one place, and let it pass in any +other. For that part of Light which is stopp'd cannot be the same with +that which is let pass. The least Light or part of Light, which may be +stopp'd alone without the rest of the Light, or propagated alone, or do +or suffer any thing alone, which the rest of the Light doth not or +suffers not, I call a Ray of Light. + + +DEFIN. II. + +_Refrangibility of the Rays of Light, is their Disposition to be +refracted or turned out of their Way in passing out of one transparent +Body or Medium into another. And a greater or less Refrangibility of +Rays, is their Disposition to be turned more or less out of their Way in +like Incidences on the same Medium._ Mathematicians usually consider the +Rays of Light to be Lines reaching from the luminous Body to the Body +illuminated, and the refraction of those Rays to be the bending or +breaking of those lines in their passing out of one Medium into another. +And thus may Rays and Refractions be considered, if Light be propagated +in an instant. But by an Argument taken from the Æquations of the times +of the Eclipses of _Jupiter's Satellites_, it seems that Light is +propagated in time, spending in its passage from the Sun to us about +seven Minutes of time: And therefore I have chosen to define Rays and +Refractions in such general terms as may agree to Light in both cases. + + +DEFIN. III. + +_Reflexibility of Rays, is their Disposition to be reflected or turned +back into the same Medium from any other Medium upon whose Surface they +fall. And Rays are more or less reflexible, which are turned back more +or less easily._ As if Light pass out of a Glass into Air, and by being +inclined more and more to the common Surface of the Glass and Air, +begins at length to be totally reflected by that Surface; those sorts of +Rays which at like Incidences are reflected most copiously, or by +inclining the Rays begin soonest to be totally reflected, are most +reflexible. + + +DEFIN. IV. + +_The Angle of Incidence is that Angle, which the Line described by the +incident Ray contains with the Perpendicular to the reflecting or +refracting Surface at the Point of Incidence._ + + +DEFIN. V. + +_The Angle of Reflexion or Refraction, is the Angle which the line +described by the reflected or refracted Ray containeth with the +Perpendicular to the reflecting or refracting Surface at the Point of +Incidence._ + + +DEFIN. VI. + +_The Sines of Incidence, Reflexion, and Refraction, are the Sines of the +Angles of Incidence, Reflexion, and Refraction._ + + +DEFIN. VII + +_The Light whose Rays are all alike Refrangible, I call Simple, +Homogeneal and Similar; and that whose Rays are some more Refrangible +than others, I call Compound, Heterogeneal and Dissimilar._ The former +Light I call Homogeneal, not because I would affirm it so in all +respects, but because the Rays which agree in Refrangibility, agree at +least in all those their other Properties which I consider in the +following Discourse. + + +DEFIN. VIII. + +_The Colours of Homogeneal Lights, I call Primary, Homogeneal and +Simple; and those of Heterogeneal Lights, Heterogeneal and Compound._ +For these are always compounded of the colours of Homogeneal Lights; as +will appear in the following Discourse. + + + + +_AXIOMS._ + + +AX. I. + +_The Angles of Reflexion and Refraction, lie in one and the same Plane +with the Angle of Incidence._ + + +AX. II. + +_The Angle of Reflexion is equal to the Angle of Incidence._ + + +AX. III. + +_If the refracted Ray be returned directly back to the Point of +Incidence, it shall be refracted into the Line before described by the +incident Ray._ + + +AX. IV. + +_Refraction out of the rarer Medium into the denser, is made towards the +Perpendicular; that is, so that the Angle of Refraction be less than the +Angle of Incidence._ + + +AX. V. + +_The Sine of Incidence is either accurately or very nearly in a given +Ratio to the Sine of Refraction._ + +Whence if that Proportion be known in any one Inclination of the +incident Ray, 'tis known in all the Inclinations, and thereby the +Refraction in all cases of Incidence on the same refracting Body may be +determined. Thus if the Refraction be made out of Air into Water, the +Sine of Incidence of the red Light is to the Sine of its Refraction as 4 +to 3. If out of Air into Glass, the Sines are as 17 to 11. In Light of +other Colours the Sines have other Proportions: but the difference is so +little that it need seldom be considered. + +[Illustration: FIG. 1] + +Suppose therefore, that RS [in _Fig._ 1.] represents the Surface of +stagnating Water, and that C is the point of Incidence in which any Ray +coming in the Air from A in the Line AC is reflected or refracted, and I +would know whither this Ray shall go after Reflexion or Refraction: I +erect upon the Surface of the Water from the point of Incidence the +Perpendicular CP and produce it downwards to Q, and conclude by the +first Axiom, that the Ray after Reflexion and Refraction, shall be +found somewhere in the Plane of the Angle of Incidence ACP produced. I +let fall therefore upon the Perpendicular CP the Sine of Incidence AD; +and if the reflected Ray be desired, I produce AD to B so that DB be +equal to AD, and draw CB. For this Line CB shall be the reflected Ray; +the Angle of Reflexion BCP and its Sine BD being equal to the Angle and +Sine of Incidence, as they ought to be by the second Axiom, But if the +refracted Ray be desired, I produce AD to H, so that DH may be to AD as +the Sine of Refraction to the Sine of Incidence, that is, (if the Light +be red) as 3 to 4; and about the Center C and in the Plane ACP with the +Radius CA describing a Circle ABE, I draw a parallel to the +Perpendicular CPQ, the Line HE cutting the Circumference in E, and +joining CE, this Line CE shall be the Line of the refracted Ray. For if +EF be let fall perpendicularly on the Line PQ, this Line EF shall be the +Sine of Refraction of the Ray CE, the Angle of Refraction being ECQ; and +this Sine EF is equal to DH, and consequently in Proportion to the Sine +of Incidence AD as 3 to 4. + +In like manner, if there be a Prism of Glass (that is, a Glass bounded +with two Equal and Parallel Triangular ends, and three plain and well +polished Sides, which meet in three Parallel Lines running from the +three Angles of one end to the three Angles of the other end) and if the +Refraction of the Light in passing cross this Prism be desired: Let ACB +[in _Fig._ 2.] represent a Plane cutting this Prism transversly to its +three Parallel lines or edges there where the Light passeth through it, +and let DE be the Ray incident upon the first side of the Prism AC where +the Light goes into the Glass; and by putting the Proportion of the Sine +of Incidence to the Sine of Refraction as 17 to 11 find EF the first +refracted Ray. Then taking this Ray for the Incident Ray upon the second +side of the Glass BC where the Light goes out, find the next refracted +Ray FG by putting the Proportion of the Sine of Incidence to the Sine of +Refraction as 11 to 17. For if the Sine of Incidence out of Air into +Glass be to the Sine of Refraction as 17 to 11, the Sine of Incidence +out of Glass into Air must on the contrary be to the Sine of Refraction +as 11 to 17, by the third Axiom. + +[Illustration: FIG. 2.] + +Much after the same manner, if ACBD [in _Fig._ 3.] represent a Glass +spherically convex on both sides (usually called a _Lens_, such as is a +Burning-glass, or Spectacle-glass, or an Object-glass of a Telescope) +and it be required to know how Light falling upon it from any lucid +point Q shall be refracted, let QM represent a Ray falling upon any +point M of its first spherical Surface ACB, and by erecting a +Perpendicular to the Glass at the point M, find the first refracted Ray +MN by the Proportion of the Sines 17 to 11. Let that Ray in going out of +the Glass be incident upon N, and then find the second refracted Ray +N_q_ by the Proportion of the Sines 11 to 17. And after the same manner +may the Refraction be found when the Lens is convex on one side and +plane or concave on the other, or concave on both sides. + +[Illustration: FIG. 3.] + + +AX. VI. + +_Homogeneal Rays which flow from several Points of any Object, and fall +perpendicularly or almost perpendicularly on any reflecting or +refracting Plane or spherical Surface, shall afterwards diverge from so +many other Points, or be parallel to so many other Lines, or converge to +so many other Points, either accurately or without any sensible Error. +And the same thing will happen, if the Rays be reflected or refracted +successively by two or three or more Plane or Spherical Surfaces._ + +The Point from which Rays diverge or to which they converge may be +called their _Focus_. And the Focus of the incident Rays being given, +that of the reflected or refracted ones may be found by finding the +Refraction of any two Rays, as above; or more readily thus. + +_Cas._ 1. Let ACB [in _Fig._ 4.] be a reflecting or refracting Plane, +and Q the Focus of the incident Rays, and Q_q_C a Perpendicular to that +Plane. And if this Perpendicular be produced to _q_, so that _q_C be +equal to QC, the Point _q_ shall be the Focus of the reflected Rays: Or +if _q_C be taken on the same side of the Plane with QC, and in +proportion to QC as the Sine of Incidence to the Sine of Refraction, the +Point _q_ shall be the Focus of the refracted Rays. + +[Illustration: FIG. 4.] + +_Cas._ 2. Let ACB [in _Fig._ 5.] be the reflecting Surface of any Sphere +whose Centre is E. Bisect any Radius thereof, (suppose EC) in T, and if +in that Radius on the same side the Point T you take the Points Q and +_q_, so that TQ, TE, and T_q_, be continual Proportionals, and the Point +Q be the Focus of the incident Rays, the Point _q_ shall be the Focus of +the reflected ones. + +[Illustration: FIG. 5.] + +_Cas._ 3. Let ACB [in _Fig._ 6.] be the refracting Surface of any Sphere +whose Centre is E. In any Radius thereof EC produced both ways take ET +and C_t_ equal to one another and severally in such Proportion to that +Radius as the lesser of the Sines of Incidence and Refraction hath to +the difference of those Sines. And then if in the same Line you find any +two Points Q and _q_, so that TQ be to ET as E_t_ to _tq_, taking _tq_ +the contrary way from _t_ which TQ lieth from T, and if the Point Q be +the Focus of any incident Rays, the Point _q_ shall be the Focus of the +refracted ones. + +[Illustration: FIG. 6.] + +And by the same means the Focus of the Rays after two or more Reflexions +or Refractions may be found. + +[Illustration: FIG. 7.] + +_Cas._ 4. Let ACBD [in _Fig._ 7.] be any refracting Lens, spherically +Convex or Concave or Plane on either side, and let CD be its Axis (that +is, the Line which cuts both its Surfaces perpendicularly, and passes +through the Centres of the Spheres,) and in this Axis produced let F and +_f_ be the Foci of the refracted Rays found as above, when the incident +Rays on both sides the Lens are parallel to the same Axis; and upon the +Diameter F_f_ bisected in E, describe a Circle. Suppose now that any +Point Q be the Focus of any incident Rays. Draw QE cutting the said +Circle in T and _t_, and therein take _tq_ in such proportion to _t_E as +_t_E or TE hath to TQ. Let _tq_ lie the contrary way from _t_ which TQ +doth from T, and _q_ shall be the Focus of the refracted Rays without +any sensible Error, provided the Point Q be not so remote from the Axis, +nor the Lens so broad as to make any of the Rays fall too obliquely on +the refracting Surfaces.[A] + +And by the like Operations may the reflecting or refracting Surfaces be +found when the two Foci are given, and thereby a Lens be formed, which +shall make the Rays flow towards or from what Place you please.[B] + +So then the Meaning of this Axiom is, that if Rays fall upon any Plane +or Spherical Surface or Lens, and before their Incidence flow from or +towards any Point Q, they shall after Reflexion or Refraction flow from +or towards the Point _q_ found by the foregoing Rules. And if the +incident Rays flow from or towards several points Q, the reflected or +refracted Rays shall flow from or towards so many other Points _q_ +found by the same Rules. Whether the reflected and refracted Rays flow +from or towards the Point _q_ is easily known by the situation of that +Point. For if that Point be on the same side of the reflecting or +refracting Surface or Lens with the Point Q, and the incident Rays flow +from the Point Q, the reflected flow towards the Point _q_ and the +refracted from it; and if the incident Rays flow towards Q, the +reflected flow from _q_, and the refracted towards it. And the contrary +happens when _q_ is on the other side of the Surface. + + +AX. VII. + +_Wherever the Rays which come from all the Points of any Object meet +again in so many Points after they have been made to converge by +Reflection or Refraction, there they will make a Picture of the Object +upon any white Body on which they fall._ + +So if PR [in _Fig._ 3.] represent any Object without Doors, and AB be a +Lens placed at a hole in the Window-shut of a dark Chamber, whereby the +Rays that come from any Point Q of that Object are made to converge and +meet again in the Point _q_; and if a Sheet of white Paper be held at +_q_ for the Light there to fall upon it, the Picture of that Object PR +will appear upon the Paper in its proper shape and Colours. For as the +Light which comes from the Point Q goes to the Point _q_, so the Light +which comes from other Points P and R of the Object, will go to so many +other correspondent Points _p_ and _r_ (as is manifest by the sixth +Axiom;) so that every Point of the Object shall illuminate a +correspondent Point of the Picture, and thereby make a Picture like the +Object in Shape and Colour, this only excepted, that the Picture shall +be inverted. And this is the Reason of that vulgar Experiment of casting +the Species of Objects from abroad upon a Wall or Sheet of white Paper +in a dark Room. + +In like manner, when a Man views any Object PQR, [in _Fig._ 8.] the +Light which comes from the several Points of the Object is so refracted +by the transparent skins and humours of the Eye, (that is, by the +outward coat EFG, called the _Tunica Cornea_, and by the crystalline +humour AB which is beyond the Pupil _mk_) as to converge and meet again +in so many Points in the bottom of the Eye, and there to paint the +Picture of the Object upon that skin (called the _Tunica Retina_) with +which the bottom of the Eye is covered. For Anatomists, when they have +taken off from the bottom of the Eye that outward and most thick Coat +called the _Dura Mater_, can then see through the thinner Coats, the +Pictures of Objects lively painted thereon. And these Pictures, +propagated by Motion along the Fibres of the Optick Nerves into the +Brain, are the cause of Vision. For accordingly as these Pictures are +perfect or imperfect, the Object is seen perfectly or imperfectly. If +the Eye be tinged with any colour (as in the Disease of the _Jaundice_) +so as to tinge the Pictures in the bottom of the Eye with that Colour, +then all Objects appear tinged with the same Colour. If the Humours of +the Eye by old Age decay, so as by shrinking to make the _Cornea_ and +Coat of the _Crystalline Humour_ grow flatter than before, the Light +will not be refracted enough, and for want of a sufficient Refraction +will not converge to the bottom of the Eye but to some place beyond it, +and by consequence paint in the bottom of the Eye a confused Picture, +and according to the Indistinctness of this Picture the Object will +appear confused. This is the reason of the decay of sight in old Men, +and shews why their Sight is mended by Spectacles. For those Convex +glasses supply the defect of plumpness in the Eye, and by increasing the +Refraction make the Rays converge sooner, so as to convene distinctly at +the bottom of the Eye if the Glass have a due degree of convexity. And +the contrary happens in short-sighted Men whose Eyes are too plump. For +the Refraction being now too great, the Rays converge and convene in the +Eyes before they come at the bottom; and therefore the Picture made in +the bottom and the Vision caused thereby will not be distinct, unless +the Object be brought so near the Eye as that the place where the +converging Rays convene may be removed to the bottom, or that the +plumpness of the Eye be taken off and the Refractions diminished by a +Concave-glass of a due degree of Concavity, or lastly that by Age the +Eye grow flatter till it come to a due Figure: For short-sighted Men see +remote Objects best in Old Age, and therefore they are accounted to have +the most lasting Eyes. + +[Illustration: FIG. 8.] + + +AX. VIII. + +_An Object seen by Reflexion or Refraction, appears in that place from +whence the Rays after their last Reflexion or Refraction diverge in +falling on the Spectator's Eye._ + +[Illustration: FIG. 9.] + +If the Object A [in FIG. 9.] be seen by Reflexion of a Looking-glass +_mn_, it shall appear, not in its proper place A, but behind the Glass +at _a_, from whence any Rays AB, AC, AD, which flow from one and the +same Point of the Object, do after their Reflexion made in the Points B, +C, D, diverge in going from the Glass to E, F, G, where they are +incident on the Spectator's Eyes. For these Rays do make the same +Picture in the bottom of the Eyes as if they had come from the Object +really placed at _a_ without the Interposition of the Looking-glass; and +all Vision is made according to the place and shape of that Picture. + +In like manner the Object D [in FIG. 2.] seen through a Prism, appears +not in its proper place D, but is thence translated to some other place +_d_ situated in the last refracted Ray FG drawn backward from F to _d_. + +[Illustration: FIG. 10.] + +And so the Object Q [in FIG. 10.] seen through the Lens AB, appears at +the place _q_ from whence the Rays diverge in passing from the Lens to +the Eye. Now it is to be noted, that the Image of the Object at _q_ is +so much bigger or lesser than the Object it self at Q, as the distance +of the Image at _q_ from the Lens AB is bigger or less than the distance +of the Object at Q from the same Lens. And if the Object be seen through +two or more such Convex or Concave-glasses, every Glass shall make a new +Image, and the Object shall appear in the place of the bigness of the +last Image. Which consideration unfolds the Theory of Microscopes and +Telescopes. For that Theory consists in almost nothing else than the +describing such Glasses as shall make the last Image of any Object as +distinct and large and luminous as it can conveniently be made. + +I have now given in Axioms and their Explications the sum of what hath +hitherto been treated of in Opticks. For what hath been generally +agreed on I content my self to assume under the notion of Principles, in +order to what I have farther to write. And this may suffice for an +Introduction to Readers of quick Wit and good Understanding not yet +versed in Opticks: Although those who are already acquainted with this +Science, and have handled Glasses, will more readily apprehend what +followeth. + +FOOTNOTES: + +[A] In our Author's _Lectiones Opticæ_, Part I. Sect. IV. Prop 29, 30, +there is an elegant Method of determining these _Foci_; not only in +spherical Surfaces, but likewise in any other curved Figure whatever: +And in Prop. 32, 33, the same thing is done for any Ray lying out of the +Axis. + +[B] _Ibid._ Prop. 34. + + + + +_PROPOSITIONS._ + + + +_PROP._ I. THEOR. I. + +_Lights which differ in Colour, differ also in Degrees of +Refrangibility._ + +The PROOF by Experiments. + +_Exper._ 1. + +I took a black oblong stiff Paper terminated by Parallel Sides, and with +a Perpendicular right Line drawn cross from one Side to the other, +distinguished it into two equal Parts. One of these parts I painted with +a red colour and the other with a blue. The Paper was very black, and +the Colours intense and thickly laid on, that the Phænomenon might be +more conspicuous. This Paper I view'd through a Prism of solid Glass, +whose two Sides through which the Light passed to the Eye were plane and +well polished, and contained an Angle of about sixty degrees; which +Angle I call the refracting Angle of the Prism. And whilst I view'd it, +I held it and the Prism before a Window in such manner that the Sides of +the Paper were parallel to the Prism, and both those Sides and the Prism +were parallel to the Horizon, and the cross Line was also parallel to +it: and that the Light which fell from the Window upon the Paper made an +Angle with the Paper, equal to that Angle which was made with the same +Paper by the Light reflected from it to the Eye. Beyond the Prism was +the Wall of the Chamber under the Window covered over with black Cloth, +and the Cloth was involved in Darkness that no Light might be reflected +from thence, which in passing by the Edges of the Paper to the Eye, +might mingle itself with the Light of the Paper, and obscure the +Phænomenon thereof. These things being thus ordered, I found that if the +refracting Angle of the Prism be turned upwards, so that the Paper may +seem to be lifted upwards by the Refraction, its blue half will be +lifted higher by the Refraction than its red half. But if the refracting +Angle of the Prism be turned downward, so that the Paper may seem to be +carried lower by the Refraction, its blue half will be carried something +lower thereby than its red half. Wherefore in both Cases the Light which +comes from the blue half of the Paper through the Prism to the Eye, does +in like Circumstances suffer a greater Refraction than the Light which +comes from the red half, and by consequence is more refrangible. + +_Illustration._ In the eleventh Figure, MN represents the Window, and DE +the Paper terminated with parallel Sides DJ and HE, and by the +transverse Line FG distinguished into two halfs, the one DG of an +intensely blue Colour, the other FE of an intensely red. And BAC_cab_ +represents the Prism whose refracting Planes AB_ba_ and AC_ca_ meet in +the Edge of the refracting Angle A_a_. This Edge A_a_ being upward, is +parallel both to the Horizon, and to the Parallel-Edges of the Paper DJ +and HE, and the transverse Line FG is perpendicular to the Plane of the +Window. And _de_ represents the Image of the Paper seen by Refraction +upwards in such manner, that the blue half DG is carried higher to _dg_ +than the red half FE is to _fe_, and therefore suffers a greater +Refraction. If the Edge of the refracting Angle be turned downward, the +Image of the Paper will be refracted downward; suppose to [Greek: de], +and the blue half will be refracted lower to [Greek: dg] than the red +half is to [Greek: pe]. + +[Illustration: FIG. 11.] + +_Exper._ 2. About the aforesaid Paper, whose two halfs were painted over +with red and blue, and which was stiff like thin Pasteboard, I lapped +several times a slender Thred of very black Silk, in such manner that +the several parts of the Thred might appear upon the Colours like so +many black Lines drawn over them, or like long and slender dark Shadows +cast upon them. I might have drawn black Lines with a Pen, but the +Threds were smaller and better defined. This Paper thus coloured and +lined I set against a Wall perpendicularly to the Horizon, so that one +of the Colours might stand to the Right Hand, and the other to the Left. +Close before the Paper, at the Confine of the Colours below, I placed a +Candle to illuminate the Paper strongly: For the Experiment was tried in +the Night. The Flame of the Candle reached up to the lower edge of the +Paper, or a very little higher. Then at the distance of six Feet, and +one or two Inches from the Paper upon the Floor I erected a Glass Lens +four Inches and a quarter broad, which might collect the Rays coming +from the several Points of the Paper, and make them converge towards so +many other Points at the same distance of six Feet, and one or two +Inches on the other side of the Lens, and so form the Image of the +coloured Paper upon a white Paper placed there, after the same manner +that a Lens at a Hole in a Window casts the Images of Objects abroad +upon a Sheet of white Paper in a dark Room. The aforesaid white Paper, +erected perpendicular to the Horizon, and to the Rays which fell upon it +from the Lens, I moved sometimes towards the Lens, sometimes from it, to +find the Places where the Images of the blue and red Parts of the +coloured Paper appeared most distinct. Those Places I easily knew by the +Images of the black Lines which I had made by winding the Silk about the +Paper. For the Images of those fine and slender Lines (which by reason +of their Blackness were like Shadows on the Colours) were confused and +scarce visible, unless when the Colours on either side of each Line were +terminated most distinctly, Noting therefore, as diligently as I could, +the Places where the Images of the red and blue halfs of the coloured +Paper appeared most distinct, I found that where the red half of the +Paper appeared distinct, the blue half appeared confused, so that the +black Lines drawn upon it could scarce be seen; and on the contrary, +where the blue half appeared most distinct, the red half appeared +confused, so that the black Lines upon it were scarce visible. And +between the two Places where these Images appeared distinct there was +the distance of an Inch and a half; the distance of the white Paper from +the Lens, when the Image of the red half of the coloured Paper appeared +most distinct, being greater by an Inch and an half than the distance of +the same white Paper from the Lens, when the Image of the blue half +appeared most distinct. In like Incidences therefore of the blue and red +upon the Lens, the blue was refracted more by the Lens than the red, so +as to converge sooner by an Inch and a half, and therefore is more +refrangible. + +_Illustration._ In the twelfth Figure (p. 27), DE signifies the coloured +Paper, DG the blue half, FE the red half, MN the Lens, HJ the white +Paper in that Place where the red half with its black Lines appeared +distinct, and _hi_ the same Paper in that Place where the blue half +appeared distinct. The Place _hi_ was nearer to the Lens MN than the +Place HJ by an Inch and an half. + +_Scholium._ The same Things succeed, notwithstanding that some of the +Circumstances be varied; as in the first Experiment when the Prism and +Paper are any ways inclined to the Horizon, and in both when coloured +Lines are drawn upon very black Paper. But in the Description of these +Experiments, I have set down such Circumstances, by which either the +Phænomenon might be render'd more conspicuous, or a Novice might more +easily try them, or by which I did try them only. The same Thing, I have +often done in the following Experiments: Concerning all which, this one +Admonition may suffice. Now from these Experiments it follows not, that +all the Light of the blue is more refrangible than all the Light of the +red: For both Lights are mixed of Rays differently refrangible, so that +in the red there are some Rays not less refrangible than those of the +blue, and in the blue there are some Rays not more refrangible than +those of the red: But these Rays, in proportion to the whole Light, are +but few, and serve to diminish the Event of the Experiment, but are not +able to destroy it. For, if the red and blue Colours were more dilute +and weak, the distance of the Images would be less than an Inch and a +half; and if they were more intense and full, that distance would be +greater, as will appear hereafter. These Experiments may suffice for the +Colours of Natural Bodies. For in the Colours made by the Refraction of +Prisms, this Proposition will appear by the Experiments which are now to +follow in the next Proposition. + + +_PROP._ II. THEOR. II. + +_The Light of the Sun consists of Rays differently Refrangible._ + +The PROOF by Experiments. + +[Illustration: FIG. 12.] + +[Illustration: FIG. 13.] + +_Exper._ 3. + +In a very dark Chamber, at a round Hole, about one third Part of an Inch +broad, made in the Shut of a Window, I placed a Glass Prism, whereby the +Beam of the Sun's Light, which came in at that Hole, might be refracted +upwards toward the opposite Wall of the Chamber, and there form a +colour'd Image of the Sun. The Axis of the Prism (that is, the Line +passing through the middle of the Prism from one end of it to the other +end parallel to the edge of the Refracting Angle) was in this and the +following Experiments perpendicular to the incident Rays. About this +Axis I turned the Prism slowly, and saw the refracted Light on the Wall, +or coloured Image of the Sun, first to descend, and then to ascend. +Between the Descent and Ascent, when the Image seemed Stationary, I +stopp'd the Prism, and fix'd it in that Posture, that it should be moved +no more. For in that Posture the Refractions of the Light at the two +Sides of the refracting Angle, that is, at the Entrance of the Rays into +the Prism, and at their going out of it, were equal to one another.[C] +So also in other Experiments, as often as I would have the Refractions +on both sides the Prism to be equal to one another, I noted the Place +where the Image of the Sun formed by the refracted Light stood still +between its two contrary Motions, in the common Period of its Progress +and Regress; and when the Image fell upon that Place, I made fast the +Prism. And in this Posture, as the most convenient, it is to be +understood that all the Prisms are placed in the following Experiments, +unless where some other Posture is described. The Prism therefore being +placed in this Posture, I let the refracted Light fall perpendicularly +upon a Sheet of white Paper at the opposite Wall of the Chamber, and +observed the Figure and Dimensions of the Solar Image formed on the +Paper by that Light. This Image was Oblong and not Oval, but terminated +with two Rectilinear and Parallel Sides, and two Semicircular Ends. On +its Sides it was bounded pretty distinctly, but on its Ends very +confusedly and indistinctly, the Light there decaying and vanishing by +degrees. The Breadth of this Image answered to the Sun's Diameter, and +was about two Inches and the eighth Part of an Inch, including the +Penumbra. For the Image was eighteen Feet and an half distant from the +Prism, and at this distance that Breadth, if diminished by the Diameter +of the Hole in the Window-shut, that is by a quarter of an Inch, +subtended an Angle at the Prism of about half a Degree, which is the +Sun's apparent Diameter. But the Length of the Image was about ten +Inches and a quarter, and the Length of the Rectilinear Sides about +eight Inches; and the refracting Angle of the Prism, whereby so great a +Length was made, was 64 degrees. With a less Angle the Length of the +Image was less, the Breadth remaining the same. If the Prism was turned +about its Axis that way which made the Rays emerge more obliquely out of +the second refracting Surface of the Prism, the Image soon became an +Inch or two longer, or more; and if the Prism was turned about the +contrary way, so as to make the Rays fall more obliquely on the first +refracting Surface, the Image soon became an Inch or two shorter. And +therefore in trying this Experiment, I was as curious as I could be in +placing the Prism by the above-mention'd Rule exactly in such a Posture, +that the Refractions of the Rays at their Emergence out of the Prism +might be equal to that at their Incidence on it. This Prism had some +Veins running along within the Glass from one end to the other, which +scattered some of the Sun's Light irregularly, but had no sensible +Effect in increasing the Length of the coloured Spectrum. For I tried +the same Experiment with other Prisms with the same Success. And +particularly with a Prism which seemed free from such Veins, and whose +refracting Angle was 62-1/2 Degrees, I found the Length of the Image +9-3/4 or 10 Inches at the distance of 18-1/2 Feet from the Prism, the +Breadth of the Hole in the Window-shut being 1/4 of an Inch, as before. +And because it is easy to commit a Mistake in placing the Prism in its +due Posture, I repeated the Experiment four or five Times, and always +found the Length of the Image that which is set down above. With another +Prism of clearer Glass and better Polish, which seemed free from Veins, +and whose refracting Angle was 63-1/2 Degrees, the Length of this Image +at the same distance of 18-1/2 Feet was also about 10 Inches, or 10-1/8. +Beyond these Measures for about a 1/4 or 1/3 of an Inch at either end of +the Spectrum the Light of the Clouds seemed to be a little tinged with +red and violet, but so very faintly, that I suspected that Tincture +might either wholly, or in great Measure arise from some Rays of the +Spectrum scattered irregularly by some Inequalities in the Substance and +Polish of the Glass, and therefore I did not include it in these +Measures. Now the different Magnitude of the hole in the Window-shut, +and different thickness of the Prism where the Rays passed through it, +and different inclinations of the Prism to the Horizon, made no sensible +changes in the length of the Image. Neither did the different matter of +the Prisms make any: for in a Vessel made of polished Plates of Glass +cemented together in the shape of a Prism and filled with Water, there +is the like Success of the Experiment according to the quantity of the +Refraction. It is farther to be observed, that the Rays went on in right +Lines from the Prism to the Image, and therefore at their very going out +of the Prism had all that Inclination to one another from which the +length of the Image proceeded, that is, the Inclination of more than two +degrees and an half. And yet according to the Laws of Opticks vulgarly +received, they could not possibly be so much inclined to one another.[D] +For let EG [_Fig._ 13. (p. 27)] represent the Window-shut, F the hole +made therein through which a beam of the Sun's Light was transmitted +into the darkened Chamber, and ABC a Triangular Imaginary Plane whereby +the Prism is feigned to be cut transversely through the middle of the +Light. Or if you please, let ABC represent the Prism it self, looking +directly towards the Spectator's Eye with its nearer end: And let XY be +the Sun, MN the Paper upon which the Solar Image or Spectrum is cast, +and PT the Image it self whose sides towards _v_ and _w_ are Rectilinear +and Parallel, and ends towards P and T Semicircular. YKHP and XLJT are +two Rays, the first of which comes from the lower part of the Sun to the +higher part of the Image, and is refracted in the Prism at K and H, and +the latter comes from the higher part of the Sun to the lower part of +the Image, and is refracted at L and J. Since the Refractions on both +sides the Prism are equal to one another, that is, the Refraction at K +equal to the Refraction at J, and the Refraction at L equal to the +Refraction at H, so that the Refractions of the incident Rays at K and L +taken together, are equal to the Refractions of the emergent Rays at H +and J taken together: it follows by adding equal things to equal things, +that the Refractions at K and H taken together, are equal to the +Refractions at J and L taken together, and therefore the two Rays being +equally refracted, have the same Inclination to one another after +Refraction which they had before; that is, the Inclination of half a +Degree answering to the Sun's Diameter. For so great was the inclination +of the Rays to one another before Refraction. So then, the length of the +Image PT would by the Rules of Vulgar Opticks subtend an Angle of half a +Degree at the Prism, and by Consequence be equal to the breadth _vw_; +and therefore the Image would be round. Thus it would be were the two +Rays XLJT and YKHP, and all the rest which form the Image P_w_T_v_, +alike refrangible. And therefore seeing by Experience it is found that +the Image is not round, but about five times longer than broad, the Rays +which going to the upper end P of the Image suffer the greatest +Refraction, must be more refrangible than those which go to the lower +end T, unless the Inequality of Refraction be casual. + +This Image or Spectrum PT was coloured, being red at its least refracted +end T, and violet at its most refracted end P, and yellow green and +blue in the intermediate Spaces. Which agrees with the first +Proposition, that Lights which differ in Colour, do also differ in +Refrangibility. The length of the Image in the foregoing Experiments, I +measured from the faintest and outmost red at one end, to the faintest +and outmost blue at the other end, excepting only a little Penumbra, +whose breadth scarce exceeded a quarter of an Inch, as was said above. + +_Exper._ 4. In the Sun's Beam which was propagated into the Room through +the hole in the Window-shut, at the distance of some Feet from the hole, +I held the Prism in such a Posture, that its Axis might be perpendicular +to that Beam. Then I looked through the Prism upon the hole, and turning +the Prism to and fro about its Axis, to make the Image of the Hole +ascend and descend, when between its two contrary Motions it seemed +Stationary, I stopp'd the Prism, that the Refractions of both sides of +the refracting Angle might be equal to each other, as in the former +Experiment. In this situation of the Prism viewing through it the said +Hole, I observed the length of its refracted Image to be many times +greater than its breadth, and that the most refracted part thereof +appeared violet, the least refracted red, the middle parts blue, green +and yellow in order. The same thing happen'd when I removed the Prism +out of the Sun's Light, and looked through it upon the hole shining by +the Light of the Clouds beyond it. And yet if the Refraction were done +regularly according to one certain Proportion of the Sines of Incidence +and Refraction as is vulgarly supposed, the refracted Image ought to +have appeared round. + +So then, by these two Experiments it appears, that in Equal Incidences +there is a considerable inequality of Refractions. But whence this +inequality arises, whether it be that some of the incident Rays are +refracted more, and others less, constantly, or by chance, or that one +and the same Ray is by Refraction disturbed, shatter'd, dilated, and as +it were split and spread into many diverging Rays, as _Grimaldo_ +supposes, does not yet appear by these Experiments, but will appear by +those that follow. + +_Exper._ 5. Considering therefore, that if in the third Experiment the +Image of the Sun should be drawn out into an oblong Form, either by a +Dilatation of every Ray, or by any other casual inequality of the +Refractions, the same oblong Image would by a second Refraction made +sideways be drawn out as much in breadth by the like Dilatation of the +Rays, or other casual inequality of the Refractions sideways, I tried +what would be the Effects of such a second Refraction. For this end I +ordered all things as in the third Experiment, and then placed a second +Prism immediately after the first in a cross Position to it, that it +might again refract the beam of the Sun's Light which came to it through +the first Prism. In the first Prism this beam was refracted upwards, and +in the second sideways. And I found that by the Refraction of the second +Prism, the breadth of the Image was not increased, but its superior +part, which in the first Prism suffered the greater Refraction, and +appeared violet and blue, did again in the second Prism suffer a greater +Refraction than its inferior part, which appeared red and yellow, and +this without any Dilatation of the Image in breadth. + +[Illustration: FIG. 14] + +_Illustration._ Let S [_Fig._ 14, 15.] represent the Sun, F the hole in +the Window, ABC the first Prism, DH the second Prism, Y the round Image +of the Sun made by a direct beam of Light when the Prisms are taken +away, PT the oblong Image of the Sun made by that beam passing through +the first Prism alone, when the second Prism is taken away, and _pt_ the +Image made by the cross Refractions of both Prisms together. Now if the +Rays which tend towards the several Points of the round Image Y were +dilated and spread by the Refraction of the first Prism, so that they +should not any longer go in single Lines to single Points, but that +every Ray being split, shattered, and changed from a Linear Ray to a +Superficies of Rays diverging from the Point of Refraction, and lying in +the Plane of the Angles of Incidence and Refraction, they should go in +those Planes to so many Lines reaching almost from one end of the Image +PT to the other, and if that Image should thence become oblong: those +Rays and their several parts tending towards the several Points of the +Image PT ought to be again dilated and spread sideways by the transverse +Refraction of the second Prism, so as to compose a four square Image, +such as is represented at [Greek: pt]. For the better understanding of +which, let the Image PT be distinguished into five equal parts PQK, +KQRL, LRSM, MSVN, NVT. And by the same irregularity that the orbicular +Light Y is by the Refraction of the first Prism dilated and drawn out +into a long Image PT, the Light PQK which takes up a space of the same +length and breadth with the Light Y ought to be by the Refraction of the +second Prism dilated and drawn out into the long Image _[Greek: p]qkp_, +and the Light KQRL into the long Image _kqrl_, and the Lights LRSM, +MSVN, NVT, into so many other long Images _lrsm_, _msvn_, _nvt[Greek: +t]_; and all these long Images would compose the four square Images +_[Greek: pt]_. Thus it ought to be were every Ray dilated by Refraction, +and spread into a triangular Superficies of Rays diverging from the +Point of Refraction. For the second Refraction would spread the Rays one +way as much as the first doth another, and so dilate the Image in +breadth as much as the first doth in length. And the same thing ought to +happen, were some rays casually refracted more than others. But the +Event is otherwise. The Image PT was not made broader by the Refraction +of the second Prism, but only became oblique, as 'tis represented at +_pt_, its upper end P being by the Refraction translated to a greater +distance than its lower end T. So then the Light which went towards the +upper end P of the Image, was (at equal Incidences) more refracted in +the second Prism, than the Light which tended towards the lower end T, +that is the blue and violet, than the red and yellow; and therefore was +more refrangible. The same Light was by the Refraction of the first +Prism translated farther from the place Y to which it tended before +Refraction; and therefore suffered as well in the first Prism as in the +second a greater Refraction than the rest of the Light, and by +consequence was more refrangible than the rest, even before its +incidence on the first Prism. + +Sometimes I placed a third Prism after the second, and sometimes also a +fourth after the third, by all which the Image might be often refracted +sideways: but the Rays which were more refracted than the rest in the +first Prism were also more refracted in all the rest, and that without +any Dilatation of the Image sideways: and therefore those Rays for their +constancy of a greater Refraction are deservedly reputed more +refrangible. + +[Illustration: FIG. 15] + +But that the meaning of this Experiment may more clearly appear, it is +to be considered that the Rays which are equally refrangible do fall +upon a Circle answering to the Sun's Disque. For this was proved in the +third Experiment. By a Circle I understand not here a perfect +geometrical Circle, but any orbicular Figure whose length is equal to +its breadth, and which, as to Sense, may seem circular. Let therefore AG +[in _Fig._ 15.] represent the Circle which all the most refrangible Rays +propagated from the whole Disque of the Sun, would illuminate and paint +upon the opposite Wall if they were alone; EL the Circle which all the +least refrangible Rays would in like manner illuminate and paint if they +were alone; BH, CJ, DK, the Circles which so many intermediate sorts of +Rays would successively paint upon the Wall, if they were singly +propagated from the Sun in successive order, the rest being always +intercepted; and conceive that there are other intermediate Circles +without Number, which innumerable other intermediate sorts of Rays would +successively paint upon the Wall if the Sun should successively emit +every sort apart. And seeing the Sun emits all these sorts at once, they +must all together illuminate and paint innumerable equal Circles, of all +which, being according to their degrees of Refrangibility placed in +order in a continual Series, that oblong Spectrum PT is composed which I +described in the third Experiment. Now if the Sun's circular Image Y [in +_Fig._ 15.] which is made by an unrefracted beam of Light was by any +Dilation of the single Rays, or by any other irregularity in the +Refraction of the first Prism, converted into the oblong Spectrum, PT: +then ought every Circle AG, BH, CJ, &c. in that Spectrum, by the cross +Refraction of the second Prism again dilating or otherwise scattering +the Rays as before, to be in like manner drawn out and transformed into +an oblong Figure, and thereby the breadth of the Image PT would be now +as much augmented as the length of the Image Y was before by the +Refraction of the first Prism; and thus by the Refractions of both +Prisms together would be formed a four square Figure _p[Greek: +p]t[Greek: t]_, as I described above. Wherefore since the breadth of the +Spectrum PT is not increased by the Refraction sideways, it is certain +that the Rays are not split or dilated, or otherways irregularly +scatter'd by that Refraction, but that every Circle is by a regular and +uniform Refraction translated entire into another Place, as the Circle +AG by the greatest Refraction into the place _ag_, the Circle BH by a +less Refraction into the place _bh_, the Circle CJ by a Refraction still +less into the place _ci_, and so of the rest; by which means a new +Spectrum _pt_ inclined to the former PT is in like manner composed of +Circles lying in a right Line; and these Circles must be of the same +bigness with the former, because the breadths of all the Spectrums Y, PT +and _pt_ at equal distances from the Prisms are equal. + +I considered farther, that by the breadth of the hole F through which +the Light enters into the dark Chamber, there is a Penumbra made in the +Circuit of the Spectrum Y, and that Penumbra remains in the rectilinear +Sides of the Spectrums PT and _pt_. I placed therefore at that hole a +Lens or Object-glass of a Telescope which might cast the Image of the +Sun distinctly on Y without any Penumbra at all, and found that the +Penumbra of the rectilinear Sides of the oblong Spectrums PT and _pt_ +was also thereby taken away, so that those Sides appeared as distinctly +defined as did the Circumference of the first Image Y. Thus it happens +if the Glass of the Prisms be free from Veins, and their sides be +accurately plane and well polished without those numberless Waves or +Curles which usually arise from Sand-holes a little smoothed in +polishing with Putty. If the Glass be only well polished and free from +Veins, and the Sides not accurately plane, but a little Convex or +Concave, as it frequently happens; yet may the three Spectrums Y, PT and +_pt_ want Penumbras, but not in equal distances from the Prisms. Now +from this want of Penumbras, I knew more certainly that every one of the +Circles was refracted according to some most regular, uniform and +constant Law. For if there were any irregularity in the Refraction, the +right Lines AE and GL, which all the Circles in the Spectrum PT do +touch, could not by that Refraction be translated into the Lines _ae_ +and _gl_ as distinct and straight as they were before, but there would +arise in those translated Lines some Penumbra or Crookedness or +Undulation, or other sensible Perturbation contrary to what is found by +Experience. Whatsoever Penumbra or Perturbation should be made in the +Circles by the cross Refraction of the second Prism, all that Penumbra +or Perturbation would be conspicuous in the right Lines _ae_ and _gl_ +which touch those Circles. And therefore since there is no such Penumbra +or Perturbation in those right Lines, there must be none in the +Circles. Since the distance between those Tangents or breadth of the +Spectrum is not increased by the Refractions, the Diameters of the +Circles are not increased thereby. Since those Tangents continue to be +right Lines, every Circle which in the first Prism is more or less +refracted, is exactly in the same proportion more or less refracted in +the second. And seeing all these things continue to succeed after the +same manner when the Rays are again in a third Prism, and again in a +fourth refracted sideways, it is evident that the Rays of one and the +same Circle, as to their degree of Refrangibility, continue always +uniform and homogeneal to one another, and that those of several Circles +do differ in degree of Refrangibility, and that in some certain and +constant Proportion. Which is the thing I was to prove. + +There is yet another Circumstance or two of this Experiment by which it +becomes still more plain and convincing. Let the second Prism DH [in +_Fig._ 16.] be placed not immediately after the first, but at some +distance from it; suppose in the mid-way between it and the Wall on +which the oblong Spectrum PT is cast, so that the Light from the first +Prism may fall upon it in the form of an oblong Spectrum [Greek: pt] +parallel to this second Prism, and be refracted sideways to form the +oblong Spectrum _pt_ upon the Wall. And you will find as before, that +this Spectrum _pt_ is inclined to that Spectrum PT, which the first +Prism forms alone without the second; the blue ends P and _p_ being +farther distant from one another than the red ones T and _t_, and by +consequence that the Rays which go to the blue end [Greek: p] of the +Image [Greek: pt], and which therefore suffer the greatest Refraction in +the first Prism, are again in the second Prism more refracted than the +rest. + +[Illustration: FIG. 16.] + +[Illustration: FIG. 17.] + +The same thing I try'd also by letting the Sun's Light into a dark Room +through two little round holes F and [Greek: ph] [in _Fig._ 17.] made in +the Window, and with two parallel Prisms ABC and [Greek: abg] placed at +those holes (one at each) refracting those two beams of Light to the +opposite Wall of the Chamber, in such manner that the two colour'd +Images PT and MN which they there painted were joined end to end and lay +in one straight Line, the red end T of the one touching the blue end M +of the other. For if these two refracted Beams were again by a third +Prism DH placed cross to the two first, refracted sideways, and the +Spectrums thereby translated to some other part of the Wall of the +Chamber, suppose the Spectrum PT to _pt_ and the Spectrum MN to _mn_, +these translated Spectrums _pt_ and _mn_ would not lie in one straight +Line with their ends contiguous as before, but be broken off from one +another and become parallel, the blue end _m_ of the Image _mn_ being by +a greater Refraction translated farther from its former place MT, than +the red end _t_ of the other Image _pt_ from the same place MT; which +puts the Proposition past Dispute. And this happens whether the third +Prism DH be placed immediately after the two first, or at a great +distance from them, so that the Light refracted in the two first Prisms +be either white and circular, or coloured and oblong when it falls on +the third. + +_Exper._ 6. In the middle of two thin Boards I made round holes a third +part of an Inch in diameter, and in the Window-shut a much broader hole +being made to let into my darkned Chamber a large Beam of the Sun's +Light; I placed a Prism behind the Shut in that beam to refract it +towards the opposite Wall, and close behind the Prism I fixed one of the +Boards, in such manner that the middle of the refracted Light might pass +through the hole made in it, and the rest be intercepted by the Board. +Then at the distance of about twelve Feet from the first Board I fixed +the other Board in such manner that the middle of the refracted Light +which came through the hole in the first Board, and fell upon the +opposite Wall, might pass through the hole in this other Board, and the +rest being intercepted by the Board might paint upon it the coloured +Spectrum of the Sun. And close behind this Board I fixed another Prism +to refract the Light which came through the hole. Then I returned +speedily to the first Prism, and by turning it slowly to and fro about +its Axis, I caused the Image which fell upon the second Board to move up +and down upon that Board, that all its parts might successively pass +through the hole in that Board and fall upon the Prism behind it. And in +the mean time, I noted the places on the opposite Wall to which that +Light after its Refraction in the second Prism did pass; and by the +difference of the places I found that the Light which being most +refracted in the first Prism did go to the blue end of the Image, was +again more refracted in the second Prism than the Light which went to +the red end of that Image, which proves as well the first Proposition as +the second. And this happened whether the Axis of the two Prisms were +parallel, or inclined to one another, and to the Horizon in any given +Angles. + +_Illustration._ Let F [in _Fig._ 18.] be the wide hole in the +Window-shut, through which the Sun shines upon the first Prism ABC, and +let the refracted Light fall upon the middle of the Board DE, and the +middle part of that Light upon the hole G made in the middle part of +that Board. Let this trajected part of that Light fall again upon the +middle of the second Board _de_, and there paint such an oblong coloured +Image of the Sun as was described in the third Experiment. By turning +the Prism ABC slowly to and fro about its Axis, this Image will be made +to move up and down the Board _de_, and by this means all its parts from +one end to the other may be made to pass successively through the hole +_g_ which is made in the middle of that Board. In the mean while another +Prism _abc_ is to be fixed next after that hole _g_, to refract the +trajected Light a second time. And these things being thus ordered, I +marked the places M and N of the opposite Wall upon which the refracted +Light fell, and found that whilst the two Boards and second Prism +remained unmoved, those places by turning the first Prism about its Axis +were changed perpetually. For when the lower part of the Light which +fell upon the second Board _de_ was cast through the hole _g_, it went +to a lower place M on the Wall and when the higher part of that Light +was cast through the same hole _g_, it went to a higher place N on the +Wall, and when any intermediate part of the Light was cast through that +hole, it went to some place on the Wall between M and N. The unchanged +Position of the holes in the Boards, made the Incidence of the Rays upon +the second Prism to be the same in all cases. And yet in that common +Incidence some of the Rays were more refracted, and others less. And +those were more refracted in this Prism, which by a greater Refraction +in the first Prism were more turned out of the way, and therefore for +their Constancy of being more refracted are deservedly called more +refrangible. + +[Illustration: FIG. 18.] + +[Illustration: FIG. 20.] + +_Exper._ 7. At two holes made near one another in my Window-shut I +placed two Prisms, one at each, which might cast upon the opposite Wall +(after the manner of the third Experiment) two oblong coloured Images of +the Sun. And at a little distance from the Wall I placed a long slender +Paper with straight and parallel edges, and ordered the Prisms and Paper +so, that the red Colour of one Image might fall directly upon one half +of the Paper, and the violet Colour of the other Image upon the other +half of the same Paper; so that the Paper appeared of two Colours, red +and violet, much after the manner of the painted Paper in the first and +second Experiments. Then with a black Cloth I covered the Wall behind +the Paper, that no Light might be reflected from it to disturb the +Experiment, and viewing the Paper through a third Prism held parallel +to it, I saw that half of it which was illuminated by the violet Light +to be divided from the other half by a greater Refraction, especially +when I went a good way off from the Paper. For when I viewed it too near +at hand, the two halfs of the Paper did not appear fully divided from +one another, but seemed contiguous at one of their Angles like the +painted Paper in the first Experiment. Which also happened when the +Paper was too broad. + +[Illustration: FIG. 19.] + +Sometimes instead of the Paper I used a white Thred, and this appeared +through the Prism divided into two parallel Threds as is represented in +the nineteenth Figure, where DG denotes the Thred illuminated with +violet Light from D to E and with red Light from F to G, and _defg_ are +the parts of the Thred seen by Refraction. If one half of the Thred be +constantly illuminated with red, and the other half be illuminated with +all the Colours successively, (which may be done by causing one of the +Prisms to be turned about its Axis whilst the other remains unmoved) +this other half in viewing the Thred through the Prism, will appear in +a continual right Line with the first half when illuminated with red, +and begin to be a little divided from it when illuminated with Orange, +and remove farther from it when illuminated with yellow, and still +farther when with green, and farther when with blue, and go yet farther +off when illuminated with Indigo, and farthest when with deep violet. +Which plainly shews, that the Lights of several Colours are more and +more refrangible one than another, in this Order of their Colours, red, +orange, yellow, green, blue, indigo, deep violet; and so proves as well +the first Proposition as the second. + +I caused also the coloured Spectrums PT [in _Fig._ 17.] and MN made in a +dark Chamber by the Refractions of two Prisms to lie in a Right Line end +to end, as was described above in the fifth Experiment, and viewing them +through a third Prism held parallel to their Length, they appeared no +longer in a Right Line, but became broken from one another, as they are +represented at _pt_ and _mn_, the violet end _m_ of the Spectrum _mn_ +being by a greater Refraction translated farther from its former Place +MT than the red end _t_ of the other Spectrum _pt_. + +I farther caused those two Spectrums PT [in _Fig._ 20.] and MN to become +co-incident in an inverted Order of their Colours, the red end of each +falling on the violet end of the other, as they are represented in the +oblong Figure PTMN; and then viewing them through a Prism DH held +parallel to their Length, they appeared not co-incident, as when view'd +with the naked Eye, but in the form of two distinct Spectrums _pt_ and +_mn_ crossing one another in the middle after the manner of the Letter +X. Which shews that the red of the one Spectrum and violet of the other, +which were co-incident at PN and MT, being parted from one another by a +greater Refraction of the violet to _p_ and _m_ than of the red to _n_ +and _t_, do differ in degrees of Refrangibility. + +I illuminated also a little Circular Piece of white Paper all over with +the Lights of both Prisms intermixed, and when it was illuminated with +the red of one Spectrum, and deep violet of the other, so as by the +Mixture of those Colours to appear all over purple, I viewed the Paper, +first at a less distance, and then at a greater, through a third Prism; +and as I went from the Paper, the refracted Image thereof became more +and more divided by the unequal Refraction of the two mixed Colours, and +at length parted into two distinct Images, a red one and a violet one, +whereof the violet was farthest from the Paper, and therefore suffered +the greatest Refraction. And when that Prism at the Window, which cast +the violet on the Paper was taken away, the violet Image disappeared; +but when the other Prism was taken away the red vanished; which shews, +that these two Images were nothing else than the Lights of the two +Prisms, which had been intermixed on the purple Paper, but were parted +again by their unequal Refractions made in the third Prism, through +which the Paper was view'd. This also was observable, that if one of the +Prisms at the Window, suppose that which cast the violet on the Paper, +was turned about its Axis to make all the Colours in this order, +violet, indigo, blue, green, yellow, orange, red, fall successively on +the Paper from that Prism, the violet Image changed Colour accordingly, +turning successively to indigo, blue, green, yellow and red, and in +changing Colour came nearer and nearer to the red Image made by the +other Prism, until when it was also red both Images became fully +co-incident. + +I placed also two Paper Circles very near one another, the one in the +red Light of one Prism, and the other in the violet Light of the other. +The Circles were each of them an Inch in diameter, and behind them the +Wall was dark, that the Experiment might not be disturbed by any Light +coming from thence. These Circles thus illuminated, I viewed through a +Prism, so held, that the Refraction might be made towards the red +Circle, and as I went from them they came nearer and nearer together, +and at length became co-incident; and afterwards when I went still +farther off, they parted again in a contrary Order, the violet by a +greater Refraction being carried beyond the red. + +_Exper._ 8. In Summer, when the Sun's Light uses to be strongest, I +placed a Prism at the Hole of the Window-shut, as in the third +Experiment, yet so that its Axis might be parallel to the Axis of the +World, and at the opposite Wall in the Sun's refracted Light, I placed +an open Book. Then going six Feet and two Inches from the Book, I placed +there the above-mentioned Lens, by which the Light reflected from the +Book might be made to converge and meet again at the distance of six +Feet and two Inches behind the Lens, and there paint the Species of the +Book upon a Sheet of white Paper much after the manner of the second +Experiment. The Book and Lens being made fast, I noted the Place where +the Paper was, when the Letters of the Book, illuminated by the fullest +red Light of the Solar Image falling upon it, did cast their Species on +that Paper most distinctly: And then I stay'd till by the Motion of the +Sun, and consequent Motion of his Image on the Book, all the Colours +from that red to the middle of the blue pass'd over those Letters; and +when those Letters were illuminated by that blue, I noted again the +Place of the Paper when they cast their Species most distinctly upon it: +And I found that this last Place of the Paper was nearer to the Lens +than its former Place by about two Inches and an half, or two and three +quarters. So much sooner therefore did the Light in the violet end of +the Image by a greater Refraction converge and meet, than the Light in +the red end. But in trying this, the Chamber was as dark as I could make +it. For, if these Colours be diluted and weakned by the Mixture of any +adventitious Light, the distance between the Places of the Paper will +not be so great. This distance in the second Experiment, where the +Colours of natural Bodies were made use of, was but an Inch and an half, +by reason of the Imperfection of those Colours. Here in the Colours of +the Prism, which are manifestly more full, intense, and lively than +those of natural Bodies, the distance is two Inches and three quarters. +And were the Colours still more full, I question not but that the +distance would be considerably greater. For the coloured Light of the +Prism, by the interfering of the Circles described in the second Figure +of the fifth Experiment, and also by the Light of the very bright Clouds +next the Sun's Body intermixing with these Colours, and by the Light +scattered by the Inequalities in the Polish of the Prism, was so very +much compounded, that the Species which those faint and dark Colours, +the indigo and violet, cast upon the Paper were not distinct enough to +be well observed. + +_Exper._ 9. A Prism, whose two Angles at its Base were equal to one +another, and half right ones, and the third a right one, I placed in a +Beam of the Sun's Light let into a dark Chamber through a Hole in the +Window-shut, as in the third Experiment. And turning the Prism slowly +about its Axis, until all the Light which went through one of its +Angles, and was refracted by it began to be reflected by its Base, at +which till then it went out of the Glass, I observed that those Rays +which had suffered the greatest Refraction were sooner reflected than +the rest. I conceived therefore, that those Rays of the reflected Light, +which were most refrangible, did first of all by a total Reflexion +become more copious in that Light than the rest, and that afterwards the +rest also, by a total Reflexion, became as copious as these. To try +this, I made the reflected Light pass through another Prism, and being +refracted by it to fall afterwards upon a Sheet of white Paper placed +at some distance behind it, and there by that Refraction to paint the +usual Colours of the Prism. And then causing the first Prism to be +turned about its Axis as above, I observed that when those Rays, which +in this Prism had suffered the greatest Refraction, and appeared of a +blue and violet Colour began to be totally reflected, the blue and +violet Light on the Paper, which was most refracted in the second Prism, +received a sensible Increase above that of the red and yellow, which was +least refracted; and afterwards, when the rest of the Light which was +green, yellow, and red, began to be totally reflected in the first +Prism, the Light of those Colours on the Paper received as great an +Increase as the violet and blue had done before. Whence 'tis manifest, +that the Beam of Light reflected by the Base of the Prism, being +augmented first by the more refrangible Rays, and afterwards by the less +refrangible ones, is compounded of Rays differently refrangible. And +that all such reflected Light is of the same Nature with the Sun's Light +before its Incidence on the Base of the Prism, no Man ever doubted; it +being generally allowed, that Light by such Reflexions suffers no +Alteration in its Modifications and Properties. I do not here take +Notice of any Refractions made in the sides of the first Prism, because +the Light enters it perpendicularly at the first side, and goes out +perpendicularly at the second side, and therefore suffers none. So then, +the Sun's incident Light being of the same Temper and Constitution with +his emergent Light, and the last being compounded of Rays differently +refrangible, the first must be in like manner compounded. + +[Illustration: FIG. 21.] + +_Illustration._ In the twenty-first Figure, ABC is the first Prism, BC +its Base, B and C its equal Angles at the Base, each of 45 Degrees, A +its rectangular Vertex, FM a beam of the Sun's Light let into a dark +Room through a hole F one third part of an Inch broad, M its Incidence +on the Base of the Prism, MG a less refracted Ray, MH a more refracted +Ray, MN the beam of Light reflected from the Base, VXY the second Prism +by which this beam in passing through it is refracted, N_t_ the less +refracted Light of this beam, and N_p_ the more refracted part thereof. +When the first Prism ABC is turned about its Axis according to the order +of the Letters ABC, the Rays MH emerge more and more obliquely out of +that Prism, and at length after their most oblique Emergence are +reflected towards N, and going on to _p_ do increase the Number of the +Rays N_p_. Afterwards by continuing the Motion of the first Prism, the +Rays MG are also reflected to N and increase the number of the Rays +N_t_. And therefore the Light MN admits into its Composition, first the +more refrangible Rays, and then the less refrangible Rays, and yet after +this Composition is of the same Nature with the Sun's immediate Light +FM, the Reflexion of the specular Base BC causing no Alteration therein. + +_Exper._ 10. Two Prisms, which were alike in Shape, I tied so together, +that their Axis and opposite Sides being parallel, they composed a +Parallelopiped. And, the Sun shining into my dark Chamber through a +little hole in the Window-shut, I placed that Parallelopiped in his beam +at some distance from the hole, in such a Posture, that the Axes of the +Prisms might be perpendicular to the incident Rays, and that those Rays +being incident upon the first Side of one Prism, might go on through the +two contiguous Sides of both Prisms, and emerge out of the last Side of +the second Prism. This Side being parallel to the first Side of the +first Prism, caused the emerging Light to be parallel to the incident. +Then, beyond these two Prisms I placed a third, which might refract that +emergent Light, and by that Refraction cast the usual Colours of the +Prism upon the opposite Wall, or upon a sheet of white Paper held at a +convenient Distance behind the Prism for that refracted Light to fall +upon it. After this I turned the Parallelopiped about its Axis, and +found that when the contiguous Sides of the two Prisms became so oblique +to the incident Rays, that those Rays began all of them to be +reflected, those Rays which in the third Prism had suffered the greatest +Refraction, and painted the Paper with violet and blue, were first of +all by a total Reflexion taken out of the transmitted Light, the rest +remaining and on the Paper painting their Colours of green, yellow, +orange and red, as before; and afterwards by continuing the Motion of +the two Prisms, the rest of the Rays also by a total Reflexion vanished +in order, according to their degrees of Refrangibility. The Light +therefore which emerged out of the two Prisms is compounded of Rays +differently refrangible, seeing the more refrangible Rays may be taken +out of it, while the less refrangible remain. But this Light being +trajected only through the parallel Superficies of the two Prisms, if it +suffer'd any change by the Refraction of one Superficies it lost that +Impression by the contrary Refraction of the other Superficies, and so +being restor'd to its pristine Constitution, became of the same Nature +and Condition as at first before its Incidence on those Prisms; and +therefore, before its Incidence, was as much compounded of Rays +differently refrangible, as afterwards. + +[Illustration: FIG. 22.] + +_Illustration._ In the twenty second Figure ABC and BCD are the two +Prisms tied together in the form of a Parallelopiped, their Sides BC and +CB being contiguous, and their Sides AB and CD parallel. And HJK is the +third Prism, by which the Sun's Light propagated through the hole F into +the dark Chamber, and there passing through those sides of the Prisms +AB, BC, CB and CD, is refracted at O to the white Paper PT, falling +there partly upon P by a greater Refraction, partly upon T by a less +Refraction, and partly upon R and other intermediate places by +intermediate Refractions. By turning the Parallelopiped ACBD about its +Axis, according to the order of the Letters A, C, D, B, at length when +the contiguous Planes BC and CB become sufficiently oblique to the Rays +FM, which are incident upon them at M, there will vanish totally out of +the refracted Light OPT, first of all the most refracted Rays OP, (the +rest OR and OT remaining as before) then the Rays OR and other +intermediate ones, and lastly, the least refracted Rays OT. For when +the Plane BC becomes sufficiently oblique to the Rays incident upon it, +those Rays will begin to be totally reflected by it towards N; and first +the most refrangible Rays will be totally reflected (as was explained in +the preceding Experiment) and by Consequence must first disappear at P, +and afterwards the rest as they are in order totally reflected to N, +they must disappear in the same order at R and T. So then the Rays which +at O suffer the greatest Refraction, may be taken out of the Light MO +whilst the rest of the Rays remain in it, and therefore that Light MO is +compounded of Rays differently refrangible. And because the Planes AB +and CD are parallel, and therefore by equal and contrary Refractions +destroy one anothers Effects, the incident Light FM must be of the same +Kind and Nature with the emergent Light MO, and therefore doth also +consist of Rays differently refrangible. These two Lights FM and MO, +before the most refrangible Rays are separated out of the emergent Light +MO, agree in Colour, and in all other Properties so far as my +Observation reaches, and therefore are deservedly reputed of the same +Nature and Constitution, and by Consequence the one is compounded as +well as the other. But after the most refrangible Rays begin to be +totally reflected, and thereby separated out of the emergent Light MO, +that Light changes its Colour from white to a dilute and faint yellow, a +pretty good orange, a very full red successively, and then totally +vanishes. For after the most refrangible Rays which paint the Paper at +P with a purple Colour, are by a total Reflexion taken out of the beam +of Light MO, the rest of the Colours which appear on the Paper at R and +T being mix'd in the Light MO compound there a faint yellow, and after +the blue and part of the green which appear on the Paper between P and R +are taken away, the rest which appear between R and T (that is the +yellow, orange, red and a little green) being mixed in the beam MO +compound there an orange; and when all the Rays are by Reflexion taken +out of the beam MO, except the least refrangible, which at T appear of a +full red, their Colour is the same in that beam MO as afterwards at T, +the Refraction of the Prism HJK serving only to separate the differently +refrangible Rays, without making any Alteration in their Colours, as +shall be more fully proved hereafter. All which confirms as well the +first Proposition as the second. + +_Scholium._ If this Experiment and the former be conjoined and made one +by applying a fourth Prism VXY [in _Fig._ 22.] to refract the reflected +beam MN towards _tp_, the Conclusion will be clearer. For then the Light +N_p_ which in the fourth Prism is more refracted, will become fuller and +stronger when the Light OP, which in the third Prism HJK is more +refracted, vanishes at P; and afterwards when the less refracted Light +OT vanishes at T, the less refracted Light N_t_ will become increased +whilst the more refracted Light at _p_ receives no farther increase. And +as the trajected beam MO in vanishing is always of such a Colour as +ought to result from the mixture of the Colours which fall upon the +Paper PT, so is the reflected beam MN always of such a Colour as ought +to result from the mixture of the Colours which fall upon the Paper +_pt_. For when the most refrangible Rays are by a total Reflexion taken +out of the beam MO, and leave that beam of an orange Colour, the Excess +of those Rays in the reflected Light, does not only make the violet, +indigo and blue at _p_ more full, but also makes the beam MN change from +the yellowish Colour of the Sun's Light, to a pale white inclining to +blue, and afterward recover its yellowish Colour again, so soon as all +the rest of the transmitted Light MOT is reflected. + +Now seeing that in all this variety of Experiments, whether the Trial be +made in Light reflected, and that either from natural Bodies, as in the +first and second Experiment, or specular, as in the ninth; or in Light +refracted, and that either before the unequally refracted Rays are by +diverging separated from one another, and losing their whiteness which +they have altogether, appear severally of several Colours, as in the +fifth Experiment; or after they are separated from one another, and +appear colour'd as in the sixth, seventh, and eighth Experiments; or in +Light trajected through parallel Superficies, destroying each others +Effects, as in the tenth Experiment; there are always found Rays, which +at equal Incidences on the same Medium suffer unequal Refractions, and +that without any splitting or dilating of single Rays, or contingence in +the inequality of the Refractions, as is proved in the fifth and sixth +Experiments. And seeing the Rays which differ in Refrangibility may be +parted and sorted from one another, and that either by Refraction as in +the third Experiment, or by Reflexion as in the tenth, and then the +several sorts apart at equal Incidences suffer unequal Refractions, and +those sorts are more refracted than others after Separation, which were +more refracted before it, as in the sixth and following Experiments, and +if the Sun's Light be trajected through three or more cross Prisms +successively, those Rays which in the first Prism are refracted more +than others, are in all the following Prisms refracted more than others +in the same Rate and Proportion, as appears by the fifth Experiment; +it's manifest that the Sun's Light is an heterogeneous Mixture of Rays, +some of which are constantly more refrangible than others, as was +proposed. + + +_PROP._ III. THEOR. III. + +_The Sun's Light consists of Rays differing in Reflexibility, and those +Rays are more reflexible than others which are more refrangible._ + +This is manifest by the ninth and tenth Experiments: For in the ninth +Experiment, by turning the Prism about its Axis, until the Rays within +it which in going out into the Air were refracted by its Base, became so +oblique to that Base, as to begin to be totally reflected thereby; those +Rays became first of all totally reflected, which before at equal +Incidences with the rest had suffered the greatest Refraction. And the +same thing happens in the Reflexion made by the common Base of the two +Prisms in the tenth Experiment. + + +_PROP._ IV. PROB. I. + +_To separate from one another the heterogeneous Rays of compound Light._ + +[Illustration: FIG. 23.] + +The heterogeneous Rays are in some measure separated from one another by +the Refraction of the Prism in the third Experiment, and in the fifth +Experiment, by taking away the Penumbra from the rectilinear sides of +the coloured Image, that Separation in those very rectilinear sides or +straight edges of the Image becomes perfect. But in all places between +those rectilinear edges, those innumerable Circles there described, +which are severally illuminated by homogeneal Rays, by interfering with +one another, and being every where commix'd, do render the Light +sufficiently compound. But if these Circles, whilst their Centers keep +their Distances and Positions, could be made less in Diameter, their +interfering one with another, and by Consequence the Mixture of the +heterogeneous Rays would be proportionally diminish'd. In the twenty +third Figure let AG, BH, CJ, DK, EL, FM be the Circles which so many +sorts of Rays flowing from the same disque of the Sun, do in the third +Experiment illuminate; of all which and innumerable other intermediate +ones lying in a continual Series between the two rectilinear and +parallel edges of the Sun's oblong Image PT, that Image is compos'd, as +was explained in the fifth Experiment. And let _ag_, _bh_, _ci_, _dk_, +_el_, _fm_ be so many less Circles lying in a like continual Series +between two parallel right Lines _af_ and _gm_ with the same distances +between their Centers, and illuminated by the same sorts of Rays, that +is the Circle _ag_ with the same sort by which the corresponding Circle +AG was illuminated, and the Circle _bh_ with the same sort by which the +corresponding Circle BH was illuminated, and the rest of the Circles +_ci_, _dk_, _el_, _fm_ respectively, with the same sorts of Rays by +which the several corresponding Circles CJ, DK, EL, FM were illuminated. +In the Figure PT composed of the greater Circles, three of those Circles +AG, BH, CJ, are so expanded into one another, that the three sorts of +Rays by which those Circles are illuminated, together with other +innumerable sorts of intermediate Rays, are mixed at QR in the middle +of the Circle BH. And the like Mixture happens throughout almost the +whole length of the Figure PT. But in the Figure _pt_ composed of the +less Circles, the three less Circles _ag_, _bh_, _ci_, which answer to +those three greater, do not extend into one another; nor are there any +where mingled so much as any two of the three sorts of Rays by which +those Circles are illuminated, and which in the Figure PT are all of +them intermingled at BH. + +Now he that shall thus consider it, will easily understand that the +Mixture is diminished in the same Proportion with the Diameters of the +Circles. If the Diameters of the Circles whilst their Centers remain the +same, be made three times less than before, the Mixture will be also +three times less; if ten times less, the Mixture will be ten times less, +and so of other Proportions. That is, the Mixture of the Rays in the +greater Figure PT will be to their Mixture in the less _pt_, as the +Latitude of the greater Figure is to the Latitude of the less. For the +Latitudes of these Figures are equal to the Diameters of their Circles. +And hence it easily follows, that the Mixture of the Rays in the +refracted Spectrum _pt_ is to the Mixture of the Rays in the direct and +immediate Light of the Sun, as the breadth of that Spectrum is to the +difference between the length and breadth of the same Spectrum. + +So then, if we would diminish the Mixture of the Rays, we are to +diminish the Diameters of the Circles. Now these would be diminished if +the Sun's Diameter to which they answer could be made less than it is, +or (which comes to the same Purpose) if without Doors, at a great +distance from the Prism towards the Sun, some opake Body were placed, +with a round hole in the middle of it, to intercept all the Sun's Light, +excepting so much as coming from the middle of his Body could pass +through that Hole to the Prism. For so the Circles AG, BH, and the rest, +would not any longer answer to the whole Disque of the Sun, but only to +that Part of it which could be seen from the Prism through that Hole, +that it is to the apparent Magnitude of that Hole view'd from the Prism. +But that these Circles may answer more distinctly to that Hole, a Lens +is to be placed by the Prism to cast the Image of the Hole, (that is, +every one of the Circles AG, BH, &c.) distinctly upon the Paper at PT, +after such a manner, as by a Lens placed at a Window, the Species of +Objects abroad are cast distinctly upon a Paper within the Room, and the +rectilinear Sides of the oblong Solar Image in the fifth Experiment +became distinct without any Penumbra. If this be done, it will not be +necessary to place that Hole very far off, no not beyond the Window. And +therefore instead of that Hole, I used the Hole in the Window-shut, as +follows. + +_Exper._ 11. In the Sun's Light let into my darken'd Chamber through a +small round Hole in my Window-shut, at about ten or twelve Feet from the +Window, I placed a Lens, by which the Image of the Hole might be +distinctly cast upon a Sheet of white Paper, placed at the distance of +six, eight, ten, or twelve Feet from the Lens. For, according to the +difference of the Lenses I used various distances, which I think not +worth the while to describe. Then immediately after the Lens I placed a +Prism, by which the trajected Light might be refracted either upwards or +sideways, and thereby the round Image, which the Lens alone did cast +upon the Paper might be drawn out into a long one with Parallel Sides, +as in the third Experiment. This oblong Image I let fall upon another +Paper at about the same distance from the Prism as before, moving the +Paper either towards the Prism or from it, until I found the just +distance where the Rectilinear Sides of the Image became most distinct. +For in this Case, the Circular Images of the Hole, which compose that +Image after the same manner that the Circles _ag_, _bh_, _ci_, &c. do +the Figure _pt_ [in _Fig._ 23.] were terminated most distinctly without +any Penumbra, and therefore extended into one another the least that +they could, and by consequence the Mixture of the heterogeneous Rays was +now the least of all. By this means I used to form an oblong Image (such +as is _pt_) [in _Fig._ 23, and 24.] of Circular Images of the Hole, +(such as are _ag_, _bh_, _ci_, &c.) and by using a greater or less Hole +in the Window-shut, I made the Circular Images _ag_, _bh_, _ci_, &c. of +which it was formed, to become greater or less at pleasure, and thereby +the Mixture of the Rays in the Image _pt_ to be as much, or as little as +I desired. + +[Illustration: FIG. 24.] + +_Illustration._ In the twenty-fourth Figure, F represents the Circular +Hole in the Window-shut, MN the Lens, whereby the Image or Species of +that Hole is cast distinctly upon a Paper at J, ABC the Prism, whereby +the Rays are at their emerging out of the Lens refracted from J towards +another Paper at _pt_, and the round Image at J is turned into an oblong +Image _pt_ falling on that other Paper. This Image _pt_ consists of +Circles placed one after another in a Rectilinear Order, as was +sufficiently explained in the fifth Experiment; and these Circles are +equal to the Circle J, and consequently answer in magnitude to the Hole +F; and therefore by diminishing that Hole they may be at pleasure +diminished, whilst their Centers remain in their Places. By this means I +made the Breadth of the Image _pt_ to be forty times, and sometimes +sixty or seventy times less than its Length. As for instance, if the +Breadth of the Hole F be one tenth of an Inch, and MF the distance of +the Lens from the Hole be 12 Feet; and if _p_B or _p_M the distance of +the Image _pt_ from the Prism or Lens be 10 Feet, and the refracting +Angle of the Prism be 62 Degrees, the Breadth of the Image _pt_ will be +one twelfth of an Inch, and the Length about six Inches, and therefore +the Length to the Breadth as 72 to 1, and by consequence the Light of +this Image 71 times less compound than the Sun's direct Light. And Light +thus far simple and homogeneal, is sufficient for trying all the +Experiments in this Book about simple Light. For the Composition of +heterogeneal Rays is in this Light so little, that it is scarce to be +discovered and perceiv'd by Sense, except perhaps in the indigo and +violet. For these being dark Colours do easily suffer a sensible Allay +by that little scattering Light which uses to be refracted irregularly +by the Inequalities of the Prism. + +Yet instead of the Circular Hole F, 'tis better to substitute an oblong +Hole shaped like a long Parallelogram with its Length parallel to the +Prism ABC. For if this Hole be an Inch or two long, and but a tenth or +twentieth Part of an Inch broad, or narrower; the Light of the Image +_pt_ will be as simple as before, or simpler, and the Image will become +much broader, and therefore more fit to have Experiments try'd in its +Light than before. + +Instead of this Parallelogram Hole may be substituted a triangular one +of equal Sides, whose Base, for instance, is about the tenth Part of an +Inch, and its Height an Inch or more. For by this means, if the Axis of +the Prism be parallel to the Perpendicular of the Triangle, the Image +_pt_ [in _Fig._ 25.] will now be form'd of equicrural Triangles _ag_, +_bh_, _ci_, _dk_, _el_, _fm_, &c. and innumerable other intermediate +ones answering to the triangular Hole in Shape and Bigness, and lying +one after another in a continual Series between two Parallel Lines _af_ +and _gm_. These Triangles are a little intermingled at their Bases, but +not at their Vertices; and therefore the Light on the brighter Side _af_ +of the Image, where the Bases of the Triangles are, is a little +compounded, but on the darker Side _gm_ is altogether uncompounded, and +in all Places between the Sides the Composition is proportional to the +distances of the Places from that obscurer Side _gm_. And having a +Spectrum _pt_ of such a Composition, we may try Experiments either in +its stronger and less simple Light near the Side _af_, or in its weaker +and simpler Light near the other Side _gm_, as it shall seem most +convenient. + +[Illustration: FIG. 25.] + +But in making Experiments of this kind, the Chamber ought to be made as +dark as can be, lest any Foreign Light mingle it self with the Light of +the Spectrum _pt_, and render it compound; especially if we would try +Experiments in the more simple Light next the Side _gm_ of the Spectrum; +which being fainter, will have a less proportion to the Foreign Light; +and so by the mixture of that Light be more troubled, and made more +compound. The Lens also ought to be good, such as may serve for optical +Uses, and the Prism ought to have a large Angle, suppose of 65 or 70 +Degrees, and to be well wrought, being made of Glass free from Bubbles +and Veins, with its Sides not a little convex or concave, as usually +happens, but truly plane, and its Polish elaborate, as in working +Optick-glasses, and not such as is usually wrought with Putty, whereby +the edges of the Sand-holes being worn away, there are left all over the +Glass a numberless Company of very little convex polite Risings like +Waves. The edges also of the Prism and Lens, so far as they may make any +irregular Refraction, must be covered with a black Paper glewed on. And +all the Light of the Sun's Beam let into the Chamber, which is useless +and unprofitable to the Experiment, ought to be intercepted with black +Paper, or other black Obstacles. For otherwise the useless Light being +reflected every way in the Chamber, will mix with the oblong Spectrum, +and help to disturb it. In trying these Things, so much diligence is not +altogether necessary, but it will promote the Success of the +Experiments, and by a very scrupulous Examiner of Things deserves to be +apply'd. It's difficult to get Glass Prisms fit for this Purpose, and +therefore I used sometimes prismatick Vessels made with pieces of broken +Looking-glasses, and filled with Rain Water. And to increase the +Refraction, I sometimes impregnated the Water strongly with _Saccharum +Saturni_. + + +_PROP._ V. THEOR. IV. + +_Homogeneal Light is refracted regularly without any Dilatation +splitting or shattering of the Rays, and the confused Vision of Objects +seen through refracting Bodies by heterogeneal Light arises from the +different Refrangibility of several sorts of Rays._ + +The first Part of this Proposition has been already sufficiently proved +in the fifth Experiment, and will farther appear by the Experiments +which follow. + +_Exper._ 12. In the middle of a black Paper I made a round Hole about a +fifth or sixth Part of an Inch in diameter. Upon this Paper I caused the +Spectrum of homogeneal Light described in the former Proposition, so to +fall, that some part of the Light might pass through the Hole of the +Paper. This transmitted part of the Light I refracted with a Prism +placed behind the Paper, and letting this refracted Light fall +perpendicularly upon a white Paper two or three Feet distant from the +Prism, I found that the Spectrum formed on the Paper by this Light was +not oblong, as when 'tis made (in the third Experiment) by refracting +the Sun's compound Light, but was (so far as I could judge by my Eye) +perfectly circular, the Length being no greater than the Breadth. Which +shews, that this Light is refracted regularly without any Dilatation of +the Rays. + +_Exper._ 13. In the homogeneal Light I placed a Paper Circle of a +quarter of an Inch in diameter, and in the Sun's unrefracted +heterogeneal white Light I placed another Paper Circle of the same +Bigness. And going from the Papers to the distance of some Feet, I +viewed both Circles through a Prism. The Circle illuminated by the Sun's +heterogeneal Light appeared very oblong, as in the fourth Experiment, +the Length being many times greater than the Breadth; but the other +Circle, illuminated with homogeneal Light, appeared circular and +distinctly defined, as when 'tis view'd with the naked Eye. Which proves +the whole Proposition. + +_Exper._ 14. In the homogeneal Light I placed Flies, and such-like +minute Objects, and viewing them through a Prism, I saw their Parts as +distinctly defined, as if I had viewed them with the naked Eye. The same +Objects placed in the Sun's unrefracted heterogeneal Light, which was +white, I viewed also through a Prism, and saw them most confusedly +defined, so that I could not distinguish their smaller Parts from one +another. I placed also the Letters of a small print, one while in the +homogeneal Light, and then in the heterogeneal, and viewing them through +a Prism, they appeared in the latter Case so confused and indistinct, +that I could not read them; but in the former they appeared so distinct, +that I could read readily, and thought I saw them as distinct, as when I +view'd them with my naked Eye. In both Cases I view'd the same Objects, +through the same Prism at the same distance from me, and in the same +Situation. There was no difference, but in the Light by which the +Objects were illuminated, and which in one Case was simple, and in the +other compound; and therefore, the distinct Vision in the former Case, +and confused in the latter, could arise from nothing else than from that +difference of the Lights. Which proves the whole Proposition. + +And in these three Experiments it is farther very remarkable, that the +Colour of homogeneal Light was never changed by the Refraction. + + +_PROP._ VI. THEOR. V. + +_The Sine of Incidence of every Ray considered apart, is to its Sine of +Refraction in a given Ratio._ + +That every Ray consider'd apart, is constant to it self in some degree +of Refrangibility, is sufficiently manifest out of what has been said. +Those Rays, which in the first Refraction, are at equal Incidences most +refracted, are also in the following Refractions at equal Incidences +most refracted; and so of the least refrangible, and the rest which have +any mean Degree of Refrangibility, as is manifest by the fifth, sixth, +seventh, eighth, and ninth Experiments. And those which the first Time +at like Incidences are equally refracted, are again at like Incidences +equally and uniformly refracted, and that whether they be refracted +before they be separated from one another, as in the fifth Experiment, +or whether they be refracted apart, as in the twelfth, thirteenth and +fourteenth Experiments. The Refraction therefore of every Ray apart is +regular, and what Rule that Refraction observes we are now to shew.[E] + +The late Writers in Opticks teach, that the Sines of Incidence are in a +given Proportion to the Sines of Refraction, as was explained in the +fifth Axiom, and some by Instruments fitted for measuring of +Refractions, or otherwise experimentally examining this Proportion, do +acquaint us that they have found it accurate. But whilst they, not +understanding the different Refrangibility of several Rays, conceived +them all to be refracted according to one and the same Proportion, 'tis +to be presumed that they adapted their Measures only to the middle of +the refracted Light; so that from their Measures we may conclude only +that the Rays which have a mean Degree of Refrangibility, that is, those +which when separated from the rest appear green, are refracted according +to a given Proportion of their Sines. And therefore we are now to shew, +that the like given Proportions obtain in all the rest. That it should +be so is very reasonable, Nature being ever conformable to her self; but +an experimental Proof is desired. And such a Proof will be had, if we +can shew that the Sines of Refraction of Rays differently refrangible +are one to another in a given Proportion when their Sines of Incidence +are equal. For, if the Sines of Refraction of all the Rays are in given +Proportions to the Sine of Refractions of a Ray which has a mean Degree +of Refrangibility, and this Sine is in a given Proportion to the equal +Sines of Incidence, those other Sines of Refraction will also be in +given Proportions to the equal Sines of Incidence. Now, when the Sines +of Incidence are equal, it will appear by the following Experiment, that +the Sines of Refraction are in a given Proportion to one another. + +[Illustration: FIG. 26.] + +_Exper._ 15. The Sun shining into a dark Chamber through a little round +Hole in the Window-shut, let S [in _Fig._ 26.] represent his round white +Image painted on the opposite Wall by his direct Light, PT his oblong +coloured Image made by refracting that Light with a Prism placed at the +Window; and _pt_, or _2p 2t_, _3p 3t_, his oblong colour'd Image made by +refracting again the same Light sideways with a second Prism placed +immediately after the first in a cross Position to it, as was explained +in the fifth Experiment; that is to say, _pt_ when the Refraction of the +second Prism is small, _2p 2t_ when its Refraction is greater, and _3p +3t_ when it is greatest. For such will be the diversity of the +Refractions, if the refracting Angle of the second Prism be of various +Magnitudes; suppose of fifteen or twenty Degrees to make the Image _pt_, +of thirty or forty to make the Image _2p 2t_, and of sixty to make the +Image _3p 3t_. But for want of solid Glass Prisms with Angles of +convenient Bignesses, there may be Vessels made of polished Plates of +Glass cemented together in the form of Prisms and filled with Water. +These things being thus ordered, I observed that all the solar Images or +coloured Spectrums PT, _pt_, _2p 2t_, _3p 3t_ did very nearly converge +to the place S on which the direct Light of the Sun fell and painted his +white round Image when the Prisms were taken away. The Axis of the +Spectrum PT, that is the Line drawn through the middle of it parallel to +its rectilinear Sides, did when produced pass exactly through the middle +of that white round Image S. And when the Refraction of the second Prism +was equal to the Refraction of the first, the refracting Angles of them +both being about 60 Degrees, the Axis of the Spectrum _3p 3t_ made by +that Refraction, did when produced pass also through the middle of the +same white round Image S. But when the Refraction of the second Prism +was less than that of the first, the produced Axes of the Spectrums _tp_ +or _2t 2p_ made by that Refraction did cut the produced Axis of the +Spectrum TP in the points _m_ and _n_, a little beyond the Center of +that white round Image S. Whence the proportion of the Line 3_t_T to the +Line 3_p_P was a little greater than the Proportion of 2_t_T or 2_p_P, +and this Proportion a little greater than that of _t_T to _p_P. Now when +the Light of the Spectrum PT falls perpendicularly upon the Wall, those +Lines 3_t_T, 3_p_P, and 2_t_T, and 2_p_P, and _t_T, _p_P, are the +Tangents of the Refractions, and therefore by this Experiment the +Proportions of the Tangents of the Refractions are obtained, from whence +the Proportions of the Sines being derived, they come out equal, so far +as by viewing the Spectrums, and using some mathematical Reasoning I +could estimate. For I did not make an accurate Computation. So then the +Proposition holds true in every Ray apart, so far as appears by +Experiment. And that it is accurately true, may be demonstrated upon +this Supposition. _That Bodies refract Light by acting upon its Rays in +Lines perpendicular to their Surfaces._ But in order to this +Demonstration, I must distinguish the Motion of every Ray into two +Motions, the one perpendicular to the refracting Surface, the other +parallel to it, and concerning the perpendicular Motion lay down the +following Proposition. + +If any Motion or moving thing whatsoever be incident with any Velocity +on any broad and thin space terminated on both sides by two parallel +Planes, and in its Passage through that space be urged perpendicularly +towards the farther Plane by any force which at given distances from the +Plane is of given Quantities; the perpendicular velocity of that Motion +or Thing, at its emerging out of that space, shall be always equal to +the square Root of the sum of the square of the perpendicular velocity +of that Motion or Thing at its Incidence on that space; and of the +square of the perpendicular velocity which that Motion or Thing would +have at its Emergence, if at its Incidence its perpendicular velocity +was infinitely little. + +And the same Proposition holds true of any Motion or Thing +perpendicularly retarded in its passage through that space, if instead +of the sum of the two Squares you take their difference. The +Demonstration Mathematicians will easily find out, and therefore I shall +not trouble the Reader with it. + +Suppose now that a Ray coming most obliquely in the Line MC [in _Fig._ +1.] be refracted at C by the Plane RS into the Line CN, and if it be +required to find the Line CE, into which any other Ray AC shall be +refracted; let MC, AD, be the Sines of Incidence of the two Rays, and +NG, EF, their Sines of Refraction, and let the equal Motions of the +incident Rays be represented by the equal Lines MC and AC, and the +Motion MC being considered as parallel to the refracting Plane, let the +other Motion AC be distinguished into two Motions AD and DC, one of +which AD is parallel, and the other DC perpendicular to the refracting +Surface. In like manner, let the Motions of the emerging Rays be +distinguish'd into two, whereof the perpendicular ones are MC/NG × CG +and AD/EF × CF. And if the force of the refracting Plane begins to act +upon the Rays either in that Plane or at a certain distance from it on +the one side, and ends at a certain distance from it on the other side, +and in all places between those two limits acts upon the Rays in Lines +perpendicular to that refracting Plane, and the Actions upon the Rays at +equal distances from the refracting Plane be equal, and at unequal ones +either equal or unequal according to any rate whatever; that Motion of +the Ray which is parallel to the refracting Plane, will suffer no +Alteration by that Force; and that Motion which is perpendicular to it +will be altered according to the rule of the foregoing Proposition. If +therefore for the perpendicular velocity of the emerging Ray CN you +write MC/NG × CG as above, then the perpendicular velocity of any other +emerging Ray CE which was AD/EF × CF, will be equal to the square Root +of CD_q_ + (_MCq/NGq_ × CG_q_). And by squaring these Equals, and adding +to them the Equals AD_q_ and MC_q_ - CD_q_, and dividing the Sums by the +Equals CF_q_ + EF_q_ and CG_q_ + NG_q_, you will have _MCq/NGq_ equal to +_ADq/EFq_. Whence AD, the Sine of Incidence, is to EF the Sine of +Refraction, as MC to NG, that is, in a given _ratio_. And this +Demonstration being general, without determining what Light is, or by +what kind of Force it is refracted, or assuming any thing farther than +that the refracting Body acts upon the Rays in Lines perpendicular to +its Surface; I take it to be a very convincing Argument of the full +truth of this Proposition. + +So then, if the _ratio_ of the Sines of Incidence and Refraction of any +sort of Rays be found in any one case, 'tis given in all cases; and this +may be readily found by the Method in the following Proposition. + + +_PROP._ VII. THEOR. VI. + +_The Perfection of Telescopes is impeded by the different Refrangibility +of the Rays of Light._ + +The Imperfection of Telescopes is vulgarly attributed to the spherical +Figures of the Glasses, and therefore Mathematicians have propounded to +figure them by the conical Sections. To shew that they are mistaken, I +have inserted this Proposition; the truth of which will appear by the +measure of the Refractions of the several sorts of Rays; and these +measures I thus determine. + +In the third Experiment of this first Part, where the refracting Angle +of the Prism was 62-1/2 Degrees, the half of that Angle 31 deg. 15 min. +is the Angle of Incidence of the Rays at their going out of the Glass +into the Air[F]; and the Sine of this Angle is 5188, the Radius being +10000. When the Axis of this Prism was parallel to the Horizon, and the +Refraction of the Rays at their Incidence on this Prism equal to that at +their Emergence out of it, I observed with a Quadrant the Angle which +the mean refrangible Rays, (that is those which went to the middle of +the Sun's coloured Image) made with the Horizon, and by this Angle and +the Sun's altitude observed at the same time, I found the Angle which +the emergent Rays contained with the incident to be 44 deg. and 40 min. +and the half of this Angle added to the Angle of Incidence 31 deg. 15 +min. makes the Angle of Refraction, which is therefore 53 deg. 35 min. +and its Sine 8047. These are the Sines of Incidence and Refraction of +the mean refrangible Rays, and their Proportion in round Numbers is 20 +to 31. This Glass was of a Colour inclining to green. The last of the +Prisms mentioned in the third Experiment was of clear white Glass. Its +refracting Angle 63-1/2 Degrees. The Angle which the emergent Rays +contained, with the incident 45 deg. 50 min. The Sine of half the first +Angle 5262. The Sine of half the Sum of the Angles 8157. And their +Proportion in round Numbers 20 to 31, as before. + +From the Length of the Image, which was about 9-3/4 or 10 Inches, +subduct its Breadth, which was 2-1/8 Inches, and the Remainder 7-3/4 +Inches would be the Length of the Image were the Sun but a Point, and +therefore subtends the Angle which the most and least refrangible Rays, +when incident on the Prism in the same Lines, do contain with one +another after their Emergence. Whence this Angle is 2 deg. 0´. 7´´. For +the distance between the Image and the Prism where this Angle is made, +was 18-1/2 Feet, and at that distance the Chord 7-3/4 Inches subtends an +Angle of 2 deg. 0´. 7´´. Now half this Angle is the Angle which these +emergent Rays contain with the emergent mean refrangible Rays, and a +quarter thereof, that is 30´. 2´´. may be accounted the Angle which they +would contain with the same emergent mean refrangible Rays, were they +co-incident to them within the Glass, and suffered no other Refraction +than that at their Emergence. For, if two equal Refractions, the one at +the Incidence of the Rays on the Prism, the other at their Emergence, +make half the Angle 2 deg. 0´. 7´´. then one of those Refractions will +make about a quarter of that Angle, and this quarter added to, and +subducted from the Angle of Refraction of the mean refrangible Rays, +which was 53 deg. 35´, gives the Angles of Refraction of the most and +least refrangible Rays 54 deg. 5´ 2´´, and 53 deg. 4´ 58´´, whose Sines +are 8099 and 7995, the common Angle of Incidence being 31 deg. 15´, and +its Sine 5188; and these Sines in the least round Numbers are in +proportion to one another, as 78 and 77 to 50. + +Now, if you subduct the common Sine of Incidence 50 from the Sines of +Refraction 77 and 78, the Remainders 27 and 28 shew, that in small +Refractions the Refraction of the least refrangible Rays is to the +Refraction of the most refrangible ones, as 27 to 28 very nearly, and +that the difference of the Refractions of the least refrangible and most +refrangible Rays is about the 27-1/2th Part of the whole Refraction of +the mean refrangible Rays. + +Whence they that are skilled in Opticks will easily understand,[G] that +the Breadth of the least circular Space, into which Object-glasses of +Telescopes can collect all sorts of Parallel Rays, is about the 27-1/2th +Part of half the Aperture of the Glass, or 55th Part of the whole +Aperture; and that the Focus of the most refrangible Rays is nearer to +the Object-glass than the Focus of the least refrangible ones, by about +the 27-1/2th Part of the distance between the Object-glass and the Focus +of the mean refrangible ones. + +And if Rays of all sorts, flowing from any one lucid Point in the Axis +of any convex Lens, be made by the Refraction of the Lens to converge to +Points not too remote from the Lens, the Focus of the most refrangible +Rays shall be nearer to the Lens than the Focus of the least refrangible +ones, by a distance which is to the 27-1/2th Part of the distance of the +Focus of the mean refrangible Rays from the Lens, as the distance +between that Focus and the lucid Point, from whence the Rays flow, is to +the distance between that lucid Point and the Lens very nearly. + +Now to examine whether the Difference between the Refractions, which the +most refrangible and the least refrangible Rays flowing from the same +Point suffer in the Object-glasses of Telescopes and such-like Glasses, +be so great as is here described, I contrived the following Experiment. + +_Exper._ 16. The Lens which I used in the second and eighth Experiments, +being placed six Feet and an Inch distant from any Object, collected the +Species of that Object by the mean refrangible Rays at the distance of +six Feet and an Inch from the Lens on the other side. And therefore by +the foregoing Rule, it ought to collect the Species of that Object by +the least refrangible Rays at the distance of six Feet and 3-2/3 Inches +from the Lens, and by the most refrangible ones at the distance of five +Feet and 10-1/3 Inches from it: So that between the two Places, where +these least and most refrangible Rays collect the Species, there may be +the distance of about 5-1/3 Inches. For by that Rule, as six Feet and an +Inch (the distance of the Lens from the lucid Object) is to twelve Feet +and two Inches (the distance of the lucid Object from the Focus of the +mean refrangible Rays) that is, as One is to Two; so is the 27-1/2th +Part of six Feet and an Inch (the distance between the Lens and the same +Focus) to the distance between the Focus of the most refrangible Rays +and the Focus of the least refrangible ones, which is therefore 5-17/55 +Inches, that is very nearly 5-1/3 Inches. Now to know whether this +Measure was true, I repeated the second and eighth Experiment with +coloured Light, which was less compounded than that I there made use of: +For I now separated the heterogeneous Rays from one another by the +Method I described in the eleventh Experiment, so as to make a coloured +Spectrum about twelve or fifteen Times longer than broad. This Spectrum +I cast on a printed Book, and placing the above-mentioned Lens at the +distance of six Feet and an Inch from this Spectrum to collect the +Species of the illuminated Letters at the same distance on the other +side, I found that the Species of the Letters illuminated with blue were +nearer to the Lens than those illuminated with deep red by about three +Inches, or three and a quarter; but the Species of the Letters +illuminated with indigo and violet appeared so confused and indistinct, +that I could not read them: Whereupon viewing the Prism, I found it was +full of Veins running from one end of the Glass to the other; so that +the Refraction could not be regular. I took another Prism therefore +which was free from Veins, and instead of the Letters I used two or +three Parallel black Lines a little broader than the Strokes of the +Letters, and casting the Colours upon these Lines in such manner, that +the Lines ran along the Colours from one end of the Spectrum to the +other, I found that the Focus where the indigo, or confine of this +Colour and violet cast the Species of the black Lines most distinctly, +to be about four Inches, or 4-1/4 nearer to the Lens than the Focus, +where the deepest red cast the Species of the same black Lines most +distinctly. The violet was so faint and dark, that I could not discern +the Species of the Lines distinctly by that Colour; and therefore +considering that the Prism was made of a dark coloured Glass inclining +to green, I took another Prism of clear white Glass; but the Spectrum of +Colours which this Prism made had long white Streams of faint Light +shooting out from both ends of the Colours, which made me conclude that +something was amiss; and viewing the Prism, I found two or three little +Bubbles in the Glass, which refracted the Light irregularly. Wherefore I +covered that Part of the Glass with black Paper, and letting the Light +pass through another Part of it which was free from such Bubbles, the +Spectrum of Colours became free from those irregular Streams of Light, +and was now such as I desired. But still I found the violet so dark and +faint, that I could scarce see the Species of the Lines by the violet, +and not at all by the deepest Part of it, which was next the end of the +Spectrum. I suspected therefore, that this faint and dark Colour might +be allayed by that scattering Light which was refracted, and reflected +irregularly, partly by some very small Bubbles in the Glasses, and +partly by the Inequalities of their Polish; which Light, tho' it was but +little, yet it being of a white Colour, might suffice to affect the +Sense so strongly as to disturb the Phænomena of that weak and dark +Colour the violet, and therefore I tried, as in the 12th, 13th, and 14th +Experiments, whether the Light of this Colour did not consist of a +sensible Mixture of heterogeneous Rays, but found it did not. Nor did +the Refractions cause any other sensible Colour than violet to emerge +out of this Light, as they would have done out of white Light, and by +consequence out of this violet Light had it been sensibly compounded +with white Light. And therefore I concluded, that the reason why I could +not see the Species of the Lines distinctly by this Colour, was only +the Darkness of this Colour, and Thinness of its Light, and its distance +from the Axis of the Lens; I divided therefore those Parallel black +Lines into equal Parts, by which I might readily know the distances of +the Colours in the Spectrum from one another, and noted the distances of +the Lens from the Foci of such Colours, as cast the Species of the Lines +distinctly, and then considered whether the difference of those +distances bear such proportion to 5-1/3 Inches, the greatest Difference +of the distances, which the Foci of the deepest red and violet ought to +have from the Lens, as the distance of the observed Colours from one +another in the Spectrum bear to the greatest distance of the deepest red +and violet measured in the Rectilinear Sides of the Spectrum, that is, +to the Length of those Sides, or Excess of the Length of the Spectrum +above its Breadth. And my Observations were as follows. + +When I observed and compared the deepest sensible red, and the Colour in +the Confine of green and blue, which at the Rectilinear Sides of the +Spectrum was distant from it half the Length of those Sides, the Focus +where the Confine of green and blue cast the Species of the Lines +distinctly on the Paper, was nearer to the Lens than the Focus, where +the red cast those Lines distinctly on it by about 2-1/2 or 2-3/4 +Inches. For sometimes the Measures were a little greater, sometimes a +little less, but seldom varied from one another above 1/3 of an Inch. +For it was very difficult to define the Places of the Foci, without some +little Errors. Now, if the Colours distant half the Length of the +Image, (measured at its Rectilinear Sides) give 2-1/2 or 2-3/4 +Difference of the distances of their Foci from the Lens, then the +Colours distant the whole Length ought to give 5 or 5-1/2 Inches +difference of those distances. + +But here it's to be noted, that I could not see the red to the full end +of the Spectrum, but only to the Center of the Semicircle which bounded +that end, or a little farther; and therefore I compared this red not +with that Colour which was exactly in the middle of the Spectrum, or +Confine of green and blue, but with that which verged a little more to +the blue than to the green: And as I reckoned the whole Length of the +Colours not to be the whole Length of the Spectrum, but the Length of +its Rectilinear Sides, so compleating the semicircular Ends into +Circles, when either of the observed Colours fell within those Circles, +I measured the distance of that Colour from the semicircular End of the +Spectrum, and subducting half this distance from the measured distance +of the two Colours, I took the Remainder for their corrected distance; +and in these Observations set down this corrected distance for the +difference of the distances of their Foci from the Lens. For, as the +Length of the Rectilinear Sides of the Spectrum would be the whole +Length of all the Colours, were the Circles of which (as we shewed) that +Spectrum consists contracted and reduced to Physical Points, so in that +Case this corrected distance would be the real distance of the two +observed Colours. + +When therefore I farther observed the deepest sensible red, and that +blue whose corrected distance from it was 7/12 Parts of the Length of +the Rectilinear Sides of the Spectrum, the difference of the distances +of their Foci from the Lens was about 3-1/4 Inches, and as 7 to 12, so +is 3-1/4 to 5-4/7. + +When I observed the deepest sensible red, and that indigo whose +corrected distance was 8/12 or 2/3 of the Length of the Rectilinear +Sides of the Spectrum, the difference of the distances of their Foci +from the Lens, was about 3-2/3 Inches, and as 2 to 3, so is 3-2/3 to +5-1/2. + +When I observed the deepest sensible red, and that deep indigo whose +corrected distance from one another was 9/12 or 3/4 of the Length of the +Rectilinear Sides of the Spectrum, the difference of the distances of +their Foci from the Lens was about 4 Inches; and as 3 to 4, so is 4 to +5-1/3. + +When I observed the deepest sensible red, and that Part of the violet +next the indigo, whose corrected distance from the red was 10/12 or 5/6 +of the Length of the Rectilinear Sides of the Spectrum, the difference +of the distances of their Foci from the Lens was about 4-1/2 Inches, and +as 5 to 6, so is 4-1/2 to 5-2/5. For sometimes, when the Lens was +advantageously placed, so that its Axis respected the blue, and all +Things else were well ordered, and the Sun shone clear, and I held my +Eye very near to the Paper on which the Lens cast the Species of the +Lines, I could see pretty distinctly the Species of those Lines by that +Part of the violet which was next the indigo; and sometimes I could see +them by above half the violet, For in making these Experiments I had +observed, that the Species of those Colours only appear distinct, which +were in or near the Axis of the Lens: So that if the blue or indigo were +in the Axis, I could see their Species distinctly; and then the red +appeared much less distinct than before. Wherefore I contrived to make +the Spectrum of Colours shorter than before, so that both its Ends might +be nearer to the Axis of the Lens. And now its Length was about 2-1/2 +Inches, and Breadth about 1/5 or 1/6 of an Inch. Also instead of the +black Lines on which the Spectrum was cast, I made one black Line +broader than those, that I might see its Species more easily; and this +Line I divided by short cross Lines into equal Parts, for measuring the +distances of the observed Colours. And now I could sometimes see the +Species of this Line with its Divisions almost as far as the Center of +the semicircular violet End of the Spectrum, and made these farther +Observations. + +When I observed the deepest sensible red, and that Part of the violet, +whose corrected distance from it was about 8/9 Parts of the Rectilinear +Sides of the Spectrum, the Difference of the distances of the Foci of +those Colours from the Lens, was one time 4-2/3, another time 4-3/4, +another time 4-7/8 Inches; and as 8 to 9, so are 4-2/3, 4-3/4, 4-7/8, to +5-1/4, 5-11/32, 5-31/64 respectively. + +When I observed the deepest sensible red, and deepest sensible violet, +(the corrected distance of which Colours, when all Things were ordered +to the best Advantage, and the Sun shone very clear, was about 11/12 or +15/16 Parts of the Length of the Rectilinear Sides of the coloured +Spectrum) I found the Difference of the distances of their Foci from the +Lens sometimes 4-3/4 sometimes 5-1/4, and for the most part 5 Inches or +thereabouts; and as 11 to 12, or 15 to 16, so is five Inches to 5-2/2 or +5-1/3 Inches. + +And by this Progression of Experiments I satisfied my self, that had the +Light at the very Ends of the Spectrum been strong enough to make the +Species of the black Lines appear plainly on the Paper, the Focus of the +deepest violet would have been found nearer to the Lens, than the Focus +of the deepest red, by about 5-1/3 Inches at least. And this is a +farther Evidence, that the Sines of Incidence and Refraction of the +several sorts of Rays, hold the same Proportion to one another in the +smallest Refractions which they do in the greatest. + +My Progress in making this nice and troublesome Experiment I have set +down more at large, that they that shall try it after me may be aware of +the Circumspection requisite to make it succeed well. And if they cannot +make it succeed so well as I did, they may notwithstanding collect by +the Proportion of the distance of the Colours of the Spectrum, to the +Difference of the distances of their Foci from the Lens, what would be +the Success in the more distant Colours by a better trial. And yet, if +they use a broader Lens than I did, and fix it to a long strait Staff, +by means of which it may be readily and truly directed to the Colour +whose Focus is desired, I question not but the Experiment will succeed +better with them than it did with me. For I directed the Axis as nearly +as I could to the middle of the Colours, and then the faint Ends of the +Spectrum being remote from the Axis, cast their Species less distinctly +on the Paper than they would have done, had the Axis been successively +directed to them. + +Now by what has been said, it's certain that the Rays which differ in +Refrangibility do not converge to the same Focus; but if they flow from +a lucid Point, as far from the Lens on one side as their Foci are on the +other, the Focus of the most refrangible Rays shall be nearer to the +Lens than that of the least refrangible, by above the fourteenth Part of +the whole distance; and if they flow from a lucid Point, so very remote +from the Lens, that before their Incidence they may be accounted +parallel, the Focus of the most refrangible Rays shall be nearer to the +Lens than the Focus of the least refrangible, by about the 27th or 28th +Part of their whole distance from it. And the Diameter of the Circle in +the middle Space between those two Foci which they illuminate, when they +fall there on any Plane, perpendicular to the Axis (which Circle is the +least into which they can all be gathered) is about the 55th Part of the +Diameter of the Aperture of the Glass. So that 'tis a wonder, that +Telescopes represent Objects so distinct as they do. But were all the +Rays of Light equally refrangible, the Error arising only from the +Sphericalness of the Figures of Glasses would be many hundred times +less. For, if the Object-glass of a Telescope be Plano-convex, and the +Plane side be turned towards the Object, and the Diameter of the +Sphere, whereof this Glass is a Segment, be called D, and the +Semi-diameter of the Aperture of the Glass be called S, and the Sine of +Incidence out of Glass into Air, be to the Sine of Refraction as I to R; +the Rays which come parallel to the Axis of the Glass, shall in the +Place where the Image of the Object is most distinctly made, be +scattered all over a little Circle, whose Diameter is _(Rq/Iq) × (S +cub./D quad.)_ very nearly,[H] as I gather by computing the Errors of +the Rays by the Method of infinite Series, and rejecting the Terms, +whose Quantities are inconsiderable. As for instance, if the Sine of +Incidence I, be to the Sine of Refraction R, as 20 to 31, and if D the +Diameter of the Sphere, to which the Convex-side of the Glass is ground, +be 100 Feet or 1200 Inches, and S the Semi-diameter of the Aperture be +two Inches, the Diameter of the little Circle, (that is (_Rq × S +cub.)/(Iq × D quad._)) will be (31 × 31 × 8)/(20 × 20 × 1200 × 1200) (or +961/72000000) Parts of an Inch. But the Diameter of the little Circle, +through which these Rays are scattered by unequal Refrangibility, will +be about the 55th Part of the Aperture of the Object-glass, which here +is four Inches. And therefore, the Error arising from the Spherical +Figure of the Glass, is to the Error arising from the different +Refrangibility of the Rays, as 961/72000000 to 4/55, that is as 1 to +5449; and therefore being in comparison so very little, deserves not to +be considered. + +[Illustration: FIG. 27.] + +But you will say, if the Errors caused by the different Refrangibility +be so very great, how comes it to pass, that Objects appear through +Telescopes so distinct as they do? I answer, 'tis because the erring +Rays are not scattered uniformly over all that Circular Space, but +collected infinitely more densely in the Center than in any other Part +of the Circle, and in the Way from the Center to the Circumference, grow +continually rarer and rarer, so as at the Circumference to become +infinitely rare; and by reason of their Rarity are not strong enough to +be visible, unless in the Center and very near it. Let ADE [in _Fig._ +27.] represent one of those Circles described with the Center C, and +Semi-diameter AC, and let BFG be a smaller Circle concentrick to the +former, cutting with its Circumference the Diameter AC in B, and bisect +AC in N; and by my reckoning, the Density of the Light in any Place B, +will be to its Density in N, as AB to BC; and the whole Light within the +lesser Circle BFG, will be to the whole Light within the greater AED, as +the Excess of the Square of AC above the Square of AB, is to the Square +of AC. As if BC be the fifth Part of AC, the Light will be four times +denser in B than in N, and the whole Light within the less Circle, will +be to the whole Light within the greater, as nine to twenty-five. Whence +it's evident, that the Light within the less Circle, must strike the +Sense much more strongly, than that faint and dilated Light round about +between it and the Circumference of the greater. + +But it's farther to be noted, that the most luminous of the Prismatick +Colours are the yellow and orange. These affect the Senses more strongly +than all the rest together, and next to these in strength are the red +and green. The blue compared with these is a faint and dark Colour, and +the indigo and violet are much darker and fainter, so that these +compared with the stronger Colours are little to be regarded. The Images +of Objects are therefore to be placed, not in the Focus of the mean +refrangible Rays, which are in the Confine of green and blue, but in the +Focus of those Rays which are in the middle of the orange and yellow; +there where the Colour is most luminous and fulgent, that is in the +brightest yellow, that yellow which inclines more to orange than to +green. And by the Refraction of these Rays (whose Sines of Incidence and +Refraction in Glass are as 17 and 11) the Refraction of Glass and +Crystal for Optical Uses is to be measured. Let us therefore place the +Image of the Object in the Focus of these Rays, and all the yellow and +orange will fall within a Circle, whose Diameter is about the 250th +Part of the Diameter of the Aperture of the Glass. And if you add the +brighter half of the red, (that half which is next the orange) and the +brighter half of the green, (that half which is next the yellow) about +three fifth Parts of the Light of these two Colours will fall within the +same Circle, and two fifth Parts will fall without it round about; and +that which falls without will be spread through almost as much more +space as that which falls within, and so in the gross be almost three +times rarer. Of the other half of the red and green, (that is of the +deep dark red and willow green) about one quarter will fall within this +Circle, and three quarters without, and that which falls without will be +spread through about four or five times more space than that which falls +within; and so in the gross be rarer, and if compared with the whole +Light within it, will be about 25 times rarer than all that taken in the +gross; or rather more than 30 or 40 times rarer, because the deep red in +the end of the Spectrum of Colours made by a Prism is very thin and +rare, and the willow green is something rarer than the orange and +yellow. The Light of these Colours therefore being so very much rarer +than that within the Circle, will scarce affect the Sense, especially +since the deep red and willow green of this Light, are much darker +Colours than the rest. And for the same reason the blue and violet being +much darker Colours than these, and much more rarified, may be +neglected. For the dense and bright Light of the Circle, will obscure +the rare and weak Light of these dark Colours round about it, and +render them almost insensible. The sensible Image of a lucid Point is +therefore scarce broader than a Circle, whose Diameter is the 250th Part +of the Diameter of the Aperture of the Object-glass of a good Telescope, +or not much broader, if you except a faint and dark misty Light round +about it, which a Spectator will scarce regard. And therefore in a +Telescope, whose Aperture is four Inches, and Length an hundred Feet, it +exceeds not 2´´ 45´´´, or 3´´. And in a Telescope whose Aperture is two +Inches, and Length 20 or 30 Feet, it may be 5´´ or 6´´, and scarce +above. And this answers well to Experience: For some Astronomers have +found the Diameters of the fix'd Stars, in Telescopes of between 20 and +60 Feet in length, to be about 5´´ or 6´´, or at most 8´´ or 10´´ in +diameter. But if the Eye-Glass be tincted faintly with the Smoak of a +Lamp or Torch, to obscure the Light of the Star, the fainter Light in +the Circumference of the Star ceases to be visible, and the Star (if the +Glass be sufficiently soiled with Smoak) appears something more like a +mathematical Point. And for the same Reason, the enormous Part of the +Light in the Circumference of every lucid Point ought to be less +discernible in shorter Telescopes than in longer, because the shorter +transmit less Light to the Eye. + +Now, that the fix'd Stars, by reason of their immense Distance, appear +like Points, unless so far as their Light is dilated by Refraction, may +appear from hence; that when the Moon passes over them and eclipses +them, their Light vanishes, not gradually like that of the Planets, but +all at once; and in the end of the Eclipse it returns into Sight all at +once, or certainly in less time than the second of a Minute; the +Refraction of the Moon's Atmosphere a little protracting the time in +which the Light of the Star first vanishes, and afterwards returns into +Sight. + +Now, if we suppose the sensible Image of a lucid Point, to be even 250 +times narrower than the Aperture of the Glass; yet this Image would be +still much greater than if it were only from the spherical Figure of the +Glass. For were it not for the different Refrangibility of the Rays, its +breadth in an 100 Foot Telescope whose aperture is 4 Inches, would be +but 961/72000000 parts of an Inch, as is manifest by the foregoing +Computation. And therefore in this case the greatest Errors arising from +the spherical Figure of the Glass, would be to the greatest sensible +Errors arising from the different Refrangibility of the Rays as +961/72000000 to 4/250 at most, that is only as 1 to 1200. And this +sufficiently shews that it is not the spherical Figures of Glasses, but +the different Refrangibility of the Rays which hinders the perfection of +Telescopes. + +There is another Argument by which it may appear that the different +Refrangibility of Rays, is the true cause of the imperfection of +Telescopes. For the Errors of the Rays arising from the spherical +Figures of Object-glasses, are as the Cubes of the Apertures of the +Object Glasses; and thence to make Telescopes of various Lengths magnify +with equal distinctness, the Apertures of the Object-glasses, and the +Charges or magnifying Powers ought to be as the Cubes of the square +Roots of their lengths; which doth not answer to Experience. But the +Errors of the Rays arising from the different Refrangibility, are as the +Apertures of the Object-glasses; and thence to make Telescopes of +various lengths, magnify with equal distinctness, their Apertures and +Charges ought to be as the square Roots of their lengths; and this +answers to Experience, as is well known. For Instance, a Telescope of 64 +Feet in length, with an Aperture of 2-2/3 Inches, magnifies about 120 +times, with as much distinctness as one of a Foot in length, with 1/3 of +an Inch aperture, magnifies 15 times. + +[Illustration: FIG. 28.] + +Now were it not for this different Refrangibility of Rays, Telescopes +might be brought to a greater perfection than we have yet describ'd, by +composing the Object-glass of two Glasses with Water between them. Let +ADFC [in _Fig._ 28.] represent the Object-glass composed of two Glasses +ABED and BEFC, alike convex on the outsides AGD and CHF, and alike +concave on the insides BME, BNE, with Water in the concavity BMEN. Let +the Sine of Incidence out of Glass into Air be as I to R, and out of +Water into Air, as K to R, and by consequence out of Glass into Water, +as I to K: and let the Diameter of the Sphere to which the convex sides +AGD and CHF are ground be D, and the Diameter of the Sphere to which the +concave sides BME and BNE, are ground be to D, as the Cube Root of +KK--KI to the Cube Root of RK--RI: and the Refractions on the concave +sides of the Glasses, will very much correct the Errors of the +Refractions on the convex sides, so far as they arise from the +sphericalness of the Figure. And by this means might Telescopes be +brought to sufficient perfection, were it not for the different +Refrangibility of several sorts of Rays. But by reason of this different +Refrangibility, I do not yet see any other means of improving Telescopes +by Refractions alone, than that of increasing their lengths, for which +end the late Contrivance of _Hugenius_ seems well accommodated. For very +long Tubes are cumbersome, and scarce to be readily managed, and by +reason of their length are very apt to bend, and shake by bending, so as +to cause a continual trembling in the Objects, whereby it becomes +difficult to see them distinctly: whereas by his Contrivance the Glasses +are readily manageable, and the Object-glass being fix'd upon a strong +upright Pole becomes more steady. + +Seeing therefore the Improvement of Telescopes of given lengths by +Refractions is desperate; I contrived heretofore a Perspective by +Reflexion, using instead of an Object-glass a concave Metal. The +diameter of the Sphere to which the Metal was ground concave was about +25 _English_ Inches, and by consequence the length of the Instrument +about six Inches and a quarter. The Eye-glass was Plano-convex, and the +diameter of the Sphere to which the convex side was ground was about 1/5 +of an Inch, or a little less, and by consequence it magnified between 30 +and 40 times. By another way of measuring I found that it magnified +about 35 times. The concave Metal bore an Aperture of an Inch and a +third part; but the Aperture was limited not by an opake Circle, +covering the Limb of the Metal round about, but by an opake Circle +placed between the Eyeglass and the Eye, and perforated in the middle +with a little round hole for the Rays to pass through to the Eye. For +this Circle by being placed here, stopp'd much of the erroneous Light, +which otherwise would have disturbed the Vision. By comparing it with a +pretty good Perspective of four Feet in length, made with a concave +Eye-glass, I could read at a greater distance with my own Instrument +than with the Glass. Yet Objects appeared much darker in it than in the +Glass, and that partly because more Light was lost by Reflexion in the +Metal, than by Refraction in the Glass, and partly because my Instrument +was overcharged. Had it magnified but 30 or 25 times, it would have made +the Object appear more brisk and pleasant. Two of these I made about 16 +Years ago, and have one of them still by me, by which I can prove the +truth of what I write. Yet it is not so good as at the first. For the +concave has been divers times tarnished and cleared again, by rubbing +it with very soft Leather. When I made these an Artist in _London_ +undertook to imitate it; but using another way of polishing them than I +did, he fell much short of what I had attained to, as I afterwards +understood by discoursing the Under-workman he had employed. The Polish +I used was in this manner. I had two round Copper Plates, each six +Inches in Diameter, the one convex, the other concave, ground very true +to one another. On the convex I ground the Object-Metal or Concave which +was to be polish'd, 'till it had taken the Figure of the Convex and was +ready for a Polish. Then I pitched over the convex very thinly, by +dropping melted Pitch upon it, and warming it to keep the Pitch soft, +whilst I ground it with the concave Copper wetted to make it spread +eavenly all over the convex. Thus by working it well I made it as thin +as a Groat, and after the convex was cold I ground it again to give it +as true a Figure as I could. Then I took Putty which I had made very +fine by washing it from all its grosser Particles, and laying a little +of this upon the Pitch, I ground it upon the Pitch with the concave +Copper, till it had done making a Noise; and then upon the Pitch I +ground the Object-Metal with a brisk motion, for about two or three +Minutes of time, leaning hard upon it. Then I put fresh Putty upon the +Pitch, and ground it again till it had done making a noise, and +afterwards ground the Object-Metal upon it as before. And this Work I +repeated till the Metal was polished, grinding it the last time with all +my strength for a good while together, and frequently breathing upon +the Pitch, to keep it moist without laying on any more fresh Putty. The +Object-Metal was two Inches broad, and about one third part of an Inch +thick, to keep it from bending. I had two of these Metals, and when I +had polished them both, I tried which was best, and ground the other +again, to see if I could make it better than that which I kept. And thus +by many Trials I learn'd the way of polishing, till I made those two +reflecting Perspectives I spake of above. For this Art of polishing will +be better learn'd by repeated Practice than by my Description. Before I +ground the Object-Metal on the Pitch, I always ground the Putty on it +with the concave Copper, till it had done making a noise, because if the +Particles of the Putty were not by this means made to stick fast in the +Pitch, they would by rolling up and down grate and fret the Object-Metal +and fill it full of little holes. + +But because Metal is more difficult to polish than Glass, and is +afterwards very apt to be spoiled by tarnishing, and reflects not so +much Light as Glass quick-silver'd over does: I would propound to use +instead of the Metal, a Glass ground concave on the foreside, and as +much convex on the backside, and quick-silver'd over on the convex side. +The Glass must be every where of the same thickness exactly. Otherwise +it will make Objects look colour'd and indistinct. By such a Glass I +tried about five or six Years ago to make a reflecting Telescope of four +Feet in length to magnify about 150 times, and I satisfied my self that +there wants nothing but a good Artist to bring the Design to +perfection. For the Glass being wrought by one of our _London_ Artists +after such a manner as they grind Glasses for Telescopes, though it +seemed as well wrought as the Object-glasses use to be, yet when it was +quick-silver'd, the Reflexion discovered innumerable Inequalities all +over the Glass. And by reason of these Inequalities, Objects appeared +indistinct in this Instrument. For the Errors of reflected Rays caused +by any Inequality of the Glass, are about six times greater than the +Errors of refracted Rays caused by the like Inequalities. Yet by this +Experiment I satisfied my self that the Reflexion on the concave side of +the Glass, which I feared would disturb the Vision, did no sensible +prejudice to it, and by consequence that nothing is wanting to perfect +these Telescopes, but good Workmen who can grind and polish Glasses +truly spherical. An Object-glass of a fourteen Foot Telescope, made by +an Artificer at _London_, I once mended considerably, by grinding it on +Pitch with Putty, and leaning very easily on it in the grinding, lest +the Putty should scratch it. Whether this way may not do well enough for +polishing these reflecting Glasses, I have not yet tried. But he that +shall try either this or any other way of polishing which he may think +better, may do well to make his Glasses ready for polishing, by grinding +them without that Violence, wherewith our _London_ Workmen press their +Glasses in grinding. For by such violent pressure, Glasses are apt to +bend a little in the grinding, and such bending will certainly spoil +their Figure. To recommend therefore the consideration of these +reflecting Glasses to such Artists as are curious in figuring Glasses, I +shall describe this optical Instrument in the following Proposition. + + +_PROP._ VIII. PROB. II. + +_To shorten Telescopes._ + +Let ABCD [in _Fig._ 29.] represent a Glass spherically concave on the +foreside AB, and as much convex on the backside CD, so that it be every +where of an equal thickness. Let it not be thicker on one side than on +the other, lest it make Objects appear colour'd and indistinct, and let +it be very truly wrought and quick-silver'd over on the backside; and +set in the Tube VXYZ which must be very black within. Let EFG represent +a Prism of Glass or Crystal placed near the other end of the Tube, in +the middle of it, by means of a handle of Brass or Iron FGK, to the end +of which made flat it is cemented. Let this Prism be rectangular at E, +and let the other two Angles at F and G be accurately equal to each +other, and by consequence equal to half right ones, and let the plane +sides FE and GE be square, and by consequence the third side FG a +rectangular Parallelogram, whose length is to its breadth in a +subduplicate proportion of two to one. Let it be so placed in the Tube, +that the Axis of the Speculum may pass through the middle of the square +side EF perpendicularly and by consequence through the middle of the +side FG at an Angle of 45 Degrees, and let the side EF be turned towards +the Speculum, and the distance of this Prism from the Speculum be such +that the Rays of the Light PQ, RS, &c. which are incident upon the +Speculum in Lines parallel to the Axis thereof, may enter the Prism at +the side EF, and be reflected by the side FG, and thence go out of it +through the side GE, to the Point T, which must be the common Focus of +the Speculum ABDC, and of a Plano-convex Eye-glass H, through which +those Rays must pass to the Eye. And let the Rays at their coming out of +the Glass pass through a small round hole, or aperture made in a little +plate of Lead, Brass, or Silver, wherewith the Glass is to be covered, +which hole must be no bigger than is necessary for Light enough to pass +through. For so it will render the Object distinct, the Plate in which +'tis made intercepting all the erroneous part of the Light which comes +from the verges of the Speculum AB. Such an Instrument well made, if it +be six Foot long, (reckoning the length from the Speculum to the Prism, +and thence to the Focus T) will bear an aperture of six Inches at the +Speculum, and magnify between two and three hundred times. But the hole +H here limits the aperture with more advantage, than if the aperture was +placed at the Speculum. If the Instrument be made longer or shorter, the +aperture must be in proportion as the Cube of the square-square Root of +the length, and the magnifying as the aperture. But it's convenient that +the Speculum be an Inch or two broader than the aperture at the least, +and that the Glass of the Speculum be thick, that it bend not in the +working. The Prism EFG must be no bigger than is necessary, and its back +side FG must not be quick-silver'd over. For without quicksilver it will +reflect all the Light incident on it from the Speculum. + +[Illustration: FIG. 29.] + +In this Instrument the Object will be inverted, but may be erected by +making the square sides FF and EG of the Prism EFG not plane but +spherically convex, that the Rays may cross as well before they come at +it as afterwards between it and the Eye-glass. If it be desired that the +Instrument bear a larger aperture, that may be also done by composing +the Speculum of two Glasses with Water between them. + +If the Theory of making Telescopes could at length be fully brought into +Practice, yet there would be certain Bounds beyond which Telescopes +could not perform. For the Air through which we look upon the Stars, is +in a perpetual Tremor; as may be seen by the tremulous Motion of Shadows +cast from high Towers, and by the twinkling of the fix'd Stars. But +these Stars do not twinkle when viewed through Telescopes which have +large apertures. For the Rays of Light which pass through divers parts +of the aperture, tremble each of them apart, and by means of their +various and sometimes contrary Tremors, fall at one and the same time +upon different points in the bottom of the Eye, and their trembling +Motions are too quick and confused to be perceived severally. And all +these illuminated Points constitute one broad lucid Point, composed of +those many trembling Points confusedly and insensibly mixed with one +another by very short and swift Tremors, and thereby cause the Star to +appear broader than it is, and without any trembling of the whole. Long +Telescopes may cause Objects to appear brighter and larger than short +ones can do, but they cannot be so formed as to take away that confusion +of the Rays which arises from the Tremors of the Atmosphere. The only +Remedy is a most serene and quiet Air, such as may perhaps be found on +the tops of the highest Mountains above the grosser Clouds. + +FOOTNOTES: + +[C] _See our_ Author's Lectiones Opticæ § 10. _Sect. II. § 29. and Sect. +III. Prop. 25._ + +[D] See our Author's _Lectiones Opticæ_, Part. I. Sect. 1. §5. + +[E] _This is very fully treated of in our_ Author's Lect. Optic. _Part_ +I. _Sect._ II. + +[F] _See our_ Author's Lect. Optic. Part I. Sect. II. § 29. + +[G] _This is demonstrated in our_ Author's Lect. Optic. _Part_ I. +_Sect._ IV. _Prop._ 37. + +[H] _How to do this, is shewn in our_ Author's Lect. Optic. _Part_ I. +_Sect._ IV. _Prop._ 31. + + + + +THE FIRST BOOK OF OPTICKS + + + + +_PART II._ + + +_PROP._ I. THEOR. I. + +_The Phænomena of Colours in refracted or reflected Light are not caused +by new Modifications of the Light variously impress'd, according to the +various Terminations of the Light and Shadow_. + +The PROOF by Experiments. + +_Exper._ 1. For if the Sun shine into a very dark Chamber through an +oblong hole F, [in _Fig._ 1.] whose breadth is the sixth or eighth part +of an Inch, or something less; and his beam FH do afterwards pass first +through a very large Prism ABC, distant about 20 Feet from the hole, and +parallel to it, and then (with its white part) through an oblong hole H, +whose breadth is about the fortieth or sixtieth part of an Inch, and +which is made in a black opake Body GI, and placed at the distance of +two or three Feet from the Prism, in a parallel Situation both to the +Prism and to the former hole, and if this white Light thus transmitted +through the hole H, fall afterwards upon a white Paper _pt_, placed +after that hole H, at the distance of three or four Feet from it, and +there paint the usual Colours of the Prism, suppose red at _t_, yellow +at _s_, green at _r_, blue at _q_, and violet at _p_; you may with an +Iron Wire, or any such like slender opake Body, whose breadth is about +the tenth part of an Inch, by intercepting the Rays at _k_, _l_, _m_, +_n_ or _o_, take away any one of the Colours at _t_, _s_, _r_, _q_ or +_p_, whilst the other Colours remain upon the Paper as before; or with +an Obstacle something bigger you may take away any two, or three, or +four Colours together, the rest remaining: So that any one of the +Colours as well as violet may become outmost in the Confine of the +Shadow towards _p_, and any one of them as well as red may become +outmost in the Confine of the Shadow towards _t_, and any one of them +may also border upon the Shadow made within the Colours by the Obstacle +R intercepting some intermediate part of the Light; and, lastly, any one +of them by being left alone, may border upon the Shadow on either hand. +All the Colours have themselves indifferently to any Confines of Shadow, +and therefore the differences of these Colours from one another, do not +arise from the different Confines of Shadow, whereby Light is variously +modified, as has hitherto been the Opinion of Philosophers. In trying +these things 'tis to be observed, that by how much the holes F and H are +narrower, and the Intervals between them and the Prism greater, and the +Chamber darker, by so much the better doth the Experiment succeed; +provided the Light be not so far diminished, but that the Colours at +_pt_ be sufficiently visible. To procure a Prism of solid Glass large +enough for this Experiment will be difficult, and therefore a prismatick +Vessel must be made of polish'd Glass Plates cemented together, and +filled with salt Water or clear Oil. + +[Illustration: FIG. 1.] + +_Exper._ 2. The Sun's Light let into a dark Chamber through the round +hole F, [in _Fig._ 2.] half an Inch wide, passed first through the Prism +ABC placed at the hole, and then through a Lens PT something more than +four Inches broad, and about eight Feet distant from the Prism, and +thence converged to O the Focus of the Lens distant from it about three +Feet, and there fell upon a white Paper DE. If that Paper was +perpendicular to that Light incident upon it, as 'tis represented in the +posture DE, all the Colours upon it at O appeared white. But if the +Paper being turned about an Axis parallel to the Prism, became very much +inclined to the Light, as 'tis represented in the Positions _de_ and +_[Greek: de]_; the same Light in the one case appeared yellow and red, +in the other blue. Here one and the same part of the Light in one and +the same place, according to the various Inclinations of the Paper, +appeared in one case white, in another yellow or red, in a third blue, +whilst the Confine of Light and shadow, and the Refractions of the Prism +in all these cases remained the same. + +[Illustration: FIG. 2.] + +[Illustration: FIG. 3.] + +_Exper._ 3. Such another Experiment may be more easily tried as follows. +Let a broad beam of the Sun's Light coming into a dark Chamber through a +hole in the Window-shut be refracted by a large Prism ABC, [in _Fig._ +3.] whose refracting Angle C is more than 60 Degrees, and so soon as it +comes out of the Prism, let it fall upon the white Paper DE glewed upon +a stiff Plane; and this Light, when the Paper is perpendicular to it, as +'tis represented in DE, will appear perfectly white upon the Paper; but +when the Paper is very much inclin'd to it in such a manner as to keep +always parallel to the Axis of the Prism, the whiteness of the whole +Light upon the Paper will according to the inclination of the Paper this +way or that way, change either into yellow and red, as in the posture +_de_, or into blue and violet, as in the posture [Greek: de]. And if the +Light before it fall upon the Paper be twice refracted the same way by +two parallel Prisms, these Colours will become the more conspicuous. +Here all the middle parts of the broad beam of white Light which fell +upon the Paper, did without any Confine of Shadow to modify it, become +colour'd all over with one uniform Colour, the Colour being always the +same in the middle of the Paper as at the edges, and this Colour changed +according to the various Obliquity of the reflecting Paper, without any +change in the Refractions or Shadow, or in the Light which fell upon the +Paper. And therefore these Colours are to be derived from some other +Cause than the new Modifications of Light by Refractions and Shadows. + +If it be asked, what then is their Cause? I answer, That the Paper in +the posture _de_, being more oblique to the more refrangible Rays than +to the less refrangible ones, is more strongly illuminated by the latter +than by the former, and therefore the less refrangible Rays are +predominant in the reflected Light. And where-ever they are predominant +in any Light, they tinge it with red or yellow, as may in some measure +appear by the first Proposition of the first Part of this Book, and will +more fully appear hereafter. And the contrary happens in the posture of +the Paper [Greek: de], the more refrangible Rays being then predominant +which always tinge Light with blues and violets. + +_Exper._ 4. The Colours of Bubbles with which Children play are various, +and change their Situation variously, without any respect to any Confine +or Shadow. If such a Bubble be cover'd with a concave Glass, to keep it +from being agitated by any Wind or Motion of the Air, the Colours will +slowly and regularly change their situation, even whilst the Eye and the +Bubble, and all Bodies which emit any Light, or cast any Shadow, remain +unmoved. And therefore their Colours arise from some regular Cause which +depends not on any Confine of Shadow. What this Cause is will be shewed +in the next Book. + +To these Experiments may be added the tenth Experiment of the first Part +of this first Book, where the Sun's Light in a dark Room being +trajected through the parallel Superficies of two Prisms tied together +in the form of a Parallelopipede, became totally of one uniform yellow +or red Colour, at its emerging out of the Prisms. Here, in the +production of these Colours, the Confine of Shadow can have nothing to +do. For the Light changes from white to yellow, orange and red +successively, without any alteration of the Confine of Shadow: And at +both edges of the emerging Light where the contrary Confines of Shadow +ought to produce different Effects, the Colour is one and the same, +whether it be white, yellow, orange or red: And in the middle of the +emerging Light, where there is no Confine of Shadow at all, the Colour +is the very same as at the edges, the whole Light at its very first +Emergence being of one uniform Colour, whether white, yellow, orange or +red, and going on thence perpetually without any change of Colour, such +as the Confine of Shadow is vulgarly supposed to work in refracted Light +after its Emergence. Neither can these Colours arise from any new +Modifications of the Light by Refractions, because they change +successively from white to yellow, orange and red, while the Refractions +remain the same, and also because the Refractions are made contrary ways +by parallel Superficies which destroy one another's Effects. They arise +not therefore from any Modifications of Light made by Refractions and +Shadows, but have some other Cause. What that Cause is we shewed above +in this tenth Experiment, and need not here repeat it. + +There is yet another material Circumstance of this Experiment. For this +emerging Light being by a third Prism HIK [in _Fig._ 22. _Part_ I.][I] +refracted towards the Paper PT, and there painting the usual Colours of +the Prism, red, yellow, green, blue, violet: If these Colours arose from +the Refractions of that Prism modifying the Light, they would not be in +the Light before its Incidence on that Prism. And yet in that Experiment +we found, that when by turning the two first Prisms about their common +Axis all the Colours were made to vanish but the red; the Light which +makes that red being left alone, appeared of the very same red Colour +before its Incidence on the third Prism. And in general we find by other +Experiments, that when the Rays which differ in Refrangibility are +separated from one another, and any one Sort of them is considered +apart, the Colour of the Light which they compose cannot be changed by +any Refraction or Reflexion whatever, as it ought to be were Colours +nothing else than Modifications of Light caused by Refractions, and +Reflexions, and Shadows. This Unchangeableness of Colour I am now to +describe in the following Proposition. + + +_PROP._ II. THEOR. II. + +_All homogeneal Light has its proper Colour answering to its Degree of +Refrangibility, and that Colour cannot be changed by Reflexions and +Refractions._ + +In the Experiments of the fourth Proposition of the first Part of this +first Book, when I had separated the heterogeneous Rays from one +another, the Spectrum _pt_ formed by the separated Rays, did in the +Progress from its End _p_, on which the most refrangible Rays fell, unto +its other End _t_, on which the least refrangible Rays fell, appear +tinged with this Series of Colours, violet, indigo, blue, green, yellow, +orange, red, together with all their intermediate Degrees in a continual +Succession perpetually varying. So that there appeared as many Degrees +of Colours, as there were sorts of Rays differing in Refrangibility. + +_Exper._ 5. Now, that these Colours could not be changed by Refraction, +I knew by refracting with a Prism sometimes one very little Part of this +Light, sometimes another very little Part, as is described in the +twelfth Experiment of the first Part of this Book. For by this +Refraction the Colour of the Light was never changed in the least. If +any Part of the red Light was refracted, it remained totally of the same +red Colour as before. No orange, no yellow, no green or blue, no other +new Colour was produced by that Refraction. Neither did the Colour any +ways change by repeated Refractions, but continued always the same red +entirely as at first. The like Constancy and Immutability I found also +in the blue, green, and other Colours. So also, if I looked through a +Prism upon any Body illuminated with any part of this homogeneal Light, +as in the fourteenth Experiment of the first Part of this Book is +described; I could not perceive any new Colour generated this way. All +Bodies illuminated with compound Light appear through Prisms confused, +(as was said above) and tinged with various new Colours, but those +illuminated with homogeneal Light appeared through Prisms neither less +distinct, nor otherwise colour'd, than when viewed with the naked Eyes. +Their Colours were not in the least changed by the Refraction of the +interposed Prism. I speak here of a sensible Change of Colour: For the +Light which I here call homogeneal, being not absolutely homogeneal, +there ought to arise some little Change of Colour from its +Heterogeneity. But, if that Heterogeneity was so little as it might be +made by the said Experiments of the fourth Proposition, that Change was +not sensible, and therefore in Experiments, where Sense is Judge, ought +to be accounted none at all. + +_Exper._ 6. And as these Colours were not changeable by Refractions, so +neither were they by Reflexions. For all white, grey, red, yellow, +green, blue, violet Bodies, as Paper, Ashes, red Lead, Orpiment, Indico +Bise, Gold, Silver, Copper, Grass, blue Flowers, Violets, Bubbles of +Water tinged with various Colours, Peacock's Feathers, the Tincture of +_Lignum Nephriticum_, and such-like, in red homogeneal Light appeared +totally red, in blue Light totally blue, in green Light totally green, +and so of other Colours. In the homogeneal Light of any Colour they all +appeared totally of that same Colour, with this only Difference, that +some of them reflected that Light more strongly, others more faintly. I +never yet found any Body, which by reflecting homogeneal Light could +sensibly change its Colour. + +From all which it is manifest, that if the Sun's Light consisted of but +one sort of Rays, there would be but one Colour in the whole World, nor +would it be possible to produce any new Colour by Reflexions and +Refractions, and by consequence that the variety of Colours depends upon +the Composition of Light. + + +_DEFINITION._ + +The homogeneal Light and Rays which appear red, or rather make Objects +appear so, I call Rubrifick or Red-making; those which make Objects +appear yellow, green, blue, and violet, I call Yellow-making, +Green-making, Blue-making, Violet-making, and so of the rest. And if at +any time I speak of Light and Rays as coloured or endued with Colours, I +would be understood to speak not philosophically and properly, but +grossly, and accordingly to such Conceptions as vulgar People in seeing +all these Experiments would be apt to frame. For the Rays to speak +properly are not coloured. In them there is nothing else than a certain +Power and Disposition to stir up a Sensation of this or that Colour. +For as Sound in a Bell or musical String, or other sounding Body, is +nothing but a trembling Motion, and in the Air nothing but that Motion +propagated from the Object, and in the Sensorium 'tis a Sense of that +Motion under the Form of Sound; so Colours in the Object are nothing but +a Disposition to reflect this or that sort of Rays more copiously than +the rest; in the Rays they are nothing but their Dispositions to +propagate this or that Motion into the Sensorium, and in the Sensorium +they are Sensations of those Motions under the Forms of Colours. + + +_PROP._ III. PROB. I. + +_To define the Refrangibility of the several sorts of homogeneal Light +answering to the several Colours._ + +For determining this Problem I made the following Experiment.[J] + +_Exper._ 7. When I had caused the Rectilinear Sides AF, GM, [in _Fig._ +4.] of the Spectrum of Colours made by the Prism to be distinctly +defined, as in the fifth Experiment of the first Part of this Book is +described, there were found in it all the homogeneal Colours in the same +Order and Situation one among another as in the Spectrum of simple +Light, described in the fourth Proposition of that Part. For the Circles +of which the Spectrum of compound Light PT is composed, and which in +the middle Parts of the Spectrum interfere, and are intermix'd with one +another, are not intermix'd in their outmost Parts where they touch +those Rectilinear Sides AF and GM. And therefore, in those Rectilinear +Sides when distinctly defined, there is no new Colour generated by +Refraction. I observed also, that if any where between the two outmost +Circles TMF and PGA a Right Line, as [Greek: gd], was cross to the +Spectrum, so as both Ends to fall perpendicularly upon its Rectilinear +Sides, there appeared one and the same Colour, and degree of Colour from +one End of this Line to the other. I delineated therefore in a Paper the +Perimeter of the Spectrum FAP GMT, and in trying the third Experiment of +the first Part of this Book, I held the Paper so that the Spectrum might +fall upon this delineated Figure, and agree with it exactly, whilst an +Assistant, whose Eyes for distinguishing Colours were more critical than +mine, did by Right Lines [Greek: ab, gd, ez,] &c. drawn cross the +Spectrum, note the Confines of the Colours, that is of the red M[Greek: +ab]F, of the orange [Greek: agdb], of the yellow [Greek: gezd], of the +green [Greek: eêthz], of the blue [Greek: êikth], of the indico [Greek: +ilmk], and of the violet [Greek: l]GA[Greek: m]. And this Operation +being divers times repeated both in the same, and in several Papers, I +found that the Observations agreed well enough with one another, and +that the Rectilinear Sides MG and FA were by the said cross Lines +divided after the manner of a Musical Chord. Let GM be produced to X, +that MX may be equal to GM, and conceive GX, [Greek: l]X, [Greek: i]X, +[Greek: ê]X, [Greek: e]X, [Greek: g]X, [Greek: a]X, MX, to be in +proportion to one another, as the Numbers, 1, 8/9, 5/6, 3/4, 2/3, 3/5, +9/16, 1/2, and so to represent the Chords of the Key, and of a Tone, a +third Minor, a fourth, a fifth, a sixth Major, a seventh and an eighth +above that Key: And the Intervals M[Greek: a], [Greek: ag], [Greek: ge], +[Greek: eê], [Greek: êi], [Greek: il], and [Greek: l]G, will be the +Spaces which the several Colours (red, orange, yellow, green, blue, +indigo, violet) take up. + +[Illustration: FIG. 4.] + +[Illustration: FIG. 5.] + +Now these Intervals or Spaces subtending the Differences of the +Refractions of the Rays going to the Limits of those Colours, that is, +to the Points M, [Greek: a], [Greek: g], [Greek: e], [Greek: ê], [Greek: +i], [Greek: l], G, may without any sensible Error be accounted +proportional to the Differences of the Sines of Refraction of those Rays +having one common Sine of Incidence, and therefore since the common Sine +of Incidence of the most and least refrangible Rays out of Glass into +Air was (by a Method described above) found in proportion to their Sines +of Refraction, as 50 to 77 and 78, divide the Difference between the +Sines of Refraction 77 and 78, as the Line GM is divided by those +Intervals, and you will have 77, 77-1/8, 77-1/5, 77-1/3, 77-1/2, 77-2/3, +77-7/9, 78, the Sines of Refraction of those Rays out of Glass into Air, +their common Sine of Incidence being 50. So then the Sines of the +Incidences of all the red-making Rays out of Glass into Air, were to the +Sines of their Refractions, not greater than 50 to 77, nor less than 50 +to 77-1/8, but they varied from one another according to all +intermediate Proportions. And the Sines of the Incidences of the +green-making Rays were to the Sines of their Refractions in all +Proportions from that of 50 to 77-1/3, unto that of 50 to 77-1/2. And +by the like Limits above-mentioned were the Refractions of the Rays +belonging to the rest of the Colours defined, the Sines of the +red-making Rays extending from 77 to 77-1/8, those of the orange-making +from 77-1/8 to 77-1/5, those of the yellow-making from 77-1/5 to 77-1/3, +those of the green-making from 77-1/3 to 77-1/2, those of the +blue-making from 77-1/2 to 77-2/3, those of the indigo-making from +77-2/3 to 77-7/9, and those of the violet from 77-7/9, to 78. + +These are the Laws of the Refractions made out of Glass into Air, and +thence by the third Axiom of the first Part of this Book, the Laws of +the Refractions made out of Air into Glass are easily derived. + +_Exper._ 8. I found moreover, that when Light goes out of Air through +several contiguous refracting Mediums as through Water and Glass, and +thence goes out again into Air, whether the refracting Superficies be +parallel or inclin'd to one another, that Light as often as by contrary +Refractions 'tis so corrected, that it emergeth in Lines parallel to +those in which it was incident, continues ever after to be white. But if +the emergent Rays be inclined to the incident, the Whiteness of the +emerging Light will by degrees in passing on from the Place of +Emergence, become tinged in its Edges with Colours. This I try'd by +refracting Light with Prisms of Glass placed within a Prismatick Vessel +of Water. Now those Colours argue a diverging and separation of the +heterogeneous Rays from one another by means of their unequal +Refractions, as in what follows will more fully appear. And, on the +contrary, the permanent whiteness argues, that in like Incidences of the +Rays there is no such separation of the emerging Rays, and by +consequence no inequality of their whole Refractions. Whence I seem to +gather the two following Theorems. + +1. The Excesses of the Sines of Refraction of several sorts of Rays +above their common Sine of Incidence when the Refractions are made out +of divers denser Mediums immediately into one and the same rarer Medium, +suppose of Air, are to one another in a given Proportion. + +2. The Proportion of the Sine of Incidence to the Sine of Refraction of +one and the same sort of Rays out of one Medium into another, is +composed of the Proportion of the Sine of Incidence to the Sine of +Refraction out of the first Medium into any third Medium, and of the +Proportion of the Sine of Incidence to the Sine of Refraction out of +that third Medium into the second Medium. + +By the first Theorem the Refractions of the Rays of every sort made out +of any Medium into Air are known by having the Refraction of the Rays of +any one sort. As for instance, if the Refractions of the Rays of every +sort out of Rain-water into Air be desired, let the common Sine of +Incidence out of Glass into Air be subducted from the Sines of +Refraction, and the Excesses will be 27, 27-1/8, 27-1/5, 27-1/3, 27-1/2, +27-2/3, 27-7/9, 28. Suppose now that the Sine of Incidence of the least +refrangible Rays be to their Sine of Refraction out of Rain-water into +Air as 3 to 4, and say as 1 the difference of those Sines is to 3 the +Sine of Incidence, so is 27 the least of the Excesses above-mentioned to +a fourth Number 81; and 81 will be the common Sine of Incidence out of +Rain-water into Air, to which Sine if you add all the above-mentioned +Excesses, you will have the desired Sines of the Refractions 108, +108-1/8, 108-1/5, 108-1/3, 108-1/2, 108-2/3, 108-7/9, 109. + +By the latter Theorem the Refraction out of one Medium into another is +gathered as often as you have the Refractions out of them both into any +third Medium. As if the Sine of Incidence of any Ray out of Glass into +Air be to its Sine of Refraction, as 20 to 31, and the Sine of Incidence +of the same Ray out of Air into Water, be to its Sine of Refraction as 4 +to 3; the Sine of Incidence of that Ray out of Glass into Water will be +to its Sine of Refraction as 20 to 31 and 4 to 3 jointly, that is, as +the Factum of 20 and 4 to the Factum of 31 and 3, or as 80 to 93. + +And these Theorems being admitted into Opticks, there would be scope +enough of handling that Science voluminously after a new manner,[K] not +only by teaching those things which tend to the perfection of Vision, +but also by determining mathematically all kinds of Phænomena of Colours +which could be produced by Refractions. For to do this, there is nothing +else requisite than to find out the Separations of heterogeneous Rays, +and their various Mixtures and Proportions in every Mixture. By this +way of arguing I invented almost all the Phænomena described in these +Books, beside some others less necessary to the Argument; and by the +successes I met with in the Trials, I dare promise, that to him who +shall argue truly, and then try all things with good Glasses and +sufficient Circumspection, the expected Event will not be wanting. But +he is first to know what Colours will arise from any others mix'd in any +assigned Proportion. + + +_PROP._ IV. THEOR. III. + +_Colours may be produced by Composition which shall be like to the +Colours of homogeneal Light as to the Appearance of Colour, but not as +to the Immutability of Colour and Constitution of Light. And those +Colours by how much they are more compounded by so much are they less +full and intense, and by too much Composition they maybe diluted and +weaken'd till they cease, and the Mixture becomes white or grey. There +may be also Colours produced by Composition, which are not fully like +any of the Colours of homogeneal Light._ + +For a Mixture of homogeneal red and yellow compounds an Orange, like in +appearance of Colour to that orange which in the series of unmixed +prismatick Colours lies between them; but the Light of one orange is +homogeneal as to Refrangibility, and that of the other is heterogeneal, +and the Colour of the one, if viewed through a Prism, remains unchanged, +that of the other is changed and resolved into its component Colours red +and yellow. And after the same manner other neighbouring homogeneal +Colours may compound new Colours, like the intermediate homogeneal ones, +as yellow and green, the Colour between them both, and afterwards, if +blue be added, there will be made a green the middle Colour of the three +which enter the Composition. For the yellow and blue on either hand, if +they are equal in quantity they draw the intermediate green equally +towards themselves in Composition, and so keep it as it were in +Æquilibrion, that it verge not more to the yellow on the one hand, and +to the blue on the other, but by their mix'd Actions remain still a +middle Colour. To this mix'd green there may be farther added some red +and violet, and yet the green will not presently cease, but only grow +less full and vivid, and by increasing the red and violet, it will grow +more and more dilute, until by the prevalence of the added Colours it be +overcome and turned into whiteness, or some other Colour. So if to the +Colour of any homogeneal Light, the Sun's white Light composed of all +sorts of Rays be added, that Colour will not vanish or change its +Species, but be diluted, and by adding more and more white it will be +diluted more and more perpetually. Lastly, If red and violet be mingled, +there will be generated according to their various Proportions various +Purples, such as are not like in appearance to the Colour of any +homogeneal Light, and of these Purples mix'd with yellow and blue may be +made other new Colours. + + +_PROP._ V. THEOR. IV. + +_Whiteness and all grey Colours between white and black, may be +compounded of Colours, and the whiteness of the Sun's Light is +compounded of all the primary Colours mix'd in a due Proportion._ + +The PROOF by Experiments. + +_Exper._ 9. The Sun shining into a dark Chamber through a little round +hole in the Window-shut, and his Light being there refracted by a Prism +to cast his coloured Image PT [in _Fig._ 5.] upon the opposite Wall: I +held a white Paper V to that image in such manner that it might be +illuminated by the colour'd Light reflected from thence, and yet not +intercept any part of that Light in its passage from the Prism to the +Spectrum. And I found that when the Paper was held nearer to any Colour +than to the rest, it appeared of that Colour to which it approached +nearest; but when it was equally or almost equally distant from all the +Colours, so that it might be equally illuminated by them all it appeared +white. And in this last situation of the Paper, if some Colours were +intercepted, the Paper lost its white Colour, and appeared of the Colour +of the rest of the Light which was not intercepted. So then the Paper +was illuminated with Lights of various Colours, namely, red, yellow, +green, blue and violet, and every part of the Light retained its proper +Colour, until it was incident on the Paper, and became reflected thence +to the Eye; so that if it had been either alone (the rest of the Light +being intercepted) or if it had abounded most, and been predominant in +the Light reflected from the Paper, it would have tinged the Paper with +its own Colour; and yet being mixed with the rest of the Colours in a +due proportion, it made the Paper look white, and therefore by a +Composition with the rest produced that Colour. The several parts of the +coloured Light reflected from the Spectrum, whilst they are propagated +from thence through the Air, do perpetually retain their proper Colours, +because wherever they fall upon the Eyes of any Spectator, they make the +several parts of the Spectrum to appear under their proper Colours. They +retain therefore their proper Colours when they fall upon the Paper V, +and so by the confusion and perfect mixture of those Colours compound +the whiteness of the Light reflected from thence. + +_Exper._ 10. Let that Spectrum or solar Image PT [in _Fig._ 6.] fall now +upon the Lens MN above four Inches broad, and about six Feet distant +from the Prism ABC and so figured that it may cause the coloured Light +which divergeth from the Prism to converge and meet again at its Focus +G, about six or eight Feet distant from the Lens, and there to fall +perpendicularly upon a white Paper DE. And if you move this Paper to and +fro, you will perceive that near the Lens, as at _de_, the whole solar +Image (suppose at _pt_) will appear upon it intensely coloured after the +manner above-explained, and that by receding from the Lens those Colours +will perpetually come towards one another, and by mixing more and more +dilute one another continually, until at length the Paper come to the +Focus G, where by a perfect mixture they will wholly vanish and be +converted into whiteness, the whole Light appearing now upon the Paper +like a little white Circle. And afterwards by receding farther from the +Lens, the Rays which before converged will now cross one another in the +Focus G, and diverge from thence, and thereby make the Colours to appear +again, but yet in a contrary order; suppose at [Greek: de], where the +red _t_ is now above which before was below, and the violet _p_ is below +which before was above. + +Let us now stop the Paper at the Focus G, where the Light appears +totally white and circular, and let us consider its whiteness. I say, +that this is composed of the converging Colours. For if any of those +Colours be intercepted at the Lens, the whiteness will cease and +degenerate into that Colour which ariseth from the composition of the +other Colours which are not intercepted. And then if the intercepted +Colours be let pass and fall upon that compound Colour, they mix with +it, and by their mixture restore the whiteness. So if the violet, blue +and green be intercepted, the remaining yellow, orange and red will +compound upon the Paper an orange, and then if the intercepted Colours +be let pass, they will fall upon this compounded orange, and together +with it decompound a white. So also if the red and violet be +intercepted, the remaining yellow, green and blue, will compound a green +upon the Paper, and then the red and violet being let pass will fall +upon this green, and together with it decompound a white. And that in +this Composition of white the several Rays do not suffer any Change in +their colorific Qualities by acting upon one another, but are only +mixed, and by a mixture of their Colours produce white, may farther +appear by these Arguments. + +[Illustration: FIG. 6.] + +If the Paper be placed beyond the Focus G, suppose at [Greek: de], and +then the red Colour at the Lens be alternately intercepted, and let pass +again, the violet Colour on the Paper will not suffer any Change +thereby, as it ought to do if the several sorts of Rays acted upon one +another in the Focus G, where they cross. Neither will the red upon the +Paper be changed by any alternate stopping, and letting pass the violet +which crosseth it. + +And if the Paper be placed at the Focus G, and the white round Image at +G be viewed through the Prism HIK, and by the Refraction of that Prism +be translated to the place _rv_, and there appear tinged with various +Colours, namely, the violet at _v_ and red at _r_, and others between, +and then the red Colours at the Lens be often stopp'd and let pass by +turns, the red at _r_ will accordingly disappear, and return as often, +but the violet at _v_ will not thereby suffer any Change. And so by +stopping and letting pass alternately the blue at the Lens, the blue at +_v_ will accordingly disappear and return, without any Change made in +the red at _r_. The red therefore depends on one sort of Rays, and the +blue on another sort, which in the Focus G where they are commix'd, do +not act on one another. And there is the same Reason of the other +Colours. + +I considered farther, that when the most refrangible Rays P_p_, and the +least refrangible ones T_t_, are by converging inclined to one another, +the Paper, if held very oblique to those Rays in the Focus G, might +reflect one sort of them more copiously than the other sort, and by that +Means the reflected Light would be tinged in that Focus with the Colour +of the predominant Rays, provided those Rays severally retained their +Colours, or colorific Qualities in the Composition of White made by them +in that Focus. But if they did not retain them in that White, but became +all of them severally endued there with a Disposition to strike the +Sense with the Perception of White, then they could never lose their +Whiteness by such Reflexions. I inclined therefore the Paper to the Rays +very obliquely, as in the second Experiment of this second Part of the +first Book, that the most refrangible Rays, might be more copiously +reflected than the rest, and the Whiteness at Length changed +successively into blue, indigo, and violet. Then I inclined it the +contrary Way, that the least refrangible Rays might be more copious in +the reflected Light than the rest, and the Whiteness turned successively +to yellow, orange, and red. + +Lastly, I made an Instrument XY in fashion of a Comb, whose Teeth being +in number sixteen, were about an Inch and a half broad, and the +Intervals of the Teeth about two Inches wide. Then by interposing +successively the Teeth of this Instrument near the Lens, I intercepted +Part of the Colours by the interposed Tooth, whilst the rest of them +went on through the Interval of the Teeth to the Paper DE, and there +painted a round Solar Image. But the Paper I had first placed so, that +the Image might appear white as often as the Comb was taken away; and +then the Comb being as was said interposed, that Whiteness by reason of +the intercepted Part of the Colours at the Lens did always change into +the Colour compounded of those Colours which were not intercepted, and +that Colour was by the Motion of the Comb perpetually varied so, that in +the passing of every Tooth over the Lens all these Colours, red, yellow, +green, blue, and purple, did always succeed one another. I caused +therefore all the Teeth to pass successively over the Lens, and when the +Motion was slow, there appeared a perpetual Succession of the Colours +upon the Paper: But if I so much accelerated the Motion, that the +Colours by reason of their quick Succession could not be distinguished +from one another, the Appearance of the single Colours ceased. There was +no red, no yellow, no green, no blue, nor purple to be seen any longer, +but from a Confusion of them all there arose one uniform white Colour. +Of the Light which now by the Mixture of all the Colours appeared white, +there was no Part really white. One Part was red, another yellow, a +third green, a fourth blue, a fifth purple, and every Part retains its +proper Colour till it strike the Sensorium. If the Impressions follow +one another slowly, so that they may be severally perceived, there is +made a distinct Sensation of all the Colours one after another in a +continual Succession. But if the Impressions follow one another so +quickly, that they cannot be severally perceived, there ariseth out of +them all one common Sensation, which is neither of this Colour alone nor +of that alone, but hath it self indifferently to 'em all, and this is a +Sensation of Whiteness. By the Quickness of the Successions, the +Impressions of the several Colours are confounded in the Sensorium, and +out of that Confusion ariseth a mix'd Sensation. If a burning Coal be +nimbly moved round in a Circle with Gyrations continually repeated, the +whole Circle will appear like Fire; the reason of which is, that the +Sensation of the Coal in the several Places of that Circle remains +impress'd on the Sensorium, until the Coal return again to the same +Place. And so in a quick Consecution of the Colours the Impression of +every Colour remains in the Sensorium, until a Revolution of all the +Colours be compleated, and that first Colour return again. The +Impressions therefore of all the successive Colours are at once in the +Sensorium, and jointly stir up a Sensation of them all; and so it is +manifest by this Experiment, that the commix'd Impressions of all the +Colours do stir up and beget a Sensation of white, that is, that +Whiteness is compounded of all the Colours. + +And if the Comb be now taken away, that all the Colours may at once pass +from the Lens to the Paper, and be there intermixed, and together +reflected thence to the Spectator's Eyes; their Impressions on the +Sensorium being now more subtilly and perfectly commixed there, ought +much more to stir up a Sensation of Whiteness. + +You may instead of the Lens use two Prisms HIK and LMN, which by +refracting the coloured Light the contrary Way to that of the first +Refraction, may make the diverging Rays converge and meet again in G, as +you see represented in the seventh Figure. For where they meet and mix, +they will compose a white Light, as when a Lens is used. + +_Exper._ 11. Let the Sun's coloured Image PT [in _Fig._ 8.] fall upon +the Wall of a dark Chamber, as in the third Experiment of the first +Book, and let the same be viewed through a Prism _abc_, held parallel to +the Prism ABC, by whose Refraction that Image was made, and let it now +appear lower than before, suppose in the Place S over-against the red +Colour T. And if you go near to the Image PT, the Spectrum S will appear +oblong and coloured like the Image PT; but if you recede from it, the +Colours of the spectrum S will be contracted more and more, and at +length vanish, that Spectrum S becoming perfectly round and white; and +if you recede yet farther, the Colours will emerge again, but in a +contrary Order. Now that Spectrum S appears white in that Case, when the +Rays of several sorts which converge from the several Parts of the Image +PT, to the Prism _abc_, are so refracted unequally by it, that in their +Passage from the Prism to the Eye they may diverge from one and the same +Point of the Spectrum S, and so fall afterwards upon one and the same +Point in the bottom of the Eye, and there be mingled. + +[Illustration: FIG. 7.] + +[Illustration: FIG. 8.] + +And farther, if the Comb be here made use of, by whose Teeth the Colours +at the Image PT may be successively intercepted; the Spectrum S, when +the Comb is moved slowly, will be perpetually tinged with successive +Colours: But when by accelerating the Motion of the Comb, the Succession +of the Colours is so quick that they cannot be severally seen, that +Spectrum S, by a confused and mix'd Sensation of them all, will appear +white. + +_Exper._ 12. The Sun shining through a large Prism ABC [in _Fig._ 9.] +upon a Comb XY, placed immediately behind the Prism, his Light which +passed through the Interstices of the Teeth fell upon a white Paper DE. +The Breadths of the Teeth were equal to their Interstices, and seven +Teeth together with their Interstices took up an Inch in Breadth. Now, +when the Paper was about two or three Inches distant from the Comb, the +Light which passed through its several Interstices painted so many +Ranges of Colours, _kl_, _mn_, _op_, _qr_, &c. which were parallel to +one another, and contiguous, and without any Mixture of white. And these +Ranges of Colours, if the Comb was moved continually up and down with a +reciprocal Motion, ascended and descended in the Paper, and when the +Motion of the Comb was so quick, that the Colours could not be +distinguished from one another, the whole Paper by their Confusion and +Mixture in the Sensorium appeared white. + +[Illustration: FIG. 9.] + +Let the Comb now rest, and let the Paper be removed farther from the +Prism, and the several Ranges of Colours will be dilated and expanded +into one another more and more, and by mixing their Colours will dilute +one another, and at length, when the distance of the Paper from the Comb +is about a Foot, or a little more (suppose in the Place 2D 2E) they will +so far dilute one another, as to become white. + +With any Obstacle, let all the Light be now stopp'd which passes through +any one Interval of the Teeth, so that the Range of Colours which comes +from thence may be taken away, and you will see the Light of the rest of +the Ranges to be expanded into the Place of the Range taken away, and +there to be coloured. Let the intercepted Range pass on as before, and +its Colours falling upon the Colours of the other Ranges, and mixing +with them, will restore the Whiteness. + +Let the Paper 2D 2E be now very much inclined to the Rays, so that the +most refrangible Rays may be more copiously reflected than the rest, and +the white Colour of the Paper through the Excess of those Rays will be +changed into blue and violet. Let the Paper be as much inclined the +contrary way, that the least refrangible Rays may be now more copiously +reflected than the rest, and by their Excess the Whiteness will be +changed into yellow and red. The several Rays therefore in that white +Light do retain their colorific Qualities, by which those of any sort, +whenever they become more copious than the rest, do by their Excess and +Predominance cause their proper Colour to appear. + +And by the same way of arguing, applied to the third Experiment of this +second Part of the first Book, it may be concluded, that the white +Colour of all refracted Light at its very first Emergence, where it +appears as white as before its Incidence, is compounded of various +Colours. + +[Illustration: FIG. 10.] + +_Exper._ 13. In the foregoing Experiment the several Intervals of the +Teeth of the Comb do the Office of so many Prisms, every Interval +producing the Phænomenon of one Prism. Whence instead of those Intervals +using several Prisms, I try'd to compound Whiteness by mixing their +Colours, and did it by using only three Prisms, as also by using only +two as follows. Let two Prisms ABC and _abc_, [in _Fig._ 10.] whose +refracting Angles B and _b_ are equal, be so placed parallel to one +another, that the refracting Angle B of the one may touch the Angle _c_ +at the Base of the other, and their Planes CB and _cb_, at which the +Rays emerge, may lie in Directum. Then let the Light trajected through +them fall upon the Paper MN, distant about 8 or 12 Inches from the +Prisms. And the Colours generated by the interior Limits B and _c_ of +the two Prisms, will be mingled at PT, and there compound white. For if +either Prism be taken away, the Colours made by the other will appear in +that Place PT, and when the Prism is restored to its Place again, so +that its Colours may there fall upon the Colours of the other, the +Mixture of them both will restore the Whiteness. + +This Experiment succeeds also, as I have tried, when the Angle _b_ of +the lower Prism, is a little greater than the Angle B of the upper, and +between the interior Angles B and _c_, there intercedes some Space B_c_, +as is represented in the Figure, and the refracting Planes BC and _bc_, +are neither in Directum, nor parallel to one another. For there is +nothing more requisite to the Success of this Experiment, than that the +Rays of all sorts may be uniformly mixed upon the Paper in the Place PT. +If the most refrangible Rays coming from the superior Prism take up all +the Space from M to P, the Rays of the same sort which come from the +inferior Prism ought to begin at P, and take up all the rest of the +Space from thence towards N. If the least refrangible Rays coming from +the superior Prism take up the Space MT, the Rays of the same kind which +come from the other Prism ought to begin at T, and take up the +remaining Space TN. If one sort of the Rays which have intermediate +Degrees of Refrangibility, and come from the superior Prism be extended +through the Space MQ, and another sort of those Rays through the Space +MR, and a third sort of them through the Space MS, the same sorts of +Rays coming from the lower Prism, ought to illuminate the remaining +Spaces QN, RN, SN, respectively. And the same is to be understood of all +the other sorts of Rays. For thus the Rays of every sort will be +scattered uniformly and evenly through the whole Space MN, and so being +every where mix'd in the same Proportion, they must every where produce +the same Colour. And therefore, since by this Mixture they produce white +in the Exterior Spaces MP and TN, they must also produce white in the +Interior Space PT. This is the reason of the Composition by which +Whiteness was produced in this Experiment, and by what other way soever +I made the like Composition, the Result was Whiteness. + +Lastly, If with the Teeth of a Comb of a due Size, the coloured Lights +of the two Prisms which fall upon the Space PT be alternately +intercepted, that Space PT, when the Motion of the Comb is slow, will +always appear coloured, but by accelerating the Motion of the Comb so +much that the successive Colours cannot be distinguished from one +another, it will appear white. + +_Exper._ 14. Hitherto I have produced Whiteness by mixing the Colours of +Prisms. If now the Colours of natural Bodies are to be mingled, let +Water a little thicken'd with Soap be agitated to raise a Froth, and +after that Froth has stood a little, there will appear to one that shall +view it intently various Colours every where in the Surfaces of the +several Bubbles; but to one that shall go so far off, that he cannot +distinguish the Colours from one another, the whole Froth will grow +white with a perfect Whiteness. + +_Exper._ 15. Lastly, In attempting to compound a white, by mixing the +coloured Powders which Painters use, I consider'd that all colour'd +Powders do suppress and stop in them a very considerable Part of the +Light by which they are illuminated. For they become colour'd by +reflecting the Light of their own Colours more copiously, and that of +all other Colours more sparingly, and yet they do not reflect the Light +of their own Colours so copiously as white Bodies do. If red Lead, for +instance, and a white Paper, be placed in the red Light of the colour'd +Spectrum made in a dark Chamber by the Refraction of a Prism, as is +described in the third Experiment of the first Part of this Book; the +Paper will appear more lucid than the red Lead, and therefore reflects +the red-making Rays more copiously than red Lead doth. And if they be +held in the Light of any other Colour, the Light reflected by the Paper +will exceed the Light reflected by the red Lead in a much greater +Proportion. And the like happens in Powders of other Colours. And +therefore by mixing such Powders, we are not to expect a strong and +full White, such as is that of Paper, but some dusky obscure one, such +as might arise from a Mixture of Light and Darkness, or from white and +black, that is, a grey, or dun, or russet brown, such as are the Colours +of a Man's Nail, of a Mouse, of Ashes, of ordinary Stones, of Mortar, of +Dust and Dirt in High-ways, and the like. And such a dark white I have +often produced by mixing colour'd Powders. For thus one Part of red +Lead, and five Parts of _Viride Æris_, composed a dun Colour like that +of a Mouse. For these two Colours were severally so compounded of +others, that in both together were a Mixture of all Colours; and there +was less red Lead used than _Viride Æris_, because of the Fulness of its +Colour. Again, one Part of red Lead, and four Parts of blue Bise, +composed a dun Colour verging a little to purple, and by adding to this +a certain Mixture of Orpiment and _Viride Æris_ in a due Proportion, the +Mixture lost its purple Tincture, and became perfectly dun. But the +Experiment succeeded best without Minium thus. To Orpiment I added by +little and little a certain full bright purple, which Painters use, +until the Orpiment ceased to be yellow, and became of a pale red. Then I +diluted that red by adding a little _Viride Æris_, and a little more +blue Bise than _Viride Æris_, until it became of such a grey or pale +white, as verged to no one of the Colours more than to another. For thus +it became of a Colour equal in Whiteness to that of Ashes, or of Wood +newly cut, or of a Man's Skin. The Orpiment reflected more Light than +did any other of the Powders, and therefore conduced more to the +Whiteness of the compounded Colour than they. To assign the Proportions +accurately may be difficult, by reason of the different Goodness of +Powders of the same kind. Accordingly, as the Colour of any Powder is +more or less full and luminous, it ought to be used in a less or greater +Proportion. + +Now, considering that these grey and dun Colours may be also produced by +mixing Whites and Blacks, and by consequence differ from perfect Whites, +not in Species of Colours, but only in degree of Luminousness, it is +manifest that there is nothing more requisite to make them perfectly +white than to increase their Light sufficiently; and, on the contrary, +if by increasing their Light they can be brought to perfect Whiteness, +it will thence also follow, that they are of the same Species of Colour +with the best Whites, and differ from them only in the Quantity of +Light. And this I tried as follows. I took the third of the +above-mention'd grey Mixtures, (that which was compounded of Orpiment, +Purple, Bise, and _Viride Æris_) and rubbed it thickly upon the Floor of +my Chamber, where the Sun shone upon it through the opened Casement; and +by it, in the shadow, I laid a Piece of white Paper of the same Bigness. +Then going from them to the distance of 12 or 18 Feet, so that I could +not discern the Unevenness of the Surface of the Powder, nor the little +Shadows let fall from the gritty Particles thereof; the Powder appeared +intensely white, so as to transcend even the Paper it self in Whiteness, +especially if the Paper were a little shaded from the Light of the +Clouds, and then the Paper compared with the Powder appeared of such a +grey Colour as the Powder had done before. But by laying the Paper where +the Sun shines through the Glass of the Window, or by shutting the +Window that the Sun might shine through the Glass upon the Powder, and +by such other fit Means of increasing or decreasing the Lights wherewith +the Powder and Paper were illuminated, the Light wherewith the Powder is +illuminated may be made stronger in such a due Proportion than the Light +wherewith the Paper is illuminated, that they shall both appear exactly +alike in Whiteness. For when I was trying this, a Friend coming to visit +me, I stopp'd him at the Door, and before I told him what the Colours +were, or what I was doing; I asked him, Which of the two Whites were the +best, and wherein they differed? And after he had at that distance +viewed them well, he answer'd, that they were both good Whites, and that +he could not say which was best, nor wherein their Colours differed. +Now, if you consider, that this White of the Powder in the Sun-shine was +compounded of the Colours which the component Powders (Orpiment, Purple, +Bise, and _Viride Æris_) have in the same Sun-shine, you must +acknowledge by this Experiment, as well as by the former, that perfect +Whiteness may be compounded of Colours. + +From what has been said it is also evident, that the Whiteness of the +Sun's Light is compounded of all the Colours wherewith the several sorts +of Rays whereof that Light consists, when by their several +Refrangibilities they are separated from one another, do tinge Paper or +any other white Body whereon they fall. For those Colours (by _Prop._ +II. _Part_ 2.) are unchangeable, and whenever all those Rays with those +their Colours are mix'd again, they reproduce the same white Light as +before. + + +_PROP._ VI. PROB. II. + +_In a mixture of Primary Colours, the Quantity and Quality of each being +given, to know the Colour of the Compound._ + +[Illustration: FIG. 11.] + +With the Center O [in _Fig._ 11.] and Radius OD describe a Circle ADF, +and distinguish its Circumference into seven Parts DE, EF, FG, GA, AB, +BC, CD, proportional to the seven Musical Tones or Intervals of the +eight Sounds, _Sol_, _la_, _fa_, _sol_, _la_, _mi_, _fa_, _sol_, +contained in an eight, that is, proportional to the Number 1/9, 1/16, +1/10, 1/9, 1/16, 1/16, 1/9. Let the first Part DE represent a red +Colour, the second EF orange, the third FG yellow, the fourth CA green, +the fifth AB blue, the sixth BC indigo, and the seventh CD violet. And +conceive that these are all the Colours of uncompounded Light gradually +passing into one another, as they do when made by Prisms; the +Circumference DEFGABCD, representing the whole Series of Colours from +one end of the Sun's colour'd Image to the other, so that from D to E be +all degrees of red, at E the mean Colour between red and orange, from E +to F all degrees of orange, at F the mean between orange and yellow, +from F to G all degrees of yellow, and so on. Let _p_ be the Center of +Gravity of the Arch DE, and _q_, _r_, _s_, _t_, _u_, _x_, the Centers of +Gravity of the Arches EF, FG, GA, AB, BC, and CD respectively, and about +those Centers of Gravity let Circles proportional to the Number of Rays +of each Colour in the given Mixture be describ'd: that is, the Circle +_p_ proportional to the Number of the red-making Rays in the Mixture, +the Circle _q_ proportional to the Number of the orange-making Rays in +the Mixture, and so of the rest. Find the common Center of Gravity of +all those Circles, _p_, _q_, _r_, _s_, _t_, _u_, _x_. Let that Center be +Z; and from the Center of the Circle ADF, through Z to the +Circumference, drawing the Right Line OY, the Place of the Point Y in +the Circumference shall shew the Colour arising from the Composition of +all the Colours in the given Mixture, and the Line OZ shall be +proportional to the Fulness or Intenseness of the Colour, that is, to +its distance from Whiteness. As if Y fall in the middle between F and G, +the compounded Colour shall be the best yellow; if Y verge from the +middle towards F or G, the compound Colour shall accordingly be a +yellow, verging towards orange or green. If Z fall upon the +Circumference, the Colour shall be intense and florid in the highest +Degree; if it fall in the mid-way between the Circumference and Center, +it shall be but half so intense, that is, it shall be such a Colour as +would be made by diluting the intensest yellow with an equal quantity of +whiteness; and if it fall upon the center O, the Colour shall have lost +all its intenseness, and become a white. But it is to be noted, That if +the point Z fall in or near the line OD, the main ingredients being the +red and violet, the Colour compounded shall not be any of the prismatick +Colours, but a purple, inclining to red or violet, accordingly as the +point Z lieth on the side of the line DO towards E or towards C, and in +general the compounded violet is more bright and more fiery than the +uncompounded. Also if only two of the primary Colours which in the +circle are opposite to one another be mixed in an equal proportion, the +point Z shall fall upon the center O, and yet the Colour compounded of +those two shall not be perfectly white, but some faint anonymous Colour. +For I could never yet by mixing only two primary Colours produce a +perfect white. Whether it may be compounded of a mixture of three taken +at equal distances in the circumference I do not know, but of four or +five I do not much question but it may. But these are Curiosities of +little or no moment to the understanding the Phænomena of Nature. For in +all whites produced by Nature, there uses to be a mixture of all sorts +of Rays, and by consequence a composition of all Colours. + +To give an instance of this Rule; suppose a Colour is compounded of +these homogeneal Colours, of violet one part, of indigo one part, of +blue two parts, of green three parts, of yellow five parts, of orange +six parts, and of red ten parts. Proportional to these parts describe +the Circles _x_, _v_, _t_, _s_, _r_, _q_, _p_, respectively, that is, so +that if the Circle _x_ be one, the Circle _v_ may be one, the Circle _t_ +two, the Circle _s_ three, and the Circles _r_, _q_ and _p_, five, six +and ten. Then I find Z the common center of gravity of these Circles, +and through Z drawing the Line OY, the Point Y falls upon the +circumference between E and F, something nearer to E than to F, and +thence I conclude, that the Colour compounded of these Ingredients will +be an orange, verging a little more to red than to yellow. Also I find +that OZ is a little less than one half of OY, and thence I conclude, +that this orange hath a little less than half the fulness or intenseness +of an uncompounded orange; that is to say, that it is such an orange as +may be made by mixing an homogeneal orange with a good white in the +proportion of the Line OZ to the Line ZY, this Proportion being not of +the quantities of mixed orange and white Powders, but of the quantities +of the Lights reflected from them. + +This Rule I conceive accurate enough for practice, though not +mathematically accurate; and the truth of it may be sufficiently proved +to Sense, by stopping any of the Colours at the Lens in the tenth +Experiment of this Book. For the rest of the Colours which are not +stopp'd, but pass on to the Focus of the Lens, will there compound +either accurately or very nearly such a Colour, as by this Rule ought to +result from their Mixture. + + +_PROP._ VII. THEOR. V. + +_All the Colours in the Universe which are made by Light, and depend not +on the Power of Imagination, are either the Colours of homogeneal +Lights, or compounded of these, and that either accurately or very +nearly, according to the Rule of the foregoing Problem._ + +For it has been proved (in _Prop. 1. Part 2._) that the changes of +Colours made by Refractions do not arise from any new Modifications of +the Rays impress'd by those Refractions, and by the various Terminations +of Light and Shadow, as has been the constant and general Opinion of +Philosophers. It has also been proved that the several Colours of the +homogeneal Rays do constantly answer to their degrees of Refrangibility, +(_Prop._ 1. _Part_ 1. and _Prop._ 2. _Part_ 2.) and that their degrees +of Refrangibility cannot be changed by Refractions and Reflexions +(_Prop._ 2. _Part_ 1.) and by consequence that those their Colours are +likewise immutable. It has also been proved directly by refracting and +reflecting homogeneal Lights apart, that their Colours cannot be +changed, (_Prop._ 2. _Part_ 2.) It has been proved also, that when the +several sorts of Rays are mixed, and in crossing pass through the same +space, they do not act on one another so as to change each others +colorific qualities. (_Exper._ 10. _Part_ 2.) but by mixing their +Actions in the Sensorium beget a Sensation differing from what either +would do apart, that is a Sensation of a mean Colour between their +proper Colours; and particularly when by the concourse and mixtures of +all sorts of Rays, a white Colour is produced, the white is a mixture of +all the Colours which the Rays would have apart, (_Prop._ 5. _Part_ 2.) +The Rays in that mixture do not lose or alter their several colorific +qualities, but by all their various kinds of Actions mix'd in the +Sensorium, beget a Sensation of a middling Colour between all their +Colours, which is whiteness. For whiteness is a mean between all +Colours, having it self indifferently to them all, so as with equal +facility to be tinged with any of them. A red Powder mixed with a little +blue, or a blue with a little red, doth not presently lose its Colour, +but a white Powder mix'd with any Colour is presently tinged with that +Colour, and is equally capable of being tinged with any Colour whatever. +It has been shewed also, that as the Sun's Light is mix'd of all sorts +of Rays, so its whiteness is a mixture of the Colours of all sorts of +Rays; those Rays having from the beginning their several colorific +qualities as well as their several Refrangibilities, and retaining them +perpetually unchanged notwithstanding any Refractions or Reflexions they +may at any time suffer, and that whenever any sort of the Sun's Rays is +by any means (as by Reflexion in _Exper._ 9, and 10. _Part_ 1. or by +Refraction as happens in all Refractions) separated from the rest, they +then manifest their proper Colours. These things have been prov'd, and +the sum of all this amounts to the Proposition here to be proved. For if +the Sun's Light is mix'd of several sorts of Rays, each of which have +originally their several Refrangibilities and colorific Qualities, and +notwithstanding their Refractions and Reflexions, and their various +Separations or Mixtures, keep those their original Properties +perpetually the same without alteration; then all the Colours in the +World must be such as constantly ought to arise from the original +colorific qualities of the Rays whereof the Lights consist by which +those Colours are seen. And therefore if the reason of any Colour +whatever be required, we have nothing else to do than to consider how +the Rays in the Sun's Light have by Reflexions or Refractions, or other +causes, been parted from one another, or mixed together; or otherwise to +find out what sorts of Rays are in the Light by which that Colour is +made, and in what Proportion; and then by the last Problem to learn the +Colour which ought to arise by mixing those Rays (or their Colours) in +that proportion. I speak here of Colours so far as they arise from +Light. For they appear sometimes by other Causes, as when by the power +of Phantasy we see Colours in a Dream, or a Mad-man sees things before +him which are not there; or when we see Fire by striking the Eye, or see +Colours like the Eye of a Peacock's Feather, by pressing our Eyes in +either corner whilst we look the other way. Where these and such like +Causes interpose not, the Colour always answers to the sort or sorts of +the Rays whereof the Light consists, as I have constantly found in +whatever Phænomena of Colours I have hitherto been able to examine. I +shall in the following Propositions give instances of this in the +Phænomena of chiefest note. + + +_PROP._ VIII. PROB. III. + +_By the discovered Properties of Light to explain the Colours made by +Prisms._ + +Let ABC [in _Fig._ 12.] represent a Prism refracting the Light of the +Sun, which comes into a dark Chamber through a hole F[Greek: ph] almost +as broad as the Prism, and let MN represent a white Paper on which the +refracted Light is cast, and suppose the most refrangible or deepest +violet-making Rays fall upon the Space P[Greek: p], the least +refrangible or deepest red-making Rays upon the Space T[Greek: t], the +middle sort between the indigo-making and blue-making Rays upon the +Space Q[Greek: ch], the middle sort of the green-making Rays upon the +Space R, the middle sort between the yellow-making and orange-making +Rays upon the Space S[Greek: s], and other intermediate sorts upon +intermediate Spaces. For so the Spaces upon which the several sorts +adequately fall will by reason of the different Refrangibility of those +sorts be one lower than another. Now if the Paper MN be so near the +Prism that the Spaces PT and [Greek: pt] do not interfere with one +another, the distance between them T[Greek: p] will be illuminated by +all the sorts of Rays in that proportion to one another which they have +at their very first coming out of the Prism, and consequently be white. +But the Spaces PT and [Greek: pt] on either hand, will not be +illuminated by them all, and therefore will appear coloured. And +particularly at P, where the outmost violet-making Rays fall alone, the +Colour must be the deepest violet. At Q where the violet-making and +indigo-making Rays are mixed, it must be a violet inclining much to +indigo. At R where the violet-making, indigo-making, blue-making, and +one half of the green-making Rays are mixed, their Colours must (by the +construction of the second Problem) compound a middle Colour between +indigo and blue. At S where all the Rays are mixed, except the +red-making and orange-making, their Colours ought by the same Rule to +compound a faint blue, verging more to green than indigo. And in the +progress from S to T, this blue will grow more and more faint and +dilute, till at T, where all the Colours begin to be mixed, it ends in +whiteness. + +[Illustration: FIG. 12.] + +So again, on the other side of the white at [Greek: t], where the least +refrangible or utmost red-making Rays are alone, the Colour must be the +deepest red. At [Greek: s] the mixture of red and orange will compound a +red inclining to orange. At [Greek: r] the mixture of red, orange, +yellow, and one half of the green must compound a middle Colour between +orange and yellow. At [Greek: ch] the mixture of all Colours but violet +and indigo will compound a faint yellow, verging more to green than to +orange. And this yellow will grow more faint and dilute continually in +its progress from [Greek: ch] to [Greek: p], where by a mixture of all +sorts of Rays it will become white. + +These Colours ought to appear were the Sun's Light perfectly white: But +because it inclines to yellow, the Excess of the yellow-making Rays +whereby 'tis tinged with that Colour, being mixed with the faint blue +between S and T, will draw it to a faint green. And so the Colours in +order from P to [Greek: t] ought to be violet, indigo, blue, very faint +green, white, faint yellow, orange, red. Thus it is by the computation: +And they that please to view the Colours made by a Prism will find it so +in Nature. + +These are the Colours on both sides the white when the Paper is held +between the Prism and the Point X where the Colours meet, and the +interjacent white vanishes. For if the Paper be held still farther off +from the Prism, the most refrangible and least refrangible Rays will be +wanting in the middle of the Light, and the rest of the Rays which are +found there, will by mixture produce a fuller green than before. Also +the yellow and blue will now become less compounded, and by consequence +more intense than before. And this also agrees with experience. + +And if one look through a Prism upon a white Object encompassed with +blackness or darkness, the reason of the Colours arising on the edges is +much the same, as will appear to one that shall a little consider it. If +a black Object be encompassed with a white one, the Colours which appear +through the Prism are to be derived from the Light of the white one, +spreading into the Regions of the black, and therefore they appear in a +contrary order to that, when a white Object is surrounded with black. +And the same is to be understood when an Object is viewed, whose parts +are some of them less luminous than others. For in the borders of the +more and less luminous Parts, Colours ought always by the same +Principles to arise from the Excess of the Light of the more luminous, +and to be of the same kind as if the darker parts were black, but yet to +be more faint and dilute. + +What is said of Colours made by Prisms may be easily applied to Colours +made by the Glasses of Telescopes or Microscopes, or by the Humours of +the Eye. For if the Object-glass of a Telescope be thicker on one side +than on the other, or if one half of the Glass, or one half of the Pupil +of the Eye be cover'd with any opake substance; the Object-glass, or +that part of it or of the Eye which is not cover'd, may be consider'd as +a Wedge with crooked Sides, and every Wedge of Glass or other pellucid +Substance has the effect of a Prism in refracting the Light which passes +through it.[L] + +How the Colours in the ninth and tenth Experiments of the first Part +arise from the different Reflexibility of Light, is evident by what was +there said. But it is observable in the ninth Experiment, that whilst +the Sun's direct Light is yellow, the Excess of the blue-making Rays in +the reflected beam of Light MN, suffices only to bring that yellow to a +pale white inclining to blue, and not to tinge it with a manifestly blue +Colour. To obtain therefore a better blue, I used instead of the yellow +Light of the Sun the white Light of the Clouds, by varying a little the +Experiment, as follows. + +[Illustration: FIG. 13.] + +_Exper._ 16 Let HFG [in _Fig._ 13.] represent a Prism in the open Air, +and S the Eye of the Spectator, viewing the Clouds by their Light coming +into the Prism at the Plane Side FIGK, and reflected in it by its Base +HEIG, and thence going out through its Plane Side HEFK to the Eye. And +when the Prism and Eye are conveniently placed, so that the Angles of +Incidence and Reflexion at the Base may be about 40 Degrees, the +Spectator will see a Bow MN of a blue Colour, running from one End of +the Base to the other, with the Concave Side towards him, and the Part +of the Base IMNG beyond this Bow will be brighter than the other Part +EMNH on the other Side of it. This blue Colour MN being made by nothing +else than by Reflexion of a specular Superficies, seems so odd a +Phænomenon, and so difficult to be explained by the vulgar Hypothesis of +Philosophers, that I could not but think it deserved to be taken Notice +of. Now for understanding the Reason of it, suppose the Plane ABC to cut +the Plane Sides and Base of the Prism perpendicularly. From the Eye to +the Line BC, wherein that Plane cuts the Base, draw the Lines S_p_ and +S_t_, in the Angles S_pc_ 50 degr. 1/9, and S_tc_ 49 degr. 1/28, and the +Point _p_ will be the Limit beyond which none of the most refrangible +Rays can pass through the Base of the Prism, and be refracted, whose +Incidence is such that they may be reflected to the Eye; and the Point +_t_ will be the like Limit for the least refrangible Rays, that is, +beyond which none of them can pass through the Base, whose Incidence is +such that by Reflexion they may come to the Eye. And the Point _r_ taken +in the middle Way between _p_ and _t_, will be the like Limit for the +meanly refrangible Rays. And therefore all the least refrangible Rays +which fall upon the Base beyond _t_, that is, between _t_ and B, and can +come from thence to the Eye, will be reflected thither: But on this side +_t_, that is, between _t_ and _c_, many of these Rays will be +transmitted through the Base. And all the most refrangible Rays which +fall upon the Base beyond _p_, that is, between, _p_ and B, and can by +Reflexion come from thence to the Eye, will be reflected thither, but +every where between _p_ and _c_, many of these Rays will get through the +Base, and be refracted; and the same is to be understood of the meanly +refrangible Rays on either side of the Point _r_. Whence it follows, +that the Base of the Prism must every where between _t_ and B, by a +total Reflexion of all sorts of Rays to the Eye, look white and bright. +And every where between _p_ and C, by reason of the Transmission of many +Rays of every sort, look more pale, obscure, and dark. But at _r_, and +in other Places between _p_ and _t_, where all the more refrangible Rays +are reflected to the Eye, and many of the less refrangible are +transmitted, the Excess of the most refrangible in the reflected Light +will tinge that Light with their Colour, which is violet and blue. And +this happens by taking the Line C _prt_ B any where between the Ends of +the Prism HG and EI. + + +_PROP._ IX. PROB. IV. + +_By the discovered Properties of Light to explain the Colours of the +Rain-bow._ + +[Illustration: FIG. 14.] + +This Bow never appears, but where it rains in the Sun-shine, and may be +made artificially by spouting up Water which may break aloft, and +scatter into Drops, and fall down like Rain. For the Sun shining upon +these Drops certainly causes the Bow to appear to a Spectator standing +in a due Position to the Rain and Sun. And hence it is now agreed upon, +that this Bow is made by Refraction of the Sun's Light in drops of +falling Rain. This was understood by some of the Antients, and of late +more fully discover'd and explain'd by the famous _Antonius de Dominis_ +Archbishop of _Spalato_, in his book _De Radiis Visûs & Lucis_, +published by his Friend _Bartolus_ at _Venice_, in the Year 1611, and +written above 20 Years before. For he teaches there how the interior Bow +is made in round Drops of Rain by two Refractions of the Sun's Light, +and one Reflexion between them, and the exterior by two Refractions, and +two sorts of Reflexions between them in each Drop of Water, and proves +his Explications by Experiments made with a Phial full of Water, and +with Globes of Glass filled with Water, and placed in the Sun to make +the Colours of the two Bows appear in them. The same Explication +_Des-Cartes_ hath pursued in his Meteors, and mended that of the +exterior Bow. But whilst they understood not the true Origin of Colours, +it's necessary to pursue it here a little farther. For understanding +therefore how the Bow is made, let a Drop of Rain, or any other +spherical transparent Body be represented by the Sphere BNFG, [in _Fig._ +14.] described with the Center C, and Semi-diameter CN. And let AN be +one of the Sun's Rays incident upon it at N, and thence refracted to F, +where let it either go out of the Sphere by Refraction towards V, or be +reflected to G; and at G let it either go out by Refraction to R, or be +reflected to H; and at H let it go out by Refraction towards S, cutting +the incident Ray in Y. Produce AN and RG, till they meet in X, and upon +AX and NF, let fall the Perpendiculars CD and CE, and produce CD till it +fall upon the Circumference at L. Parallel to the incident Ray AN draw +the Diameter BQ, and let the Sine of Incidence out of Air into Water be +to the Sine of Refraction as I to R. Now, if you suppose the Point of +Incidence N to move from the Point B, continually till it come to L, the +Arch QF will first increase and then decrease, and so will the Angle AXR +which the Rays AN and GR contain; and the Arch QF and Angle AXR will be +biggest when ND is to CN as sqrt(II - RR) to sqrt(3)RR, in which +case NE will be to ND as 2R to I. Also the Angle AYS, which the Rays AN +and HS contain will first decrease, and then increase and grow least +when ND is to CN as sqrt(II - RR) to sqrt(8)RR, in which case NE +will be to ND, as 3R to I. And so the Angle which the next emergent Ray +(that is, the emergent Ray after three Reflexions) contains with the +incident Ray AN will come to its Limit when ND is to CN as sqrt(II - +RR) to sqrt(15)RR, in which case NE will be to ND as 4R to I. And the +Angle which the Ray next after that Emergent, that is, the Ray emergent +after four Reflexions, contains with the Incident, will come to its +Limit, when ND is to CN as sqrt(II - RR) to sqrt(24)RR, in which +case NE will be to ND as 5R to I; and so on infinitely, the Numbers 3, +8, 15, 24, &c. being gather'd by continual Addition of the Terms of the +arithmetical Progression 3, 5, 7, 9, &c. The Truth of all this +Mathematicians will easily examine.[M] + +Now it is to be observed, that as when the Sun comes to his Tropicks, +Days increase and decrease but a very little for a great while together; +so when by increasing the distance CD, these Angles come to their +Limits, they vary their quantity but very little for some time together, +and therefore a far greater number of the Rays which fall upon all the +Points N in the Quadrant BL, shall emerge in the Limits of these Angles, +than in any other Inclinations. And farther it is to be observed, that +the Rays which differ in Refrangibility will have different Limits of +their Angles of Emergence, and by consequence according to their +different Degrees of Refrangibility emerge most copiously in different +Angles, and being separated from one another appear each in their proper +Colours. And what those Angles are may be easily gather'd from the +foregoing Theorem by Computation. + +For in the least refrangible Rays the Sines I and R (as was found above) +are 108 and 81, and thence by Computation the greatest Angle AXR will be +found 42 Degrees and 2 Minutes, and the least Angle AYS, 50 Degrees and +57 Minutes. And in the most refrangible Rays the Sines I and R are 109 +and 81, and thence by Computation the greatest Angle AXR will be found +40 Degrees and 17 Minutes, and the least Angle AYS 54 Degrees and 7 +Minutes. + +Suppose now that O [in _Fig._ 15.] is the Spectator's Eye, and OP a Line +drawn parallel to the Sun's Rays and let POE, POF, POG, POH, be Angles +of 40 Degr. 17 Min. 42 Degr. 2 Min. 50 Degr. 57 Min. and 54 Degr. 7 Min. +respectively, and these Angles turned about their common Side OP, shall +with their other Sides OE, OF; OG, OH, describe the Verges of two +Rain-bows AF, BE and CHDG. For if E, F, G, H, be drops placed any where +in the conical Superficies described by OE, OF, OG, OH, and be +illuminated by the Sun's Rays SE, SF, SG, SH; the Angle SEO being equal +to the Angle POE, or 40 Degr. 17 Min. shall be the greatest Angle in +which the most refrangible Rays can after one Reflexion be refracted to +the Eye, and therefore all the Drops in the Line OE shall send the most +refrangible Rays most copiously to the Eye, and thereby strike the +Senses with the deepest violet Colour in that Region. And in like +manner the Angle SFO being equal to the Angle POF, or 42 Degr. 2 Min. +shall be the greatest in which the least refrangible Rays after one +Reflexion can emerge out of the Drops, and therefore those Rays shall +come most copiously to the Eye from the Drops in the Line OF, and strike +the Senses with the deepest red Colour in that Region. And by the same +Argument, the Rays which have intermediate Degrees of Refrangibility +shall come most copiously from Drops between E and F, and strike the +Senses with the intermediate Colours, in the Order which their Degrees +of Refrangibility require, that is in the Progress from E to F, or from +the inside of the Bow to the outside in this order, violet, indigo, +blue, green, yellow, orange, red. But the violet, by the mixture of the +white Light of the Clouds, will appear faint and incline to purple. + +[Illustration: FIG. 15.] + +Again, the Angle SGO being equal to the Angle POG, or 50 Gr. 51 Min. +shall be the least Angle in which the least refrangible Rays can after +two Reflexions emerge out of the Drops, and therefore the least +refrangible Rays shall come most copiously to the Eye from the Drops in +the Line OG, and strike the Sense with the deepest red in that Region. +And the Angle SHO being equal to the Angle POH, or 54 Gr. 7 Min. shall +be the least Angle, in which the most refrangible Rays after two +Reflexions can emerge out of the Drops; and therefore those Rays shall +come most copiously to the Eye from the Drops in the Line OH, and strike +the Senses with the deepest violet in that Region. And by the same +Argument, the Drops in the Regions between G and H shall strike the +Sense with the intermediate Colours in the Order which their Degrees of +Refrangibility require, that is, in the Progress from G to H, or from +the inside of the Bow to the outside in this order, red, orange, yellow, +green, blue, indigo, violet. And since these four Lines OE, OF, OG, OH, +may be situated any where in the above-mention'd conical Superficies; +what is said of the Drops and Colours in these Lines is to be understood +of the Drops and Colours every where in those Superficies. + +Thus shall there be made two Bows of Colours, an interior and stronger, +by one Reflexion in the Drops, and an exterior and fainter by two; for +the Light becomes fainter by every Reflexion. And their Colours shall +lie in a contrary Order to one another, the red of both Bows bordering +upon the Space GF, which is between the Bows. The Breadth of the +interior Bow EOF measured cross the Colours shall be 1 Degr. 45 Min. and +the Breadth of the exterior GOH shall be 3 Degr. 10 Min. and the +distance between them GOF shall be 8 Gr. 15 Min. the greatest +Semi-diameter of the innermost, that is, the Angle POF being 42 Gr. 2 +Min. and the least Semi-diameter of the outermost POG, being 50 Gr. 57 +Min. These are the Measures of the Bows, as they would be were the Sun +but a Point; for by the Breadth of his Body, the Breadth of the Bows +will be increased, and their Distance decreased by half a Degree, and so +the breadth of the interior Iris will be 2 Degr. 15 Min. that of the +exterior 3 Degr. 40 Min. their distance 8 Degr. 25 Min. the greatest +Semi-diameter of the interior Bow 42 Degr. 17 Min. and the least of the +exterior 50 Degr. 42 Min. And such are the Dimensions of the Bows in the +Heavens found to be very nearly, when their Colours appear strong and +perfect. For once, by such means as I then had, I measured the greatest +Semi-diameter of the interior Iris about 42 Degrees, and the breadth of +the red, yellow and green in that Iris 63 or 64 Minutes, besides the +outmost faint red obscured by the brightness of the Clouds, for which we +may allow 3 or 4 Minutes more. The breadth of the blue was about 40 +Minutes more besides the violet, which was so much obscured by the +brightness of the Clouds, that I could not measure its breadth. But +supposing the breadth of the blue and violet together to equal that of +the red, yellow and green together, the whole breadth of this Iris will +be about 2-1/4 Degrees, as above. The least distance between this Iris +and the exterior Iris was about 8 Degrees and 30 Minutes. The exterior +Iris was broader than the interior, but so faint, especially on the blue +side, that I could not measure its breadth distinctly. At another time +when both Bows appeared more distinct, I measured the breadth of the +interior Iris 2 Gr. 10´, and the breadth of the red, yellow and green in +the exterior Iris, was to the breadth of the same Colours in the +interior as 3 to 2. + +This Explication of the Rain-bow is yet farther confirmed by the known +Experiment (made by _Antonius de Dominis_ and _Des-Cartes_) of hanging +up any where in the Sun-shine a Glass Globe filled with Water, and +viewing it in such a posture, that the Rays which come from the Globe to +the Eye may contain with the Sun's Rays an Angle of either 42 or 50 +Degrees. For if the Angle be about 42 or 43 Degrees, the Spectator +(suppose at O) shall see a full red Colour in that side of the Globe +opposed to the Sun as 'tis represented at F, and if that Angle become +less (suppose by depressing the Globe to E) there will appear other +Colours, yellow, green and blue successive in the same side of the +Globe. But if the Angle be made about 50 Degrees (suppose by lifting up +the Globe to G) there will appear a red Colour in that side of the Globe +towards the Sun, and if the Angle be made greater (suppose by lifting +up the Globe to H) the red will turn successively to the other Colours, +yellow, green and blue. The same thing I have tried, by letting a Globe +rest, and raising or depressing the Eye, or otherwise moving it to make +the Angle of a just magnitude. + +I have heard it represented, that if the Light of a Candle be refracted +by a Prism to the Eye; when the blue Colour falls upon the Eye, the +Spectator shall see red in the Prism, and when the red falls upon the +Eye he shall see blue; and if this were certain, the Colours of the +Globe and Rain-bow ought to appear in a contrary order to what we find. +But the Colours of the Candle being very faint, the mistake seems to +arise from the difficulty of discerning what Colours fall on the Eye. +For, on the contrary, I have sometimes had occasion to observe in the +Sun's Light refracted by a Prism, that the Spectator always sees that +Colour in the Prism which falls upon his Eye. And the same I have found +true also in Candle-light. For when the Prism is moved slowly from the +Line which is drawn directly from the Candle to the Eye, the red appears +first in the Prism and then the blue, and therefore each of them is seen +when it falls upon the Eye. For the red passes over the Eye first, and +then the blue. + +The Light which comes through drops of Rain by two Refractions without +any Reflexion, ought to appear strongest at the distance of about 26 +Degrees from the Sun, and to decay gradually both ways as the distance +from him increases and decreases. And the same is to be understood of +Light transmitted through spherical Hail-stones. And if the Hail be a +little flatted, as it often is, the Light transmitted may grow so strong +at a little less distance than that of 26 Degrees, as to form a Halo +about the Sun or Moon; which Halo, as often as the Hail-stones are duly +figured may be colour'd, and then it must be red within by the least +refrangible Rays, and blue without by the most refrangible ones, +especially if the Hail-stones have opake Globules of Snow in their +center to intercept the Light within the Halo (as _Hugenius_ has +observ'd) and make the inside thereof more distinctly defined than it +would otherwise be. For such Hail-stones, though spherical, by +terminating the Light by the Snow, may make a Halo red within and +colourless without, and darker in the red than without, as Halos used to +be. For of those Rays which pass close by the Snow the Rubriform will be +least refracted, and so come to the Eye in the directest Lines. + +The Light which passes through a drop of Rain after two Refractions, and +three or more Reflexions, is scarce strong enough to cause a sensible +Bow; but in those Cylinders of Ice by which _Hugenius_ explains the +_Parhelia_, it may perhaps be sensible. + + +_PROP._ X. PROB. V. + +_By the discovered Properties of Light to explain the permanent Colours +of Natural Bodies._ + +These Colours arise from hence, that some natural Bodies reflect some +sorts of Rays, others other sorts more copiously than the rest. Minium +reflects the least refrangible or red-making Rays most copiously, and +thence appears red. Violets reflect the most refrangible most copiously, +and thence have their Colour, and so of other Bodies. Every Body +reflects the Rays of its own Colour more copiously than the rest, and +from their excess and predominance in the reflected Light has its +Colour. + +_Exper._ 17. For if in the homogeneal Lights obtained by the solution of +the Problem proposed in the fourth Proposition of the first Part of this +Book, you place Bodies of several Colours, you will find, as I have +done, that every Body looks most splendid and luminous in the Light of +its own Colour. Cinnaber in the homogeneal red Light is most +resplendent, in the green Light it is manifestly less resplendent, and +in the blue Light still less. Indigo in the violet blue Light is most +resplendent, and its splendor is gradually diminish'd, as it is removed +thence by degrees through the green and yellow Light to the red. By a +Leek the green Light, and next that the blue and yellow which compound +green, are more strongly reflected than the other Colours red and +violet, and so of the rest. But to make these Experiments the more +manifest, such Bodies ought to be chosen as have the fullest and most +vivid Colours, and two of those Bodies are to be compared together. +Thus, for instance, if Cinnaber and _ultra_-marine blue, or some other +full blue be held together in the red homogeneal Light, they will both +appear red, but the Cinnaber will appear of a strongly luminous and +resplendent red, and the _ultra_-marine blue of a faint obscure and dark +red; and if they be held together in the blue homogeneal Light, they +will both appear blue, but the _ultra_-marine will appear of a strongly +luminous and resplendent blue, and the Cinnaber of a faint and dark +blue. Which puts it out of dispute that the Cinnaber reflects the red +Light much more copiously than the _ultra_-marine doth, and the +_ultra_-marine reflects the blue Light much more copiously than the +Cinnaber doth. The same Experiment may be tried successfully with red +Lead and Indigo, or with any other two colour'd Bodies, if due allowance +be made for the different strength or weakness of their Colour and +Light. + +And as the reason of the Colours of natural Bodies is evident by these +Experiments, so it is farther confirmed and put past dispute by the two +first Experiments of the first Part, whereby 'twas proved in such Bodies +that the reflected Lights which differ in Colours do differ also in +degrees of Refrangibility. For thence it's certain, that some Bodies +reflect the more refrangible, others the less refrangible Rays more +copiously. + +And that this is not only a true reason of these Colours, but even the +only reason, may appear farther from this Consideration, that the Colour +of homogeneal Light cannot be changed by the Reflexion of natural +Bodies. + +For if Bodies by Reflexion cannot in the least change the Colour of any +one sort of Rays, they cannot appear colour'd by any other means than by +reflecting those which either are of their own Colour, or which by +mixture must produce it. + +But in trying Experiments of this kind care must be had that the Light +be sufficiently homogeneal. For if Bodies be illuminated by the ordinary +prismatick Colours, they will appear neither of their own Day-light +Colours, nor of the Colour of the Light cast on them, but of some middle +Colour between both, as I have found by Experience. Thus red Lead (for +instance) illuminated with the ordinary prismatick green will not appear +either red or green, but orange or yellow, or between yellow and green, +accordingly as the green Light by which 'tis illuminated is more or less +compounded. For because red Lead appears red when illuminated with white +Light, wherein all sorts of Rays are equally mix'd, and in the green +Light all sorts of Rays are not equally mix'd, the Excess of the +yellow-making, green-making and blue-making Rays in the incident green +Light, will cause those Rays to abound so much in the reflected Light, +as to draw the Colour from red towards their Colour. And because the red +Lead reflects the red-making Rays most copiously in proportion to their +number, and next after them the orange-making and yellow-making Rays; +these Rays in the reflected Light will be more in proportion to the +Light than they were in the incident green Light, and thereby will draw +the reflected Light from green towards their Colour. And therefore the +red Lead will appear neither red nor green, but of a Colour between +both. + +In transparently colour'd Liquors 'tis observable, that their Colour +uses to vary with their thickness. Thus, for instance, a red Liquor in a +conical Glass held between the Light and the Eye, looks of a pale and +dilute yellow at the bottom where 'tis thin, and a little higher where +'tis thicker grows orange, and where 'tis still thicker becomes red, and +where 'tis thickest the red is deepest and darkest. For it is to be +conceiv'd that such a Liquor stops the indigo-making and violet-making +Rays most easily, the blue-making Rays more difficultly, the +green-making Rays still more difficultly, and the red-making most +difficultly: And that if the thickness of the Liquor be only so much as +suffices to stop a competent number of the violet-making and +indigo-making Rays, without diminishing much the number of the rest, the +rest must (by _Prop._ 6. _Part_ 2.) compound a pale yellow. But if the +Liquor be so much thicker as to stop also a great number of the +blue-making Rays, and some of the green-making, the rest must compound +an orange; and where it is so thick as to stop also a great number of +the green-making and a considerable number of the yellow-making, the +rest must begin to compound a red, and this red must grow deeper and +darker as the yellow-making and orange-making Rays are more and more +stopp'd by increasing the thickness of the Liquor, so that few Rays +besides the red-making can get through. + +Of this kind is an Experiment lately related to me by Mr. _Halley_, who, +in diving deep into the Sea in a diving Vessel, found in a clear +Sun-shine Day, that when he was sunk many Fathoms deep into the Water +the upper part of his Hand on which the Sun shone directly through the +Water and through a small Glass Window in the Vessel appeared of a red +Colour, like that of a Damask Rose, and the Water below and the under +part of his Hand illuminated by Light reflected from the Water below +look'd green. For thence it may be gather'd, that the Sea-Water reflects +back the violet and blue-making Rays most easily, and lets the +red-making Rays pass most freely and copiously to great Depths. For +thereby the Sun's direct Light at all great Depths, by reason of the +predominating red-making Rays, must appear red; and the greater the +Depth is, the fuller and intenser must that red be. And at such Depths +as the violet-making Rays scarce penetrate unto, the blue-making, +green-making, and yellow-making Rays being reflected from below more +copiously than the red-making ones, must compound a green. + +Now, if there be two Liquors of full Colours, suppose a red and blue, +and both of them so thick as suffices to make their Colours sufficiently +full; though either Liquor be sufficiently transparent apart, yet will +you not be able to see through both together. For, if only the +red-making Rays pass through one Liquor, and only the blue-making +through the other, no Rays can pass through both. This Mr. _Hook_ tried +casually with Glass Wedges filled with red and blue Liquors, and was +surprized at the unexpected Event, the reason of it being then unknown; +which makes me trust the more to his Experiment, though I have not tried +it my self. But he that would repeat it, must take care the Liquors be +of very good and full Colours. + +Now, whilst Bodies become coloured by reflecting or transmitting this or +that sort of Rays more copiously than the rest, it is to be conceived +that they stop and stifle in themselves the Rays which they do not +reflect or transmit. For, if Gold be foliated and held between your Eye +and the Light, the Light looks of a greenish blue, and therefore massy +Gold lets into its Body the blue-making Rays to be reflected to and fro +within it till they be stopp'd and stifled, whilst it reflects the +yellow-making outwards, and thereby looks yellow. And much after the +same manner that Leaf Gold is yellow by reflected, and blue by +transmitted Light, and massy Gold is yellow in all Positions of the Eye; +there are some Liquors, as the Tincture of _Lignum Nephriticum_, and +some sorts of Glass which transmit one sort of Light most copiously, and +reflect another sort, and thereby look of several Colours, according to +the Position of the Eye to the Light. But, if these Liquors or Glasses +were so thick and massy that no Light could get through them, I question +not but they would like all other opake Bodies appear of one and the +same Colour in all Positions of the Eye, though this I cannot yet affirm +by Experience. For all colour'd Bodies, so far as my Observation +reaches, may be seen through if made sufficiently thin, and therefore +are in some measure transparent, and differ only in degrees of +Transparency from tinged transparent Liquors; these Liquors, as well as +those Bodies, by a sufficient Thickness becoming opake. A transparent +Body which looks of any Colour by transmitted Light, may also look of +the same Colour by reflected Light, the Light of that Colour being +reflected by the farther Surface of the Body, or by the Air beyond it. +And then the reflected Colour will be diminished, and perhaps cease, by +making the Body very thick, and pitching it on the backside to diminish +the Reflexion of its farther Surface, so that the Light reflected from +the tinging Particles may predominate. In such Cases, the Colour of the +reflected Light will be apt to vary from that of the Light transmitted. +But whence it is that tinged Bodies and Liquors reflect some sort of +Rays, and intromit or transmit other sorts, shall be said in the next +Book. In this Proposition I content my self to have put it past dispute, +that Bodies have such Properties, and thence appear colour'd. + + +_PROP._ XI. PROB. VI. + +_By mixing colour'd Lights to compound a beam of Light of the same +Colour and Nature with a beam of the Sun's direct Light, and therein to +experience the Truth of the foregoing Propositions._ + +[Illustration: FIG. 16.] + +Let ABC _abc_ [in _Fig._ 16.] represent a Prism, by which the Sun's +Light let into a dark Chamber through the Hole F, may be refracted +towards the Lens MN, and paint upon it at _p_, _q_, _r_, _s_, and _t_, +the usual Colours violet, blue, green, yellow, and red, and let the +diverging Rays by the Refraction of this Lens converge again towards X, +and there, by the mixture of all those their Colours, compound a white +according to what was shewn above. Then let another Prism DEG _deg_, +parallel to the former, be placed at X, to refract that white Light +upwards towards Y. Let the refracting Angles of the Prisms, and their +distances from the Lens be equal, so that the Rays which converged from +the Lens towards X, and without Refraction, would there have crossed and +diverged again, may by the Refraction of the second Prism be reduced +into Parallelism and diverge no more. For then those Rays will recompose +a beam of white Light XY. If the refracting Angle of either Prism be the +bigger, that Prism must be so much the nearer to the Lens. You will know +when the Prisms and the Lens are well set together, by observing if the +beam of Light XY, which comes out of the second Prism be perfectly white +to the very edges of the Light, and at all distances from the Prism +continue perfectly and totally white like a beam of the Sun's Light. For +till this happens, the Position of the Prisms and Lens to one another +must be corrected; and then if by the help of a long beam of Wood, as is +represented in the Figure, or by a Tube, or some other such Instrument, +made for that Purpose, they be made fast in that Situation, you may try +all the same Experiments in this compounded beam of Light XY, which have +been made in the Sun's direct Light. For this compounded beam of Light +has the same appearance, and is endow'd with all the same Properties +with a direct beam of the Sun's Light, so far as my Observation reaches. +And in trying Experiments in this beam you may by stopping any of the +Colours, _p_, _q_, _r_, _s_, and _t_, at the Lens, see how the Colours +produced in the Experiments are no other than those which the Rays had +at the Lens before they entered the Composition of this Beam: And by +consequence, that they arise not from any new Modifications of the Light +by Refractions and Reflexions, but from the various Separations and +Mixtures of the Rays originally endow'd with their colour-making +Qualities. + +So, for instance, having with a Lens 4-1/4 Inches broad, and two Prisms +on either hand 6-1/4 Feet distant from the Lens, made such a beam of +compounded Light; to examine the reason of the Colours made by Prisms, I +refracted this compounded beam of Light XY with another Prism HIK _kh_, +and thereby cast the usual Prismatick Colours PQRST upon the Paper LV +placed behind. And then by stopping any of the Colours _p_, _q_, _r_, +_s_, _t_, at the Lens, I found that the same Colour would vanish at the +Paper. So if the Purple _p_ was stopp'd at the Lens, the Purple P upon +the Paper would vanish, and the rest of the Colours would remain +unalter'd, unless perhaps the blue, so far as some purple latent in it +at the Lens might be separated from it by the following Refractions. And +so by intercepting the green upon the Lens, the green R upon the Paper +would vanish, and so of the rest; which plainly shews, that as the white +beam of Light XY was compounded of several Lights variously colour'd at +the Lens, so the Colours which afterwards emerge out of it by new +Refractions are no other than those of which its Whiteness was +compounded. The Refraction of the Prism HIK _kh_ generates the Colours +PQRST upon the Paper, not by changing the colorific Qualities of the +Rays, but by separating the Rays which had the very same colorific +Qualities before they enter'd the Composition of the refracted beam of +white Light XY. For otherwise the Rays which were of one Colour at the +Lens might be of another upon the Paper, contrary to what we find. + +So again, to examine the reason of the Colours of natural Bodies, I +placed such Bodies in the Beam of Light XY, and found that they all +appeared there of those their own Colours which they have in Day-light, +and that those Colours depend upon the Rays which had the same Colours +at the Lens before they enter'd the Composition of that beam. Thus, for +instance, Cinnaber illuminated by this beam appears of the same red +Colour as in Day-light; and if at the Lens you intercept the +green-making and blue-making Rays, its redness will become more full and +lively: But if you there intercept the red-making Rays, it will not any +longer appear red, but become yellow or green, or of some other Colour, +according to the sorts of Rays which you do not intercept. So Gold in +this Light XY appears of the same yellow Colour as in Day-light, but by +intercepting at the Lens a due Quantity of the yellow-making Rays it +will appear white like Silver (as I have tried) which shews that its +yellowness arises from the Excess of the intercepted Rays tinging that +Whiteness with their Colour when they are let pass. So the Infusion of +_Lignum Nephriticum_ (as I have also tried) when held in this beam of +Light XY, looks blue by the reflected Part of the Light, and red by the +transmitted Part of it, as when 'tis view'd in Day-light; but if you +intercept the blue at the Lens the Infusion will lose its reflected blue +Colour, whilst its transmitted red remains perfect, and by the loss of +some blue-making Rays, wherewith it was allay'd, becomes more intense +and full. And, on the contrary, if the red and orange-making Rays be +intercepted at the Lens, the Infusion will lose its transmitted red, +whilst its blue will remain and become more full and perfect. Which +shews, that the Infusion does not tinge the Rays with blue and red, but +only transmits those most copiously which were red-making before, and +reflects those most copiously which were blue-making before. And after +the same manner may the Reasons of other Phænomena be examined, by +trying them in this artificial beam of Light XY. + +FOOTNOTES: + +[I] See p. 59. + +[J] _See our_ Author's Lect. Optic. _Part_ II. _Sect._ II. _p._ 239. + +[K] _As is done in our_ Author's Lect. Optic. _Part_ I. _Sect._ III. +_and_ IV. _and Part_ II. _Sect._ II. + +[L] _See our_ Author's Lect. Optic. _Part_ II. _Sect._ II. _pag._ 269, +&c. + +[M] _This is demonstrated in our_ Author's Lect. Optic. _Part_ I. +_Sect._ IV. _Prop._ 35 _and_ 36. + + + + +THE + +SECOND BOOK + +OF + +OPTICKS + + + + +_PART I._ + +_Observations concerning the Reflexions, Refractions, and Colours of +thin transparent Bodies._ + + +It has been observed by others, that transparent Substances, as Glass, +Water, Air, &c. when made very thin by being blown into Bubbles, or +otherwise formed into Plates, do exhibit various Colours according to +their various thinness, altho' at a greater thickness they appear very +clear and colourless. In the former Book I forbore to treat of these +Colours, because they seemed of a more difficult Consideration, and were +not necessary for establishing the Properties of Light there discoursed +of. But because they may conduce to farther Discoveries for compleating +the Theory of Light, especially as to the constitution of the parts of +natural Bodies, on which their Colours or Transparency depend; I have +here set down an account of them. To render this Discourse short and +distinct, I have first described the principal of my Observations, and +then consider'd and made use of them. The Observations are these. + +_Obs._ 1. Compressing two Prisms hard together that their sides (which +by chance were a very little convex) might somewhere touch one another: +I found the place in which they touched to become absolutely +transparent, as if they had there been one continued piece of Glass. For +when the Light fell so obliquely on the Air, which in other places was +between them, as to be all reflected; it seemed in that place of contact +to be wholly transmitted, insomuch that when look'd upon, it appeared +like a black or dark spot, by reason that little or no sensible Light +was reflected from thence, as from other places; and when looked through +it seemed (as it were) a hole in that Air which was formed into a thin +Plate, by being compress'd between the Glasses. And through this hole +Objects that were beyond might be seen distinctly, which could not at +all be seen through other parts of the Glasses where the Air was +interjacent. Although the Glasses were a little convex, yet this +transparent spot was of a considerable breadth, which breadth seemed +principally to proceed from the yielding inwards of the parts of the +Glasses, by reason of their mutual pressure. For by pressing them very +hard together it would become much broader than otherwise. + +_Obs._ 2. When the Plate of Air, by turning the Prisms about their +common Axis, became so little inclined to the incident Rays, that some +of them began to be transmitted, there arose in it many slender Arcs of +Colours which at first were shaped almost like the Conchoid, as you see +them delineated in the first Figure. And by continuing the Motion of the +Prisms, these Arcs increased and bended more and more about the said +transparent spot, till they were compleated into Circles or Rings +incompassing it, and afterwards continually grew more and more +contracted. + +[Illustration: FIG. 1.] + +These Arcs at their first appearance were of a violet and blue Colour, +and between them were white Arcs of Circles, which presently by +continuing the Motion of the Prisms became a little tinged in their +inward Limbs with red and yellow, and to their outward Limbs the blue +was adjacent. So that the order of these Colours from the central dark +spot, was at that time white, blue, violet; black, red, orange, yellow, +white, blue, violet, &c. But the yellow and red were much fainter than +the blue and violet. + +The Motion of the Prisms about their Axis being continued, these Colours +contracted more and more, shrinking towards the whiteness on either +side of it, until they totally vanished into it. And then the Circles in +those parts appear'd black and white, without any other Colours +intermix'd. But by farther moving the Prisms about, the Colours again +emerged out of the whiteness, the violet and blue at its inward Limb, +and at its outward Limb the red and yellow. So that now their order from +the central Spot was white, yellow, red; black; violet, blue, white, +yellow, red, &c. contrary to what it was before. + +_Obs._ 3. When the Rings or some parts of them appeared only black and +white, they were very distinct and well defined, and the blackness +seemed as intense as that of the central Spot. Also in the Borders of +the Rings, where the Colours began to emerge out of the whiteness, they +were pretty distinct, which made them visible to a very great multitude. +I have sometimes number'd above thirty Successions (reckoning every +black and white Ring for one Succession) and seen more of them, which by +reason of their smalness I could not number. But in other Positions of +the Prisms, at which the Rings appeared of many Colours, I could not +distinguish above eight or nine of them, and the Exterior of those were +very confused and dilute. + +In these two Observations to see the Rings distinct, and without any +other Colour than Black and white, I found it necessary to hold my Eye +at a good distance from them. For by approaching nearer, although in the +same inclination of my Eye to the Plane of the Rings, there emerged a +bluish Colour out of the white, which by dilating it self more and more +into the black, render'd the Circles less distinct, and left the white a +little tinged with red and yellow. I found also by looking through a +slit or oblong hole, which was narrower than the pupil of my Eye, and +held close to it parallel to the Prisms, I could see the Circles much +distincter and visible to a far greater number than otherwise. + +_Obs._ 4. To observe more nicely the order of the Colours which arose +out of the white Circles as the Rays became less and less inclined to +the Plate of Air; I took two Object-glasses, the one a Plano-convex for +a fourteen Foot Telescope, and the other a large double Convex for one +of about fifty Foot; and upon this, laying the other with its plane side +downwards, I pressed them slowly together, to make the Colours +successively emerge in the middle of the Circles, and then slowly lifted +the upper Glass from the lower to make them successively vanish again in +the same place. The Colour, which by pressing the Glasses together, +emerged last in the middle of the other Colours, would upon its first +appearance look like a Circle of a Colour almost uniform from the +circumference to the center and by compressing the Glasses still more, +grow continually broader until a new Colour emerged in its center, and +thereby it became a Ring encompassing that new Colour. And by +compressing the Glasses still more, the diameter of this Ring would +increase, and the breadth of its Orbit or Perimeter decrease until +another new Colour emerged in the center of the last: And so on until a +third, a fourth, a fifth, and other following new Colours successively +emerged there, and became Rings encompassing the innermost Colour, the +last of which was the black Spot. And, on the contrary, by lifting up +the upper Glass from the lower, the diameter of the Rings would +decrease, and the breadth of their Orbit increase, until their Colours +reached successively to the center; and then they being of a +considerable breadth, I could more easily discern and distinguish their +Species than before. And by this means I observ'd their Succession and +Quantity to be as followeth. + +Next to the pellucid central Spot made by the contact of the Glasses +succeeded blue, white, yellow, and red. The blue was so little in +quantity, that I could not discern it in the Circles made by the Prisms, +nor could I well distinguish any violet in it, but the yellow and red +were pretty copious, and seemed about as much in extent as the white, +and four or five times more than the blue. The next Circuit in order of +Colours immediately encompassing these were violet, blue, green, yellow, +and red: and these were all of them copious and vivid, excepting the +green, which was very little in quantity, and seemed much more faint and +dilute than the other Colours. Of the other four, the violet was the +least in extent, and the blue less than the yellow or red. The third +Circuit or Order was purple, blue, green, yellow, and red; in which the +purple seemed more reddish than the violet in the former Circuit, and +the green was much more conspicuous, being as brisk and copious as any +of the other Colours, except the yellow, but the red began to be a +little faded, inclining very much to purple. After this succeeded the +fourth Circuit of green and red. The green was very copious and lively, +inclining on the one side to blue, and on the other side to yellow. But +in this fourth Circuit there was neither violet, blue, nor yellow, and +the red was very imperfect and dirty. Also the succeeding Colours became +more and more imperfect and dilute, till after three or four revolutions +they ended in perfect whiteness. Their form, when the Glasses were most +compress'd so as to make the black Spot appear in the center, is +delineated in the second Figure; where _a_, _b_, _c_, _d_, _e_: _f_, +_g_, _h_, _i_, _k_: _l_, _m_, _n_, _o_, _p_: _q_, _r_: _s_, _t_: _v_, +_x_: _y_, _z_, denote the Colours reckon'd in order from the center, +black, blue, white, yellow, red: violet, blue, green, yellow, red: +purple, blue, green, yellow, red: green, red: greenish blue, red: +greenish blue, pale red: greenish blue, reddish white. + +[Illustration: FIG. 2.] + +_Obs._ 5. To determine the interval of the Glasses, or thickness of the +interjacent Air, by which each Colour was produced, I measured the +Diameters of the first six Rings at the most lucid part of their Orbits, +and squaring them, I found their Squares to be in the arithmetical +Progression of the odd Numbers, 1, 3, 5, 7, 9, 11. And since one of +these Glasses was plane, and the other spherical, their Intervals at +those Rings must be in the same Progression. I measured also the +Diameters of the dark or faint Rings between the more lucid Colours, and +found their Squares to be in the arithmetical Progression of the even +Numbers, 2, 4, 6, 8, 10, 12. And it being very nice and difficult to +take these measures exactly; I repeated them divers times at divers +parts of the Glasses, that by their Agreement I might be confirmed in +them. And the same method I used in determining some others of the +following Observations. + +_Obs._ 6. The Diameter of the sixth Ring at the most lucid part of its +Orbit was 58/100 parts of an Inch, and the Diameter of the Sphere on +which the double convex Object-glass was ground was about 102 Feet, and +hence I gathered the thickness of the Air or Aereal Interval of the +Glasses at that Ring. But some time after, suspecting that in making +this Observation I had not determined the Diameter of the Sphere with +sufficient accurateness, and being uncertain whether the Plano-convex +Glass was truly plane, and not something concave or convex on that side +which I accounted plane; and whether I had not pressed the Glasses +together, as I often did, to make them touch; (For by pressing such +Glasses together their parts easily yield inwards, and the Rings thereby +become sensibly broader than they would be, did the Glasses keep their +Figures.) I repeated the Experiment, and found the Diameter of the sixth +lucid Ring about 55/100 parts of an Inch. I repeated the Experiment also +with such an Object-glass of another Telescope as I had at hand. This +was a double Convex ground on both sides to one and the same Sphere, and +its Focus was distant from it 83-2/5 Inches. And thence, if the Sines of +Incidence and Refraction of the bright yellow Light be assumed in +proportion as 11 to 17, the Diameter of the Sphere to which the Glass +was figured will by computation be found 182 Inches. This Glass I laid +upon a flat one, so that the black Spot appeared in the middle of the +Rings of Colours without any other Pressure than that of the weight of +the Glass. And now measuring the Diameter of the fifth dark Circle as +accurately as I could, I found it the fifth part of an Inch precisely. +This Measure was taken with the points of a pair of Compasses on the +upper Surface on the upper Glass, and my Eye was about eight or nine +Inches distance from the Glass, almost perpendicularly over it, and the +Glass was 1/6 of an Inch thick, and thence it is easy to collect that +the true Diameter of the Ring between the Glasses was greater than its +measur'd Diameter above the Glasses in the Proportion of 80 to 79, or +thereabouts, and by consequence equal to 16/79 parts of an Inch, and its +true Semi-diameter equal to 8/79 parts. Now as the Diameter of the +Sphere (182 Inches) is to the Semi-diameter of this fifth dark Ring +(8/79 parts of an Inch) so is this Semi-diameter to the thickness of the +Air at this fifth dark Ring; which is therefore 32/567931 or +100/1774784. Parts of an Inch; and the fifth Part thereof, _viz._ the +1/88739 Part of an Inch, is the Thickness of the Air at the first of +these dark Rings. + +The same Experiment I repeated with another double convex Object-glass +ground on both sides to one and the same Sphere. Its Focus was distant +from it 168-1/2 Inches, and therefore the Diameter of that Sphere was +184 Inches. This Glass being laid upon the same plain Glass, the +Diameter of the fifth of the dark Rings, when the black Spot in their +Center appear'd plainly without pressing the Glasses, was by the measure +of the Compasses upon the upper Glass 121/600 Parts of an Inch, and by +consequence between the Glasses it was 1222/6000: For the upper Glass +was 1/8 of an Inch thick, and my Eye was distant from it 8 Inches. And a +third proportional to half this from the Diameter of the Sphere is +5/88850 Parts of an Inch. This is therefore the Thickness of the Air at +this Ring, and a fifth Part thereof, _viz._ the 1/88850th Part of an +Inch is the Thickness thereof at the first of the Rings, as above. + +I tried the same Thing, by laying these Object-glasses upon flat Pieces +of a broken Looking-glass, and found the same Measures of the Rings: +Which makes me rely upon them till they can be determin'd more +accurately by Glasses ground to larger Spheres, though in such Glasses +greater care must be taken of a true Plane. + +These Dimensions were taken, when my Eye was placed almost +perpendicularly over the Glasses, being about an Inch, or an Inch and a +quarter, distant from the incident Rays, and eight Inches distant from +the Glass; so that the Rays were inclined to the Glass in an Angle of +about four Degrees. Whence by the following Observation you will +understand, that had the Rays been perpendicular to the Glasses, the +Thickness of the Air at these Rings would have been less in the +Proportion of the Radius to the Secant of four Degrees, that is, of +10000 to 10024. Let the Thicknesses found be therefore diminish'd in +this Proportion, and they will become 1/88952 and 1/89063, or (to use +the nearest round Number) the 1/89000th Part of an Inch. This is the +Thickness of the Air at the darkest Part of the first dark Ring made by +perpendicular Rays; and half this Thickness multiplied by the +Progression, 1, 3, 5, 7, 9, 11, &c. gives the Thicknesses of the Air at +the most luminous Parts of all the brightest Rings, _viz._ 1/178000, +3/178000, 5/178000, 7/178000, &c. their arithmetical Means 2/178000, +4/178000, 6/178000, &c. being its Thicknesses at the darkest Parts of +all the dark ones. + +_Obs._ 7. The Rings were least, when my Eye was placed perpendicularly +over the Glasses in the Axis of the Rings: And when I view'd them +obliquely they became bigger, continually swelling as I removed my Eye +farther from the Axis. And partly by measuring the Diameter of the same +Circle at several Obliquities of my Eye, partly by other Means, as also +by making use of the two Prisms for very great Obliquities, I found its +Diameter, and consequently the Thickness of the Air at its Perimeter in +all those Obliquities to be very nearly in the Proportions express'd in +this Table. + +-------------------+--------------------+----------+---------- +Angle of Incidence |Angle of Refraction |Diameter |Thickness + on | into | of the | of the + the Air. | the Air. | Ring. | Air. +-------------------+--------------------+----------+---------- + Deg. Min. | | | + | | | + 00 00 | 00 00 | 10 | 10 + | | | + 06 26 | 10 00 | 10-1/13 | 10-2/13 + | | | + 12 45 | 20 00 | 10-1/3 | 10-2/3 + | | | + 18 49 | 30 00 | 10-3/4 | 11-1/2 + | | | + 24 30 | 40 00 | 11-2/5 | 13 + | | | + 29 37 | 50 00 | 12-1/2 | 15-1/2 + | | | + 33 58 | 60 00 | 14 | 20 + | | | + 35 47 | 65 00 | 15-1/4 | 23-1/4 + | | | + 37 19 | 70 00 | 16-4/5 | 28-1/4 + | | | + 38 33 | 75 00 | 19-1/4 | 37 + | | | + 39 27 | 80 00 | 22-6/7 | 52-1/4 + | | | + 40 00 | 85 00 | 29 | 84-1/12 + | | | + 40 11 | 90 00 | 35 | 122-1/2 +-------------------+--------------------+----------+---------- + +In the two first Columns are express'd the Obliquities of the incident +and emergent Rays to the Plate of the Air, that is, their Angles of +Incidence and Refraction. In the third Column the Diameter of any +colour'd Ring at those Obliquities is expressed in Parts, of which ten +constitute that Diameter when the Rays are perpendicular. And in the +fourth Column the Thickness of the Air at the Circumference of that Ring +is expressed in Parts, of which also ten constitute its Thickness when +the Rays are perpendicular. + +And from these Measures I seem to gather this Rule: That the Thickness +of the Air is proportional to the Secant of an Angle, whose Sine is a +certain mean Proportional between the Sines of Incidence and Refraction. +And that mean Proportional, so far as by these Measures I can determine +it, is the first of an hundred and six arithmetical mean Proportionals +between those Sines counted from the bigger Sine, that is, from the Sine +of Refraction when the Refraction is made out of the Glass into the +Plate of Air, or from the Sine of Incidence when the Refraction is made +out of the Plate of Air into the Glass. + +_Obs._ 8. The dark Spot in the middle of the Rings increased also by the +Obliquation of the Eye, although almost insensibly. But, if instead of +the Object-glasses the Prisms were made use of, its Increase was more +manifest when viewed so obliquely that no Colours appear'd about it. It +was least when the Rays were incident most obliquely on the interjacent +Air, and as the obliquity decreased it increased more and more until the +colour'd Rings appear'd, and then decreased again, but not so much as it +increased before. And hence it is evident, that the Transparency was +not only at the absolute Contact of the Glasses, but also where they had +some little Interval. I have sometimes observed the Diameter of that +Spot to be between half and two fifth parts of the Diameter of the +exterior Circumference of the red in the first Circuit or Revolution of +Colours when view'd almost perpendicularly; whereas when view'd +obliquely it hath wholly vanish'd and become opake and white like the +other parts of the Glass; whence it may be collected that the Glasses +did then scarcely, or not at all, touch one another, and that their +Interval at the perimeter of that Spot when view'd perpendicularly was +about a fifth or sixth part of their Interval at the circumference of +the said red. + +_Obs._ 9. By looking through the two contiguous Object-glasses, I found +that the interjacent Air exhibited Rings of Colours, as well by +transmitting Light as by reflecting it. The central Spot was now white, +and from it the order of the Colours were yellowish red; black, violet, +blue, white, yellow, red; violet, blue, green, yellow, red, &c. But +these Colours were very faint and dilute, unless when the Light was +trajected very obliquely through the Glasses: For by that means they +became pretty vivid. Only the first yellowish red, like the blue in the +fourth Observation, was so little and faint as scarcely to be discern'd. +Comparing the colour'd Rings made by Reflexion, with these made by +transmission of the Light; I found that white was opposite to black, red +to blue, yellow to violet, and green to a Compound of red and violet. +That is, those parts of the Glass were black when looked through, which +when looked upon appeared white, and on the contrary. And so those which +in one case exhibited blue, did in the other case exhibit red. And the +like of the other Colours. The manner you have represented in the third +Figure, where AB, CD, are the Surfaces of the Glasses contiguous at E, +and the black Lines between them are their Distances in arithmetical +Progression, and the Colours written above are seen by reflected Light, +and those below by Light transmitted (p. 209). + +_Obs._ 10. Wetting the Object-glasses a little at their edges, the Water +crept in slowly between them, and the Circles thereby became less and +the Colours more faint: Insomuch that as the Water crept along, one half +of them at which it first arrived would appear broken off from the other +half, and contracted into a less Room. By measuring them I found the +Proportions of their Diameters to the Diameters of the like Circles made +by Air to be about seven to eight, and consequently the Intervals of the +Glasses at like Circles, caused by those two Mediums Water and Air, are +as about three to four. Perhaps it may be a general Rule, That if any +other Medium more or less dense than Water be compress'd between the +Glasses, their Intervals at the Rings caused thereby will be to their +Intervals caused by interjacent Air, as the Sines are which measure the +Refraction made out of that Medium into Air. + +_Obs._ 11. When the Water was between the Glasses, if I pressed the +upper Glass variously at its edges to make the Rings move nimbly from +one place to another, a little white Spot would immediately follow the +center of them, which upon creeping in of the ambient Water into that +place would presently vanish. Its appearance was such as interjacent Air +would have caused, and it exhibited the same Colours. But it was not +air, for where any Bubbles of Air were in the Water they would not +vanish. The Reflexion must have rather been caused by a subtiler Medium, +which could recede through the Glasses at the creeping in of the Water. + +_Obs._ 12. These Observations were made in the open Air. But farther to +examine the Effects of colour'd Light falling on the Glasses, I darken'd +the Room, and view'd them by Reflexion of the Colours of a Prism cast on +a Sheet of white Paper, my Eye being so placed that I could see the +colour'd Paper by Reflexion in the Glasses, as in a Looking-glass. And +by this means the Rings became distincter and visible to a far greater +number than in the open Air. I have sometimes seen more than twenty of +them, whereas in the open Air I could not discern above eight or nine. + +[Illustration: FIG. 3.] + +_Obs._ 13. Appointing an Assistant to move the Prism to and fro about +its Axis, that all the Colours might successively fall on that part of +the Paper which I saw by Reflexion from that part of the Glasses, where +the Circles appear'd, so that all the Colours might be successively +reflected from the Circles to my Eye, whilst I held it immovable, I +found the Circles which the red Light made to be manifestly bigger than +those which were made by the blue and violet. And it was very pleasant +to see them gradually swell or contract accordingly as the Colour of the +Light was changed. The Interval of the Glasses at any of the Rings when +they were made by the utmost red Light, was to their Interval at the +same Ring when made by the utmost violet, greater than as 3 to 2, and +less than as 13 to 8. By the most of my Observations it was as 14 to 9. +And this Proportion seem'd very nearly the same in all Obliquities of my +Eye; unless when two Prisms were made use of instead of the +Object-glasses. For then at a certain great obliquity of my Eye, the +Rings made by the several Colours seem'd equal, and at a greater +obliquity those made by the violet would be greater than the same Rings +made by the red: the Refraction of the Prism in this case causing the +most refrangible Rays to fall more obliquely on that plate of the Air +than the least refrangible ones. Thus the Experiment succeeded in the +colour'd Light, which was sufficiently strong and copious to make the +Rings sensible. And thence it may be gather'd, that if the most +refrangible and least refrangible Rays had been copious enough to make +the Rings sensible without the mixture of other Rays, the Proportion +which here was 14 to 9 would have been a little greater, suppose 14-1/4 +or 14-1/3 to 9. + +_Obs._ 14. Whilst the Prism was turn'd about its Axis with an uniform +Motion, to make all the several Colours fall successively upon the +Object-glasses, and thereby to make the Rings contract and dilate: The +Contraction or Dilatation of each Ring thus made by the variation of its +Colour was swiftest in the red, and slowest in the violet, and in the +intermediate Colours it had intermediate degrees of Celerity. Comparing +the quantity of Contraction and Dilatation made by all the degrees of +each Colour, I found that it was greatest in the red; less in the +yellow, still less in the blue, and least in the violet. And to make as +just an Estimation as I could of the Proportions of their Contractions +or Dilatations, I observ'd that the whole Contraction or Dilatation of +the Diameter of any Ring made by all the degrees of red, was to that of +the Diameter of the same Ring made by all the degrees of violet, as +about four to three, or five to four, and that when the Light was of the +middle Colour between yellow and green, the Diameter of the Ring was +very nearly an arithmetical Mean between the greatest Diameter of the +same Ring made by the outmost red, and the least Diameter thereof made +by the outmost violet: Contrary to what happens in the Colours of the +oblong Spectrum made by the Refraction of a Prism, where the red is most +contracted, the violet most expanded, and in the midst of all the +Colours is the Confine of green and blue. And hence I seem to collect +that the thicknesses of the Air between the Glasses there, where the +Ring is successively made by the limits of the five principal Colours +(red, yellow, green, blue, violet) in order (that is, by the extreme +red, by the limit of red and yellow in the middle of the orange, by the +limit of yellow and green, by the limit of green and blue, by the limit +of blue and violet in the middle of the indigo, and by the extreme +violet) are to one another very nearly as the sixth lengths of a Chord +which found the Notes in a sixth Major, _sol_, _la_, _mi_, _fa_, _sol_, +_la_. But it agrees something better with the Observation to say, that +the thicknesses of the Air between the Glasses there, where the Rings +are successively made by the limits of the seven Colours, red, orange, +yellow, green, blue, indigo, violet in order, are to one another as the +Cube Roots of the Squares of the eight lengths of a Chord, which found +the Notes in an eighth, _sol_, _la_, _fa_, _sol_, _la_, _mi_, _fa_, +_sol_; that is, as the Cube Roots of the Squares of the Numbers, 1, 8/9, +5/6, 3/4, 2/3, 3/5, 9/16, 1/2. + +_Obs._ 15. These Rings were not of various Colours like those made in +the open Air, but appeared all over of that prismatick Colour only with +which they were illuminated. And by projecting the prismatick Colours +immediately upon the Glasses, I found that the Light which fell on the +dark Spaces which were between the Colour'd Rings was transmitted +through the Glasses without any variation of Colour. For on a white +Paper placed behind, it would paint Rings of the same Colour with those +which were reflected, and of the bigness of their immediate Spaces. And +from thence the origin of these Rings is manifest; namely, that the Air +between the Glasses, according to its various thickness, is disposed in +some places to reflect, and in others to transmit the Light of any one +Colour (as you may see represented in the fourth Figure) and in the same +place to reflect that of one Colour where it transmits that of another. + +[Illustration: FIG. 4.] + +_Obs._ 16. The Squares of the Diameters of these Rings made by any +prismatick Colour were in arithmetical Progression, as in the fifth +Observation. And the Diameter of the sixth Circle, when made by the +citrine yellow, and viewed almost perpendicularly was about 58/100 parts +of an Inch, or a little less, agreeable to the sixth Observation. + +The precedent Observations were made with a rarer thin Medium, +terminated by a denser, such as was Air or Water compress'd between two +Glasses. In those that follow are set down the Appearances of a denser +Medium thin'd within a rarer, such as are Plates of Muscovy Glass, +Bubbles of Water, and some other thin Substances terminated on all sides +with air. + +_Obs._ 17. If a Bubble be blown with Water first made tenacious by +dissolving a little Soap in it, 'tis a common Observation, that after a +while it will appear tinged with a great variety of Colours. To defend +these Bubbles from being agitated by the external Air (whereby their +Colours are irregularly moved one among another, so that no accurate +Observation can be made of them,) as soon as I had blown any of them I +cover'd it with a clear Glass, and by that means its Colours emerged in +a very regular order, like so many concentrick Rings encompassing the +top of the Bubble. And as the Bubble grew thinner by the continual +subsiding of the Water, these Rings dilated slowly and overspread the +whole Bubble, descending in order to the bottom of it, where they +vanish'd successively. In the mean while, after all the Colours were +emerged at the top, there grew in the center of the Rings a small round +black Spot, like that in the first Observation, which continually +dilated it self till it became sometimes more than 1/2 or 3/4 of an Inch +in breadth before the Bubble broke. At first I thought there had been no +Light reflected from the Water in that place, but observing it more +curiously, I saw within it several smaller round Spots, which appeared +much blacker and darker than the rest, whereby I knew that there was +some Reflexion at the other places which were not so dark as those +Spots. And by farther Tryal I found that I could see the Images of some +things (as of a Candle or the Sun) very faintly reflected, not only from +the great black Spot, but also from the little darker Spots which were +within it. + +Besides the aforesaid colour'd Rings there would often appear small +Spots of Colours, ascending and descending up and down the sides of the +Bubble, by reason of some Inequalities in the subsiding of the Water. +And sometimes small black Spots generated at the sides would ascend up +to the larger black Spot at the top of the Bubble, and unite with it. + +_Obs._ 18. Because the Colours of these Bubbles were more extended and +lively than those of the Air thinn'd between two Glasses, and so more +easy to be distinguish'd, I shall here give you a farther description of +their order, as they were observ'd in viewing them by Reflexion of the +Skies when of a white Colour, whilst a black substance was placed +behind the Bubble. And they were these, red, blue; red, blue; red, blue; +red, green; red, yellow, green, blue, purple; red, yellow, green, blue, +violet; red, yellow, white, blue, black. + +The three first Successions of red and blue were very dilute and dirty, +especially the first, where the red seem'd in a manner to be white. +Among these there was scarce any other Colour sensible besides red and +blue, only the blues (and principally the second blue) inclined a little +to green. + +The fourth red was also dilute and dirty, but not so much as the former +three; after that succeeded little or no yellow, but a copious green, +which at first inclined a little to yellow, and then became a pretty +brisk and good willow green, and afterwards changed to a bluish Colour; +but there succeeded neither blue nor violet. + +The fifth red at first inclined very much to purple, and afterwards +became more bright and brisk, but yet not very pure. This was succeeded +with a very bright and intense yellow, which was but little in quantity, +and soon chang'd to green: But that green was copious and something more +pure, deep and lively, than the former green. After that follow'd an +excellent blue of a bright Sky-colour, and then a purple, which was less +in quantity than the blue, and much inclined to red. + +The sixth red was at first of a very fair and lively scarlet, and soon +after of a brighter Colour, being very pure and brisk, and the best of +all the reds. Then after a lively orange follow'd an intense bright and +copious yellow, which was also the best of all the yellows, and this +changed first to a greenish yellow, and then to a greenish blue; but the +green between the yellow and the blue, was very little and dilute, +seeming rather a greenish white than a green. The blue which succeeded +became very good, and of a very bright Sky-colour, but yet something +inferior to the former blue; and the violet was intense and deep with +little or no redness in it. And less in quantity than the blue. + +In the last red appeared a tincture of scarlet next to violet, which +soon changed to a brighter Colour, inclining to an orange; and the +yellow which follow'd was at first pretty good and lively, but +afterwards it grew more dilute until by degrees it ended in perfect +whiteness. And this whiteness, if the Water was very tenacious and +well-temper'd, would slowly spread and dilate it self over the greater +part of the Bubble; continually growing paler at the top, where at +length it would crack in many places, and those cracks, as they dilated, +would appear of a pretty good, but yet obscure and dark Sky-colour; the +white between the blue Spots diminishing, until it resembled the Threds +of an irregular Net-work, and soon after vanish'd, and left all the +upper part of the Bubble of the said dark blue Colour. And this Colour, +after the aforesaid manner, dilated it self downwards, until sometimes +it hath overspread the whole Bubble. In the mean while at the top, which +was of a darker blue than the bottom, and appear'd also full of many +round blue Spots, something darker than the rest, there would emerge +one or more very black Spots, and within those, other Spots of an +intenser blackness, which I mention'd in the former Observation; and +these continually dilated themselves until the Bubble broke. + +If the Water was not very tenacious, the black Spots would break forth +in the white, without any sensible intervention of the blue. And +sometimes they would break forth within the precedent yellow, or red, or +perhaps within the blue of the second order, before the intermediate +Colours had time to display themselves. + +By this description you may perceive how great an affinity these Colours +have with those of Air described in the fourth Observation, although set +down in a contrary order, by reason that they begin to appear when the +Bubble is thickest, and are most conveniently reckon'd from the lowest +and thickest part of the Bubble upwards. + +_Obs._ 19. Viewing in several oblique Positions of my Eye the Rings of +Colours emerging on the top of the Bubble, I found that they were +sensibly dilated by increasing the obliquity, but yet not so much by far +as those made by thinn'd Air in the seventh Observation. For there they +were dilated so much as, when view'd most obliquely, to arrive at a part +of the Plate more than twelve times thicker than that where they +appear'd when viewed perpendicularly; whereas in this case the thickness +of the Water, at which they arrived when viewed most obliquely, was to +that thickness which exhibited them by perpendicular Rays, something +less than as 8 to 5. By the best of my Observations it was between 15 +and 15-1/2 to 10; an increase about 24 times less than in the other +case. + +Sometimes the Bubble would become of an uniform thickness all over, +except at the top of it near the black Spot, as I knew, because it would +exhibit the same appearance of Colours in all Positions of the Eye. And +then the Colours which were seen at its apparent circumference by the +obliquest Rays, would be different from those that were seen in other +places, by Rays less oblique to it. And divers Spectators might see the +same part of it of differing Colours, by viewing it at very differing +Obliquities. Now observing how much the Colours at the same places of +the Bubble, or at divers places of equal thickness, were varied by the +several Obliquities of the Rays; by the assistance of the 4th, 14th, +16th and 18th Observations, as they are hereafter explain'd, I collect +the thickness of the Water requisite to exhibit any one and the same +Colour, at several Obliquities, to be very nearly in the Proportion +expressed in this Table. + +-----------------+------------------+---------------- + Incidence on | Refraction into | Thickness of + the Water. | the Water. | the Water. +-----------------+------------------+---------------- + Deg. Min. | Deg. Min. | + | | + 00 00 | 00 00 | 10 + | | + 15 00 | 11 11 | 10-1/4 + | | + 30 00 | 22 1 | 10-4/5 + | | + 45 00 | 32 2 | 11-4/5 + | | + 60 00 | 40 30 | 13 + | | + 75 00 | 46 25 | 14-1/2 + | | + 90 00 | 48 35 | 15-1/5 +-----------------+------------------+---------------- + +In the two first Columns are express'd the Obliquities of the Rays to +the Superficies of the Water, that is, their Angles of Incidence and +Refraction. Where I suppose, that the Sines which measure them are in +round Numbers, as 3 to 4, though probably the Dissolution of Soap in the +Water, may a little alter its refractive Virtue. In the third Column, +the Thickness of the Bubble, at which any one Colour is exhibited in +those several Obliquities, is express'd in Parts, of which ten +constitute its Thickness when the Rays are perpendicular. And the Rule +found by the seventh Observation agrees well with these Measures, if +duly apply'd; namely, that the Thickness of a Plate of Water requisite +to exhibit one and the same Colour at several Obliquities of the Eye, is +proportional to the Secant of an Angle, whose Sine is the first of an +hundred and six arithmetical mean Proportionals between the Sines of +Incidence and Refraction counted from the lesser Sine, that is, from the +Sine of Refraction when the Refraction is made out of Air into Water, +otherwise from the Sine of Incidence. + +I have sometimes observ'd, that the Colours which arise on polish'd +Steel by heating it, or on Bell-metal, and some other metalline +Substances, when melted and pour'd on the Ground, where they may cool in +the open Air, have, like the Colours of Water-bubbles, been a little +changed by viewing them at divers Obliquities, and particularly that a +deep blue, or violet, when view'd very obliquely, hath been changed to a +deep red. But the Changes of these Colours are not so great and +sensible as of those made by Water. For the Scoria, or vitrified Part of +the Metal, which most Metals when heated or melted do continually +protrude, and send out to their Surface, and which by covering the +Metals in form of a thin glassy Skin, causes these Colours, is much +denser than Water; and I find that the Change made by the Obliquation of +the Eye is least in Colours of the densest thin Substances. + +_Obs._ 20. As in the ninth Observation, so here, the Bubble, by +transmitted Light, appear'd of a contrary Colour to that, which it +exhibited by Reflexion. Thus when the Bubble being look'd on by the +Light of the Clouds reflected from it, seemed red at its apparent +Circumference, if the Clouds at the same time, or immediately after, +were view'd through it, the Colour at its Circumference would be blue. +And, on the contrary, when by reflected Light it appeared blue, it would +appear red by transmitted Light. + +_Obs._ 21. By wetting very thin Plates of _Muscovy_ Glass, whose +thinness made the like Colours appear, the Colours became more faint and +languid, especially by wetting the Plates on that side opposite to the +Eye: But I could not perceive any variation of their Species. So then +the thickness of a Plate requisite to produce any Colour, depends only +on the density of the Plate, and not on that of the ambient Medium. And +hence, by the 10th and 16th Observations, may be known the thickness +which Bubbles of Water, or Plates of _Muscovy_ Glass, or other +Substances, have at any Colour produced by them. + +_Obs._ 22. A thin transparent Body, which is denser than its ambient +Medium, exhibits more brisk and vivid Colours than that which is so much +rarer; as I have particularly observed in the Air and Glass. For blowing +Glass very thin at a Lamp Furnace, those Plates encompassed with Air did +exhibit Colours much more vivid than those of Air made thin between two +Glasses. + +_Obs._ 23. Comparing the quantity of Light reflected from the several +Rings, I found that it was most copious from the first or inmost, and in +the exterior Rings became gradually less and less. Also the whiteness of +the first Ring was stronger than that reflected from those parts of the +thin Medium or Plate which were without the Rings; as I could manifestly +perceive by viewing at a distance the Rings made by the two +Object-glasses; or by comparing two Bubbles of Water blown at distant +Times, in the first of which the Whiteness appear'd, which succeeded all +the Colours, and in the other, the Whiteness which preceded them all. + +_Obs._ 24. When the two Object-glasses were lay'd upon one another, so +as to make the Rings of the Colours appear, though with my naked Eye I +could not discern above eight or nine of those Rings, yet by viewing +them through a Prism I have seen a far greater Multitude, insomuch that +I could number more than forty, besides many others, that were so very +small and close together, that I could not keep my Eye steady on them +severally so as to number them, but by their Extent I have sometimes +estimated them to be more than an hundred. And I believe the Experiment +may be improved to the Discovery of far greater Numbers. For they seem +to be really unlimited, though visible only so far as they can be +separated by the Refraction of the Prism, as I shall hereafter explain. + +[Illustration: FIG. 5.] + +But it was but one side of these Rings, namely, that towards which the +Refraction was made, which by that Refraction was render'd distinct, and +the other side became more confused than when view'd by the naked Eye, +insomuch that there I could not discern above one or two, and sometimes +none of those Rings, of which I could discern eight or nine with my +naked Eye. And their Segments or Arcs, which on the other side appear'd +so numerous, for the most part exceeded not the third Part of a Circle. +If the Refraction was very great, or the Prism very distant from the +Object-glasses, the middle Part of those Arcs became also confused, so +as to disappear and constitute an even Whiteness, whilst on either side +their Ends, as also the whole Arcs farthest from the Center, became +distincter than before, appearing in the Form as you see them design'd +in the fifth Figure. + +The Arcs, where they seem'd distinctest, were only white and black +successively, without any other Colours intermix'd. But in other Places +there appeared Colours, whose Order was inverted by the refraction in +such manner, that if I first held the Prism very near the +Object-glasses, and then gradually removed it farther off towards my +Eye, the Colours of the 2d, 3d, 4th, and following Rings, shrunk towards +the white that emerged between them, until they wholly vanish'd into it +at the middle of the Arcs, and afterwards emerged again in a contrary +Order. But at the Ends of the Arcs they retain'd their Order unchanged. + +I have sometimes so lay'd one Object-glass upon the other, that to the +naked Eye they have all over seem'd uniformly white, without the least +Appearance of any of the colour'd Rings; and yet by viewing them through +a Prism, great Multitudes of those Rings have discover'd themselves. And +in like manner Plates of _Muscovy_ Glass, and Bubbles of Glass blown at +a Lamp-Furnace, which were not so thin as to exhibit any Colours to the +naked Eye, have through the Prism exhibited a great Variety of them +ranged irregularly up and down in the Form of Waves. And so Bubbles of +Water, before they began to exhibit their Colours to the naked Eye of a +Bystander, have appeared through a Prism, girded about with many +parallel and horizontal Rings; to produce which Effect, it was necessary +to hold the Prism parallel, or very nearly parallel to the Horizon, and +to dispose it so that the Rays might be refracted upwards. + + + + +THE + +SECOND BOOK + +OF + +OPTICKS + + +_PART II._ + +_Remarks upon the foregoing Observations._ + + +Having given my Observations of these Colours, before I make use of them +to unfold the Causes of the Colours of natural Bodies, it is convenient +that by the simplest of them, such as are the 2d, 3d, 4th, 9th, 12th, +18th, 20th, and 24th, I first explain the more compounded. And first to +shew how the Colours in the fourth and eighteenth Observations are +produced, let there be taken in any Right Line from the Point Y, [in +_Fig._ 6.] the Lengths YA, YB, YC, YD, YE, YF, YG, YH, in proportion to +one another, as the Cube-Roots of the Squares of the Numbers, 1/2, 9/16, +3/5, 2/3, 3/4, 5/6, 8/9, 1, whereby the Lengths of a Musical Chord to +sound all the Notes in an eighth are represented; that is, in the +Proportion of the Numbers 6300, 6814, 7114, 7631, 8255, 8855, 9243, +10000. And at the Points A, B, C, D, E, F, G, H, let Perpendiculars +A[Greek: a], B[Greek: b], &c. be erected, by whose Intervals the Extent +of the several Colours set underneath against them, is to be +represented. Then divide the Line _A[Greek: a]_ in such Proportion as +the Numbers 1, 2, 3, 5, 6, 7, 9, 10, 11, &c. set at the Points of +Division denote. And through those Divisions from Y draw Lines 1I, 2K, +3L, 5M, 6N, 7O, &c. + +Now, if A2 be supposed to represent the Thickness of any thin +transparent Body, at which the outmost Violet is most copiously +reflected in the first Ring, or Series of Colours, then by the 13th +Observation, HK will represent its Thickness, at which the utmost Red is +most copiously reflected in the same Series. Also by the 5th and 16th +Observations, A6 and HN will denote the Thicknesses at which those +extreme Colours are most copiously reflected in the second Series, and +A10 and HQ the Thicknesses at which they are most copiously reflected in +the third Series, and so on. And the Thickness at which any of the +intermediate Colours are reflected most copiously, will, according to +the 14th Observation, be defined by the distance of the Line AH from the +intermediate parts of the Lines 2K, 6N, 10Q, &c. against which the Names +of those Colours are written below. + +[Illustration: FIG. 6.] + +But farther, to define the Latitude of these Colours in each Ring or +Series, let A1 design the least thickness, and A3 the greatest +thickness, at which the extreme violet in the first Series is reflected, +and let HI, and HL, design the like limits for the extreme red, and let +the intermediate Colours be limited by the intermediate parts of the +Lines 1I, and 3L, against which the Names of those Colours are written, +and so on: But yet with this caution, that the Reflexions be supposed +strongest at the intermediate Spaces, 2K, 6N, 10Q, &c. and from thence +to decrease gradually towards these limits, 1I, 3L, 5M, 7O, &c. on +either side; where you must not conceive them to be precisely limited, +but to decay indefinitely. And whereas I have assign'd the same Latitude +to every Series, I did it, because although the Colours in the first +Series seem to be a little broader than the rest, by reason of a +stronger Reflexion there, yet that inequality is so insensible as +scarcely to be determin'd by Observation. + +Now according to this Description, conceiving that the Rays originally +of several Colours are by turns reflected at the Spaces 1I, L3, 5M, O7, +9PR11, &c. and transmitted at the Spaces AHI1, 3LM5, 7OP9, &c. it is +easy to know what Colour must in the open Air be exhibited at any +thickness of a transparent thin Body. For if a Ruler be applied parallel +to AH, at that distance from it by which the thickness of the Body is +represented, the alternate Spaces 1IL3, 5MO7, &c. which it crosseth will +denote the reflected original Colours, of which the Colour exhibited in +the open Air is compounded. Thus if the constitution of the green in the +third Series of Colours be desired, apply the Ruler as you see at +[Greek: prsph], and by its passing through some of the blue at [Greek: +p] and yellow at [Greek: s], as well as through the green at [Greek: r], +you may conclude that the green exhibited at that thickness of the Body +is principally constituted of original green, but not without a mixture +of some blue and yellow. + +By this means you may know how the Colours from the center of the Rings +outward ought to succeed in order as they were described in the 4th and +18th Observations. For if you move the Ruler gradually from AH through +all distances, having pass'd over the first Space which denotes little +or no Reflexion to be made by thinnest Substances, it will first arrive +at 1 the violet, and then very quickly at the blue and green, which +together with that violet compound blue, and then at the yellow and red, +by whose farther addition that blue is converted into whiteness, which +whiteness continues during the transit of the edge of the Ruler from I +to 3, and after that by the successive deficience of its component +Colours, turns first to compound yellow, and then to red, and last of +all the red ceaseth at L. Then begin the Colours of the second Series, +which succeed in order during the transit of the edge of the Ruler from +5 to O, and are more lively than before, because more expanded and +severed. And for the same reason instead of the former white there +intercedes between the blue and yellow a mixture of orange, yellow, +green, blue and indigo, all which together ought to exhibit a dilute and +imperfect green. So the Colours of the third Series all succeed in +order; first, the violet, which a little interferes with the red of the +second order, and is thereby inclined to a reddish purple; then the blue +and green, which are less mix'd with other Colours, and consequently +more lively than before, especially the green: Then follows the yellow, +some of which towards the green is distinct and good, but that part of +it towards the succeeding red, as also that red is mix'd with the violet +and blue of the fourth Series, whereby various degrees of red very much +inclining to purple are compounded. This violet and blue, which should +succeed this red, being mixed with, and hidden in it, there succeeds a +green. And this at first is much inclined to blue, but soon becomes a +good green, the only unmix'd and lively Colour in this fourth Series. +For as it verges towards the yellow, it begins to interfere with the +Colours of the fifth Series, by whose mixture the succeeding yellow and +red are very much diluted and made dirty, especially the yellow, which +being the weaker Colour is scarce able to shew it self. After this the +several Series interfere more and more, and their Colours become more +and more intermix'd, till after three or four more revolutions (in which +the red and blue predominate by turns) all sorts of Colours are in all +places pretty equally blended, and compound an even whiteness. + +And since by the 15th Observation the Rays endued with one Colour are +transmitted, where those of another Colour are reflected, the reason of +the Colours made by the transmitted Light in the 9th and 20th +Observations is from hence evident. + +If not only the Order and Species of these Colours, but also the precise +thickness of the Plate, or thin Body at which they are exhibited, be +desired in parts of an Inch, that may be also obtained by assistance of +the 6th or 16th Observations. For according to those Observations the +thickness of the thinned Air, which between two Glasses exhibited the +most luminous parts of the first six Rings were 1/178000, 3/178000, +5/178000, 7/178000, 9/178000, 11/178000 parts of an Inch. Suppose the +Light reflected most copiously at these thicknesses be the bright +citrine yellow, or confine of yellow and orange, and these thicknesses +will be F[Greek: l], F[Greek: m], F[Greek: u], F[Greek: x], F[Greek: o], +F[Greek: t]. And this being known, it is easy to determine what +thickness of Air is represented by G[Greek: ph], or by any other +distance of the Ruler from AH. + +But farther, since by the 10th Observation the thickness of Air was to +the thickness of Water, which between the same Glasses exhibited the +same Colour, as 4 to 3, and by the 21st Observation the Colours of thin +Bodies are not varied by varying the ambient Medium; the thickness of a +Bubble of Water, exhibiting any Colour, will be 3/4 of the thickness of +Air producing the same Colour. And so according to the same 10th and +21st Observations, the thickness of a Plate of Glass, whose Refraction +of the mean refrangible Ray, is measured by the proportion of the Sines +31 to 20, may be 20/31 of the thickness of Air producing the same +Colours; and the like of other Mediums. I do not affirm, that this +proportion of 20 to 31, holds in all the Rays; for the Sines of other +sorts of Rays have other Proportions. But the differences of those +Proportions are so little that I do not here consider them. On these +Grounds I have composed the following Table, wherein the thickness of +Air, Water, and Glass, at which each Colour is most intense and +specifick, is expressed in parts of an Inch divided into ten hundred +thousand equal parts. + +Now if this Table be compared with the 6th Scheme, you will there see +the constitution of each Colour, as to its Ingredients, or the original +Colours of which it is compounded, and thence be enabled to judge of its +Intenseness or Imperfection; which may suffice in explication of the 4th +and 18th Observations, unless it be farther desired to delineate the +manner how the Colours appear, when the two Object-glasses are laid upon +one another. To do which, let there be described a large Arc of a +Circle, and a streight Line which may touch that Arc, and parallel to +that Tangent several occult Lines, at such distances from it, as the +Numbers set against the several Colours in the Table denote. For the +Arc, and its Tangent, will represent the Superficies of the Glasses +terminating the interjacent Air; and the places where the occult Lines +cut the Arc will show at what distances from the center, or Point of +contact, each Colour is reflected. + +_The thickness of colour'd Plates and Particles of_ + _____________|_______________ + / \ + Air. Water. Glass. + |---------+----------+----------+ + {Very black | 1/2 | 3/8 | 10/31 | + {Black | 1 | 3/4 | 20/31 | + {Beginning of | | | | + { Black | 2 | 1-1/2 | 1-2/7 | +Their Colours of the {Blue | 2-2/5 | 1-4/5 | 1-11/22 | +first Order, {White | 5-1/4 | 3-7/8 | 3-2/5 | + {Yellow | 7-1/9 | 5-1/3 | 4-3/5 | + {Orange | 8 | 6 | 5-1/6 | + {Red | 9 | 6-3/4 | 5-4/5 | + |---------+----------+----------| + {Violet | 11-1/6 | 8-3/8 | 7-1/5 | + {Indigo | 12-5/6 | 9-5/8 | 8-2/11 | + {Blue | 14 | 10-1/2 | 9 | + {Green | 15-1/8 | 11-2/3 | 9-5/7 | +Of the second order, {Yellow | 16-2/7 | 12-1/5 | 10-2/5 | + {Orange | 17-2/9 | 13 | 11-1/9 | + {Bright red | 18-1/3 | 13-3/4 | 11-5/6 | + {Scarlet | 19-2/3 | 14-3/4 | 12-2/3 | + |---------+----------+----------| + {Purple | 21 | 15-3/4 | 13-11/20 | + {Indigo | 22-1/10 | 16-4/7 | 14-1/4 | + {Blue | 23-2/5 | 17-11/20 | 15-1/10 | +Of the third Order, {Green | 25-1/5 | 18-9/10 | 16-1/4 | + {Yellow | 27-1/7 | 20-1/3 | 17-1/2 | + {Red | 29 | 21-3/4 | 18-5/7 | + {Bluish red | 32 | 24 | 20-2/3 | + |---------+----------+----------| + {Bluish green | 34 | 25-1/2 | 22 | + {Green | 35-2/7 | 26-1/2 | 22-3/4 | +Of the fourth Order, {Yellowish green | 36 | 27 | 23-2/9 | + {Red | 40-1/3 | 30-1/4 | 26 | + |---------+----------+----------| + {Greenish blue | 46 | 34-1/2 | 29-2/3 | +Of the fifth Order, {Red | 52-1/2 | 39-3/8 | 34 | + |---------+----------+----------| + {Greenish blue | 58-3/4 | 44 | 38 | +Of the sixth Order, {Red | 65 | 48-3/4 | 42 | + |---------+----------+----------| +Of the seventh Order, {Greenish blue | 71 | 53-1/4 | 45-4/5 | + {Ruddy White | 77 | 57-3/4 | 49-2/3 | + |---------+----------+----------| + +There are also other Uses of this Table: For by its assistance the +thickness of the Bubble in the 19th Observation was determin'd by the +Colours which it exhibited. And so the bigness of the parts of natural +Bodies may be conjectured by their Colours, as shall be hereafter shewn. +Also, if two or more very thin Plates be laid one upon another, so as to +compose one Plate equalling them all in thickness, the resulting Colour +may be hereby determin'd. For instance, Mr. _Hook_ observed, as is +mentioned in his _Micrographia_, that a faint yellow Plate of _Muscovy_ +Glass laid upon a blue one, constituted a very deep purple. The yellow +of the first Order is a faint one, and the thickness of the Plate +exhibiting it, according to the Table is 4-3/5, to which add 9, the +thickness exhibiting blue of the second Order, and the Sum will be +13-3/5, which is the thickness exhibiting the purple of the third Order. + +To explain, in the next place, the circumstances of the 2d and 3d +Observations; that is, how the Rings of the Colours may (by turning the +Prisms about their common Axis the contrary way to that expressed in +those Observations) be converted into white and black Rings, and +afterwards into Rings of Colours again, the Colours of each Ring lying +now in an inverted order; it must be remember'd, that those Rings of +Colours are dilated by the obliquation of the Rays to the Air which +intercedes the Glasses, and that according to the Table in the 7th +Observation, their Dilatation or Increase of their Diameter is most +manifest and speedy when they are obliquest. Now the Rays of yellow +being more refracted by the first Superficies of the said Air than those +of red, are thereby made more oblique to the second Superficies, at +which they are reflected to produce the colour'd Rings, and consequently +the yellow Circle in each Ring will be more dilated than the red; and +the Excess of its Dilatation will be so much the greater, by how much +the greater is the obliquity of the Rays, until at last it become of +equal extent with the red of the same Ring. And for the same reason the +green, blue and violet, will be also so much dilated by the still +greater obliquity of their Rays, as to become all very nearly of equal +extent with the red, that is, equally distant from the center of the +Rings. And then all the Colours of the same Ring must be co-incident, +and by their mixture exhibit a white Ring. And these white Rings must +have black and dark Rings between them, because they do not spread and +interfere with one another, as before. And for that reason also they +must become distincter, and visible to far greater numbers. But yet the +violet being obliquest will be something more dilated, in proportion to +its extent, than the other Colours, and so very apt to appear at the +exterior Verges of the white. + +Afterwards, by a greater obliquity of the Rays, the violet and blue +become more sensibly dilated than the red and yellow, and so being +farther removed from the center of the Rings, the Colours must emerge +out of the white in an order contrary to that which they had before; the +violet and blue at the exterior Limbs of each Ring, and the red and +yellow at the interior. And the violet, by reason of the greatest +obliquity of its Rays, being in proportion most of all expanded, will +soonest appear at the exterior Limb of each white Ring, and become more +conspicuous than the rest. And the several Series of Colours belonging +to the several Rings, will, by their unfolding and spreading, begin +again to interfere, and thereby render the Rings less distinct, and not +visible to so great numbers. + +If instead of the Prisms the Object-glasses be made use of, the Rings +which they exhibit become not white and distinct by the obliquity of the +Eye, by reason that the Rays in their passage through that Air which +intercedes the Glasses are very nearly parallel to those Lines in which +they were first incident on the Glasses, and consequently the Rays +endued with several Colours are not inclined one more than another to +that Air, as it happens in the Prisms. + +There is yet another circumstance of these Experiments to be consider'd, +and that is why the black and white Rings which when view'd at a +distance appear distinct, should not only become confused by viewing +them near at hand, but also yield a violet Colour at both the edges of +every white Ring. And the reason is, that the Rays which enter the Eye +at several parts of the Pupil, have several Obliquities to the Glasses, +and those which are most oblique, if consider'd apart, would represent +the Rings bigger than those which are the least oblique. Whence the +breadth of the Perimeter of every white Ring is expanded outwards by the +obliquest Rays, and inwards by the least oblique. And this Expansion is +so much the greater by how much the greater is the difference of the +Obliquity; that is, by how much the Pupil is wider, or the Eye nearer to +the Glasses. And the breadth of the violet must be most expanded, +because the Rays apt to excite a Sensation of that Colour are most +oblique to a second or farther Superficies of the thinn'd Air at which +they are reflected, and have also the greatest variation of Obliquity, +which makes that Colour soonest emerge out of the edges of the white. +And as the breadth of every Ring is thus augmented, the dark Intervals +must be diminish'd, until the neighbouring Rings become continuous, and +are blended, the exterior first, and then those nearer the center; so +that they can no longer be distinguish'd apart, but seem to constitute +an even and uniform whiteness. + +Among all the Observations there is none accompanied with so odd +circumstances as the twenty-fourth. Of those the principal are, that in +thin Plates, which to the naked Eye seem of an even and uniform +transparent whiteness, without any terminations of Shadows, the +Refraction of a Prism should make Rings of Colours appear, whereas it +usually makes Objects appear colour'd only there where they are +terminated with Shadows, or have parts unequally luminous; and that it +should make those Rings exceedingly distinct and white, although it +usually renders Objects confused and coloured. The Cause of these things +you will understand by considering, that all the Rings of Colours are +really in the Plate, when view'd with the naked Eye, although by reason +of the great breadth of their Circumferences they so much interfere and +are blended together, that they seem to constitute an uniform whiteness. +But when the Rays pass through the Prism to the Eye, the Orbits of the +several Colours in every Ring are refracted, some more than others, +according to their degrees of Refrangibility: By which means the Colours +on one side of the Ring (that is in the circumference on one side of its +center), become more unfolded and dilated, and those on the other side +more complicated and contracted. And where by a due Refraction they are +so much contracted, that the several Rings become narrower than to +interfere with one another, they must appear distinct, and also white, +if the constituent Colours be so much contracted as to be wholly +co-incident. But on the other side, where the Orbit of every Ring is +made broader by the farther unfolding of its Colours, it must interfere +more with other Rings than before, and so become less distinct. + +[Illustration: FIG. 7.] + +To explain this a little farther, suppose the concentrick Circles AV, +and BX, [in _Fig._ 7.] represent the red and violet of any Order, which, +together with the intermediate Colours, constitute any one of these +Rings. Now these being view'd through a Prism, the violet Circle BX, +will, by a greater Refraction, be farther translated from its place than +the red AV, and so approach nearer to it on that side of the Circles, +towards which the Refractions are made. For instance, if the red be +translated to _av_, the violet may be translated to _bx_, so as to +approach nearer to it at _x_ than before; and if the red be farther +translated to av, the violet may be so much farther translated to bx as +to convene with it at x; and if the red be yet farther translated to +[Greek: aY], the violet may be still so much farther translated to +[Greek: bx] as to pass beyond it at [Greek: x], and convene with it at +_e_ and _f_. And this being understood not only of the red and violet, +but of all the other intermediate Colours, and also of every revolution +of those Colours, you will easily perceive how those of the same +revolution or order, by their nearness at _xv_ and [Greek: Yx], and +their coincidence at xv, _e_ and _f_, ought to constitute pretty +distinct Arcs of Circles, especially at xv, or at _e_ and _f_; and that +they will appear severally at _x_[Greek: u] and at xv exhibit whiteness +by their coincidence, and again appear severally at [Greek: Yx], but yet +in a contrary order to that which they had before, and still retain +beyond _e_ and _f_. But on the other side, at _ab_, ab, or [Greek: ab], +these Colours must become much more confused by being dilated and spread +so as to interfere with those of other Orders. And the same confusion +will happen at [Greek: Ux] between _e_ and _f_, if the Refraction be +very great, or the Prism very distant from the Object-glasses: In which +case no parts of the Rings will be seen, save only two little Arcs at +_e_ and _f_, whose distance from one another will be augmented by +removing the Prism still farther from the Object-glasses: And these +little Arcs must be distinctest and whitest at their middle, and at +their ends, where they begin to grow confused, they must be colour'd. +And the Colours at one end of every Arc must be in a contrary order to +those at the other end, by reason that they cross in the intermediate +white; namely, their ends, which verge towards [Greek: Ux], will be red +and yellow on that side next the center, and blue and violet on the +other side. But their other ends which verge from [Greek: Ux], will on +the contrary be blue and violet on that side towards the center, and on +the other side red and yellow. + +Now as all these things follow from the properties of Light by a +mathematical way of reasoning, so the truth of them may be manifested by +Experiments. For in a dark Room, by viewing these Rings through a Prism, +by reflexion of the several prismatick Colours, which an assistant +causes to move to and fro upon a Wall or Paper from whence they are +reflected, whilst the Spectator's Eye, the Prism, and the +Object-glasses, (as in the 13th Observation,) are placed steady; the +Position of the Circles made successively by the several Colours, will +be found such, in respect of one another, as I have described in the +Figures _abxv_, or abxv, or _[Greek: abxU]_. And by the same method the +truth of the Explications of other Observations may be examined. + +By what hath been said, the like Phænomena of Water and thin Plates of +Glass may be understood. But in small fragments of those Plates there is +this farther observable, that where they lie flat upon a Table, and are +turned about their centers whilst they are view'd through a Prism, they +will in some postures exhibit Waves of various Colours; and some of them +exhibit these Waves in one or two Positions only, but the most of them +do in all Positions exhibit them, and make them for the most part appear +almost all over the Plates. The reason is, that the Superficies of such +Plates are not even, but have many Cavities and Swellings, which, how +shallow soever, do a little vary the thickness of the Plate. For at the +several sides of those Cavities, for the Reasons newly described, there +ought to be produced Waves in several postures of the Prism. Now though +it be but some very small and narrower parts of the Glass, by which +these Waves for the most part are caused, yet they may seem to extend +themselves over the whole Glass, because from the narrowest of those +parts there are Colours of several Orders, that is, of several Rings, +confusedly reflected, which by Refraction of the Prism are unfolded, +separated, and, according to their degrees of Refraction, dispersed to +several places, so as to constitute so many several Waves, as there were +divers orders of Colours promiscuously reflected from that part of the +Glass. + +These are the principal Phænomena of thin Plates or Bubbles, whose +Explications depend on the properties of Light, which I have heretofore +deliver'd. And these you see do necessarily follow from them, and agree +with them, even to their very least circumstances; and not only so, but +do very much tend to their proof. Thus, by the 24th Observation it +appears, that the Rays of several Colours, made as well by thin Plates +or Bubbles, as by Refractions of a Prism, have several degrees of +Refrangibility; whereby those of each order, which at the reflexion from +the Plate or Bubble are intermix'd with those of other orders, are +separated from them by Refraction, and associated together so as to +become visible by themselves like Arcs of Circles. For if the Rays were +all alike refrangible, 'tis impossible that the whiteness, which to the +naked Sense appears uniform, should by Refraction have its parts +transposed and ranged into those black and white Arcs. + +It appears also that the unequal Refractions of difform Rays proceed not +from any contingent irregularities; such as are Veins, an uneven Polish, +or fortuitous Position of the Pores of Glass; unequal and casual Motions +in the Air or Æther, the spreading, breaking, or dividing the same Ray +into many diverging parts; or the like. For, admitting any such +irregularities, it would be impossible for Refractions to render those +Rings so very distinct, and well defined, as they do in the 24th +Observation. It is necessary therefore that every Ray have its proper +and constant degree of Refrangibility connate with it, according to +which its refraction is ever justly and regularly perform'd; and that +several Rays have several of those degrees. + +And what is said of their Refrangibility may be also understood of their +Reflexibility, that is, of their Dispositions to be reflected, some at a +greater, and others at a less thickness of thin Plates or Bubbles; +namely, that those Dispositions are also connate with the Rays, and +immutable; as may appear by the 13th, 14th, and 15th Observations, +compared with the fourth and eighteenth. + +By the Precedent Observations it appears also, that whiteness is a +dissimilar mixture of all Colours, and that Light is a mixture of Rays +endued with all those Colours. For, considering the multitude of the +Rings of Colours in the 3d, 12th, and 24th Observations, it is manifest, +that although in the 4th and 18th Observations there appear no more than +eight or nine of those Rings, yet there are really a far greater number, +which so much interfere and mingle with one another, as after those +eight or nine revolutions to dilute one another wholly, and constitute +an even and sensibly uniform whiteness. And consequently that whiteness +must be allow'd a mixture of all Colours, and the Light which conveys it +to the Eye must be a mixture of Rays endued with all those Colours. + +But farther; by the 24th Observation it appears, that there is a +constant relation between Colours and Refrangibility; the most +refrangible Rays being violet, the least refrangible red, and those of +intermediate Colours having proportionably intermediate degrees of +Refrangibility. And by the 13th, 14th, and 15th Observations, compared +with the 4th or 18th there appears to be the same constant relation +between Colour and Reflexibility; the violet being in like circumstances +reflected at least thicknesses of any thin Plate or Bubble, the red at +greatest thicknesses, and the intermediate Colours at intermediate +thicknesses. Whence it follows, that the colorifick Dispositions of +Rays are also connate with them, and immutable; and by consequence, that +all the Productions and Appearances of Colours in the World are derived, +not from any physical Change caused in Light by Refraction or Reflexion, +but only from the various Mixtures or Separations of Rays, by virtue of +their different Refrangibility or Reflexibility. And in this respect the +Science of Colours becomes a Speculation as truly mathematical as any +other part of Opticks. I mean, so far as they depend on the Nature of +Light, and are not produced or alter'd by the Power of Imagination, or +by striking or pressing the Eye. + + + + +THE + +SECOND BOOK + +OF + +OPTICKS + + +_PART III._ + +_Of the permanent Colours of natural Bodies, and the Analogy between +them and the Colours of thin transparent Plates._ + +I am now come to another part of this Design, which is to consider how +the Phænomena of thin transparent Plates stand related to those of all +other natural Bodies. Of these Bodies I have already told you that they +appear of divers Colours, accordingly as they are disposed to reflect +most copiously the Rays originally endued with those Colours. But their +Constitutions, whereby they reflect some Rays more copiously than +others, remain to be discover'd; and these I shall endeavour to manifest +in the following Propositions. + + +PROP. I. + +_Those Superficies of transparent Bodies reflect the greatest quantity +of Light, which have the greatest refracting Power; that is, which +intercede Mediums that differ most in their refractive Densities. And in +the Confines of equally refracting Mediums there is no Reflexion._ + +The Analogy between Reflexion and Refraction will appear by considering, +that when Light passeth obliquely out of one Medium into another which +refracts from the perpendicular, the greater is the difference of their +refractive Density, the less Obliquity of Incidence is requisite to +cause a total Reflexion. For as the Sines are which measure the +Refraction, so is the Sine of Incidence at which the total Reflexion +begins, to the Radius of the Circle; and consequently that Angle of +Incidence is least where there is the greatest difference of the Sines. +Thus in the passing of Light out of Water into Air, where the Refraction +is measured by the Ratio of the Sines 3 to 4, the total Reflexion begins +when the Angle of Incidence is about 48 Degrees 35 Minutes. In passing +out of Glass into Air, where the Refraction is measured by the Ratio of +the Sines 20 to 31, the total Reflexion begins when the Angle of +Incidence is 40 Degrees 10 Minutes; and so in passing out of Crystal, or +more strongly refracting Mediums into Air, there is still a less +obliquity requisite to cause a total reflexion. Superficies therefore +which refract most do soonest reflect all the Light which is incident on +them, and so must be allowed most strongly reflexive. + +But the truth of this Proposition will farther appear by observing, that +in the Superficies interceding two transparent Mediums, (such as are +Air, Water, Oil, common Glass, Crystal, metalline Glasses, Island +Glasses, white transparent Arsenick, Diamonds, &c.) the Reflexion is +stronger or weaker accordingly, as the Superficies hath a greater or +less refracting Power. For in the Confine of Air and Sal-gem 'tis +stronger than in the Confine of Air and Water, and still stronger in the +Confine of Air and common Glass or Crystal, and stronger in the Confine +of Air and a Diamond. If any of these, and such like transparent Solids, +be immerged in Water, its Reflexion becomes, much weaker than before; +and still weaker if they be immerged in the more strongly refracting +Liquors of well rectified Oil of Vitriol or Spirit of Turpentine. If +Water be distinguish'd into two parts by any imaginary Surface, the +Reflexion in the Confine of those two parts is none at all. In the +Confine of Water and Ice 'tis very little; in that of Water and Oil 'tis +something greater; in that of Water and Sal-gem still greater; and in +that of Water and Glass, or Crystal or other denser Substances still +greater, accordingly as those Mediums differ more or less in their +refracting Powers. Hence in the Confine of common Glass and Crystal, +there ought to be a weak Reflexion, and a stronger Reflexion in the +Confine of common and metalline Glass; though I have not yet tried +this. But in the Confine of two Glasses of equal density, there is not +any sensible Reflexion; as was shewn in the first Observation. And the +same may be understood of the Superficies interceding two Crystals, or +two Liquors, or any other Substances in which no Refraction is caused. +So then the reason why uniform pellucid Mediums (such as Water, Glass, +or Crystal,) have no sensible Reflexion but in their external +Superficies, where they are adjacent to other Mediums of a different +density, is because all their contiguous parts have one and the same +degree of density. + + +PROP. II. + +_The least parts of almost all natural Bodies are in some measure +transparent: And the Opacity of those Bodies ariseth from the multitude +of Reflexions caused in their internal Parts._ + +That this is so has been observed by others, and will easily be granted +by them that have been conversant with Microscopes. And it may be also +tried by applying any substance to a hole through which some Light is +immitted into a dark Room. For how opake soever that Substance may seem +in the open Air, it will by that means appear very manifestly +transparent, if it be of a sufficient thinness. Only white metalline +Bodies must be excepted, which by reason of their excessive density seem +to reflect almost all the Light incident on their first Superficies; +unless by solution in Menstruums they be reduced into very small +Particles, and then they become transparent. + + +PROP. III. + +_Between the parts of opake and colour'd Bodies are many Spaces, either +empty, or replenish'd with Mediums of other Densities; as Water between +the tinging Corpuscles wherewith any Liquor is impregnated, Air between +the aqueous Globules that constitute Clouds or Mists; and for the most +part Spaces void of both Air and Water, but yet perhaps not wholly void +of all Substance, between the parts of hard Bodies._ + +The truth of this is evinced by the two precedent Propositions: For by +the second Proposition there are many Reflexions made by the internal +parts of Bodies, which, by the first Proposition, would not happen if +the parts of those Bodies were continued without any such Interstices +between them; because Reflexions are caused only in Superficies, which +intercede Mediums of a differing density, by _Prop._ 1. + +But farther, that this discontinuity of parts is the principal Cause of +the opacity of Bodies, will appear by considering, that opake Substances +become transparent by filling their Pores with any Substance of equal or +almost equal density with their parts. Thus Paper dipped in Water or +Oil, the _Oculus Mundi_ Stone steep'd in Water, Linnen Cloth oiled or +varnish'd, and many other Substances soaked in such Liquors as will +intimately pervade their little Pores, become by that means more +transparent than otherwise; so, on the contrary, the most transparent +Substances, may, by evacuating their Pores, or separating their parts, +be render'd sufficiently opake; as Salts or wet Paper, or the _Oculus +Mundi_ Stone by being dried, Horn by being scraped, Glass by being +reduced to Powder, or otherwise flawed; Turpentine by being stirred +about with Water till they mix imperfectly, and Water by being form'd +into many small Bubbles, either alone in the form of Froth, or by +shaking it together with Oil of Turpentine, or Oil Olive, or with some +other convenient Liquor, with which it will not perfectly incorporate. +And to the increase of the opacity of these Bodies, it conduces +something, that by the 23d Observation the Reflexions of very thin +transparent Substances are considerably stronger than those made by the +same Substances of a greater thickness. + + +PROP. IV. + +_The Parts of Bodies and their Interstices must not be less than of some +definite bigness, to render them opake and colour'd._ + +For the opakest Bodies, if their parts be subtilly divided, (as Metals, +by being dissolved in acid Menstruums, &c.) become perfectly +transparent. And you may also remember, that in the eighth Observation +there was no sensible reflexion at the Superficies of the +Object-glasses, where they were very near one another, though they did +not absolutely touch. And in the 17th Observation the Reflexion of the +Water-bubble where it became thinnest was almost insensible, so as to +cause very black Spots to appear on the top of the Bubble, by the want +of reflected Light. + +On these grounds I perceive it is that Water, Salt, Glass, Stones, and +such like Substances, are transparent. For, upon divers Considerations, +they seem to be as full of Pores or Interstices between their parts as +other Bodies are, but yet their Parts and Interstices to be too small to +cause Reflexions in their common Surfaces. + + +PROP. V. + +_The transparent parts of Bodies, according to their several sizes, +reflect Rays of one Colour, and transmit those of another, on the same +grounds that thin Plates or Bubbles do reflect or transmit those Rays. +And this I take to be the ground of all their Colours._ + +For if a thinn'd or plated Body, which being of an even thickness, +appears all over of one uniform Colour, should be slit into Threads, or +broken into Fragments, of the same thickness with the Plate; I see no +reason why every Thread or Fragment should not keep its Colour, and by +consequence why a heap of those Threads or Fragments should not +constitute a Mass or Powder of the same Colour, which the Plate +exhibited before it was broken. And the parts of all natural Bodies +being like so many Fragments of a Plate, must on the same grounds +exhibit the same Colours. + +Now, that they do so will appear by the affinity of their Properties. +The finely colour'd Feathers of some Birds, and particularly those of +Peacocks Tails, do, in the very same part of the Feather, appear of +several Colours in several Positions of the Eye, after the very same +manner that thin Plates were found to do in the 7th and 19th +Observations, and therefore their Colours arise from the thinness of the +transparent parts of the Feathers; that is, from the slenderness of the +very fine Hairs, or _Capillamenta_, which grow out of the sides of the +grosser lateral Branches or Fibres of those Feathers. And to the same +purpose it is, that the Webs of some Spiders, by being spun very fine, +have appeared colour'd, as some have observ'd, and that the colour'd +Fibres of some Silks, by varying the Position of the Eye, do vary their +Colour. Also the Colours of Silks, Cloths, and other Substances, which +Water or Oil can intimately penetrate, become more faint and obscure by +being immerged in those Liquors, and recover their Vigor again by being +dried; much after the manner declared of thin Bodies in the 10th and +21st Observations. Leaf-Gold, some sorts of painted Glass, the Infusion +of _Lignum Nephriticum_, and some other Substances, reflect one Colour, +and transmit another; like thin Bodies in the 9th and 20th Observations. +And some of those colour'd Powders which Painters use, may have their +Colours a little changed, by being very elaborately and finely ground. +Where I see not what can be justly pretended for those changes, besides +the breaking of their parts into less parts by that contrition, after +the same manner that the Colour of a thin Plate is changed by varying +its thickness. For which reason also it is that the colour'd Flowers of +Plants and Vegetables, by being bruised, usually become more transparent +than before, or at least in some degree or other change their Colours. +Nor is it much less to my purpose, that, by mixing divers Liquors, very +odd and remarkable Productions and Changes of Colours may be effected, +of which no cause can be more obvious and rational than that the saline +Corpuscles of one Liquor do variously act upon or unite with the tinging +Corpuscles of another, so as to make them swell, or shrink, (whereby not +only their bulk but their density also may be changed,) or to divide +them into smaller Corpuscles, (whereby a colour'd Liquor may become +transparent,) or to make many of them associate into one cluster, +whereby two transparent Liquors may compose a colour'd one. For we see +how apt those saline Menstruums are to penetrate and dissolve Substances +to which they are applied, and some of them to precipitate what others +dissolve. In like manner, if we consider the various Phænomena of the +Atmosphere, we may observe, that when Vapours are first raised, they +hinder not the transparency of the Air, being divided into parts too +small to cause any Reflexion in their Superficies. But when in order to +compose drops of Rain they begin to coalesce and constitute Globules of +all intermediate sizes, those Globules, when they become of convenient +size to reflect some Colours and transmit others, may constitute Clouds +of various Colours according to their sizes. And I see not what can be +rationally conceived in so transparent a Substance as Water for the +production of these Colours, besides the various sizes of its fluid and +globular Parcels. + + +PROP. VI. + +_The parts of Bodies on which their Colours depend, are denser than the +Medium which pervades their Interstices._ + +This will appear by considering, that the Colour of a Body depends not +only on the Rays which are incident perpendicularly on its parts, but on +those also which are incident at all other Angles. And that according to +the 7th Observation, a very little variation of obliquity will change +the reflected Colour, where the thin Body or small Particles is rarer +than the ambient Medium, insomuch that such a small Particle will at +diversly oblique Incidences reflect all sorts of Colours, in so great a +variety that the Colour resulting from them all, confusedly reflected +from a heap of such Particles, must rather be a white or grey than any +other Colour, or at best it must be but a very imperfect and dirty +Colour. Whereas if the thin Body or small Particle be much denser than +the ambient Medium, the Colours, according to the 19th Observation, are +so little changed by the variation of obliquity, that the Rays which +are reflected least obliquely may predominate over the rest, so much as +to cause a heap of such Particles to appear very intensely of their +Colour. + +It conduces also something to the confirmation of this Proposition, +that, according to the 22d Observation, the Colours exhibited by the +denser thin Body within the rarer, are more brisk than those exhibited +by the rarer within the denser. + + +PROP. VII. + +_The bigness of the component parts of natural Bodies may be conjectured +by their Colours._ + +For since the parts of these Bodies, by _Prop._ 5. do most probably +exhibit the same Colours with a Plate of equal thickness, provided they +have the same refractive density; and since their parts seem for the +most part to have much the same density with Water or Glass, as by many +circumstances is obvious to collect; to determine the sizes of those +parts, you need only have recourse to the precedent Tables, in which the +thickness of Water or Glass exhibiting any Colour is expressed. Thus if +it be desired to know the diameter of a Corpuscle, which being of equal +density with Glass shall reflect green of the third Order; the Number +16-1/4 shews it to be (16-1/4)/10000 parts of an Inch. + +The greatest difficulty is here to know of what Order the Colour of any +Body is. And for this end we must have recourse to the 4th and 18th +Observations; from whence may be collected these particulars. + +_Scarlets_, and other _reds_, _oranges_, and _yellows_, if they be pure +and intense, are most probably of the second order. Those of the first +and third order also may be pretty good; only the yellow of the first +order is faint, and the orange and red of the third Order have a great +Mixture of violet and blue. + +There may be good _Greens_ of the fourth Order, but the purest are of +the third. And of this Order the green of all Vegetables seems to be, +partly by reason of the Intenseness of their Colours, and partly because +when they wither some of them turn to a greenish yellow, and others to a +more perfect yellow or orange, or perhaps to red, passing first through +all the aforesaid intermediate Colours. Which Changes seem to be +effected by the exhaling of the Moisture which may leave the tinging +Corpuscles more dense, and something augmented by the Accretion of the +oily and earthy Part of that Moisture. Now the green, without doubt, is +of the same Order with those Colours into which it changeth, because the +Changes are gradual, and those Colours, though usually not very full, +yet are often too full and lively to be of the fourth Order. + +_Blues_ and _Purples_ may be either of the second or third Order, but +the best are of the third. Thus the Colour of Violets seems to be of +that Order, because their Syrup by acid Liquors turns red, and by +urinous and alcalizate turns green. For since it is of the Nature of +Acids to dissolve or attenuate, and of Alcalies to precipitate or +incrassate, if the Purple Colour of the Syrup was of the second Order, +an acid Liquor by attenuating its tinging Corpuscles would change it to +a red of the first Order, and an Alcali by incrassating them would +change it to a green of the second Order; which red and green, +especially the green, seem too imperfect to be the Colours produced by +these Changes. But if the said Purple be supposed of the third Order, +its Change to red of the second, and green of the third, may without any +Inconvenience be allow'd. + +If there be found any Body of a deeper and less reddish Purple than that +of the Violets, its Colour most probably is of the second Order. But yet +there being no Body commonly known whose Colour is constantly more deep +than theirs, I have made use of their Name to denote the deepest and +least reddish Purples, such as manifestly transcend their Colour in +purity. + +The _blue_ of the first Order, though very faint and little, may +possibly be the Colour of some Substances; and particularly the azure +Colour of the Skies seems to be of this Order. For all Vapours when they +begin to condense and coalesce into small Parcels, become first of that +Bigness, whereby such an Azure must be reflected before they can +constitute Clouds of other Colours. And so this being the first Colour +which Vapours begin to reflect, it ought to be the Colour of the finest +and most transparent Skies, in which Vapours are not arrived to that +Grossness requisite to reflect other Colours, as we find it is by +Experience. + +_Whiteness_, if most intense and luminous, is that of the first Order, +if less strong and luminous, a Mixture of the Colours of several Orders. +Of this last kind is the Whiteness of Froth, Paper, Linnen, and most +white Substances; of the former I reckon that of white Metals to be. For +whilst the densest of Metals, Gold, if foliated, is transparent, and all +Metals become transparent if dissolved in Menstruums or vitrified, the +Opacity of white Metals ariseth not from their Density alone. They being +less dense than Gold would be more transparent than it, did not some +other Cause concur with their Density to make them opake. And this Cause +I take to be such a Bigness of their Particles as fits them to reflect +the white of the first order. For, if they be of other Thicknesses they +may reflect other Colours, as is manifest by the Colours which appear +upon hot Steel in tempering it, and sometimes upon the Surface of melted +Metals in the Skin or Scoria which arises upon them in their cooling. +And as the white of the first order is the strongest which can be made +by Plates of transparent Substances, so it ought to be stronger in the +denser Substances of Metals than in the rarer of Air, Water, and Glass. +Nor do I see but that metallick Substances of such a Thickness as may +fit them to reflect the white of the first order, may, by reason of +their great Density (according to the Tenor of the first of these +Propositions) reflect all the Light incident upon them, and so be as +opake and splendent as it's possible for any Body to be. Gold, or Copper +mix'd with less than half their Weight of Silver, or Tin, or Regulus of +Antimony, in fusion, or amalgamed with a very little Mercury, become +white; which shews both that the Particles of white Metals have much +more Superficies, and so are smaller, than those of Gold and Copper, and +also that they are so opake as not to suffer the Particles of Gold or +Copper to shine through them. Now it is scarce to be doubted but that +the Colours of Gold and Copper are of the second and third order, and +therefore the Particles of white Metals cannot be much bigger than is +requisite to make them reflect the white of the first order. The +Volatility of Mercury argues that they are not much bigger, nor may they +be much less, lest they lose their Opacity, and become either +transparent as they do when attenuated by Vitrification, or by Solution +in Menstruums, or black as they do when ground smaller, by rubbing +Silver, or Tin, or Lead, upon other Substances to draw black Lines. The +first and only Colour which white Metals take by grinding their +Particles smaller, is black, and therefore their white ought to be that +which borders upon the black Spot in the Center of the Rings of Colours, +that is, the white of the first order. But, if you would hence gather +the Bigness of metallick Particles, you must allow for their Density. +For were Mercury transparent, its Density is such that the Sine of +Incidence upon it (by my Computation) would be to the Sine of its +Refraction, as 71 to 20, or 7 to 2. And therefore the Thickness of its +Particles, that they may exhibit the same Colours with those of Bubbles +of Water, ought to be less than the Thickness of the Skin of those +Bubbles in the Proportion of 2 to 7. Whence it's possible, that the +Particles of Mercury may be as little as the Particles of some +transparent and volatile Fluids, and yet reflect the white of the first +order. + +Lastly, for the production of _black_, the Corpuscles must be less than +any of those which exhibit Colours. For at all greater sizes there is +too much Light reflected to constitute this Colour. But if they be +supposed a little less than is requisite to reflect the white and very +faint blue of the first order, they will, according to the 4th, 8th, +17th and 18th Observations, reflect so very little Light as to appear +intensely black, and yet may perhaps variously refract it to and fro +within themselves so long, until it happen to be stifled and lost, by +which means they will appear black in all positions of the Eye without +any transparency. And from hence may be understood why Fire, and the +more subtile dissolver Putrefaction, by dividing the Particles of +Substances, turn them to black, why small quantities of black Substances +impart their Colour very freely and intensely to other Substances to +which they are applied; the minute Particles of these, by reason of +their very great number, easily overspreading the gross Particles of +others; why Glass ground very elaborately with Sand on a Copper Plate, +'till it be well polish'd, makes the Sand, together with what is worn +off from the Glass and Copper, become very black: why black Substances +do soonest of all others become hot in the Sun's Light and burn, (which +Effect may proceed partly from the multitude of Refractions in a little +room, and partly from the easy Commotion of so very small Corpuscles;) +and why blacks are usually a little inclined to a bluish Colour. For +that they are so may be seen by illuminating white Paper by Light +reflected from black Substances. For the Paper will usually appear of a +bluish white; and the reason is, that black borders in the obscure blue +of the order described in the 18th Observation, and therefore reflects +more Rays of that Colour than of any other. + +In these Descriptions I have been the more particular, because it is not +impossible but that Microscopes may at length be improved to the +discovery of the Particles of Bodies on which their Colours depend, if +they are not already in some measure arrived to that degree of +perfection. For if those Instruments are or can be so far improved as +with sufficient distinctness to represent Objects five or six hundred +times bigger than at a Foot distance they appear to our naked Eyes, I +should hope that we might be able to discover some of the greatest of +those Corpuscles. And by one that would magnify three or four thousand +times perhaps they might all be discover'd, but those which produce +blackness. In the mean while I see nothing material in this Discourse +that may rationally be doubted of, excepting this Position: That +transparent Corpuscles of the same thickness and density with a Plate, +do exhibit the same Colour. And this I would have understood not without +some Latitude, as well because those Corpuscles may be of irregular +Figures, and many Rays must be obliquely incident on them, and so have +a shorter way through them than the length of their Diameters, as +because the straitness of the Medium put in on all sides within such +Corpuscles may a little alter its Motions or other qualities on which +the Reflexion depends. But yet I cannot much suspect the last, because I +have observed of some small Plates of Muscovy Glass which were of an +even thickness, that through a Microscope they have appeared of the same +Colour at their edges and corners where the included Medium was +terminated, which they appeared of in other places. However it will add +much to our Satisfaction, if those Corpuscles can be discover'd with +Microscopes; which if we shall at length attain to, I fear it will be +the utmost improvement of this Sense. For it seems impossible to see the +more secret and noble Works of Nature within the Corpuscles by reason of +their transparency. + + +PROP. VIII. + +_The Cause of Reflexion is not the impinging of Light on the solid or +impervious parts of Bodies, as is commonly believed._ + +This will appear by the following Considerations. First, That in the +passage of Light out of Glass into Air there is a Reflexion as strong as +in its passage out of Air into Glass, or rather a little stronger, and +by many degrees stronger than in its passage out of Glass into Water. +And it seems not probable that Air should have more strongly reflecting +parts than Water or Glass. But if that should possibly be supposed, yet +it will avail nothing; for the Reflexion is as strong or stronger when +the Air is drawn away from the Glass, (suppose by the Air-Pump invented +by _Otto Gueriet_, and improved and made useful by Mr. _Boyle_) as when +it is adjacent to it. Secondly, If Light in its passage out of Glass +into Air be incident more obliquely than at an Angle of 40 or 41 Degrees +it is wholly reflected, if less obliquely it is in great measure +transmitted. Now it is not to be imagined that Light at one degree of +obliquity should meet with Pores enough in the Air to transmit the +greater part of it, and at another degree of obliquity should meet with +nothing but parts to reflect it wholly, especially considering that in +its passage out of Air into Glass, how oblique soever be its Incidence, +it finds Pores enough in the Glass to transmit a great part of it. If +any Man suppose that it is not reflected by the Air, but by the outmost +superficial parts of the Glass, there is still the same difficulty: +Besides, that such a Supposition is unintelligible, and will also appear +to be false by applying Water behind some part of the Glass instead of +Air. For so in a convenient obliquity of the Rays, suppose of 45 or 46 +Degrees, at which they are all reflected where the Air is adjacent to +the Glass, they shall be in great measure transmitted where the Water is +adjacent to it; which argues, that their Reflexion or Transmission +depends on the constitution of the Air and Water behind the Glass, and +not on the striking of the Rays upon the parts of the Glass. Thirdly, +If the Colours made by a Prism placed at the entrance of a Beam of Light +into a darken'd Room be successively cast on a second Prism placed at a +greater distance from the former, in such manner that they are all alike +incident upon it, the second Prism may be so inclined to the incident +Rays, that those which are of a blue Colour shall be all reflected by +it, and yet those of a red Colour pretty copiously transmitted. Now if +the Reflexion be caused by the parts of Air or Glass, I would ask, why +at the same Obliquity of Incidence the blue should wholly impinge on +those parts, so as to be all reflected, and yet the red find Pores +enough to be in a great measure transmitted. Fourthly, Where two Glasses +touch one another, there is no sensible Reflexion, as was declared in +the first Observation; and yet I see no reason why the Rays should not +impinge on the parts of Glass, as much when contiguous to other Glass as +when contiguous to Air. Fifthly, When the top of a Water-Bubble (in the +17th Observation,) by the continual subsiding and exhaling of the Water +grew very thin, there was such a little and almost insensible quantity +of Light reflected from it, that it appeared intensely black; whereas +round about that black Spot, where the Water was thicker, the Reflexion +was so strong as to make the Water seem very white. Nor is it only at +the least thickness of thin Plates or Bubbles, that there is no manifest +Reflexion, but at many other thicknesses continually greater and +greater. For in the 15th Observation the Rays of the same Colour were by +turns transmitted at one thickness, and reflected at another thickness, +for an indeterminate number of Successions. And yet in the Superficies +of the thinned Body, where it is of any one thickness, there are as many +parts for the Rays to impinge on, as where it is of any other thickness. +Sixthly, If Reflexion were caused by the parts of reflecting Bodies, it +would be impossible for thin Plates or Bubbles, at one and the same +place, to reflect the Rays of one Colour, and transmit those of another, +as they do according to the 13th and 15th Observations. For it is not to +be imagined that at one place the Rays which, for instance, exhibit a +blue Colour, should have the fortune to dash upon the parts, and those +which exhibit a red to hit upon the Pores of the Body; and then at +another place, where the Body is either a little thicker or a little +thinner, that on the contrary the blue should hit upon its pores, and +the red upon its parts. Lastly, Were the Rays of Light reflected by +impinging on the solid parts of Bodies, their Reflexions from polish'd +Bodies could not be so regular as they are. For in polishing Glass with +Sand, Putty, or Tripoly, it is not to be imagined that those Substances +can, by grating and fretting the Glass, bring all its least Particles to +an accurate Polish; so that all their Surfaces shall be truly plain or +truly spherical, and look all the same way, so as together to compose +one even Surface. The smaller the Particles of those Substances are, the +smaller will be the Scratches by which they continually fret and wear +away the Glass until it be polish'd; but be they never so small they can +wear away the Glass no otherwise than by grating and scratching it, and +breaking the Protuberances; and therefore polish it no otherwise than by +bringing its roughness to a very fine Grain, so that the Scratches and +Frettings of the Surface become too small to be visible. And therefore +if Light were reflected by impinging upon the solid parts of the Glass, +it would be scatter'd as much by the most polish'd Glass as by the +roughest. So then it remains a Problem, how Glass polish'd by fretting +Substances can reflect Light so regularly as it does. And this Problem +is scarce otherwise to be solved, than by saying, that the Reflexion of +a Ray is effected, not by a single point of the reflecting Body, but by +some power of the Body which is evenly diffused all over its Surface, +and by which it acts upon the Ray without immediate Contact. For that +the parts of Bodies do act upon Light at a distance shall be shewn +hereafter. + +Now if Light be reflected, not by impinging on the solid parts of +Bodies, but by some other principle; it's probable that as many of its +Rays as impinge on the solid parts of Bodies are not reflected but +stifled and lost in the Bodies. For otherwise we must allow two sorts of +Reflexions. Should all the Rays be reflected which impinge on the +internal parts of clear Water or Crystal, those Substances would rather +have a cloudy Colour than a clear Transparency. To make Bodies look +black, it's necessary that many Rays be stopp'd, retained, and lost in +them; and it seems not probable that any Rays can be stopp'd and +stifled in them which do not impinge on their parts. + +And hence we may understand that Bodies are much more rare and porous +than is commonly believed. Water is nineteen times lighter, and by +consequence nineteen times rarer than Gold; and Gold is so rare as very +readily and without the least opposition to transmit the magnetick +Effluvia, and easily to admit Quicksilver into its Pores, and to let +Water pass through it. For a concave Sphere of Gold filled with Water, +and solder'd up, has, upon pressing the Sphere with great force, let the +Water squeeze through it, and stand all over its outside in multitudes +of small Drops, like Dew, without bursting or cracking the Body of the +Gold, as I have been inform'd by an Eye witness. From all which we may +conclude, that Gold has more Pores than solid parts, and by consequence +that Water has above forty times more Pores than Parts. And he that +shall find out an Hypothesis, by which Water may be so rare, and yet not +be capable of compression by force, may doubtless by the same Hypothesis +make Gold, and Water, and all other Bodies, as much rarer as he pleases; +so that Light may find a ready passage through transparent Substances. + +The Magnet acts upon Iron through all dense Bodies not magnetick nor red +hot, without any diminution of its Virtue; as for instance, through +Gold, Silver, Lead, Glass, Water. The gravitating Power of the Sun is +transmitted through the vast Bodies of the Planets without any +diminution, so as to act upon all their parts to their very centers +with the same Force and according to the same Laws, as if the part upon +which it acts were not surrounded with the Body of the Planet, The Rays +of Light, whether they be very small Bodies projected, or only Motion or +Force propagated, are moved in right Lines; and whenever a Ray of Light +is by any Obstacle turned out of its rectilinear way, it will never +return into the same rectilinear way, unless perhaps by very great +accident. And yet Light is transmitted through pellucid solid Bodies in +right Lines to very great distances. How Bodies can have a sufficient +quantity of Pores for producing these Effects is very difficult to +conceive, but perhaps not altogether impossible. For the Colours of +Bodies arise from the Magnitudes of the Particles which reflect them, as +was explained above. Now if we conceive these Particles of Bodies to be +so disposed amongst themselves, that the Intervals or empty Spaces +between them may be equal in magnitude to them all; and that these +Particles may be composed of other Particles much smaller, which have as +much empty Space between them as equals all the Magnitudes of these +smaller Particles: And that in like manner these smaller Particles are +again composed of others much smaller, all which together are equal to +all the Pores or empty Spaces between them; and so on perpetually till +you come to solid Particles, such as have no Pores or empty Spaces +within them: And if in any gross Body there be, for instance, three such +degrees of Particles, the least of which are solid; this Body will have +seven times more Pores than solid Parts. But if there be four such +degrees of Particles, the least of which are solid, the Body will have +fifteen times more Pores than solid Parts. If there be five degrees, the +Body will have one and thirty times more Pores than solid Parts. If six +degrees, the Body will have sixty and three times more Pores than solid +Parts. And so on perpetually. And there are other ways of conceiving how +Bodies may be exceeding porous. But what is really their inward Frame is +not yet known to us. + + +PROP. IX. + +_Bodies reflect and refract Light by one and the same power, variously +exercised in various Circumstances._ + +This appears by several Considerations. First, Because when Light goes +out of Glass into Air, as obliquely as it can possibly do. If its +Incidence be made still more oblique, it becomes totally reflected. For +the power of the Glass after it has refracted the Light as obliquely as +is possible, if the Incidence be still made more oblique, becomes too +strong to let any of its Rays go through, and by consequence causes +total Reflexions. Secondly, Because Light is alternately reflected and +transmitted by thin Plates of Glass for many Successions, accordingly as +the thickness of the Plate increases in an arithmetical Progression. For +here the thickness of the Glass determines whether that Power by which +Glass acts upon Light shall cause it to be reflected, or suffer it to +be transmitted. And, Thirdly, because those Surfaces of transparent +Bodies which have the greatest refracting power, reflect the greatest +quantity of Light, as was shewn in the first Proposition. + + +PROP. X. + +_If Light be swifter in Bodies than in Vacuo, in the proportion of the +Sines which measure the Refraction of the Bodies, the Forces of the +Bodies to reflect and refract Light, are very nearly proportional to the +densities of the same Bodies; excepting that unctuous and sulphureous +Bodies refract more than others of this same density._ + +[Illustration: FIG. 8.] + +Let AB represent the refracting plane Surface of any Body, and IC a Ray +incident very obliquely upon the Body in C, so that the Angle ACI may be +infinitely little, and let CR be the refracted Ray. From a given Point B +perpendicular to the refracting Surface erect BR meeting with the +refracting Ray CR in R, and if CR represent the Motion of the refracted +Ray, and this Motion be distinguish'd into two Motions CB and BR, +whereof CB is parallel to the refracting Plane, and BR perpendicular to +it: CB shall represent the Motion of the incident Ray, and BR the +Motion generated by the Refraction, as Opticians have of late explain'd. + +Now if any Body or Thing, in moving through any Space of a given breadth +terminated on both sides by two parallel Planes, be urged forward in all +parts of that Space by Forces tending directly forwards towards the last +Plane, and before its Incidence on the first Plane, had no Motion +towards it, or but an infinitely little one; and if the Forces in all +parts of that Space, between the Planes, be at equal distances from the +Planes equal to one another, but at several distances be bigger or less +in any given Proportion, the Motion generated by the Forces in the whole +passage of the Body or thing through that Space shall be in a +subduplicate Proportion of the Forces, as Mathematicians will easily +understand. And therefore, if the Space of activity of the refracting +Superficies of the Body be consider'd as such a Space, the Motion of the +Ray generated by the refracting Force of the Body, during its passage +through that Space, that is, the Motion BR, must be in subduplicate +Proportion of that refracting Force. I say therefore, that the Square of +the Line BR, and by consequence the refracting Force of the Body, is +very nearly as the density of the same Body. For this will appear by the +following Table, wherein the Proportion of the Sines which measure the +Refractions of several Bodies, the Square of BR, supposing CB an unite, +the Densities of the Bodies estimated by their Specifick Gravities, and +their Refractive Power in respect of their Densities are set down in +several Columns. + +---------------------+----------------+----------------+----------+----------- + | | | | + | | The Square | The | The + | | of BR, to | density | refractive + | The Proportion | which the | and | Power of + | of the Sines of| refracting | specifick| the Body + | Incidence and | force of the | gravity | in respect + The refracting | Refraction of | Body is | of the | of its + Bodies. | yellow Light. | proportionate. | Body. | density. +---------------------+----------------+----------------+----------+----------- +A Pseudo-Topazius, | | | | + being a natural, | | | | + pellucid, brittle, | 23 to 14 | 1'699 | 4'27 | 3979 + hairy Stone, of a | | | | + yellow Colour. | | | | +Air. | 3201 to 3200 | 0'000625 | 0'0012 | 5208 +Glass of Antimony. | 17 to 9 | 2'568 | 5'28 | 4864 +A Selenitis. | 61 to 41 | 1'213 | 2'252 | 5386 +Glass vulgar. | 31 to 20 | 1'4025 | 2'58 | 5436 +Crystal of the Rock. | 25 to 16 | 1'445 | 2'65 | 5450 +Island Crystal. | 5 to 3 | 1'778 | 2'72 | 6536 +Sal Gemmæ. | 17 to 11 | 1'388 | 2'143 | 6477 +Alume. | 35 to 24 | 1'1267 | 1'714 | 6570 +Borax. | 22 to 15 | 1'1511 | 1'714 | 6716 +Niter. | 32 to 21 | 1'345 | 1'9 | 7079 +Dantzick Vitriol. | 303 to 200 | 1'295 | 1'715 | 7551 +Oil of Vitriol. | 10 to 7 | 1'041 | 1'7 | 6124 +Rain Water. | 529 to 396 | 0'7845 | 1' | 7845 +Gum Arabick. | 31 to 21 | 1'179 | 1'375 | 8574 +Spirit of Wine well | | | | + rectified. | 100 to 73 | 0'8765 | 0'866 | 10121 +Camphire. | 3 to 2 | 1'25 | 0'996 | 12551 +Oil Olive. | 22 to 15 | 1'1511 | 0'913 | 12607 +Linseed Oil. | 40 to 27 | 1'1948 | 0'932 | 12819 +Spirit of Turpentine.| 25 to 17 | 1'1626 | 0'874 | 13222 +Amber. | 14 to 9 | 1'42 | 1'04 | 13654 +A Diamond. | 100 to 41 | 4'949 | 3'4 | 14556 +---------------------+----------------+----------------+----------+----------- + +The Refraction of the Air in this Table is determin'd by that of the +Atmosphere observed by Astronomers. For, if Light pass through many +refracting Substances or Mediums gradually denser and denser, and +terminated with parallel Surfaces, the Sum of all the Refractions will +be equal to the single Refraction which it would have suffer'd in +passing immediately out of the first Medium into the last. And this +holds true, though the Number of the refracting Substances be increased +to Infinity, and the Distances from one another as much decreased, so +that the Light may be refracted in every Point of its Passage, and by +continual Refractions bent into a Curve-Line. And therefore the whole +Refraction of Light in passing through the Atmosphere from the highest +and rarest Part thereof down to the lowest and densest Part, must be +equal to the Refraction which it would suffer in passing at like +Obliquity out of a Vacuum immediately into Air of equal Density with +that in the lowest Part of the Atmosphere. + +Now, although a Pseudo-Topaz, a Selenitis, Rock Crystal, Island Crystal, +Vulgar Glass (that is, Sand melted together) and Glass of Antimony, +which are terrestrial stony alcalizate Concretes, and Air which probably +arises from such Substances by Fermentation, be Substances very +differing from one another in Density, yet by this Table, they have +their refractive Powers almost in the same Proportion to one another as +their Densities are, excepting that the Refraction of that strange +Substance, Island Crystal is a little bigger than the rest. And +particularly Air, which is 3500 Times rarer than the Pseudo-Topaz, and +4400 Times rarer than Glass of Antimony, and 2000 Times rarer than the +Selenitis, Glass vulgar, or Crystal of the Rock, has notwithstanding its +rarity the same refractive Power in respect of its Density which those +very dense Substances have in respect of theirs, excepting so far as +those differ from one another. + +Again, the Refraction of Camphire, Oil Olive, Linseed Oil, Spirit of +Turpentine and Amber, which are fat sulphureous unctuous Bodies, and a +Diamond, which probably is an unctuous Substance coagulated, have their +refractive Powers in Proportion to one another as their Densities +without any considerable Variation. But the refractive Powers of these +unctuous Substances are two or three Times greater in respect of their +Densities than the refractive Powers of the former Substances in respect +of theirs. + +Water has a refractive Power in a middle degree between those two sorts +of Substances, and probably is of a middle nature. For out of it grow +all vegetable and animal Substances, which consist as well of +sulphureous fat and inflamable Parts, as of earthy lean and alcalizate +ones. + +Salts and Vitriols have refractive Powers in a middle degree between +those of earthy Substances and Water, and accordingly are composed of +those two sorts of Substances. For by distillation and rectification of +their Spirits a great Part of them goes into Water, and a great Part +remains behind in the form of a dry fix'd Earth capable of +Vitrification. + +Spirit of Wine has a refractive Power in a middle degree between those +of Water and oily Substances, and accordingly seems to be composed of +both, united by Fermentation; the Water, by means of some saline Spirits +with which 'tis impregnated, dissolving the Oil, and volatizing it by +the Action. For Spirit of Wine is inflamable by means of its oily Parts, +and being distilled often from Salt of Tartar, grow by every +distillation more and more aqueous and phlegmatick. And Chymists +observe, that Vegetables (as Lavender, Rue, Marjoram, &c.) distilled +_per se_, before fermentation yield Oils without any burning Spirits, +but after fermentation yield ardent Spirits without Oils: Which shews, +that their Oil is by fermentation converted into Spirit. They find also, +that if Oils be poured in a small quantity upon fermentating Vegetables, +they distil over after fermentation in the form of Spirits. + +So then, by the foregoing Table, all Bodies seem to have their +refractive Powers proportional to their Densities, (or very nearly;) +excepting so far as they partake more or less of sulphureous oily +Particles, and thereby have their refractive Power made greater or less. +Whence it seems rational to attribute the refractive Power of all Bodies +chiefly, if not wholly, to the sulphureous Parts with which they abound. +For it's probable that all Bodies abound more or less with Sulphurs. And +as Light congregated by a Burning-glass acts most upon sulphureous +Bodies, to turn them into Fire and Flame; so, since all Action is +mutual, Sulphurs ought to act most upon Light. For that the action +between Light and Bodies is mutual, may appear from this Consideration; +That the densest Bodies which refract and reflect Light most strongly, +grow hottest in the Summer Sun, by the action of the refracted or +reflected Light. + +I have hitherto explain'd the power of Bodies to reflect and refract, +and shew'd, that thin transparent Plates, Fibres, and Particles, do, +according to their several thicknesses and densities, reflect several +sorts of Rays, and thereby appear of several Colours; and by consequence +that nothing more is requisite for producing all the Colours of natural +Bodies, than the several sizes and densities of their transparent +Particles. But whence it is that these Plates, Fibres, and Particles, +do, according to their several thicknesses and densities, reflect +several sorts of Rays, I have not yet explain'd. To give some insight +into this matter, and make way for understanding the next part of this +Book, I shall conclude this part with a few more Propositions. Those +which preceded respect the nature of Bodies, these the nature of Light: +For both must be understood, before the reason of their Actions upon one +another can be known. And because the last Proposition depended upon the +velocity of Light, I will begin with a Proposition of that kind. + + +PROP. XI. + +_Light is propagated from luminous Bodies in time, and spends about +seven or eight Minutes of an Hour in passing from the Sun to the Earth._ + +This was observed first by _Roemer_, and then by others, by means of the +Eclipses of the Satellites of _Jupiter_. For these Eclipses, when the +Earth is between the Sun and _Jupiter_, happen about seven or eight +Minutes sooner than they ought to do by the Tables, and when the Earth +is beyond the Sun they happen about seven or eight Minutes later than +they ought to do; the reason being, that the Light of the Satellites has +farther to go in the latter case than in the former by the Diameter of +the Earth's Orbit. Some inequalities of time may arise from the +Excentricities of the Orbs of the Satellites; but those cannot answer in +all the Satellites, and at all times to the Position and Distance of the +Earth from the Sun. The mean motions of _Jupiter_'s Satellites is also +swifter in his descent from his Aphelium to his Perihelium, than in his +ascent in the other half of his Orb. But this inequality has no respect +to the position of the Earth, and in the three interior Satellites is +insensible, as I find by computation from the Theory of their Gravity. + + +PROP. XII. + +_Every Ray of Light in its passage through any refracting Surface is put +into a certain transient Constitution or State, which in the progress of +the Ray returns at equal Intervals, and disposes the Ray at every return +to be easily transmitted through the next refracting Surface, and +between the returns to be easily reflected by it._ + +This is manifest by the 5th, 9th, 12th, and 15th Observations. For by +those Observations it appears, that one and the same sort of Rays at +equal Angles of Incidence on any thin transparent Plate, is alternately +reflected and transmitted for many Successions accordingly as the +thickness of the Plate increases in arithmetical Progression of the +Numbers, 0, 1, 2, 3, 4, 5, 6, 7, 8, &c. so that if the first Reflexion +(that which makes the first or innermost of the Rings of Colours there +described) be made at the thickness 1, the Rays shall be transmitted at +the thicknesses 0, 2, 4, 6, 8, 10, 12, &c. and thereby make the central +Spot and Rings of Light, which appear by transmission, and be reflected +at the thickness 1, 3, 5, 7, 9, 11, &c. and thereby make the Rings which +appear by Reflexion. And this alternate Reflexion and Transmission, as I +gather by the 24th Observation, continues for above an hundred +vicissitudes, and by the Observations in the next part of this Book, for +many thousands, being propagated from one Surface of a Glass Plate to +the other, though the thickness of the Plate be a quarter of an Inch or +above: So that this alternation seems to be propagated from every +refracting Surface to all distances without end or limitation. + +This alternate Reflexion and Refraction depends on both the Surfaces of +every thin Plate, because it depends on their distance. By the 21st +Observation, if either Surface of a thin Plate of _Muscovy_ Glass be +wetted, the Colours caused by the alternate Reflexion and Refraction +grow faint, and therefore it depends on them both. + +It is therefore perform'd at the second Surface; for if it were +perform'd at the first, before the Rays arrive at the second, it would +not depend on the second. + +It is also influenced by some action or disposition, propagated from the +first to the second, because otherwise at the second it would not depend +on the first. And this action or disposition, in its propagation, +intermits and returns by equal Intervals, because in all its progress it +inclines the Ray at one distance from the first Surface to be reflected +by the second, at another to be transmitted by it, and that by equal +Intervals for innumerable vicissitudes. And because the Ray is disposed +to Reflexion at the distances 1, 3, 5, 7, 9, &c. and to Transmission at +the distances 0, 2, 4, 6, 8, 10, &c. (for its transmission through the +first Surface, is at the distance 0, and it is transmitted through both +together, if their distance be infinitely little or much less than 1) +the disposition to be transmitted at the distances 2, 4, 6, 8, 10, &c. +is to be accounted a return of the same disposition which the Ray first +had at the distance 0, that is at its transmission through the first +refracting Surface. All which is the thing I would prove. + +What kind of action or disposition this is; Whether it consists in a +circulating or a vibrating motion of the Ray, or of the Medium, or +something else, I do not here enquire. Those that are averse from +assenting to any new Discoveries, but such as they can explain by an +Hypothesis, may for the present suppose, that as Stones by falling upon +Water put the Water into an undulating Motion, and all Bodies by +percussion excite vibrations in the Air; so the Rays of Light, by +impinging on any refracting or reflecting Surface, excite vibrations in +the refracting or reflecting Medium or Substance, and by exciting them +agitate the solid parts of the refracting or reflecting Body, and by +agitating them cause the Body to grow warm or hot; that the vibrations +thus excited are propagated in the refracting or reflecting Medium or +Substance, much after the manner that vibrations are propagated in the +Air for causing Sound, and move faster than the Rays so as to overtake +them; and that when any Ray is in that part of the vibration which +conspires with its Motion, it easily breaks through a refracting +Surface, but when it is in the contrary part of the vibration which +impedes its Motion, it is easily reflected; and, by consequence, that +every Ray is successively disposed to be easily reflected, or easily +transmitted, by every vibration which overtakes it. But whether this +Hypothesis be true or false I do not here consider. I content my self +with the bare Discovery, that the Rays of Light are by some cause or +other alternately disposed to be reflected or refracted for many +vicissitudes. + + +DEFINITION. + +_The returns of the disposition of any Ray to be reflected I will call +its_ Fits of easy Reflexion, _and those of its disposition to be +transmitted its_ Fits of easy Transmission, _and the space it passes +between every return and the next return, the_ Interval of its Fits. + + +PROP. XIII. + +_The reason why the Surfaces of all thick transparent Bodies reflect +part of the Light incident on them, and refract the rest, is, that some +Rays at their Incidence are in Fits of easy Reflexion, and others in +Fits of easy Transmission._ + +This may be gather'd from the 24th Observation, where the Light +reflected by thin Plates of Air and Glass, which to the naked Eye +appear'd evenly white all over the Plate, did through a Prism appear +waved with many Successions of Light and Darkness made by alternate Fits +of easy Reflexion and easy Transmission, the Prism severing and +distinguishing the Waves of which the white reflected Light was +composed, as was explain'd above. + +And hence Light is in Fits of easy Reflexion and easy Transmission, +before its Incidence on transparent Bodies. And probably it is put into +such fits at its first emission from luminous Bodies, and continues in +them during all its progress. For these Fits are of a lasting nature, as +will appear by the next part of this Book. + +In this Proposition I suppose the transparent Bodies to be thick; +because if the thickness of the Body be much less than the Interval of +the Fits of easy Reflexion and Transmission of the Rays, the Body loseth +its reflecting power. For if the Rays, which at their entering into the +Body are put into Fits of easy Transmission, arrive at the farthest +Surface of the Body before they be out of those Fits, they must be +transmitted. And this is the reason why Bubbles of Water lose their +reflecting power when they grow very thin; and why all opake Bodies, +when reduced into very small parts, become transparent. + + +PROP. XIV. + +_Those Surfaces of transparent Bodies, which if the Ray be in a Fit of +Refraction do refract it most strongly, if the Ray be in a Fit of +Reflexion do reflect it most easily._ + +For we shewed above, in _Prop._ 8. that the cause of Reflexion is not +the impinging of Light on the solid impervious parts of Bodies, but some +other power by which those solid parts act on Light at a distance. We +shewed also in _Prop._ 9. that Bodies reflect and refract Light by one +and the same power, variously exercised in various circumstances; and in +_Prop._ 1. that the most strongly refracting Surfaces reflect the most +Light: All which compared together evince and rarify both this and the +last Proposition. + + +PROP. XV. + +_In any one and the same sort of Rays, emerging in any Angle out of any +refracting Surface into one and the same Medium, the Interval of the +following Fits of easy Reflexion and Transmission are either accurately +or very nearly, as the Rectangle of the Secant of the Angle of +Refraction, and of the Secant of another Angle, whose Sine is the first +of 106 arithmetical mean Proportionals, between the Sines of Incidence +and Refraction, counted from the Sine of Refraction._ + +This is manifest by the 7th and 19th Observations. + + +PROP. XVI. + +_In several sorts of Rays emerging in equal Angles out of any refracting +Surface into the same Medium, the Intervals of the following Fits of +easy Reflexion and easy Transmission are either accurately, or very +nearly, as the Cube-Roots of the Squares of the lengths of a Chord, +which found the Notes in an Eight_, sol, la, fa, sol, la, mi, fa, sol, +_with all their intermediate degrees answering to the Colours of those +Rays, according to the Analogy described in the seventh Experiment of +the second Part of the first Book._ + +This is manifest by the 13th and 14th Observations. + + +PROP. XVII. + +_If Rays of any sort pass perpendicularly into several Mediums, the +Intervals of the Fits of easy Reflexion and Transmission in any one +Medium, are to those Intervals in any other, as the Sine of Incidence to +the Sine of Refraction, when the Rays pass out of the first of those two +Mediums into the second._ + +This is manifest by the 10th Observation. + + +PROP. XVIII. + +_If the Rays which paint the Colour in the Confine of yellow and orange +pass perpendicularly out of any Medium into Air, the Intervals of their +Fits of easy Reflexion are the 1/89000th part of an Inch. And of the +same length are the Intervals of their Fits of easy Transmission._ + +This is manifest by the 6th Observation. From these Propositions it is +easy to collect the Intervals of the Fits of easy Reflexion and easy +Transmission of any sort of Rays refracted in any angle into any Medium; +and thence to know, whether the Rays shall be reflected or transmitted +at their subsequent Incidence upon any other pellucid Medium. Which +thing, being useful for understanding the next part of this Book, was +here to be set down. And for the same reason I add the two following +Propositions. + + +PROP. XIX. + +_If any sort of Rays falling on the polite Surface of any pellucid +Medium be reflected back, the Fits of easy Reflexion, which they have at +the point of Reflexion, shall still continue to return; and the Returns +shall be at distances from the point of Reflexion in the arithmetical +progression of the Numbers 2, 4, 6, 8, 10, 12, &c. and between these +Fits the Rays shall be in Fits of easy Transmission._ + +For since the Fits of easy Reflexion and easy Transmission are of a +returning nature, there is no reason why these Fits, which continued +till the Ray arrived at the reflecting Medium, and there inclined the +Ray to Reflexion, should there cease. And if the Ray at the point of +Reflexion was in a Fit of easy Reflexion, the progression of the +distances of these Fits from that point must begin from 0, and so be of +the Numbers 0, 2, 4, 6, 8, &c. And therefore the progression of the +distances of the intermediate Fits of easy Transmission, reckon'd from +the same point, must be in the progression of the odd Numbers 1, 3, 5, +7, 9, &c. contrary to what happens when the Fits are propagated from +points of Refraction. + + +PROP. XX. + +_The Intervals of the Fits of easy Reflexion and easy Transmission, +propagated from points of Reflexion into any Medium, are equal to the +Intervals of the like Fits, which the same Rays would have, if refracted +into the same Medium in Angles of Refraction equal to their Angles of +Reflexion._ + +For when Light is reflected by the second Surface of thin Plates, it +goes out afterwards freely at the first Surface to make the Rings of +Colours which appear by Reflexion; and, by the freedom of its egress, +makes the Colours of these Rings more vivid and strong than those which +appear on the other side of the Plates by the transmitted Light. The +reflected Rays are therefore in Fits of easy Transmission at their +egress; which would not always happen, if the Intervals of the Fits +within the Plate after Reflexion were not equal, both in length and +number, to their Intervals before it. And this confirms also the +proportions set down in the former Proposition. For if the Rays both in +going in and out at the first Surface be in Fits of easy Transmission, +and the Intervals and Numbers of those Fits between the first and second +Surface, before and after Reflexion, be equal, the distances of the Fits +of easy Transmission from either Surface, must be in the same +progression after Reflexion as before; that is, from the first Surface +which transmitted them in the progression of the even Numbers 0, 2, 4, +6, 8, &c. and from the second which reflected them, in that of the odd +Numbers 1, 3, 5, 7, &c. But these two Propositions will become much more +evident by the Observations in the following part of this Book. + + + + +THE + +SECOND BOOK + +OF + +OPTICKS + + +_PART IV._ + +_Observations concerning the Reflexions and Colours of thick transparent +polish'd Plates._ + +There is no Glass or Speculum how well soever polished, but, besides the +Light which it refracts or reflects regularly, scatters every way +irregularly a faint Light, by means of which the polish'd Surface, when +illuminated in a dark room by a beam of the Sun's Light, may be easily +seen in all positions of the Eye. There are certain Phænomena of this +scatter'd Light, which when I first observed them, seem'd very strange +and surprizing to me. My Observations were as follows. + +_Obs._ 1. The Sun shining into my darken'd Chamber through a hole one +third of an Inch wide, I let the intromitted beam of Light fall +perpendicularly upon a Glass Speculum ground concave on one side and +convex on the other, to a Sphere of five Feet and eleven Inches Radius, +and Quick-silver'd over on the convex side. And holding a white opake +Chart, or a Quire of Paper at the center of the Spheres to which the +Speculum was ground, that is, at the distance of about five Feet and +eleven Inches from the Speculum, in such manner, that the beam of Light +might pass through a little hole made in the middle of the Chart to the +Speculum, and thence be reflected back to the same hole: I observed upon +the Chart four or five concentric Irises or Rings of Colours, like +Rain-bows, encompassing the hole much after the manner that those, which +in the fourth and following Observations of the first part of this Book +appear'd between the Object-glasses, encompassed the black Spot, but yet +larger and fainter than those. These Rings as they grew larger and +larger became diluter and fainter, so that the fifth was scarce visible. +Yet sometimes, when the Sun shone very clear, there appear'd faint +Lineaments of a sixth and seventh. If the distance of the Chart from the +Speculum was much greater or much less than that of six Feet, the Rings +became dilute and vanish'd. And if the distance of the Speculum from the +Window was much greater than that of six Feet, the reflected beam of +Light would be so broad at the distance of six Feet from the Speculum +where the Rings appear'd, as to obscure one or two of the innermost +Rings. And therefore I usually placed the Speculum at about six Feet +from the Window; so that its Focus might there fall in with the center +of its concavity at the Rings upon the Chart. And this Posture is always +to be understood in the following Observations where no other is +express'd. + +_Obs._ 2. The Colours of these Rain-bows succeeded one another from the +center outwards, in the same form and order with those which were made +in the ninth Observation of the first Part of this Book by Light not +reflected, but transmitted through the two Object-glasses. For, first, +there was in their common center a white round Spot of faint Light, +something broader than the reflected beam of Light, which beam sometimes +fell upon the middle of the Spot, and sometimes by a little inclination +of the Speculum receded from the middle, and left the Spot white to the +center. + +This white Spot was immediately encompassed with a dark grey or russet, +and that dark grey with the Colours of the first Iris; which Colours on +the inside next the dark grey were a little violet and indigo, and next +to that a blue, which on the outside grew pale, and then succeeded a +little greenish yellow, and after that a brighter yellow, and then on +the outward edge of the Iris a red which on the outside inclined to +purple. + +This Iris was immediately encompassed with a second, whose Colours were +in order from the inside outwards, purple, blue, green, yellow, light +red, a red mix'd with purple. + +Then immediately follow'd the Colours of the third Iris, which were in +order outwards a green inclining to purple, a good green, and a red more +bright than that of the former Iris. + +The fourth and fifth Iris seem'd of a bluish green within, and red +without, but so faintly that it was difficult to discern the Colours. + +_Obs._ 3. Measuring the Diameters of these Rings upon the Chart as +accurately as I could, I found them also in the same proportion to one +another with the Rings made by Light transmitted through the two +Object-glasses. For the Diameters of the four first of the bright Rings +measured between the brightest parts of their Orbits, at the distance of +six Feet from the Speculum were 1-11/16, 2-3/8, 2-11/12, 3-3/8 Inches, +whose Squares are in arithmetical progression of the numbers 1, 2, 3, 4. +If the white circular Spot in the middle be reckon'd amongst the Rings, +and its central Light, where it seems to be most luminous, be put +equipollent to an infinitely little Ring; the Squares of the Diameters +of the Rings will be in the progression 0, 1, 2, 3, 4, &c. I measured +also the Diameters of the dark Circles between these luminous ones, and +found their Squares in the progression of the numbers 1/2, 1-1/2, 2-1/2, +3-1/2, &c. the Diameters of the first four at the distance of six Feet +from the Speculum, being 1-3/16, 2-1/16, 2-2/3, 3-3/20 Inches. If the +distance of the Chart from the Speculum was increased or diminished, the +Diameters of the Circles were increased or diminished proportionally. + +_Obs._ 4. By the analogy between these Rings and those described in the +Observations of the first Part of this Book, I suspected that there +were many more of them which spread into one another, and by interfering +mix'd their Colours, and diluted one another so that they could not be +seen apart. I viewed them therefore through a Prism, as I did those in +the 24th Observation of the first Part of this Book. And when the Prism +was so placed as by refracting the Light of their mix'd Colours to +separate them, and distinguish the Rings from one another, as it did +those in that Observation, I could then see them distincter than before, +and easily number eight or nine of them, and sometimes twelve or +thirteen. And had not their Light been so very faint, I question not but +that I might have seen many more. + +_Obs._ 5. Placing a Prism at the Window to refract the intromitted beam +of Light, and cast the oblong Spectrum of Colours on the Speculum: I +covered the Speculum with a black Paper which had in the middle of it a +hole to let any one of the Colours pass through to the Speculum, whilst +the rest were intercepted by the Paper. And now I found Rings of that +Colour only which fell upon the Speculum. If the Speculum was +illuminated with red, the Rings were totally red with dark Intervals, if +with blue they were totally blue, and so of the other Colours. And when +they were illuminated with any one Colour, the Squares of their +Diameters measured between their most luminous Parts, were in the +arithmetical Progression of the Numbers, 0, 1, 2, 3, 4 and the Squares +of the Diameters of their dark Intervals in the Progression of the +intermediate Numbers 1/2, 1-1/2, 2-1/2, 3-1/2. But if the Colour was +varied, they varied their Magnitude. In the red they were largest, in +the indigo and violet least, and in the intermediate Colours yellow, +green, and blue, they were of several intermediate Bignesses answering +to the Colour, that is, greater in yellow than in green, and greater in +green than in blue. And hence I knew, that when the Speculum was +illuminated with white Light, the red and yellow on the outside of the +Rings were produced by the least refrangible Rays, and the blue and +violet by the most refrangible, and that the Colours of each Ring spread +into the Colours of the neighbouring Rings on either side, after the +manner explain'd in the first and second Part of this Book, and by +mixing diluted one another so that they could not be distinguish'd, +unless near the Center where they were least mix'd. For in this +Observation I could see the Rings more distinctly, and to a greater +Number than before, being able in the yellow Light to number eight or +nine of them, besides a faint shadow of a tenth. To satisfy my self how +much the Colours of the several Rings spread into one another, I +measured the Diameters of the second and third Rings, and found them +when made by the Confine of the red and orange to be to the same +Diameters when made by the Confine of blue and indigo, as 9 to 8, or +thereabouts. For it was hard to determine this Proportion accurately. +Also the Circles made successively by the red, yellow, and green, +differ'd more from one another than those made successively by the +green, blue, and indigo. For the Circle made by the violet was too dark +to be seen. To carry on the Computation, let us therefore suppose that +the Differences of the Diameters of the Circles made by the outmost red, +the Confine of red and orange, the Confine of orange and yellow, the +Confine of yellow and green, the Confine of green and blue, the Confine +of blue and indigo, the Confine of indigo and violet, and outmost +violet, are in proportion as the Differences of the Lengths of a +Monochord which sound the Tones in an Eight; _sol_, _la_, _fa_, _sol_, +_la_, _mi_, _fa_, _sol_, that is, as the Numbers 1/9, 1/18, 1/12, 1/12, +2/27, 1/27, 1/18. And if the Diameter of the Circle made by the Confine +of red and orange be 9A, and that of the Circle made by the Confine of +blue and indigo be 8A as above; their difference 9A-8A will be to the +difference of the Diameters of the Circles made by the outmost red, and +by the Confine of red and orange, as 1/18 + 1/12 + 1/12 + 2/27 to 1/9, +that is as 8/27 to 1/9, or 8 to 3, and to the difference of the Circles +made by the outmost violet, and by the Confine of blue and indigo, as +1/18 + 1/12 + 1/12 + 2/27 to 1/27 + 1/18, that is, as 8/27 to 5/54, or +as 16 to 5. And therefore these differences will be 3/8A and 5/16A. Add +the first to 9A and subduct the last from 8A, and you will have the +Diameters of the Circles made by the least and most refrangible Rays +75/8A and ((61-1/2)/8)A. These diameters are therefore to one another as +75 to 61-1/2 or 50 to 41, and their Squares as 2500 to 1681, that is, as +3 to 2 very nearly. Which proportion differs not much from the +proportion of the Diameters of the Circles made by the outmost red and +outmost violet, in the 13th Observation of the first part of this Book. + +_Obs._ 6. Placing my Eye where these Rings appear'd plainest, I saw the +Speculum tinged all over with Waves of Colours, (red, yellow, green, +blue;) like those which in the Observations of the first part of this +Book appeared between the Object-glasses, and upon Bubbles of Water, but +much larger. And after the manner of those, they were of various +magnitudes in various Positions of the Eye, swelling and shrinking as I +moved my Eye this way and that way. They were formed like Arcs of +concentrick Circles, as those were; and when my Eye was over against the +center of the concavity of the Speculum, (that is, 5 Feet and 10 Inches +distant from the Speculum,) their common center was in a right Line with +that center of concavity, and with the hole in the Window. But in other +postures of my Eye their center had other positions. They appear'd by +the Light of the Clouds propagated to the Speculum through the hole in +the Window; and when the Sun shone through that hole upon the Speculum, +his Light upon it was of the Colour of the Ring whereon it fell, but by +its splendor obscured the Rings made by the Light of the Clouds, unless +when the Speculum was removed to a great distance from the Window, so +that his Light upon it might be broad and faint. By varying the position +of my Eye, and moving it nearer to or farther from the direct beam of +the Sun's Light, the Colour of the Sun's reflected Light constantly +varied upon the Speculum, as it did upon my Eye, the same Colour always +appearing to a Bystander upon my Eye which to me appear'd upon the +Speculum. And thence I knew that the Rings of Colours upon the Chart +were made by these reflected Colours, propagated thither from the +Speculum in several Angles, and that their production depended not upon +the termination of Light and Shadow. + +_Obs._ 7. By the Analogy of all these Phænomena with those of the like +Rings of Colours described in the first part of this Book, it seemed to +me that these Colours were produced by this thick Plate of Glass, much +after the manner that those were produced by very thin Plates. For, upon +trial, I found that if the Quick-silver were rubb'd off from the +backside of the Speculum, the Glass alone would cause the same Rings of +Colours, but much more faint than before; and therefore the Phænomenon +depends not upon the Quick-silver, unless so far as the Quick-silver by +increasing the Reflexion of the backside of the Glass increases the +Light of the Rings of Colours. I found also that a Speculum of Metal +without Glass made some Years since for optical uses, and very well +wrought, produced none of those Rings; and thence I understood that +these Rings arise not from one specular Surface alone, but depend upon +the two Surfaces of the Plate of Glass whereof the Speculum was made, +and upon the thickness of the Glass between them. For as in the 7th and +19th Observations of the first part of this Book a thin Plate of Air, +Water, or Glass of an even thickness appeared of one Colour when the +Rays were perpendicular to it, of another when they were a little +oblique, of another when more oblique, of another when still more +oblique, and so on; so here, in the sixth Observation, the Light which +emerged out of the Glass in several Obliquities, made the Glass appear +of several Colours, and being propagated in those Obliquities to the +Chart, there painted Rings of those Colours. And as the reason why a +thin Plate appeared of several Colours in several Obliquities of the +Rays, was, that the Rays of one and the same sort are reflected by the +thin Plate at one obliquity and transmitted at another, and those of +other sorts transmitted where these are reflected, and reflected where +these are transmitted: So the reason why the thick Plate of Glass +whereof the Speculum was made did appear of various Colours in various +Obliquities, and in those Obliquities propagated those Colours to the +Chart, was, that the Rays of one and the same sort did at one Obliquity +emerge out of the Glass, at another did not emerge, but were reflected +back towards the Quick-silver by the hither Surface of the Glass, and +accordingly as the Obliquity became greater and greater, emerged and +were reflected alternately for many Successions; and that in one and the +same Obliquity the Rays of one sort were reflected, and those of another +transmitted. This is manifest by the fifth Observation of this part of +this Book. For in that Observation, when the Speculum was illuminated by +any one of the prismatick Colours, that Light made many Rings of the +same Colour upon the Chart with dark Intervals, and therefore at its +emergence out of the Speculum was alternately transmitted and not +transmitted from the Speculum to the Chart for many Successions, +according to the various Obliquities of its Emergence. And when the +Colour cast on the Speculum by the Prism was varied, the Rings became of +the Colour cast on it, and varied their bigness with their Colour, and +therefore the Light was now alternately transmitted and not transmitted +from the Speculum to the Chart at other Obliquities than before. It +seemed to me therefore that these Rings were of one and the same +original with those of thin Plates, but yet with this difference, that +those of thin Plates are made by the alternate Reflexions and +Transmissions of the Rays at the second Surface of the Plate, after one +passage through it; but here the Rays go twice through the Plate before +they are alternately reflected and transmitted. First, they go through +it from the first Surface to the Quick-silver, and then return through +it from the Quick-silver to the first Surface, and there are either +transmitted to the Chart or reflected back to the Quick-silver, +accordingly as they are in their Fits of easy Reflexion or Transmission +when they arrive at that Surface. For the Intervals of the Fits of the +Rays which fall perpendicularly on the Speculum, and are reflected back +in the same perpendicular Lines, by reason of the equality of these +Angles and Lines, are of the same length and number within the Glass +after Reflexion as before, by the 19th Proposition of the third part of +this Book. And therefore since all the Rays that enter through the +first Surface are in their Fits of easy Transmission at their entrance, +and as many of these as are reflected by the second are in their Fits of +easy Reflexion there, all these must be again in their Fits of easy +Transmission at their return to the first, and by consequence there go +out of the Glass to the Chart, and form upon it the white Spot of Light +in the center of the Rings. For the reason holds good in all sorts of +Rays, and therefore all sorts must go out promiscuously to that Spot, +and by their mixture cause it to be white. But the Intervals of the Fits +of those Rays which are reflected more obliquely than they enter, must +be greater after Reflexion than before, by the 15th and 20th +Propositions. And thence it may happen that the Rays at their return to +the first Surface, may in certain Obliquities be in Fits of easy +Reflexion, and return back to the Quick-silver, and in other +intermediate Obliquities be again in Fits of easy Transmission, and so +go out to the Chart, and paint on it the Rings of Colours about the +white Spot. And because the Intervals of the Fits at equal obliquities +are greater and fewer in the less refrangible Rays, and less and more +numerous in the more refrangible, therefore the less refrangible at +equal obliquities shall make fewer Rings than the more refrangible, and +the Rings made by those shall be larger than the like number of Rings +made by these; that is, the red Rings shall be larger than the yellow, +the yellow than the green, the green than the blue, and the blue than +the violet, as they were really found to be in the fifth Observation. +And therefore the first Ring of all Colours encompassing the white Spot +of Light shall be red without any violet within, and yellow, and green, +and blue in the middle, as it was found in the second Observation; and +these Colours in the second Ring, and those that follow, shall be more +expanded, till they spread into one another, and blend one another by +interfering. + +These seem to be the reasons of these Rings in general; and this put me +upon observing the thickness of the Glass, and considering whether the +dimensions and proportions of the Rings may be truly derived from it by +computation. + +_Obs._ 8. I measured therefore the thickness of this concavo-convex +Plate of Glass, and found it every where 1/4 of an Inch precisely. Now, +by the sixth Observation of the first Part of this Book, a thin Plate of +Air transmits the brightest Light of the first Ring, that is, the bright +yellow, when its thickness is the 1/89000th part of an Inch; and by the +tenth Observation of the same Part, a thin Plate of Glass transmits the +same Light of the same Ring, when its thickness is less in proportion of +the Sine of Refraction to the Sine of Incidence, that is, when its +thickness is the 11/1513000th or 1/137545th part of an Inch, supposing +the Sines are as 11 to 17. And if this thickness be doubled, it +transmits the same bright Light of the second Ring; if tripled, it +transmits that of the third, and so on; the bright yellow Light in all +these cases being in its Fits of Transmission. And therefore if its +thickness be multiplied 34386 times, so as to become 1/4 of an Inch, it +transmits the same bright Light of the 34386th Ring. Suppose this be the +bright yellow Light transmitted perpendicularly from the reflecting +convex side of the Glass through the concave side to the white Spot in +the center of the Rings of Colours on the Chart: And by a Rule in the +7th and 19th Observations in the first Part of this Book, and by the +15th and 20th Propositions of the third Part of this Book, if the Rays +be made oblique to the Glass, the thickness of the Glass requisite to +transmit the same bright Light of the same Ring in any obliquity, is to +this thickness of 1/4 of an Inch, as the Secant of a certain Angle to +the Radius, the Sine of which Angle is the first of an hundred and six +arithmetical Means between the Sines of Incidence and Refraction, +counted from the Sine of Incidence when the Refraction is made out of +any plated Body into any Medium encompassing it; that is, in this case, +out of Glass into Air. Now if the thickness of the Glass be increased by +degrees, so as to bear to its first thickness, (_viz._ that of a quarter +of an Inch,) the Proportions which 34386 (the number of Fits of the +perpendicular Rays in going through the Glass towards the white Spot in +the center of the Rings,) hath to 34385, 34384, 34383, and 34382, (the +numbers of the Fits of the oblique Rays in going through the Glass +towards the first, second, third, and fourth Rings of Colours,) and if +the first thickness be divided into 100000000 equal parts, the increased +thicknesses will be 100002908, 100005816, 100008725, and 100011633, and +the Angles of which these thicknesses are Secants will be 26´ 13´´, 37´ +5´´, 45´ 6´´, and 52´ 26´´, the Radius being 100000000; and the Sines of +these Angles are 762, 1079, 1321, and 1525, and the proportional Sines +of Refraction 1172, 1659, 2031, and 2345, the Radius being 100000. For +since the Sines of Incidence out of Glass into Air are to the Sines of +Refraction as 11 to 17, and to the above-mentioned Secants as 11 to the +first of 106 arithmetical Means between 11 and 17, that is, as 11 to +11-6/106, those Secants will be to the Sines of Refraction as 11-6/106, +to 17, and by this Analogy will give these Sines. So then, if the +obliquities of the Rays to the concave Surface of the Glass be such that +the Sines of their Refraction in passing out of the Glass through that +Surface into the Air be 1172, 1659, 2031, 2345, the bright Light of the +34386th Ring shall emerge at the thicknesses of the Glass, which are to +1/4 of an Inch as 34386 to 34385, 34384, 34383, 34382, respectively. And +therefore, if the thickness in all these Cases be 1/4 of an Inch (as it +is in the Glass of which the Speculum was made) the bright Light of the +34385th Ring shall emerge where the Sine of Refraction is 1172, and that +of the 34384th, 34383th, and 34382th Ring where the Sine is 1659, 2031, +and 2345 respectively. And in these Angles of Refraction the Light of +these Rings shall be propagated from the Speculum to the Chart, and +there paint Rings about the white central round Spot of Light which we +said was the Light of the 34386th Ring. And the Semidiameters of these +Rings shall subtend the Angles of Refraction made at the +Concave-Surface of the Speculum, and by consequence their Diameters +shall be to the distance of the Chart from the Speculum as those Sines +of Refraction doubled are to the Radius, that is, as 1172, 1659, 2031, +and 2345, doubled are to 100000. And therefore, if the distance of the +Chart from the Concave-Surface of the Speculum be six Feet (as it was in +the third of these Observations) the Diameters of the Rings of this +bright yellow Light upon the Chart shall be 1'688, 2'389, 2'925, 3'375 +Inches: For these Diameters are to six Feet, as the above-mention'd +Sines doubled are to the Radius. Now, these Diameters of the bright +yellow Rings, thus found by Computation are the very same with those +found in the third of these Observations by measuring them, _viz._ with +1-11/16, 2-3/8, 2-11/12, and 3-3/8 Inches, and therefore the Theory of +deriving these Rings from the thickness of the Plate of Glass of which +the Speculum was made, and from the Obliquity of the emerging Rays +agrees with the Observation. In this Computation I have equalled the +Diameters of the bright Rings made by Light of all Colours, to the +Diameters of the Rings made by the bright yellow. For this yellow makes +the brightest Part of the Rings of all Colours. If you desire the +Diameters of the Rings made by the Light of any other unmix'd Colour, +you may find them readily by putting them to the Diameters of the bright +yellow ones in a subduplicate Proportion of the Intervals of the Fits of +the Rays of those Colours when equally inclined to the refracting or +reflecting Surface which caused those Fits, that is, by putting the +Diameters of the Rings made by the Rays in the Extremities and Limits of +the seven Colours, red, orange, yellow, green, blue, indigo, violet, +proportional to the Cube-roots of the Numbers, 1, 8/9, 5/6, 3/4, 2/3, +3/5, 9/16, 1/2, which express the Lengths of a Monochord sounding the +Notes in an Eighth: For by this means the Diameters of the Rings of +these Colours will be found pretty nearly in the same Proportion to one +another, which they ought to have by the fifth of these Observations. + +And thus I satisfy'd my self, that these Rings were of the same kind and +Original with those of thin Plates, and by consequence that the Fits or +alternate Dispositions of the Rays to be reflected and transmitted are +propagated to great distances from every reflecting and refracting +Surface. But yet to put the matter out of doubt, I added the following +Observation. + +_Obs._ 9. If these Rings thus depend on the thickness of the Plate of +Glass, their Diameters at equal distances from several Speculums made of +such concavo-convex Plates of Glass as are ground on the same Sphere, +ought to be reciprocally in a subduplicate Proportion of the thicknesses +of the Plates of Glass. And if this Proportion be found true by +experience it will amount to a demonstration that these Rings (like +those formed in thin Plates) do depend on the thickness of the Glass. I +procured therefore another concavo-convex Plate of Glass ground on both +sides to the same Sphere with the former Plate. Its thickness was 5/62 +Parts of an Inch; and the Diameters of the three first bright Rings +measured between the brightest Parts of their Orbits at the distance of +six Feet from the Glass were 3·4-1/6·5-1/8· Inches. Now, the thickness +of the other Glass being 1/4 of an Inch was to the thickness of this +Glass as 1/4 to 5/62, that is as 31 to 10, or 310000000 to 100000000, +and the Roots of these Numbers are 17607 and 10000, and in the +Proportion of the first of these Roots to the second are the Diameters +of the bright Rings made in this Observation by the thinner Glass, +3·4-1/6·5-1/8, to the Diameters of the same Rings made in the third of +these Observations by the thicker Glass 1-11/16, 2-3/8. 2-11/12, that +is, the Diameters of the Rings are reciprocally in a subduplicate +Proportion of the thicknesses of the Plates of Glass. + +So then in Plates of Glass which are alike concave on one side, and +alike convex on the other side, and alike quick-silver'd on the convex +sides, and differ in nothing but their thickness, the Diameters of the +Rings are reciprocally in a subduplicate Proportion of the thicknesses +of the Plates. And this shews sufficiently that the Rings depend on both +the Surfaces of the Glass. They depend on the convex Surface, because +they are more luminous when that Surface is quick-silver'd over than +when it is without Quick-silver. They depend also upon the concave +Surface, because without that Surface a Speculum makes them not. They +depend on both Surfaces, and on the distances between them, because +their bigness is varied by varying only that distance. And this +dependence is of the same kind with that which the Colours of thin +Plates have on the distance of the Surfaces of those Plates, because the +bigness of the Rings, and their Proportion to one another, and the +variation of their bigness arising from the variation of the thickness +of the Glass, and the Orders of their Colours, is such as ought to +result from the Propositions in the end of the third Part of this Book, +derived from the Phænomena of the Colours of thin Plates set down in the +first Part. + +There are yet other Phænomena of these Rings of Colours, but such as +follow from the same Propositions, and therefore confirm both the Truth +of those Propositions, and the Analogy between these Rings and the Rings +of Colours made by very thin Plates. I shall subjoin some of them. + +_Obs._ 10. When the beam of the Sun's Light was reflected back from the +Speculum not directly to the hole in the Window, but to a place a little +distant from it, the common center of that Spot, and of all the Rings of +Colours fell in the middle way between the beam of the incident Light, +and the beam of the reflected Light, and by consequence in the center of +the spherical concavity of the Speculum, whenever the Chart on which the +Rings of Colours fell was placed at that center. And as the beam of +reflected Light by inclining the Speculum receded more and more from the +beam of incident Light and from the common center of the colour'd Rings +between them, those Rings grew bigger and bigger, and so also did the +white round Spot, and new Rings of Colours emerged successively out of +their common center, and the white Spot became a white Ring +encompassing them; and the incident and reflected beams of Light always +fell upon the opposite parts of this white Ring, illuminating its +Perimeter like two mock Suns in the opposite parts of an Iris. So then +the Diameter of this Ring, measured from the middle of its Light on one +side to the middle of its Light on the other side, was always equal to +the distance between the middle of the incident beam of Light, and the +middle of the reflected beam measured at the Chart on which the Rings +appeared: And the Rays which form'd this Ring were reflected by the +Speculum in Angles equal to their Angles of Incidence, and by +consequence to their Angles of Refraction at their entrance into the +Glass, but yet their Angles of Reflexion were not in the same Planes +with their Angles of Incidence. + +_Obs._ 11. The Colours of the new Rings were in a contrary order to +those of the former, and arose after this manner. The white round Spot +of Light in the middle of the Rings continued white to the center till +the distance of the incident and reflected beams at the Chart was about +7/8 parts of an Inch, and then it began to grow dark in the middle. And +when that distance was about 1-3/16 of an Inch, the white Spot was +become a Ring encompassing a dark round Spot which in the middle +inclined to violet and indigo. And the luminous Rings encompassing it +were grown equal to those dark ones which in the four first Observations +encompassed them, that is to say, the white Spot was grown a white Ring +equal to the first of those dark Rings, and the first of those luminous +Rings was now grown equal to the second of those dark ones, and the +second of those luminous ones to the third of those dark ones, and so +on. For the Diameters of the luminous Rings were now 1-3/16, 2-1/16, +2-2/3, 3-3/20, &c. Inches. + +When the distance between the incident and reflected beams of Light +became a little bigger, there emerged out of the middle of the dark Spot +after the indigo a blue, and then out of that blue a pale green, and +soon after a yellow and red. And when the Colour at the center was +brightest, being between yellow and red, the bright Rings were grown +equal to those Rings which in the four first Observations next +encompassed them; that is to say, the white Spot in the middle of those +Rings was now become a white Ring equal to the first of those bright +Rings, and the first of those bright ones was now become equal to the +second of those, and so on. For the Diameters of the white Ring, and of +the other luminous Rings encompassing it, were now 1-11/16, 2-3/8, +2-11/12, 3-3/8, &c. or thereabouts. + +When the distance of the two beams of Light at the Chart was a little +more increased, there emerged out of the middle in order after the red, +a purple, a blue, a green, a yellow, and a red inclining much to purple, +and when the Colour was brightest being between yellow and red, the +former indigo, blue, green, yellow and red, were become an Iris or Ring +of Colours equal to the first of those luminous Rings which appeared in +the four first Observations, and the white Ring which was now become +the second of the luminous Rings was grown equal to the second of those, +and the first of those which was now become the third Ring was become +equal to the third of those, and so on. For their Diameters were +1-11/16, 2-3/8, 2-11/12, 3-3/8 Inches, the distance of the two beams of +Light, and the Diameter of the white Ring being 2-3/8 Inches. + +When these two beams became more distant there emerged out of the middle +of the purplish red, first a darker round Spot, and then out of the +middle of that Spot a brighter. And now the former Colours (purple, +blue, green, yellow, and purplish red) were become a Ring equal to the +first of the bright Rings mentioned in the four first Observations, and +the Rings about this Ring were grown equal to the Rings about that +respectively; the distance between the two beams of Light and the +Diameter of the white Ring (which was now become the third Ring) being +about 3 Inches. + +The Colours of the Rings in the middle began now to grow very dilute, +and if the distance between the two Beams was increased half an Inch, or +an Inch more, they vanish'd whilst the white Ring, with one or two of +the Rings next it on either side, continued still visible. But if the +distance of the two beams of Light was still more increased, these also +vanished: For the Light which coming from several parts of the hole in +the Window fell upon the Speculum in several Angles of Incidence, made +Rings of several bignesses, which diluted and blotted out one another, +as I knew by intercepting some part of that Light. For if I intercepted +that part which was nearest to the Axis of the Speculum the Rings would +be less, if the other part which was remotest from it they would be +bigger. + +_Obs._ 12. When the Colours of the Prism were cast successively on the +Speculum, that Ring which in the two last Observations was white, was of +the same bigness in all the Colours, but the Rings without it were +greater in the green than in the blue, and still greater in the yellow, +and greatest in the red. And, on the contrary, the Rings within that +white Circle were less in the green than in the blue, and still less in +the yellow, and least in the red. For the Angles of Reflexion of those +Rays which made this Ring, being equal to their Angles of Incidence, the +Fits of every reflected Ray within the Glass after Reflexion are equal +in length and number to the Fits of the same Ray within the Glass before +its Incidence on the reflecting Surface. And therefore since all the +Rays of all sorts at their entrance into the Glass were in a Fit of +Transmission, they were also in a Fit of Transmission at their returning +to the same Surface after Reflexion; and by consequence were +transmitted, and went out to the white Ring on the Chart. This is the +reason why that Ring was of the same bigness in all the Colours, and why +in a mixture of all it appears white. But in Rays which are reflected in +other Angles, the Intervals of the Fits of the least refrangible being +greatest, make the Rings of their Colour in their progress from this +white Ring, either outwards or inwards, increase or decrease by the +greatest steps; so that the Rings of this Colour without are greatest, +and within least. And this is the reason why in the last Observation, +when the Speculum was illuminated with white Light, the exterior Rings +made by all Colours appeared red without and blue within, and the +interior blue without and red within. + +These are the Phænomena of thick convexo-concave Plates of Glass, which +are every where of the same thickness. There are yet other Phænomena +when these Plates are a little thicker on one side than on the other, +and others when the Plates are more or less concave than convex, or +plano-convex, or double-convex. For in all these cases the Plates make +Rings of Colours, but after various manners; all which, so far as I have +yet observed, follow from the Propositions in the end of the third part +of this Book, and so conspire to confirm the truth of those +Propositions. But the Phænomena are too various, and the Calculations +whereby they follow from those Propositions too intricate to be here +prosecuted. I content my self with having prosecuted this kind of +Phænomena so far as to discover their Cause, and by discovering it to +ratify the Propositions in the third Part of this Book. + +_Obs._ 13. As Light reflected by a Lens quick-silver'd on the backside +makes the Rings of Colours above described, so it ought to make the like +Rings of Colours in passing through a drop of Water. At the first +Reflexion of the Rays within the drop, some Colours ought to be +transmitted, as in the case of a Lens, and others to be reflected back +to the Eye. For instance, if the Diameter of a small drop or globule of +Water be about the 500th part of an Inch, so that a red-making Ray in +passing through the middle of this globule has 250 Fits of easy +Transmission within the globule, and that all the red-making Rays which +are at a certain distance from this middle Ray round about it have 249 +Fits within the globule, and all the like Rays at a certain farther +distance round about it have 248 Fits, and all those at a certain +farther distance 247 Fits, and so on; these concentrick Circles of Rays +after their transmission, falling on a white Paper, will make +concentrick Rings of red upon the Paper, supposing the Light which +passes through one single globule, strong enough to be sensible. And, in +like manner, the Rays of other Colours will make Rings of other Colours. +Suppose now that in a fair Day the Sun shines through a thin Cloud of +such globules of Water or Hail, and that the globules are all of the +same bigness; and the Sun seen through this Cloud shall appear +encompassed with the like concentrick Rings of Colours, and the Diameter +of the first Ring of red shall be 7-1/4 Degrees, that of the second +10-1/4 Degrees, that of the third 12 Degrees 33 Minutes. And accordingly +as the Globules of Water are bigger or less, the Rings shall be less or +bigger. This is the Theory, and Experience answers it. For in _June_ +1692, I saw by reflexion in a Vessel of stagnating Water three Halos, +Crowns, or Rings of Colours about the Sun, like three little Rain-bows, +concentrick to his Body. The Colours of the first or innermost Crown +were blue next the Sun, red without, and white in the middle between the +blue and red. Those of the second Crown were purple and blue within, and +pale red without, and green in the middle. And those of the third were +pale blue within, and pale red without; these Crowns enclosed one +another immediately, so that their Colours proceeded in this continual +order from the Sun outward: blue, white, red; purple, blue, green, pale +yellow and red; pale blue, pale red. The Diameter of the second Crown +measured from the middle of the yellow and red on one side of the Sun, +to the middle of the same Colour on the other side was 9-1/3 Degrees, or +thereabouts. The Diameters of the first and third I had not time to +measure, but that of the first seemed to be about five or six Degrees, +and that of the third about twelve. The like Crowns appear sometimes +about the Moon; for in the beginning of the Year 1664, _Febr._ 19th at +Night, I saw two such Crowns about her. The Diameter of the first or +innermost was about three Degrees, and that of the second about five +Degrees and an half. Next about the Moon was a Circle of white, and next +about that the inner Crown, which was of a bluish green within next the +white, and of a yellow and red without, and next about these Colours +were blue and green on the inside of the outward Crown, and red on the +outside of it. At the same time there appear'd a Halo about 22 Degrees +35´ distant from the center of the Moon. It was elliptical, and its long +Diameter was perpendicular to the Horizon, verging below farthest from +the Moon. I am told that the Moon has sometimes three or more +concentrick Crowns of Colours encompassing one another next about her +Body. The more equal the globules of Water or Ice are to one another, +the more Crowns of Colours will appear, and the Colours will be the more +lively. The Halo at the distance of 22-1/2 Degrees from the Moon is of +another sort. By its being oval and remoter from the Moon below than +above, I conclude, that it was made by Refraction in some sort of Hail +or Snow floating in the Air in an horizontal posture, the refracting +Angle being about 58 or 60 Degrees. + + + + +THE + +THIRD BOOK + +OF + +OPTICKS + + +_PART I._ + +_Observations concerning the Inflexions of the Rays of Light, and the +Colours made thereby._ + +Grimaldo has inform'd us, that if a beam of the Sun's Light be let into +a dark Room through a very small hole, the Shadows of things in this +Light will be larger than they ought to be if the Rays went on by the +Bodies in straight Lines, and that these Shadows have three parallel +Fringes, Bands or Ranks of colour'd Light adjacent to them. But if the +Hole be enlarged the Fringes grow broad and run into one another, so +that they cannot be distinguish'd. These broad Shadows and Fringes have +been reckon'd by some to proceed from the ordinary refraction of the +Air, but without due examination of the Matter. For the circumstances of +the Phænomenon, so far as I have observed them, are as follows. + +_Obs._ 1. I made in a piece of Lead a small Hole with a Pin, whose +breadth was the 42d part of an Inch. For 21 of those Pins laid together +took up the breadth of half an Inch. Through this Hole I let into my +darken'd Chamber a beam of the Sun's Light, and found that the Shadows +of Hairs, Thred, Pins, Straws, and such like slender Substances placed +in this beam of Light, were considerably broader than they ought to be, +if the Rays of Light passed on by these Bodies in right Lines. And +particularly a Hair of a Man's Head, whose breadth was but the 280th +part of an Inch, being held in this Light, at the distance of about +twelve Feet from the Hole, did cast a Shadow which at the distance of +four Inches from the Hair was the sixtieth part of an Inch broad, that +is, above four times broader than the Hair, and at the distance of two +Feet from the Hair was about the eight and twentieth part of an Inch +broad, that is, ten times broader than the Hair, and at the distance of +ten Feet was the eighth part of an Inch broad, that is 35 times broader. + +Nor is it material whether the Hair be encompassed with Air, or with any +other pellucid Substance. For I wetted a polish'd Plate of Glass, and +laid the Hair in the Water upon the Glass, and then laying another +polish'd Plate of Glass upon it, so that the Water might fill up the +space between the Glasses, I held them in the aforesaid beam of Light, +so that the Light might pass through them perpendicularly, and the +Shadow of the Hair was at the same distances as big as before. The +Shadows of Scratches made in polish'd Plates of Glass were also much +broader than they ought to be, and the Veins in polish'd Plates of Glass +did also cast the like broad Shadows. And therefore the great breadth of +these Shadows proceeds from some other cause than the Refraction of the +Air. + +Let the Circle X [in _Fig._ 1.] represent the middle of the Hair; ADG, +BEH, CFI, three Rays passing by one side of the Hair at several +distances; KNQ, LOR, MPS, three other Rays passing by the other side of +the Hair at the like distances; D, E, F, and N, O, P, the places where +the Rays are bent in their passage by the Hair; G, H, I, and Q, R, S, +the places where the Rays fall on a Paper GQ; IS the breadth of the +Shadow of the Hair cast on the Paper, and TI, VS, two Rays passing to +the Points I and S without bending when the Hair is taken away. And it's +manifest that all the Light between these two Rays TI and VS is bent in +passing by the Hair, and turned aside from the Shadow IS, because if any +part of this Light were not bent it would fall on the Paper within the +Shadow, and there illuminate the Paper, contrary to experience. And +because when the Paper is at a great distance from the Hair, the Shadow +is broad, and therefore the Rays TI and VS are at a great distance from +one another, it follows that the Hair acts upon the Rays of Light at a +good distance in their passing by it. But the Action is strongest on the +Rays which pass by at least distances, and grows weaker and weaker +accordingly as the Rays pass by at distances greater and greater, as is +represented in the Scheme: For thence it comes to pass, that the Shadow +of the Hair is much broader in proportion to the distance of the Paper +from the Hair, when the Paper is nearer the Hair, than when it is at a +great distance from it. + +_Obs._ 2. The Shadows of all Bodies (Metals, Stones, Glass, Wood, Horn, +Ice, &c.) in this Light were border'd with three Parallel Fringes or +Bands of colour'd Light, whereof that which was contiguous to the Shadow +was broadest and most luminous, and that which was remotest from it was +narrowest, and so faint, as not easily to be visible. It was difficult +to distinguish the Colours, unless when the Light fell very obliquely +upon a smooth Paper, or some other smooth white Body, so as to make them +appear much broader than they would otherwise do. And then the Colours +were plainly visible in this Order: The first or innermost Fringe was +violet and deep blue next the Shadow, and then light blue, green, and +yellow in the middle, and red without. The second Fringe was almost +contiguous to the first, and the third to the second, and both were blue +within, and yellow and red without, but their Colours were very faint, +especially those of the third. The Colours therefore proceeded in this +order from the Shadow; violet, indigo, pale blue, green, yellow, red; +blue, yellow, red; pale blue, pale yellow and red. The Shadows made by +Scratches and Bubbles in polish'd Plates of Glass were border'd with the +like Fringes of colour'd Light. And if Plates of Looking-glass sloop'd +off near the edges with a Diamond-cut, be held in the same beam of +Light, the Light which passes through the parallel Planes of the Glass +will be border'd with the like Fringes of Colours where those Planes +meet with the Diamond-cut, and by this means there will sometimes appear +four or five Fringes of Colours. Let AB, CD [in _Fig._ 2.] represent the +parallel Planes of a Looking-glass, and BD the Plane of the Diamond-cut, +making at B a very obtuse Angle with the Plane AB. And let all the Light +between the Rays ENI and FBM pass directly through the parallel Planes +of the Glass, and fall upon the Paper between I and M, and all the Light +between the Rays GO and HD be refracted by the oblique Plane of the +Diamond-cut BD, and fall upon the Paper between K and L; and the Light +which passes directly through the parallel Planes of the Glass, and +falls upon the Paper between I and M, will be border'd with three or +more Fringes at M. + +[Illustration: FIG. 1.] + +[Illustration: FIG. 2.] + +So by looking on the Sun through a Feather or black Ribband held close +to the Eye, several Rain-bows will appear; the Shadows which the Fibres +or Threds cast on the _Tunica Retina_, being border'd with the like +Fringes of Colours. + +_Obs._ 3. When the Hair was twelve Feet distant from this Hole, and its +Shadow fell obliquely upon a flat white Scale of Inches and Parts of an +Inch placed half a Foot beyond it, and also when the Shadow fell +perpendicularly upon the same Scale placed nine Feet beyond it; I +measured the breadth of the Shadow and Fringes as accurately as I could, +and found them in Parts of an Inch as follows. + +-------------------------------------------+-----------+-------- + | half a | Nine + At the Distance of | Foot | Feet +-------------------------------------------+-----------+-------- +The breadth of the Shadow | 1/54 | 1/9 +-------------------------------------------+-----------+-------- +The breadth between the Middles of the | 1/38 | + brightest Light of the innermost Fringes | or | + on either side the Shadow | 1/39 | 7/50 +-------------------------------------------+-----------+-------- +The breadth between the Middles of the | | + brightest Light of the middlemost Fringes| | + on either side the Shadow | 1/23-1/2 | 4/17 +-------------------------------------------+-----------+-------- +The breadth between the Middles of the | 1/18 | + brightest Light of the outmost Fringes | or | + on either side the Shadow | 1/18-1/2 | 3/10 +-------------------------------------------+-----------+-------- +The distance between the Middles of the | | + brightest Light of the first and second | | + Fringes | 1/120 | 1/21 +-------------------------------------------+-----------+-------- +The distance between the Middles of the | | + brightest Light of the second and third | | + Fringes | 1/170 | 1/31 +-------------------------------------------+-----------+-------- +The breadth of the luminous Part (green, | | + white, yellow, and red) of the first | | + Fringe | 1/170 | 1/32 +-------------------------------------------+-----------+-------- +The breadth of the darker Space between | | + the first and second Fringes | 1/240 | 1/45 +-------------------------------------------+-----------+-------- +The breadth of the luminous Part of the | | + second Fringe | 1/290 | 1/55 +-------------------------------------------+-----------+-------- +The breadth of the darker Space between | | + the second and third Fringes | 1/340 | 1/63 +-------------------------------------------+-----------+-------- + +These Measures I took by letting the Shadow of the Hair, at half a Foot +distance, fall so obliquely on the Scale, as to appear twelve times +broader than when it fell perpendicularly on it at the same distance, +and setting down in this Table the twelfth part of the Measures I then +took. + +_Obs._ 4. When the Shadow and Fringes were cast obliquely upon a smooth +white Body, and that Body was removed farther and farther from the Hair, +the first Fringe began to appear and look brighter than the rest of the +Light at the distance of less than a quarter of an Inch from the Hair, +and the dark Line or Shadow between that and the second Fringe began to +appear at a less distance from the Hair than that of the third part of +an Inch. The second Fringe began to appear at a distance from the Hair +of less than half an Inch, and the Shadow between that and the third +Fringe at a distance less than an inch, and the third Fringe at a +distance less than three Inches. At greater distances they became much +more sensible, but kept very nearly the same proportion of their +breadths and intervals which they had at their first appearing. For the +distance between the middle of the first, and middle of the second +Fringe, was to the distance between the middle of the second and middle +of the third Fringe, as three to two, or ten to seven. And the last of +these two distances was equal to the breadth of the bright Light or +luminous part of the first Fringe. And this breadth was to the breadth +of the bright Light of the second Fringe as seven to four, and to the +dark Interval of the first and second Fringe as three to two, and to +the like dark Interval between the second and third as two to one. For +the breadths of the Fringes seem'd to be in the progression of the +Numbers 1, sqrt(1/3), sqrt(1/5), and their Intervals to be in the +same progression with them; that is, the Fringes and their Intervals +together to be in the continual progression of the Numbers 1, +sqrt(1/2), sqrt(1/3), sqrt(1/4), sqrt(1/5), or thereabouts. And +these Proportions held the same very nearly at all distances from the +Hair; the dark Intervals of the Fringes being as broad in proportion to +the breadth of the Fringes at their first appearance as afterwards at +great distances from the Hair, though not so dark and distinct. + +_Obs._ 5. The Sun shining into my darken'd Chamber through a hole a +quarter of an Inch broad, I placed at the distance of two or three Feet +from the Hole a Sheet of Pasteboard, which was black'd all over on both +sides, and in the middle of it had a hole about three quarters of an +Inch square for the Light to pass through. And behind the hole I +fasten'd to the Pasteboard with Pitch the blade of a sharp Knife, to +intercept some part of the Light which passed through the hole. The +Planes of the Pasteboard and blade of the Knife were parallel to one +another, and perpendicular to the Rays. And when they were so placed +that none of the Sun's Light fell on the Pasteboard, but all of it +passed through the hole to the Knife, and there part of it fell upon the +blade of the Knife, and part of it passed by its edge; I let this part +of the Light which passed by, fall on a white Paper two or three Feet +beyond the Knife, and there saw two streams of faint Light shoot out +both ways from the beam of Light into the shadow, like the Tails of +Comets. But because the Sun's direct Light by its brightness upon the +Paper obscured these faint streams, so that I could scarce see them, I +made a little hole in the midst of the Paper for that Light to pass +through and fall on a black Cloth behind it; and then I saw the two +streams plainly. They were like one another, and pretty nearly equal in +length, and breadth, and quantity of Light. Their Light at that end next +the Sun's direct Light was pretty strong for the space of about a +quarter of an Inch, or half an Inch, and in all its progress from that +direct Light decreased gradually till it became insensible. The whole +length of either of these streams measured upon the paper at the +distance of three Feet from the Knife was about six or eight Inches; so +that it subtended an Angle at the edge of the Knife of about 10 or 12, +or at most 14 Degrees. Yet sometimes I thought I saw it shoot three or +four Degrees farther, but with a Light so very faint that I could scarce +perceive it, and suspected it might (in some measure at least) arise +from some other cause than the two streams did. For placing my Eye in +that Light beyond the end of that stream which was behind the Knife, and +looking towards the Knife, I could see a line of Light upon its edge, +and that not only when my Eye was in the line of the Streams, but also +when it was without that line either towards the point of the Knife, or +towards the handle. This line of Light appear'd contiguous to the edge +of the Knife, and was narrower than the Light of the innermost Fringe, +and narrowest when my Eye was farthest from the direct Light, and +therefore seem'd to pass between the Light of that Fringe and the edge +of the Knife, and that which passed nearest the edge to be most bent, +though not all of it. + +_Obs._ 6. I placed another Knife by this, so that their edges might be +parallel, and look towards one another, and that the beam of Light might +fall upon both the Knives, and some part of it pass between their edges. +And when the distance of their edges was about the 400th part of an +Inch, the stream parted in the middle, and left a Shadow between the two +parts. This Shadow was so black and dark that all the Light which passed +between the Knives seem'd to be bent, and turn'd aside to the one hand +or to the other. And as the Knives still approach'd one another the +Shadow grew broader, and the streams shorter at their inward ends which +were next the Shadow, until upon the contact of the Knives the whole +Light vanish'd, leaving its place to the Shadow. + +And hence I gather that the Light which is least bent, and goes to the +inward ends of the streams, passes by the edges of the Knives at the +greatest distance, and this distance when the Shadow begins to appear +between the streams, is about the 800th part of an Inch. And the Light +which passes by the edges of the Knives at distances still less and +less, is more and more bent, and goes to those parts of the streams +which are farther and farther from the direct Light; because when the +Knives approach one another till they touch, those parts of the streams +vanish last which are farthest from the direct Light. + +_Obs._ 7. In the fifth Observation the Fringes did not appear, but by +reason of the breadth of the hole in the Window became so broad as to +run into one another, and by joining, to make one continued Light in the +beginning of the streams. But in the sixth, as the Knives approached one +another, a little before the Shadow appeared between the two streams, +the Fringes began to appear on the inner ends of the Streams on either +side of the direct Light; three on one side made by the edge of one +Knife, and three on the other side made by the edge of the other Knife. +They were distinctest when the Knives were placed at the greatest +distance from the hole in the Window, and still became more distinct by +making the hole less, insomuch that I could sometimes see a faint +lineament of a fourth Fringe beyond the three above mention'd. And as +the Knives continually approach'd one another, the Fringes grew +distincter and larger, until they vanish'd. The outmost Fringe vanish'd +first, and the middlemost next, and the innermost last. And after they +were all vanish'd, and the line of Light which was in the middle between +them was grown very broad, enlarging it self on both sides into the +streams of Light described in the fifth Observation, the above-mention'd +Shadow began to appear in the middle of this line, and divide it along +the middle into two lines of Light, and increased until the whole Light +vanish'd. This enlargement of the Fringes was so great that the Rays +which go to the innermost Fringe seem'd to be bent above twenty times +more when this Fringe was ready to vanish, than when one of the Knives +was taken away. + +And from this and the former Observation compared, I gather, that the +Light of the first Fringe passed by the edge of the Knife at a distance +greater than the 800th part of an Inch, and the Light of the second +Fringe passed by the edge of the Knife at a greater distance than the +Light of the first Fringe did, and that of the third at a greater +distance than that of the second, and that of the streams of Light +described in the fifth and sixth Observations passed by the edges of the +Knives at less distances than that of any of the Fringes. + +_Obs._ 8. I caused the edges of two Knives to be ground truly strait, +and pricking their points into a Board so that their edges might look +towards one another, and meeting near their points contain a rectilinear +Angle, I fasten'd their Handles together with Pitch to make this Angle +invariable. The distance of the edges of the Knives from one another at +the distance of four Inches from the angular Point, where the edges of +the Knives met, was the eighth part of an Inch; and therefore the Angle +contain'd by the edges was about one Degree 54: The Knives thus fix'd +together I placed in a beam of the Sun's Light, let into my darken'd +Chamber through a Hole the 42d Part of an Inch wide, at the distance of +10 or 15 Feet from the Hole, and let the Light which passed between +their edges fall very obliquely upon a smooth white Ruler at the +distance of half an Inch, or an Inch from the Knives, and there saw the +Fringes by the two edges of the Knives run along the edges of the +Shadows of the Knives in Lines parallel to those edges without growing +sensibly broader, till they met in Angles equal to the Angle contained +by the edges of the Knives, and where they met and joined they ended +without crossing one another. But if the Ruler was held at a much +greater distance from the Knives, the Fringes where they were farther +from the Place of their Meeting, were a little narrower, and became +something broader and broader as they approach'd nearer and nearer to +one another, and after they met they cross'd one another, and then +became much broader than before. + +Whence I gather that the distances at which the Fringes pass by the +Knives are not increased nor alter'd by the approach of the Knives, but +the Angles in which the Rays are there bent are much increased by that +approach; and that the Knife which is nearest any Ray determines which +way the Ray shall be bent, and the other Knife increases the bent. + +_Obs._ 9. When the Rays fell very obliquely upon the Ruler at the +distance of the third Part of an Inch from the Knives, the dark Line +between the first and second Fringe of the Shadow of one Knife, and the +dark Line between the first and second Fringe of the Shadow of the other +knife met with one another, at the distance of the fifth Part of an Inch +from the end of the Light which passed between the Knives at the +concourse of their edges. And therefore the distance of the edges of the +Knives at the meeting of these dark Lines was the 160th Part of an Inch. +For as four Inches to the eighth Part of an Inch, so is any Length of +the edges of the Knives measured from the point of their concourse to +the distance of the edges of the Knives at the end of that Length, and +so is the fifth Part of an Inch to the 160th Part. So then the dark +Lines above-mention'd meet in the middle of the Light which passes +between the Knives where they are distant the 160th Part of an Inch, and +the one half of that Light passes by the edge of one Knife at a distance +not greater than the 320th Part of an Inch, and falling upon the Paper +makes the Fringes of the Shadow of that Knife, and the other half passes +by the edge of the other Knife, at a distance not greater than the 320th +Part of an Inch, and falling upon the Paper makes the Fringes of the +Shadow of the other Knife. But if the Paper be held at a distance from +the Knives greater than the third Part of an Inch, the dark Lines +above-mention'd meet at a greater distance than the fifth Part of an +Inch from the end of the Light which passed between the Knives at the +concourse of their edges; and therefore the Light which falls upon the +Paper where those dark Lines meet passes between the Knives where the +edges are distant above the 160th part of an Inch. + +For at another time, when the two Knives were distant eight Feet and +five Inches from the little hole in the Window, made with a small Pin as +above, the Light which fell upon the Paper where the aforesaid dark +lines met, passed between the Knives, where the distance between their +edges was as in the following Table, when the distance of the Paper from +the Knives was also as follows. + +-----------------------------+------------------------------ + | Distances between the edges + Distances of the Paper | of the Knives in millesimal + from the Knives in Inches. | parts of an Inch. +-----------------------------+------------------------------ + 1-1/2. | 0'012 + 3-1/3. | 0'020 + 8-3/5. | 0'034 + 32. | 0'057 + 96. | 0'081 + 131. | 0'087 +_____________________________|______________________________ + +And hence I gather, that the Light which makes the Fringes upon the +Paper is not the same Light at all distances of the Paper from the +Knives, but when the Paper is held near the Knives, the Fringes are made +by Light which passes by the edges of the Knives at a less distance, and +is more bent than when the Paper is held at a greater distance from the +Knives. + +[Illustration: FIG. 3.] + +_Obs._ 10. When the Fringes of the Shadows of the Knives fell +perpendicularly upon a Paper at a great distance from the Knives, they +were in the form of Hyperbola's, and their Dimensions were as follows. +Let CA, CB [in _Fig._ 3.] represent Lines drawn upon the Paper parallel +to the edges of the Knives, and between which all the Light would fall, +if it passed between the edges of the Knives without inflexion; DE a +Right Line drawn through C making the Angles ACD, BCE, equal to one +another, and terminating all the Light which falls upon the Paper from +the point where the edges of the Knives meet; _eis_, _fkt_, and _glv_, +three hyperbolical Lines representing the Terminus of the Shadow of one +of the Knives, the dark Line between the first and second Fringes of +that Shadow, and the dark Line between the second and third Fringes of +the same Shadow; _xip_, _ykq_, and _zlr_, three other hyperbolical Lines +representing the Terminus of the Shadow of the other Knife, the dark +Line between the first and second Fringes of that Shadow, and the dark +line between the second and third Fringes of the same Shadow. And +conceive that these three Hyperbola's are like and equal to the former +three, and cross them in the points _i_, _k_, and _l_, and that the +Shadows of the Knives are terminated and distinguish'd from the first +luminous Fringes by the lines _eis_ and _xip_, until the meeting and +crossing of the Fringes, and then those lines cross the Fringes in the +form of dark lines, terminating the first luminous Fringes within side, +and distinguishing them from another Light which begins to appear at +_i_, and illuminates all the triangular space _ip_DE_s_ comprehended by +these dark lines, and the right line DE. Of these Hyperbola's one +Asymptote is the line DE, and their other Asymptotes are parallel to the +lines CA and CB. Let _rv_ represent a line drawn any where upon the +Paper parallel to the Asymptote DE, and let this line cross the right +lines AC in _m_, and BC in _n_, and the six dark hyperbolical lines in +_p_, _q_, _r_; _s_, _t_, _v_; and by measuring the distances _ps_, _qt_, +_rv_, and thence collecting the lengths of the Ordinates _np_, _nq_, +_nr_ or _ms_, _mt_, _mv_, and doing this at several distances of the +line _rv_ from the Asymptote DD, you may find as many points of these +Hyperbola's as you please, and thereby know that these curve lines are +Hyperbola's differing little from the conical Hyperbola. And by +measuring the lines C_i_, C_k_, C_l_, you may find other points of these +Curves. + +For instance; when the Knives were distant from the hole in the Window +ten Feet, and the Paper from the Knives nine Feet, and the Angle +contained by the edges of the Knives to which the Angle ACB is equal, +was subtended by a Chord which was to the Radius as 1 to 32, and the +distance of the line _rv_ from the Asymptote DE was half an Inch: I +measured the lines _ps_, _qt_, _rv_, and found them 0'35, 0'65, 0'98 +Inches respectively; and by adding to their halfs the line 1/2 _mn_, +(which here was the 128th part of an Inch, or 0'0078 Inches,) the Sums +_np_, _nq_, _nr_, were 0'1828, 0'3328, 0'4978 Inches. I measured also +the distances of the brightest parts of the Fringes which run between +_pq_ and _st_, _qr_ and _tv_, and next beyond _r_ and _v_, and found +them 0'5, 0'8, and 1'17 Inches. + +_Obs._ 11. The Sun shining into my darken'd Room through a small round +hole made in a Plate of Lead with a slender Pin, as above; I placed at +the hole a Prism to refract the Light, and form on the opposite Wall the +Spectrum of Colours, described in the third Experiment of the first +Book. And then I found that the Shadows of all Bodies held in the +colour'd Light between the Prism and the Wall, were border'd with +Fringes of the Colour of that Light in which they were held. In the full +red Light they were totally red without any sensible blue or violet, and +in the deep blue Light they were totally blue without any sensible red +or yellow; and so in the green Light they were totally green, excepting +a little yellow and blue, which were mixed in the green Light of the +Prism. And comparing the Fringes made in the several colour'd Lights, I +found that those made in the red Light were largest, those made in the +violet were least, and those made in the green were of a middle bigness. +For the Fringes with which the Shadow of a Man's Hair were bordered, +being measured cross the Shadow at the distance of six Inches from the +Hair, the distance between the middle and most luminous part of the +first or innermost Fringe on one side of the Shadow, and that of the +like Fringe on the other side of the Shadow, was in the full red Light +1/37-1/4 of an Inch, and in the full violet 7/46. And the like distance +between the middle and most luminous parts of the second Fringes on +either side the Shadow was in the full red Light 1/22, and in the violet +1/27 of an Inch. And these distances of the Fringes held the same +proportion at all distances from the Hair without any sensible +variation. + +So then the Rays which made these Fringes in the red Light passed by the +Hair at a greater distance than those did which made the like Fringes in +the violet; and therefore the Hair in causing these Fringes acted alike +upon the red Light or least refrangible Rays at a greater distance, and +upon the violet or most refrangible Rays at a less distance, and by +those actions disposed the red Light into Larger Fringes, and the violet +into smaller, and the Lights of intermediate Colours into Fringes of +intermediate bignesses without changing the Colour of any sort of Light. + +When therefore the Hair in the first and second of these Observations +was held in the white beam of the Sun's Light, and cast a Shadow which +was border'd with three Fringes of coloured Light, those Colours arose +not from any new modifications impress'd upon the Rays of Light by the +Hair, but only from the various inflexions whereby the several Sorts of +Rays were separated from one another, which before separation, by the +mixture of all their Colours, composed the white beam of the Sun's +Light, but whenever separated compose Lights of the several Colours +which they are originally disposed to exhibit. In this 11th Observation, +where the Colours are separated before the Light passes by the Hair, the +least refrangible Rays, which when separated from the rest make red, +were inflected at a greater distance from the Hair, so as to make three +red Fringes at a greater distance from the middle of the Shadow of the +Hair; and the most refrangible Rays which when separated make violet, +were inflected at a less distance from the Hair, so as to make three +violet Fringes at a less distance from the middle of the Shadow of the +Hair. And other Rays of intermediate degrees of Refrangibility were +inflected at intermediate distances from the Hair, so as to make Fringes +of intermediate Colours at intermediate distances from the middle of the +Shadow of the Hair. And in the second Observation, where all the Colours +are mix'd in the white Light which passes by the Hair, these Colours are +separated by the various inflexions of the Rays, and the Fringes which +they make appear all together, and the innermost Fringes being +contiguous make one broad Fringe composed of all the Colours in due +order, the violet lying on the inside of the Fringe next the Shadow, the +red on the outside farthest from the Shadow, and the blue, green, and +yellow, in the middle. And, in like manner, the middlemost Fringes of +all the Colours lying in order, and being contiguous, make another broad +Fringe composed of all the Colours; and the outmost Fringes of all the +Colours lying in order, and being contiguous, make a third broad Fringe +composed of all the Colours. These are the three Fringes of colour'd +Light with which the Shadows of all Bodies are border'd in the second +Observation. + +When I made the foregoing Observations, I design'd to repeat most of +them with more care and exactness, and to make some new ones for +determining the manner how the Rays of Light are bent in their passage +by Bodies, for making the Fringes of Colours with the dark lines between +them. But I was then interrupted, and cannot now think of taking these +things into farther Consideration. And since I have not finish'd this +part of my Design, I shall conclude with proposing only some Queries, in +order to a farther search to be made by others. + +_Query_ 1. Do not Bodies act upon Light at a distance, and by their +action bend its Rays; and is not this action (_cæteris paribus_) +strongest at the least distance? + +_Qu._ 2. Do not the Rays which differ in Refrangibility differ also in +Flexibity; and are they not by their different Inflexions separated from +one another, so as after separation to make the Colours in the three +Fringes above described? And after what manner are they inflected to +make those Fringes? + +_Qu._ 3. Are not the Rays of Light in passing by the edges and sides of +Bodies, bent several times backwards and forwards, with a motion like +that of an Eel? And do not the three Fringes of colour'd Light +above-mention'd arise from three such bendings? + +_Qu._ 4. Do not the Rays of Light which fall upon Bodies, and are +reflected or refracted, begin to bend before they arrive at the Bodies; +and are they not reflected, refracted, and inflected, by one and the +same Principle, acting variously in various Circumstances? + +_Qu._ 5. Do not Bodies and Light act mutually upon one another; that is +to say, Bodies upon Light in emitting, reflecting, refracting and +inflecting it, and Light upon Bodies for heating them, and putting their +parts into a vibrating motion wherein heat consists? + +_Qu._ 6. Do not black Bodies conceive heat more easily from Light than +those of other Colours do, by reason that the Light falling on them is +not reflected outwards, but enters the Bodies, and is often reflected +and refracted within them, until it be stifled and lost? + +_Qu._ 7. Is not the strength and vigor of the action between Light and +sulphureous Bodies observed above, one reason why sulphureous Bodies +take fire more readily, and burn more vehemently than other Bodies do? + +_Qu._ 8. Do not all fix'd Bodies, when heated beyond a certain degree, +emit Light and shine; and is not this Emission perform'd by the +vibrating motions of their parts? And do not all Bodies which abound +with terrestrial parts, and especially with sulphureous ones, emit Light +as often as those parts are sufficiently agitated; whether that +agitation be made by Heat, or by Friction, or Percussion, or +Putrefaction, or by any vital Motion, or any other Cause? As for +instance; Sea-Water in a raging Storm; Quick-silver agitated in _vacuo_; +the Back of a Cat, or Neck of a Horse, obliquely struck or rubbed in a +dark place; Wood, Flesh and Fish while they putrefy; Vapours arising +from putrefy'd Waters, usually call'd _Ignes Fatui_; Stacks of moist Hay +or Corn growing hot by fermentation; Glow-worms and the Eyes of some +Animals by vital Motions; the vulgar _Phosphorus_ agitated by the +attrition of any Body, or by the acid Particles of the Air; Amber and +some Diamonds by striking, pressing or rubbing them; Scrapings of Steel +struck off with a Flint; Iron hammer'd very nimbly till it become so hot +as to kindle Sulphur thrown upon it; the Axletrees of Chariots taking +fire by the rapid rotation of the Wheels; and some Liquors mix'd with +one another whose Particles come together with an Impetus, as Oil of +Vitriol distilled from its weight of Nitre, and then mix'd with twice +its weight of Oil of Anniseeds. So also a Globe of Glass about 8 or 10 +Inches in diameter, being put into a Frame where it may be swiftly +turn'd round its Axis, will in turning shine where it rubs against the +palm of ones Hand apply'd to it: And if at the same time a piece of +white Paper or white Cloth, or the end of ones Finger be held at the +distance of about a quarter of an Inch or half an Inch from that part of +the Glass where it is most in motion, the electrick Vapour which is +excited by the friction of the Glass against the Hand, will by dashing +against the white Paper, Cloth or Finger, be put into such an agitation +as to emit Light, and make the white Paper, Cloth or Finger, appear +lucid like a Glowworm; and in rushing out of the Glass will sometimes +push against the finger so as to be felt. And the same things have been +found by rubbing a long and large Cylinder or Glass or Amber with a +Paper held in ones hand, and continuing the friction till the Glass grew +warm. + +_Qu._ 9. Is not Fire a Body heated so hot as to emit Light copiously? +For what else is a red hot Iron than Fire? And what else is a burning +Coal than red hot Wood? + +_Qu._ 10. Is not Flame a Vapour, Fume or Exhalation heated red hot, that +is, so hot as to shine? For Bodies do not flame without emitting a +copious Fume, and this Fume burns in the Flame. The _Ignis Fatuus_ is a +Vapour shining without heat, and is there not the same difference +between this Vapour and Flame, as between rotten Wood shining without +heat and burning Coals of Fire? In distilling hot Spirits, if the Head +of the Still be taken off, the Vapour which ascends out of the Still +will take fire at the Flame of a Candle, and turn into Flame, and the +Flame will run along the Vapour from the Candle to the Still. Some +Bodies heated by Motion, or Fermentation, if the heat grow intense, fume +copiously, and if the heat be great enough the Fumes will shine and +become Flame. Metals in fusion do not flame for want of a copious Fume, +except Spelter, which fumes copiously, and thereby flames. All flaming +Bodies, as Oil, Tallow, Wax, Wood, fossil Coals, Pitch, Sulphur, by +flaming waste and vanish into burning Smoke, which Smoke, if the Flame +be put out, is very thick and visible, and sometimes smells strongly, +but in the Flame loses its smell by burning, and according to the nature +of the Smoke the Flame is of several Colours, as that of Sulphur blue, +that of Copper open'd with sublimate green, that of Tallow yellow, that +of Camphire white. Smoke passing through Flame cannot but grow red hot, +and red hot Smoke can have no other appearance than that of Flame. When +Gun-powder takes fire, it goes away into Flaming Smoke. For the Charcoal +and Sulphur easily take fire, and set fire to the Nitre, and the Spirit +of the Nitre being thereby rarified into Vapour, rushes out with +Explosion much after the manner that the Vapour of Water rushes out of +an Æolipile; the Sulphur also being volatile is converted into Vapour, +and augments the Explosion. And the acid Vapour of the Sulphur (namely +that which distils under a Bell into Oil of Sulphur,) entring violently +into the fix'd Body of the Nitre, sets loose the Spirit of the Nitre, +and excites a great Fermentation, whereby the Heat is farther augmented, +and the fix'd Body of the Nitre is also rarified into Fume, and the +Explosion is thereby made more vehement and quick. For if Salt of Tartar +be mix'd with Gun-powder, and that Mixture be warm'd till it takes fire, +the Explosion will be more violent and quick than that of Gun-powder +alone; which cannot proceed from any other cause than the action of the +Vapour of the Gun-powder upon the Salt of Tartar, whereby that Salt is +rarified. The Explosion of Gun-powder arises therefore from the violent +action whereby all the Mixture being quickly and vehemently heated, is +rarified and converted into Fume and Vapour: which Vapour, by the +violence of that action, becoming so hot as to shine, appears in the +form of Flame. + +_Qu._ 11. Do not great Bodies conserve their heat the longest, their +parts heating one another, and may not great dense and fix'd Bodies, +when heated beyond a certain degree, emit Light so copiously, as by the +Emission and Re-action of its Light, and the Reflexions and Refractions +of its Rays within its Pores to grow still hotter, till it comes to a +certain period of heat, such as is that of the Sun? And are not the Sun +and fix'd Stars great Earths vehemently hot, whose heat is conserved by +the greatness of the Bodies, and the mutual Action and Reaction between +them, and the Light which they emit, and whose parts are kept from +fuming away, not only by their fixity, but also by the vast weight and +density of the Atmospheres incumbent upon them; and very strongly +compressing them, and condensing the Vapours and Exhalations which arise +from them? For if Water be made warm in any pellucid Vessel emptied of +Air, that Water in the _Vacuum_ will bubble and boil as vehemently as it +would in the open Air in a Vessel set upon the Fire till it conceives a +much greater heat. For the weight of the incumbent Atmosphere keeps down +the Vapours, and hinders the Water from boiling, until it grow much +hotter than is requisite to make it boil _in vacuo_. Also a mixture of +Tin and Lead being put upon a red hot Iron _in vacuo_ emits a Fume and +Flame, but the same Mixture in the open Air, by reason of the incumbent +Atmosphere, does not so much as emit any Fume which can be perceived by +Sight. In like manner the great weight of the Atmosphere which lies upon +the Globe of the Sun may hinder Bodies there from rising up and going +away from the Sun in the form of Vapours and Fumes, unless by means of a +far greater heat than that which on the Surface of our Earth would very +easily turn them into Vapours and Fumes. And the same great weight may +condense those Vapours and Exhalations as soon as they shall at any time +begin to ascend from the Sun, and make them presently fall back again +into him, and by that action increase his Heat much after the manner +that in our Earth the Air increases the Heat of a culinary Fire. And the +same weight may hinder the Globe of the Sun from being diminish'd, +unless by the Emission of Light, and a very small quantity of Vapours +and Exhalations. + +_Qu._ 12. Do not the Rays of Light in falling upon the bottom of the Eye +excite Vibrations in the _Tunica Retina_? Which Vibrations, being +propagated along the solid Fibres of the optick Nerves into the Brain, +cause the Sense of seeing. For because dense Bodies conserve their Heat +a long time, and the densest Bodies conserve their Heat the longest, the +Vibrations of their parts are of a lasting nature, and therefore may be +propagated along solid Fibres of uniform dense Matter to a great +distance, for conveying into the Brain the impressions made upon all the +Organs of Sense. For that Motion which can continue long in one and the +same part of a Body, can be propagated a long way from one part to +another, supposing the Body homogeneal, so that the Motion may not be +reflected, refracted, interrupted or disorder'd by any unevenness of the +Body. + +_Qu._ 13. Do not several sorts of Rays make Vibrations of several +bignesses, which according to their bignesses excite Sensations of +several Colours, much after the manner that the Vibrations of the Air, +according to their several bignesses excite Sensations of several +Sounds? And particularly do not the most refrangible Rays excite the +shortest Vibrations for making a Sensation of deep violet, the least +refrangible the largest for making a Sensation of deep red, and the +several intermediate sorts of Rays, Vibrations of several intermediate +bignesses to make Sensations of the several intermediate Colours? + +_Qu._ 14. May not the harmony and discord of Colours arise from the +proportions of the Vibrations propagated through the Fibres of the +optick Nerves into the Brain, as the harmony and discord of Sounds arise +from the proportions of the Vibrations of the Air? For some Colours, if +they be view'd together, are agreeable to one another, as those of Gold +and Indigo, and others disagree. + +_Qu._ 15. Are not the Species of Objects seen with both Eyes united +where the optick Nerves meet before they come into the Brain, the Fibres +on the right side of both Nerves uniting there, and after union going +thence into the Brain in the Nerve which is on the right side of the +Head, and the Fibres on the left side of both Nerves uniting in the same +place, and after union going into the Brain in the Nerve which is on the +left side of the Head, and these two Nerves meeting in the Brain in such +a manner that their Fibres make but one entire Species or Picture, half +of which on the right side of the Sensorium comes from the right side of +both Eyes through the right side of both optick Nerves to the place +where the Nerves meet, and from thence on the right side of the Head +into the Brain, and the other half on the left side of the Sensorium +comes in like manner from the left side of both Eyes. For the optick +Nerves of such Animals as look the same way with both Eyes (as of Men, +Dogs, Sheep, Oxen, &c.) meet before they come into the Brain, but the +optick Nerves of such Animals as do not look the same way with both Eyes +(as of Fishes, and of the Chameleon,) do not meet, if I am rightly +inform'd. + +_Qu._ 16. When a Man in the dark presses either corner of his Eye with +his Finger, and turns his Eye away from his Finger, he will see a Circle +of Colours like those in the Feather of a Peacock's Tail. If the Eye and +the Finger remain quiet these Colours vanish in a second Minute of Time, +but if the Finger be moved with a quavering Motion they appear again. Do +not these Colours arise from such Motions excited in the bottom of the +Eye by the Pressure and Motion of the Finger, as, at other times are +excited there by Light for causing Vision? And do not the Motions once +excited continue about a Second of Time before they cease? And when a +Man by a stroke upon his Eye sees a flash of Light, are not the like +Motions excited in the _Retina_ by the stroke? And when a Coal of Fire +moved nimbly in the circumference of a Circle, makes the whole +circumference appear like a Circle of Fire; is it not because the +Motions excited in the bottom of the Eye by the Rays of Light are of a +lasting nature, and continue till the Coal of Fire in going round +returns to its former place? And considering the lastingness of the +Motions excited in the bottom of the Eye by Light, are they not of a +vibrating nature? + +_Qu._ 17. If a stone be thrown into stagnating Water, the Waves excited +thereby continue some time to arise in the place where the Stone fell +into the Water, and are propagated from thence in concentrick Circles +upon the Surface of the Water to great distances. And the Vibrations or +Tremors excited in the Air by percussion, continue a little time to move +from the place of percussion in concentrick Spheres to great distances. +And in like manner, when a Ray of Light falls upon the Surface of any +pellucid Body, and is there refracted or reflected, may not Waves of +Vibrations, or Tremors, be thereby excited in the refracting or +reflecting Medium at the point of Incidence, and continue to arise +there, and to be propagated from thence as long as they continue to +arise and be propagated, when they are excited in the bottom of the Eye +by the Pressure or Motion of the Finger, or by the Light which comes +from the Coal of Fire in the Experiments above-mention'd? and are not +these Vibrations propagated from the point of Incidence to great +distances? And do they not overtake the Rays of Light, and by overtaking +them successively, do they not put them into the Fits of easy Reflexion +and easy Transmission described above? For if the Rays endeavour to +recede from the densest part of the Vibration, they may be alternately +accelerated and retarded by the Vibrations overtaking them. + +_Qu._ 18. If in two large tall cylindrical Vessels of Glass inverted, +two little Thermometers be suspended so as not to touch the Vessels, and +the Air be drawn out of one of these Vessels, and these Vessels thus +prepared be carried out of a cold place into a warm one; the Thermometer +_in vacuo_ will grow warm as much, and almost as soon as the Thermometer +which is not _in vacuo_. And when the Vessels are carried back into the +cold place, the Thermometer _in vacuo_ will grow cold almost as soon as +the other Thermometer. Is not the Heat of the warm Room convey'd through +the _Vacuum_ by the Vibrations of a much subtiler Medium than Air, which +after the Air was drawn out remained in the _Vacuum_? And is not this +Medium the same with that Medium by which Light is refracted and +reflected, and by whose Vibrations Light communicates Heat to Bodies, +and is put into Fits of easy Reflexion and easy Transmission? And do not +the Vibrations of this Medium in hot Bodies contribute to the +intenseness and duration of their Heat? And do not hot Bodies +communicate their Heat to contiguous cold ones, by the Vibrations of +this Medium propagated from them into the cold ones? And is not this +Medium exceedingly more rare and subtile than the Air, and exceedingly +more elastick and active? And doth it not readily pervade all Bodies? +And is it not (by its elastick force) expanded through all the Heavens? + +_Qu._ 19. Doth not the Refraction of Light proceed from the different +density of this Æthereal Medium in different places, the Light receding +always from the denser parts of the Medium? And is not the density +thereof greater in free and open Spaces void of Air and other grosser +Bodies, than within the Pores of Water, Glass, Crystal, Gems, and other +compact Bodies? For when Light passes through Glass or Crystal, and +falling very obliquely upon the farther Surface thereof is totally +reflected, the total Reflexion ought to proceed rather from the density +and vigour of the Medium without and beyond the Glass, than from the +rarity and weakness thereof. + +_Qu._ 20. Doth not this Æthereal Medium in passing out of Water, Glass, +Crystal, and other compact and dense Bodies into empty Spaces, grow +denser and denser by degrees, and by that means refract the Rays of +Light not in a point, but by bending them gradually in curve Lines? And +doth not the gradual condensation of this Medium extend to some distance +from the Bodies, and thereby cause the Inflexions of the Rays of Light, +which pass by the edges of dense Bodies, at some distance from the +Bodies? + +_Qu._ 21. Is not this Medium much rarer within the dense Bodies of the +Sun, Stars, Planets and Comets, than in the empty celestial Spaces +between them? And in passing from them to great distances, doth it not +grow denser and denser perpetually, and thereby cause the gravity of +those great Bodies towards one another, and of their parts towards the +Bodies; every Body endeavouring to go from the denser parts of the +Medium towards the rarer? For if this Medium be rarer within the Sun's +Body than at its Surface, and rarer there than at the hundredth part of +an Inch from its Body, and rarer there than at the fiftieth part of an +Inch from its Body, and rarer there than at the Orb of _Saturn_; I see +no reason why the Increase of density should stop any where, and not +rather be continued through all distances from the Sun to _Saturn_, and +beyond. And though this Increase of density may at great distances be +exceeding slow, yet if the elastick force of this Medium be exceeding +great, it may suffice to impel Bodies from the denser parts of the +Medium towards the rarer, with all that power which we call Gravity. And +that the elastick force of this Medium is exceeding great, may be +gather'd from the swiftness of its Vibrations. Sounds move about 1140 +_English_ Feet in a second Minute of Time, and in seven or eight Minutes +of Time they move about one hundred _English_ Miles. Light moves from +the Sun to us in about seven or eight Minutes of Time, which distance is +about 70,000,000 _English_ Miles, supposing the horizontal Parallax of +the Sun to be about 12´´. And the Vibrations or Pulses of this Medium, +that they may cause the alternate Fits of easy Transmission and easy +Reflexion, must be swifter than Light, and by consequence above 700,000 +times swifter than Sounds. And therefore the elastick force of this +Medium, in proportion to its density, must be above 700000 x 700000 +(that is, above 490,000,000,000) times greater than the elastick force +of the Air is in proportion to its density. For the Velocities of the +Pulses of elastick Mediums are in a subduplicate _Ratio_ of the +Elasticities and the Rarities of the Mediums taken together. + +As Attraction is stronger in small Magnets than in great ones in +proportion to their Bulk, and Gravity is greater in the Surfaces of +small Planets than in those of great ones in proportion to their bulk, +and small Bodies are agitated much more by electric attraction than +great ones; so the smallness of the Rays of Light may contribute very +much to the power of the Agent by which they are refracted. And so if +any one should suppose that _Æther_ (like our Air) may contain Particles +which endeavour to recede from one another (for I do not know what this +_Æther_ is) and that its Particles are exceedingly smaller than those of +Air, or even than those of Light: The exceeding smallness of its +Particles may contribute to the greatness of the force by which those +Particles may recede from one another, and thereby make that Medium +exceedingly more rare and elastick than Air, and by consequence +exceedingly less able to resist the motions of Projectiles, and +exceedingly more able to press upon gross Bodies, by endeavouring to +expand it self. + +_Qu._ 22. May not Planets and Comets, and all gross Bodies, perform +their Motions more freely, and with less resistance in this Æthereal +Medium than in any Fluid, which fills all Space adequately without +leaving any Pores, and by consequence is much denser than Quick-silver +or Gold? And may not its resistance be so small, as to be +inconsiderable? For instance; If this _Æther_ (for so I will call it) +should be supposed 700000 times more elastick than our Air, and above +700000 times more rare; its resistance would be above 600,000,000 times +less than that of Water. And so small a resistance would scarce make any +sensible alteration in the Motions of the Planets in ten thousand +Years. If any one would ask how a Medium can be so rare, let him tell me +how the Air, in the upper parts of the Atmosphere, can be above an +hundred thousand thousand times rarer than Gold. Let him also tell me, +how an electrick Body can by Friction emit an Exhalation so rare and +subtile, and yet so potent, as by its Emission to cause no sensible +Diminution of the weight of the electrick Body, and to be expanded +through a Sphere, whose Diameter is above two Feet, and yet to be able +to agitate and carry up Leaf Copper, or Leaf Gold, at the distance of +above a Foot from the electrick Body? And how the Effluvia of a Magnet +can be so rare and subtile, as to pass through a Plate of Glass without +any Resistance or Diminution of their Force, and yet so potent as to +turn a magnetick Needle beyond the Glass? + +_Qu._ 23. Is not Vision perform'd chiefly by the Vibrations of this +Medium, excited in the bottom of the Eye by the Rays of Light, and +propagated through the solid, pellucid and uniform Capillamenta of the +optick Nerves into the place of Sensation? And is not Hearing perform'd +by the Vibrations either of this or some other Medium, excited in the +auditory Nerves by the Tremors of the Air, and propagated through the +solid, pellucid and uniform Capillamenta of those Nerves into the place +of Sensation? And so of the other Senses. + +_Qu._ 24. Is not Animal Motion perform'd by the Vibrations of this +Medium, excited in the Brain by the power of the Will, and propagated +from thence through the solid, pellucid and uniform Capillamenta of the +Nerves into the Muscles, for contracting and dilating them? I suppose +that the Capillamenta of the Nerves are each of them solid and uniform, +that the vibrating Motion of the Æthereal Medium may be propagated along +them from one end to the other uniformly, and without interruption: For +Obstructions in the Nerves create Palsies. And that they may be +sufficiently uniform, I suppose them to be pellucid when view'd singly, +tho' the Reflexions in their cylindrical Surfaces may make the whole +Nerve (composed of many Capillamenta) appear opake and white. For +opacity arises from reflecting Surfaces, such as may disturb and +interrupt the Motions of this Medium. + +[Sidenote: _See the following Scheme, p. 356._] + +_Qu._ 25. Are there not other original Properties of the Rays of Light, +besides those already described? An instance of another original +Property we have in the Refraction of Island Crystal, described first by +_Erasmus Bartholine_, and afterwards more exactly by _Hugenius_, in his +Book _De la Lumiere_. This Crystal is a pellucid fissile Stone, clear as +Water or Crystal of the Rock, and without Colour; enduring a red Heat +without losing its transparency, and in a very strong Heat calcining +without Fusion. Steep'd a Day or two in Water, it loses its natural +Polish. Being rubb'd on Cloth, it attracts pieces of Straws and other +light things, like Ambar or Glass; and with _Aqua fortis_ it makes an +Ebullition. It seems to be a sort of Talk, and is found in form of an +oblique Parallelopiped, with six parallelogram Sides and eight solid +Angles. The obtuse Angles of the Parallelograms are each of them 101 +Degrees and 52 Minutes; the acute ones 78 Degrees and 8 Minutes. Two of +the solid Angles opposite to one another, as C and E, are compassed each +of them with three of these obtuse Angles, and each of the other six +with one obtuse and two acute ones. It cleaves easily in planes parallel +to any of its Sides, and not in any other Planes. It cleaves with a +glossy polite Surface not perfectly plane, but with some little +unevenness. It is easily scratch'd, and by reason of its softness it +takes a Polish very difficultly. It polishes better upon polish'd +Looking-glass than upon Metal, and perhaps better upon Pitch, Leather or +Parchment. Afterwards it must be rubb'd with a little Oil or white of an +Egg, to fill up its Scratches; whereby it will become very transparent +and polite. But for several Experiments, it is not necessary to polish +it. If a piece of this crystalline Stone be laid upon a Book, every +Letter of the Book seen through it will appear double, by means of a +double Refraction. And if any beam of Light falls either +perpendicularly, or in any oblique Angle upon any Surface of this +Crystal, it becomes divided into two beams by means of the same double +Refraction. Which beams are of the same Colour with the incident beam of +Light, and seem equal to one another in the quantity of their Light, or +very nearly equal. One of these Refractions is perform'd by the usual +Rule of Opticks, the Sine of Incidence out of Air into this Crystal +being to the Sine of Refraction, as five to three. The other +Refraction, which may be called the unusual Refraction, is perform'd by +the following Rule. + +[Illustration: FIG. 4.] + +Let ADBC represent the refracting Surface of the Crystal, C the biggest +solid Angle at that Surface, GEHF the opposite Surface, and CK a +perpendicular on that Surface. This perpendicular makes with the edge of +the Crystal CF, an Angle of 19 Degr. 3'. Join KF, and in it take KL, so +that the Angle KCL be 6 Degr. 40'. and the Angle LCF 12 Degr. 23'. And +if ST represent any beam of Light incident at T in any Angle upon the +refracting Surface ADBC, let TV be the refracted beam determin'd by the +given Portion of the Sines 5 to 3, according to the usual Rule of +Opticks. Draw VX parallel and equal to KL. Draw it the same way from V +in which L lieth from K; and joining TX, this line TX shall be the other +refracted beam carried from T to X, by the unusual Refraction. + +If therefore the incident beam ST be perpendicular to the refracting +Surface, the two beams TV and TX, into which it shall become divided, +shall be parallel to the lines CK and CL; one of those beams going +through the Crystal perpendicularly, as it ought to do by the usual Laws +of Opticks, and the other TX by an unusual Refraction diverging from the +perpendicular, and making with it an Angle VTX of about 6-2/3 Degrees, +as is found by Experience. And hence, the Plane VTX, and such like +Planes which are parallel to the Plane CFK, may be called the Planes of +perpendicular Refraction. And the Coast towards which the lines KL and +VX are drawn, may be call'd the Coast of unusual Refraction. + +In like manner Crystal of the Rock has a double Refraction: But the +difference of the two Refractions is not so great and manifest as in +Island Crystal. + +When the beam ST incident on Island Crystal is divided into two beams TV +and TX, and these two beams arrive at the farther Surface of the Glass; +the beam TV, which was refracted at the first Surface after the usual +manner, shall be again refracted entirely after the usual manner at the +second Surface; and the beam TX, which was refracted after the unusual +manner in the first Surface, shall be again refracted entirely after the +unusual manner in the second Surface; so that both these beams shall +emerge out of the second Surface in lines parallel to the first incident +beam ST. + +And if two pieces of Island Crystal be placed one after another, in such +manner that all the Surfaces of the latter be parallel to all the +corresponding Surfaces of the former: The Rays which are refracted after +the usual manner in the first Surface of the first Crystal, shall be +refracted after the usual manner in all the following Surfaces; and the +Rays which are refracted after the unusual manner in the first Surface, +shall be refracted after the unusual manner in all the following +Surfaces. And the same thing happens, though the Surfaces of the +Crystals be any ways inclined to one another, provided that their Planes +of perpendicular Refraction be parallel to one another. + +And therefore there is an original difference in the Rays of Light, by +means of which some Rays are in this Experiment constantly refracted +after the usual manner, and others constantly after the unusual manner: +For if the difference be not original, but arises from new Modifications +impress'd on the Rays at their first Refraction, it would be alter'd by +new Modifications in the three following Refractions; whereas it suffers +no alteration, but is constant, and has the same effect upon the Rays in +all the Refractions. The unusual Refraction is therefore perform'd by an +original property of the Rays. And it remains to be enquired, whether +the Rays have not more original Properties than are yet discover'd. + +_Qu._ 26. Have not the Rays of Light several sides, endued with several +original Properties? For if the Planes of perpendicular Refraction of +the second Crystal be at right Angles with the Planes of perpendicular +Refraction of the first Crystal, the Rays which are refracted after the +usual manner in passing through the first Crystal, will be all of them +refracted after the unusual manner in passing through the second +Crystal; and the Rays which are refracted after the unusual manner in +passing through the first Crystal, will be all of them refracted after +the usual manner in passing through the second Crystal. And therefore +there are not two sorts of Rays differing in their nature from one +another, one of which is constantly and in all Positions refracted after +the usual manner, and the other constantly and in all Positions after +the unusual manner. The difference between the two sorts of Rays in the +Experiment mention'd in the 25th Question, was only in the Positions of +the Sides of the Rays to the Planes of perpendicular Refraction. For one +and the same Ray is here refracted sometimes after the usual, and +sometimes after the unusual manner, according to the Position which its +Sides have to the Crystals. If the Sides of the Ray are posited the same +way to both Crystals, it is refracted after the same manner in them +both: But if that side of the Ray which looks towards the Coast of the +unusual Refraction of the first Crystal, be 90 Degrees from that side of +the same Ray which looks toward the Coast of the unusual Refraction of +the second Crystal, (which may be effected by varying the Position of +the second Crystal to the first, and by consequence to the Rays of +Light,) the Ray shall be refracted after several manners in the several +Crystals. There is nothing more required to determine whether the Rays +of Light which fall upon the second Crystal shall be refracted after +the usual or after the unusual manner, but to turn about this Crystal, +so that the Coast of this Crystal's unusual Refraction may be on this or +on that side of the Ray. And therefore every Ray may be consider'd as +having four Sides or Quarters, two of which opposite to one another +incline the Ray to be refracted after the unusual manner, as often as +either of them are turn'd towards the Coast of unusual Refraction; and +the other two, whenever either of them are turn'd towards the Coast of +unusual Refraction, do not incline it to be otherwise refracted than +after the usual manner. The two first may therefore be call'd the Sides +of unusual Refraction. And since these Dispositions were in the Rays +before their Incidence on the second, third, and fourth Surfaces of the +two Crystals, and suffered no alteration (so far as appears,) by the +Refraction of the Rays in their passage through those Surfaces, and the +Rays were refracted by the same Laws in all the four Surfaces; it +appears that those Dispositions were in the Rays originally, and +suffer'd no alteration by the first Refraction, and that by means of +those Dispositions the Rays were refracted at their Incidence on the +first Surface of the first Crystal, some of them after the usual, and +some of them after the unusual manner, accordingly as their Sides of +unusual Refraction were then turn'd towards the Coast of the unusual +Refraction of that Crystal, or sideways from it. + +Every Ray of Light has therefore two opposite Sides, originally endued +with a Property on which the unusual Refraction depends, and the other +two opposite Sides not endued with that Property. And it remains to be +enquired, whether there are not more Properties of Light by which the +Sides of the Rays differ, and are distinguished from one another. + +In explaining the difference of the Sides of the Rays above mention'd, I +have supposed that the Rays fall perpendicularly on the first Crystal. +But if they fall obliquely on it, the Success is the same. Those Rays +which are refracted after the usual manner in the first Crystal, will be +refracted after the unusual manner in the second Crystal, supposing the +Planes of perpendicular Refraction to be at right Angles with one +another, as above; and on the contrary. + +If the Planes of the perpendicular Refraction of the two Crystals be +neither parallel nor perpendicular to one another, but contain an acute +Angle: The two beams of Light which emerge out of the first Crystal, +will be each of them divided into two more at their Incidence on the +second Crystal. For in this case the Rays in each of the two beams will +some of them have their Sides of unusual Refraction, and some of them +their other Sides turn'd towards the Coast of the unusual Refraction of +the second Crystal. + +_Qu._ 27. Are not all Hypotheses erroneous which have hitherto been +invented for explaining the Phænomena of Light, by new Modifications of +the Rays? For those Phænomena depend not upon new Modifications, as has +been supposed, but upon the original and unchangeable Properties of the +Rays. + +_Qu._ 28. Are not all Hypotheses erroneous, in which Light is supposed +to consist in Pression or Motion, propagated through a fluid Medium? For +in all these Hypotheses the Phænomena of Light have been hitherto +explain'd by supposing that they arise from new Modifications of the +Rays; which is an erroneous Supposition. + +If Light consisted only in Pression propagated without actual Motion, it +would not be able to agitate and heat the Bodies which refract and +reflect it. If it consisted in Motion propagated to all distances in an +instant, it would require an infinite force every moment, in every +shining Particle, to generate that Motion. And if it consisted in +Pression or Motion, propagated either in an instant or in time, it would +bend into the Shadow. For Pression or Motion cannot be propagated in a +Fluid in right Lines, beyond an Obstacle which stops part of the Motion, +but will bend and spread every way into the quiescent Medium which lies +beyond the Obstacle. Gravity tends downwards, but the Pressure of Water +arising from Gravity tends every way with equal Force, and is propagated +as readily, and with as much force sideways as downwards, and through +crooked passages as through strait ones. The Waves on the Surface of +stagnating Water, passing by the sides of a broad Obstacle which stops +part of them, bend afterwards and dilate themselves gradually into the +quiet Water behind the Obstacle. The Waves, Pulses or Vibrations of the +Air, wherein Sounds consist, bend manifestly, though not so much as the +Waves of Water. For a Bell or a Cannon may be heard beyond a Hill which +intercepts the sight of the sounding Body, and Sounds are propagated as +readily through crooked Pipes as through streight ones. But Light is +never known to follow crooked Passages nor to bend into the Shadow. For +the fix'd Stars by the Interposition of any of the Planets cease to be +seen. And so do the Parts of the Sun by the Interposition of the Moon, +_Mercury_ or _Venus_. The Rays which pass very near to the edges of any +Body, are bent a little by the action of the Body, as we shew'd above; +but this bending is not towards but from the Shadow, and is perform'd +only in the passage of the Ray by the Body, and at a very small distance +from it. So soon as the Ray is past the Body, it goes right on. + +[Sidenote: _Mais pour dire comment cela se fait, je n'ay rien trove +jusqu' ici qui me satisfasse._ C. H. de la lumiere, c. 5, p. 91.] + +To explain the unusual Refraction of Island Crystal by Pression or +Motion propagated, has not hitherto been attempted (to my knowledge) +except by _Huygens_, who for that end supposed two several vibrating +Mediums within that Crystal. But when he tried the Refractions in two +successive pieces of that Crystal, and found them such as is mention'd +above; he confessed himself at a loss for explaining them. For Pressions +or Motions, propagated from a shining Body through an uniform Medium, +must be on all sides alike; whereas by those Experiments it appears, +that the Rays of Light have different Properties in their different +Sides. He suspected that the Pulses of _Æther_ in passing through the +first Crystal might receive certain new Modifications, which might +determine them to be propagated in this or that Medium within the +second Crystal, according to the Position of that Crystal. But what +Modifications those might be he could not say, nor think of any thing +satisfactory in that Point. And if he had known that the unusual +Refraction depends not on new Modifications, but on the original and +unchangeable Dispositions of the Rays, he would have found it as +difficult to explain how those Dispositions which he supposed to be +impress'd on the Rays by the first Crystal, could be in them before +their Incidence on that Crystal, and in general, how all Rays emitted by +shining Bodies, can have those Dispositions in them from the beginning. +To me, at least, this seems inexplicable, if Light be nothing else than +Pression or Motion propagated through _Æther_. + +And it is as difficult to explain by these Hypotheses, how Rays can be +alternately in Fits of easy Reflexion and easy Transmission; unless +perhaps one might suppose that there are in all Space two Æthereal +vibrating Mediums, and that the Vibrations of one of them constitute +Light, and the Vibrations of the other are swifter, and as often as they +overtake the Vibrations of the first, put them into those Fits. But how +two _Æthers_ can be diffused through all Space, one of which acts upon +the other, and by consequence is re-acted upon, without retarding, +shattering, dispersing and confounding one anothers Motions, is +inconceivable. And against filling the Heavens with fluid Mediums, +unless they be exceeding rare, a great Objection arises from the regular +and very lasting Motions of the Planets and Comets in all manner of +Courses through the Heavens. For thence it is manifest, that the Heavens +are void of all sensible Resistance, and by consequence of all sensible +Matter. + +For the resisting Power of fluid Mediums arises partly from the +Attrition of the Parts of the Medium, and partly from the _Vis inertiæ_ +of the Matter. That part of the Resistance of a spherical Body which +arises from the Attrition of the Parts of the Medium is very nearly as +the Diameter, or, at the most, as the _Factum_ of the Diameter, and the +Velocity of the spherical Body together. And that part of the Resistance +which arises from the _Vis inertiæ_ of the Matter, is as the Square of +that _Factum_. And by this difference the two sorts of Resistance may be +distinguish'd from one another in any Medium; and these being +distinguish'd, it will be found that almost all the Resistance of Bodies +of a competent Magnitude moving in Air, Water, Quick-silver, and such +like Fluids with a competent Velocity, arises from the _Vis inertiæ_ of +the Parts of the Fluid. + +Now that part of the resisting Power of any Medium which arises from the +Tenacity, Friction or Attrition of the Parts of the Medium, may be +diminish'd by dividing the Matter into smaller Parts, and making the +Parts more smooth and slippery: But that part of the Resistance which +arises from the _Vis inertiæ_, is proportional to the Density of the +Matter, and cannot be diminish'd by dividing the Matter into smaller +Parts, nor by any other means than by decreasing the Density of the +Medium. And for these Reasons the Density of fluid Mediums is very +nearly proportional to their Resistance. Liquors which differ not much +in Density, as Water, Spirit of Wine, Spirit of Turpentine, hot Oil, +differ not much in Resistance. Water is thirteen or fourteen times +lighter than Quick-silver and by consequence thirteen or fourteen times +rarer, and its Resistance is less than that of Quick-silver in the same +Proportion, or thereabouts, as I have found by Experiments made with +Pendulums. The open Air in which we breathe is eight or nine hundred +times lighter than Water, and by consequence eight or nine hundred times +rarer, and accordingly its Resistance is less than that of Water in the +same Proportion, or thereabouts; as I have also found by Experiments +made with Pendulums. And in thinner Air the Resistance is still less, +and at length, by ratifying the Air, becomes insensible. For small +Feathers falling in the open Air meet with great Resistance, but in a +tall Glass well emptied of Air, they fall as fast as Lead or Gold, as I +have seen tried several times. Whence the Resistance seems still to +decrease in proportion to the Density of the Fluid. For I do not find by +any Experiments, that Bodies moving in Quick-silver, Water or Air, meet +with any other sensible Resistance than what arises from the Density and +Tenacity of those sensible Fluids, as they would do if the Pores of +those Fluids, and all other Spaces, were filled with a dense and +subtile Fluid. Now if the Resistance in a Vessel well emptied of Air, +was but an hundred times less than in the open Air, it would be about a +million of times less than in Quick-silver. But it seems to be much less +in such a Vessel, and still much less in the Heavens, at the height of +three or four hundred Miles from the Earth, or above. For Mr. _Boyle_ +has shew'd that Air may be rarified above ten thousand times in Vessels +of Glass; and the Heavens are much emptier of Air than any _Vacuum_ we +can make below. For since the Air is compress'd by the Weight of the +incumbent Atmosphere, and the Density of Air is proportional to the +Force compressing it, it follows by Computation, that at the height of +about seven and a half _English_ Miles from the Earth, the Air is four +times rarer than at the Surface of the Earth; and at the height of 15 +Miles it is sixteen times rarer than that at the Surface of the Earth; +and at the height of 22-1/2, 30, or 38 Miles, it is respectively 64, +256, or 1024 times rarer, or thereabouts; and at the height of 76, 152, +228 Miles, it is about 1000000, 1000000000000, or 1000000000000000000 +times rarer; and so on. + +Heat promotes Fluidity very much by diminishing the Tenacity of Bodies. +It makes many Bodies fluid which are not fluid in cold, and increases +the Fluidity of tenacious Liquids, as of Oil, Balsam, and Honey, and +thereby decreases their Resistance. But it decreases not the Resistance +of Water considerably, as it would do if any considerable part of the +Resistance of Water arose from the Attrition or Tenacity of its Parts. +And therefore the Resistance of Water arises principally and almost +entirely from the _Vis inertiæ_ of its Matter; and by consequence, if +the Heavens were as dense as Water, they would not have much less +Resistance than Water; if as dense as Quick-silver, they would not have +much less Resistance than Quick-silver; if absolutely dense, or full of +Matter without any _Vacuum_, let the Matter be never so subtil and +fluid, they would have a greater Resistance than Quick-silver. A solid +Globe in such a Medium would lose above half its Motion in moving three +times the length of its Diameter, and a Globe not solid (such as are the +Planets,) would be retarded sooner. And therefore to make way for the +regular and lasting Motions of the Planets and Comets, it's necessary to +empty the Heavens of all Matter, except perhaps some very thin Vapours, +Steams, or Effluvia, arising from the Atmospheres of the Earth, Planets, +and Comets, and from such an exceedingly rare Æthereal Medium as we +described above. A dense Fluid can be of no use for explaining the +Phænomena of Nature, the Motions of the Planets and Comets being better +explain'd without it. It serves only to disturb and retard the Motions +of those great Bodies, and make the Frame of Nature languish: And in the +Pores of Bodies, it serves only to stop the vibrating Motions of their +Parts, wherein their Heat and Activity consists. And as it is of no use, +and hinders the Operations of Nature, and makes her languish, so there +is no evidence for its Existence, and therefore it ought to be rejected. +And if it be rejected, the Hypotheses that Light consists in Pression +or Motion, propagated through such a Medium, are rejected with it. + +And for rejecting such a Medium, we have the Authority of those the +oldest and most celebrated Philosophers of _Greece_ and _Phoenicia_, +who made a _Vacuum_, and Atoms, and the Gravity of Atoms, the first +Principles of their Philosophy; tacitly attributing Gravity to some +other Cause than dense Matter. Later Philosophers banish the +Consideration of such a Cause out of natural Philosophy, feigning +Hypotheses for explaining all things mechanically, and referring other +Causes to Metaphysicks: Whereas the main Business of natural Philosophy +is to argue from Phænomena without feigning Hypotheses, and to deduce +Causes from Effects, till we come to the very first Cause, which +certainly is not mechanical; and not only to unfold the Mechanism of the +World, but chiefly to resolve these and such like Questions. What is +there in places almost empty of Matter, and whence is it that the Sun +and Planets gravitate towards one another, without dense Matter between +them? Whence is it that Nature doth nothing in vain; and whence arises +all that Order and Beauty which we see in the World? To what end are +Comets, and whence is it that Planets move all one and the same way in +Orbs concentrick, while Comets move all manner of ways in Orbs very +excentrick; and what hinders the fix'd Stars from falling upon one +another? How came the Bodies of Animals to be contrived with so much +Art, and for what ends were their several Parts? Was the Eye contrived +without Skill in Opticks, and the Ear without Knowledge of Sounds? How +do the Motions of the Body follow from the Will, and whence is the +Instinct in Animals? Is not the Sensory of Animals that place to which +the sensitive Substance is present, and into which the sensible Species +of Things are carried through the Nerves and Brain, that there they may +be perceived by their immediate presence to that Substance? And these +things being rightly dispatch'd, does it not appear from Phænomena that +there is a Being incorporeal, living, intelligent, omnipresent, who in +infinite Space, as it were in his Sensory, sees the things themselves +intimately, and throughly perceives them, and comprehends them wholly by +their immediate presence to himself: Of which things the Images only +carried through the Organs of Sense into our little Sensoriums, are +there seen and beheld by that which in us perceives and thinks. And +though every true Step made in this Philosophy brings us not immediately +to the Knowledge of the first Cause, yet it brings us nearer to it, and +on that account is to be highly valued. + +_Qu._ 29. Are not the Rays of Light very small Bodies emitted from +shining Substances? For such Bodies will pass through uniform Mediums in +right Lines without bending into the Shadow, which is the Nature of the +Rays of Light. They will also be capable of several Properties, and be +able to conserve their Properties unchanged in passing through several +Mediums, which is another Condition of the Rays of Light. Pellucid +Substances act upon the Rays of Light at a distance in refracting, +reflecting, and inflecting them, and the Rays mutually agitate the Parts +of those Substances at a distance for heating them; and this Action and +Re-action at a distance very much resembles an attractive Force between +Bodies. If Refraction be perform'd by Attraction of the Rays, the Sines +of Incidence must be to the Sines of Refraction in a given Proportion, +as we shew'd in our Principles of Philosophy: And this Rule is true by +Experience. The Rays of Light in going out of Glass into a _Vacuum_, are +bent towards the Glass; and if they fall too obliquely on the _Vacuum_, +they are bent backwards into the Glass, and totally reflected; and this +Reflexion cannot be ascribed to the Resistance of an absolute _Vacuum_, +but must be caused by the Power of the Glass attracting the Rays at +their going out of it into the _Vacuum_, and bringing them back. For if +the farther Surface of the Glass be moisten'd with Water or clear Oil, +or liquid and clear Honey, the Rays which would otherwise be reflected +will go into the Water, Oil, or Honey; and therefore are not reflected +before they arrive at the farther Surface of the Glass, and begin to go +out of it. If they go out of it into the Water, Oil, or Honey, they go +on, because the Attraction of the Glass is almost balanced and rendered +ineffectual by the contrary Attraction of the Liquor. But if they go out +of it into a _Vacuum_ which has no Attraction to balance that of the +Glass, the Attraction of the Glass either bends and refracts them, or +brings them back and reflects them. And this is still more evident by +laying together two Prisms of Glass, or two Object-glasses of very long +Telescopes, the one plane, the other a little convex, and so compressing +them that they do not fully touch, nor are too far asunder. For the +Light which falls upon the farther Surface of the first Glass where the +Interval between the Glasses is not above the ten hundred thousandth +Part of an Inch, will go through that Surface, and through the Air or +_Vacuum_ between the Glasses, and enter into the second Glass, as was +explain'd in the first, fourth, and eighth Observations of the first +Part of the second Book. But, if the second Glass be taken away, the +Light which goes out of the second Surface of the first Glass into the +Air or _Vacuum_, will not go on forwards, but turns back into the first +Glass, and is reflected; and therefore it is drawn back by the Power of +the first Glass, there being nothing else to turn it back. Nothing more +is requisite for producing all the variety of Colours, and degrees of +Refrangibility, than that the Rays of Light be Bodies of different +Sizes, the least of which may take violet the weakest and darkest of the +Colours, and be more easily diverted by refracting Surfaces from the +right Course; and the rest as they are bigger and bigger, may make the +stronger and more lucid Colours, blue, green, yellow, and red, and be +more and more difficultly diverted. Nothing more is requisite for +putting the Rays of Light into Fits of easy Reflexion and easy +Transmission, than that they be small Bodies which by their attractive +Powers, or some other Force, stir up Vibrations in what they act upon, +which Vibrations being swifter than the Rays, overtake them +successively, and agitate them so as by turns to increase and decrease +their Velocities, and thereby put them into those Fits. And lastly, the +unusual Refraction of Island-Crystal looks very much as if it were +perform'd by some kind of attractive virtue lodged in certain Sides both +of the Rays, and of the Particles of the Crystal. For were it not for +some kind of Disposition or Virtue lodged in some Sides of the Particles +of the Crystal, and not in their other Sides, and which inclines and +bends the Rays towards the Coast of unusual Refraction, the Rays which +fall perpendicularly on the Crystal, would not be refracted towards that +Coast rather than towards any other Coast, both at their Incidence and +at their Emergence, so as to emerge perpendicularly by a contrary +Situation of the Coast of unusual Refraction at the second Surface; the +Crystal acting upon the Rays after they have pass'd through it, and are +emerging into the Air; or, if you please, into a _Vacuum_. And since the +Crystal by this Disposition or Virtue does not act upon the Rays, unless +when one of their Sides of unusual Refraction looks towards that Coast, +this argues a Virtue or Disposition in those Sides of the Rays, which +answers to, and sympathizes with that Virtue or Disposition of the +Crystal, as the Poles of two Magnets answer to one another. And as +Magnetism may be intended and remitted, and is found only in the Magnet +and in Iron: So this Virtue of refracting the perpendicular Rays is +greater in Island-Crystal, less in Crystal of the Rock, and is not yet +found in other Bodies. I do not say that this Virtue is magnetical: It +seems to be of another kind. I only say, that whatever it be, it's +difficult to conceive how the Rays of Light, unless they be Bodies, can +have a permanent Virtue in two of their Sides which is not in their +other Sides, and this without any regard to their Position to the Space +or Medium through which they pass. + +What I mean in this Question by a _Vacuum_, and by the Attractions of +the Rays of Light towards Glass or Crystal, may be understood by what +was said in the 18th, 19th, and 20th Questions. + +_Quest._ 30. Are not gross Bodies and Light convertible into one +another, and may not Bodies receive much of their Activity from the +Particles of Light which enter their Composition? For all fix'd Bodies +being heated emit Light so long as they continue sufficiently hot, and +Light mutually stops in Bodies as often as its Rays strike upon their +Parts, as we shew'd above. I know no Body less apt to shine than Water; +and yet Water by frequent Distillations changes into fix'd Earth, as Mr. +_Boyle_ has try'd; and then this Earth being enabled to endure a +sufficient Heat, shines by Heat like other Bodies. + +The changing of Bodies into Light, and Light into Bodies, is very +conformable to the Course of Nature, which seems delighted with +Transmutations. Water, which is a very fluid tasteless Salt, she changes +by Heat into Vapour, which is a sort of Air, and by Cold into Ice, which +is a hard, pellucid, brittle, fusible Stone; and this Stone returns into +Water by Heat, and Vapour returns into Water by Cold. Earth by Heat +becomes Fire, and by Cold returns into Earth. Dense Bodies by +Fermentation rarify into several sorts of Air, and this Air by +Fermentation, and sometimes without it, returns into dense Bodies. +Mercury appears sometimes in the form of a fluid Metal, sometimes in the +form of a hard brittle Metal, sometimes in the form of a corrosive +pellucid Salt call'd Sublimate, sometimes in the form of a tasteless, +pellucid, volatile white Earth, call'd _Mercurius Dulcis_; or in that of +a red opake volatile Earth, call'd Cinnaber; or in that of a red or +white Precipitate, or in that of a fluid Salt; and in Distillation it +turns into Vapour, and being agitated _in Vacuo_, it shines like Fire. +And after all these Changes it returns again into its first form of +Mercury. Eggs grow from insensible Magnitudes, and change into Animals; +Tadpoles into Frogs; and Worms into Flies. All Birds, Beasts and Fishes, +Insects, Trees, and other Vegetables, with their several Parts, grow out +of Water and watry Tinctures and Salts, and by Putrefaction return again +into watry Substances. And Water standing a few Days in the open Air, +yields a Tincture, which (like that of Malt) by standing longer yields a +Sediment and a Spirit, but before Putrefaction is fit Nourishment for +Animals and Vegetables. And among such various and strange +Transmutations, why may not Nature change Bodies into Light, and Light +into Bodies? + +_Quest._ 31. Have not the small Particles of Bodies certain Powers, +Virtues, or Forces, by which they act at a distance, not only upon the +Rays of Light for reflecting, refracting, and inflecting them, but also +upon one another for producing a great Part of the Phænomena of Nature? +For it's well known, that Bodies act one upon another by the Attractions +of Gravity, Magnetism, and Electricity; and these Instances shew the +Tenor and Course of Nature, and make it not improbable but that there +may be more attractive Powers than these. For Nature is very consonant +and conformable to her self. How these Attractions may be perform'd, I +do not here consider. What I call Attraction may be perform'd by +impulse, or by some other means unknown to me. I use that Word here to +signify only in general any Force by which Bodies tend towards one +another, whatsoever be the Cause. For we must learn from the Phænomena +of Nature what Bodies attract one another, and what are the Laws and +Properties of the Attraction, before we enquire the Cause by which the +Attraction is perform'd. The Attractions of Gravity, Magnetism, and +Electricity, reach to very sensible distances, and so have been observed +by vulgar Eyes, and there may be others which reach to so small +distances as hitherto escape Observation; and perhaps electrical +Attraction may reach to such small distances, even without being excited +by Friction. + +For when Salt of Tartar runs _per Deliquium_, is not this done by an +Attraction between the Particles of the Salt of Tartar, and the +Particles of the Water which float in the Air in the form of Vapours? +And why does not common Salt, or Salt-petre, or Vitriol, run _per +Deliquium_, but for want of such an Attraction? Or why does not Salt of +Tartar draw more Water out of the Air than in a certain Proportion to +its quantity, but for want of an attractive Force after it is satiated +with Water? And whence is it but from this attractive Power that Water +which alone distils with a gentle luke-warm Heat, will not distil from +Salt of Tartar without a great Heat? And is it not from the like +attractive Power between the Particles of Oil of Vitriol and the +Particles of Water, that Oil of Vitriol draws to it a good quantity of +Water out of the Air, and after it is satiated draws no more, and in +Distillation lets go the Water very difficultly? And when Water and Oil +of Vitriol poured successively into the same Vessel grow very hot in the +mixing, does not this Heat argue a great Motion in the Parts of the +Liquors? And does not this Motion argue, that the Parts of the two +Liquors in mixing coalesce with Violence, and by consequence rush +towards one another with an accelerated Motion? And when _Aqua fortis_, +or Spirit of Vitriol poured upon Filings of Iron dissolves the Filings +with a great Heat and Ebullition, is not this Heat and Ebullition +effected by a violent Motion of the Parts, and does not that Motion +argue that the acid Parts of the Liquor rush towards the Parts of the +Metal with violence, and run forcibly into its Pores till they get +between its outmost Particles, and the main Mass of the Metal, and +surrounding those Particles loosen them from the main Mass, and set them +at liberty to float off into the Water? And when the acid Particles, +which alone would distil with an easy Heat, will not separate from the +Particles of the Metal without a very violent Heat, does not this +confirm the Attraction between them? + +When Spirit of Vitriol poured upon common Salt or Salt-petre makes an +Ebullition with the Salt, and unites with it, and in Distillation the +Spirit of the common Salt or Salt-petre comes over much easier than it +would do before, and the acid part of the Spirit of Vitriol stays +behind; does not this argue that the fix'd Alcaly of the Salt attracts +the acid Spirit of the Vitriol more strongly than its own Spirit, and +not being able to hold them both, lets go its own? And when Oil of +Vitriol is drawn off from its weight of Nitre, and from both the +Ingredients a compound Spirit of Nitre is distilled, and two parts of +this Spirit are poured on one part of Oil of Cloves or Carraway Seeds, +or of any ponderous Oil of vegetable or animal Substances, or Oil of +Turpentine thicken'd with a little Balsam of Sulphur, and the Liquors +grow so very hot in mixing, as presently to send up a burning Flame; +does not this very great and sudden Heat argue that the two Liquors mix +with violence, and that their Parts in mixing run towards one another +with an accelerated Motion, and clash with the greatest Force? And is it +not for the same reason that well rectified Spirit of Wine poured on the +same compound Spirit flashes; and that the _Pulvis fulminans_, composed +of Sulphur, Nitre, and Salt of Tartar, goes off with a more sudden and +violent Explosion than Gun-powder, the acid Spirits of the Sulphur and +Nitre rushing towards one another, and towards the Salt of Tartar, with +so great a violence, as by the shock to turn the whole at once into +Vapour and Flame? Where the Dissolution is slow, it makes a slow +Ebullition and a gentle Heat; and where it is quicker, it makes a +greater Ebullition with more heat; and where it is done at once, the +Ebullition is contracted into a sudden Blast or violent Explosion, with +a heat equal to that of Fire and Flame. So when a Drachm of the +above-mention'd compound Spirit of Nitre was poured upon half a Drachm +of Oil of Carraway Seeds _in vacuo_, the Mixture immediately made a +flash like Gun-powder, and burst the exhausted Receiver, which was a +Glass six Inches wide, and eight Inches deep. And even the gross Body of +Sulphur powder'd, and with an equal weight of Iron Filings and a little +Water made into Paste, acts upon the Iron, and in five or six hours +grows too hot to be touch'd, and emits a Flame. And by these Experiments +compared with the great quantity of Sulphur with which the Earth +abounds, and the warmth of the interior Parts of the Earth, and hot +Springs, and burning Mountains, and with Damps, mineral Coruscations, +Earthquakes, hot suffocating Exhalations, Hurricanes, and Spouts; we may +learn that sulphureous Steams abound in the Bowels of the Earth and +ferment with Minerals, and sometimes take fire with a sudden Coruscation +and Explosion; and if pent up in subterraneous Caverns, burst the +Caverns with a great shaking of the Earth, as in springing of a Mine. +And then the Vapour generated by the Explosion, expiring through the +Pores of the Earth, feels hot and suffocates, and makes Tempests and +Hurricanes, and sometimes causes the Land to slide, or the Sea to boil, +and carries up the Water thereof in Drops, which by their weight fall +down again in Spouts. Also some sulphureous Steams, at all times when +the Earth is dry, ascending into the Air, ferment there with nitrous +Acids, and sometimes taking fire cause Lightning and Thunder, and fiery +Meteors. For the Air abounds with acid Vapours fit to promote +Fermentations, as appears by the rusting of Iron and Copper in it, the +kindling of Fire by blowing, and the beating of the Heart by means of +Respiration. Now the above-mention'd Motions are so great and violent as +to shew that in Fermentations the Particles of Bodies which almost rest, +are put into new Motions by a very potent Principle, which acts upon +them only when they approach one another, and causes them to meet and +clash with great violence, and grow hot with the motion, and dash one +another into pieces, and vanish into Air, and Vapour, and Flame. + +When Salt of Tartar _per deliquium_, being poured into the Solution of +any Metal, precipitates the Metal and makes it fall down to the bottom +of the Liquor in the form of Mud: Does not this argue that the acid +Particles are attracted more strongly by the Salt of Tartar than by the +Metal, and by the stronger Attraction go from the Metal to the Salt of +Tartar? And so when a Solution of Iron in _Aqua fortis_ dissolves the +_Lapis Calaminaris_, and lets go the Iron, or a Solution of Copper +dissolves Iron immersed in it and lets go the Copper, or a Solution of +Silver dissolves Copper and lets go the Silver, or a Solution of Mercury +in _Aqua fortis_ being poured upon Iron, Copper, Tin, or Lead, dissolves +the Metal and lets go the Mercury; does not this argue that the acid +Particles of the _Aqua fortis_ are attracted more strongly by the _Lapis +Calaminaris_ than by Iron, and more strongly by Iron than by Copper, and +more strongly by Copper than by Silver, and more strongly by Iron, +Copper, Tin, and Lead, than by Mercury? And is it not for the same +reason that Iron requires more _Aqua fortis_ to dissolve it than Copper, +and Copper more than the other Metals; and that of all Metals, Iron is +dissolved most easily, and is most apt to rust; and next after Iron, +Copper? + +When Oil of Vitriol is mix'd with a little Water, or is run _per +deliquium_, and in Distillation the Water ascends difficultly, and +brings over with it some part of the Oil of Vitriol in the form of +Spirit of Vitriol, and this Spirit being poured upon Iron, Copper, or +Salt of Tartar, unites with the Body and lets go the Water; doth not +this shew that the acid Spirit is attracted by the Water, and more +attracted by the fix'd Body than by the Water, and therefore lets go the +Water to close with the fix'd Body? And is it not for the same reason +that the Water and acid Spirits which are mix'd together in Vinegar, +_Aqua fortis_, and Spirit of Salt, cohere and rise together in +Distillation; but if the _Menstruum_ be poured on Salt of Tartar, or on +Lead, or Iron, or any fix'd Body which it can dissolve, the Acid by a +stronger Attraction adheres to the Body, and lets go the Water? And is +it not also from a mutual Attraction that the Spirits of Soot and +Sea-Salt unite and compose the Particles of Sal-armoniac, which are less +volatile than before, because grosser and freer from Water; and that the +Particles of Sal-armoniac in Sublimation carry up the Particles of +Antimony, which will not sublime alone; and that the Particles of +Mercury uniting with the acid Particles of Spirit of Salt compose +Mercury sublimate, and with the Particles of Sulphur, compose Cinnaber; +and that the Particles of Spirit of Wine and Spirit of Urine well +rectified unite, and letting go the Water which dissolved them, compose +a consistent Body; and that in subliming Cinnaber from Salt of Tartar, +or from quick Lime, the Sulphur by a stronger Attraction of the Salt or +Lime lets go the Mercury, and stays with the fix'd Body; and that when +Mercury sublimate is sublimed from Antimony, or from Regulus of +Antimony, the Spirit of Salt lets go the Mercury, and unites with the +antimonial metal which attracts it more strongly, and stays with it till +the Heat be great enough to make them both ascend together, and then +carries up the Metal with it in the form of a very fusible Salt, called +Butter of Antimony, although the Spirit of Salt alone be almost as +volatile as Water, and the Antimony alone as fix'd as Lead? + +When _Aqua fortis_ dissolves Silver and not Gold, and _Aqua regia_ +dissolves Gold and not Silver, may it not be said that _Aqua fortis_ is +subtil enough to penetrate Gold as well as Silver, but wants the +attractive Force to give it Entrance; and that _Aqua regia_ is subtil +enough to penetrate Silver as well as Gold, but wants the attractive +Force to give it Entrance? For _Aqua regia_ is nothing else than _Aqua +fortis_ mix'd with some Spirit of Salt, or with Sal-armoniac; and even +common Salt dissolved in _Aqua fortis_, enables the _Menstruum_ to +dissolve Gold, though the Salt be a gross Body. When therefore Spirit of +Salt precipitates Silver out of _Aqua fortis_, is it not done by +attracting and mixing with the _Aqua fortis_, and not attracting, or +perhaps repelling Silver? And when Water precipitates Antimony out of +the Sublimate of Antimony and Sal-armoniac, or out of Butter of +Antimony, is it not done by its dissolving, mixing with, and weakening +the Sal-armoniac or Spirit of Salt, and its not attracting, or perhaps +repelling the Antimony? And is it not for want of an attractive virtue +between the Parts of Water and Oil, of Quick-silver and Antimony, of +Lead and Iron, that these Substances do not mix; and by a weak +Attraction, that Quick-silver and Copper mix difficultly; and from a +strong one, that Quick-silver and Tin, Antimony and Iron, Water and +Salts, mix readily? And in general, is it not from the same Principle +that Heat congregates homogeneal Bodies, and separates heterogeneal +ones? + +When Arsenick with Soap gives a Regulus, and with Mercury sublimate a +volatile fusible Salt, like Butter of Antimony, doth not this shew that +Arsenick, which is a Substance totally volatile, is compounded of fix'd +and volatile Parts, strongly cohering by a mutual Attraction, so that +the volatile will not ascend without carrying up the fixed? And so, when +an equal weight of Spirit of Wine and Oil of Vitriol are digested +together, and in Distillation yield two fragrant and volatile Spirits +which will not mix with one another, and a fix'd black Earth remains +behind; doth not this shew that Oil of Vitriol is composed of volatile +and fix'd Parts strongly united by Attraction, so as to ascend together +in form of a volatile, acid, fluid Salt, until the Spirit of Wine +attracts and separates the volatile Parts from the fixed? And therefore, +since Oil of Sulphur _per Campanam_ is of the same Nature with Oil of +Vitriol, may it not be inferred, that Sulphur is also a mixture of +volatile and fix'd Parts so strongly cohering by Attraction, as to +ascend together in Sublimation. By dissolving Flowers of Sulphur in Oil +of Turpentine, and distilling the Solution, it is found that Sulphur is +composed of an inflamable thick Oil or fat Bitumen, an acid Salt, a very +fix'd Earth, and a little Metal. The three first were found not much +unequal to one another, the fourth in so small a quantity as scarce to +be worth considering. The acid Salt dissolved in Water, is the same with +Oil of Sulphur _per Campanam_, and abounding much in the Bowels of the +Earth, and particularly in Markasites, unites it self to the other +Ingredients of the Markasite, which are, Bitumen, Iron, Copper, and +Earth, and with them compounds Allum, Vitriol, and Sulphur. With the +Earth alone it compounds Allum; with the Metal alone, or Metal and +Earth together, it compounds Vitriol; and with the Bitumen and Earth it +compounds Sulphur. Whence it comes to pass that Markasites abound with +those three Minerals. And is it not from the mutual Attraction of the +Ingredients that they stick together for compounding these Minerals, and +that the Bitumen carries up the other Ingredients of the Sulphur, which +without it would not sublime? And the same Question may be put +concerning all, or almost all the gross Bodies in Nature. For all the +Parts of Animals and Vegetables are composed of Substances volatile and +fix'd, fluid and solid, as appears by their Analysis; and so are Salts +and Minerals, so far as Chymists have been hitherto able to examine +their Composition. + +When Mercury sublimate is re-sublimed with fresh Mercury, and becomes +_Mercurius Dulcis_, which is a white tasteless Earth scarce dissolvable +in Water, and _Mercurius Dulcis_ re-sublimed with Spirit of Salt returns +into Mercury sublimate; and when Metals corroded with a little acid turn +into rust, which is an Earth tasteless and indissolvable in Water, and +this Earth imbibed with more acid becomes a metallick Salt; and when +some Stones, as Spar of Lead, dissolved in proper _Menstruums_ become +Salts; do not these things shew that Salts are dry Earth and watry Acid +united by Attraction, and that the Earth will not become a Salt without +so much acid as makes it dissolvable in Water? Do not the sharp and +pungent Tastes of Acids arise from the strong Attraction whereby the +acid Particles rush upon and agitate the Particles of the Tongue? And +when Metals are dissolved in acid _Menstruums_, and the Acids in +conjunction with the Metal act after a different manner, so that the +Compound has a different Taste much milder than before, and sometimes a +sweet one; is it not because the Acids adhere to the metallick +Particles, and thereby lose much of their Activity? And if the Acid be +in too small a Proportion to make the Compound dissolvable in Water, +will it not by adhering strongly to the Metal become unactive and lose +its Taste, and the Compound be a tasteless Earth? For such things as are +not dissolvable by the Moisture of the Tongue, act not upon the Taste. + +As Gravity makes the Sea flow round the denser and weightier Parts of +the Globe of the Earth, so the Attraction may make the watry Acid flow +round the denser and compacter Particles of Earth for composing the +Particles of Salt. For otherwise the Acid would not do the Office of a +Medium between the Earth and common Water, for making Salts dissolvable +in the Water; nor would Salt of Tartar readily draw off the Acid from +dissolved Metals, nor Metals the Acid from Mercury. Now, as in the great +Globe of the Earth and Sea, the densest Bodies by their Gravity sink +down in Water, and always endeavour to go towards the Center of the +Globe; so in Particles of Salt, the densest Matter may always endeavour +to approach the Center of the Particle: So that a Particle of Salt may +be compared to a Chaos; being dense, hard, dry, and earthy in the +Center; and rare, soft, moist, and watry in the Circumference. And +hence it seems to be that Salts are of a lasting Nature, being scarce +destroy'd, unless by drawing away their watry Parts by violence, or by +letting them soak into the Pores of the central Earth by a gentle Heat +in Putrefaction, until the Earth be dissolved by the Water, and +separated into smaller Particles, which by reason of their Smallness +make the rotten Compound appear of a black Colour. Hence also it may be, +that the Parts of Animals and Vegetables preserve their several Forms, +and assimilate their Nourishment; the soft and moist Nourishment easily +changing its Texture by a gentle Heat and Motion, till it becomes like +the dense, hard, dry, and durable Earth in the Center of each Particle. +But when the Nourishment grows unfit to be assimilated, or the central +Earth grows too feeble to assimilate it, the Motion ends in Confusion, +Putrefaction, and Death. + +If a very small quantity of any Salt or Vitriol be dissolved in a great +quantity of Water, the Particles of the Salt or Vitriol will not sink to +the bottom, though they be heavier in Specie than the Water, but will +evenly diffuse themselves into all the Water, so as to make it as saline +at the top as at the bottom. And does not this imply that the Parts of +the Salt or Vitriol recede from one another, and endeavour to expand +themselves, and get as far asunder as the quantity of Water in which +they float, will allow? And does not this Endeavour imply that they have +a repulsive Force by which they fly from one another, or at least, that +they attract the Water more strongly than they do one another? For as +all things ascend in Water which are less attracted than Water, by the +gravitating Power of the Earth; so all the Particles of Salt which float +in Water, and are less attracted than Water by any one Particle of Salt, +must recede from that Particle, and give way to the more attracted +Water. + +When any saline Liquor is evaporated to a Cuticle and let cool, the Salt +concretes in regular Figures; which argues, that the Particles of the +Salt before they concreted, floated in the Liquor at equal distances in +rank and file, and by consequence that they acted upon one another by +some Power which at equal distances is equal, at unequal distances +unequal. For by such a Power they will range themselves uniformly, and +without it they will float irregularly, and come together as +irregularly. And since the Particles of Island-Crystal act all the same +way upon the Rays of Light for causing the unusual Refraction, may it +not be supposed that in the Formation of this Crystal, the Particles not +only ranged themselves in rank and file for concreting in regular +Figures, but also by some kind of polar Virtue turned their homogeneal +Sides the same way. + +The Parts of all homogeneal hard Bodies which fully touch one another, +stick together very strongly. And for explaining how this may be, some +have invented hooked Atoms, which is begging the Question; and others +tell us that Bodies are glued together by rest, that is, by an occult +Quality, or rather by nothing; and others, that they stick together by +conspiring Motions, that is, by relative rest amongst themselves. I had +rather infer from their Cohesion, that their Particles attract one +another by some Force, which in immediate Contact is exceeding strong, +at small distances performs the chymical Operations above-mention'd, and +reaches not far from the Particles with any sensible Effect. + +All Bodies seem to be composed of hard Particles: For otherwise Fluids +would not congeal; as Water, Oils, Vinegar, and Spirit or Oil of Vitriol +do by freezing; Mercury by Fumes of Lead; Spirit of Nitre and Mercury, +by dissolving the Mercury and evaporating the Flegm; Spirit of Wine and +Spirit of Urine, by deflegming and mixing them; and Spirit of Urine and +Spirit of Salt, by subliming them together to make Sal-armoniac. Even +the Rays of Light seem to be hard Bodies; for otherwise they would not +retain different Properties in their different Sides. And therefore +Hardness may be reckon'd the Property of all uncompounded Matter. At +least, this seems to be as evident as the universal Impenetrability of +Matter. For all Bodies, so far as Experience reaches, are either hard, +or may be harden'd; and we have no other Evidence of universal +Impenetrability, besides a large Experience without an experimental +Exception. Now if compound Bodies are so very hard as we find some of +them to be, and yet are very porous, and consist of Parts which are only +laid together; the simple Particles which are void of Pores, and were +never yet divided, must be much harder. For such hard Particles being +heaped up together, can scarce touch one another in more than a few +Points, and therefore must be separable by much less Force than is +requisite to break a solid Particle, whose Parts touch in all the Space +between them, without any Pores or Interstices to weaken their Cohesion. +And how such very hard Particles which are only laid together and touch +only in a few Points, can stick together, and that so firmly as they do, +without the assistance of something which causes them to be attracted or +press'd towards one another, is very difficult to conceive. + +The same thing I infer also from the cohering of two polish'd Marbles +_in vacuo_, and from the standing of Quick-silver in the Barometer at +the height of 50, 60 or 70 Inches, or above, when ever it is well-purged +of Air and carefully poured in, so that its Parts be every where +contiguous both to one another and to the Glass. The Atmosphere by its +weight presses the Quick-silver into the Glass, to the height of 29 or +30 Inches. And some other Agent raises it higher, not by pressing it +into the Glass, but by making its Parts stick to the Glass, and to one +another. For upon any discontinuation of Parts, made either by Bubbles +or by shaking the Glass, the whole Mercury falls down to the height of +29 or 30 Inches. + +And of the same kind with these Experiments are those that follow. If +two plane polish'd Plates of Glass (suppose two pieces of a polish'd +Looking-glass) be laid together, so that their sides be parallel and at +a very small distance from one another, and then their lower edges be +dipped into Water, the Water will rise up between them. And the less +the distance of the Glasses is, the greater will be the height to which +the Water will rise. If the distance be about the hundredth part of an +Inch, the Water will rise to the height of about an Inch; and if the +distance be greater or less in any Proportion, the height will be +reciprocally proportional to the distance very nearly. For the +attractive Force of the Glasses is the same, whether the distance +between them be greater or less; and the weight of the Water drawn up is +the same, if the height of it be reciprocally proportional to the +distance of the Glasses. And in like manner, Water ascends between two +Marbles polish'd plane, when their polish'd sides are parallel, and at a +very little distance from one another, And if slender Pipes of Glass be +dipped at one end into stagnating Water, the Water will rise up within +the Pipe, and the height to which it rises will be reciprocally +proportional to the Diameter of the Cavity of the Pipe, and will equal +the height to which it rises between two Planes of Glass, if the +Semi-diameter of the Cavity of the Pipe be equal to the distance between +the Planes, or thereabouts. And these Experiments succeed after the same +manner _in vacuo_ as in the open Air, (as hath been tried before the +Royal Society,) and therefore are not influenced by the Weight or +Pressure of the Atmosphere. + +And if a large Pipe of Glass be filled with sifted Ashes well pressed +together in the Glass, and one end of the Pipe be dipped into stagnating +Water, the Water will rise up slowly in the Ashes, so as in the space +of a Week or Fortnight to reach up within the Glass, to the height of 30 +or 40 Inches above the stagnating Water. And the Water rises up to this +height by the Action only of those Particles of the Ashes which are upon +the Surface of the elevated Water; the Particles which are within the +Water, attracting or repelling it as much downwards as upwards. And +therefore the Action of the Particles is very strong. But the Particles +of the Ashes being not so dense and close together as those of Glass, +their Action is not so strong as that of Glass, which keeps Quick-silver +suspended to the height of 60 or 70 Inches, and therefore acts with a +Force which would keep Water suspended to the height of above 60 Feet. + +By the same Principle, a Sponge sucks in Water, and the Glands in the +Bodies of Animals, according to their several Natures and Dispositions, +suck in various Juices from the Blood. + +If two plane polish'd Plates of Glass three or four Inches broad, and +twenty or twenty five long, be laid one of them parallel to the Horizon, +the other upon the first, so as at one of their ends to touch one +another, and contain an Angle of about 10 or 15 Minutes, and the same be +first moisten'd on their inward sides with a clean Cloth dipp'd into Oil +of Oranges or Spirit of Turpentine, and a Drop or two of the Oil or +Spirit be let fall upon the lower Glass at the other; so soon as the +upper Glass is laid down upon the lower, so as to touch it at one end as +above, and to touch the Drop at the other end, making with the lower +Glass an Angle of about 10 or 15 Minutes; the Drop will begin to move +towards the Concourse of the Glasses, and will continue to move with an +accelerated Motion, till it arrives at that Concourse of the Glasses. +For the two Glasses attract the Drop, and make it run that way towards +which the Attractions incline. And if when the Drop is in motion you +lift up that end of the Glasses where they meet, and towards which the +Drop moves, the Drop will ascend between the Glasses, and therefore is +attracted. And as you lift up the Glasses more and more, the Drop will +ascend slower and slower, and at length rest, being then carried +downward by its Weight, as much as upwards by the Attraction. And by +this means you may know the Force by which the Drop is attracted at all +distances from the Concourse of the Glasses. + +Now by some Experiments of this kind, (made by Mr. _Hauksbee_) it has +been found that the Attraction is almost reciprocally in a duplicate +Proportion of the distance of the middle of the Drop from the Concourse +of the Glasses, _viz._ reciprocally in a simple Proportion, by reason of +the spreading of the Drop, and its touching each Glass in a larger +Surface; and again reciprocally in a simple Proportion, by reason of the +Attractions growing stronger within the same quantity of attracting +Surface. The Attraction therefore within the same quantity of attracting +Surface, is reciprocally as the distance between the Glasses. And +therefore where the distance is exceeding small, the Attraction must be +exceeding great. By the Table in the second Part of the second Book, +wherein the thicknesses of colour'd Plates of Water between two Glasses +are set down, the thickness of the Plate where it appears very black, is +three eighths of the ten hundred thousandth part of an Inch. And where +the Oil of Oranges between the Glasses is of this thickness, the +Attraction collected by the foregoing Rule, seems to be so strong, as +within a Circle of an Inch in diameter, to suffice to hold up a Weight +equal to that of a Cylinder of Water of an Inch in diameter, and two or +three Furlongs in length. And where it is of a less thickness the +Attraction may be proportionally greater, and continue to increase, +until the thickness do not exceed that of a single Particle of the Oil. +There are therefore Agents in Nature able to make the Particles of +Bodies stick together by very strong Attractions. And it is the Business +of experimental Philosophy to find them out. + +Now the smallest Particles of Matter may cohere by the strongest +Attractions, and compose bigger Particles of weaker Virtue; and many of +these may cohere and compose bigger Particles whose Virtue is still +weaker, and so on for divers Successions, until the Progression end in +the biggest Particles on which the Operations in Chymistry, and the +Colours of natural Bodies depend, and which by cohering compose Bodies +of a sensible Magnitude. If the Body is compact, and bends or yields +inward to Pression without any sliding of its Parts, it is hard and +elastick, returning to its Figure with a Force rising from the mutual +Attraction of its Parts. If the Parts slide upon one another, the Body +is malleable or soft. If they slip easily, and are of a fit Size to be +agitated by Heat, and the Heat is big enough to keep them in Agitation, +the Body is fluid; and if it be apt to stick to things, it is humid; and +the Drops of every fluid affect a round Figure by the mutual Attraction +of their Parts, as the Globe of the Earth and Sea affects a round Figure +by the mutual Attraction of its Parts by Gravity. + +Since Metals dissolved in Acids attract but a small quantity of the +Acid, their attractive Force can reach but to a small distance from +them. And as in Algebra, where affirmative Quantities vanish and cease, +there negative ones begin; so in Mechanicks, where Attraction ceases, +there a repulsive Virtue ought to succeed. And that there is such a +Virtue, seems to follow from the Reflexions and Inflexions of the Rays +of Light. For the Rays are repelled by Bodies in both these Cases, +without the immediate Contact of the reflecting or inflecting Body. It +seems also to follow from the Emission of Light; the Ray so soon as it +is shaken off from a shining Body by the vibrating Motion of the Parts +of the Body, and gets beyond the reach of Attraction, being driven away +with exceeding great Velocity. For that Force which is sufficient to +turn it back in Reflexion, may be sufficient to emit it. It seems also +to follow from the Production of Air and Vapour. The Particles when they +are shaken off from Bodies by Heat or Fermentation, so soon as they are +beyond the reach of the Attraction of the Body, receding from it, and +also from one another with great Strength, and keeping at a distance, +so as sometimes to take up above a Million of Times more space than they +did before in the form of a dense Body. Which vast Contraction and +Expansion seems unintelligible, by feigning the Particles of Air to be +springy and ramous, or rolled up like Hoops, or by any other means than +a repulsive Power. The Particles of Fluids which do not cohere too +strongly, and are of such a Smallness as renders them most susceptible +of those Agitations which keep Liquors in a Fluor, are most easily +separated and rarified into Vapour, and in the Language of the Chymists, +they are volatile, rarifying with an easy Heat, and condensing with +Cold. But those which are grosser, and so less susceptible of Agitation, +or cohere by a stronger Attraction, are not separated without a stronger +Heat, or perhaps not without Fermentation. And these last are the Bodies +which Chymists call fix'd, and being rarified by Fermentation, become +true permanent Air; those Particles receding from one another with the +greatest Force, and being most difficultly brought together, which upon +Contact cohere most strongly. And because the Particles of permanent Air +are grosser, and arise from denser Substances than those of Vapours, +thence it is that true Air is more ponderous than Vapour, and that a +moist Atmosphere is lighter than a dry one, quantity for quantity. From +the same repelling Power it seems to be that Flies walk upon the Water +without wetting their Feet; and that the Object-glasses of long +Telescopes lie upon one another without touching; and that dry Powders +are difficultly made to touch one another so as to stick together, +unless by melting them, or wetting them with Water, which by exhaling +may bring them together; and that two polish'd Marbles, which by +immediate Contact stick together, are difficultly brought so close +together as to stick. + +And thus Nature will be very conformable to her self and very simple, +performing all the great Motions of the heavenly Bodies by the +Attraction of Gravity which intercedes those Bodies, and almost all the +small ones of their Particles by some other attractive and repelling +Powers which intercede the Particles. The _Vis inertiæ_ is a passive +Principle by which Bodies persist in their Motion or Rest, receive +Motion in proportion to the Force impressing it, and resist as much as +they are resisted. By this Principle alone there never could have been +any Motion in the World. Some other Principle was necessary for putting +Bodies into Motion; and now they are in Motion, some other Principle is +necessary for conserving the Motion. For from the various Composition of +two Motions, 'tis very certain that there is not always the same +quantity of Motion in the World. For if two Globes joined by a slender +Rod, revolve about their common Center of Gravity with an uniform +Motion, while that Center moves on uniformly in a right Line drawn in +the Plane of their circular Motion; the Sum of the Motions of the two +Globes, as often as the Globes are in the right Line described by their +common Center of Gravity, will be bigger than the Sum of their Motions, +when they are in a Line perpendicular to that right Line. By this +Instance it appears that Motion may be got or lost. But by reason of the +Tenacity of Fluids, and Attrition of their Parts, and the Weakness of +Elasticity in Solids, Motion is much more apt to be lost than got, and +is always upon the Decay. For Bodies which are either absolutely hard, +or so soft as to be void of Elasticity, will not rebound from one +another. Impenetrability makes them only stop. If two equal Bodies meet +directly _in vacuo_, they will by the Laws of Motion stop where they +meet, and lose all their Motion, and remain in rest, unless they be +elastick, and receive new Motion from their Spring. If they have so much +Elasticity as suffices to make them re-bound with a quarter, or half, or +three quarters of the Force with which they come together, they will +lose three quarters, or half, or a quarter of their Motion. And this may +be try'd, by letting two equal Pendulums fall against one another from +equal heights. If the Pendulums be of Lead or soft Clay, they will lose +all or almost all their Motions: If of elastick Bodies they will lose +all but what they recover from their Elasticity. If it be said, that +they can lose no Motion but what they communicate to other Bodies, the +consequence is, that _in vacuo_ they can lose no Motion, but when they +meet they must go on and penetrate one another's Dimensions. If three +equal round Vessels be filled, the one with Water, the other with Oil, +the third with molten Pitch, and the Liquors be stirred about alike to +give them a vortical Motion; the Pitch by its Tenacity will lose its +Motion quickly, the Oil being less tenacious will keep it longer, and +the Water being less tenacious will keep it longest, but yet will lose +it in a short time. Whence it is easy to understand, that if many +contiguous Vortices of molten Pitch were each of them as large as those +which some suppose to revolve about the Sun and fix'd Stars, yet these +and all their Parts would, by their Tenacity and Stiffness, communicate +their Motion to one another till they all rested among themselves. +Vortices of Oil or Water, or some fluider Matter, might continue longer +in Motion; but unless the Matter were void of all Tenacity and Attrition +of Parts, and Communication of Motion, (which is not to be supposed,) +the Motion would constantly decay. Seeing therefore the variety of +Motion which we find in the World is always decreasing, there is a +necessity of conserving and recruiting it by active Principles, such as +are the cause of Gravity, by which Planets and Comets keep their Motions +in their Orbs, and Bodies acquire great Motion in falling; and the cause +of Fermentation, by which the Heart and Blood of Animals are kept in +perpetual Motion and Heat; the inward Parts of the Earth are constantly +warm'd, and in some places grow very hot; Bodies burn and shine, +Mountains take fire, the Caverns of the Earth are blown up, and the Sun +continues violently hot and lucid, and warms all things by his Light. +For we meet with very little Motion in the World, besides what is owing +to these active Principles. And if it were not for these Principles, the +Bodies of the Earth, Planets, Comets, Sun, and all things in them, +would grow cold and freeze, and become inactive Masses; and all +Putrefaction, Generation, Vegetation and Life would cease, and the +Planets and Comets would not remain in their Orbs. + +All these things being consider'd, it seems probable to me, that God in +the Beginning form'd Matter in solid, massy, hard, impenetrable, +moveable Particles, of such Sizes and Figures, and with such other +Properties, and in such Proportion to Space, as most conduced to the End +for which he form'd them; and that these primitive Particles being +Solids, are incomparably harder than any porous Bodies compounded of +them; even so very hard, as never to wear or break in pieces; no +ordinary Power being able to divide what God himself made one in the +first Creation. While the Particles continue entire, they may compose +Bodies of one and the same Nature and Texture in all Ages: But should +they wear away, or break in pieces, the Nature of Things depending on +them, would be changed. Water and Earth, composed of old worn Particles +and Fragments of Particles, would not be of the same Nature and Texture +now, with Water and Earth composed of entire Particles in the Beginning. +And therefore, that Nature may be lasting, the Changes of corporeal +Things are to be placed only in the various Separations and new +Associations and Motions of these permanent Particles; compound Bodies +being apt to break, not in the midst of solid Particles, but where those +Particles are laid together, and only touch in a few Points. + +It seems to me farther, that these Particles have not only a _Vis +inertiæ_, accompanied with such passive Laws of Motion as naturally +result from that Force, but also that they are moved by certain active +Principles, such as is that of Gravity, and that which causes +Fermentation, and the Cohesion of Bodies. These Principles I consider, +not as occult Qualities, supposed to result from the specifick Forms of +Things, but as general Laws of Nature, by which the Things themselves +are form'd; their Truth appearing to us by Phænomena, though their +Causes be not yet discover'd. For these are manifest Qualities, and +their Causes only are occult. And the _Aristotelians_ gave the Name of +occult Qualities, not to manifest Qualities, but to such Qualities only +as they supposed to lie hid in Bodies, and to be the unknown Causes of +manifest Effects: Such as would be the Causes of Gravity, and of +magnetick and electrick Attractions, and of Fermentations, if we should +suppose that these Forces or Actions arose from Qualities unknown to us, +and uncapable of being discovered and made manifest. Such occult +Qualities put a stop to the Improvement of natural Philosophy, and +therefore of late Years have been rejected. To tell us that every +Species of Things is endow'd with an occult specifick Quality by which +it acts and produces manifest Effects, is to tell us nothing: But to +derive two or three general Principles of Motion from Phænomena, and +afterwards to tell us how the Properties and Actions of all corporeal +Things follow from those manifest Principles, would be a very great step +in Philosophy, though the Causes of those Principles were not yet +discover'd: And therefore I scruple not to propose the Principles of +Motion above-mention'd, they being of very general Extent, and leave +their Causes to be found out. + +Now by the help of these Principles, all material Things seem to have +been composed of the hard and solid Particles above-mention'd, variously +associated in the first Creation by the Counsel of an intelligent Agent. +For it became him who created them to set them in order. And if he did +so, it's unphilosophical to seek for any other Origin of the World, or +to pretend that it might arise out of a Chaos by the mere Laws of +Nature; though being once form'd, it may continue by those Laws for many +Ages. For while Comets move in very excentrick Orbs in all manner of +Positions, blind Fate could never make all the Planets move one and the +same way in Orbs concentrick, some inconsiderable Irregularities +excepted, which may have risen from the mutual Actions of Comets and +Planets upon one another, and which will be apt to increase, till this +System wants a Reformation. Such a wonderful Uniformity in the Planetary +System must be allowed the Effect of Choice. And so must the Uniformity +in the Bodies of Animals, they having generally a right and a left side +shaped alike, and on either side of their Bodies two Legs behind, and +either two Arms, or two Legs, or two Wings before upon their Shoulders, +and between their Shoulders a Neck running down into a Back-bone, and a +Head upon it; and in the Head two Ears, two Eyes, a Nose, a Mouth, and +a Tongue, alike situated. Also the first Contrivance of those very +artificial Parts of Animals, the Eyes, Ears, Brain, Muscles, Heart, +Lungs, Midriff, Glands, Larynx, Hands, Wings, swimming Bladders, natural +Spectacles, and other Organs of Sense and Motion; and the Instinct of +Brutes and Insects, can be the effect of nothing else than the Wisdom +and Skill of a powerful ever-living Agent, who being in all Places, is +more able by his Will to move the Bodies within his boundless uniform +Sensorium, and thereby to form and reform the Parts of the Universe, +than we are by our Will to move the Parts of our own Bodies. And yet we +are not to consider the World as the Body of God, or the several Parts +thereof, as the Parts of God. He is an uniform Being, void of Organs, +Members or Parts, and they are his Creatures subordinate to him, and +subservient to his Will; and he is no more the Soul of them, than the +Soul of Man is the Soul of the Species of Things carried through the +Organs of Sense into the place of its Sensation, where it perceives them +by means of its immediate Presence, without the Intervention of any +third thing. The Organs of Sense are not for enabling the Soul to +perceive the Species of Things in its Sensorium, but only for conveying +them thither; and God has no need of such Organs, he being every where +present to the Things themselves. And since Space is divisible _in +infinitum_, and Matter is not necessarily in all places, it may be also +allow'd that God is able to create Particles of Matter of several Sizes +and Figures, and in several Proportions to Space, and perhaps of +different Densities and Forces, and thereby to vary the Laws of Nature, +and make Worlds of several sorts in several Parts of the Universe. At +least, I see nothing of Contradiction in all this. + +As in Mathematicks, so in Natural Philosophy, the Investigation of +difficult Things by the Method of Analysis, ought ever to precede the +Method of Composition. This Analysis consists in making Experiments and +Observations, and in drawing general Conclusions from them by Induction, +and admitting of no Objections against the Conclusions, but such as are +taken from Experiments, or other certain Truths. For Hypotheses are not +to be regarded in experimental Philosophy. And although the arguing from +Experiments and Observations by Induction be no Demonstration of general +Conclusions; yet it is the best way of arguing which the Nature of +Things admits of, and may be looked upon as so much the stronger, by how +much the Induction is more general. And if no Exception occur from +Phænomena, the Conclusion may be pronounced generally. But if at any +time afterwards any Exception shall occur from Experiments, it may then +begin to be pronounced with such Exceptions as occur. By this way of +Analysis we may proceed from Compounds to Ingredients, and from Motions +to the Forces producing them; and in general, from Effects to their +Causes, and from particular Causes to more general ones, till the +Argument end in the most general. This is the Method of Analysis: And +the Synthesis consists in assuming the Causes discover'd, and +establish'd as Principles, and by them explaining the Phænomena +proceeding from them, and proving the Explanations. + +In the two first Books of these Opticks, I proceeded by this Analysis to +discover and prove the original Differences of the Rays of Light in +respect of Refrangibility, Reflexibility, and Colour, and their +alternate Fits of easy Reflexion and easy Transmission, and the +Properties of Bodies, both opake and pellucid, on which their Reflexions +and Colours depend. And these Discoveries being proved, may be assumed +in the Method of Composition for explaining the Phænomena arising from +them: An Instance of which Method I gave in the End of the first Book. +In this third Book I have only begun the Analysis of what remains to be +discover'd about Light and its Effects upon the Frame of Nature, hinting +several things about it, and leaving the Hints to be examin'd and +improv'd by the farther Experiments and Observations of such as are +inquisitive. And if natural Philosophy in all its Parts, by pursuing +this Method, shall at length be perfected, the Bounds of Moral +Philosophy will be also enlarged. For so far as we can know by natural +Philosophy what is the first Cause, what Power he has over us, and what +Benefits we receive from him, so far our Duty towards him, as well as +that towards one another, will appear to us by the Light of Nature. And +no doubt, if the Worship of false Gods had not blinded the Heathen, +their moral Philosophy would have gone farther than to the four +Cardinal Virtues; and instead of teaching the Transmigration of Souls, +and to worship the Sun and Moon, and dead Heroes, they would have taught +us to worship our true Author and Benefactor, as their Ancestors did +under the Government of _Noah_ and his Sons before they corrupted +themselves. \ No newline at end of file diff --git a/libgo/go/testing/benchmark.go b/libgo/go/testing/benchmark.go index 9c7b1be79e7..8dd8cbc17e2 100644 --- a/libgo/go/testing/benchmark.go +++ b/libgo/go/testing/benchmark.go @@ -10,15 +10,50 @@ import ( "internal/race" "os" "runtime" + "strconv" + "strings" "sync" "sync/atomic" "time" ) var matchBenchmarks = flag.String("test.bench", "", "run only benchmarks matching `regexp`") -var benchTime = flag.Duration("test.benchtime", 1*time.Second, "run each benchmark for duration `d`") +var benchTime = benchTimeFlag{d: 1 * time.Second} var benchmarkMemory = flag.Bool("test.benchmem", false, "print memory allocations for benchmarks") +func init() { + flag.Var(&benchTime, "test.benchtime", "run each benchmark for duration `d`") +} + +type benchTimeFlag struct { + d time.Duration + n int +} + +func (f *benchTimeFlag) String() string { + if f.n > 0 { + return fmt.Sprintf("%dx", f.n) + } + return time.Duration(f.d).String() +} + +func (f *benchTimeFlag) Set(s string) error { + if strings.HasSuffix(s, "x") { + n, err := strconv.ParseInt(s[:len(s)-1], 10, 0) + if err != nil || n <= 0 { + return fmt.Errorf("invalid count") + } + *f = benchTimeFlag{n: int(n)} + return nil + } + d, err := time.ParseDuration(s) + if err != nil || d <= 0 { + return fmt.Errorf("invalid duration") + } + *f = benchTimeFlag{d: d} + return nil +} + // Global lock to ensure only one benchmark runs at a time. var benchmarkLock sync.Mutex @@ -53,7 +88,7 @@ type B struct { previousN int // number of iterations in the previous run previousDuration time.Duration // total duration of the previous run benchFunc func(b *B) - benchTime time.Duration + benchTime benchTimeFlag bytes int64 missingBytes bool // one of the subbenchmarks does not have bytes set. timerOn bool @@ -195,7 +230,7 @@ func roundUp(n int) int { } } -// run1 runs the first iteration of benchFunc. It returns whether more +// run1 runs the first iteration of benchFunc. It reports whether more // iterations of this benchmarks should be run. func (b *B) run1() bool { if ctx := b.context; ctx != nil { @@ -273,21 +308,25 @@ func (b *B) launch() { }() // Run the benchmark for at least the specified amount of time. - d := b.benchTime - for n := 1; !b.failed && b.duration < d && n < 1e9; { - last := n - // Predict required iterations. - n = int(d.Nanoseconds()) - if nsop := b.nsPerOp(); nsop != 0 { - n /= int(nsop) + if b.benchTime.n > 0 { + b.runN(b.benchTime.n) + } else { + d := b.benchTime.d + for n := 1; !b.failed && b.duration < d && n < 1e9; { + last := n + // Predict required iterations. + n = int(d.Nanoseconds()) + if nsop := b.nsPerOp(); nsop != 0 { + n /= int(nsop) + } + // Run more iterations than we think we'll need (1.2x). + // Don't grow too fast in case we had timing errors previously. + // Be sure to run at least one more than last time. + n = max(min(n+n/5, 100*last), last+1) + // Round up to something easy to read. + n = roundUp(n) + b.runN(n) } - // Run more iterations than we think we'll need (1.2x). - // Don't grow too fast in case we had timing errors previously. - // Be sure to run at least one more than last time. - n = max(min(n+n/5, 100*last), last+1) - // Round up to something easy to read. - n = roundUp(n) - b.runN(n) } b.result = BenchmarkResult{b.N, b.duration, b.bytes, b.netAllocs, b.netBytes} } @@ -416,7 +455,7 @@ func runBenchmarks(importPath string, matchString func(pat, str string) (bool, e b.Run(Benchmark.Name, Benchmark.F) } }, - benchTime: *benchTime, + benchTime: benchTime, context: ctx, } main.runN(1) @@ -653,7 +692,7 @@ func Benchmark(f func(b *B)) BenchmarkResult { w: discard{}, }, benchFunc: f, - benchTime: *benchTime, + benchTime: benchTime, } if b.run1() { b.run() diff --git a/libgo/go/testing/sub_test.go b/libgo/go/testing/sub_test.go index 9af3909b355..8c989714a1c 100644 --- a/libgo/go/testing/sub_test.go +++ b/libgo/go/testing/sub_test.go @@ -17,7 +17,7 @@ import ( func init() { // Make benchmark tests run 10* faster. - *benchTime = 100 * time.Millisecond + benchTime.d = 100 * time.Millisecond } func TestTestContext(t *T) { @@ -411,6 +411,29 @@ func TestTRun(t *T) { ch <- true <-ch }, + }, { + desc: "log in finished sub test logs to parent", + ok: false, + output: ` + --- FAIL: log in finished sub test logs to parent (N.NNs) + sub_test.go:NNN: message2 + sub_test.go:NNN: message1 + sub_test.go:NNN: error`, + maxPar: 1, + f: func(t *T) { + ch := make(chan bool) + t.Run("sub", func(t2 *T) { + go func() { + <-ch + t2.Log("message1") + ch <- true + }() + }) + t.Log("message2") + ch <- true + <-ch + t.Errorf("error") + }, }} for _, tc := range testCases { ctx := newTestContext(tc.maxPar, newMatcher(regexp.MatchString, "", "")) @@ -570,7 +593,7 @@ func TestBRun(t *T) { chatty: tc.chatty, }, benchFunc: func(b *B) { ok = b.Run("test", tc.f) }, // Use Run to catch failure. - benchTime: time.Microsecond, + benchTime: benchTimeFlag{d: 1 * time.Microsecond}, } root.runN(1) if ok != !tc.failed { @@ -594,8 +617,8 @@ func TestBRun(t *T) { func makeRegexp(s string) string { s = regexp.QuoteMeta(s) - s = strings.Replace(s, ":NNN:", `:\d\d\d:`, -1) - s = strings.Replace(s, "N\\.NNs", `\d*\.\d*s`, -1) + s = strings.ReplaceAll(s, ":NNN:", `:\d\d\d:`) + s = strings.ReplaceAll(s, "N\\.NNs", `\d*\.\d*s`) return s } diff --git a/libgo/go/testing/testing.go b/libgo/go/testing/testing.go index a552b363617..0ac51b6fe51 100644 --- a/libgo/go/testing/testing.go +++ b/libgo/go/testing/testing.go @@ -17,13 +17,13 @@ // package builds but will be included when the ``go test'' command is run. // For more detail, run ``go help test'' and ``go help testflag''. // -// Tests and benchmarks may be skipped if not applicable with a call to -// the Skip method of *T and *B: -// func TestTimeConsuming(t *testing.T) { -// if testing.Short() { -// t.Skip("skipping test in short mode.") +// A simple test function looks like this: +// +// func TestAbs(t *testing.T) { +// got := Abs(-1) +// if got != 1 { +// t.Errorf("Abs(-1) = %d; want 1", got) // } -// ... // } // // Benchmarks @@ -132,6 +132,18 @@ // example function, at least one other function, type, variable, or constant // declaration, and no test or benchmark functions. // +// Skipping +// +// Tests or benchmarks may be skipped at run time with a call to +// the Skip method of *T or *B: +// +// func TestTimeConsuming(t *testing.T) { +// if testing.Short() { +// t.Skip("skipping test in short mode.") +// } +// ... +// } +// // Subtests and Sub-benchmarks // // The Run methods of T and B allow defining subtests and sub-benchmarks, @@ -316,6 +328,13 @@ type common struct { // Short reports whether the -test.short flag is set. func Short() bool { + // Catch code that calls this from TestMain without first + // calling flag.Parse. This shouldn't really be a panic + if !flag.Parsed() { + fmt.Fprintf(os.Stderr, "testing: testing.Short called before flag.Parse\n") + os.Exit(2) + } + return *short } @@ -396,8 +415,8 @@ func (c *common) frameSkip(skip int) runtime.Frame { // decorate prefixes the string with the file and line of the call site // and inserts the final newline if needed and indentation spaces for formatting. // This function must be called with c.mu held. -func (c *common) decorate(s string) string { - frame := c.frameSkip(3) // decorate + log + public function. +func (c *common) decorate(s string, skip int) string { + frame := c.frameSkip(skip) file := frame.File line := frame.Line if file != "" { @@ -592,9 +611,25 @@ func (c *common) FailNow() { // log generates the output. It's always at the same stack depth. func (c *common) log(s string) { + c.logDepth(s, 3) // logDepth + log + public function +} + +// logDepth generates the output. At an arbitary stack depth +func (c *common) logDepth(s string, depth int) { c.mu.Lock() defer c.mu.Unlock() - c.output = append(c.output, c.decorate(s)...) + // If this test has already finished try and log this message with our parent + // with this test name tagged so we know where it came from. + // If we don't have a parent panic. + if c.done { + if c.parent != nil { + c.parent.logDepth(s, depth+1) + } else { + panic("Log in goroutine after " + c.name + " has completed") + } + } else { + c.output = append(c.output, c.decorate(s, depth+1)...) + } } // Log formats its arguments using default formatting, analogous to Println, diff --git a/libgo/go/text/scanner/scanner.go b/libgo/go/text/scanner/scanner.go index 4e76664dc0c..893a4edbaf9 100644 --- a/libgo/go/text/scanner/scanner.go +++ b/libgo/go/text/scanner/scanner.go @@ -384,6 +384,9 @@ func (s *Scanner) scanExponent(ch rune) rune { if ch == '-' || ch == '+' { ch = s.next() } + if !isDecimal(ch) { + s.error("illegal exponent") + } ch = s.scanMantissa(ch) } return ch diff --git a/libgo/go/text/scanner/scanner_test.go b/libgo/go/text/scanner/scanner_test.go index 9a6b72ef673..e26e816f519 100644 --- a/libgo/go/text/scanner/scanner_test.go +++ b/libgo/go/text/scanner/scanner_test.go @@ -252,6 +252,14 @@ func checkTok(t *testing.T, s *Scanner, line int, got, want rune, text string) { } } +func checkTokErr(t *testing.T, s *Scanner, line int, want rune, text string) { + prevCount := s.ErrorCount + checkTok(t, s, line, s.Scan(), want, text) + if s.ErrorCount != prevCount+1 { + t.Fatalf("want error for %q", text) + } +} + func countNewlines(s string) int { n := 0 for _, ch := range s { @@ -282,6 +290,21 @@ func TestScan(t *testing.T) { testScan(t, GoTokens&^SkipComments) } +func TestIllegalExponent(t *testing.T) { + const src = "1.5e 1.5E 1e+ 1e- 1.5z" + s := new(Scanner).Init(strings.NewReader(src)) + checkTokErr(t, s, 1, Float, "1.5e") + checkTokErr(t, s, 1, Float, "1.5E") + checkTokErr(t, s, 1, Float, "1e+") + checkTokErr(t, s, 1, Float, "1e-") + checkTok(t, s, 1, s.Scan(), Float, "1.5") + checkTok(t, s, 1, s.Scan(), Ident, "z") + checkTok(t, s, 1, s.Scan(), EOF, "") + if s.ErrorCount != 4 { + t.Errorf("%d errors, want 4", s.ErrorCount) + } +} + func TestPosition(t *testing.T) { src := makeSource("\t\t\t\t%s\n") s := new(Scanner).Init(src) @@ -475,6 +498,10 @@ func TestError(t *testing.T) { testError(t, `0x`, ":1:3", "illegal hexadecimal number", Int) testError(t, `0xg`, ":1:3", "illegal hexadecimal number", Int) testError(t, `'aa'`, ":1:4", "illegal char literal", Char) + testError(t, `1.5e`, ":1:5", "illegal exponent", Float) + testError(t, `1.5E`, ":1:5", "illegal exponent", Float) + testError(t, `1.5e+`, ":1:6", "illegal exponent", Float) + testError(t, `1.5e-`, ":1:6", "illegal exponent", Float) testError(t, `'`, ":1:2", "literal not terminated", Char) testError(t, `'`+"\n", ":1:2", "literal not terminated", Char) diff --git a/libgo/go/text/template/doc.go b/libgo/go/text/template/doc.go index 4b243067b0f..0179dec5c33 100644 --- a/libgo/go/text/template/doc.go +++ b/libgo/go/text/template/doc.go @@ -142,7 +142,9 @@ An argument is a simple value, denoted by one of the following. - A boolean, string, character, integer, floating-point, imaginary or complex constant in Go syntax. These behave like Go's untyped - constants. + constants. Note that, as in Go, whether a large integer constant + overflows when assigned or passed to a function can depend on whether + the host machine's ints are 32 or 64 bits. - The keyword nil, representing an untyped Go nil. - The character '.' (period): . diff --git a/libgo/go/text/template/exec.go b/libgo/go/text/template/exec.go index 7ee60bd6f6d..d29721b7f35 100644 --- a/libgo/go/text/template/exec.go +++ b/libgo/go/text/template/exec.go @@ -7,10 +7,10 @@ package template import ( "bytes" "fmt" + "internal/fmtsort" "io" "reflect" "runtime" - "sort" "strings" "text/template/parse" ) @@ -104,7 +104,7 @@ func (s *state) at(node parse.Node) { // doublePercent returns the string with %'s replaced by %%, if necessary, // so it can be used safely inside a Printf format string. func doublePercent(str string) string { - return strings.Replace(str, "%", "%%", -1) + return strings.ReplaceAll(str, "%", "%%") } // TODO: It would be nice if ExecError was more broken down, but @@ -364,8 +364,9 @@ func (s *state) walkRange(dot reflect.Value, r *parse.RangeNode) { if val.Len() == 0 { break } - for _, key := range sortKeys(val.MapKeys()) { - oneIteration(key, val.MapIndex(key)) + om := fmtsort.Sort(val) + for i, key := range om.Key { + oneIteration(key, om.Value[i]) } return case reflect.Chan: @@ -694,13 +695,13 @@ func (s *state) evalCall(dot, fun reflect.Value, node parse.Node, name string, a } argv[i] = s.validateType(final, t) } - result := fun.Call(argv) - // If we have an error that is not nil, stop execution and return that error to the caller. - if len(result) == 2 && !result[1].IsNil() { + v, err := safeCall(fun, argv) + // If we have an error that is not nil, stop execution and return that + // error to the caller. + if err != nil { s.at(node) - s.errorf("error calling %s: %s", name, result[1].Interface().(error)) + s.errorf("error calling %s: %v", name, err) } - v := result[0] if v.Type() == reflectValueType { v = v.Interface().(reflect.Value) } @@ -960,29 +961,3 @@ func printableValue(v reflect.Value) (interface{}, bool) { } return v.Interface(), true } - -// sortKeys sorts (if it can) the slice of reflect.Values, which is a slice of map keys. -func sortKeys(v []reflect.Value) []reflect.Value { - if len(v) <= 1 { - return v - } - switch v[0].Kind() { - case reflect.Float32, reflect.Float64: - sort.Slice(v, func(i, j int) bool { - return v[i].Float() < v[j].Float() - }) - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - sort.Slice(v, func(i, j int) bool { - return v[i].Int() < v[j].Int() - }) - case reflect.String: - sort.Slice(v, func(i, j int) bool { - return v[i].String() < v[j].String() - }) - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - sort.Slice(v, func(i, j int) bool { - return v[i].Uint() < v[j].Uint() - }) - } - return v -} diff --git a/libgo/go/text/template/exec_test.go b/libgo/go/text/template/exec_test.go index 6f40d80635f..085f7c411da 100644 --- a/libgo/go/text/template/exec_test.go +++ b/libgo/go/text/template/exec_test.go @@ -74,6 +74,7 @@ type T struct { VariadicFuncInt func(int, ...string) string NilOKFunc func(*int) bool ErrFunc func() (string, error) + PanicFunc func() string // Template to test evaluation of templates. Tmpl *Template // Unexported field; cannot be accessed by template. @@ -156,6 +157,7 @@ var tVal = &T{ VariadicFuncInt: func(a int, s ...string) string { return fmt.Sprint(a, "=<", strings.Join(s, "+"), ">") }, NilOKFunc: func(s *int) bool { return s == nil }, ErrFunc: func() (string, error) { return "bla", nil }, + PanicFunc: func() string { panic("test panic") }, Tmpl: Must(New("x").Parse("test template")), // "x" is the value of .X } @@ -1279,6 +1281,7 @@ func TestBadFuncNames(t *testing.T) { } func testBadFuncName(name string, t *testing.T) { + t.Helper() defer func() { recover() }() @@ -1450,3 +1453,60 @@ func TestInterfaceValues(t *testing.T) { } } } + +// Check that panics during calls are recovered and returned as errors. +func TestExecutePanicDuringCall(t *testing.T) { + funcs := map[string]interface{}{ + "doPanic": func() string { + panic("custom panic string") + }, + } + tests := []struct { + name string + input string + data interface{} + wantErr string + }{ + { + "direct func call panics", + "{{doPanic}}", (*T)(nil), + `template: t:1:2: executing "t" at : error calling doPanic: custom panic string`, + }, + { + "indirect func call panics", + "{{call doPanic}}", (*T)(nil), + `template: t:1:7: executing "t" at : error calling doPanic: custom panic string`, + }, + { + "direct method call panics", + "{{.GetU}}", (*T)(nil), + `template: t:1:2: executing "t" at <.GetU>: error calling GetU: runtime error: `, + }, + { + "indirect method call panics", + "{{call .GetU}}", (*T)(nil), + `template: t:1:7: executing "t" at <.GetU>: error calling GetU: runtime error: `, + }, + { + "func field call panics", + "{{call .PanicFunc}}", tVal, + `template: t:1:2: executing "t" at : error calling call: test panic`, + }, + } + for _, tc := range tests { + b := new(bytes.Buffer) + tmpl, err := New("t").Funcs(funcs).Parse(tc.input) + if err != nil { + t.Fatalf("parse error: %s", err) + } + err = tmpl.Execute(b, tc.data) + if err == nil { + t.Errorf("%s: expected error; got none", tc.name) + } else if !strings.Contains(err.Error(), tc.wantErr) { + if *debug { + fmt.Printf("%s: test execute error: %s\n", tc.name, err) + } + t.Errorf("%s: expected error:\n%s\ngot:\n%s", tc.name, tc.wantErr, err) + } + } +} diff --git a/libgo/go/text/template/funcs.go b/libgo/go/text/template/funcs.go index abddfa1141b..72d3f666918 100644 --- a/libgo/go/text/template/funcs.go +++ b/libgo/go/text/template/funcs.go @@ -65,7 +65,7 @@ func createValueFuncs(funcMap FuncMap) map[string]reflect.Value { func addValueFuncs(out map[string]reflect.Value, in FuncMap) { for name, fn := range in { if !goodName(name) { - panic(fmt.Errorf("function name %s is not a valid identifier", name)) + panic(fmt.Errorf("function name %q is not a valid identifier", name)) } v := reflect.ValueOf(fn) if v.Kind() != reflect.Func { @@ -275,11 +275,26 @@ func call(fn reflect.Value, args ...reflect.Value) (reflect.Value, error) { return reflect.Value{}, fmt.Errorf("arg %d: %s", i, err) } } - result := v.Call(argv) - if len(result) == 2 && !result[1].IsNil() { - return result[0], result[1].Interface().(error) + return safeCall(v, argv) +} + +// safeCall runs fun.Call(args), and returns the resulting value and error, if +// any. If the call panics, the panic value is returned as an error. +func safeCall(fun reflect.Value, args []reflect.Value) (val reflect.Value, err error) { + defer func() { + if r := recover(); r != nil { + if e, ok := r.(error); ok { + err = e + } else { + err = fmt.Errorf("%v", r) + } + } + }() + ret := fun.Call(args) + if len(ret) == 2 && !ret[1].IsNil() { + return ret[0], ret[1].Interface().(error) } - return result[0], nil + return ret[0], nil } // Boolean logic. diff --git a/libgo/go/text/template/parse/lex.go b/libgo/go/text/template/parse/lex.go index fc259f351ed..94a676c579c 100644 --- a/libgo/go/text/template/parse/lex.go +++ b/libgo/go/text/template/parse/lex.go @@ -117,6 +117,7 @@ type lexer struct { items chan item // channel of scanned items parenDepth int // nesting depth of ( ) exprs line int // 1+number of newlines seen + startLine int // start line of this item } // next returns the next rune in the input. @@ -152,19 +153,16 @@ func (l *lexer) backup() { // emit passes an item back to the client. func (l *lexer) emit(t itemType) { - l.items <- item{t, l.start, l.input[l.start:l.pos], l.line} - // Some items contain text internally. If so, count their newlines. - switch t { - case itemText, itemRawString, itemLeftDelim, itemRightDelim: - l.line += strings.Count(l.input[l.start:l.pos], "\n") - } + l.items <- item{t, l.start, l.input[l.start:l.pos], l.startLine} l.start = l.pos + l.startLine = l.line } // ignore skips over the pending input before this point. func (l *lexer) ignore() { l.line += strings.Count(l.input[l.start:l.pos], "\n") l.start = l.pos + l.startLine = l.line } // accept consumes the next rune if it's from the valid set. @@ -186,7 +184,7 @@ func (l *lexer) acceptRun(valid string) { // errorf returns an error token and terminates the scan by passing // back a nil pointer that will be the next state, terminating l.nextItem. func (l *lexer) errorf(format string, args ...interface{}) stateFn { - l.items <- item{itemError, l.start, fmt.Sprintf(format, args...), l.line} + l.items <- item{itemError, l.start, fmt.Sprintf(format, args...), l.startLine} return nil } @@ -218,6 +216,7 @@ func lex(name, input, left, right string) *lexer { rightDelim: right, items: make(chan item), line: 1, + startLine: 1, } go l.run() return l @@ -252,16 +251,17 @@ func lexText(l *lexer) stateFn { } l.pos -= trimLength if l.pos > l.start { + l.line += strings.Count(l.input[l.start:l.pos], "\n") l.emit(itemText) } l.pos += trimLength l.ignore() return lexLeftDelim - } else { - l.pos = Pos(len(l.input)) } + l.pos = Pos(len(l.input)) // Correctly reached EOF. if l.pos > l.start { + l.line += strings.Count(l.input[l.start:l.pos], "\n") l.emit(itemText) } l.emit(itemEOF) @@ -609,14 +609,10 @@ Loop: // lexRawQuote scans a raw quoted string. func lexRawQuote(l *lexer) stateFn { - startLine := l.line Loop: for { switch l.next() { case eof: - // Restore line number to location of opening quote. - // We will error out so it's ok just to overwrite the field. - l.line = startLine return l.errorf("unterminated raw quoted string") case '`': break Loop diff --git a/libgo/go/text/template/parse/parse.go b/libgo/go/text/template/parse/parse.go index cb9b44e9da0..7c35b0ff3d8 100644 --- a/libgo/go/text/template/parse/parse.go +++ b/libgo/go/text/template/parse/parse.go @@ -148,9 +148,6 @@ func (t *Tree) ErrorContext(n Node) (location, context string) { } lineNum := 1 + strings.Count(text, "\n") context = n.String() - if len(context) > 20 { - context = fmt.Sprintf("%.20s...", context) - } return fmt.Sprintf("%s:%d:%d", tree.ParseName, lineNum, byteNum), context } @@ -383,46 +380,44 @@ func (t *Tree) action() (n Node) { // Pipeline: // declarations? command ('|' command)* func (t *Tree) pipeline(context string) (pipe *PipeNode) { - decl := false - var vars []*VariableNode token := t.peekNonSpace() - pos := token.pos + pipe = t.newPipeline(token.pos, token.line, nil) // Are there declarations or assignments? - for { - if v := t.peekNonSpace(); v.typ == itemVariable { - t.next() - // Since space is a token, we need 3-token look-ahead here in the worst case: - // in "$x foo" we need to read "foo" (as opposed to ":=") to know that $x is an - // argument variable rather than a declaration. So remember the token - // adjacent to the variable so we can push it back if necessary. - tokenAfterVariable := t.peek() - next := t.peekNonSpace() - switch { - case next.typ == itemAssign, next.typ == itemDeclare, - next.typ == itemChar && next.val == ",": - t.nextNonSpace() - variable := t.newVariable(v.pos, v.val) - vars = append(vars, variable) - t.vars = append(t.vars, v.val) - if next.typ == itemDeclare { - decl = true - } - if next.typ == itemChar && next.val == "," { - if context == "range" && len(vars) < 2 { - continue - } - t.errorf("too many declarations in %s", context) +decls: + if v := t.peekNonSpace(); v.typ == itemVariable { + t.next() + // Since space is a token, we need 3-token look-ahead here in the worst case: + // in "$x foo" we need to read "foo" (as opposed to ":=") to know that $x is an + // argument variable rather than a declaration. So remember the token + // adjacent to the variable so we can push it back if necessary. + tokenAfterVariable := t.peek() + next := t.peekNonSpace() + switch { + case next.typ == itemAssign, next.typ == itemDeclare: + pipe.IsAssign = next.typ == itemAssign + t.nextNonSpace() + pipe.Decl = append(pipe.Decl, t.newVariable(v.pos, v.val)) + t.vars = append(t.vars, v.val) + case next.typ == itemChar && next.val == ",": + t.nextNonSpace() + pipe.Decl = append(pipe.Decl, t.newVariable(v.pos, v.val)) + t.vars = append(t.vars, v.val) + if context == "range" && len(pipe.Decl) < 2 { + switch t.peekNonSpace().typ { + case itemVariable, itemRightDelim, itemRightParen: + // second initialized variable in a range pipeline + goto decls + default: + t.errorf("range can only initialize variables") } - case tokenAfterVariable.typ == itemSpace: - t.backup3(v, tokenAfterVariable) - default: - t.backup2(v) } + t.errorf("too many declarations in %s", context) + case tokenAfterVariable.typ == itemSpace: + t.backup3(v, tokenAfterVariable) + default: + t.backup2(v) } - break } - pipe = t.newPipeline(pos, token.line, vars) - pipe.IsAssign = !decl for { switch token := t.nextNonSpace(); token.typ { case itemRightDelim, itemRightParen: diff --git a/libgo/go/text/template/parse/parse_test.go b/libgo/go/text/template/parse/parse_test.go index c1f80c1326b..15cc65670ad 100644 --- a/libgo/go/text/template/parse/parse_test.go +++ b/libgo/go/text/template/parse/parse_test.go @@ -447,18 +447,40 @@ var errorTests = []parseTest{ {"emptypipeline", `{{ ( ) }}`, hasError, `missing value for parenthesized pipeline`}, + {"multilinerawstring", + "{{ $v := `\n` }} {{", + hasError, `multilinerawstring:2: unexpected unclosed action`}, + {"rangeundefvar", + "{{range $k}}{{end}}", + hasError, `undefined variable`}, + {"rangeundefvars", + "{{range $k, $v}}{{end}}", + hasError, `undefined variable`}, + {"rangemissingvalue1", + "{{range $k,}}{{end}}", + hasError, `missing value for range`}, + {"rangemissingvalue2", + "{{range $k, $v := }}{{end}}", + hasError, `missing value for range`}, + {"rangenotvariable1", + "{{range $k, .}}{{end}}", + hasError, `range can only initialize variables`}, + {"rangenotvariable2", + "{{range $k, 123 := .}}{{end}}", + hasError, `range can only initialize variables`}, } func TestErrors(t *testing.T) { for _, test := range errorTests { - _, err := New(test.name).Parse(test.input, "", "", make(map[string]*Tree)) - if err == nil { - t.Errorf("%q: expected error", test.name) - continue - } - if !strings.Contains(err.Error(), test.result) { - t.Errorf("%q: error %q does not contain %q", test.name, err, test.result) - } + t.Run(test.name, func(t *testing.T) { + _, err := New(test.name).Parse(test.input, "", "", make(map[string]*Tree)) + if err == nil { + t.Fatalf("expected error %q, got nil", test.result) + } + if !strings.Contains(err.Error(), test.result) { + t.Fatalf("error %q does not contain %q", err, test.result) + } + }) } } diff --git a/libgo/go/time/example_test.go b/libgo/go/time/example_test.go index 494a4168025..0fd325f2e4f 100644 --- a/libgo/go/time/example_test.go +++ b/libgo/go/time/example_test.go @@ -132,7 +132,7 @@ func ExampleAfter() { select { case m := <-c: handle(m) - case <-time.After(5 * time.Minute): + case <-time.After(10 * time.Second): fmt.Println("timed out") } } @@ -144,7 +144,7 @@ func ExampleSleep() { func statusUpdate() string { return "" } func ExampleTick() { - c := time.Tick(1 * time.Minute) + c := time.Tick(5 * time.Second) for now := range c { fmt.Printf("%v %s\n", now, statusUpdate()) } @@ -429,6 +429,17 @@ func ExampleTime_Truncate() { // t.Truncate(10m0s) = 12:10:00 } +func ExampleLoadLocation() { + location, err := time.LoadLocation("America/Los_Angeles") + if err != nil { + panic(err) + } + + timeInUTC := time.Date(2018, 8, 30, 12, 0, 0, 0, time.UTC) + fmt.Println(timeInUTC.In(location)) + // Output: 2018-08-30 05:00:00 -0700 PDT +} + func ExampleLocation() { // China doesn't have daylight saving. It uses a fixed 8 hour offset from UTC. secondsEastOfUTC := int((8 * time.Hour).Seconds()) diff --git a/libgo/go/time/format.go b/libgo/go/time/format.go index 237f28738b5..2adbbe07706 100644 --- a/libgo/go/time/format.go +++ b/libgo/go/time/format.go @@ -1120,7 +1120,8 @@ func parseTimeZone(value string) (length int, ok bool) { // Special Case 3: Some time zones are not named, but have +/-00 format if value[0] == '+' || value[0] == '-' { length = parseSignedOffset(value) - return length, true + ok := length > 0 // parseSignedOffset returns 0 in case of bad input + return length, ok } // How many upper-case letters are there? Need at least three, at most five. var nUpper int @@ -1152,7 +1153,7 @@ func parseTimeZone(value string) (length int, ok bool) { // parseGMT parses a GMT time zone. The input string is known to start "GMT". // The function checks whether that is followed by a sign and a number in the -// range -14 through 12 excluding zero. +// range -23 through +23 excluding zero. func parseGMT(value string) int { value = value[3:] if len(value) == 0 { @@ -1163,7 +1164,7 @@ func parseGMT(value string) int { } // parseSignedOffset parses a signed timezone offset (e.g. "+03" or "-04"). -// The function checks for a signed number in the range -14 through +12 excluding zero. +// The function checks for a signed number in the range -23 through +23 excluding zero. // Returns length of the found offset string or 0 otherwise func parseSignedOffset(value string) int { sign := value[0] @@ -1171,13 +1172,15 @@ func parseSignedOffset(value string) int { return 0 } x, rem, err := leadingInt(value[1:]) - if err != nil { + + // fail if nothing consumed by leadingInt + if err != nil || value[1:] == rem { return 0 } if sign == '-' { x = -x } - if x == 0 || x < -14 || 12 < x { + if x < -23 || 23 < x { return 0 } return len(value) - len(rem) diff --git a/libgo/go/time/format_test.go b/libgo/go/time/format_test.go index 72dd5926436..0b9f3f49447 100644 --- a/libgo/go/time/format_test.go +++ b/libgo/go/time/format_test.go @@ -418,7 +418,11 @@ var parseTimeZoneTests = []ParseTimeZoneTest{ {"gmt hi there", 0, false}, {"GMT hi there", 3, true}, {"GMT+12 hi there", 6, true}, - {"GMT+00 hi there", 3, true}, // 0 or 00 is not a legal offset. + {"GMT+00 hi there", 6, true}, + {"GMT+", 3, true}, + {"GMT+3", 5, true}, + {"GMT+a", 3, true}, + {"GMT+3a", 5, true}, {"GMT-5 hi there", 5, true}, {"GMT-51 hi there", 3, true}, {"ChST hi there", 4, true}, @@ -429,8 +433,19 @@ var parseTimeZoneTests = []ParseTimeZoneTest{ {"ESASTT hi", 0, false}, // run of upper-case letters too long. {"ESATY hi", 0, false}, // five letters must end in T. {"WITA hi", 4, true}, // Issue #18251 - {"+03 hi", 3, true}, // Issue #24071 - {"-04 hi", 3, true}, // Issue #24071 + // Issue #24071 + {"+03 hi", 3, true}, + {"-04 hi", 3, true}, + // Issue #26032 + {"+00", 3, true}, + {"-11", 3, true}, + {"-12", 3, true}, + {"-23", 3, true}, + {"-24", 0, false}, + {"+13", 3, true}, + {"+14", 3, true}, + {"+23", 3, true}, + {"+24", 0, false}, } func TestParseTimeZone(t *testing.T) { diff --git a/libgo/go/time/sleep.go b/libgo/go/time/sleep.go index b8c81b437c0..10edf6fe0e0 100644 --- a/libgo/go/time/sleep.go +++ b/libgo/go/time/sleep.go @@ -8,9 +8,6 @@ package time // A negative or zero duration causes Sleep to return immediately. func Sleep(d Duration) -// runtimeNano returns the current value of the runtime clock in nanoseconds. -func runtimeNano() int64 - // Interface to timers implemented in package runtime. // Must be in sync with ../runtime/time.go:/^type timer type runtimeTimer struct { diff --git a/libgo/go/time/sleep_test.go b/libgo/go/time/sleep_test.go index e6a08fcf7d8..42df6d1ba4d 100644 --- a/libgo/go/time/sleep_test.go +++ b/libgo/go/time/sleep_test.go @@ -426,10 +426,6 @@ func TestOverflowSleep(t *testing.T) { // Test that a panic while deleting a timer does not leave // the timers mutex held, deadlocking a ticker.Stop in a defer. func TestIssue5745(t *testing.T) { - if runtime.GOOS == "darwin" && runtime.GOARCH == "arm" { - t.Skipf("skipping on %s/%s, see issue 10043", runtime.GOOS, runtime.GOARCH) - } - ticker := NewTicker(Hour) defer func() { // would deadlock here before the fix due to diff --git a/libgo/go/time/time.go b/libgo/go/time/time.go index 2374043ea3c..d0d780fd6ca 100644 --- a/libgo/go/time/time.go +++ b/libgo/go/time/time.go @@ -75,7 +75,10 @@ // package time -import "errors" +import ( + "errors" + _ "unsafe" // for go:linkname +) // A Time represents an instant in time with nanosecond precision. // @@ -102,6 +105,10 @@ import "errors" // change the instant in time being denoted and therefore does not affect the // computations described in earlier paragraphs. // +// Representations of a Time value saved by the GobEncode, MarshalBinary, +// MarshalJSON, and MarshalText methods store the Time.Location's offset, but not +// the location name. They therefore lose information about Daylight Saving Time. +// // In addition to the required “wall clock” reading, a Time may contain an optional // reading of the current process's monotonic clock, to provide additional precision // for comparison or subtraction. @@ -908,13 +915,27 @@ func (t Time) Sub(u Time) Duration { // Since returns the time elapsed since t. // It is shorthand for time.Now().Sub(t). func Since(t Time) Duration { - return Now().Sub(t) + var now Time + if t.wall&hasMonotonic != 0 { + // Common case optimization: if t has monotomic time, then Sub will use only it. + now = Time{hasMonotonic, runtimeNano() - startNano, nil} + } else { + now = Now() + } + return now.Sub(t) } // Until returns the duration until t. // It is shorthand for t.Sub(time.Now()). func Until(t Time) Duration { - return t.Sub(Now()) + var now Time + if t.wall&hasMonotonic != 0 { + // Common case optimization: if t has monotomic time, then Sub will use only it. + now = Time{hasMonotonic, runtimeNano() - startNano, nil} + } else { + now = Now() + } + return t.Sub(now) } // AddDate returns the time corresponding to adding the @@ -933,7 +954,7 @@ func (t Time) AddDate(years int, months int, days int) Time { const ( secondsPerMinute = 60 - secondsPerHour = 60 * 60 + secondsPerHour = 60 * secondsPerMinute secondsPerDay = 24 * secondsPerHour secondsPerWeek = 7 * secondsPerDay daysPer400Years = 365*400 + 97 @@ -1050,9 +1071,22 @@ func daysIn(m Month, year int) int { // Provided by package runtime. func now() (sec int64, nsec int32, mono int64) +// runtimeNano returns the current value of the runtime clock in nanoseconds. +//go:linkname runtimeNano runtime.nanotime +func runtimeNano() int64 + +// Monotonic times are reported as offsets from startNano. +// We initialize startNano to runtimeNano() - 1 so that on systems where +// monotonic time resolution is fairly low (e.g. Windows 2008 +// which appears to have a default resolution of 15ms), +// we avoid ever reporting a monotonic time of 0. +// (Callers may want to use 0 as "time not set".) +var startNano int64 = runtimeNano() - 1 + // Now returns the current local time. func Now() Time { sec, nsec, mono := now() + mono -= startNano sec += unixToInternal - minWall if uint64(sec)>>33 != 0 { return Time{uint64(nsec), sec + minWall, Local} @@ -1076,7 +1110,7 @@ func (t Time) Local() Time { return t } -// In returns a copy of t representating the same time instant, but +// In returns a copy of t representing the same time instant, but // with the copy's location information set to loc for display // purposes. // diff --git a/libgo/go/time/zoneinfo.go b/libgo/go/time/zoneinfo.go index d2bc642d813..7dffbfad5e4 100644 --- a/libgo/go/time/zoneinfo.go +++ b/libgo/go/time/zoneinfo.go @@ -205,7 +205,7 @@ func (l *Location) lookupFirstZone() int { return 0 } -// firstZoneUsed returns whether the first zone is used by some +// firstZoneUsed reports whether the first zone is used by some // transition. func (l *Location) firstZoneUsed() bool { for _, tx := range l.tx { @@ -288,14 +288,23 @@ func LoadLocation(name string) (*Location, error) { env, _ := syscall.Getenv("ZONEINFO") zoneinfo = &env }) + var firstErr error if *zoneinfo != "" { if zoneData, err := loadTzinfoFromDirOrZip(*zoneinfo, name); err == nil { if z, err := LoadLocationFromTZData(name, zoneData); err == nil { return z, nil } + firstErr = err + } else if err != syscall.ENOENT { + firstErr = err } } - return loadLocation(name, zoneSources) + if z, err := loadLocation(name, zoneSources); err == nil { + return z, nil + } else if firstErr == nil { + firstErr = err + } + return nil, firstErr } // containsDotDot reports whether s contains "..". diff --git a/libgo/go/time/zoneinfo_android.go b/libgo/go/time/zoneinfo_android.go index 65e0975ab02..237ff202f91 100644 --- a/libgo/go/time/zoneinfo_android.go +++ b/libgo/go/time/zoneinfo_android.go @@ -11,6 +11,7 @@ package time import ( "errors" "runtime" + "syscall" ) var zoneSources = []string{ @@ -75,5 +76,5 @@ func androidLoadTzinfoFromTzdata(file, name string) ([]byte, error) { } return buf, nil } - return nil, errors.New("cannot find " + name + " in tzdata file " + file) + return nil, syscall.ENOENT } diff --git a/libgo/go/time/zoneinfo_js.go b/libgo/go/time/zoneinfo_js.go new file mode 100644 index 00000000000..2d76a571f21 --- /dev/null +++ b/libgo/go/time/zoneinfo_js.go @@ -0,0 +1,67 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build js,wasm + +package time + +import ( + "runtime" + "syscall/js" +) + +var zoneSources = []string{ + "/usr/share/zoneinfo/", + "/usr/share/lib/zoneinfo/", + "/usr/lib/locale/TZ/", + runtime.GOROOT() + "/lib/time/zoneinfo.zip", +} + +func initLocal() { + localLoc.name = "Local" + + z := zone{} + d := js.Global().Get("Date").New() + offset := d.Call("getTimezoneOffset").Int() * -1 + z.offset = offset * 60 + // According to https://tc39.github.io/ecma262/#sec-timezoneestring, + // the timezone name from (new Date()).toTimeString() is an implementation-dependent + // result, and in Google Chrome, it gives the fully expanded name rather than + // the abbreviation. + // Hence, we construct the name from the offset. + z.name = "UTC" + if offset < 0 { + z.name += "-" + offset *= -1 + } else { + z.name += "+" + } + z.name += itoa(offset / 60) + min := offset % 60 + if min != 0 { + z.name += ":" + itoa(min) + } + localLoc.zone = []zone{z} +} + +// itoa is like strconv.Itoa but only works for values of i in range [0,99]. +// It panics if i is out of range. +func itoa(i int) string { + if i < 10 { + return digits[i : i+1] + } + return smallsString[i*2 : i*2+2] +} + +const smallsString = "00010203040506070809" + + "10111213141516171819" + + "20212223242526272829" + + "30313233343536373839" + + "40414243444546474849" + + "50515253545556575859" + + "60616263646566676869" + + "70717273747576777879" + + "80818283848586878889" + + "90919293949596979899" +const digits = "0123456789" diff --git a/libgo/go/time/zoneinfo_read.go b/libgo/go/time/zoneinfo_read.go index 20f84f00671..d8d4070d5b5 100644 --- a/libgo/go/time/zoneinfo_read.go +++ b/libgo/go/time/zoneinfo_read.go @@ -11,6 +11,7 @@ package time import ( "errors" + "runtime" "syscall" ) @@ -55,7 +56,7 @@ func (d *dataIO) big4() (n uint32, ok bool) { d.error = true return 0, false } - return uint32(p[0])<<24 | uint32(p[1])<<16 | uint32(p[2])<<8 | uint32(p[3]), true + return uint32(p[3]) | uint32(p[2])<<8 | uint32(p[1])<<16 | uint32(p[0])<<24, true } func (d *dataIO) byte() (n byte, ok bool) { @@ -172,6 +173,14 @@ func LoadLocationFromTZData(name string, data []byte) (*Location, error) { return nil, badData } zone[i].name = byteString(abbrev[b:]) + if runtime.GOOS == "aix" && len(name) > 8 && (name[:8] == "Etc/GMT+" || name[:8] == "Etc/GMT-") { + // There is a bug with AIX 7.2 TL 0 with files in Etc, + // GMT+1 will return GMT-1 instead of GMT+1 or -01. + if name != "Etc/GMT+0" { + // GMT+0 is OK + zone[i].name = name[4:] + } + } } // Now the transition time info. @@ -262,7 +271,7 @@ func get2(b []byte) int { func loadTzinfoFromZip(zipfile, name string) ([]byte, error) { fd, err := open(zipfile) if err != nil { - return nil, errors.New("open " + zipfile + ": " + err.Error()) + return nil, err } defer closefd(fd) @@ -364,7 +373,7 @@ func loadTzinfoFromZip(zipfile, name string) ([]byte, error) { return buf, nil } - return nil, errors.New("cannot find " + name + " in zip file " + zipfile) + return nil, syscall.ENOENT } // loadTzinfoFromTzdata returns the time zone information of the time zone diff --git a/libgo/go/time/zoneinfo_test.go b/libgo/go/time/zoneinfo_test.go index 9bf8c4fdf33..2f7612d018f 100644 --- a/libgo/go/time/zoneinfo_test.go +++ b/libgo/go/time/zoneinfo_test.go @@ -5,6 +5,7 @@ package time_test import ( + "errors" "fmt" "os" "reflect" @@ -36,6 +37,16 @@ func TestEnvVarUsage(t *testing.T) { } } +func TestBadLocationErrMsg(t *testing.T) { + time.ResetZoneinfoForTesting() + loc := "Asia/SomethingNotExist" + want := errors.New("unknown time zone " + loc) + _, err := time.LoadLocation(loc) + if err.Error() != want.Error() { + t.Errorf("LoadLocation(%q) error = %v; want %v", loc, err, want) + } +} + func TestLoadLocationValidatesNames(t *testing.T) { time.ResetZoneinfoForTesting() const env = "ZONEINFO" diff --git a/libgo/go/unicode/tables.go b/libgo/go/unicode/tables.go index dd2f70b6519..ce85b128ca4 100644 --- a/libgo/go/unicode/tables.go +++ b/libgo/go/unicode/tables.go @@ -3380,53 +3380,53 @@ var _Zs = &RangeTable{ // These variables have type *RangeTable. var ( - Cc = _Cc // Cc is the set of Unicode characters in category Cc. - Cf = _Cf // Cf is the set of Unicode characters in category Cf. - Co = _Co // Co is the set of Unicode characters in category Co. - Cs = _Cs // Cs is the set of Unicode characters in category Cs. + Cc = _Cc // Cc is the set of Unicode characters in category Cc (Other, control). + Cf = _Cf // Cf is the set of Unicode characters in category Cf (Other, format). + Co = _Co // Co is the set of Unicode characters in category Co (Other, private use). + Cs = _Cs // Cs is the set of Unicode characters in category Cs (Other, surrogate). Digit = _Nd // Digit is the set of Unicode characters with the "decimal digit" property. - Nd = _Nd // Nd is the set of Unicode characters in category Nd. + Nd = _Nd // Nd is the set of Unicode characters in category Nd (Number, decimal digit). Letter = _L // Letter/L is the set of Unicode letters, category L. L = _L - Lm = _Lm // Lm is the set of Unicode characters in category Lm. - Lo = _Lo // Lo is the set of Unicode characters in category Lo. + Lm = _Lm // Lm is the set of Unicode characters in category Lm (Letter, modifier). + Lo = _Lo // Lo is the set of Unicode characters in category Lo (Letter, other). Lower = _Ll // Lower is the set of Unicode lower case letters. - Ll = _Ll // Ll is the set of Unicode characters in category Ll. + Ll = _Ll // Ll is the set of Unicode characters in category Ll (Letter, lowercase). Mark = _M // Mark/M is the set of Unicode mark characters, category M. M = _M - Mc = _Mc // Mc is the set of Unicode characters in category Mc. - Me = _Me // Me is the set of Unicode characters in category Me. - Mn = _Mn // Mn is the set of Unicode characters in category Mn. - Nl = _Nl // Nl is the set of Unicode characters in category Nl. - No = _No // No is the set of Unicode characters in category No. + Mc = _Mc // Mc is the set of Unicode characters in category Mc (Mark, spacing combining). + Me = _Me // Me is the set of Unicode characters in category Me (Mark, enclosing). + Mn = _Mn // Mn is the set of Unicode characters in category Mn (Mark, nonspacing). + Nl = _Nl // Nl is the set of Unicode characters in category Nl (Number, letter). + No = _No // No is the set of Unicode characters in category No (Number, other). Number = _N // Number/N is the set of Unicode number characters, category N. N = _N Other = _C // Other/C is the set of Unicode control and special characters, category C. C = _C - Pc = _Pc // Pc is the set of Unicode characters in category Pc. - Pd = _Pd // Pd is the set of Unicode characters in category Pd. - Pe = _Pe // Pe is the set of Unicode characters in category Pe. - Pf = _Pf // Pf is the set of Unicode characters in category Pf. - Pi = _Pi // Pi is the set of Unicode characters in category Pi. - Po = _Po // Po is the set of Unicode characters in category Po. - Ps = _Ps // Ps is the set of Unicode characters in category Ps. + Pc = _Pc // Pc is the set of Unicode characters in category Pc (Punctuation, connector). + Pd = _Pd // Pd is the set of Unicode characters in category Pd (Punctuation, dash). + Pe = _Pe // Pe is the set of Unicode characters in category Pe (Punctuation, close). + Pf = _Pf // Pf is the set of Unicode characters in category Pf (Punctuation, final quote). + Pi = _Pi // Pi is the set of Unicode characters in category Pi (Punctuation, initial quote). + Po = _Po // Po is the set of Unicode characters in category Po (Punctuation, other). + Ps = _Ps // Ps is the set of Unicode characters in category Ps (Punctuation, open). Punct = _P // Punct/P is the set of Unicode punctuation characters, category P. P = _P - Sc = _Sc // Sc is the set of Unicode characters in category Sc. - Sk = _Sk // Sk is the set of Unicode characters in category Sk. - Sm = _Sm // Sm is the set of Unicode characters in category Sm. - So = _So // So is the set of Unicode characters in category So. + Sc = _Sc // Sc is the set of Unicode characters in category Sc (Symbol, currency). + Sk = _Sk // Sk is the set of Unicode characters in category Sk (Symbol, modifier). + Sm = _Sm // Sm is the set of Unicode characters in category Sm (Symbol, math). + So = _So // So is the set of Unicode characters in category So (Symbol, other). Space = _Z // Space/Z is the set of Unicode space characters, category Z. Z = _Z Symbol = _S // Symbol/S is the set of Unicode symbol characters, category S. S = _S Title = _Lt // Title is the set of Unicode title case letters. - Lt = _Lt // Lt is the set of Unicode characters in category Lt. + Lt = _Lt // Lt is the set of Unicode characters in category Lt (Letter, titlecase). Upper = _Lu // Upper is the set of Unicode upper case letters. - Lu = _Lu // Lu is the set of Unicode characters in category Lu. - Zl = _Zl // Zl is the set of Unicode characters in category Zl. - Zp = _Zp // Zp is the set of Unicode characters in category Zp. - Zs = _Zs // Zs is the set of Unicode characters in category Zs. + Lu = _Lu // Lu is the set of Unicode characters in category Lu (Letter, uppercase). + Zl = _Zl // Zl is the set of Unicode characters in category Zl (Separator, line). + Zp = _Zp // Zp is the set of Unicode characters in category Zp (Separator, paragraph). + Zs = _Zs // Zs is the set of Unicode characters in category Zs (Separator, space). ) // Generated by running diff --git a/libgo/gotool-packages.txt b/libgo/gotool-packages.txt index 76319233530..72eef3bd4c9 100644 --- a/libgo/gotool-packages.txt +++ b/libgo/gotool-packages.txt @@ -15,6 +15,8 @@ cmd/go/internal/help cmd/go/internal/imports cmd/go/internal/list cmd/go/internal/load +cmd/go/internal/lockedfile +cmd/go/internal/lockedfile/internal/filelock cmd/go/internal/modcmd cmd/go/internal/modconv cmd/go/internal/modfetch @@ -26,6 +28,7 @@ cmd/go/internal/modload cmd/go/internal/module cmd/go/internal/mvs cmd/go/internal/par +cmd/go/internal/renameio cmd/go/internal/run cmd/go/internal/search cmd/go/internal/semver @@ -43,6 +46,39 @@ cmd/internal/browser cmd/internal/buildid cmd/internal/edit cmd/internal/objabi +cmd/internal/sys cmd/internal/test2json -cmd/vet/internal/cfg -cmd/vet/internal/whitelist +golang.org/x/tools/go/analysis +golang.org/x/tools/go/analysis/internal/analysisflags +golang.org/x/tools/go/analysis/internal/facts +golang.org/x/tools/go/analysis/passes/asmdecl +golang.org/x/tools/go/analysis/passes/assign +golang.org/x/tools/go/analysis/passes/atomic +golang.org/x/tools/go/analysis/passes/bools +golang.org/x/tools/go/analysis/passes/buildtag +golang.org/x/tools/go/analysis/passes/cgocall +golang.org/x/tools/go/analysis/passes/composite +golang.org/x/tools/go/analysis/passes/copylock +golang.org/x/tools/go/analysis/passes/ctrlflow +golang.org/x/tools/go/analysis/passes/httpresponse +golang.org/x/tools/go/analysis/passes/inspect +golang.org/x/tools/go/analysis/passes/internal/analysisutil +golang.org/x/tools/go/analysis/passes/loopclosure +golang.org/x/tools/go/analysis/passes/lostcancel +golang.org/x/tools/go/analysis/passes/nilfunc +golang.org/x/tools/go/analysis/passes/pkgfact +golang.org/x/tools/go/analysis/passes/printf +golang.org/x/tools/go/analysis/passes/shift +golang.org/x/tools/go/analysis/passes/stdmethods +golang.org/x/tools/go/analysis/passes/structtag +golang.org/x/tools/go/analysis/passes/tests +golang.org/x/tools/go/analysis/passes/unmarshal +golang.org/x/tools/go/analysis/passes/unreachable +golang.org/x/tools/go/analysis/passes/unsafeptr +golang.org/x/tools/go/analysis/passes/unusedresult +golang.org/x/tools/go/analysis/unitchecker +golang.org/x/tools/go/ast/astutil +golang.org/x/tools/go/ast/inspector +golang.org/x/tools/go/cfg +golang.org/x/tools/go/types/objectpath +golang.org/x/tools/go/types/typeutil diff --git a/libgo/libgo-packages.txt b/libgo/libgo-packages.txt index c3c16cde591..f7c0007bfa4 100644 --- a/libgo/libgo-packages.txt +++ b/libgo/libgo-packages.txt @@ -40,7 +40,6 @@ debug/gosym debug/macho debug/pe debug/plan9obj -debug/xcoff encoding encoding/ascii85 encoding/asn1 @@ -71,27 +70,6 @@ go/printer go/scanner go/token go/types -golang_org/x/crypto/internal/chacha20 -golang_org/x/crypto/chacha20poly1305 -golang_org/x/crypto/chacha20poly1305/internal/chacha20 -golang_org/x/crypto/cryptobyte -golang_org/x/crypto/cryptobyte/asn1 -golang_org/x/crypto/curve25519 -golang_org/x/crypto/poly1305 -golang_org/x/net/dns/dnsmessage -golang_org/x/net/http/httpguts -golang_org/x/net/http/httpproxy -golang_org/x/net/http2/hpack -golang_org/x/net/idna -golang_org/x/net/internal/nettest -golang_org/x/net/lex/httplex -golang_org/x/net/nettest -golang_org/x/net/proxy -golang_org/x/text/secure/bidirule -golang_org/x/text/transform -golang_org/x/text/unicode/bidi -golang_org/x/text/unicode/norm -golang_org/x/text/width hash hash/adler32 hash/crc32 @@ -110,6 +88,7 @@ image/png index/suffixarray internal/bytealg internal/cpu +internal/fmtsort internal/goroot internal/nettrace internal/poll @@ -119,6 +98,25 @@ internal/syscall/unix internal/testenv internal/testlog internal/trace +internal/x/crypto/chacha20poly1305 +internal/x/crypto/cryptobyte +internal/x/crypto/cryptobyte/asn1 +internal/x/crypto/curve25519 +internal/x/crypto/hkdf +internal/x/crypto/internal/chacha20 +internal/x/crypto/poly1305 +internal/x/net/dns/dnsmessage +internal/x/net/http/httpguts +internal/x/net/http/httpproxy +internal/x/net/http2/hpack +internal/x/net/idna +internal/x/net/internal/nettest +internal/x/net/nettest +internal/x/text/secure/bidirule +internal/x/text/transform +internal/x/text/unicode/bidi +internal/x/text/unicode/norm +internal/xcoff io io/ioutil log @@ -161,6 +159,7 @@ regexp/syntax runtime runtime/debug runtime/internal/atomic +runtime/internal/math runtime/internal/sys runtime/pprof runtime/pprof/internal/profile diff --git a/libgo/match.sh b/libgo/match.sh index d280620771f..79d4275f7cd 100755 --- a/libgo/match.sh +++ b/libgo/match.sh @@ -113,7 +113,7 @@ for f in $gofiles; do "") ;; $goarch) ;; $goos) ;; - aix | android | darwin | dragonfly | freebsd | linux | nacl | netbsd | openbsd | plan9 | solaris | windows) + aix | android | darwin | dragonfly | freebsd | hurd | js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows) tag1=nonmatchingtag ;; 386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | nios2 | ppc | ppc64 | ppc64le | riscv64 | s390 | s390x | sh | shbe | sparc | sparc64 | wasm) @@ -125,7 +125,7 @@ for f in $gofiles; do "") ;; $goarch) ;; $goos) ;; - aix | android | darwin | dragonfly | freebsd | linux | nacl | netbsd | openbsd | plan9 | solaris | windows) + aix | android | darwin | dragonfly | freebsd | hurd | js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows) tag2=nonmatchingtag ;; 386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | nios2 | ppc | ppc64 | ppc64le | riscv64 | s390 | s390x | sh | shbe | sparc | sparc64 | wasm) diff --git a/libgo/merge.sh b/libgo/merge.sh index 9d9f57c5942..7138891cd61 100755 --- a/libgo/merge.sh +++ b/libgo/merge.sh @@ -128,7 +128,7 @@ echo ${rev} > VERSION (cd ${NEWDIR}/src && find . -name '*.go' -print) | while read f; do skip=false case "$f" in - ./cmd/buildid/* | ./cmd/cgo/* | ./cmd/go/* | ./cmd/gofmt/* | ./cmd/testjson/* | ./cmd/vet/* | ./cmd/internal/browser/* | ./cmd/internal/buildid/* | ./cmd/internal/edit/* | ./cmd/internal/objabi/* | ./cmd/internal/testj2on/* ) + ./cmd/buildid/* | ./cmd/cgo/* | ./cmd/go/* | ./cmd/gofmt/* | ./cmd/testjson/* | ./cmd/vet/* | ./cmd/internal/browser/* | ./cmd/internal/buildid/* | ./cmd/internal/edit/* | ./cmd/internal/objabi/* | ./cmd/internal/testj2on/* | ./cmd/internal/sys/* | ./cmd/vendor/golang.org/x/tools/* ) ;; ./cmd/*) skip=true @@ -143,14 +143,14 @@ echo ${rev} > VERSION oldfile=${OLDDIR}/src/$f newfile=${NEWDIR}/src/$f - libgofile=go/`echo $f | sed -e 's|/vendor/|/|'` + libgofile=go/`echo $f | sed -e 's|cmd/vendor/|/|' | sed -e 's|/vendor/|/|'` merge $f ${oldfile} ${newfile} ${libgofile} done (cd ${NEWDIR}/src && find . -name testdata -print) | while read d; do skip=false case "$d" in - ./cmd/cgo/* | ./cmd/go/* | ./cmd/gofmt/* | ./cmd/internal/browser/*) + ./cmd/buildid/* | ./cmd/cgo/* | ./cmd/go/* | ./cmd/gofmt/* | ./cmd/testjson/* | ./cmd/vet/* | ./cmd/internal/browser/* | ./cmd/internal/buildid/* | ./cmd/internal/edit/* | ./cmd/internal/objabi/* | ./cmd/internal/testj2on/* | ./cmd/internal/sys/* | ./cmd/vendor/golang.org/x/tools/* ) ;; ./cmd/*) skip=true @@ -165,7 +165,7 @@ done oldtd=${OLDDIR}/src/$d newtd=${NEWDIR}/src/$d - libgotd=go/$d + libgofile=go/`echo $d | sed -e 's|cmd/vendor/|/|' | sed -e 's|/vendor/|/|'` if ! test -d ${oldtd}; then echo "merge.sh: $d: NEWDIR" continue diff --git a/libgo/misc/cgo/errors/errors_test.go b/libgo/misc/cgo/errors/errors_test.go index 118187f23b8..59054f4703a 100644 --- a/libgo/misc/cgo/errors/errors_test.go +++ b/libgo/misc/cgo/errors/errors_test.go @@ -121,12 +121,19 @@ func TestReportsTypeErrors(t *testing.T) { "issue16591.go", "issue18452.go", "issue18889.go", + "issue26745.go", + "issue28721.go", } { check(t, file) } if sizeofLongDouble(t) > 8 { - check(t, "err4.go") + for _, file := range []string{ + "err4.go", + "issue28069.go", + } { + check(t, file) + } } } diff --git a/libgo/misc/cgo/errors/ptr_test.go b/libgo/misc/cgo/errors/ptr_test.go index fe8dfff1d89..254671f179e 100644 --- a/libgo/misc/cgo/errors/ptr_test.go +++ b/libgo/misc/cgo/errors/ptr_test.go @@ -357,6 +357,73 @@ var ptrTests = []ptrTest{ body: `r, _, _ := os.Pipe(); r.SetDeadline(time.Now().Add(C.US * time.Microsecond))`, fail: false, }, + { + // Test for double evaluation of channel receive. + name: "chan-recv", + c: `void f(char** p) {}`, + imports: []string{"time"}, + body: `c := make(chan []*C.char, 2); c <- make([]*C.char, 1); go func() { time.Sleep(10 * time.Second); panic("received twice from chan") }(); C.f(&(<-c)[0]);`, + fail: false, + }, + { + // Test that converting the address of a struct field + // to unsafe.Pointer still just checks that field. + // Issue #25941. + name: "struct-field", + c: `void f(void* p) {}`, + imports: []string{"unsafe"}, + support: `type S struct { p *int; a [8]byte; u uintptr }`, + body: `s := &S{p: new(int)}; C.f(unsafe.Pointer(&s.a))`, + fail: false, + }, + { + // Test that converting multiple struct field + // addresses to unsafe.Pointer still just checks those + // fields. Issue #25941. + name: "struct-field-2", + c: `void f(void* p, int r, void* s) {}`, + imports: []string{"unsafe"}, + support: `type S struct { a [8]byte; p *int; b int64; }`, + body: `s := &S{p: new(int)}; C.f(unsafe.Pointer(&s.a), 32, unsafe.Pointer(&s.b))`, + fail: false, + }, + { + // Test that second argument to cgoCheckPointer is + // evaluated when a deferred function is deferred, not + // when it is run. + name: "defer2", + c: `void f(char **pc) {}`, + support: `type S1 struct { s []*C.char }; type S2 struct { ps *S1 }`, + body: `p := &S2{&S1{[]*C.char{nil}}}; defer C.f(&p.ps.s[0]); p.ps = nil`, + fail: false, + }, + { + // Test that indexing into a function call still + // examines only the slice being indexed. + name: "buffer", + c: `void f(void *p) {}`, + imports: []string{"bytes", "unsafe"}, + body: `var b bytes.Buffer; b.WriteString("a"); C.f(unsafe.Pointer(&b.Bytes()[0]))`, + fail: false, + }, + { + // Test that bgsweep releasing a finalizer is OK. + name: "finalizer", + c: `// Nothing to declare.`, + imports: []string{"os"}, + support: `func open() { os.Open(os.Args[0]) }; var G [][]byte`, + body: `for i := 0; i < 10000; i++ { G = append(G, make([]byte, 4096)); if i % 100 == 0 { G = nil; open() } }`, + fail: false, + }, + { + // Test that converting generated struct to interface is OK. + name: "structof", + c: `// Nothing to declare.`, + imports: []string{"reflect"}, + support: `type MyInt int; func (i MyInt) Get() int { return int(i) }; type Getter interface { Get() int }`, + body: `t := reflect.StructOf([]reflect.StructField{{Name: "MyInt", Type: reflect.TypeOf(MyInt(0)), Anonymous: true}}); v := reflect.New(t).Elem(); v.Interface().(Getter).Get()`, + fail: false, + }, } func TestPointerChecks(t *testing.T) { @@ -429,7 +496,7 @@ func testOne(t *testing.T, pt ptrTest) { cmd := exec.Command("go", "build") cmd.Dir = src - cmd.Env = addEnv("GOPATH", gopath) + cmd.Env = append(os.Environ(), "GOPATH="+gopath) buf, err := cmd.CombinedOutput() if err != nil { t.Logf("%#q:\n%s", args(cmd), buf) @@ -501,16 +568,5 @@ func testOne(t *testing.T, pt ptrTest) { } func cgocheckEnv(val string) []string { - return addEnv("GODEBUG", "cgocheck="+val) -} - -func addEnv(key, val string) []string { - env := []string{key + "=" + val} - look := key + "=" - for _, e := range os.Environ() { - if !strings.HasPrefix(e, look) { - env = append(env, e) - } - } - return env + return append(os.Environ(), "GODEBUG=cgocheck="+val) } diff --git a/libgo/misc/cgo/errors/src/issue26745.go b/libgo/misc/cgo/errors/src/issue26745.go new file mode 100644 index 00000000000..0e224538db6 --- /dev/null +++ b/libgo/misc/cgo/errors/src/issue26745.go @@ -0,0 +1,17 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +// int a; +// void CF(int i) {} +import "C" + +func F1(i int) int { + return C.a + 1 // ERROR HERE: :13 +} + +func F2(i int) { + C.CF(i) // ERROR HERE: :6 +} diff --git a/libgo/misc/cgo/errors/src/issue28069.go b/libgo/misc/cgo/errors/src/issue28069.go new file mode 100644 index 00000000000..e19a3b45bd5 --- /dev/null +++ b/libgo/misc/cgo/errors/src/issue28069.go @@ -0,0 +1,26 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test that the error message for an unrepresentable typedef in a +// union appears on the right line. This test is only run if the size +// of long double is larger than 64. + +package main + +/* +typedef long double Float128; + +typedef struct SV { + union { + Float128 float128; + } value; +} SV; +*/ +import "C" + +type ts struct { + tv *C.SV // ERROR HERE +} + +func main() {} diff --git a/libgo/misc/cgo/errors/src/issue28721.go b/libgo/misc/cgo/errors/src/issue28721.go new file mode 100644 index 00000000000..0eb2a9271c2 --- /dev/null +++ b/libgo/misc/cgo/errors/src/issue28721.go @@ -0,0 +1,29 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// cgo should reject the use of mangled C names. + +package main + +/* +typedef struct a { + int i; +} a; +void fn(void) {} +*/ +import "C" + +type B _Ctype_struct_a // ERROR HERE + +var a _Ctype_struct_a // ERROR HERE + +type A struct { + a *_Ctype_struct_a // ERROR HERE +} + +var notExist _Ctype_NotExist // ERROR HERE + +func main() { + _Cfunc_fn() // ERROR HERE +} diff --git a/libgo/misc/cgo/test/callback.go b/libgo/misc/cgo/test/callback.go index b88bf134bc1..4fc6b39ffa6 100644 --- a/libgo/misc/cgo/test/callback.go +++ b/libgo/misc/cgo/test/callback.go @@ -179,7 +179,6 @@ func testCallbackCallers(t *testing.T) { pc := make([]uintptr, 100) n := 0 name := []string{ - "runtime.call16", "runtime.cgocallbackg1", "runtime.cgocallbackg", "runtime.cgocallback_gofunc", @@ -193,9 +192,6 @@ func testCallbackCallers(t *testing.T) { "testing.tRunner", "runtime.goexit", } - if unsafe.Sizeof((*byte)(nil)) == 8 { - name[0] = "runtime.call32" - } nestedCall(func() { n = runtime.Callers(4, pc) }) @@ -295,7 +291,7 @@ func goWithString(s string) { } func testCallbackStack(t *testing.T) { - // Make cgo call and callback with different amount of stack stack available. + // Make cgo call and callback with different amount of stack available. // We do not do any explicit checks, just ensure that it does not crash. for _, f := range splitTests { f() diff --git a/libgo/misc/cgo/test/cgo_test.go b/libgo/misc/cgo/test/cgo_test.go index ccacc50fe1a..242ba6c0e5d 100644 --- a/libgo/misc/cgo/test/cgo_test.go +++ b/libgo/misc/cgo/test/cgo_test.go @@ -92,6 +92,8 @@ func Test25143(t *testing.T) { test25143(t) } func Test23356(t *testing.T) { test23356(t) } func Test26066(t *testing.T) { test26066(t) } func Test26213(t *testing.T) { test26213(t) } +func Test27660(t *testing.T) { test27660(t) } +func Test28896(t *testing.T) { test28896(t) } func BenchmarkCgoCall(b *testing.B) { benchCgoCall(b) } func BenchmarkGoString(b *testing.B) { benchGoString(b) } diff --git a/libgo/misc/cgo/test/issue27054/egl.h b/libgo/misc/cgo/test/issue27054/egl.h new file mode 100644 index 00000000000..33a759ea2a8 --- /dev/null +++ b/libgo/misc/cgo/test/issue27054/egl.h @@ -0,0 +1,7 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This is the relevant part of EGL/egl.h. + +typedef void *EGLDisplay; diff --git a/libgo/misc/cgo/test/issue27054/test27054.go b/libgo/misc/cgo/test/issue27054/test27054.go new file mode 100644 index 00000000000..186f5bd6020 --- /dev/null +++ b/libgo/misc/cgo/test/issue27054/test27054.go @@ -0,0 +1,17 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package issue27054 + +/* +#include "egl.h" +*/ +import "C" +import ( + "testing" +) + +func Test27054(t *testing.T) { + var _ C.EGLDisplay = 0 // Note: 0, not nil. That makes sure we use uintptr for this type. +} diff --git a/libgo/misc/cgo/test/issue27340.go b/libgo/misc/cgo/test/issue27340.go new file mode 100644 index 00000000000..f8c8a87f201 --- /dev/null +++ b/libgo/misc/cgo/test/issue27340.go @@ -0,0 +1,12 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Failed to resolve typedefs consistently. +// No runtime test; just make sure it compiles. + +package cgotest + +import "./issue27340" + +var issue27340Var = issue27340.Issue27340GoFunc diff --git a/libgo/misc/cgo/test/issue27340/a.go b/libgo/misc/cgo/test/issue27340/a.go new file mode 100644 index 00000000000..f5b120c1fd8 --- /dev/null +++ b/libgo/misc/cgo/test/issue27340/a.go @@ -0,0 +1,42 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Failed to resolve typedefs consistently. +// No runtime test; just make sure it compiles. +// In separate directory to isolate #pragma GCC diagnostic. + +package issue27340 + +// We use the #pragma to avoid a compiler warning about incompatible +// pointer types, because we generate code passing a struct ptr rather +// than using the typedef. This warning is expected and does not break +// a normal build. +// We can only disable -Wincompatible-pointer-types starting with GCC 5. + +// #if __GNU_MAJOR__ >= 5 +// +// #pragma GCC diagnostic ignored "-Wincompatible-pointer-types" +// +// typedef struct { +// int a; +// } issue27340Struct, *issue27340Ptr; +// +// static void issue27340CFunc(issue27340Ptr p) {} +// +// #else /* _GNU_MAJOR_ < 5 */ +// +// typedef struct { +// int a; +// } issue27340Struct; +// +// static issue27340Struct* issue27340Ptr(issue27340Struct* p) { return p; } +// +// static void issue27340CFunc(issue27340Struct *p) {} +// #endif /* _GNU_MAJOR_ < 5 */ +import "C" + +func Issue27340GoFunc() { + var s C.issue27340Struct + C.issue27340CFunc(C.issue27340Ptr(&s)) +} diff --git a/libgo/misc/cgo/test/issue28545.go b/libgo/misc/cgo/test/issue28545.go new file mode 100644 index 00000000000..8419b89c0af --- /dev/null +++ b/libgo/misc/cgo/test/issue28545.go @@ -0,0 +1,26 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Failed to add type conversion for negative constant. +// Issue 28772: Failed to add type conversion for Go constant set to C constant. +// No runtime test; just make sure it compiles. + +package cgotest + +/* +#include + +#define issue28772Constant 1 + +static void issue28545F(char **p, int n, complex double a) {} +*/ +import "C" + +const issue28772Constant = C.issue28772Constant + +func issue28545G(p **C.char) { + C.issue28545F(p, -1, (0)) + C.issue28545F(p, 2+3, complex(1, 1)) + C.issue28545F(p, issue28772Constant, issue28772Constant2) +} diff --git a/libgo/misc/cgo/test/issue28772.go b/libgo/misc/cgo/test/issue28772.go new file mode 100644 index 00000000000..bed786bf306 --- /dev/null +++ b/libgo/misc/cgo/test/issue28772.go @@ -0,0 +1,12 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package cgotest + +// Constants didn't work if defined in different source file. + +// #define issue28772Constant2 2 +import "C" + +const issue28772Constant2 = C.issue28772Constant2 diff --git a/libgo/misc/cgo/test/issue28896.go b/libgo/misc/cgo/test/issue28896.go new file mode 100644 index 00000000000..8796040f18e --- /dev/null +++ b/libgo/misc/cgo/test/issue28896.go @@ -0,0 +1,83 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// cgo was incorrectly adding padding after a packed struct. + +package cgotest + +/* +#include +#include +#include + +typedef struct { + void *f1; + uint32_t f2; +} __attribute__((__packed__)) innerPacked; + +typedef struct { + innerPacked g1; + uint64_t g2; +} outerPacked; + +typedef struct { + void *f1; + uint32_t f2; +} innerUnpacked; + +typedef struct { + innerUnpacked g1; + uint64_t g2; +} outerUnpacked; + +size_t offset(int x) { + switch (x) { + case 0: + return offsetof(innerPacked, f2); + case 1: + return offsetof(outerPacked, g2); + case 2: + return offsetof(innerUnpacked, f2); + case 3: + return offsetof(outerUnpacked, g2); + default: + abort(); + } +} +*/ +import "C" + +import ( + "testing" + "unsafe" +) + +func offset(i int) uintptr { + var pi C.innerPacked + var po C.outerPacked + var ui C.innerUnpacked + var uo C.outerUnpacked + switch i { + case 0: + return unsafe.Offsetof(pi.f2) + case 1: + return unsafe.Offsetof(po.g2) + case 2: + return unsafe.Offsetof(ui.f2) + case 3: + return unsafe.Offsetof(uo.g2) + default: + panic("can't happen") + } +} + +func test28896(t *testing.T) { + for i := 0; i < 4; i++ { + c := uintptr(C.offset(C.int(i))) + g := offset(i) + if c != g { + t.Errorf("%d: C: %d != Go %d", i, c, g) + } + } +} diff --git a/libgo/misc/cgo/test/issue29383.go b/libgo/misc/cgo/test/issue29383.go new file mode 100644 index 00000000000..462c9a37df2 --- /dev/null +++ b/libgo/misc/cgo/test/issue29383.go @@ -0,0 +1,19 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// cgo's /*line*/ comments failed when inserted after '/', +// because the result looked like a "//" comment. +// No runtime test; just make sure it compiles. + +package cgotest + +// #include +import "C" + +func Issue29383(n, size uint) int { + if ^C.size_t(0)/C.size_t(n) < C.size_t(size) { + return 0 + } + return 0 +} diff --git a/libgo/misc/cgo/test/issue4339.go b/libgo/misc/cgo/test/issue4339.go index 4fa4b2bbd7e..3715fde5757 100644 --- a/libgo/misc/cgo/test/issue4339.go +++ b/libgo/misc/cgo/test/issue4339.go @@ -5,7 +5,8 @@ package cgotest /* -#include "issue4339.h" +// We've historically permitted #include <>, so test it here. Issue 29333. +#include */ import "C" diff --git a/libgo/misc/cgo/test/issue9026/issue9026.go b/libgo/misc/cgo/test/issue9026/issue9026.go index 0af86e64da4..149c26562ad 100644 --- a/libgo/misc/cgo/test/issue9026/issue9026.go +++ b/libgo/misc/cgo/test/issue9026/issue9026.go @@ -29,7 +29,7 @@ func Test(t *testing.T) { // Brittle: the assertion may fail spuriously when the algorithm // changes, but should remain stable otherwise. got := fmt.Sprintf("%T %T", in, opts) - want := "issue9026._Ctype_struct___0 *issue9026._Ctype_struct___1" + want := "issue9026._Ctype_struct___0 *issue9026._Ctype_struct___0" if got != want { t.Errorf("Non-deterministic type names: got %s, want %s", got, want) } diff --git a/libgo/misc/cgo/test/issue9400_linux.go b/libgo/misc/cgo/test/issue9400_linux.go index 34eb4983a41..7719535d251 100644 --- a/libgo/misc/cgo/test/issue9400_linux.go +++ b/libgo/misc/cgo/test/issue9400_linux.go @@ -41,7 +41,7 @@ func test9400(t *testing.T) { // Grow the stack and put down a test pattern const pattern = 0x123456789abcdef - var big [1024]uint64 // len must match assmebly + var big [1024]uint64 // len must match assembly for i := range big { big[i] = pattern } diff --git a/libgo/misc/cgo/test/test27660.go b/libgo/misc/cgo/test/test27660.go new file mode 100644 index 00000000000..0345aa7312b --- /dev/null +++ b/libgo/misc/cgo/test/test27660.go @@ -0,0 +1,61 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Stress the interaction between the race detector and cgo in an +// attempt to reproduce the memory corruption described in #27660. +// The bug was very timing sensitive; at the time of writing this +// test would only trigger the bug about once out of every five runs. + +package cgotest + +// #include +import "C" + +import ( + "context" + "math/rand" + "runtime" + "sync" + "testing" + "time" +) + +func test27660(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + ints := make([]int, 100) + locks := make([]sync.Mutex, 100) + // Slowly create threads so that ThreadSanitizer is forced to + // frequently resize its SyncClocks. + for i := 0; i < 100; i++ { + go func() { + for ctx.Err() == nil { + // Sleep in C for long enough that it is likely that the runtime + // will retake this goroutine's currently wired P. + C.usleep(1000 /* 1ms */) + runtime.Gosched() // avoid starvation (see #28701) + } + }() + go func() { + // Trigger lots of synchronization and memory reads/writes to + // increase the likelihood that the race described in #27660 + // results in corruption of ThreadSanitizer's internal state + // and thus an assertion failure or segfault. + i := 0 + for ctx.Err() == nil { + j := rand.Intn(100) + locks[j].Lock() + ints[j]++ + locks[j].Unlock() + // Avoid making the loop unpreemptible + // for gccgo. + if i%0x1000000 == 0 { + runtime.Gosched() + } + i++ + } + }() + time.Sleep(time.Millisecond) + } +} diff --git a/libgo/misc/cgo/test/twoargs.go b/libgo/misc/cgo/test/twoargs.go new file mode 100644 index 00000000000..ca0534ca310 --- /dev/null +++ b/libgo/misc/cgo/test/twoargs.go @@ -0,0 +1,22 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Crash from call with two arguments that need pointer checking. +// No runtime test; just make sure it compiles. + +package cgotest + +/* +static void twoargs1(void *p, int n) {} +static void *twoargs2() { return 0; } +static int twoargs3(void * p) { return 0; } +*/ +import "C" + +import "unsafe" + +func twoargsF() { + v := []string{} + C.twoargs1(C.twoargs2(), C.twoargs3(unsafe.Pointer(&v))) +} diff --git a/libgo/misc/cgo/testcshared/cshared_test.go b/libgo/misc/cgo/testcshared/cshared_test.go index 89b19d653a3..e5b90ff194c 100644 --- a/libgo/misc/cgo/testcshared/cshared_test.go +++ b/libgo/misc/cgo/testcshared/cshared_test.go @@ -602,3 +602,55 @@ func copyFile(t *testing.T, dst, src string) { t.Fatal(err) } } + +func TestGo2C2Go(t *testing.T) { + switch GOOS { + case "darwin": + // Darwin shared libraries don't support the multiple + // copies of the runtime package implied by this test. + t.Skip("linking c-shared into Go programs not supported on Darwin; issue 29061") + case "android": + t.Skip("test fails on android; issue 29087") + } + + t.Parallel() + + tmpdir, err := ioutil.TempDir("", "cshared-TestGo2C2Go") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(tmpdir) + + shlib := filepath.Join(tmpdir, "libtestgo2c2go."+libSuffix) + run(t, gopathEnv, "go", "build", "-buildmode=c-shared", "-o", shlib, "go2c2go/go") + + cgoCflags := os.Getenv("CGO_CFLAGS") + if cgoCflags != "" { + cgoCflags += " " + } + cgoCflags += "-I" + tmpdir + + cgoLdflags := os.Getenv("CGO_LDFLAGS") + if cgoLdflags != "" { + cgoLdflags += " " + } + cgoLdflags += "-L" + tmpdir + " -ltestgo2c2go" + + goenv := append(gopathEnv[:len(gopathEnv):len(gopathEnv)], "CGO_CFLAGS="+cgoCflags, "CGO_LDFLAGS="+cgoLdflags) + + ldLibPath := os.Getenv("LD_LIBRARY_PATH") + if ldLibPath != "" { + ldLibPath += ":" + } + ldLibPath += tmpdir + + runenv := append(gopathEnv[:len(gopathEnv):len(gopathEnv)], "LD_LIBRARY_PATH="+ldLibPath) + + bin := filepath.Join(tmpdir, "m1") + exeSuffix + run(t, goenv, "go", "build", "-o", bin, "go2c2go/m1") + runExe(t, runenv, bin) + + bin = filepath.Join(tmpdir, "m2") + exeSuffix + run(t, goenv, "go", "build", "-o", bin, "go2c2go/m2") + runExe(t, runenv, bin) +} diff --git a/libgo/misc/cgo/testcshared/src/go2c2go/go/shlib.go b/libgo/misc/cgo/testcshared/src/go2c2go/go/shlib.go new file mode 100644 index 00000000000..76a5323ad2d --- /dev/null +++ b/libgo/misc/cgo/testcshared/src/go2c2go/go/shlib.go @@ -0,0 +1,12 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "C" + +//export GoFunc +func GoFunc() int { return 1 } + +func main() {} diff --git a/libgo/misc/cgo/testcshared/src/go2c2go/m1/c.c b/libgo/misc/cgo/testcshared/src/go2c2go/m1/c.c new file mode 100644 index 00000000000..0e8fac4cf36 --- /dev/null +++ b/libgo/misc/cgo/testcshared/src/go2c2go/m1/c.c @@ -0,0 +1,9 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#include "libtestgo2c2go.h" + +int CFunc(void) { + return (GoFunc() << 8) + 2; +} diff --git a/libgo/misc/cgo/testcshared/src/go2c2go/m1/main.go b/libgo/misc/cgo/testcshared/src/go2c2go/m1/main.go new file mode 100644 index 00000000000..17ba1eb0a72 --- /dev/null +++ b/libgo/misc/cgo/testcshared/src/go2c2go/m1/main.go @@ -0,0 +1,22 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +// extern int CFunc(void); +import "C" + +import ( + "fmt" + "os" +) + +func main() { + got := C.CFunc() + const want = (1 << 8) | 2 + if got != want { + fmt.Printf("got %#x, want %#x\n", got, want) + os.Exit(1) + } +} diff --git a/libgo/misc/cgo/testcshared/src/go2c2go/m2/main.go b/libgo/misc/cgo/testcshared/src/go2c2go/m2/main.go new file mode 100644 index 00000000000..91bf308057c --- /dev/null +++ b/libgo/misc/cgo/testcshared/src/go2c2go/m2/main.go @@ -0,0 +1,22 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +// #include "libtestgo2c2go.h" +import "C" + +import ( + "fmt" + "os" +) + +func main() { + got := C.GoFunc() + const want = 1 + if got != want { + fmt.Printf("got %#x, want %#x\n", got, want) + os.Exit(1) + } +} diff --git a/libgo/misc/cgo/testplugin/src/checkdwarf/main.go b/libgo/misc/cgo/testplugin/src/checkdwarf/main.go new file mode 100644 index 00000000000..7886c834e7c --- /dev/null +++ b/libgo/misc/cgo/testplugin/src/checkdwarf/main.go @@ -0,0 +1,106 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Usage: +// +// checkdwarf +// +// Opens , which must be an executable or a library and checks that +// there is an entry in .debug_info whose name ends in + +package main + +import ( + "debug/dwarf" + "debug/elf" + "debug/macho" + "debug/pe" + "fmt" + "os" + "strings" +) + +func usage() { + fmt.Fprintf(os.Stderr, "checkdwarf executable-or-library DIE-suffix\n") +} + +type dwarfer interface { + DWARF() (*dwarf.Data, error) +} + +func openElf(path string) dwarfer { + exe, err := elf.Open(path) + if err != nil { + return nil + } + return exe +} + +func openMacho(path string) dwarfer { + exe, err := macho.Open(path) + if err != nil { + return nil + } + return exe +} + +func openPE(path string) dwarfer { + exe, err := pe.Open(path) + if err != nil { + return nil + } + return exe +} + +func main() { + if len(os.Args) != 3 { + usage() + } + + exePath := os.Args[1] + dieSuffix := os.Args[2] + + var exe dwarfer + + for _, openfn := range []func(string) dwarfer{openMacho, openPE, openElf} { + exe = openfn(exePath) + if exe != nil { + break + } + } + + if exe == nil { + fmt.Fprintf(os.Stderr, "could not open %s\n", exePath) + os.Exit(1) + } + + data, err := exe.DWARF() + if err != nil { + fmt.Fprintf(os.Stderr, "%s: error opening DWARF: %v\n", exePath, err) + os.Exit(1) + } + + rdr := data.Reader() + for { + e, err := rdr.Next() + if err != nil { + fmt.Fprintf(os.Stderr, "%s: error reading DWARF: %v\n", exePath, err) + os.Exit(1) + } + if e == nil { + break + } + name, hasname := e.Val(dwarf.AttrName).(string) + if !hasname { + continue + } + if strings.HasSuffix(name, dieSuffix) { + // found + os.Exit(0) + } + } + + fmt.Fprintf(os.Stderr, "%s: no entry with a name ending in %q was found\n", exePath, dieSuffix) + os.Exit(1) +} diff --git a/libgo/misc/cgo/testplugin/test.bash b/libgo/misc/cgo/testplugin/test.bash index bf8ed3cd191..1b94bc4badb 100644 --- a/libgo/misc/cgo/testplugin/test.bash +++ b/libgo/misc/cgo/testplugin/test.bash @@ -32,6 +32,14 @@ GOPATH=$(pwd) go build -gcflags "$GO_GCFLAGS" -buildmode=plugin -o=unnamed1.so u GOPATH=$(pwd) go build -gcflags "$GO_GCFLAGS" -buildmode=plugin -o=unnamed2.so unnamed2/main.go GOPATH=$(pwd) go build -gcflags "$GO_GCFLAGS" host +# test that DWARF sections are emitted for plugins and programs importing "plugin" +if [ $GOOS != "darwin" ]; then + # On macOS, for some reason, the linker doesn't add debug sections to .so, + # see issue #27502. + go run src/checkdwarf/main.go plugin2.so plugin2.UnexportedNameReuse +fi +go run src/checkdwarf/main.go host main.main + LD_LIBRARY_PATH=$(pwd) ./host # Test that types and itabs get properly uniqified. diff --git a/libgo/misc/cgo/testplugin/unnamed1/main.go b/libgo/misc/cgo/testplugin/unnamed1/main.go index 5c1df086d76..caf09c9e890 100644 --- a/libgo/misc/cgo/testplugin/unnamed1/main.go +++ b/libgo/misc/cgo/testplugin/unnamed1/main.go @@ -9,7 +9,7 @@ import "C" func FuncInt() int { return 1 } -// Add a recursive type to to check that type equality across plugins doesn't +// Add a recursive type to check that type equality across plugins doesn't // crash. See https://golang.org/issues/19258 func FuncRecursive() X { return X{} } diff --git a/libgo/misc/cgo/testsanitizers/cc_test.go b/libgo/misc/cgo/testsanitizers/cc_test.go index f09ad52ceee..218e2254295 100644 --- a/libgo/misc/cgo/testsanitizers/cc_test.go +++ b/libgo/misc/cgo/testsanitizers/cc_test.go @@ -374,7 +374,7 @@ func (c *config) checkRuntime() (skip bool, err error) { } // libcgo.h sets CGO_TSAN if it detects TSAN support in the C compiler. - // Dump the preprocessor defines to check that that works. + // Dump the preprocessor defines to check that works. // (Sometimes it doesn't: see https://golang.org/issue/15983.) cmd, err := cc(c.cFlags...) if err != nil { diff --git a/libgo/misc/cgo/testshared/shared_test.go b/libgo/misc/cgo/testshared/shared_test.go index 846a27173e3..41a24efe22c 100644 --- a/libgo/misc/cgo/testshared/shared_test.go +++ b/libgo/misc/cgo/testshared/shared_test.go @@ -560,7 +560,7 @@ func TestNotes(t *testing.T) { abiHashNoteFound = true case 3: // ELF_NOTE_GODEPS_TAG if depsNoteFound { - t.Error("multiple depedency list notes") + t.Error("multiple dependency list notes") } testDepsNote(t, f, note) depsNoteFound = true @@ -578,7 +578,7 @@ func TestNotes(t *testing.T) { } // Build a GOPATH package (depBase) into a shared library that links against the goroot -// runtime, another package (dep2) that links against the first, and and an +// runtime, another package (dep2) that links against the first, and an // executable that links against dep2. func TestTwoGopathShlibs(t *testing.T) { goCmd(t, "install", "-buildmode=shared", "-linkshared", "depBase") @@ -911,3 +911,9 @@ func TestGlobal(t *testing.T) { func TestTestInstalledShared(t *testing.T) { goCmd(nil, "test", "-linkshared", "-test.short", "sync/atomic") } + +// Test generated pointer method with -linkshared. +// Issue 25065. +func TestGeneratedMethod(t *testing.T) { + goCmd(t, "install", "-buildmode=shared", "-linkshared", "issue25065") +} diff --git a/libgo/misc/cgo/testshared/src/issue25065/a.go b/libgo/misc/cgo/testshared/src/issue25065/a.go new file mode 100644 index 00000000000..979350ff24c --- /dev/null +++ b/libgo/misc/cgo/testshared/src/issue25065/a.go @@ -0,0 +1,20 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package issue25065 has a type with a method that is +// 1) referenced in a method expression +// 2) not called +// 3) not converted to an interface +// 4) is a value method but the reference is to the pointer method +// These cases avoid the call to makefuncsym from typecheckfunc, but we +// still need to call makefuncsym somehow or the symbol will not be defined. +package issue25065 + +type T int + +func (t T) M() {} + +func F() func(*T) { + return (*T).M +} diff --git a/libgo/runtime/runtime.h b/libgo/runtime/runtime.h index 9f6e251b1cd..3bb1e556835 100644 --- a/libgo/runtime/runtime.h +++ b/libgo/runtime/runtime.h @@ -394,7 +394,7 @@ void __wrap_rtems_task_variable_add(void **); */ void reflect_call(const struct __go_func_type *, FuncVal *, _Bool, _Bool, void **, void **) - __asm__ (GOSYM_PREFIX "reflect.call"); + __asm__ (GOSYM_PREFIX "runtime.reflectcall"); void runtime_panic(Eface) __asm__ (GOSYM_PREFIX "runtime.gopanic"); void runtime_panic(Eface) diff --git a/libgo/testsuite/gotest b/libgo/testsuite/gotest index dba7408a07c..b4eeb1ef4aa 100755 --- a/libgo/testsuite/gotest +++ b/libgo/testsuite/gotest @@ -311,7 +311,7 @@ x) "") ;; $goarch) ;; $goos) ;; - aix | android | darwin | dragonfly | freebsd | linux | nacl | netbsd | openbsd | plan9 | solaris | windows) + aix | android | darwin | dragonfly | freebsd | hurd | js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows) tag1=nonmatchingtag ;; 386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le·| nios2 | ppc | ppc64 | ppc64le | riscv64 | s390 | s390x | sh | shbe | sparc | sparc64 | wasm) @@ -323,7 +323,7 @@ x) "") ;; $goarch) ;; $goos) ;; - aix | android | darwin | dragonfly | freebsd | linux | nacl | netbsd | openbsd | plan9 | solaris | windows) + aix | android | darwin | dragonfly | freebsd | hurd | js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows) tag2=nonmatchingtag ;; 386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le·| nios2 | ppc | ppc64 | ppc64le | riscv64 | s390 | s390x | sh | shbe | sparc | sparc64 | wasm) -- 2.30.2